3 if ( !class_exists(
"report_visitor_absolute") ) {
7 class Report_visitor_absolute
extends report_base
14 protected $_sThisTemplate =
"report_visitor_absolute.tpl";
21 public function drawReport()
25 $oSmarty = $this->getSmarty();
26 $sTimeFrom = $oDb->quote( date(
"Y-m-d H:i:s", strtotime( $oSmarty->_tpl_vars[
'time_from'] ) ) );
27 $sTimeTo = $oDb->quote( date(
"Y-m-d H:i:s", strtotime( $oSmarty->_tpl_vars[
'time_to'] ) ) );
29 if ( $oDb->getOne(
"select 1 from oxlogs where oxtime >= $sTimeFrom and oxtime <= $sTimeTo" ) ) {
34 if ( $oDb->getOne(
"select 1 from oxorder where oxorderdate >= $sTimeFrom and oxorderdate <= $sTimeTo" ) ) {
39 if ( $oDb->getOne(
"select 1 from oxuser where oxcreate >= $sTimeFrom and oxcreate <= $sTimeTo" ) ) {
49 public function visitor_month()
58 $dTimeFrom = mktime( 23, 59, 59, date(
"m", $dTimeTo)-12, date(
"d", $dTimeTo), date(
"Y", $dTimeTo));
60 $sTimeTo = $oDb->quote( date(
"Y-m-d H:i:s", $dTimeTo ) );
61 $sTimeFrom = $oDb->quote( date(
"Y-m-d H:i:s", $dTimeFrom ) );
63 $sSQL =
"select oxtime, count(*) as nrof from oxlogs where oxtime >= $sTimeFrom and oxtime <= $sTimeTo group by oxsessid";
65 for ( $i = 1; $i <= 12; $i++)
66 $aTemp[date(
"m/Y", mktime( 23, 59, 59, date(
"m", $dTimeFrom)+$i, date(
"d", $dTimeFrom), date(
"Y", $dTimeFrom)) )] = 0;
68 $rs = $oDb->execute( $sSQL);
69 if ($rs !=
false && $rs->recordCount() > 0) {
71 $aTemp[date(
"m/Y", strtotime( $rs->fields[0]))]++;
76 foreach ( $aTemp as $key => $value) {
77 $aDataX[$key] = $value;
84 $sSQL =
"select oxorderdate from oxorder where oxorderdate >= $sTimeFrom and oxorderdate <= $sTimeTo order by oxorderdate";
86 $rs = $oDb->execute( $sSQL);
87 if ($rs !=
false && $rs->recordCount() > 0) {
89 $aTemp[date(
"m/Y", strtotime( $rs->fields[0]))]++;
94 foreach ( $aTemp as $key => $value) {
95 $aDataX2[$key] = $value;
99 $sSQL =
"select oxcreate from oxuser where oxcreate >= $sTimeFrom and oxcreate <= $sTimeTo order by oxcreate";
101 $rs = $oDb->execute( $sSQL);
102 if ($rs !=
false && $rs->recordCount() > 0) {
104 $aTemp[date(
"m/Y", strtotime( $rs->fields[0]))]++;
109 foreach ( $aTemp as $key => $value) {
110 $aDataX3[$key] = $value;
114 header (
"Content-type: image/png" );
117 $graph =
new Graph(800, 600);
119 $graph->setBackgroundImage(
$myConfig->getImageDir(
true).
"/reportbgrnd.jpg", BGIMG_FILLFRAME);
122 $graph->setScale(
"textlin");
125 $graph->xaxis->setLabelAlign(
'center',
'top',
'right');
128 $graph->yaxis->setLabelAlign(
'right',
'bottom');
132 $graph->xaxis->setTickLabels( $aDataY);
136 $graph->title->set(
"Monat");
139 $graph->title->setFont(FF_FONT1, FS_BOLD);
141 $aDataFinalX = array();
142 foreach ( $aDataX as $dData)
143 $aDataFinalX[] = $dData;
145 $bplot =
new BarPlot( $aDataFinalX);
146 $bplot->setFillGradient(
"navy",
"lightsteelblue", GRAD_VER);
147 $bplot->setLegend(
"Besucher");
149 $aDataFinalX2 = array();
150 foreach ( $aDataX2 as $dData)
151 $aDataFinalX2[] = $dData;
153 $bplot2 =
new BarPlot( $aDataFinalX2);
154 $bplot2->setFillColor (
"orange");
155 $bplot2->setLegend(
"Kaeufer");
157 $aDataFinalX3 = array();
158 foreach ( $aDataX3 as $dData)
159 $aDataFinalX3[] = $dData;
161 $bplot3 =
new BarPlot( $aDataFinalX3);
162 $bplot3->setFillColor (
"silver");
163 $bplot3->setLegend(
"Neukunden");
166 $gbplot =
new groupBarPlot (array($bplot, $bplot2, $bplot3));
167 $graph->add( $gbplot);
179 public function visitor_week()
190 $sSQL =
"select oxtime, count(*) as nrof from oxlogs where oxtime >= $sTimeFrom and oxtime <= $sTimeTo group by oxsessid order by oxtime";
192 $rs = $oDb->execute( $sSQL);
193 if ($rs !=
false && $rs->recordCount() > 0) {
196 $aTemp[
oxRegistry::get(
"oxUtilsDate")->getWeekNumber(
$myConfig->getConfigParam(
'iFirstWeekDay' ), strtotime( $rs->fields[0]))]++;
202 list( $iFrom, $iTo ) = $this->getWeekRange();
203 for ( $i = $iFrom; $i < $iTo; $i++ ) {
207 $aDataY[] =
"KW ".$i;
210 foreach ( $aTemp as $key => $value) {
211 $aDataX[$key] = $value;
214 $aDataY[] =
"KW ".$key;
218 $sSQL =
"select oxorderdate from oxorder where oxorderdate >= $sTimeFrom and oxorderdate <= $sTimeTo order by oxorderdate";
220 $rs = $oDb->execute( $sSQL);
221 if ($rs !=
false && $rs->recordCount() > 0) {
224 $aTemp[
oxRegistry::get(
"oxUtilsDate")->getWeekNumber(
$myConfig->getConfigParam(
'iFirstWeekDay' ), strtotime( $rs->fields[0]))]++;
229 foreach ( $aTemp as $key => $value) {
230 $aDataX2[$key] = $value;
234 $sSQL =
"select oxcreate from oxuser where oxcreate >= $sTimeFrom and oxcreate <= $sTimeTo order by oxcreate";
236 $rs = $oDb->execute( $sSQL);
237 if ($rs !=
false && $rs->recordCount() > 0) {
240 $aTemp[
oxRegistry::get(
"oxUtilsDate")->getWeekNumber(
$myConfig->getConfigParam(
'iFirstWeekDay' ), strtotime( $rs->fields[0]))]++;
245 foreach ( $aTemp as $key => $value) {
246 $aDataX3[$key] = $value;
249 header (
"Content-type: image/png" );
252 $graph =
new Graph( max( 800, count( $aDataX) * 80), 600);
254 $graph->setBackgroundImage(
$myConfig->getImageDir(
true).
"/reportbgrnd.jpg", BGIMG_FILLFRAME);
257 $graph->setScale(
"textlin");
260 $graph->xaxis->setLabelAlign(
'center',
'top',
'right');
263 $graph->yaxis->setLabelAlign(
'right',
'bottom');
267 $graph->xaxis->setTickLabels( $aDataY);
271 $graph->title->set(
"Woche");
274 $graph->title->setFont(FF_FONT1, FS_BOLD);
276 $aDataFinalX = array();
277 foreach ( $aDataX as $dData)
278 $aDataFinalX[] = $dData;
280 $bplot =
new BarPlot( $aDataFinalX);
281 $bplot->setFillGradient(
"navy",
"lightsteelblue", GRAD_VER);
282 $bplot->setLegend(
"Besucher");
284 $aDataFinalX2 = array();
285 foreach ( $aDataX2 as $dData)
286 $aDataFinalX2[] = $dData;
288 $bplot2 =
new BarPlot( $aDataFinalX2);
289 $bplot2->setFillColor (
"orange");
290 $bplot2->setLegend(
"Kaeufer");
292 $aDataFinalX3 = array();
293 foreach ( $aDataX3 as $dData)
294 $aDataFinalX3[] = $dData;
296 $bplot3 =
new BarPlot( $aDataFinalX3);
297 $bplot3->setFillColor (
"silver");
298 $bplot3->setLegend(
"Neukunden");
301 $gbplot =
new groupBarPlot (array($bplot, $bplot2, $bplot3));
302 $graph->add( $gbplot);