report_base.php

Go to the documentation of this file.
00001 <?php
00002 
00006 $myConfig = oxConfig::getInstance();
00007 
00011 $sIncPath = $myConfig->getConfigParam( 'sShopDir' ).'/'.$myConfig->getConfigParam( 'sAdminDir' );
00012 
00016 DEFINE( 'USE_CACHE', false );
00017 DEFINE( 'CACHE_DIR', $myConfig->getConfigParam( 'sCompileDir' ) );
00018 
00022 require_once "$sIncPath/reports/jpgraph/jpgraph.php";
00023 require_once "$sIncPath/reports/jpgraph/jpgraph_bar.php";
00024 require_once "$sIncPath/reports/jpgraph/jpgraph_line.php";
00025 require_once "$sIncPath/reports/jpgraph/jpgraph_pie.php";
00026 require_once "$sIncPath/reports/jpgraph/jpgraph_pie3d.php";
00027 
00028 if ( !class_exists( 'report_base' ) ) {
00032 class Report_base extends oxAdminView
00033 {
00038     protected $_oSmarty = null;
00039 
00045     public function render()
00046     {
00047         return $this->_sThisTemplate;
00048     }
00049 
00057     public function setSmarty( $oSmarty )
00058     {
00059         $this->_oSmarty = $oSmarty;
00060     }
00061 
00067     public function getSmarty()
00068     {
00069         return $this->_oSmarty;
00070     }
00071 
00077     public function getWeekRange()
00078     {
00079         $myConfig = $this->getConfig();
00080 
00081         // initializing one week before current..
00082         $iFrom = oxUtilsDate::getInstance()->getWeekNumber($myConfig->getConfigParam( 'iFirstWeekDay' ), strtotime( oxConfig::getParameter( "time_from") ) );
00083         $iTo   = oxUtilsDate::getInstance()->getWeekNumber($myConfig->getConfigParam( 'iFirstWeekDay' ), strtotime( oxConfig::getParameter( "time_to") ) );
00084 
00085         return array( $iFrom - 1, $iTo + 1 );
00086     }
00087 
00098     public function getGraph( $iXSize, $iYSize, $sBackgroundImg = null, $sScaleType = "textlin" )
00099     {
00100         $sBackgroundImg = $sBackgroundImg ? $sBackgroundImg : $this->getConfig()->getImageDir( true )."/reportbgrnd.jpg";
00101 
00102         // New graph with a drop shadow
00103         $oGraph = new Graph( $iXSize, $iYSize );
00104 
00105         $oGraph->setBackgroundImage( $sBackgroundImg, BGIMG_FILLFRAME );
00106 
00107         // Use a "text" X-scale
00108         $oGraph->setScale( $sScaleType );
00109 
00110         // Label align for X-axis
00111         $oGraph->xaxis->setLabelAlign( 'center', 'top', 'right' );
00112 
00113         // Label align for Y-axis
00114         $oGraph->yaxis->setLabelAlign( 'right', 'bottom' );
00115 
00116         // shadow
00117         $oGraph->setShadow();
00118 
00119         // Use built in font
00120         $oGraph->title->setFont( FF_FONT1, FS_BOLD );
00121 
00122         return $oGraph;
00123     }
00124 }
00125 }