2013-01-20 20:06 | So, then let's begin: in /database/tranlations/xx.php add:
$lang['Statistic'] = "Statystyka";
in admin.php under:
// plugins actions
add:
elseif($p=='orders-stats'){ require_once DIR_TEMPLATES.'admin/orders-stats.php'; }
in /core/orders-admin.php in function generateCache() under:
$this->aOrders[$aData['iOrder']]['sStatus']=$this->throwStatus($aData['iStatus']);
add:
$this->aOrders[$aData['iOrder']]['fSummary']=0;
then in the same function under:
fclose($rFile);
add:
$rFile=fopen(DB_ORDERS_PRODUCTS,'r'); $i=0; while(!feof($rFile)){ $sContent=fgets($rFile); if($i>0&&!empty($sContent)){ $aData=unserialize(trim($sContent)); $this->aOrders[$aData['iOrder']]['fSummary']+=$aData['fPrice']*$aData['iQuantity']; } $i++; } fclose($rFile);
then in /templates/admin/style.css add:
/* STATISTIC */ #statistic{ text-align:center; padding-top:30px; border:1px solid #870707; border-bottom-width:12px; border-bottom-right-radius:10px; border-bottom-left-radius:10px; } #statistic span{ font-size:1.6em; font-weight:bold; color:#000; background-color:#ccc; padding:0 4px; border-top-left-radius:8px; -webkit-box-shadow:5px -5px 10px rgba(50,50,50,.25); box-shadow:2px -2px 10px rgba(50,50,50,.25); } #statistic table{ width:99%; border:1px solid #444; margin:0 auto 30px; border-bottom-width:2px; } #statistic table.lastTable{ margin-bottom:10px; } #statistic td{ vertical-align:bottom; text-align:center; width:8%; } #statistic div{ background:#add8f6; margin:0 10%; border-top-left-radius:10px; -webkit-box-shadow:5px -5px 10px rgba(50,50,50,.25); box-shadow:5px -5px 10px rgba(50,50,50,.25); } #statistic .datum{ background:#eee; font-weight:bold; }
then in /templares/admin create a new file "orders-stats.php" with the content:
<?php if(!defined('ADMIN_PAGE')) exit; $oOrder=new OrdersAdmin(); $oOrder->generateCache(); require_once DIR_TEMPLATES.'admin/_header.php'; require_once DIR_TEMPLATES.'admin/_menu.php'; ?> <h1> <img src="<?php echo $config['dir_templates'];?>admin/img/ico_stats.png" alt=""/> <?php echo $lang['Statistic'];?> <a href="http://www.kimla.de" title="<?php echo $lang['Manual'];?>" target="_blank"></a> </h1> <?php echo $oOrder->listOrderStats(); ?> <?php require_once DIR_TEMPLATES.'admin/_footer.php'; ?>
and finally in /templates/admin/_menu.php under:
<a href="?p=payments-form"><?php echo $lang['New_payment_method']; ?></a>/php] add:
<span class="sep"></span> <a href="?p=orders-stats"><?php echo $lang['Statistic'];?></a>
The job is finished. Reload the page (in admin) and go to menu "Orders", at the end of its submenu you'll fing a "Statistic" link.
This plugin displays the monthly turnover as diagram in yearly tables. So you can analyse and compare visually how good or bad your shop goes.
Enjoy.
» Quick.Cart v6.xwww.kimla.de |
2013-01-20 20:10 | Uuups, a most important thing: in /core/orders/admin.php add a function:
public function listOrderStats(){ if(isset($this->aOrders)){ $aStatistic=null; $fMax=0; foreach($this->aOrders as $iOrder=>$aData){ $iYear=date('Y',$aData['iTime']); $iMonth=date('n',$aData['iTime']); if(!isset($aStatistic[$iYear][$iMonth])) $aStatistic[$iYear][$iMonth]=0; if($aData['iStatus']!=4) $aStatistic[$iYear][$iMonth]+=$aData['fSummary']; if($aStatistic[$iYear][$iMonth]>$fMax) $fMax=$aStatistic[$iYear][$iMonth]; } krsort($aStatistic); $content='<div id="statistic">'; $iTable=0; $iCount=count($aStatistic); foreach($aStatistic as $iYear=>$aMonths){ $fYear=0; $iTable++; $sTableValues=($iTable==$iCount)?'<table class="lastTable"><tr>':'<table><tr>'; $sTableDate='<tr>'; for($i=1;$i<13;$i++){ if(isset($aMonths[$i])){ $fYear+=$aMonths[$i]; $sTableValues.='<td><div style="height:'.((ceil(($aMonths[$i]/$fMax)*200)<12)?'12':ceil(($aMonths[$i]/$fMax)*200) ).'px;">'.number_format(round($aMonths[$i]),0,'','.').',- '.$GLOBALS['config']['currency_symbol'].'</div></td>'; $sTableDate.='<td class="datum">'.(($i<10)?'0'.$i:$i).'.'.$iYear.'</td>'; } else{ $sTableValues.='<td> </td>'; $sTableDate.='<td class="datum">'.(($i<10)?'0'.$i:$i).'.'.$iYear.'</td>'; } } $sTableValues.='</tr>'; $sTableDate.='</tr></table>'; $content.='<span>'.$iYear.' --- '.number_format(round($fYear),0,'','.').',- '.$GLOBALS['config']['currency_symbol'].'</span>'.$sTableValues.$sTableDate; } $content.='</div>'; return $content; } }
www.kimla.de |