Merge branch 'develop' of gitlab.antadis.net:dev-antadis/bebeboutik into develop
This commit is contained in:
commit
6019366684
@ -1,38 +1,332 @@
|
||||
<?php
|
||||
class AdminAntAlert extends AdminTab {
|
||||
public function postProcess() {
|
||||
if(($limit = Tools::getValue('ant_alert_limit')) !== FALSE) {
|
||||
Configuration::updateValue('ANT_ALTER_LIMIT', (int) $limit);
|
||||
}
|
||||
if($hours = Tools::getValue('ant_alert_hours')) {
|
||||
Configuration::updateValue('ANT_ALTER_HOURS', (int) $hours);
|
||||
}
|
||||
}
|
||||
public function display() {
|
||||
global $cookie;
|
||||
include_once(_PS_MODULE_DIR_.'/ant_alert/ant_alert.php');
|
||||
require_once(PS_ADMIN_DIR . '/helpers/HelperFormBootstrap.php');
|
||||
|
||||
echo '
|
||||
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
|
||||
<fieldset>
|
||||
<legend><img src="../img/admin/AdminTools.gif" alt="" />'.$this->l('Configuration Alert').'</legend>
|
||||
<p>'.$this->l('Last send : ').Configuration::get('ANT_ALTER_DATESEND').'<p>
|
||||
<div style="overflow: auto;">
|
||||
<label style="font-weight:normal; padding-top: 1px; width: 250px">'.$this->l('Limit (mail number before sending alert)').'</label>
|
||||
<div class="margin-form">
|
||||
<input value="'. Configuration::get('ANT_ALTER_LIMIT') .'" type="text" size="120" name="ant_alert_limit">
|
||||
</div>
|
||||
</div>
|
||||
<div style="overflow: auto;">
|
||||
<label style="font-weight:normal; padding-top: 1px; width: 250px">'.$this->l('Time (in hours, ex: by 24h)').'</label>
|
||||
<div class="margin-form">
|
||||
<input value="'. Configuration::get('ANT_ALTER_HOURS') .'" type="text" size="120" name="ant_alert_hours">
|
||||
</div>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input value="'. $this->l('Sauvegarder') .'" type="submit" name="saveAntAlert" class="button">
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
<br class="clear" />';
|
||||
class AdminAntAlert extends AdminTab {
|
||||
|
||||
protected $_html;
|
||||
public $module_name;
|
||||
public $config_tab;
|
||||
public $controller;
|
||||
public $helperForm;
|
||||
public $_object;
|
||||
|
||||
public function __construct($config_tab = true)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->_object = false;
|
||||
$this->controller = 'AdminModules';
|
||||
$this->module_name = 'ant_alert';
|
||||
$this->config_tab = (bool)$config_tab;
|
||||
if ($config_tab) {
|
||||
$this->controller = 'AdminAntAlert';
|
||||
}
|
||||
$this->helperForm = new HelperFormBootstrap();
|
||||
$this->helperForm->_select2 = true;
|
||||
$this->helperForm->_inputSwitch = true;
|
||||
}
|
||||
|
||||
protected function _postProcess()
|
||||
{
|
||||
if (Tools::isSubmit('newAlert')) {
|
||||
|
||||
} elseif (Tools::isSubmit('addAlert')) {
|
||||
$this->_addOrUpdateAlert(false);
|
||||
} elseif (Tools::isSubmit('editAlert')) {
|
||||
$this->_addOrUpdateAlert(true);
|
||||
} elseif (Tools::isSubmit('loadAlert') && Tools::getValue('id')) {
|
||||
$this->_object = new AntAlert((int)Tools::getValue('id'));
|
||||
} elseif (Tools::isSubmit('deleteAlert') && Tools::getValue('id')) {
|
||||
$deleted_alert = new AntAlert((int)Tools::getValue('id'));
|
||||
$res = $deleted_alert->delete();
|
||||
if ($res) {
|
||||
$this->_html .= HelperFormBootstrap::displaySuccess($this->l('Alert deleted : #') . (int)Tools::getValue('id'));
|
||||
} else {
|
||||
$this->_html .= HelperFormBootstrap::displayError($this->l('Alert cannot be deleted : #') . (int)Tools::getValue('id'));
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
protected function _addOrUpdateAlert($edit = false)
|
||||
{
|
||||
if ($edit) {
|
||||
$alert = new AntAlert((int)Tools::getValue('id_alert'));
|
||||
} else {
|
||||
$alert = new AntAlert();
|
||||
$alert->date_last_send = date("Y-m-d H:i:s");
|
||||
}
|
||||
|
||||
$alert->id_contact = Tools::getValue('id_contact');
|
||||
$alert->limit = Tools::getValue('limit');
|
||||
$alert->hours = Tools::getValue('hours');
|
||||
$alert->enabled = (int)Tools::getValue('enabled');
|
||||
|
||||
if ($alert->save()) {
|
||||
if ($edit) {
|
||||
$this->_html .= HelperFormBootstrap::displaySuccess($this->l('Alert has been updated'));
|
||||
} else {
|
||||
$this->_html .= HelperFormBootstrap::displaySuccess($this->l('Alert has been created'));
|
||||
}
|
||||
} else {
|
||||
$this->_html .= HelperFormBootstrap::displayError($this->l('Error occured while updating alert'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function display()
|
||||
{
|
||||
parent::displayForm();
|
||||
|
||||
$this->_html = '';
|
||||
|
||||
$this->_postProcess();
|
||||
|
||||
$this->_addCss();
|
||||
$this->_html .= $this->helperForm->renderStyle();
|
||||
|
||||
$this->_displayForm();
|
||||
$this->_displayList();
|
||||
|
||||
$this->_html .='<div class="clearfix"></div>';
|
||||
$this->_addJs();
|
||||
$this->_html .= $this->helperForm->renderScript();
|
||||
echo $this->_html;
|
||||
}
|
||||
|
||||
|
||||
protected function _addJs()
|
||||
{
|
||||
$this->helperForm->_js .= '<script type="text/javascript"></script>';
|
||||
}
|
||||
|
||||
protected function _addCss()
|
||||
{
|
||||
$this->helperForm->_css .='
|
||||
.table tr th {
|
||||
background: #565485;
|
||||
background: rgba(86,84,133,0.9);
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
}
|
||||
.table tr:nth-child(even) {
|
||||
background: #F1F1F1;
|
||||
}
|
||||
.table .input-group-btn .btn {
|
||||
padding: 4px 5px;
|
||||
color: #504d8b;
|
||||
|
||||
}
|
||||
.table .input-group-btn .btn .anticon{
|
||||
font-size: 12px;
|
||||
}
|
||||
.bg-grey{
|
||||
background: #EFEFEF;
|
||||
border-radius:4px;
|
||||
}
|
||||
.bg-grey .div-title {
|
||||
border-bottom: 2px solid #504D8B;
|
||||
}
|
||||
';
|
||||
}
|
||||
|
||||
protected function _displayList()
|
||||
{
|
||||
global $cookie, $currentIndex;
|
||||
|
||||
$id_lang = (int)$cookie->id_lang;
|
||||
$contacts = Contact::getContacts($cookie->id_lang);
|
||||
|
||||
$alerts = AntAlert::getAlerts(false);
|
||||
$_current_index = ($this->config_tab ? $currentIndex . '&token=' . Tools::getAdminTokenLite($this->controller) : $_SERVER['REQUEST_URI']);
|
||||
|
||||
$this->_html .='
|
||||
<div class="col-md-12">
|
||||
<div class="panel">
|
||||
<div class="panel-title">
|
||||
<h2><span class="text-rose anticon anticon-list"></span> '.$this->l('Liste des Alertes').'</h2>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div class="panel-content">
|
||||
<table class="table table-custombordered" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-left">'.$this->l('ID').'</th>
|
||||
<th class="text-left">'.$this->l('Contact').'</th>
|
||||
<th class="text-left">'.$this->l('Mess per hours').'</th>
|
||||
<th class="text-left">'.$this->l('Last sent').'</th>
|
||||
<th class="text-center">'.$this->l('Active').'</th>
|
||||
<th class="text-center">'.$this->l('Action').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
foreach ($alerts as $alert)
|
||||
{
|
||||
$current_contact = $this->_search($contacts,'id_contact',(int)$alert['id_contact']);
|
||||
$this->_html .='
|
||||
<tr>
|
||||
<td valign="middle" align="left">#'.$alert['id_alert'].'</td>
|
||||
<td valign="middle" align="left"><b>'.$current_contact['name'].'</b></td>
|
||||
<td valign="middle" align="left"><b>'.$alert['limit'].' <i class="glyphicon glyphicon-envelope"></i> / '.$alert['hours'].'h</b></td>
|
||||
<td valign="middle" align="left"><i class="glyphicon glyphicon-time"></i> '.date('d/m/Y H:i',strtotime($alert['date_last_sent'])).'</td>
|
||||
<td align="center">'.((int)$alert['enabled']?'<span class="anticon anticon-checkmark text-green-light"></span>':'<span class="anticon anticon-cross text-rose"></span>').'</td>
|
||||
<td valign="middle" align="center">
|
||||
<div class="input-group-btn" role="group" aria-label="...">
|
||||
<a href="'.$_current_index.'&loadAlert=1&id='.$alert['id_alert'].'" class="btn btn-default"><span class="anticon anticon-pencil2"></span></a>
|
||||
<a href="'.$_current_index.'&deleteAlert=1&id='.$alert['id_alert'].'" class="btn btn-default"><span class="anticon anticon-bin"></span></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
$this->_html .='
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
}
|
||||
|
||||
private function _displayForm()
|
||||
{
|
||||
global $cookie, $currentIndex;
|
||||
if (Validate::isLoadedObject($this->_object)){
|
||||
$alert = $this->_object;
|
||||
}
|
||||
$contacts = Contact::getContacts($cookie->id_lang);
|
||||
$alreadyUsedContacts = AntAlert::getAlreadyUsedContacts();
|
||||
foreach($contacts as $contact) {
|
||||
$id_contacts[(int)$contact['id_contact']] = array(
|
||||
'label' => $contact['name'],
|
||||
'value' => (int) $contact['id_contact']
|
||||
);
|
||||
if($alert!==NULL && $alert->id_contact==$contact['id_contact']) {
|
||||
$id_contacts[(int)$contact['id_contact']]['selected'] = true;
|
||||
}elseif(in_array($contact['id_contact'], $alreadyUsedContacts)){
|
||||
$id_contacts[(int)$contact['id_contact']]['disabled'] = true;
|
||||
}
|
||||
}
|
||||
$this->helperForm->_forms = array(
|
||||
array(
|
||||
'action' => $currentIndex . '&token=' . Tools::getAdminTokenLite('AdminAntAlert'),
|
||||
'title' => '<span class="text-rose glyphicon glyphicon-tags"></span> '.$this->l('Alert'),
|
||||
'class' => 'form-horizontal',
|
||||
'class_div' => 'col-md-12',
|
||||
'sections' => array(
|
||||
array(
|
||||
'class' => 'col-md-6',
|
||||
'inputs' => array(
|
||||
array(
|
||||
'type' => 'select2',
|
||||
'name' => 'id_contact',
|
||||
// 'label-class' => 'col-md-5',
|
||||
// 'input-class' => 'col-md-6',
|
||||
'label' => $this->l('Contact'),
|
||||
'options' => $id_contacts,
|
||||
),
|
||||
array(
|
||||
'type' => 'simpleText',
|
||||
'name' => 'limit',
|
||||
'label-class' => 'col-md-3',
|
||||
'input-class' => 'col-md-6',
|
||||
'label' => $this->l('Limit'),
|
||||
'default' => (isset($alert)?$alert->limit:'')
|
||||
),
|
||||
array(
|
||||
'type' => 'simpleText',
|
||||
'name' => 'hours',
|
||||
'label-class' => 'col-md-3',
|
||||
'input-class' => 'col-md-6',
|
||||
'label' => $this->l('Hours'),
|
||||
'default' => (isset($alert)?$alert->hours:'')
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Active'),
|
||||
'label-class' => 'col-md-3',
|
||||
'input-class' => 'col-md-6',
|
||||
'class-group' => 'switch',
|
||||
'name' => 'enabled',
|
||||
'title' => ' ',
|
||||
'default' => (isset($alert)?($alert->enabled==0?0:1):1),
|
||||
'checked' => (isset($alert)?($alert->enabled==0?0:1):1),
|
||||
),
|
||||
),
|
||||
'actions' => array(),
|
||||
'actions-class' => 'text-right',
|
||||
),
|
||||
array(
|
||||
'class' => 'col-md-6 bg-grey',
|
||||
'title' => '<span class="anticon anticon-info"></span> Informations',
|
||||
'inputs' => array(),
|
||||
'info_html' => '
|
||||
<p>La limite des messages est par heures et par type de contact.</p>
|
||||
<br>
|
||||
Par exemple :</p>
|
||||
<ul>
|
||||
<li style="font-size:13px;"><b>50</b> en <b>1</b> heure pour le contact "Retour/Echange" </li>
|
||||
</ul>
|
||||
<p>Ici un mail d\'alert se déclenche au 51 messages envoyés dans la même heure si le message concerne les Retour/Echange.</p>
|
||||
<p>Une seule alerte par type de contact possible !</p>
|
||||
<p></p>'
|
||||
),
|
||||
),
|
||||
'actions' => array(),
|
||||
'actions-class' => 'text-right',
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
if (isset($alert)) {
|
||||
$this->helperForm->_forms[0]['sections'][0]['title'] = "Editer une alert";
|
||||
$this->helperForm->_forms[0]['sections'][0]['inputs'][] = array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'id_alert',
|
||||
'value' => $alert->id,
|
||||
'class' => 'large'
|
||||
);
|
||||
$this->helperForm->_forms[0]['sections'][0]['actions'] = array(
|
||||
array(
|
||||
'type' => 'submit',
|
||||
'class' => 'btn-default',
|
||||
'name' => 'newAlert',
|
||||
'value' => $this->l('Nouvelle Alert')
|
||||
),
|
||||
array(
|
||||
'type' => 'submit',
|
||||
'class' => 'btn-primary',
|
||||
'name' => 'editAlert',
|
||||
'value' => $this->l('Editer l\'alert')
|
||||
),
|
||||
);
|
||||
} else {
|
||||
$this->helperForm->_forms[0]['sections'][0]['title'] = "Ajouter une alert";
|
||||
$this->helperForm->_forms[0]['sections'][0]['actions'] = array(
|
||||
array(
|
||||
'type' => 'submit',
|
||||
'class' => 'btn-primary',
|
||||
'name' => 'addAlert',
|
||||
'value' => $this->l('Ajouter l\'alert')
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$this->helperForm->renderForm();
|
||||
}
|
||||
|
||||
public function _search($array, $key, $value)
|
||||
{
|
||||
$results = array();
|
||||
|
||||
if (is_array($array)) {
|
||||
if (isset($array[$key]) && $array[$key] == $value) {
|
||||
return $array;
|
||||
}
|
||||
foreach ($array as $subarray) {
|
||||
$results = array_merge($results, $this->_search($subarray, $key, $value));
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
@ -2,7 +2,9 @@
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
class Ant_Alert extends Module
|
||||
include_once(_PS_MODULE_DIR_.'/ant_alert/models/AntAlert.php');
|
||||
|
||||
class Ant_Alert extends Module
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
@ -19,9 +21,25 @@ class Ant_Alert extends Module
|
||||
$this->description = $this->l('Alert for message of technical error');
|
||||
}
|
||||
|
||||
public function install()
|
||||
public function install()
|
||||
{
|
||||
|
||||
# Add tables
|
||||
$query = '
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'ant_alert` (
|
||||
`id_alert` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`enabled` BOOL NOT NULL,
|
||||
`id_contact` INTEGER NOT NULL,
|
||||
`limit` INTEGER NOT NULL,
|
||||
`hours` INTEGER NOT NULL,
|
||||
`date_add` DATETIME NOT NULL,
|
||||
`date_upd` DATETIME NOT NULL,
|
||||
`date_last_sent` DATETIME NOT NULL,
|
||||
PRIMARY KEY(`id_alert`,`id_contact`)
|
||||
) ENGINE=MyIsam DEFAULT CHARSET=utf8
|
||||
';
|
||||
if(!Db::getInstance()->Execute($query)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$hooks = array(
|
||||
'ant_alert' => array('Ant Alert', 'Called when a message of technical error is sent'),
|
||||
@ -46,9 +64,9 @@ class Ant_Alert extends Module
|
||||
}
|
||||
|
||||
# Set default configuration values
|
||||
Configuration::updateValue('ANT_ALTER_LIMIT', 10);
|
||||
Configuration::updateValue('ANT_ALTER_HOURS', 24);
|
||||
Configuration::updateValue('ANT_ALTER_DATESEND', date('Y-m-d H:i:s'));
|
||||
// Configuration::updateValue('ANT_ALTER_LIMIT', 10);
|
||||
// Configuration::updateValue('ANT_ALTER_HOURS', 24);
|
||||
// Configuration::updateValue('ANT_ALTER_DATESEND', date('Y-m-d H:i:s'));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -69,38 +87,43 @@ class Ant_Alert extends Module
|
||||
public function hookAnt_Alert($params) {
|
||||
global $cookie;
|
||||
|
||||
$date = new Datetime(Configuration::get('ANT_ALTER_DATESEND'));
|
||||
$now = new Datetime;
|
||||
$alert = AntAlert::getAlertByContact((int)$params['id_contact']);
|
||||
if($alert && $alert->enabled == 1) {
|
||||
$date = new Datetime($alert->date_last_send);
|
||||
$now = new Datetime;
|
||||
|
||||
$dteDiff = $date->diff($now);
|
||||
if ((int)$dteDiff->format("%H") >= (int)Configuration::get('ANT_ALTER_HOURS')) { // prod
|
||||
$open_messages = Db::getInstance()->getRow('
|
||||
SELECT COUNT(*) as total
|
||||
FROM '._DB_PREFIX_.'customer_thread ct
|
||||
WHERE ct.status = "open"
|
||||
GROUP BY ct.id_contact HAVING COUNT(*) > 0 AND ct.id_contact = 4'
|
||||
);
|
||||
if ((int)$open_messages['total'] >= (int)Configuration::get('ANT_ALTER_LIMIT')) {
|
||||
// dev
|
||||
// $to = array('marion@antadis.com');
|
||||
// prod
|
||||
$to = array(
|
||||
'frederic@bebeboutik.com',
|
||||
'jacques@bebeboutik.com',
|
||||
'valentin@bebeboutik.com',
|
||||
$dteDiff = $date->diff($now);
|
||||
if ((int)$dteDiff->format("%H") >= $alert->hours) { // prod
|
||||
$open_messages = Db::getInstance()->getRow('
|
||||
SELECT COUNT(*) as total
|
||||
FROM '._DB_PREFIX_.'customer_thread ct
|
||||
WHERE ct.status = "open"
|
||||
GROUP BY ct.id_contact HAVING COUNT(*) > 0 AND ct.id_contact ='.$alert->id_contact
|
||||
);
|
||||
$data = array(
|
||||
'{limit}' => (int)Configuration::get('ANT_ALTER_LIMIT'),
|
||||
'{hours}' => (int)Configuration::get('ANT_ALTER_HOURS'),
|
||||
);
|
||||
foreach ($to as $email) {
|
||||
if(Mail::Send((int)$cookie->id_lang, 'ant_alert', 'Alert error', $data, $to)) {
|
||||
Configuration::updateValue('ANT_ALTER_DATESEND', date('Y-m-d H:i:s'));
|
||||
if ((int)$open_messages['total'] >= (int)$alert->limit) {
|
||||
// dev
|
||||
$to = array('marion@antadis.com');
|
||||
// prod
|
||||
// $to = array(
|
||||
// 'frederic@bebeboutik.com',
|
||||
// 'jacques@bebeboutik.com',
|
||||
// 'valentin@bebeboutik.com',
|
||||
// );
|
||||
$contact = new Contact((int)$alert->id_contact,2);
|
||||
$data = array(
|
||||
'{limit}' => (int)$alert->limit,
|
||||
'{hours}' => (int)$alert->hours,
|
||||
'{contact}' => (int)$contact->name,
|
||||
);
|
||||
foreach ($to as $email) {
|
||||
if(Mail::Send((int)$cookie->id_lang, 'ant_alert', 'Alert error', $data, $to)) {
|
||||
$alert->last_date_sent = date('Y-m-d H:i:s');
|
||||
$alert->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ if (Tools::isSubmit('submitMessage')) {
|
||||
else
|
||||
$errors[] = Tools::displayError('An error occurred while sending message.');
|
||||
}
|
||||
|
||||
Module::hookExec('ant_alert', array('id_contact' => (int)($id_contact)));
|
||||
Module::hookExec('ant_alerthack', array(
|
||||
'email' => $from,
|
||||
'id_customer' => (isset($customer->id)?$customer->id:false),
|
||||
|
@ -262,6 +262,7 @@ class AdminLogistics extends AdminTab {
|
||||
Tools::redirectLink('http://'.$_SERVER['SERVER_NAME'].'/adm/index.php?tab=AdminLogistics&token='.Tools::getAdminTokenLite('AdminLogistics').'&id_order='.(int) Tools::getValue('id_order').'&mode='.Tools::getValue('mode', '').'#'.Tools::getValue('mode', ''));
|
||||
}
|
||||
|
||||
// Generate a new shipping number for product sent with many parcels
|
||||
if( (Tools::isSubmit('submitReprintShip'))
|
||||
&& ((int) $cookie->profile == 1 || (int) $cookie->profile == 9 || (int) $cookie->profile == 7 || (int) $cookie->profile == 14)
|
||||
&& (
|
||||
@ -274,7 +275,7 @@ class AdminLogistics extends AdminTab {
|
||||
$order = new Order((int) $id_order);
|
||||
if(Validate::isLoadedObject($order)) {
|
||||
$parcel_carrier == 'laposte'? $weight = 0.24: TRUE;
|
||||
if($parcel_carrier == "laposte") {
|
||||
if($parcel_carrier == "laposte" || $parcel_carrier == "mondialrelay") {
|
||||
$result = $logistics_carriers[$parcel_carrier]->registerParcel($order, $products, $weight);
|
||||
if($result[0] != '') {
|
||||
$this->_html .= $result[0];
|
||||
@ -288,7 +289,14 @@ class AdminLogistics extends AdminTab {
|
||||
} elseif($render === 'route_error') {
|
||||
$this->_html .= '<p class="error">'.$this->l('Route not found').'</p><br />';
|
||||
} elseif($render !== FALSE) {
|
||||
$this->printLabel($render);
|
||||
if($parcel_carrier == 'mondialrelay') {
|
||||
$this->printLabel($render,true);
|
||||
$f = fopen(dirname(__FILE__).'/label_mr.txt', 'a+');
|
||||
fwrite($f, $render);
|
||||
fclose($f);
|
||||
} else {
|
||||
$this->printLabel($render);
|
||||
}
|
||||
|
||||
$this->_html .= '<p class="conf">'.$this->l('Registration complete, label sent to printer').'</p><br />';
|
||||
|
||||
@ -320,16 +328,17 @@ class AdminLogistics extends AdminTab {
|
||||
} else {
|
||||
$this->html .= '<p class="error">'.$this->l('An error happened during the label rendering').'</p><br />';
|
||||
}
|
||||
} elseif($parcel_carrier=='mondialrelay'
|
||||
&& (
|
||||
($id_order_detail = Tools::getValue('id_order_detail_reprint'))
|
||||
&& ($weight = Tools::getValue('weight_reprint'))
|
||||
)
|
||||
){
|
||||
$result = $logistics_carriers['mondialrelay']->_getRegisteredParcel(new Order($id_order), $id_order_detail, $products, $weight);
|
||||
$render = $logistics_carriers['mondialrelay']->renderLabel(new Order($id_order), $weight, $result[1]);
|
||||
$this->printLabel($render,true);
|
||||
}
|
||||
// elseif($parcel_carrier=='mondialrelay'
|
||||
// && (
|
||||
// ($id_order_detail = Tools::getValue('id_order_detail_reprint'))
|
||||
// && ($weight = Tools::getValue('weight_reprint'))
|
||||
// )
|
||||
// ){
|
||||
// $result = $logistics_carriers['mondialrelay']->_getRegisteredParcel(new Order($id_order), $id_order_detail, $products, $weight);
|
||||
// $render = $logistics_carriers['mondialrelay']->renderLabel(new Order($id_order), $weight, $result[1]);
|
||||
// $this->printLabel($render,true);
|
||||
// }
|
||||
}
|
||||
//$this->printLabel($logistics_carriers['laposte']->renderLabel(new Order((int) $id_order), $weight, $reprint_number));
|
||||
} elseif(Tools::isSubmit('submitTestLaposte')) {
|
||||
|
@ -249,7 +249,7 @@ if($magistorModule->active) {
|
||||
$data .= str_pad( substr(utf8_decode(cleanChar($address_invoice->firstname.' '.$address_invoice->lastname)),0,50), 50, ' ', STR_PAD_RIGHT );
|
||||
if(in_array((int) $order->id_carrier, $carriers_mr)
|
||||
&& $delivery_info
|
||||
&& !in_array($delivery_info['dlv_mode'], array('LD1', 'LDS', 'HOM')
|
||||
&& !in_array($delivery_info['dlv_mode'], array('LD1', 'LDS', 'HOM'))
|
||||
) {
|
||||
// no company name for a delivery in relay point
|
||||
$data .= str_pad( '', 50, ' ', STR_PAD_RIGHT );
|
||||
@ -284,7 +284,7 @@ if($magistorModule->active) {
|
||||
// LIVRAISON MR (NO DOMICILE)
|
||||
elseif(in_array((int) $order->id_carrier, $carriers_mr)
|
||||
&& $delivery_info
|
||||
&& !in_array($delivery_info['dlv_mode'], array('LD1', 'LDS', 'HOM')
|
||||
&& !in_array($delivery_info['dlv_mode'], array('LD1', 'LDS', 'HOM'))
|
||||
) {
|
||||
$data .= str_pad(substr(utf8_decode(cleanChar($address_delivery->firstname.' '.$address_delivery->lastname)), 0, 50), 50, ' ', STR_PAD_RIGHT);
|
||||
// no company name for a delivery in relay point
|
||||
|
@ -707,11 +707,18 @@ class AdminStatsLogistic extends AdminTab {
|
||||
}
|
||||
|
||||
public function getPackageDetails($order_detail_ids) {
|
||||
return Db::getInstance()->ExecuteS('
|
||||
$lp = Db::getInstance()->ExecuteS('
|
||||
SELECT pws.`id_order_detail`, pws.`id_employee`, pws.`shipping_number`
|
||||
FROM `'._DB_PREFIX_.'lapostews` pws
|
||||
WHERE pws.`id_order_detail` IN ('.implode(',', $order_detail_ids).')
|
||||
');
|
||||
$mr = Db::getInstance()->ExecuteS('
|
||||
SELECT mrp.`id_order_detail`, mrp.`id_employee`, mrp.`shipping_number`
|
||||
FROM `'._DB_PREFIX_.'mondialrelay_parcel` mrp
|
||||
WHERE mrp.`id_order_detail` IN ('.implode(',', $order_detail_ids).')
|
||||
');
|
||||
$total = array_merge($lp, $mr);
|
||||
return $total;
|
||||
}
|
||||
|
||||
public function getShippingDetails() {
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
||||
require_once '../../config/config.inc.php';
|
||||
|
||||
$date = date('Y-m-d');
|
||||
@ -11,42 +12,99 @@ if (!empty($argv[1])) {
|
||||
|
||||
Configuration::updateValue('MAJ_STAT_LOGISTIC', date('Y-m-d H:i:s'));
|
||||
// laposte
|
||||
$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_.'lapostews`
|
||||
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);
|
||||
// $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_.'lapostews`
|
||||
// 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);
|
||||
//
|
||||
$parcels = array();
|
||||
|
||||
$lp = Db::getInstance()->executeS('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_.'lapostews`
|
||||
WHERE DATE(`date_add`) = "'.pSQL($date).'"
|
||||
GROUP BY `id_employee` , DATE(`date_add`)');
|
||||
|
||||
foreach($lp as $colis){
|
||||
if(!isset($parcels[$colis['id_employee']])){
|
||||
$parcels[$colis['id_employee']] = $colis;
|
||||
}
|
||||
}
|
||||
|
||||
// Mondial relay
|
||||
$query = '
|
||||
INSERT INTO `'._DB_PREFIX_.'stats_logistic`
|
||||
SELECT
|
||||
// $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` = `nb_product` + VALUES(`nb_product`),
|
||||
// `quantity` = `quantity` + VALUES(`quantity`),
|
||||
// `nb_package` = `nb_package` + VALUES(`nb_package`)
|
||||
// ';
|
||||
// Db::getInstance()->execute($query);
|
||||
//
|
||||
$mr = Db::getInstance()->executeS('SELECT
|
||||
NULL AS `id`,
|
||||
`id_employee` AS `id_employee`,
|
||||
`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);
|
||||
GROUP BY `id_employee` , DATE(`date_add`)');
|
||||
|
||||
foreach($mr as $colis){
|
||||
if(!isset($parcels[$colis['id_employee']])){
|
||||
$parcels[$colis['id_employee']] = $colis;
|
||||
} else {
|
||||
$parcels[$colis['id_employee']]['nb_product'] = $parcels[$colis['id_employee']]['nb_product'] + $colis['nb_product'];
|
||||
$parcels[$colis['id_employee']]['quantity'] = $parcels[$colis['id_employee']]['quantity'] + $colis['quantity'];
|
||||
$parcels[$colis['id_employee']]['nb_package'] = $parcels[$colis['id_employee']]['nb_package'] + $colis['nb_package'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($parcels as $key => $value) {
|
||||
Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'stats_logistic`
|
||||
VALUES(
|
||||
DEFAULT,
|
||||
'.(int)$value['id_employee'].',
|
||||
"'.$value['date'].'",
|
||||
'.(int)$value['nb_product'].',
|
||||
'.(int)$value['quantity'].',
|
||||
'.(int)$value['nb_package'].'
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`nb_product` = '.(int)$value['nb_product'].',
|
||||
`quantity` = '.(int)$value['quantity'].',
|
||||
`nb_package` ='.(int)$value['nb_package'].'
|
||||
');
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ class ContactController extends ContactControllerCore {
|
||||
$this->errors[] = Tools::displayError('An error occurred while sending message.');
|
||||
}
|
||||
|
||||
Module::hookExec('ant_alert', array());
|
||||
Module::hookExec('ant_alert', array('id_contact' => (int)($id_contact)));
|
||||
Module::hookExec('ant_alerthack', array(
|
||||
'email' => $from,
|
||||
'id_customer' => (isset($customer->id)?$customer->id:false),
|
||||
|
Loading…
Reference in New Issue
Block a user