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