table = 'stats_logistic'; $this->lang = false; $this->date_begin = date('Y-m-d'); $this->date_end = date('Y-m-d'); if (!empty($_GET['date_begin'])) { $this->date_begin = $_GET['date_begin']; } if (!empty($_GET['date_end'])){ $this->date_end = $_GET['date_end']; } parent::__construct(); } public function display() { global $currentIndex, $cookie; $date = Configuration::get('MAJ_STAT_LOGISTIC'); echo ' '; echo '
' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .' Dernière mise à jour : '.$date.'' .'
' ; $stats = $this->getStats(); $poles = array(); for ($i=0; $i < 6; $i++) { $poles[] = array( 'recap' => array( 'quantity' => 0, 'nb_package' => 0 ), 'employee' => array(), ); } $poles[0]['name'] = 'Pôle 1 : Petites marques'; $poles[1]['name'] = 'Pôle 2 : Marques moyenne'; $poles[2]['name'] = 'Pôle 3 : Grosses marques'; $poles[3]['name'] = 'Pôle 4 : Postes complementaires'; $poles[4]['name'] = 'Pôle 5 : Multi'; $poles[5]['name'] = 'Pôle 6 : Autre'; foreach ($stats as $key => $stat) { switch ($stat['id_employee']) { case '52': $poles[0]['recap']['quantity'] += $stat['quantity']; $poles[0]['recap']['nb_package'] += $stat['nb_package']; $poles[0]['employee'][] = $stat; break; case '22': case '24': $poles[1]['recap']['quantity'] += $stat['quantity']; $poles[1]['recap']['nb_package'] += $stat['nb_package']; $poles[1]['employee'][] = $stat; break; case '25': case '44': $poles[2]['recap']['quantity'] += $stat['quantity']; $poles[2]['recap']['nb_package'] += $stat['nb_package']; $poles[2]['employee'][] = $stat; break; case '47': case '48': $poles[3]['recap']['quantity'] += $stat['quantity']; $poles[3]['recap']['nb_package'] += $stat['nb_package']; $poles[3]['employee'][] = $stat; break; case '35': case '36': $poles[4]['recap']['quantity'] += $stat['quantity']; $poles[4]['recap']['nb_package'] += $stat['nb_package']; $poles[4]['employee'][] = $stat; break; case '28': default: $poles[5]['recap']['quantity'] += $stat['quantity']; $poles[5]['recap']['nb_package'] += $stat['nb_package']; $poles[5]['employee'][] = $stat; break; } $total_quantity += $stat['quantity']; } $total_colis = $this->getTotalColis(); $total_quantity = 0; echo '

Stats de la logistique

'; foreach ($poles as $k => $pole) { echo ''; foreach ($pole['employee'] as $key => $stat) { echo ''; } } echo '
Id Employee Prénom Nom Email Quantité Nombre de colis % total
'.$pole['name'].' '.$pole['recap']['quantity'].' '.$pole['recap']['nb_package'].' '. number_format(($pole['recap']['nb_package']* 100 / $total_colis), 2) .' %
'.$stat['id_employee'].' '.$stat['firstname'].' '.$stat['lastname'].' '.$stat['email'].' '.$stat['quantity'].' '.$stat['nb_package'].' '. number_format(($stat['nb_package']* 100 / $total_colis), 2) .' %
Total : '.$total_quantity.' '.$total_colis.' 100 %
'; } public function getStats() { return Db::getInstance()->executeS(' SELECT e.`id_employee`, e.`email`, e.`lastname`, e.`firstname`, SUM(s.`nb_product`) AS `nb_product`, SUM(s.`quantity`) AS `quantity`, SUM(s.`nb_package`) AS `nb_package` FROM `'._DB_PREFIX_.'stats_logistic` s LEFT JOIN `'._DB_PREFIX_.'employee` e USING(`id_employee`) WHERE s.`date` BETWEEN "'.pSQL($this->date_begin).'" AND "'.pSQL($this->date_end).'" GROUP BY s.`id_employee` '); } public function getTotalColis() { 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).'" '); } }