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

Generated on Wed Apr 22 12:26:30 2009 for OXID eShop CE by  doxygen 1.5.5