3 if (!class_exists(
"report_conversion_rate")) {
 
    9     class Report_conversion_rate 
extends report_base
 
   17         protected $_sThisTemplate = 
"report_conversion_rate.tpl";
 
   24         public function drawReport()
 
   28             $oSmarty = $this->getSmarty();
 
   29             $sTimeFrom = $oDb->quote(date(
"Y-m-d H:i:s", strtotime($oSmarty->_tpl_vars[
'time_from'])));
 
   30             $sTimeTo = $oDb->quote(date(
"Y-m-d H:i:s", strtotime($oSmarty->_tpl_vars[
'time_to'])));
 
   33             if ($oDb->getOne(
"select * from oxlogs where oxtime >= $sTimeFrom and oxtime <= $sTimeTo")) {
 
   38             if ($oDb->getOne(
"select 1 from oxorder where oxorderdate >= $sTimeFrom and oxorderdate <= $sTimeTo")) {
 
   46         public function visitor_month()
 
   55             $dTimeFrom = mktime(23, 59, 59, date(
"m", $dTimeTo) - 12, date(
"d", $dTimeTo), date(
"Y", $dTimeTo));
 
   57             $sTimeTo = $oDb->quote(date(
"Y-m-d H:i:s", $dTimeTo));
 
   58             $sTimeFrom = $oDb->quote(date(
"Y-m-d H:i:s", $dTimeFrom));
 
   61             $sSQL = 
"select oxtime, count(*) as nrof from oxlogs where oxtime >= $sTimeFrom and oxtime <= $sTimeTo group by oxsessid";
 
   63             for ($i = 1; $i <= 12; $i++) {
 
   64                 $aTemp[date(
"m/Y", mktime(23, 59, 59, date(
"m", $dTimeFrom) + $i, date(
"d", $dTimeFrom), date(
"Y", $dTimeFrom)))] = 0;
 
   67             $rs = $oDb->execute($sSQL);
 
   68             if ($rs != 
false && $rs->recordCount() > 0) {
 
   70                     $aTemp[date(
"m/Y", strtotime($rs->fields[0]))]++;
 
   78             foreach ($aTemp as $key => $value) {
 
   79                 $aDataX[$key] = $value;
 
   86             $sSQL = 
"select oxorderdate from oxorder where oxorderdate >= $sTimeFrom and oxorderdate <= $sTimeTo order by oxorderdate";
 
   87             $rs = $oDb->execute($sSQL);
 
   88             if ($rs != 
false && $rs->recordCount() > 0) {
 
   90                     $sKey = date(
"m/Y", strtotime($rs->fields[0]));
 
   91                     if (isset($aDataX2[$sKey])) {
 
   98             header(
"Content-type: image/png");
 
  101             $graph = 
new Graph(800, 600, 
"auto");
 
  103             $graph->setBackgroundImage(
$myConfig->getImageDir(
true) . 
"/reportbgrnd.jpg", BGIMG_FILLFRAME);
 
  106             $graph->setScale(
"textlin");
 
  107             $graph->setY2Scale(
"lin");
 
  108             $graph->y2axis->setColor(
"red");
 
  111             $graph->xaxis->setLabelAlign(
'center', 
'top', 
'right');
 
  114             $graph->yaxis->setLabelAlign(
'right', 
'bottom');
 
  118             $graph->xaxis->setTickLabels($aDataY);
 
  122             $graph->title->set(
"Monat");
 
  125             $graph->title->setFont(FF_FONT1, FS_BOLD);
 
  127             $aDataFinalX = array();
 
  128             foreach ($aDataX as $dData) {
 
  129                 $aDataFinalX[] = $dData;
 
  133             $l2plot = 
new LinePlot($aDataFinalX);
 
  134             $l2plot->setColor(
"navy");
 
  135             $l2plot->setWeight(2);
 
  136             $l2plot->setLegend(
"Besucher");
 
  138             $l2plot->value->setColor(
"navy");
 
  139             $l2plot->value->setFormat(
'% d');
 
  140             $l2plot->value->hideZero();
 
  141             $l2plot->value->show();
 
  143             $aDataFinalX2 = array();
 
  144             foreach ($aDataX2 as $dData) {
 
  145                 $aDataFinalX2[] = $dData;
 
  149             $l3plot = 
new LinePlot($aDataFinalX2);
 
  150             $l3plot->setColor(
"orange");
 
  151             $l3plot->setWeight(2);
 
  152             $l3plot->setLegend(
"Bestellungen");
 
  154             $l3plot->value->setColor(
'orange');
 
  155             $l3plot->value->setFormat(
'% d');
 
  156             $l3plot->value->hideZero();
 
  157             $l3plot->value->show();
 
  161             for ($iCtr = 0; $iCtr < count($aDataFinalX); $iCtr++) {
 
  162                 if ($aDataFinalX[$iCtr] != 0 && $aDataFinalX2[$iCtr] != 0) {
 
  163                     $l1datay[] = 100 / ($aDataFinalX[$iCtr] / $aDataFinalX2[$iCtr]);
 
  169             $l1plot = 
new LinePlot($l1datay);
 
  170             $l1plot->setColor(
"red");
 
  171             $l1plot->setWeight(2);
 
  172             $l1plot->setLegend(
"Conversion rate (%)");
 
  173             $l1plot->value->setColor(
'red');
 
  174             $l1plot->value->setFormat(
'% 0.2f%%');
 
  175             $l1plot->value->hideZero();
 
  176             $l1plot->value->show();
 
  179             $graph->addY2($l1plot);
 
  180             $graph->add($l2plot);
 
  181             $graph->add($l3plot);
 
  191         public function visitor_week()
 
  201             $sTimeTo = $oDb->quote(date(
"Y-m-d H:i:s", strtotime(
oxRegistry::getConfig()->getRequestParameter(
"time_to"))));
 
  202             $sTimeFrom = $oDb->quote(date(
"Y-m-d H:i:s", strtotime(
oxRegistry::getConfig()->getRequestParameter(
"time_from"))));
 
  204             $sSQL = 
"select oxtime, count(*) as nrof from oxlogs where oxtime >= $sTimeFrom and oxtime <= $sTimeTo group by oxsessid order by oxtime";
 
  206             $rs = $oDb->execute($sSQL);
 
  207             if ($rs != 
false && $rs->recordCount() > 0) {
 
  210                     $aTemp[
oxRegistry::get(
"oxUtilsDate")->getWeekNumber(
$myConfig->getConfigParam(
'iFirstWeekDay'), strtotime($rs->fields[0]))]++;
 
  217             list($iFrom, $iTo) = $this->getWeekRange();
 
  218             for ($i = $iFrom; $i < $iTo; $i++) {
 
  222                 $aDataY[] = 
"KW " . $i;
 
  225             foreach ($aTemp as $key => $value) {
 
  226                 $aDataX[$key] = $value;
 
  229                 $aDataY[] = 
"KW " . $key;
 
  233             $sSQL = 
"select oxorderdate from oxorder where oxorderdate >= $sTimeFrom and oxorderdate <= $sTimeTo order by oxorderdate";
 
  234             $rs = $oDb->execute($sSQL);
 
  235             if ($rs != 
false && $rs->recordCount() > 0) {
 
  237                     $sKey = 
oxRegistry::get(
"oxUtilsDate")->getWeekNumber(
$myConfig->getConfigParam(
'iFirstWeekDay'), strtotime($rs->fields[0]));
 
  238                     if (isset($aDataX2[$sKey])) {
 
  246             $sSQL = 
"select oxtime, oxsessid from oxlogs where oxtime >= $sTimeFrom and oxtime <= $sTimeTo group by oxsessid order by oxtime";
 
  247             $rs = $oDb->execute($sSQL);
 
  248             if ($rs != 
false && $rs->recordCount() > 0) {
 
  250                     $sKey = 
oxRegistry::get(
"oxUtilsDate")->getWeekNumber(
$myConfig->getConfigParam(
'iFirstWeekDay'), strtotime($rs->fields[0]));
 
  251                     if (isset($aDataX3[$sKey])) {
 
  258             header(
"Content-type: image/png");
 
  261             $graph = 
new Graph(max(800, count($aDataX) * 80), 600);
 
  263             $graph->setBackgroundImage(
$myConfig->getImageDir(
true) . 
"/reportbgrnd.jpg", BGIMG_FILLFRAME);
 
  266             $graph->setScale(
"textlin");
 
  267             $graph->setY2Scale(
"lin");
 
  268             $graph->y2axis->setColor(
"red");
 
  271             $graph->xaxis->setLabelAlign(
'center', 
'top', 
'right');
 
  274             $graph->yaxis->setLabelAlign(
'right', 
'bottom');
 
  278             $graph->xaxis->setTickLabels($aDataY);
 
  282             $graph->title->set(
"Woche");
 
  285             $graph->title->setFont(FF_FONT1, FS_BOLD);
 
  287             $aDataFinalX = array();
 
  288             foreach ($aDataX as $dData) {
 
  289                 $aDataFinalX[] = $dData;
 
  293             $l2plot = 
new LinePlot($aDataFinalX);
 
  294             $l2plot->setColor(
"navy");
 
  295             $l2plot->setWeight(2);
 
  296             $l2plot->setLegend(
"Besucher");
 
  297             $l2plot->value->setColor(
"navy");
 
  298             $l2plot->value->setFormat(
'% d');
 
  299             $l2plot->value->hideZero();
 
  300             $l2plot->value->show();
 
  302             $aDataFinalX2 = array();
 
  303             foreach ($aDataX2 as $dData) {
 
  304                 $aDataFinalX2[] = $dData;
 
  308             $l3plot = 
new LinePlot($aDataFinalX2);
 
  309             $l3plot->setColor(
"orange");
 
  310             $l3plot->setWeight(2);
 
  311             $l3plot->setLegend(
"Bestellungen");
 
  313             $l3plot->value->setColor(
"orange");
 
  314             $l3plot->value->setFormat(
'% d');
 
  315             $l3plot->value->hideZero();
 
  316             $l3plot->value->show();
 
  320             for ($iCtr = 0; $iCtr < count($aDataFinalX); $iCtr++) {
 
  321                 if ($aDataFinalX[$iCtr] != 0 && $aDataFinalX2[$iCtr] != 0) {
 
  322                     $l1datay[] = 100 / ($aDataFinalX[$iCtr] / $aDataFinalX2[$iCtr]);
 
  327             $l1plot = 
new LinePlot($l1datay);
 
  328             $l1plot->setColor(
"red");
 
  329             $l1plot->setWeight(2);
 
  330             $l1plot->setLegend(
"Conversion rate (%)");
 
  331             $l1plot->value->setColor(
'red');
 
  332             $l1plot->value->setFormat(
'% 0.4f%%');
 
  333             $l1plot->value->hideZero();
 
  334             $l1plot->value->show();
 
  337             $graph->addY2($l1plot);
 
  338             $graph->add($l2plot);
 
  339             $graph->add($l3plot);