Merge branch 'develop' of gitlab.antadis.net:dev-antadis/bebeboutik into develop

This commit is contained in:
root 2017-06-16 17:52:40 +02:00
commit 5b76802f6f
8 changed files with 302 additions and 149 deletions

View File

@ -24,7 +24,7 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*/ */
session_start();
define('PS_ADMIN_DIR', getcwd()); define('PS_ADMIN_DIR', getcwd());
include(PS_ADMIN_DIR.'/../config/config.inc.php'); include(PS_ADMIN_DIR.'/../config/config.inc.php');
@ -52,6 +52,7 @@ $functionArray = array(
'privatesalesM3' => 'generateInvoicesPDFPrivateM3', 'privatesalesM3' => 'generateInvoicesPDFPrivateM3',
'privatesalesAll' => 'generateInvoicesPDFPrivateSalesAll', 'privatesalesAll' => 'generateInvoicesPDFPrivateSalesAll',
'pendingorders' => 'generatePendingOrdersInvoice', 'pendingorders' => 'generatePendingOrdersInvoice',
'privatesalesManyOrders' => 'generateManyInvoicesPDF',
); );
foreach ($functionArray as $var => $function) foreach ($functionArray as $var => $function)
@ -61,6 +62,17 @@ foreach ($functionArray as $var => $function)
die; die;
} }
function generateManyInvoicesPDF()
{
if (!isset($_SESSION['id_orders']))
die (Tools::displayError('Missing order ID'));
$orders = $_SESSION['id_orders'];
unset($_SESSION['id_orders']);
session_destroy();
PDF::multipleInvoices($orders, false, true, false, true);
}
function generateInvoicePDF() function generateInvoicePDF()
{ {
if (!isset($_GET['id_order'])) if (!isset($_GET['id_order']))
@ -105,7 +117,8 @@ function generateInvoicesPDFPrivateSales()
include(dirname(__FILE__).'/../modules/privatesales/Sale.php'); include(dirname(__FILE__).'/../modules/privatesales/Sale.php');
if($sale = new Sale((int) Tools::getValue('id_sale'))) { if($sale = new Sale((int) Tools::getValue('id_sale'))) {
$statuts = array(17, Configuration::get('PS_OS_PAYMENT')); $statuts = array(17, Configuration::get('PS_OS_PAYMENT'));
$orders = $sale->getOrdersFromSale($statuts); $carrier = Tools::getValue('carrier')? Tools::getValue('carrier') : 'lp';
$orders = $sale->getOrdersFromSale($statuts, true, false, $carrier);
if(count($orders) == 0) { if(count($orders) == 0) {
die (Tools::displayError('No invoices found')); die (Tools::displayError('No invoices found'));
} }
@ -179,7 +192,8 @@ function generateInvoicesPDFPrivateSalesAll()
include(dirname(__FILE__).'/../modules/privatesales/Sale.php'); include(dirname(__FILE__).'/../modules/privatesales/Sale.php');
if($sale = new Sale((int) Tools::getValue('id_sale'))) { if($sale = new Sale((int) Tools::getValue('id_sale'))) {
$statuts = array(17, Configuration::get('PS_OS_PAYMENT')); $statuts = array(17, Configuration::get('PS_OS_PAYMENT'));
$orders = $sale->getOrdersFromSale($statuts, FALSE, TRUE); $carrier = Tools::getValue('carrier') ? Tools::getValue('carrier'):'lp';
$orders = $sale->getOrdersFromSale($statuts, FALSE, TRUE, $carrier);
if(count($orders) == 0) { if(count($orders) == 0) {
die (Tools::displayError('No invoices found')); die (Tools::displayError('No invoices found'));
} }
@ -250,8 +264,9 @@ function generateInvoicesPDFPrivateM2Plus()
if (!Validate::isDate(Tools::getValue('date_from'))) if (!Validate::isDate(Tools::getValue('date_from')))
die (Tools::displayError('Invalid end date')); die (Tools::displayError('Invalid end date'));
$carrier = Tools::getValue('carrier')?Tools::getValue('carrier'):'lp';
$statuts = array(17, Configuration::get('PS_OS_PAYMENT')); $statuts = array(17, Configuration::get('PS_OS_PAYMENT'));
$orders = Sale::getOrdersM2($statuts, $id_sales, Tools::getValue('date_from'), Tools::getValue('date_to')); $orders = Sale::getOrdersM2($statuts, $id_sales, Tools::getValue('date_from'), Tools::getValue('date_to'), false, $carrier);
if(count($orders) == 0) { if(count($orders) == 0) {
die (Tools::displayError('No invoices found')); die (Tools::displayError('No invoices found'));

View File

@ -197,27 +197,16 @@ class AdminInvoices extends AdminTab
<form id="invoices_form" action="'.$currentIndex.'&token='.$this->token.'" method="post"> <form id="invoices_form" action="'.$currentIndex.'&token='.$this->token.'" method="post">
<table class="table table-custombordered">'; <table class="table table-custombordered">';
/*echo '
<tr>
<td colspan="6"></td>
<td align="center"><a id="checkm3" data-checked="0" href="#">'. $this->l('Check all') .'</a></td>
</tr>*/
$form .= '<tr> $form .= '<tr>
<th colspan="2">'.$this->l('ID Sale').'</th> <th colspan="2">'.$this->l('ID Sale').'</th>
<th>'.$this->l('Name sale').'</th> <th>'.$this->l('Name sale').'</th>
<th>'.$this->l('Date start').'</th>'; <th>'.$this->l('Date start').'</th>
/*<th align="center">48h</th>'; <th>M1</th>
if ($cookie->id_employee == 1) { <th>M2+</th>
echo '<th align="center">48H bis</th>';
}*/
$form .= '<th>M1</th>';
/*<th>M2</th>*/
$form .= '<th>M2+</th>
<th>Même marque</th> <th>Même marque</th>
<th>All</th> <th>All</th>
<th>'. $this->l('Delay') .'</th> <th>'. $this->l('Delay') .'</th>
</tr>'; </tr>';
// <th align="center">M2\'</th>
$id_sales = unserialize(Configuration::get("ANT_CHECKED_SALES")); $id_sales = unserialize(Configuration::get("ANT_CHECKED_SALES"));
foreach ($this->print_sales as $key => $sale) { foreach ($this->print_sales as $key => $sale) {
if( $key%2 == 0) { if( $key%2 == 0) {
@ -231,78 +220,44 @@ class AdminInvoices extends AdminTab
<td></td> <td></td>
<td><label for="multi_'.$sale['id_sale'].'" style="float:none; width:auto; padding: 0; text-align: left; font-weight: normal; margin:0;">'. $sale['id_sale'] .'</label></td> <td><label for="multi_'.$sale['id_sale'].'" style="float:none; width:auto; padding: 0; text-align: left; font-weight: normal; margin:0;">'. $sale['id_sale'] .'</label></td>
<td><label for="multi_'.$sale['id_sale'].'" style="float:none; width:auto; padding: 0; text-align: left; font-weight: normal; margin:0;"><strong>'. $sale['title'] .'</strong></label></td> <td><label for="multi_'.$sale['id_sale'].'" style="float:none; width:auto; padding: 0; text-align: left; font-weight: normal; margin:0;"><strong>'. $sale['title'] .'</strong></label></td>
<td align="center"><p style="padding:0px;color: #565485;font-size:12px;">'. $date->format('Y-m-d') .'</p></td>'; <td align="center"><p style="padding:0px;color: #565485;font-size:12px;">'. $date->format('Y-m-d') .'</p></td>
/*<td align="center">'; </td>
if ($sale['delivery_delay'] == 2
|| $sale['delivery_delay'] == 6) {
echo '<a onclick="this.target=\'_blank\'" href="'.$currentIndex.'&print48h=1&id_sale='. $sale['id_sale'] .'&token='.$this->token.'">
<img src="../img/admin/pdf.gif" alt="">
</a>';
} else {
echo '-';
}*/
/*if ($cookie->id_employee == 1) {
echo '</td><td align="center">';
if ($sale['delivery_delay'] == 2
|| $sale['delivery_delay'] == 6) {
echo '<a onclick="this.target=\'_blank\'" href="'.$currentIndex.'&print48hbis=1&id_sale='. $sale['id_sale'] .'&token='.$this->token.'">
<img src="../img/admin/pdf.gif" alt="">
</a>';
} else {
echo '-';
}
}
echo '</td>*/
$form .= '</td>
<td align="center"> <td align="center">
<!--a title="Facture - Avec prix" onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printM1=1&id_sale='. $sale['id_sale'] .'&token='.$this->token.'"> <a title="Facture - La Poste" onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printM1=1&id_sale='. $sale['id_sale'] .'&gift=1&carrier=lp&token='.$this->token.'">
<span class="text-green-light anticon anticon-file-pdf" style="cursor:pointer;"></span> <span class="text-yellow anticon anticon-file-pdf" style="cursor:pointer;"></span>
</a-->
<a title="Facture cadeau - Sans prix" onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printM1=1&id_sale='. $sale['id_sale'] .'&gift=1&token='.$this->token.'">
<span class="text-rose anticon anticon-file-pdf" style="cursor:pointer;"></span>
</a> </a>
</td>'; <a title="Facture - Mondial Relay" onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printM1=1&id_sale='. $sale['id_sale'] .'&gift=1&carrier=mr&token='.$this->token.'">
/*<td align="center"> <span class="text-red-light anticon anticon-file-pdf" style="cursor:pointer;"></span>
<a onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printM2=1&id_sale='. $sale['id_sale'] .'&token='.$this->token.'">
<img src="../img/admin/pdf.gif" alt="">
</a> </a>
</td>*/ </td>
<td align="center"><input id="multi_'. $sale['id_sale'].'" type="checkbox" name="multi2[]" value="'.$sale['id_sale'].'" '.(in_array((int)$sale['id_sale'], $id_sales)?'checked':'').'/></td>
$form .= '<td align="center"><input id="multi_'. $sale['id_sale'].'" type="checkbox" name="multi2[]" value="'.$sale['id_sale'].'" '.(in_array((int)$sale['id_sale'], $id_sales)?'checked':'').'/></td>
<td align="center"><input id="multi_plus_'. $sale['id_sale'].'" type="checkbox" name="multiPlus[]" value="'.$sale['id_sale'].'"/></td> <td align="center"><input id="multi_plus_'. $sale['id_sale'].'" type="checkbox" name="multiPlus[]" value="'.$sale['id_sale'].'"/></td>
<td align="center"> <td align="center">
<!--a onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printAll=1&id_sale='. $sale['id_sale'] .'&token='.$this->token.'"> <a title="Facture - La Poste" onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printAll=1&id_sale='. $sale['id_sale'] .'&gift=1&carrier=lp&token='.$this->token.'">
<span class="text-green-light anticon anticon-file-pdf" style="cursor:pointer;"></span> <span class="text-yellow anticon anticon-file-pdf" style="cursor:pointer;"></span>
</a--> </a>
<a onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printAll=1&id_sale='. $sale['id_sale'] .'&gift=1&token='.$this->token.'"> <a title="Facture - Mondial Relay" onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printAll=1&id_sale='. $sale['id_sale'] .'&gift=1&carrier=mr&token='.$this->token.'">
<span class="text-rose anticon anticon-file-pdf" style="cursor:pointer;"></span> <span class="text-red-light anticon anticon-file-pdf" style="cursor:pointer;"></span>
</a> </a>
</td> </td>
<td align="center" '.($sale['delivery_delay'] != 1?'style="background:#f49ac1;"':'').'>'.(isset($sale['delivery_delay_name'])?$sale['delivery_delay_name']:'').'</td> <td align="center" '.($sale['delivery_delay'] != 1?'style="background:#f49ac1;"':'').'>'.(isset($sale['delivery_delay_name'])?$sale['delivery_delay_name']:'').'</td>
</tr>'; </tr>';
} }
// <td align="center"><input id="m2_'. $sale['id_sale'].'" type="checkbox" name="m2[]" value="'.$sale['id_sale'].'" /></td>
$form .= '<tr> $form .= '
<td colspan="5" style="padding:5px;"></td>'; <tr>
// <td colspan="4" style="padding:5px;"> <td colspan="5" style="padding:5px;"></td>
// <input type="hidden" name="date_to" value="'. Tools::getValue('date_to') .'" /> <td align="center" style="padding:5px;">
// <input type="hidden" name="date_from" value="'. Tools::getValue('date_from') .'" />
// <label style="float:none;" class="text-green-light "><span class="anticon anticon-file-pdf"></span> '.$this->l('Avec prix').'</label>
// <label style="float:none;" class="text-rose "><span class="anticon anticon-file-pdf"></span> '.$this->l('Sans prix').'</label>
// </td>';
/*<td align="center">
<input type="submit" name="submitPrintM2Bis" class="button" value="'.$this->l('Print M2\'').'" />
</td>*/
$form .= '<td align="center" style="padding:5px;">
<input type="hidden" name="date_to" value="'. Tools::getValue('date_to') .'" /> <input type="hidden" name="date_to" value="'. Tools::getValue('date_to') .'" />
<input type="hidden" name="date_from" value="'. Tools::getValue('date_from') .'" /> <input type="hidden" name="date_from" value="'. Tools::getValue('date_from') .'" />
<input type="submit" name="submitPrintM2Plus" class="btn btn-default btn-xs" value="'.$this->l('Print M2+').'" /> <input type="submit" name="submitPrintM2PlusLP" class="btn btn-default btn-xs" value="'.$this->l('M2+ LP').'" />
<input type="submit" name="resetPrintM2Plus" class="btn btn-default btn-xs" value="'.$this->l('Unselect all').'" /> <input type="submit" name="submitPrintM2PlusMR" class="btn btn-default btn-xs" value="'.$this->l('M2+ MR').'" />
<!-- input type="submit" name="resetPrintM2Plus" class="btn btn-default btn-xs" value="'.$this->l('Unselect all').'" / -->
</td> </td>
<td align="center" style="padding:5px;"> <td align="center" style="padding:5px;">
<input type="submit" name="submitPrintMPlus" class="btn btn-default btn-xs" value="'.$this->l('Print Même Marque').'" /> <input type="submit" name="submitPrintMPlusLP" class="btn btn-default btn-xs" value="'.$this->l('LP').'" />
<input type="submit" name="submitPrintMPlusMR" class="btn btn-default btn-xs" value="'.$this->l('MR').'" />
</td> </td>
<td style="padding:5px;"> <td style="padding:5px;">
<p><label style="float:none;"><input type="checkbox" name="gift" value="1" /> '.$this->l('Factures Cadeaux').'</label></p> <p><label style="float:none;"><input type="checkbox" name="gift" value="1" /> '.$this->l('Factures Cadeaux').'</label></p>
@ -660,12 +615,14 @@ class AdminInvoices extends AdminTab
include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php'); include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php');
if($sale = new Sale((int) Tools::getValue('id_sale'))) { if($sale = new Sale((int) Tools::getValue('id_sale'))) {
$statuts = array(17, Configuration::get('PS_OS_PAYMENT')); $statuts = array(17, Configuration::get('PS_OS_PAYMENT'));
$orders = $sale->getOrdersFromSale($statuts, FALSE, TRUE); $carrier = Tools::getValue('carrier') ? Tools::getValue('carrier'):'lp';
$orders = $sale->getOrdersFromSale($statuts, FALSE, TRUE, $carrier);
echo '<pre>';var_dump($orders);echo '</pre>';die();
if(sizeof($orders)) { if(sizeof($orders)) {
if(Tools::getValue('gift') == 1) { if(Tools::getValue('gift') == 1) {
Tools::redirectAdmin('pdf.php?privatesalesAll&gift=1&id_sale='.(int) $sale->id.'&token='.$this->token); Tools::redirectAdmin('pdf.php?privatesalesAll&gift=1&id_sale='.(int) $sale->id.'&carrier='.$carrier.'&token='.$this->token);
} else { } else {
Tools::redirectAdmin('pdf.php?privatesalesAll&id_sale='.(int) $sale->id.'&token='.$this->token); Tools::redirectAdmin('pdf.php?privatesalesAll&id_sale='.(int) $sale->id.'&carrier='.$carrier.'&token='.$this->token);
} }
} }
} }
@ -677,12 +634,14 @@ class AdminInvoices extends AdminTab
include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php'); include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php');
if($sale = new Sale((int) Tools::getValue('id_sale'))) { if($sale = new Sale((int) Tools::getValue('id_sale'))) {
$statuts = array(17, Configuration::get('PS_OS_PAYMENT')); $statuts = array(17, Configuration::get('PS_OS_PAYMENT'));
$orders = $sale->getOrdersFromSale($statuts); $carrier = Tools::getValue('carrier') ? Tools::getValue('carrier'):'lp';
$orders = $sale->getOrdersFromSale($statuts, TRUE, FALSE, $carrier);
echo '<pre>';var_dump($orders);echo '</pre>';die();
if(sizeof($orders)) { if(sizeof($orders)) {
if(Tools::getValue('gift') == 1) { if(Tools::getValue('gift') == 1) {
Tools::redirectAdmin('pdf.php?privatesales&gift=1&id_sale='.(int) $sale->id.'&token='.$this->token); Tools::redirectAdmin('pdf.php?privatesales&gift=1&id_sale='.(int) $sale->id.(Tools::getValue('carrier')?'&carrier='.Tools::getValue('carrier'):'').'&token='.$this->token);
} else { } else {
Tools::redirectAdmin('pdf.php?privatesales&id_sale='.(int) $sale->id.'&token='.$this->token); Tools::redirectAdmin('pdf.php?privatesales&id_sale='.(int) $sale->id.(Tools::getValue('carrier')?'&carrier='.Tools::getValue('carrier'):'').'&token='.$this->token);
} }
} }
} }
@ -717,7 +676,7 @@ class AdminInvoices extends AdminTab
} }
} }
// print multi (M2+) // print multi (M2+)
elseif (Tools::isSubmit('submitPrintM2Plus')) { elseif (Tools::isSubmit('submitPrintM2PlusLP') || Tools::isSubmit('submitPrintM2PlusMR')) {
include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php'); include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php');
$id_sales = Tools::getValue('multi2'); $id_sales = Tools::getValue('multi2');
@ -727,19 +686,20 @@ class AdminInvoices extends AdminTab
$this->_errors[] = $this->l('You must select 2 sales minimum for print M2+'); $this->_errors[] = $this->l('You must select 2 sales minimum for print M2+');
} else { } else {
$statuts = array(17, (int)Configuration::get('PS_OS_PAYMENT')); $statuts = array(17, (int)Configuration::get('PS_OS_PAYMENT'));
$orders = Sale::getOrdersM2($statuts, $id_sales, Tools::getValue('date_from'), Tools::getValue('date_to')); $carrier = Tools::isSubmit('submitPrintM2PlusMR')?'mr':'lp';
$orders = Sale::getOrdersM2($statuts, $id_sales, Tools::getValue('date_from'), Tools::getValue('date_to'), false, $carrier);
if(sizeof($orders)) { if(sizeof($orders)) {
if(Tools::getValue('gift') == 1) { if(Tools::getValue('gift') == 1) {
Tools::redirectAdmin('pdf.php?privatesalesM2Plus&gift=1&id_sale='.implode(',', $id_sales) .'&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&token='.$this->token); Tools::redirectAdmin('pdf.php?privatesalesM2Plus&gift=1&id_sale='.implode(',', $id_sales) .'&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&carrier='.$carrier.'&token='.$this->token);
} else { } else {
Tools::redirectAdmin('pdf.php?privatesalesM2Plus&id_sale='.implode(',', $id_sales) .'&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&token='.$this->token); Tools::redirectAdmin('pdf.php?privatesalesM2Plus&id_sale='.implode(',', $id_sales) .'&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&carrier='.$carrier.'&token='.$this->token);
} }
} }
$this->_errors[] = $this->l('No invoice found for these sales'); $this->_errors[] = $this->l('No invoice found for these sales');
} }
} }
// print multi with same brand // print multi with same brand
elseif (Tools::isSubmit('submitPrintMPlus')) { elseif (Tools::isSubmit('submitPrintMPlusLP') || Tools::isSubmit('submitPrintMPlusMR')) {
include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php'); include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php');
$id_sales = Tools::getValue('multiPlus'); $id_sales = Tools::getValue('multiPlus');
@ -747,12 +707,13 @@ class AdminInvoices extends AdminTab
$this->_errors[] = $this->l('You must select 2 sales minimum for print M2+'); $this->_errors[] = $this->l('You must select 2 sales minimum for print M2+');
} else { } else {
$statuts = array(17, Configuration::get('PS_OS_PAYMENT')); $statuts = array(17, Configuration::get('PS_OS_PAYMENT'));
$orders = Sale::getOrdersM2($statuts, $id_sales, Tools::getValue('date_from'), Tools::getValue('date_to')); $carrier = Tools::isSubmit('submitPrintMPlusMR')?'mr':'lp';
$orders = Sale::getOrdersM2($statuts, $id_sales, Tools::getValue('date_from'), Tools::getValue('date_to'), false, $carrier);
if(sizeof($orders)) { if(sizeof($orders)) {
if(Tools::getValue('gift') == 1) { if(Tools::getValue('gift') == 1) {
Tools::redirectAdmin('pdf.php?privatesalesM2Plus&gift=1&id_sale='.implode(',', $id_sales) .'&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&token='.$this->token); Tools::redirectAdmin('pdf.php?privatesalesM2Plus&gift=1&id_sale='.implode(',', $id_sales) .'&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&carrier='.$carrier.'&token='.$this->token);
} else { } else {
Tools::redirectAdmin('pdf.php?privatesalesM2Plus&id_sale='.implode(',', $id_sales) .'&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&token='.$this->token); Tools::redirectAdmin('pdf.php?privatesalesM2Plus&id_sale='.implode(',', $id_sales) .'&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&carrier='.$carrier.'&token='.$this->token);
} }
} }
$this->_errors[] = $this->l('No invoice found for these sales'); $this->_errors[] = $this->l('No invoice found for these sales');

View File

@ -3362,6 +3362,13 @@ span.anticon{
.text-purple-light{ .text-purple-light{
color: #796dc7!important; color: #796dc7!important;
} }
.text-yellow{
color: #f2be04!important;
}
.text-red-light{
color: #CA0047!important;
color: #CA0047!important;
}
a.link-anticon{ a.link-anticon{
color: #796dc7!important; color: #796dc7!important;
} }

View File

@ -241,6 +241,25 @@ class AdminAntConfigurations extends AdminTab
HelperFormBootstrap::displayWarning($this->l('Aucun résultat pour cette période')); HelperFormBootstrap::displayWarning($this->l('Aucun résultat pour cette période'));
} }
} }
}elseif(Tools::isSubmit('submitOrderPdf')){
if(isset($_FILES['csvfile']) && $_FILES['csvfile']['name'] != '') {
$f = fopen($_FILES['csvfile']['tmp_name'], 'r');
fgetcsv($f, 0, ';');
$i = 1;
$orders = array();
while($line = fgetcsv($f, 0, ';')) {
$i++;
$orders[] = (int) $line[0];
}
if(!empty($orders)) {
session_start();
$_SESSION['id_orders'] = $orders;
Tools::redirectAdmin('pdf.php?privatesalesManyOrders&gift=1&token='.$this->token);
//PDF::multipleInvoices($orders, false, true, false, true);
}
}
} }
} }
@ -308,8 +327,9 @@ class AdminAntConfigurations extends AdminTab
FROM `'._DB_PREFIX_.'privatesale` p FROM `'._DB_PREFIX_.'privatesale` p
LEFT JOIN `'._DB_PREFIX_.'category_lang` c ON (c.`id_category` = p.`id_category`) LEFT JOIN `'._DB_PREFIX_.'category_lang` c ON (c.`id_category` = p.`id_category`)
WHERE c.`id_lang` = '.$cookie->id_lang.' WHERE c.`id_lang` = '.$cookie->id_lang.'
AND p.`date_start` > "2015-01-01 00:00:00" AND p.`date_start` > "2017-01-01 00:00:00"
ORDER BY p.`id_sale` DESC ORDER BY p.`id_sale` DESC
LIMIT 800
') as $row) { ') as $row) {
$extrafields = Category::getSalesInfos(array((int) $row['id_category'])); $extrafields = Category::getSalesInfos(array((int) $row['id_category']));
$id_sale_options[] = array( $id_sale_options[] = array(
@ -345,6 +365,9 @@ class AdminAntConfigurations extends AdminTab
<li role="presentation" class="'.(Tools::getIsset('tab-pan') && Tools::getValue('tab-pan') == 'loyalties'?'active':'').'"> <li role="presentation" class="'.(Tools::getIsset('tab-pan') && Tools::getValue('tab-pan') == 'loyalties'?'active':'').'">
<a href="#loyalties" aria-controls="loyalty" role="tab" data-toggle="tab"><span class="text-rose anticon anticon-star-full"></span> '.$this->l('Suivi crédits fidélités').'</a> <a href="#loyalties" aria-controls="loyalty" role="tab" data-toggle="tab"><span class="text-rose anticon anticon-star-full"></span> '.$this->l('Suivi crédits fidélités').'</a>
</li> </li>
<li role="presentation" class="'.(Tools::getIsset('tab-pan') && Tools::getValue('tab-pan') == 'invoices'?'active':'').'">
<a href="#invoices" aria-controls="loyalty" role="tab" data-toggle="tab"><span class="text-rose anticon anticon-file-pdf"></span> '.$this->l('Factures').'</a>
</li>
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
@ -457,6 +480,34 @@ class AdminAntConfigurations extends AdminTab
</form> </form>
</div> </div>
</div> </div>
<div role="tabpanel" class="tab-pane '.(Tools::getIsset('tab-pan') && Tools::getValue('tab-pan') == 'invoices'?'active':'').'" id="invoices">
<div class="panel-content">
<h3 class="">'.$this->l('Générer un PDF de plusieurs commandes').'</h3>
<br>
<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&tab-pan=invoices" method="post" enctype="multipart/form-data">
<div class="col-md-6 col-md-offset-4">';
$help = '<br>
<p class="help-block">'.$this->l('Format: id_order').'</p>
<p class="help-block">'.$this->l('The subsequent columns and the first line are ignored.').'</p>
';
$input = array(
'type' => 'file',
'label' => $this->l('File:'),
'name' => 'csvfile',
'html' => $help
);
$form .= $helperForm->generateInput($input);
$form .= '
</div>
<div class="clearfix"></div>
<div class="ln_solid"></div>
<div class="form-group text-right">
<button type="submit" class="btn btn-primary" name="submitOrderPdf">'.$this->l('Générer PDF').'</button>
</div>
</form>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -810,11 +810,17 @@ class Sale {
* @param boolean $multi_only (if true, check only sales past in params) * @param boolean $multi_only (if true, check only sales past in params)
* @return array order_print * @return array order_print
*/ */
public static function getOrdersM2($id_status=NULL, $id_sales = array(), $date_from, $date_to, $multi_only = false) { public static function getOrdersM2($id_status=NULL, $id_sales = array(), $date_from, $date_to, $multi_only = false, $carrier = 'lp') {
if($id_sales < 2) { if($id_sales < 2) {
return false; return false;
} }
if($carrier === "lp") {
$carriers = array_map('intval',explode(',', Configuration::get('ANT_CARRIERS_SOCOL')));
} else {
$carriers = array_map('intval',explode(',', Configuration::get('ANT_CARRIERS_MR')));
}
$orders = array(); $orders = array();
foreach ($id_sales as $key => $id_sale) { foreach ($id_sales as $key => $id_sale) {
@ -830,6 +836,7 @@ class Sale {
WHERE `product_id` IN ('.implode(', ', $products).') WHERE `product_id` IN ('.implode(', ', $products).')
AND o.`invoice_date` >= "'.pSQL($date_from).' 00:00:00" AND o.`invoice_date` >= "'.pSQL($date_from).' 00:00:00"
AND o.`invoice_date` <= "'.pSQL($date_to).' 23:59:59" AND o.`invoice_date` <= "'.pSQL($date_to).' 23:59:59"
AND o.`id_carrier` IN ('.implode(',', $carriers).')
') as $order) { ') as $order) {
$orders[] = (int) $order['id_order']; $orders[] = (int) $order['id_order'];
} }
@ -844,6 +851,7 @@ class Sale {
AND h1.`id_order_state` IN ('.implode(',', $id_status).') AND h1.`id_order_state` IN ('.implode(',', $id_status).')
AND o.`invoice_date` >= "'.pSQL($date_from).' 00:00:00" AND o.`invoice_date` >= "'.pSQL($date_from).' 00:00:00"
AND o.`invoice_date` <= "'.pSQL($date_to).' 23:59:59" AND o.`invoice_date` <= "'.pSQL($date_to).' 23:59:59"
AND o.`id_carrier` IN ('.implode(',', $carriers).')
AND h1.`id_order` IN ( AND h1.`id_order` IN (
SELECT DISTINCT `id_order` SELECT DISTINCT `id_order`
FROM `'._DB_PREFIX_.'order_detail` FROM `'._DB_PREFIX_.'order_detail`
@ -951,16 +959,24 @@ class Sale {
} }
public function getOrdersFromSale($id_status=NULL, $single_only=TRUE, $send_test = FALSE) { public function getOrdersFromSale($id_status=NULL, $single_only=TRUE, $send_test = FALSE, $carrier = 'lp') {
$orders = array(); $orders = array();
$products = $this->getProducts(); $products = $this->getProducts();
if($carrier === "lp") {
$carriers = array_map('intval',explode(',', Configuration::get('ANT_CARRIERS_SOCOL')));
} else {
$carriers = array_map('intval',explode(',', Configuration::get('ANT_CARRIERS_MR')));
}
if(count($products) > 0) { if(count($products) > 0) {
if($id_status === NULL) { if($id_status === NULL) {
foreach(Db::getInstance()->ExecuteS(' foreach(Db::getInstance()->ExecuteS('
SELECT DISTINCT `id_order` SELECT DISTINCT od.`id_order`
FROM `'._DB_PREFIX_.'order_detail` FROM `'._DB_PREFIX_.'order_detail` od
WHERE `product_id` IN ('.implode(', ', $products).') LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = od.`id_order`
WHERE od.`product_id` IN ('.implode(', ', $products).')
AND o.`id_carrier` IN ('.implode(',', $carriers).')
') as $order) { ') as $order) {
$orders[] = (int) $order['id_order']; $orders[] = (int) $order['id_order'];
} }
@ -973,9 +989,11 @@ class Sale {
WHERE h2.`id_order_history` IS NULL WHERE h2.`id_order_history` IS NULL
AND h1.`id_order_state` IN ( '.implode(',', $id_status) .') AND h1.`id_order_state` IN ( '.implode(',', $id_status) .')
AND h1.`id_order` IN ( AND h1.`id_order` IN (
SELECT DISTINCT `id_order` SELECT DISTINCT od.`id_order`
FROM `'._DB_PREFIX_.'order_detail` FROM `'._DB_PREFIX_.'order_detail` od
WHERE `product_id` IN ('.implode(', ', $products).') LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = od.`id_order`
WHERE od.`product_id` IN ('.implode(', ', $products).')
AND o.`id_carrier` IN ('.implode(',', $carriers).')
) )
') as $order) { ') as $order) {
$orders[] = (int) $order['id_order']; $orders[] = (int) $order['id_order'];
@ -985,6 +1003,7 @@ class Sale {
// TEST pour les commandes en 48h // TEST pour les commandes en 48h
if ($send_test) { if ($send_test) {
$orders_not_sended = array(); $orders_not_sended = array();
foreach(Db::getInstance()->ExecuteS(' foreach(Db::getInstance()->ExecuteS('
SELECT DISTINCT(o.`id_order`) AS `id_order` SELECT DISTINCT(o.`id_order`) AS `id_order`
FROM `'._DB_PREFIX_.'order_detail` od FROM `'._DB_PREFIX_.'order_detail` od
@ -995,6 +1014,11 @@ class Sale {
SELECT `id_order_detail` SELECT `id_order_detail`
FROM `'._DB_PREFIX_.'lapostews` la FROM `'._DB_PREFIX_.'lapostews` la
WHERE la.`quantity` = (od.`product_quantity` - od.`product_quantity_refunded`) WHERE la.`quantity` = (od.`product_quantity` - od.`product_quantity_refunded`)
)
AND od.`id_order_detail` NOT IN (
SELECT `id_order_detail`
FROM `'._DB_PREFIX_.'mondialrelay_parcel` mr
WHERE mr.`quantity` = (od.`product_quantity` - od.`product_quantity_refunded`)
)' )'
) as $order) { ) as $order) {
$orders_not_sended[] = $order['id_order']; $orders_not_sended[] = $order['id_order'];

View File

@ -171,32 +171,6 @@ class AdminPrivateSalesLogistique extends AdminTab {
}); });
</script>'; </script>';
// $this->html .= '
// <link rel="stylesheet" type="text/css" href="'.__PS_BASE_URI__.'modules/privatesales_logistique/css/chosen.min.css" />
// <link rel="stylesheet" type="text/css" href="'.__PS_BASE_URI__.'modules/privatesales_logistique/css/privatesales_logistique.css" />
// <script type="text/javascript" src="'.__PS_BASE_URI__.'modules/privatesales_logistique/js/jquery-ui-1.8.20.custom.min.js"></script>
// <script type="text/javascript" src="'.__PS_BASE_URI__.'modules/privatesales_logistique/js/jquery-ui-timepicker-addon.js"></script>
// <script type="text/javascript" src="'.__PS_BASE_URI__.'modules/privatesales_logistique/js/chosen.jquery.min.js"></script>
// <script type="text/javascript" src="'.__PS_BASE_URI__.'modules/privatesales_logistique/js/filtre.js"></script>
// <style type="text/css">
// @import url("'.__PS_BASE_URI__.'modules/privatesales/jquery-ui-1.8.20.custom.css");
// </script>
// <script type="text/javascript">
// $(function() {
// $(".chosen-select").chosen(
// {
// allow_single_deselect:true,
// placeholder_text_single : "Choisir une vente",
// no_results_text : "Aucun résultat",
// enable_split_word_search : true,
// search_contains : true,
// }
// );
// });
// </script>';
} }
public function _displayAfterContent($helperForm, $option_sales,$option_select_langs) public function _displayAfterContent($helperForm, $option_sales,$option_select_langs)
@ -262,7 +236,7 @@ class AdminPrivateSalesLogistique extends AdminTab {
'</div> '</div>
<div class="clearfix"></div>'; <div class="clearfix"></div>';
$this->html .= '</div> $this->html .= '
<div class="clearfix"></div> <div class="clearfix"></div>
<div class="ln_solid"></div> <div class="ln_solid"></div>
<div class="form-group text-right"> <div class="form-group text-right">

View File

@ -37,13 +37,15 @@ class AdminStatsLogistic extends AdminTab {
$this->date_export_begin = Tools::getValue('date_export_begin', $this->date_export_begin); $this->date_export_begin = Tools::getValue('date_export_begin', $this->date_export_begin);
$this->date_export_end = Tools::getValue('date_export_end', $this->date_export_end); $this->date_export_end = Tools::getValue('date_export_end', $this->date_export_end);
$sale_ids = $this->getSales(); $sale_ids = $this->getSales();
if ($sale_ids) { if ($sale_ids) {
foreach ($sale_ids as $sale) { foreach ($sale_ids as $sale) {
//$ps = new Sale((int)$sale['id_sale']); //$ps = new Sale((int)$sale['id_sale']);
//$product_ids = $ps->getProducts(); //$product_ids = $ps->getProducts();
$product_ids = $this->getProducts((int)$sale['id_sale']); $product_ids = $this->getProducts((int)$sale['id_sale']);
if(!$product_ids){
continue;
}
$products = $this->getSaleDetails($product_ids); $products = $this->getSaleDetails($product_ids);
/*foreach ($products as $key => $product) { /*foreach ($products as $key => $product) {
$order_detail_ids[] = (int)$product['id_order_detail']; $order_detail_ids[] = (int)$product['id_order_detail'];
@ -86,6 +88,7 @@ class AdminStatsLogistic extends AdminTab {
$result[(int)$sale['id_sale']]['nb_pole_4'] = 0; $result[(int)$sale['id_sale']]['nb_pole_4'] = 0;
$result[(int)$sale['id_sale']]['nb_pole_5'] = 0; $result[(int)$sale['id_sale']]['nb_pole_5'] = 0;
$result[(int)$sale['id_sale']]['nb_pole_6'] = 0; $result[(int)$sale['id_sale']]['nb_pole_6'] = 0;
$result[(int)$sale['id_sale']]['nb_pole_philea'] = 0;
foreach($products as $row) { foreach($products as $row) {
if (!in_array((int)$row['id_order'],$id_orders)) { if (!in_array((int)$row['id_order'],$id_orders)) {
@ -164,6 +167,9 @@ class AdminStatsLogistic extends AdminTab {
foreach ($shipping_numbers as $id_employee => $value) { foreach ($shipping_numbers as $id_employee => $value) {
$nb_package += count($value); $nb_package += count($value);
switch ($id_employee) { switch ($id_employee) {
case '999':
$result[(int)$sale['id_sale']]['nb_pole_philea'] += count($value);
break;
case '52': case '52':
$result[(int)$sale['id_sale']]['nb_pole_1'] += count($value); $result[(int)$sale['id_sale']]['nb_pole_1'] += count($value);
break; break;
@ -196,6 +202,7 @@ class AdminStatsLogistic extends AdminTab {
$result[(int)$sale['id_sale']]['nb_pole_4'] = number_format(($result[(int)$sale['id_sale']]['nb_pole_4'] / $nb_package)*100,2); $result[(int)$sale['id_sale']]['nb_pole_4'] = number_format(($result[(int)$sale['id_sale']]['nb_pole_4'] / $nb_package)*100,2);
$result[(int)$sale['id_sale']]['nb_pole_5'] = number_format(($result[(int)$sale['id_sale']]['nb_pole_5'] / $nb_package)*100,2); $result[(int)$sale['id_sale']]['nb_pole_5'] = number_format(($result[(int)$sale['id_sale']]['nb_pole_5'] / $nb_package)*100,2);
$result[(int)$sale['id_sale']]['nb_pole_6'] = number_format(($result[(int)$sale['id_sale']]['nb_pole_6'] / $nb_package)*100,2); $result[(int)$sale['id_sale']]['nb_pole_6'] = number_format(($result[(int)$sale['id_sale']]['nb_pole_6'] / $nb_package)*100,2);
$result[(int)$sale['id_sale']]['nb_pole_philea'] = number_format(($result[(int)$sale['id_sale']]['nb_pole_philea'] / $nb_package)*100,2);
} }
} }
if ($result) { if ($result) {
@ -213,11 +220,16 @@ class AdminStatsLogistic extends AdminTab {
} else { } else {
echo '<p class="conf">'.$this->l('No sale found.').'</p>'; echo '<p class="conf">'.$this->l('No sale found.').'</p>';
} }
} elseif (Tools::getValue('submitExportExp')) { } elseif (Tools::isSubmit('submitExportExpLP') || Tools::isSubmit('submitExportExpMR') || Tools::isSubmit('submitExportExpPH')) {
$this->date_expe_begin = Tools::getValue('date_expe_begin', $this->date_expe_begin); $this->date_expe_begin = Tools::getValue('date_expe_begin', $this->date_expe_begin);
$this->date_expe_end = Tools::getValue('date_expe_end', $this->date_expe_end); $this->date_expe_end = Tools::getValue('date_expe_end', $this->date_expe_end);
if(Tools::isSubmit('submitExportExpLP')) {
$details = $this->getShippingDetails(); $details = $this->getShippingDetails();
} elseif(Tools::isSubmit('submitExportExpMR')) {
$details = $this->getShippingMRDetails();
} elseif(Tools::isSubmit('submitExportExpPH')) {
$details = $this->getShippingPhileaDetails();
}
if ($details) { if ($details) {
foreach ($details as $key => &$row) { foreach ($details as $key => &$row) {
$sale_info = $this->getSaleInfo((int)$row['id_sale']); $sale_info = $this->getSaleInfo((int)$row['id_sale']);
@ -317,7 +329,7 @@ class AdminStatsLogistic extends AdminTab {
$stats = $this->getStats(); $stats = $this->getStats();
$poles = array(); $poles = array();
for ($i=0; $i < 6; $i++) { for ($i=0; $i < 7; $i++) {
$poles[] = array( $poles[] = array(
'recap' => array( 'recap' => array(
'quantity' => 0, 'quantity' => 0,
@ -332,12 +344,18 @@ class AdminStatsLogistic extends AdminTab {
$poles[3]['name'] = 'Pôle 4 : Postes complementaires'; $poles[3]['name'] = 'Pôle 4 : Postes complementaires';
$poles[4]['name'] = 'Pôle 5 : Multi'; $poles[4]['name'] = 'Pôle 5 : Multi';
$poles[5]['name'] = 'Pôle 6 : Autre'; $poles[5]['name'] = 'Pôle 6 : Autre';
$poles[6]['name'] = 'Pôle Philea';
$total_quantity = 0; $total_quantity = 0;
foreach ($stats as $key => $stat) { foreach ($stats as $key => $stat) {
if (!isset($stat['id_employee'])) { if (!isset($stat['id_employee'])) {
continue; continue;
} }
switch ($stat['id_employee']) { switch ((int)$stat['id_employee']) {
case '999':
$poles[6]['recap']['quantity'] += $stat['quantity'];
$poles[6]['recap']['nb_package'] += $stat['nb_package'];
$poles[6]['employee'][] = $stat;
break;
case '52': case '52':
$poles[0]['recap']['quantity'] += $stat['quantity']; $poles[0]['recap']['quantity'] += $stat['quantity'];
$poles[0]['recap']['nb_package'] += $stat['nb_package']; $poles[0]['recap']['nb_package'] += $stat['nb_package'];
@ -402,10 +420,10 @@ class AdminStatsLogistic extends AdminTab {
</tr>'; </tr>';
foreach ($pole['employee'] as $key => $stat) { foreach ($pole['employee'] as $key => $stat) {
echo '<tr> echo '<tr>
<td>'.$stat['id_employee'].'</td> <td>'.($stat['id_employee']==999?"Expe Philéa":$stat['id_employee']).'</td>
<td>'.$stat['firstname'].'</td> <td>'.(isset($stat['firstname'])?$stat['firstname']:"").'</td>
<td>'.$stat['lastname'].'</td> <td>'.(isset($stat['lastname'])?$stat['lastname']:"").'</td>
<td>'.$stat['email'].'</td> <td>'.(isset($stat['email'])?$stat['email']:"").'</td>
<td>'.$stat['quantity'].'</td> <td>'.$stat['quantity'].'</td>
<td>'.$stat['nb_package'].'</td> <td>'.$stat['nb_package'].'</td>
<td>'. number_format(($stat['nb_package']* 100 / $total_colis), 2) .' %</td> <td>'. number_format(($stat['nb_package']* 100 / $total_colis), 2) .' %</td>
@ -506,7 +524,7 @@ class AdminStatsLogistic extends AdminTab {
.'</form> .'</form>
</fieldset>'; </fieldset>';
echo '<br><br><h2 style="margin-top:15px">Export Expeditions La Poste</h2> echo '<br><br><h2 style="margin-top:15px">Export Expeditions</h2>
<fieldset> <fieldset>
<p>Exporter le détail des expeditions dont la date est comprise entre : </p> <p>Exporter le détail des expeditions dont la date est comprise entre : </p>
<form method="POST" action="'.$currentIndex.'" >' <form method="POST" action="'.$currentIndex.'" >'
@ -520,7 +538,9 @@ class AdminStatsLogistic extends AdminTab {
.'</span>' .'</span>'
.'<input type="hidden" name="token" value="'.Tools::getAdminTokenLite(__CLASS__).'" />' .'<input type="hidden" name="token" value="'.Tools::getAdminTokenLite(__CLASS__).'" />'
.'<input type="hidden" name="tab" value="'.__CLASS__.'" />' .'<input type="hidden" name="tab" value="'.__CLASS__.'" />'
.'<input type="submit" class="button" name="submitExportExp" value="Exporter les Expéditions" />' .'<input type="submit" class="button" name="submitExportExpLP" value="Expé La Poste" />'
.'<input type="submit" class="button" name="submitExportExpMR" value="Expé Mondial Relay" />'
.'<input type="submit" class="button" name="submitExportExpPH" value="Expé Philéa" />'
.'</form> .'</form>
</fieldset>' </fieldset>'
; ;
@ -528,7 +548,7 @@ class AdminStatsLogistic extends AdminTab {
} }
public function getStats() { public function getStats() {
return Db::getInstance()->executeS(' $query1 = Db::getInstance()->executeS('
SELECT SELECT
e.`id_employee`, e.`id_employee`,
e.`email`, e.`email`,
@ -540,8 +560,21 @@ class AdminStatsLogistic extends AdminTab {
FROM `'._DB_PREFIX_.'stats_logistic` s FROM `'._DB_PREFIX_.'stats_logistic` s
LEFT JOIN `'._DB_PREFIX_.'employee` e USING(`id_employee`) LEFT JOIN `'._DB_PREFIX_.'employee` e USING(`id_employee`)
WHERE s.`date` BETWEEN "'.pSQL($this->date_begin).'" AND "'.pSQL($this->date_end).'" WHERE s.`date` BETWEEN "'.pSQL($this->date_begin).'" AND "'.pSQL($this->date_end).'"
AND e.`id_employee` IS NOT NULL
GROUP BY s.`id_employee` GROUP BY s.`id_employee`
'); ');
$query2 = Db::getInstance()->executeS('
SELECT
`id_employee`,
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
WHERE s.`date` BETWEEN "'.pSQL($this->date_begin).'" AND "'.pSQL($this->date_end).'"
AND s.`id_employee` = 999
GROUP BY s.`id_employee`
');
return array_merge($query1,$query2);
} }
public function getTotalColis() { public function getTotalColis() {
@ -573,30 +606,52 @@ class AdminStatsLogistic extends AdminTab {
} }
public function getSaleDetails($product_ids) { public function getSaleDetails($product_ids) {
return Db::getInstance()->ExecuteS(' $sale_details = array();
$sale_details_lpw = Db::getInstance()->ExecuteS('
SELECT od.*, rr.`id_reason`, pws.`id_employee`, pws.`shipping_number`, SELECT od.*, rr.`id_reason`, pws.`id_employee`, pws.`shipping_number`,
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` 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`
FROM `'._DB_PREFIX_.'order_detail` od FROM `'._DB_PREFIX_.'order_detail` od
-- LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = od.`id_order`)
LEFT JOIN `'._DB_PREFIX_.'order_slip` os ON (os.`id_order` = od.`id_order`) LEFT JOIN `'._DB_PREFIX_.'order_slip` os ON (os.`id_order` = od.`id_order`)
LEFT JOIN `'._DB_PREFIX_.'lapostews` pws ON (pws.`id_order_detail` = od.`id_order_detail`) LEFT JOIN `'._DB_PREFIX_.'lapostews` pws ON (pws.`id_order_detail` = od.`id_order_detail`)
LEFT JOIN `'._DB_PREFIX_.'refundreason` rr ON (rr.`id_order_slip` = os.`id_order_slip`) LEFT JOIN `'._DB_PREFIX_.'refundreason` rr ON (rr.`id_order_slip` = os.`id_order_slip`)
WHERE od.`product_id` IN ('.implode(',', $product_ids).') WHERE od.`product_id` IN ('.implode(',', $product_ids).')
-- AND o.`valid` = 1 AND pws.id_order_detail IS NOT NULL
-- AND od.`product_quantity_refunded`>0 ORDER BY rr.`id_reason`');
$sale_details_mr = Db::getInstance()->ExecuteS('
SELECT od.*, rr.`id_reason`, mrp.`id_employee`, mrp.`shipping_number`,
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`
FROM `'._DB_PREFIX_.'order_detail` od
LEFT JOIN `'._DB_PREFIX_.'order_slip` os ON (os.`id_order` = od.`id_order`)
LEFT JOIN `'._DB_PREFIX_.'mondialrelay_parcel` mrp ON (mrp.`id_order_detail` = od.`id_order_detail`)
LEFT JOIN `'._DB_PREFIX_.'refundreason` rr ON (rr.`id_order_slip` = os.`id_order_slip`)
WHERE od.`product_id` IN ('.implode(',', $product_ids).')
AND mrp.id_order_detail IS NOT NULL
ORDER BY rr.`id_reason` ORDER BY rr.`id_reason`
'); ');
$sale_details_ph = Db::getInstance()->ExecuteS('
SELECT od.*, rr.`id_reason`, "999" AS `id_employee`, ph.`shipping_number`,
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`
FROM `'._DB_PREFIX_.'order_detail` od
LEFT JOIN `'._DB_PREFIX_.'order_slip` os ON (os.`id_order` = od.`id_order`)
LEFT JOIN `'._DB_PREFIX_.'philea_parcel` ph ON (ph.`id_order_detail` = od.`id_order_detail`)
LEFT JOIN `'._DB_PREFIX_.'refundreason` rr ON (rr.`id_order_slip` = os.`id_order_slip`)
WHERE od.`product_id` IN ('.implode(',', $product_ids).')
AND ph.id_order_detail IS NOT NULL
ORDER BY rr.`id_reason`
');
$sale_details = array_merge($sale_details_lpw, $sale_details_mr,$sale_details_ph);
return $sale_details;
} }
public function getPackageDetails($order_detail_ids) { public function getPackageDetails($order_detail_ids) {
return Db::getInstance()->ExecuteS(' return Db::getInstance()->ExecuteS('
SELECT pws.`id_order_detail`, pws.`id_employee`, pws.`shipping_number` SELECT pws.`id_order_detail`, pws.`id_employee`, pws.`shipping_number`
FROM `'._DB_PREFIX_.'lapostews` pws FROM `'._DB_PREFIX_.'lapostews` pws
WHERE pws.`id_order_detail` IN ('.implode(',', $order_detail_ids).') WHERE pws.`id_order_detail` IN ('.implode(',', $order_detail_ids).')
'); ');
} }
public function getShippingDetails() { public function getShippingDetails() {
return Db::getInstance()->ExecuteS(' 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`, 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` 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`
@ -607,7 +662,32 @@ class AdminStatsLogistic extends AdminTab {
WHERE pws.`date_add` BETWEEN "'.pSQL($this->date_expe_begin).'" AND "'.pSQL($this->date_expe_end).'" WHERE pws.`date_add` BETWEEN "'.pSQL($this->date_expe_begin).'" AND "'.pSQL($this->date_expe_end).'"
ORDER BY pws.`date_add` ASC ORDER BY pws.`date_add` ASC
'); ');
} }
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`
FROM `'._DB_PREFIX_.'mondialrelay_parcel` pmr
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = pmr.`id_order_detail`)
LEFT JOIN `'._DB_PREFIX_.'employee` e ON (e.`id_employee` = pmr.`id_employee`)
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` psc ON (psc.`id_product` = od.`product_id`)
WHERE pmr.`date_add` BETWEEN "'.pSQL($this->date_expe_begin).'" AND "'.pSQL($this->date_expe_end).'"
ORDER BY pmr.`date_add` ASC
');
}
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`
FROM `'._DB_PREFIX_.'philea_parcel` pph
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = pph.`id_order_detail`)
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` psc ON (psc.`id_product` = od.`product_id`)
WHERE pph.`date_add` BETWEEN "'.pSQL($this->date_expe_begin).'" AND "'.pSQL($this->date_expe_end).'"
ORDER BY pph.`date_add` ASC
');
}
public function getSales() { public function getSales() {
return Db::getInstance()->ExecuteS(' return Db::getInstance()->ExecuteS('
@ -759,7 +839,8 @@ class AdminStatsLogistic extends AdminTab {
"% colis Pole 3", "% colis Pole 3",
"% colis Pole 4", "% colis Pole 4",
"% colis Pole 5", "% colis Pole 5",
"% colis Pole 6" "% colis Pole 6",
"% colis Pole Philea"
) )
); );
fputcsv ($fp,$row_1,$delim); fputcsv ($fp,$row_1,$delim);
@ -773,7 +854,7 @@ class AdminStatsLogistic extends AdminTab {
$data[] = $val; $data[] = $val;
} }
} else { } else {
$data[] = $value; $data[] = $value;
} }
} }
fputcsv ($fp,array_map('utf8_decode',array_values($data)),$delim); fputcsv ($fp,array_map('utf8_decode',array_values($data)),$delim);

View File

@ -10,7 +10,7 @@ if (!empty($argv[1])) {
} }
Configuration::updateValue('MAJ_STAT_LOGISTIC', date('Y-m-d H:i:s')); Configuration::updateValue('MAJ_STAT_LOGISTIC', date('Y-m-d H:i:s'));
// laposte
$query = ' $query = '
INSERT INTO `'._DB_PREFIX_.'stats_logistic` INSERT INTO `'._DB_PREFIX_.'stats_logistic`
SELECT SELECT
@ -28,5 +28,45 @@ $query = '
`quantity` = VALUES(`quantity`), `quantity` = VALUES(`quantity`),
`nb_package` = VALUES(`nb_package`) `nb_package` = VALUES(`nb_package`)
'; ';
Db::getInstance()->execute($query); Db::getInstance()->execute($query);
// philea
$query = '
INSERT INTO `'._DB_PREFIX_.'stats_logistic`
SELECT
NULL AS `id`,
"999" AS `id_employee`,
`date_add` AS `date`,
COUNT(`id_order_detail`) AS `nb_product`,
SUM(`quantity`) AS `quantity`,
COUNT(DISTINCT `shipping_number`) AS `nb_package`
FROM `'._DB_PREFIX_.'philea_parcel`
WHERE DATE(`date_add`) = "'.pSQL($date).'"
GROUP BY `id_employee` , DATE(`date_add`)
ON DUPLICATE KEY UPDATE
`nb_product` = VALUES(`nb_product`),
`quantity` = VALUES(`quantity`),
`nb_package` = VALUES(`nb_package`)
';
Db::getInstance()->execute($query);
// Mondial relay
$query = '
INSERT INTO `'._DB_PREFIX_.'stats_logistic`
SELECT
NULL AS `id`,
`id_employee` AS `id_employee`,
`date_add` AS `date`,
COUNT(`id_order_detail`) AS `nb_product`,
SUM(`quantity`) AS `quantity`,
COUNT(DISTINCT `shipping_number`) AS `nb_package`
FROM `'._DB_PREFIX_.'mondialrelay_parcel`
WHERE DATE(`date_add`) = "'.pSQL($date).'"
GROUP BY `id_employee` , DATE(`date_add`)
ON DUPLICATE KEY UPDATE
`nb_product` = VALUES(`nb_product`),
`quantity` = VALUES(`quantity`),
`nb_package` = VALUES(`nb_package`)
';
Db::getInstance()->execute($query);