Merge branch 'ticket-9759' into develop
This commit is contained in:
commit
9a5cf505da
15
mails/fr/ant_alert.html
Normal file
15
mails/fr/ant_alert.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Message Alert Problèmes techniques</title>
|
||||
</head>
|
||||
<body>
|
||||
<table style="font-family: tahoma,arial,sans-serif; font-size: 12px; color:#000000; width: 100%;">
|
||||
<tr>
|
||||
<td align="left" style="background: #514c8c; color:#ffffff; font-size: 12px; font-weight:bold; padding: 0.5em 1em;">Vous avez reçu {limit} messages ou plus concernant des problèmes techniques en {hours}.</td>
|
||||
</tr>
|
||||
<tr><td> </td></tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
1
mails/fr/ant_alert.txt
Normal file
1
mails/fr/ant_alert.txt
Normal file
@ -0,0 +1 @@
|
||||
Vous avez reçu {limit} messages ou plus concernant des problèmes techniques en {hours}
|
38
modules/ant_alert/AdminAntAlert.php
Normal file
38
modules/ant_alert/AdminAntAlert.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?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;
|
||||
|
||||
echo '
|
||||
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
|
||||
<fieldset>
|
||||
<legend><img src="../img/admin/AdminShipping.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" />';
|
||||
}
|
||||
}
|
99
modules/ant_alert/ant_alert.php
Normal file
99
modules/ant_alert/ant_alert.php
Normal file
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
class Ant_Alert extends Module
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = 'ant_alert';
|
||||
$this->tab = 'administration';
|
||||
$this->author = 'Antadis';
|
||||
$this->version = '1.0';
|
||||
$this->need_instance = 0;
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->displayName = $this->l('Alert for message');
|
||||
$this->description = $this->l('Alert for message of technical error');
|
||||
}
|
||||
|
||||
public function install()
|
||||
{
|
||||
|
||||
|
||||
$hooks = array(
|
||||
'ant_alert' => array('Ant Alert', 'Called when a message of technical error is sent'),
|
||||
);
|
||||
foreach($hooks as $k => $v) {
|
||||
if(count(Db::getInstance()->ExecuteS('
|
||||
SELECT `id_hook`
|
||||
FROM `'._DB_PREFIX_.'hook`
|
||||
WHERE `name` = "'.$k.'"
|
||||
LIMIT 1
|
||||
')) == 0) {
|
||||
Db::getInstance()->ExecuteS('
|
||||
INSERT INTO `'._DB_PREFIX_.'hook`
|
||||
VALUES (DEFAULT, "'.$k.'", "'.$v[0].'", "'.$v[1].'", 0, 0)
|
||||
');
|
||||
}
|
||||
}
|
||||
|
||||
if(!parent::install()
|
||||
|| !$this->registerHook('ant_alert')) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
# 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'));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function uninstall() {
|
||||
|
||||
if(parent::uninstall() == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Configuration::deleteByName('ANT_ALTER_LIMIT');
|
||||
Configuration::deleteByName('ANT_ALTER_HOURS');
|
||||
Configuration::deleteByName('ANT_ALTER_DATESEND');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function hookAnt_Alert($params) {
|
||||
global $cookie;
|
||||
|
||||
$date = new Datetime(Configuration::get('ANT_ALTER_DATESEND'));
|
||||
$now = new Datetime;
|
||||
|
||||
$dteDiff = $date->diff($now);
|
||||
if ((int)$dteDiff->format("%H") > (int)Configuration::get('ANT_ALTER_HOURS')) {
|
||||
$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')) {
|
||||
$to = array('');
|
||||
$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'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -157,6 +157,10 @@ class PaypalExpressCheckout extends Paypal
|
||||
$cart = Context::getContext()->cart;
|
||||
$customer = Context::getContext()->customer;
|
||||
|
||||
// LOGO IMG Paypal
|
||||
global $cookie;
|
||||
$fields['LOGOIMG'] = 'https://static.bebeboutik.com/img/logo_'.$cookie->id_lang.'.png';
|
||||
|
||||
//ANTADIS
|
||||
if($customer->secure_key != $cart->secure_key){
|
||||
mail('thibault@antadis.com', "bbb paypal", print_r($cart, true));
|
||||
|
@ -1,6 +1,200 @@
|
||||
<?php
|
||||
class ContactController extends ContactControllerCore {
|
||||
public function setMedia() {
|
||||
|
||||
public function preProcess()
|
||||
{
|
||||
parent::preProcess();
|
||||
|
||||
if (self::$cookie->isLogged())
|
||||
{
|
||||
self::$smarty->assign('isLogged', 1);
|
||||
$customer = new Customer((int)(self::$cookie->id_customer));
|
||||
if (!Validate::isLoadedObject($customer))
|
||||
die(Tools::displayError('Customer not found'));
|
||||
$products = array();
|
||||
$orders = array();
|
||||
$getOrders = Db::getInstance()->ExecuteS('
|
||||
SELECT id_order
|
||||
FROM '._DB_PREFIX_.'orders
|
||||
WHERE id_customer = '.(int)$customer->id.' ORDER BY date_add');
|
||||
foreach ($getOrders as $row)
|
||||
{
|
||||
$order = new Order($row['id_order']);
|
||||
$date = explode(' ', $order->date_add);
|
||||
$orders[$row['id_order']] = Tools::displayDate($date[0], self::$cookie->id_lang);
|
||||
$tmp = $order->getProducts();
|
||||
foreach ($tmp as $key => $val)
|
||||
$products[$val['product_id']] = $val['product_name'];
|
||||
}
|
||||
|
||||
$orderList = '';
|
||||
foreach ($orders as $key => $val)
|
||||
$orderList .= '<option value="'.$key.'" '.((int)(Tools::getValue('id_order')) == $key ? 'selected' : '').' >'.$key.' -- '.$val.'</option>';
|
||||
$orderedProductList = '';
|
||||
|
||||
foreach ($products as $key => $val)
|
||||
$orderedProductList .= '<option value="'.$key.'" '.((int)(Tools::getValue('id_product')) == $key ? 'selected' : '').' >'.$val.'</option>';
|
||||
self::$smarty->assign('orderList', $orderList);
|
||||
self::$smarty->assign('orderedProductList', $orderedProductList);
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitMessage'))
|
||||
{
|
||||
$fileAttachment = NULL;
|
||||
if (isset($_FILES['fileUpload']['name']) AND !empty($_FILES['fileUpload']['name']) AND !empty($_FILES['fileUpload']['tmp_name']))
|
||||
{
|
||||
$extension = array('.txt', '.rtf', '.doc', '.docx', '.pdf', '.zip', '.png', '.jpeg', '.gif', '.jpg');
|
||||
$filename = uniqid().substr($_FILES['fileUpload']['name'], -5);
|
||||
$fileAttachment['content'] = file_get_contents($_FILES['fileUpload']['tmp_name']);
|
||||
$fileAttachment['name'] = $_FILES['fileUpload']['name'];
|
||||
$fileAttachment['mime'] = $_FILES['fileUpload']['type'];
|
||||
}
|
||||
$message = Tools::htmlentitiesUTF8(Tools::getValue('message'));
|
||||
if (!($from = trim(Tools::getValue('from'))) OR !Validate::isEmail($from))
|
||||
$this->errors[] = Tools::displayError('Invalid e-mail address');
|
||||
elseif (!($message = nl2br2($message)))
|
||||
$this->errors[] = Tools::displayError('Message cannot be blank');
|
||||
elseif (!Validate::isCleanHtml($message))
|
||||
$this->errors[] = Tools::displayError('Invalid message');
|
||||
elseif (!($id_contact = (int)(Tools::getValue('id_contact'))) OR !(Validate::isLoadedObject($contact = new Contact((int)($id_contact), (int)(self::$cookie->id_lang)))))
|
||||
$this->errors[] = Tools::displayError('Please select a subject on the list.');
|
||||
elseif (!empty($_FILES['fileUpload']['name']) AND $_FILES['fileUpload']['error'] != 0)
|
||||
$this->errors[] = Tools::displayError('An error occurred during the file upload');
|
||||
elseif (!empty($_FILES['fileUpload']['name']) AND !in_array(substr($_FILES['fileUpload']['name'], -4), $extension) AND !in_array(substr($_FILES['fileUpload']['name'], -5), $extension))
|
||||
$this->errors[] = Tools::displayError('Bad file extension');
|
||||
else
|
||||
{
|
||||
if ((int)(self::$cookie->id_customer))
|
||||
$customer = new Customer((int)(self::$cookie->id_customer));
|
||||
else
|
||||
{
|
||||
$customer = new Customer();
|
||||
$customer->getByEmail($from);
|
||||
}
|
||||
|
||||
$contact = new Contact($id_contact, self::$cookie->id_lang);
|
||||
|
||||
if (!((
|
||||
$id_customer_thread = (int)Tools::getValue('id_customer_thread')
|
||||
AND (int)Db::getInstance()->getValue('
|
||||
SELECT cm.id_customer_thread FROM '._DB_PREFIX_.'customer_thread cm
|
||||
WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND token = \''.pSQL(Tools::getValue('token')).'\'')
|
||||
) OR (
|
||||
$id_customer_thread = (int)Db::getInstance()->getValue('
|
||||
SELECT cm.id_customer_thread FROM '._DB_PREFIX_.'customer_thread cm
|
||||
WHERE cm.email = \''.pSQL($from).'\' AND cm.id_order = '.(int)(Tools::getValue('id_order')).'')
|
||||
)))
|
||||
{
|
||||
$fields = Db::getInstance()->ExecuteS('
|
||||
SELECT cm.id_customer_thread, cm.id_contact, cm.id_customer, cm.id_order, cm.id_product, cm.email
|
||||
FROM '._DB_PREFIX_.'customer_thread cm
|
||||
WHERE email = \''.pSQL($from).'\' AND ('.
|
||||
($customer->id ? 'id_customer = '.(int)($customer->id).' OR ' : '').'
|
||||
id_order = '.(int)(Tools::getValue('id_order')).')');
|
||||
$score = 0;
|
||||
foreach ($fields as $key => $row)
|
||||
{
|
||||
$tmp = 0;
|
||||
if ((int)$row['id_customer'] AND $row['id_customer'] != $customer->id AND $row['email'] != $from)
|
||||
continue;
|
||||
if ($row['id_order'] != 0 AND Tools::getValue('id_order') != $row['id_order'])
|
||||
continue;
|
||||
if ($row['email'] == $from)
|
||||
$tmp += 4;
|
||||
if ($row['id_contact'] == $id_contact)
|
||||
$tmp++;
|
||||
if (Tools::getValue('id_product') != 0 AND $row['id_product'] == Tools::getValue('id_product'))
|
||||
$tmp += 2;
|
||||
if ($tmp >= 5 AND $tmp >= $score)
|
||||
{
|
||||
$score = $tmp;
|
||||
$id_customer_thread = $row['id_customer_thread'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$old_message = Db::getInstance()->getValue('
|
||||
SELECT cm.message FROM '._DB_PREFIX_.'customer_message cm
|
||||
WHERE cm.id_customer_thread = '.(int)($id_customer_thread).'
|
||||
ORDER BY date_add DESC');
|
||||
if ($old_message == htmlentities($message, ENT_COMPAT, 'UTF-8'))
|
||||
{
|
||||
self::$smarty->assign('alreadySent', 1);
|
||||
$contact->email = '';
|
||||
$contact->customer_service = 0;
|
||||
}
|
||||
|
||||
if (!empty($contact->email))
|
||||
{
|
||||
if (/*Mail::Send((int)(self::$cookie->id_lang), 'contact', Mail::l('Message from contact form'), array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, ((int)(self::$cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : ''), $fileAttachment)
|
||||
AND*/ Mail::Send((int)(self::$cookie->id_lang), 'contact_form', Mail::l('Your message has been correctly sent'), array('{message}' => stripslashes($message)), $from))
|
||||
self::$smarty->assign('confirmation', 1);
|
||||
else
|
||||
$this->errors[] = Tools::displayError('An error occurred while sending message.');
|
||||
}
|
||||
|
||||
if ($contact->customer_service)
|
||||
{
|
||||
if ((int)$id_customer_thread)
|
||||
{
|
||||
$ct = new CustomerThread($id_customer_thread);
|
||||
$ct->status = 'open';
|
||||
$ct->id_lang = (int)self::$cookie->id_lang;
|
||||
$ct->id_contact = (int)($id_contact);
|
||||
if ($id_order = (int)Tools::getValue('id_order'))
|
||||
$ct->id_order = $id_order;
|
||||
if ($id_product = (int)Tools::getValue('id_product'))
|
||||
$ct->id_product = $id_product;
|
||||
$ct->update();
|
||||
}
|
||||
else
|
||||
{
|
||||
$ct = new CustomerThread();
|
||||
if (isset($customer->id))
|
||||
$ct->id_customer = (int)($customer->id);
|
||||
if ($id_order = (int)Tools::getValue('id_order'))
|
||||
$ct->id_order = $id_order;
|
||||
if ($id_product = (int)Tools::getValue('id_product'))
|
||||
$ct->id_product = $id_product;
|
||||
$ct->id_contact = (int)($id_contact);
|
||||
$ct->id_lang = (int)self::$cookie->id_lang;
|
||||
$ct->email = $from;
|
||||
$ct->status = 'open';
|
||||
$ct->token = Tools::passwdGen(12);
|
||||
$ct->add();
|
||||
}
|
||||
|
||||
Module::hookExec('ant_alert', array());
|
||||
|
||||
if ($ct->id)
|
||||
{
|
||||
$cm = new CustomerMessage();
|
||||
$cm->id_customer_thread = $ct->id;
|
||||
$cm->message = htmlentities($message, ENT_COMPAT, 'UTF-8');
|
||||
if (isset($filename) AND rename($_FILES['fileUpload']['tmp_name'], _PS_MODULE_DIR_.'../upload/'.$filename))
|
||||
$cm->file_name = $filename;
|
||||
$cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
|
||||
$cm->user_agent = $_SERVER['HTTP_USER_AGENT'];
|
||||
if ($cm->add())
|
||||
{
|
||||
|
||||
if (empty($contact->email))
|
||||
Mail::Send((int)(self::$cookie->id_lang), 'contact_form', Mail::l('Your message has been correctly sent'), array('{message}' => stripslashes($message)), $from);
|
||||
|
||||
self::$smarty->assign('confirmation', 1);
|
||||
}
|
||||
else
|
||||
$this->errors[] = Tools::displayError('An error occurred while sending message.');
|
||||
}
|
||||
else
|
||||
$this->errors[] = Tools::displayError('An error occurred while sending message.');
|
||||
}
|
||||
if (count($this->errors) > 1)
|
||||
array_unique($this->errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setMedia() {
|
||||
parent::setMedia();
|
||||
|
||||
global $css_files;
|
||||
|
Loading…
Reference in New Issue
Block a user