This commit is contained in:
Michael RICOIS 2018-01-30 18:00:48 +01:00
parent db36c1026b
commit 40468043c9

View File

@ -1,7 +1,10 @@
<?php
include_once(_PS_ROOT_DIR_.'/modules/privatesales/Sale.php');
class AdminStatsLogistic extends AdminTab {
public function __construct() {
class AdminStatsLogistic extends AdminTab
{
public function __construct()
{
$this->table = 'stats_logistic';
$this->lang = false;
$this->date_begin = date('Y-m-d');
@ -242,7 +245,8 @@ class AdminStatsLogistic extends AdminTab {
}
}
public function display() {
public function display()
{
global $currentIndex, $cookie;
$date = Configuration::get('MAJ_STAT_LOGISTIC');
@ -600,7 +604,8 @@ class AdminStatsLogistic extends AdminTab {
}
public function getStats() {
public function getStats()
{
return Db::getInstance()->executeS('
SELECT
e.`id_employee`,
@ -619,7 +624,8 @@ class AdminStatsLogistic extends AdminTab {
');
}
public function getTotalColis() {
public function getTotalColis()
{
return Db::getInstance()->getValue('
SELECT
SUM(s.`nb_package`) AS `nb_package`
@ -628,7 +634,8 @@ class AdminStatsLogistic extends AdminTab {
');
}
public function getReport($day = 25, $state = 2, $carrier=false) {
public function getReport($day = 25, $state = 2, $carrier=false)
{
if($carrier == "laposte"){
$carriers = unserialize(Configuration::get('LAPOSTEWS_CARRIERS'));
} elseif($carrier == "mondialrelay"){
@ -645,7 +652,8 @@ class AdminStatsLogistic extends AdminTab {
');
}
public function getSaleDetails($product_ids) {
public function getSaleDetails($product_ids)
{
$sale_details = array();
$sale_details_lpw = Db::getInstance()->ExecuteS('
SELECT od.*, rr.`id_reason`, pws.`id_employee`, pws.`shipping_number`,
@ -672,7 +680,8 @@ class AdminStatsLogistic extends AdminTab {
return $sale_details;
}
public function getPackageDetails($order_detail_ids) {
public function getPackageDetails($order_detail_ids)
{
$lp = Db::getInstance()->ExecuteS('
SELECT pws.`id_order_detail`, pws.`id_employee`, pws.`shipping_number`
FROM `'._DB_PREFIX_.'lapostews` pws
@ -687,7 +696,8 @@ class AdminStatsLogistic extends AdminTab {
return $total;
}
public function getShippingDetails() {
public function getShippingDetails()
{
return Db::getInstance()->ExecuteS('
SELECT pws.`id_order_detail`, pws.`shipping_number`, pws.`date_add`, pws.`quantity`, e.`email` AS `poste`, od.`id_order`, od.`product_id`, od.`product_attribute_id`, od.`product_name`, psc.`id_sale`, od.`product_quantity`,
ROUND(((od.`product_price` * (1 - od.`reduction_percent` / 100) - od.`reduction_amount`) * (1 - od.`group_reduction` / 100) * (1 + od.`tax_rate` / 100)), 6) AS `price`
@ -700,7 +710,8 @@ class AdminStatsLogistic extends AdminTab {
');
}
public function getShippingMRDetails() {
public function getShippingMRDetails()
{
return Db::getInstance()->ExecuteS('
SELECT pmr.`id_order_detail`, pmr.`shipping_number`, pmr.`date_add`, pmr.`quantity`, e.`email` AS `poste`, od.`id_order`, od.`product_id`, od.`product_attribute_id`, od.`product_name`, psc.`id_sale`, od.`product_quantity`,
ROUND(((od.`product_price` * (1 - od.`reduction_percent` / 100) - od.`reduction_amount`) * (1 - od.`group_reduction` / 100) * (1 + od.`tax_rate` / 100)), 6) AS `price`
@ -713,7 +724,8 @@ class AdminStatsLogistic extends AdminTab {
');
}
public function getShippingPhileaDetails() {
public function getShippingPhileaDetails()
{
return Db::getInstance()->ExecuteS('
SELECT pph.`id_order_detail`, pph.`shipping_number`, pph.`date_add`, pph.`quantity`,"Philéa" AS `poste`, od.`id_order`, od.`product_id`, od.`product_attribute_id`, od.`product_name`, psc.`id_sale`, od.`product_quantity`,
ROUND(((od.`product_price` * (1 - od.`reduction_percent` / 100) - od.`reduction_amount`) * (1 - od.`group_reduction` / 100) * (1 + od.`tax_rate` / 100)), 6) AS `price`
@ -725,7 +737,8 @@ class AdminStatsLogistic extends AdminTab {
');
}
public function getSales() {
public function getSales()
{
return Db::getInstance()->ExecuteS('
SELECT p.`id_sale`, p.`date_start`, l.`name` as title
FROM `'._DB_PREFIX_.'privatesale` p
@ -736,7 +749,8 @@ class AdminStatsLogistic extends AdminTab {
');
}
public function getSaleInfo($id_sale) {
public function getSaleInfo($id_sale)
{
return Db::getInstance()->getRow('
SELECT p.`date_start`, l.`name` as title
FROM `'._DB_PREFIX_.'privatesale` p
@ -747,7 +761,8 @@ class AdminStatsLogistic extends AdminTab {
');
}
public function getProducts($id_sale) {
public function getProducts($id_sale)
{
$product_ids = array();
foreach(Db::getInstance()->ExecuteS('
SELECT DISTINCT `id_product`
@ -759,7 +774,8 @@ class AdminStatsLogistic extends AdminTab {
return $product_ids;
}
public function exportExpeCSV ($items, $filename) {
public function exportExpeCSV ($items, $filename)
{
$fp = fopen(dirname(__FILE__).'/'.$filename, 'w');
$delim = ';';
@ -791,7 +807,8 @@ class AdminStatsLogistic extends AdminTab {
fclose($fp);
}
public function exportCSV ($result, $filename) {
public function exportCSV ($result, $filename)
{
//$fp = fopen("php://output", 'w');
$fp = fopen(dirname(__FILE__).'/'.$filename, 'w');
$delim = ';';