report_canceled_orders.php

Go to the documentation of this file.
00001 <?php
00002 
00003 if ( !class_exists( 'report_canceled_orders' ) ) {
00007     class Report_canceled_orders extends report_base
00008     {
00014         protected $_sThisTemplate = "report_canceled_orders.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 
00034             $sSQL = "select oxtime, count(*) as nrof from oxlogs where oxtime >= '$sTime_from' and oxtime <= '$sTime_to' group by oxsessid";
00035             //die($sSQL);
00036             $aTemp = array();
00037             for ( $i = 1; $i <= 12; $i++)
00038                 $aTemp[date( "m/Y", mktime(23, 59, 59, date( "m", $dTimeFrom)+$i, date( "d", $dTimeFrom), date( "Y", $dTimeFrom)) )] = 0;
00039 
00040             $rs = oxDb::getDb()->execute( $sSQL);
00041             $blData = false;
00042             if ($rs != false && $rs->recordCount() > 0) {
00043                 while (!$rs->EOF) {
00044                     $aTemp[date( "m/Y", strtotime( $rs->fields[0]))]++;
00045                     $rs->moveNext();
00046                     $blData = true;
00047                 }
00048             }
00049 
00050             $aDataX2  = array();
00051             $aDataX3  = array();
00052             if ($blData) {
00053                 foreach ( $aTemp as $key => $value) {
00054                     $aDataX[$key]   = $value;
00055                     $aDataX2[$key]  = 0;
00056                     $aDataX3[$key]  = 0;
00057                     $aDataX4[$key]  = 0;
00058                     $aDataX5[$key]  = 0;
00059                     $aDataX6[$key]  = 0;
00060                     $aDataY[]       = $key;
00061                 }
00062             }
00063             // collects sessions what executed 'order' function
00064             $sSQL = "select oxtime, oxsessid from `oxlogs` where oxclass = 'order' and oxfnc = 'execute' and oxtime >= '$sTime_from' and oxtime <= '$sTime_to' group by oxsessid";
00065             $aTempOrder = array();
00066             $rs = oxDb::getDb()->execute( $sSQL);
00067             if ($rs != false && $rs->recordCount() > 0) {
00068                 while (!$rs->EOF) {
00069                     $aTempOrder[$rs->fields[1]] = $rs->fields[0];
00070                     $rs->moveNext();
00071                 }
00072             }
00073 
00074             // collects sessions what executed order class
00075             $sSQL = "select oxtime, oxsessid from `oxlogs` where oxclass = 'order' and oxtime >= '$sTime_from' and oxtime <= '$sTime_to' group by oxsessid";
00076             $aTempExecOrders = array();
00077             $aTempExecOrdersSessions = array();
00078             $rs = oxDb::getDb()->execute( $sSQL);
00079             if ($rs != false && $rs->recordCount() > 0) {
00080                 while (!$rs->EOF) {
00081                     if (!isset($aTempOrder[$rs->fields[1]])) {
00082                         $aTempExecOrdersSessions[$rs->fields[1]] = 1;
00083                         $aTempExecOrders[date( "m/Y", strtotime( $rs->fields[0]))]++;
00084                     }
00085                     $rs->moveNext();
00086                 }
00087             }
00088 
00089             foreach ( $aTempExecOrders as $key => $value) {
00090                 if (isset($aDataX6[$key]))
00091                     $aDataX6[$key] = $value;
00092             }
00093 
00094             // collects sessions what executed payment class
00095             $sSQL = "select oxtime, oxsessid from `oxlogs` where oxclass = 'payment' and oxtime >= '$sTime_from' and oxtime <= '$sTime_to' group by oxsessid";
00096             $aTempPayment = array();
00097             $aTempPaymentSessions = array();
00098             $rs = oxDb::getDb()->execute( $sSQL);
00099             if ($rs != false && $rs->recordCount() > 0) {
00100                 while (!$rs->EOF) {
00101                     if (!isset($aTempOrder[$rs->fields[1]]) && !isset($aTempExecOrdersSessions[$rs->fields[1]])) {
00102                         $aTempPaymentSessions[$rs->fields[1]] = 1;
00103                         $aTempPayment[date( "m/Y", strtotime( $rs->fields[0]))]++;
00104                     }
00105                     $rs->moveNext();
00106                 }
00107             }
00108 
00109             foreach ( $aTempPayment as $key => $value) {
00110                 if (isset($aDataX2[$key]))
00111                     $aDataX2[$key] = $value;
00112             }
00113 
00114             // collects sessions what executed 'user' class
00115             $sSQL = "select oxtime, oxsessid from `oxlogs` where oxclass = 'user' and oxtime >= '$sTime_from' and oxtime <= '$sTime_to' group by oxsessid";
00116             $aTempUser = array();
00117             $aTempUserSessions = array();
00118             $rs = oxDb::getDb()->execute( $sSQL);
00119             if ($rs != false && $rs->recordCount() > 0) {
00120                 while (!$rs->EOF) {
00121                     if (!isset($aTempOrder[$rs->fields[1]]) && !isset($aTempPaymentSessions[$rs->fields[1]]) && !isset($aTempExecOrdersSessions[$rs->fields[1]])) {
00122                         $aTempUserSessions[$rs->fields[1]] = 1;
00123                         $aTempUser[date( "m/Y", strtotime( $rs->fields[0]))]++;
00124                     }
00125                     $rs->moveNext();
00126                 }
00127             }
00128 
00129             foreach ( $aTempUser as $key => $value) {
00130                 if (isset($aDataX3[$key]))
00131                     $aDataX3[$key] = $value;
00132             }
00133 
00134             // collects sessions what executed 'tobasket' function
00135             $sSQL = "select oxtime, oxsessid from `oxlogs` where oxclass = 'basket' and oxtime >= '$sTime_from' and oxtime <= '$sTime_to' group by oxsessid";
00136             $aTempBasket = array();
00137             $rs = oxDb::getDb()->execute( $sSQL);
00138             if ($rs != false && $rs->recordCount() > 0) {
00139                 while (!$rs->EOF) {
00140                     if (!$aTempOrder[$rs->fields[1]] && !isset($aTempPaymentSessions[$rs->fields[1]]) && !isset($aTempUserSessions[$rs->fields[1]]) && !isset($aTempExecOrdersSessions[$rs->fields[1]]))
00141                         $aTempBasket[date( "m/Y", strtotime( $rs->fields[0]))]++;
00142                     $rs->moveNext();
00143                 }
00144             }
00145 
00146             foreach ( $aTempBasket as $key => $value) {
00147                 if (isset($aDataX4[$key]))
00148                     $aDataX4[$key] = $value;
00149             }
00150 
00151             // orders made
00152             $sSQL = "select oxorderdate from oxorder where oxorderdate >= '$sTime_from' and oxorderdate <= '$sTime_to' order by oxorderdate";
00153             $aTemp = array();
00154             $rs = oxDb::getDb()->execute( $sSQL);
00155             if ($rs != false && $rs->recordCount() > 0) {
00156                 while (!$rs->EOF) {
00157                     $aTemp[date( "m/Y", strtotime( $rs->fields[0]))]++;
00158                     $rs->moveNext();
00159                 }
00160             }
00161 
00162             foreach ( $aTemp as $key => $value) {
00163                 if (isset($aDataX5[$key]))
00164                     $aDataX5[$key] = $value;
00165             }
00166 
00167             header ("Content-type: image/png" );
00168 
00169             // New graph with a drop shadow
00170             $graph = new Graph(800, 600);
00171 
00172             $graph->setBackgroundImage( $myConfig->getAbsAdminImageDir()."/reportbgrnd.jpg", BGIMG_FILLFRAME);
00173 
00174             // Use a "text" X-scale
00175             $graph->setScale("textlin");
00176 
00177             // Label align for X-axis
00178             $graph->xaxis->setLabelAlign('center', 'top', 'right');
00179 
00180             // Label align for Y-axis
00181             $graph->yaxis->setLabelAlign('right', 'bottom');
00182 
00183             $graph->setShadow();
00184             // Description
00185             $graph->xaxis->setTickLabels( $aDataY);
00186 
00187 
00188             // Set title and subtitle
00189             $graph->title->set("Monat");
00190 
00191             // Use built in font
00192             $graph->title->setFont(FF_FONT1, FS_BOLD);
00193 
00194             $aDataFinalX2 = array();
00195             foreach ( $aDataX2 as $dData)
00196                 $aDataFinalX2[] = $dData;
00197 
00198             // Create the bar plot
00199             $bplot2 = new BarPlot( $aDataFinalX2);
00200             $bplot2->setFillColor ("#9966cc");
00201             //$bplot2->setLegend("Kaeufer");
00202             $bplot2->setLegend("Best.Abbr. in Bezahlmethoden");
00203 
00204             $aDataFinalX3 = array();
00205             foreach ( $aDataX3 as $dData)
00206                 $aDataFinalX3[] = $dData;
00207 
00208             // Create the bar plot
00209             $bplot3 = new BarPlot( $aDataFinalX3);
00210             $bplot3->setFillColor ("#ffcc00");
00211             $bplot3->setLegend("Best.Abbr. in Benutzer");
00212 
00213             $aDataFinalX4 = array();
00214             foreach ( $aDataX4 as $dData)
00215                 $aDataFinalX4[] = $dData;
00216 
00217             // Create the bar plot
00218             $bplot4 = new BarPlot( $aDataFinalX4);
00219             $bplot4->setFillColor ("#6699ff");
00220             $bplot4->setLegend("Best.Abbr. in Warenkorb");
00221 
00222             $aDataFinalX6 = array();
00223             foreach ( $aDataX6 as $dData)
00224                 $aDataFinalX6[] = $dData;
00225 
00226             // Create the bar plot
00227             $bplot6 = new BarPlot( $aDataFinalX6);
00228             $bplot6->setFillColor ("#ff0099");
00229             $bplot6->setLegend("Best.Abbr. in Bestellbestaetigung");
00230 
00231             $aDataFinalX5 = array();
00232             foreach ( $aDataX5 as $dData)
00233                 $aDataFinalX5[] = $dData;
00234 
00235             // Create the bar plot
00236             $bplot5 = new BarPlot( $aDataFinalX5);
00237             $bplot5->setFillColor ("silver");
00238             $bplot5->setLegend("Bestellungen");
00239 
00240             // Create the grouped bar plot
00241             $gbplot = new groupBarPlot (array($bplot4, $bplot3, $bplot2, $bplot6, $bplot5));
00242             $graph->add( $gbplot);
00243 
00244             // Finally output the  image
00245             $graph->stroke();
00246 
00247         }
00248 
00254         public function visitor_week()
00255         {
00256             $myConfig = $this->getConfig();
00257 
00258             $aDataX = array();
00259             $aDataY = array();
00260 
00261             $dTimeTo    = strtotime( oxConfig::getParameter( "time_to"));
00262             $sTime_to   = date( "Y-m-d H:i:s", $dTimeTo);
00263             $dTimeFrom  = strtotime( oxConfig::getParameter( "time_from"));
00264             $sTime_from = date( "Y-m-d H:i:s", $dTimeFrom);
00265 
00266             $sSQL = "select oxtime, count(*) as nrof from oxlogs where oxtime >= '$sTime_from' and oxtime <= '$sTime_to' group by oxsessid order by oxtime";
00267 
00268             $aTemp = array();
00269             $rs = oxDb::getDb()->execute( $sSQL);
00270             $blData = false;
00271             if ($rs != false && $rs->recordCount() > 0) {
00272                 while (!$rs->EOF) {
00273                     $aTemp[oxUtilsDate::getInstance()->getWeekNumber($myConfig->getConfigParam( 'iFirstWeekDay' ), strtotime( $rs->fields[0]))]++;
00274                     $rs->moveNext();
00275                     $blData = true;
00276                 }
00277             }
00278 
00279             $aDataX2  = array();
00280             $aDataX3  = array();
00281             if ($blData) {
00282                 foreach ( $aTemp as $key => $value) {
00283                     $aDataX[$key]   = $value;
00284                     $aDataX2[$key]  = 0;
00285                     $aDataX3[$key]  = 0;
00286                     $aDataX4[$key]  = 0;
00287                     $aDataX5[$key]  = 0;
00288                     $aDataX6[$key]  = 0;
00289                     $aDataY[]       = "KW ".$key;
00290                 }
00291             }
00292             // collects sessions what executed 'order' function
00293             $sSQL = "select oxtime, oxsessid FROM `oxlogs` where oxclass = 'order' and oxfnc = 'execute' and oxtime >= '$sTime_from' and oxtime <= '$sTime_to' group by oxsessid";
00294             $aTempOrder = array();
00295             $rs = oxDb::getDb()->execute( $sSQL);
00296             if ($rs != false && $rs->recordCount() > 0) {
00297                 while (!$rs->EOF) {
00298                     $aTempOrder[$rs->fields[1]] = $rs->fields[0];
00299                     $rs->moveNext();
00300                 }
00301             }
00302 
00303             // collects sessions what executed order class
00304             $sSQL = "select oxtime, oxsessid from `oxlogs` where oxclass = 'order' and oxtime >= '$sTime_from' and oxtime <= '$sTime_to' group by oxsessid";
00305             $aTempExecOrders = array();
00306             $aTempExecOrdersSessions = array();
00307             $rs = oxDb::getDb()->execute( $sSQL);
00308             if ($rs != false && $rs->recordCount() > 0) {
00309                 while (!$rs->EOF) {
00310                     if (!isset($aTempOrder[$rs->fields[1]])) {
00311                         $aTempExecOrdersSessions[$rs->fields[1]] = 1;
00312                         //$aTempExecOrders[date( "W", strtotime( $rs->fields[0]))]++;
00313                         $aTempExecOrders[oxUtilsDate::getInstance()->getWeekNumber($myConfig->getConfigParam( 'iFirstWeekDay' ), strtotime( $rs->fields[0]))]++;
00314                     }
00315                     $rs->moveNext();
00316                 }
00317             }
00318 
00319             foreach ( $aTempExecOrders as $key => $value) {
00320                 if (isset($aDataX6[$key]))
00321                     $aDataX6[$key] = $value;
00322             }
00323 
00324             // collects sessions what executed payment class
00325             $sSQL = "select oxtime, oxsessid from `oxlogs` where oxclass = 'payment' and oxtime >= '$sTime_from' and oxtime <= '$sTime_to' group by oxsessid";
00326             $aTempPayment = array();
00327             $aTempPaymentSessions = array();
00328             $rs = oxDb::getDb()->execute( $sSQL);
00329             if ($rs != false && $rs->recordCount() > 0) {
00330                 while (!$rs->EOF) {
00331                     if (!isset($aTempOrder[$rs->fields[1]]) && !isset($aTempExecOrdersSessions[$rs->fields[1]])) {
00332                         $aTempPaymentSessions[$rs->fields[1]] = 1;
00333                         //$aTempPayment[date( "W", strtotime( $rs->fields[0]))]++;
00334                         $aTempPayment[oxUtilsDate::getInstance()->getWeekNumber($myConfig->getConfigParam( 'iFirstWeekDay' ), strtotime( $rs->fields[0]))]++;
00335                     }
00336                     $rs->moveNext();
00337                 }
00338             }
00339 
00340             foreach ( $aTempPayment as $key => $value) {
00341                 if (isset($aDataX2[$key]))
00342                     $aDataX2[$key] = $value;
00343             }
00344 
00345             // collects sessions what executed 'user' class
00346             $sSQL = "select oxtime, oxsessid from `oxlogs` where oxclass = 'user' and oxtime >= '$sTime_from' and oxtime <= '$sTime_to' group by oxsessid";
00347             $aTempUser = array();
00348             $aTempUserSessions = array();
00349             $rs = oxDb::getDb()->execute( $sSQL);
00350             if ($rs != false && $rs->recordCount() > 0) {
00351                 while (!$rs->EOF) {
00352                     if (!isset($aTempOrder[$rs->fields[1]]) && !isset($aTempPaymentSessions[$rs->fields[1]]) && !isset($aTempExecOrdersSessions[$rs->fields[1]])) {
00353                         $aTempUserSessions[$rs->fields[1]] = 1;
00354                         //$aTempUser[date( "W", strtotime( $rs->fields[0]))]++;
00355                         $aTempUser[oxUtilsDate::getInstance()->getWeekNumber($myConfig->getConfigParam( 'iFirstWeekDay' ), strtotime( $rs->fields[0]))]++;
00356                     }
00357                     $rs->moveNext();
00358                 }
00359             }
00360 
00361             foreach ( $aTempUser as $key => $value) {
00362                 if (isset($aDataX3[$key]))
00363                     $aDataX3[$key] = $value;
00364             }
00365 
00366             // collects sessions what executed 'tobasket' function
00367             $sSQL = "select oxtime, oxsessid from `oxlogs` where oxclass = 'basket' and oxtime >= '$sTime_from' and oxtime <= '$sTime_to' group by oxsessid";
00368             $aTempBasket = array();
00369             $rs = oxDb::getDb()->execute( $sSQL);
00370             if ($rs != false && $rs->recordCount() > 0) {
00371                 while (!$rs->EOF) {
00372                     if (!$aTempOrder[$rs->fields[1]] && !isset($aTempPaymentSessions[$rs->fields[1]]) && !isset($aTempUserSessions[$rs->fields[1]]) && !isset($aTempExecOrdersSessions[$rs->fields[1]]))
00373                         $aTempBasket[oxUtilsDate::getInstance()->getWeekNumber($myConfig->getConfigParam( 'iFirstWeekDay' ), strtotime( $rs->fields[0]))]++;
00374                     $rs->moveNext();
00375                 }
00376             }
00377 
00378             foreach ( $aTempBasket as $key => $value) {
00379                 if (isset($aDataX4[$key]))
00380                     $aDataX4[$key] = $value;
00381             }
00382 
00383             // orders made
00384             $sSQL = "select oxorderdate from oxorder where oxorderdate >= '$sTime_from' and oxorderdate <= '$sTime_to' order by oxorderdate";
00385             $aTemp = array();
00386             $rs = oxDb::getDb()->execute( $sSQL);
00387             if ($rs != false && $rs->recordCount() > 0) {
00388                 while (!$rs->EOF) {
00389                     //$aTemp[date( "W", strtotime( $rs->fields[0]))]++;
00390                     $aTemp[oxUtilsDate::getInstance()->getWeekNumber($myConfig->getConfigParam( 'iFirstWeekDay' ), strtotime( $rs->fields[0]))]++;
00391                     $rs->moveNext();
00392                 }
00393             }
00394 
00395             foreach ( $aTemp as $key => $value) {
00396                 if (isset($aDataX5[$key]))
00397                     $aDataX5[$key] = $value;
00398             }
00399 
00400 
00401             header ("Content-type: image/png" );
00402 
00403             // New graph with a drop shadow
00404             $graph = new Graph( max( 800, count( $aDataX) * 80), 600);
00405 
00406             $graph->setBackgroundImage( $myConfig->getAbsAdminImageDir()."/reportbgrnd.jpg", BGIMG_FILLFRAME);
00407 
00408             // Use a "text" X-scale
00409             $graph->setScale("textlin");
00410 
00411             // Label align for X-axis
00412             $graph->xaxis->setLabelAlign('center', 'top', 'right');
00413 
00414             // Label align for Y-axis
00415             $graph->yaxis->setLabelAlign('right', 'bottom');
00416 
00417             $graph->setShadow();
00418             // Description
00419             $graph->xaxis->setTickLabels( $aDataY);
00420 
00421 
00422             // Set title and subtitle
00423             $graph->title->set("Woche");
00424 
00425             // Use built in font
00426             $graph->title->setFont(FF_FONT1, FS_BOLD);
00427 
00428             $aDataFinalX2 = array();
00429             foreach ( $aDataX2 as $dData)
00430                 $aDataFinalX2[] = $dData;
00431 
00432             // Create the bar plot
00433             $bplot2 = new BarPlot( $aDataFinalX2);
00434             $bplot2->setFillColor ("#9966cc");
00435             $bplot2->setLegend("Best.Abbr. in Bezahlmethoden");
00436 
00437             $aDataFinalX3 = array();
00438             foreach ( $aDataX3 as $dData)
00439                 $aDataFinalX3[] = $dData;
00440 
00441             // Create the bar plot
00442             $bplot3 = new BarPlot( $aDataFinalX3);
00443             $bplot3->setFillColor ("#ffcc00");
00444             $bplot3->setLegend("Best.Abbr. in Benutzer");
00445 
00446             $aDataFinalX4 = array();
00447             foreach ( $aDataX4 as $dData)
00448                 $aDataFinalX4[] = $dData;
00449 
00450             // Create the bar plot
00451             $bplot4 = new BarPlot( $aDataFinalX4);
00452             $bplot4->setFillColor ("#6699ff");
00453             $bplot4->setLegend("Best.Abbr. in Warenkorb");
00454 
00455             $aDataFinalX6 = array();
00456             foreach ( $aDataX6 as $dData)
00457                 $aDataFinalX6[] = $dData;
00458 
00459             // Create the bar plot
00460             $bplot6 = new BarPlot( $aDataFinalX6);
00461             $bplot6->setFillColor ("#ff0099");
00462             $bplot6->setLegend("Best.Abbr. in Bestellbestaetigung");
00463 
00464             $aDataFinalX5 = array();
00465             foreach ( $aDataX5 as $dData)
00466                 $aDataFinalX5[] = $dData;
00467 
00468             // Create the bar plot
00469             $bplot5 = new BarPlot( $aDataFinalX5);
00470             $bplot5->setFillColor ("silver");
00471             $bplot5->setLegend("Bestellungen");
00472 
00473             // Create the grouped bar plot
00474             $gbplot = new groupBarPlot (array($bplot4, $bplot3, $bplot2, $bplot6, $bplot5));
00475             $graph->add( $gbplot);
00476 
00477             // Finally output the  image
00478             $graph->stroke();
00479         }
00480     }
00481 }

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