report_canceled_orders.php

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

Generated on Thu Dec 4 12:04:56 2008 for OXID eShop CE by  doxygen 1.5.5