report_visitor_absolute.php

Go to the documentation of this file.
00001 <?php
00002 
00003 if ( !class_exists( "report_visitor_absolute") ) {
00007     class Report_visitor_absolute extends report_base
00008     {
00014         protected $_sThisTemplate = "report_visitor_absolute.tpl";
00015 
00021         public function drawReport()
00022         {
00023             $oDb = oxDb::getDb();
00024 
00025             $oSmarty    = $this->getSmarty();
00026             $sTime_from = $oDb->quote( date( "Y-m-d H:i:s", strtotime( $oSmarty->_tpl_vars['time_from'] ) ) );
00027             $sTime_to   = $oDb->quote( date( "Y-m-d H:i:s", strtotime( $oSmarty->_tpl_vars['time_to'] ) ) );
00028 
00029             if ( $oDb->getOne( "select 1 from oxlogs where oxtime >= $sTime_from and oxtime <= $sTime_to" ) ) {
00030                 return true;
00031             }
00032 
00033             // buyer
00034             if ( $oDb->getOne( "select 1 from oxorder where oxorderdate >= $sTime_from and oxorderdate <= $sTime_to" ) ) {
00035                 return true;
00036             }
00037 
00038             // newcustomer
00039             if ( $oDb->getOne( "select 1 from oxuser where oxcreate >= $sTime_from and oxcreate <= $sTime_to" ) ) {
00040                 return true;
00041             }
00042         }
00043 
00049         public function visitor_month()
00050         {
00051             $myConfig = $this->getConfig();
00052             $oDb = oxDb::getDb();
00053 
00054             $aDataX = array();
00055             $aDataY = array();
00056 
00057             $dTimeTo    = strtotime( oxConfig::getParameter( "time_to"));
00058             $sTime_to   = $oDb->quote( date( "Y-m-d H:i:s", $dTimeTo ) );
00059             $dTimeFrom  = mktime( 23, 59, 59, date( "m", $dTimeTo)-12, date( "d", $dTimeTo), date( "Y", $dTimeTo));
00060             $sTime_from = $oDb->quote( date( "Y-m-d H:i:s", $dTimeFrom ) );
00061 
00062             $sSQL = "select oxtime, count(*) as nrof from oxlogs where oxtime >= $sTime_from and oxtime <= $sTime_to group by oxsessid";
00063             $aTemp = array();
00064             for ( $i = 1; $i <= 12; $i++)
00065                 $aTemp[date( "m/Y", mktime( 23, 59, 59, date( "m", $dTimeFrom)+$i, date( "d", $dTimeFrom), date( "Y", $dTimeFrom)) )] = 0;
00066 
00067             $rs = $oDb->execute( $sSQL);
00068             if ($rs != false && $rs->recordCount() > 0) {
00069                 while (!$rs->EOF) {
00070                     $aTemp[date( "m/Y", strtotime( $rs->fields[0]))]++;
00071                     $rs->moveNext();
00072                 }
00073             }
00074 
00075             foreach ( $aTemp as $key => $value) {
00076                  $aDataX[$key]     = $value;
00077                 $aDataX2[$key]    = 0;
00078                 $aDataX3[$key]    = 0;
00079                 $aDataY[]         = $key;
00080             }
00081 
00082             // buyer
00083             $sSQL = "select oxorderdate from oxorder where oxorderdate >= $sTime_from and oxorderdate <= $sTime_to order by oxorderdate";
00084             $aTemp = array();
00085             $rs = $oDb->execute( $sSQL);
00086             if ($rs != false && $rs->recordCount() > 0) {
00087                 while (!$rs->EOF) {
00088                     $aTemp[date( "m/Y", strtotime( $rs->fields[0]))]++;
00089                     $rs->moveNext();
00090                 }
00091             }
00092 
00093             foreach ( $aTemp as $key => $value) {
00094                  $aDataX2[$key] = $value;
00095             }
00096 
00097             // newcustomer
00098             $sSQL = "select oxcreate from oxuser where oxcreate >= $sTime_from and oxcreate <= $sTime_to order by oxcreate";
00099             $aTemp = array();
00100             $rs = $oDb->execute( $sSQL);
00101             if ($rs != false && $rs->recordCount() > 0) {
00102                 while (!$rs->EOF) {
00103                     $aTemp[date( "m/Y", strtotime( $rs->fields[0]))]++;
00104                     $rs->moveNext();
00105                 }
00106             }
00107 
00108             foreach ( $aTemp as $key => $value) {
00109                  $aDataX3[$key] = $value;
00110             }
00111 
00112 
00113             header ("Content-type: image/png" );
00114 
00115             // New graph with a drop shadow
00116             $graph = new Graph(800, 600);
00117 
00118             $graph->setBackgroundImage( $myConfig->getAbsAdminImageDir()."/reportbgrnd.jpg", BGIMG_FILLFRAME);
00119 
00120             // Use a "text" X-scale
00121             $graph->setScale("textlin");
00122 
00123             // Label align for X-axis
00124             $graph->xaxis->setLabelAlign('center', 'top', 'right');
00125 
00126             // Label align for Y-axis
00127             $graph->yaxis->setLabelAlign('right', 'bottom');
00128 
00129             $graph->setShadow();
00130             // Description
00131             $graph->xaxis->setTickLabels( $aDataY);
00132 
00133 
00134             // Set title and subtitle
00135             $graph->title->set("Monat");
00136 
00137             // Use built in font
00138             $graph->title->setFont(FF_FONT1, FS_BOLD);
00139 
00140             $aDataFinalX = array();
00141             foreach ( $aDataX as $dData)
00142                 $aDataFinalX[] = $dData;
00143             // Create the bar plot
00144             $bplot = new BarPlot( $aDataFinalX);
00145             $bplot->setFillGradient("navy", "lightsteelblue", GRAD_VER);
00146             $bplot->setLegend("Besucher");
00147 
00148             $aDataFinalX2 = array();
00149             foreach ( $aDataX2 as $dData)
00150                 $aDataFinalX2[] = $dData;
00151             // Create the bar plot
00152             $bplot2 = new BarPlot( $aDataFinalX2);
00153             $bplot2->setFillColor ("orange");
00154             $bplot2->setLegend("Kaeufer");
00155 
00156             $aDataFinalX3 = array();
00157             foreach ( $aDataX3 as $dData)
00158                 $aDataFinalX3[] = $dData;
00159             // Create the bar plot
00160             $bplot3 = new BarPlot( $aDataFinalX3);
00161             $bplot3->setFillColor ("silver");
00162             $bplot3->setLegend("Neukunden");
00163 
00164             // Create the grouped bar plot
00165             $gbplot = new groupBarPlot (array($bplot, $bplot2, $bplot3));
00166             $graph->add( $gbplot);
00167 
00168             // Finally output the  image
00169             $graph->stroke();
00170 
00171         }
00172 
00178         public function visitor_week()
00179         {
00180             $myConfig = $this->getConfig();
00181             $oDb = oxDb::getDb();
00182 
00183             $aDataX = array();
00184             $aDataY = array();
00185 
00186             $dTimeTo    = strtotime( oxConfig::getParameter( "time_to"));
00187             $sTime_to   = $oDb->quote( date( "Y-m-d H:i:s", $dTimeTo ) );
00188             $dTimeFrom  = strtotime( oxConfig::getParameter( "time_from"));
00189             $sTime_from = $oDb->quote( date( "Y-m-d H:i:s", $dTimeFrom ) );
00190 
00191             $sSQL = "select oxtime, count(*) as nrof from oxlogs where oxtime >= $sTime_from and oxtime <= $sTime_to group by oxsessid order by oxtime";
00192             $aTemp = array();
00193             $rs = $oDb->execute( $sSQL);
00194             if ($rs != false && $rs->recordCount() > 0) {
00195                 while (!$rs->EOF) {
00196                     //$aTemp[date( "W", strtotime( $rs->fields[0]))]++;
00197                     $aTemp[oxUtilsDate::getInstance()->getWeekNumber($myConfig->getConfigParam( 'iFirstWeekDay' ), strtotime( $rs->fields[0]))]++;
00198                     $rs->moveNext();
00199                 }
00200             }
00201 
00202             // initializing
00203             list( $iFrom, $iTo ) = $this->getWeekRange();
00204             for ( $i = $iFrom; $i < $iTo; $i++ ) {
00205                 $aDataX[$i]  = 0;
00206                 $aDataX2[$i] = 0;
00207                 $aDataX3[$i] = 0;
00208                 $aDataY[]      = "KW ".$i;
00209             }
00210 
00211             foreach ( $aTemp as $key => $value) {
00212                 $aDataX[$key]  = $value;
00213                 $aDataX2[$key] = 0;
00214                 $aDataX3[$key] = 0;
00215                 $aDataY[]      = "KW ".$key;
00216             }
00217 
00218             // buyer
00219             $sSQL = "select oxorderdate from oxorder where oxorderdate >= $sTime_from and oxorderdate <= $sTime_to order by oxorderdate";
00220             $aTemp = array();
00221             $rs = $oDb->execute( $sSQL);
00222             if ($rs != false && $rs->recordCount() > 0) {
00223                 while (!$rs->EOF) {
00224                     //$aTemp[date( "W", strtotime( $rs->fields[0]))]++;
00225                     $aTemp[oxUtilsDate::getInstance()->getWeekNumber($myConfig->getConfigParam( 'iFirstWeekDay' ), strtotime( $rs->fields[0]))]++;
00226                     $rs->moveNext();
00227                 }
00228             }
00229 
00230             foreach ( $aTemp as $key => $value) {
00231                  $aDataX2[$key] = $value;
00232             }
00233 
00234             // newcustomer
00235             $sSQL = "select oxcreate from oxuser where oxcreate >= $sTime_from and oxcreate <= $sTime_to order by oxcreate";
00236             $aTemp = array();
00237             $rs = $oDb->execute( $sSQL);
00238             if ($rs != false && $rs->recordCount() > 0) {
00239                 while (!$rs->EOF) {
00240                     //$aTemp[date( "W", strtotime( $rs->fields[0]))]++;
00241                     $aTemp[oxUtilsDate::getInstance()->getWeekNumber($myConfig->getConfigParam( 'iFirstWeekDay' ), strtotime( $rs->fields[0]))]++;
00242                     $rs->moveNext();
00243                 }
00244             }
00245 
00246             foreach ( $aTemp as $key => $value) {
00247                  $aDataX3[$key] = $value;
00248             }
00249 
00250             header ("Content-type: image/png" );
00251 
00252             // New graph with a drop shadow
00253             $graph = new Graph( max( 800, count( $aDataX) * 80), 600);
00254 
00255             $graph->setBackgroundImage( $myConfig->getAbsAdminImageDir()."/reportbgrnd.jpg", BGIMG_FILLFRAME);
00256 
00257             // Use a "text" X-scale
00258             $graph->setScale("textlin");
00259 
00260             // Label align for X-axis
00261             $graph->xaxis->setLabelAlign('center', 'top', 'right');
00262 
00263             // Label align for Y-axis
00264             $graph->yaxis->setLabelAlign('right', 'bottom');
00265 
00266             $graph->setShadow();
00267             // Description
00268             $graph->xaxis->setTickLabels( $aDataY);
00269 
00270 
00271             // Set title and subtitle
00272             $graph->title->set("Woche");
00273 
00274             // Use built in font
00275             $graph->title->setFont(FF_FONT1, FS_BOLD);
00276 
00277             $aDataFinalX = array();
00278             foreach ( $aDataX as $dData)
00279                 $aDataFinalX[] = $dData;
00280             // Create the bar plot
00281             $bplot = new BarPlot( $aDataFinalX);
00282             $bplot->setFillGradient("navy", "lightsteelblue", GRAD_VER);
00283             $bplot->setLegend("Besucher");
00284 
00285             $aDataFinalX2 = array();
00286             foreach ( $aDataX2 as $dData)
00287                 $aDataFinalX2[] = $dData;
00288             // Create the bar plot
00289             $bplot2 = new BarPlot( $aDataFinalX2);
00290             $bplot2->setFillColor ("orange");
00291             $bplot2->setLegend("Kaeufer");
00292 
00293             $aDataFinalX3 = array();
00294             foreach ( $aDataX3 as $dData)
00295                 $aDataFinalX3[] = $dData;
00296             // Create the bar plot
00297             $bplot3 = new BarPlot( $aDataFinalX3);
00298             $bplot3->setFillColor ("silver");
00299             $bplot3->setLegend("Neukunden");
00300 
00301             // Create the grouped bar plot
00302             $gbplot = new groupBarPlot (array($bplot, $bplot2, $bplot3));
00303             $graph->add( $gbplot);
00304 
00305             // Finally output the  image
00306             $graph->stroke();
00307         }
00308     }
00309 }

Generated by  doxygen 1.6.2