Merge branch 'ticket-updateStats' into develop

This commit is contained in:
Marion Muszynski 2016-05-20 17:13:34 +02:00
commit fcdcc0ec8a

View File

@ -6,6 +6,7 @@ class AdminStatsLogistic extends AdminTab {
$this->lang = false;
$this->date_begin = date('Y-m-d');
$this->date_end = date('Y-m-d');
$this->date_stock = date('Y-m-d');
if (!empty($_GET['date_begin'])) {
$this->date_begin = $_GET['date_begin'];
@ -14,6 +15,10 @@ class AdminStatsLogistic extends AdminTab {
if (!empty($_GET['date_end'])){
$this->date_end = $_GET['date_end'];
}
if (!empty($_GET['date_stock'])){
$this->date_stock = $_GET['date_stock'];
}
parent::__construct();
}
@ -34,8 +39,8 @@ class AdminStatsLogistic extends AdminTab {
display: none;
}
#date_begin, #date_end {
width: 80px;
#date_begin, #date_end, #date_stock {
width: 115px;
text-align: right;
padding: 2px;
}
@ -60,7 +65,7 @@ class AdminStatsLogistic extends AdminTab {
<script type="text/javascript" src="'.__PS_BASE_URI__.'modules/privatesales/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("input[name=date_end], input[name=date_begin]").datepicker({
$("input[name=date_end], input[name=date_begin], input[name=date_stock]").datepicker({
showTime: false,
dateFormat: "yy-mm-dd",
formattedDate: "yy-mm-dd",
@ -108,6 +113,9 @@ class AdminStatsLogistic extends AdminTab {
$poles[4]['name'] = 'Pôle 5 : Multi';
$poles[5]['name'] = 'Pôle 6 : Autre';
foreach ($stats as $key => $stat) {
if (!isset($stat['id_employee'])) {
continue;
}
switch ($stat['id_employee']) {
case '52':
$poles[0]['recap']['quantity'] += $stat['quantity'];
@ -193,6 +201,65 @@ class AdminStatsLogistic extends AdminTab {
</tr>
</tfoot>
</table>';
$reports = array(
'25' => array(
'name' => 'Nb commandes > 25j',
'payment' => $this->getReport(25,2),
'partial' => $this->getReport(25,17)
),
'21' => array(
'name' => 'Nb commandes > 21j',
'payment' => $this->getReport(21,2),
'partial' => $this->getReport(21,17)
),
'18' => array(
'name' => 'Nb commandes > 18j',
'payment' => $this->getReport(18,2),
'partial' => $this->getReport(18,17)
),
'2' => array(
'name' => 'Nb commandes > 2j',
'payment' => $this->getReport(2,2),
'partial' => $this->getReport(2,17)
)
);
echo '<br><br><h2 style="margin-top:15px">Report Stock</h2>
<fieldset>
<form method="GET" action="'.$currentIndex.'">'
.'<span class="form-group">'
.'<label style="float: none;" class="control-label" for="date_stock">Date :</label>'
.'<input type="date" name="date_stock" value="'.pSQl($this->date_stock).'" id="date_stock" class="form-control" />'
.'<input type="hidden" name="date_begin" value="'.pSQl($this->date_begin).'" class="form-control" />'
.'<input type="hidden" name="date_end" value="'.pSQl($this->date_end).'" class="form-control" />'
.'</span>'
.'<input type="hidden" name="token" value="'.Tools::getAdminTokenLite(__CLASS__).'" />'
.'<input type="hidden" name="tab" value="'.__CLASS__.'" />'
.'<button type="submit" class="button">Filtrer</button>'
.'</form>
</fieldset>'
;
echo '<table class="table" style="width:100%; margin-top:15px">
<thead>
<tr>
<th colspan="2"></th>
<th>Paiement accepté</th>
<th>Commande partiellement expédiée</th>
</tr>
</thead>
<tbody>';
foreach ($reports as $k => $report) {
echo '<tr">
<td>'.$report['name'].'</td>
<td>'.date('Y-m-d', strtotime($this->date_stock. ' - '.$k.' days')).'</td>
<td>'.$report['payment'].'</td>
<td>'.$report['partial'].'</td>
</tr>';
}
echo '<tbody>
</table>';
}
@ -217,8 +284,24 @@ class AdminStatsLogistic extends AdminTab {
return Db::getInstance()->getValue('
SELECT
SUM(s.`nb_package`) AS `nb_package`
FROM `'._DB_PREFIX_.'stats_logistic` s
WHERE s.`date` BETWEEN "'.pSQL($this->date_begin).'" AND "'.pSQL($this->date_end).'"
FROM `'._DB_PREFIX_.'stats_logistic` s
WHERE s.`date` BETWEEN "'.pSQL($this->date_begin).'" AND "'.pSQL($this->date_end).'"
');
}
public function getReport($day = 25, $state = 2) {
return Db::getInstance()->getValue('
SELECT COUNT(o.`id_order`)
FROM `'._DB_PREFIX_.'orders` o
WHERE (o.`date_add` BETWEEN DATE_SUB("'.pSQL($this->date_stock).'",INTERVAL '.(int)$day.' DAY) AND "'.pSQL($this->date_stock).'")
AND
(
SELECT id_order_state
FROM '._DB_PREFIX_.'order_history oh
WHERE o.id_order = oh.id_order
ORDER BY id_order_history DESC
LIMIT 1
) = '.(int)$state.'
');
}
}