147 lines
5.7 KiB
PHP
Executable File
147 lines
5.7 KiB
PHP
Executable File
<?php
|
||
/**
|
||
* MODULE PRESTASHOP OFFICIEL CHRONOPOST
|
||
*
|
||
* LICENSE : All rights reserved - COPY AND REDISTRIBUTION FORBIDDEN WITHOUT PRIOR CONSENT FROM OXILEO
|
||
* LICENCE : Tous droits réservés, le droit d'auteur s'applique - COPIE ET REDISTRIBUTION INTERDITES SANS ACCORD EXPRES D'OXILEO
|
||
*
|
||
* @author Oxileo SAS <contact@oxileo.eu>
|
||
* @copyright 2001-2014 Oxileo SAS
|
||
* @license Proprietary - no redistribution without authorization
|
||
*/
|
||
|
||
class AdminBordereauChronopost extends AdminTab
|
||
{
|
||
|
||
public function __construct()
|
||
{
|
||
|
||
$this->table = 'order';
|
||
$this->className = 'AdminBordereauChronopost';
|
||
$this->view = false;
|
||
$this->noLink = true;
|
||
$this->delete = true;
|
||
$this->colorOnBackground = true;
|
||
|
||
/*
|
||
// set default filtering state
|
||
if(!isset($_POST) || !array_key_exists('submitFilter', $_POST))
|
||
{
|
||
$this->_filter=" AND os.`id_order_state` = 3 ";
|
||
$_POST['orderFilter_os!id_order_state']='3';
|
||
}
|
||
*/
|
||
|
||
$this->_select = '
|
||
a.id_order AS id_pdf,
|
||
CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`,
|
||
osl.`name` AS `osname`,
|
||
os.`color`,
|
||
IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new,
|
||
(SELECT COUNT(od.`id_order`) FROM `'._DB_PREFIX_.'order_detail` od WHERE od.`id_order` = a.`id_order` GROUP BY `id_order`) AS product_number';
|
||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)
|
||
LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (oh.`id_order` = a.`id_order`)
|
||
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = oh.`id_order_state`)
|
||
LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)($this->context->language->id).')';
|
||
$this->_where = 'AND oh.`id_order_history` = (SELECT MAX(`id_order_history`) FROM `'._DB_PREFIX_.'order_history` moh WHERE moh.`id_order` = a.`id_order` GROUP BY moh.`id_order`) '
|
||
.' AND (a.id_carrier='.((int)Configuration::get('CHRONOPOST_CARRIER_ID'))
|
||
.' OR a.id_carrier='.((int)Configuration::get('CHRONORELAIS_CARRIER_ID'))
|
||
.' OR a.id_carrier='.((int)Configuration::get('CHRONOEXPRESS_CARRIER_ID'))
|
||
.' OR a.id_carrier='.((int)Configuration::get('CHRONO10_CARRIER_ID'))
|
||
.' OR a.id_carrier='.((int)Configuration::get('CHRONO18_CARRIER_ID'))
|
||
.' OR a.id_carrier='.((int)Configuration::get('CHRONOCLASSIC_CARRIER_ID'))
|
||
.') ';
|
||
|
||
$statesArray = array();
|
||
$states = OrderState::getOrderStates((int)($this->context->language->id));
|
||
|
||
foreach ($states AS $state)
|
||
$statesArray[$state['id_order_state']] = $state['name'];
|
||
$this->fieldsDisplay = array(
|
||
//'id_pdf' => array('title' => $this->l('Export'), 'callback' => 'selectButton', 'orderby' => false, 'search' => false),
|
||
'id_order' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||
'customer' => array('title' => $this->l('Customer'), 'widthColumn' => 160, 'width' => 140, 'filter_key' => 'customer', 'tmpTableFilter' => true),
|
||
'total_paid' => array('title' => $this->l('Total'), 'width' => 70, 'align' => 'right', 'prefix' => '<b>', 'suffix' => '</b>', 'price' => true, 'currency' => true),
|
||
'payment' => array('title' => $this->l('Payment'), 'width' => 100),
|
||
'osname' => array('title' => $this->l('Status'), 'widthColumn' => 230, 'type' => 'select', 'select' => $statesArray, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int', 'width' => 200),
|
||
'date_add' => array('title' => $this->l('Date'), 'width' => 35, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add')
|
||
);
|
||
|
||
parent::__construct();
|
||
}
|
||
|
||
public function display()
|
||
{
|
||
|
||
echo '
|
||
<script type="text/javascript">
|
||
function checkOrdersSelected(e)
|
||
{
|
||
checkboxes=$("table input[type=checkbox]:checked");
|
||
if(checkboxes.length==0)
|
||
{
|
||
alert("Vous devez sélectionner des commandes pour effectuer un export.");
|
||
return false;
|
||
}
|
||
}
|
||
|
||
$(function() {
|
||
// change actions column
|
||
$("table tbody tr td.center:last-child").remove();
|
||
$("table thead tr th:last-child").remove();
|
||
|
||
// hide errors
|
||
$("div.error").remove();
|
||
|
||
// change deletion button
|
||
$("input[name=submitDelorder]").attr("onclick", "");
|
||
$("input[name=submitDelorder]").click(checkOrdersSelected);
|
||
$("input[name=submitDelorder]").attr("value", "Editer bordereau");
|
||
$("input[name=submitDelorder]").css("clear:left;");
|
||
});
|
||
|
||
|
||
|
||
|
||
</script>';
|
||
echo '<h2>Edition du bordereau de fin de journée</h2>';
|
||
echo '<p class="hint" style="display:block;position:relative">N’oubliez pas d\'imprimer le bordereau de remise en deux exemplaires, un doit être remis lors de l\'enlèvement ou du dépôt ; l\'autre est à conserver. Les deux doivent être signés.</p><div style="clear:both"><center>';
|
||
$this->getList((int)($this->context->language->id), !Tools::getValue($this->table.'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table.'Orderway') ? 'DESC' : NULL);
|
||
|
||
$currency = new Currency((int)(Configuration::get('PS_CURRENCY_DEFAULT')));
|
||
|
||
|
||
$this->displayList();
|
||
echo '</center></div>';
|
||
|
||
}
|
||
|
||
public static function selectButton($id_order, $tr)
|
||
{
|
||
echo '<input type="checkbox" value="'.$id_order.'" id="exportSelect['.$id_order.']" class="exportSelect"/>';
|
||
}
|
||
|
||
|
||
public function deleteSelection($table)
|
||
{
|
||
|
||
echo '<script type="text/javascript">
|
||
setTimeout("delayer()", 1000);
|
||
function delayer() {
|
||
window.location = "../modules/chronopost/generateBordereau.php?shared_secret='.Configuration::get('CHRONOPOST_SECRET').'&orders='
|
||
.implode(';', Tools::getValue('orderBox')).'";
|
||
};
|
||
</script>';
|
||
echo '<div class="conf">
|
||
Votre bordereau sera téléchargé automatiquement dans quelques secondes.
|
||
</div>';
|
||
|
||
return false; // prevents redirection
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
|