git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@7522 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -1,232 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
class Tm4bSms {
|
||||
|
||||
const __TM4B_SMS_HTTP_HOST__ = 'www.tm4b.com';
|
||||
const __TM4B_SMS_HTTP_SERVICE__ = '/client/api/http.php';
|
||||
const __TM4B_SMS_HTTP_METHOD__ = 'GET';
|
||||
const __TM4B_SMS_MESSAGE_TYPE__ = 'broadcast';
|
||||
|
||||
const __TM4B_SMS_CHECKBALANCE_TYPE__ = 'check_balance';
|
||||
const __TM4B_SMS_CHECKROUTE_TYPE__ = 'check_destination';
|
||||
const __TM4B_SMS_CHECKSTATUS_TYPE__ = 'check_status';
|
||||
|
||||
|
||||
// Keep the Query String for HTTP
|
||||
private $_httpQS = '';
|
||||
|
||||
public $msg;
|
||||
private $_to = array();
|
||||
|
||||
private $errors;
|
||||
private $_user;
|
||||
private $_pass;
|
||||
private $_route;
|
||||
private $_from;
|
||||
|
||||
private $_id;
|
||||
|
||||
function __construct($user, $pass, $route, $from = 'tm4b', $to = array(), $message = '')
|
||||
{
|
||||
$this->msg = $message;
|
||||
$this->_user = $user;
|
||||
$this->_pass = $pass;
|
||||
$this->_route = $route;
|
||||
$this->_from = $from;
|
||||
|
||||
foreach ($to as $num)
|
||||
{
|
||||
$this->addRecipient($num);
|
||||
}
|
||||
$this->_id = array(); // identifier of the sent sms
|
||||
}
|
||||
|
||||
|
||||
// Build the query string for HTTP
|
||||
private function BuildQS($args)
|
||||
{
|
||||
$qs = '';
|
||||
$countArgs = 1;
|
||||
foreach ($args as $key => $value)
|
||||
{
|
||||
if (is_array($value))
|
||||
{
|
||||
$countTo = 1;
|
||||
$qs .= $key . '=';
|
||||
foreach ($value as $index => $recipient)
|
||||
{
|
||||
if ($key == 'id')
|
||||
$qs .= $recipient;
|
||||
else
|
||||
$qs .= urlencode($recipient);
|
||||
|
||||
if ($countTo < sizeof($value))
|
||||
$qs .= '|';
|
||||
$countTo++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$qs .= $key . '=' . urlencode($value);
|
||||
}
|
||||
|
||||
if ($countArgs < sizeof($args))
|
||||
$qs .= '&';
|
||||
$countArgs++;
|
||||
}
|
||||
return $qs;
|
||||
}
|
||||
|
||||
// Send a HTTP Queries through sockets
|
||||
private function SendSocketHTTP()
|
||||
{
|
||||
// init infos
|
||||
if( self::__TM4B_SMS_HTTP_METHOD__ == "GET")
|
||||
{
|
||||
$script = self::__TM4B_SMS_HTTP_SERVICE__ . '?' . $this->_httpQS;
|
||||
}
|
||||
else
|
||||
{
|
||||
$script = self::__TM4B_SMS_HTTP_SERVICE__ ;
|
||||
}
|
||||
|
||||
|
||||
// Build HTTP Header
|
||||
$header = self::__TM4B_SMS_HTTP_METHOD__ . " " . $script . " HTTP/1.1\r\n";
|
||||
$header .= "Host: " . self::__TM4B_SMS_HTTP_HOST__ . "\r\n";
|
||||
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
||||
$header .= "Content-Length: " . Tools::strlen($this->_httpQS) . "\r\n";
|
||||
$header .= "Connection: close\r\n\r\n";
|
||||
$header .= $this->_httpQS . "\r\n";
|
||||
|
||||
// Socket connection
|
||||
$socket = fsockopen( self::__TM4B_SMS_HTTP_HOST__ , 80, $errno, $errstr);
|
||||
|
||||
if($socket) // if we're connected
|
||||
{
|
||||
fputs($socket, $header); // Send header
|
||||
while(!feof($socket))
|
||||
{
|
||||
$response[] = fgets($socket); // Grab return codes
|
||||
}
|
||||
fclose($socket);
|
||||
}
|
||||
else
|
||||
{
|
||||
$response = false;
|
||||
}
|
||||
return ($response);
|
||||
}
|
||||
|
||||
|
||||
#############################################################
|
||||
#
|
||||
# PUBLIC METHODS
|
||||
#
|
||||
#############################################################
|
||||
|
||||
// Add a recipent
|
||||
public function AddRecipient($to, $country_code = NULL)
|
||||
{
|
||||
if ($country_code)
|
||||
$to = preg_replace('/^0/', $country_code, $to);
|
||||
array_push($this->_to, $to);
|
||||
}
|
||||
|
||||
// Returns the current balance of the account in credits
|
||||
public function CheckCredits()
|
||||
{
|
||||
$this->_httpQS = $this->BuildQS( array( 'username' => $this->_user,
|
||||
'password' => $this->_pass,
|
||||
'type' => self::__TM4B_SMS_CHECKBALANCE_TYPE__) );
|
||||
$response = $this->SendSocketHTTP();
|
||||
if (isset($response[8]))
|
||||
return $response[8];
|
||||
return '';
|
||||
}
|
||||
|
||||
// Return the cost to send sms to a given country or number
|
||||
public function CheckRoute()
|
||||
{
|
||||
$this->_httpQS = $this->BuildQS( array ( 'username' => $this->_user,
|
||||
'password' => $this->_pass,
|
||||
'type' => self::__TM4B_SMS_CHECKROUTE_TYPE__,
|
||||
'dest' => $this->to,
|
||||
'route' => $this->_route ) );
|
||||
return ($this->SendSocketHTTP());
|
||||
}
|
||||
|
||||
// Send SMS trought various possible methods (SMTP / HTTP)
|
||||
public function Send($sim = 'no')
|
||||
{
|
||||
// Return if we can't send the sms
|
||||
if (empty($this->msg) OR empty($this->_to))
|
||||
return false;
|
||||
|
||||
$sim = ($sim == '0' ? 'no' : 'yes');
|
||||
|
||||
$this->_httpQS = $this->BuildQS( array (
|
||||
'username' => $this->_user,
|
||||
'password' => $this->_pass,
|
||||
'type' => self::__TM4B_SMS_MESSAGE_TYPE__,
|
||||
'to' => $this->_to,
|
||||
'route' => $this->_route,
|
||||
'from' => $this->_from,
|
||||
'msg' => $this->msg,
|
||||
'sim' => $sim
|
||||
)
|
||||
);
|
||||
$ret = $this->SendSocketHTTP();
|
||||
if (is_array($ret))
|
||||
{
|
||||
$this->_id = $ret[8];
|
||||
return $ret[8];
|
||||
}
|
||||
else
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function isSent()
|
||||
{
|
||||
if (isset($this->_id) AND preg_match('/^MT.*/', $this->_id))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public function CheckStatus()
|
||||
{
|
||||
$this->_httpQS = $this->BuildQS( array (
|
||||
$this->_user,
|
||||
'password' => $this->_pass,
|
||||
'type' => self::__TM4B_SMS_CHECKSTATUS_TYPE__,
|
||||
'id' => $this->_id )
|
||||
);
|
||||
echo 'QS = '.$this->_httpQS."\n";
|
||||
return $this->SendSocketHTTP();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>tm4b</name>
|
||||
<displayName>SMS Tm4b</displayName>
|
||||
<version>1.1</version>
|
||||
<description>Sends an SMS for each new order</description>
|
||||
<author>PrestaShop</author>
|
||||
<tab>administration</tab>
|
||||
<confirmUninstall>Are you sure you want to delete your info?</confirmUninstall>
|
||||
<is_configurable>1</is_configurable>
|
||||
<need_instance>1</need_instance>
|
||||
</module>
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
include(dirname(__FILE__).'/../../config/config.inc.php');
|
||||
include(dirname(__FILE__).'/../../init.php');
|
||||
include(dirname(__FILE__).'/tm4b.php');
|
||||
include(dirname(__FILE__).'/classes/Tm4bSms.php');
|
||||
|
||||
if (!Configuration::get('TM4B_DAILY_REPORT_ACTIVE'))
|
||||
die ('Daily report not active');
|
||||
if (Configuration::get('TM4B_LAST_REPORT') == date('Y-m-d'))
|
||||
die ('Report already sent');
|
||||
Configuration::updateValue('TM4B_LAST_REPORT', date('Y-m-d'));
|
||||
$module = new Tm4b();
|
||||
$sms = new Tm4bSms(Configuration::get('TM4B_USER'), Configuration::get('TM4B_PASSWORD'), Configuration::get('TM4B_ROUTE'));
|
||||
$sms->msg = $module->getStatsBody();
|
||||
$numbers = explode(',', Configuration::get('TM4B_NEW_ORDER_NUMBERS'));
|
||||
foreach ($numbers as $number)
|
||||
if ($number != '')
|
||||
$sms->addRecipient($number);
|
||||
$sms->Send(Configuration::get('TM4B_SIM'));
|
||||
die ('OK');
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
global $_MODULE;
|
||||
$_MODULE = array();
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_599f02a21a8d80cfa87a3a42f9aef067'] = 'Sendet eine SMS bei jeder neuen Bestellung';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_2c8be96b677dc6b891a343193822fea4'] = 'Sie sind sicher, dass Sie Ihre Daten löschen möchten?';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_088d3bfa945e4c27ac0fea363bb13d12'] = 'Nachricht erfolgreich gesendet';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_0cda570a27de3fbd0940da019f759721'] = 'Fehler beim Senden der Nachricht';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_884b60418e2f1f9a6a40f12e8ca0a64d'] = 'Login und Telefonnummer';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_a82be0f551b8708bc08eb33cd9ded0cf'] = 'Information';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_8b58aafd28dcaee7f6e92442c96e31db'] = 'Schicken Sie eine Test-SMS:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_43e9e66e3a7acefd0663287c95acd407'] = 'Geben Sie Ihre Telefonnummer ein';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_35ba634a7df95f937550c54b7b94d2c5'] = 'z.B.: 33642424242';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_2e1779891f69b099b16616ae7ea2e76c'] = 'SMS-Guthaben:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_00db7aae85aecb79c75afca7daa8f22e'] = 'Sie haben';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_928735d6f2c63bee316dd511c8ccaf55'] = 'Guthaben';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_f4f70727dc34561dfde1a3c529b6205c'] = 'Einstellungen';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_cac81c648846c9b8c3e6085a45782c7e'] = 'Benutzername:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_b341a59d5636ed3d6a819137495b08a0'] = 'Kennwort:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_6c47d739c79e0f93ec0cd90663a68ebf'] = 'Relais:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_43e7396afc9f4633157a47bf5f5af96c'] = 'SMS Absendertelefonnr.';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_1ee1c44c2dc81681f961235604247b81'] = 'Modus:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_4f502b57d2835715eaa382c7d4c32e94'] = 'Simulation';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_756d97bb256b8580d4d71ee0c547804e'] = 'Betrieb';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_ea24be6a78dd661afe60448e87b75065'] = 'Benachrichtigungen über neue Bestellung:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_93cba07454f06a4a960172bbd6e2a435'] = 'Ja';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_7b357f8e4b60349aeba339f3032e4a84'] = 'SMS schicken, wenn eine neue Bestellung gemacht wird';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_ff914fecb4b37bd6edb2e4515ec1d4dc'] = 'Benachrichtigungen zur Produktmenge:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_2ed5f5c1670d557c67c958d1f230cb2c'] = 'SMS schicken, wenn die Produktmenge aktualisiert wird';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_d0759ad8efa7234c0f9b919f9ec88c2b'] = 'Tagesbericht:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_a5d859ac85a50ed9d8b6d93be6abd217'] = 'Senden Sie einen täglichen Statistikbericht - Sie müssen einen CRON einstellen auf';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_481bfc100d0a3590edb72f53679e310c'] = 'SMS-Empfänger-Telefonnr.';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_b17f3f4dcf653a5776792498a9b44d6a'] = 'Einstellungen aktualisiert';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_c888438d14855d7d96a2724ee9c306bd'] = 'Einstellungen aktualisiert';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_b1a293b0efa4e1e7c35ef375c3cd7a44'] = 'Benutzername ist obligatorisch';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_8c194fef39e0d251494686926884733e'] = 'Kennwort ist obligatorisch';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_6ac6840e86a7b09bf9eb326228060981'] = 'Root ist obligatorisch';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_486493b98a473ebb777dd86bbf264e06'] = 'Herkunft ist obligatorisch';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_30c94c563402b0a87e4b5411518ab542'] = 'Modus ist obligatorisch';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_aea21c9ea4f10d22071eb479eee918c3'] = 'Bitte geben Sie eine Telefonnummer ein';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_713569f69019a591adfda481f6668a06'] = 'Telefonnummer ungültig';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_8394f2c720f3798ff8ef93fe7e331866'] = 'Bestellungen:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_ec3e48bb9aa902ba2ad608547fdcbfdc'] = 'Verkäufe:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_01411a97818b38fc6524d56590ca5a12'] = 'Monat:';
|
||||
@@ -1,4 +0,0 @@
|
||||
<?php
|
||||
|
||||
global $_MODULE;
|
||||
$_MODULE = array();
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
global $_MODULE;
|
||||
$_MODULE = array();
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_599f02a21a8d80cfa87a3a42f9aef067'] = 'Enviar un SMS para cada nuevo pedido';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_2c8be96b677dc6b891a343193822fea4'] = '¿Está seguro de querer eliminar toda su información?';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_088d3bfa945e4c27ac0fea363bb13d12'] = 'Mensaje enviado correctamente';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_0cda570a27de3fbd0940da019f759721'] = 'error durante el envío del mensaje';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_884b60418e2f1f9a6a40f12e8ca0a64d'] = 'Login y número de teléfono';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_a82be0f551b8708bc08eb33cd9ded0cf'] = 'Información';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_8b58aafd28dcaee7f6e92442c96e31db'] = 'Probar envío de SMS';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_43e9e66e3a7acefd0663287c95acd407'] = 'Introduzca su número de teléfono';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_35ba634a7df95f937550c54b7b94d2c5'] = 'ej: 33642424242rnrn';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_2e1779891f69b099b16616ae7ea2e76c'] = 'crédito SMS';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_00db7aae85aecb79c75afca7daa8f22e'] = 'Tiene';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_928735d6f2c63bee316dd511c8ccaf55'] = 'de crédito';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_f4f70727dc34561dfde1a3c529b6205c'] = 'configuración';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_cac81c648846c9b8c3e6085a45782c7e'] = 'Nombre de usuario';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_b341a59d5636ed3d6a819137495b08a0'] = 'Contraseña';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_6c47d739c79e0f93ec0cd90663a68ebf'] = 'Relay:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_43e7396afc9f4633157a47bf5f5af96c'] = 'Teléfono del remitente del SMS ';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_1ee1c44c2dc81681f961235604247b81'] = 'modo:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_4f502b57d2835715eaa382c7d4c32e94'] = 'Simulación';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_756d97bb256b8580d4d71ee0c547804e'] = 'Producción';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_ea24be6a78dd661afe60448e87b75065'] = 'Alerta cada nuevo pedido:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_93cba07454f06a4a960172bbd6e2a435'] = 'Sí';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_7b357f8e4b60349aeba339f3032e4a84'] = 'Enviar un SMS si se realiza un nuevo pedido';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_ff914fecb4b37bd6edb2e4515ec1d4dc'] = 'Alerta por cantidad de productos:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_2ed5f5c1670d557c67c958d1f230cb2c'] = 'Enviar un SMS cuando se actualiza el stock del producto';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_d0759ad8efa7234c0f9b919f9ec88c2b'] = 'Informe diario';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_a5d859ac85a50ed9d8b6d93be6abd217'] = 'Enviar un informe diario de las estadísticas. Debe fijar un CRON a';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_481bfc100d0a3590edb72f53679e310c'] = 'teléfono del destinatario del SMS';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_b17f3f4dcf653a5776792498a9b44d6a'] = 'Actualizar configuración';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_c888438d14855d7d96a2724ee9c306bd'] = 'Configuración actualizada';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_b1a293b0efa4e1e7c35ef375c3cd7a44'] = 'El nombre de usuario es obligatorio';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_8c194fef39e0d251494686926884733e'] = 'La contraseña es obligatoria';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_6ac6840e86a7b09bf9eb326228060981'] = 'La ruta es obligatoria';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_486493b98a473ebb777dd86bbf264e06'] = 'El origen es obligatorio';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_30c94c563402b0a87e4b5411518ab542'] = 'El modo es obligatorio';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_aea21c9ea4f10d22071eb479eee918c3'] = 'Por favor, indique un número de teléfono';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_713569f69019a591adfda481f6668a06'] = 'Número de teléfono no válido';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_8394f2c720f3798ff8ef93fe7e331866'] = 'Pedidos:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_ec3e48bb9aa902ba2ad608547fdcbfdc'] = 'Ventas:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_01411a97818b38fc6524d56590ca5a12'] = 'Mes:';
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
global $_MODULE;
|
||||
$_MODULE = array();
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_599f02a21a8d80cfa87a3a42f9aef067'] = 'Envoyer un SMS à chaque nouvelle commande';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_2c8be96b677dc6b891a343193822fea4'] = 'Êtes-vous sûr de vouloir supprimer ces informations ?';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_088d3bfa945e4c27ac0fea363bb13d12'] = 'Message bien envoyé';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_0cda570a27de3fbd0940da019f759721'] = 'Erreur lors de l\'envoie du message';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_884b60418e2f1f9a6a40f12e8ca0a64d'] = 'Identifiant et numéro de téléphone';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_a82be0f551b8708bc08eb33cd9ded0cf'] = 'Information';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_8b58aafd28dcaee7f6e92442c96e31db'] = 'Envoyer un SMS de test :';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_43e9e66e3a7acefd0663287c95acd407'] = 'Entrez votre numéro de téléphone';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_35ba634a7df95f937550c54b7b94d2c5'] = 'ex: 33642424242';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_2e1779891f69b099b16616ae7ea2e76c'] = 'Crédits SMS :';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_00db7aae85aecb79c75afca7daa8f22e'] = 'Vous avez';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_928735d6f2c63bee316dd511c8ccaf55'] = 'crédits';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_f4f70727dc34561dfde1a3c529b6205c'] = 'Paramètres';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_cac81c648846c9b8c3e6085a45782c7e'] = 'Identifiant :';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_b341a59d5636ed3d6a819137495b08a0'] = 'Mot de passe :';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_6c47d739c79e0f93ec0cd90663a68ebf'] = 'Relais :';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_43e7396afc9f4633157a47bf5f5af96c'] = 'Numéro de téléphone de l\'expéditeur du SMS';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_1ee1c44c2dc81681f961235604247b81'] = 'Mode :';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_4f502b57d2835715eaa382c7d4c32e94'] = 'Simulation';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_756d97bb256b8580d4d71ee0c547804e'] = 'Production';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_ea24be6a78dd661afe60448e87b75065'] = 'Alerte nouvelle commande';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_93cba07454f06a4a960172bbd6e2a435'] = 'Oui';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_7b357f8e4b60349aeba339f3032e4a84'] = 'Envoi un SMS à chaque nouvelle commande';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_ff914fecb4b37bd6edb2e4515ec1d4dc'] = 'Alerte changement de stock';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_2ed5f5c1670d557c67c958d1f230cb2c'] = 'Envoi un SMS à chaque changement de stock';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_d0759ad8efa7234c0f9b919f9ec88c2b'] = 'Rapport quotidien';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_a5d859ac85a50ed9d8b6d93be6abd217'] = 'Envoi un rapport journalier - vous devez configurer un CRON sur le fichier';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_481bfc100d0a3590edb72f53679e310c'] = 'Numéro de téléphone du destinataire du SMS';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_b17f3f4dcf653a5776792498a9b44d6a'] = 'Mettre à jour les informations';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_c888438d14855d7d96a2724ee9c306bd'] = 'Informations mises à jour';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_b1a293b0efa4e1e7c35ef375c3cd7a44'] = 'Identifiant obligatoire';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_8c194fef39e0d251494686926884733e'] = 'Mot de passe obligatoire';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_6ac6840e86a7b09bf9eb326228060981'] = 'Route obligatoire';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_486493b98a473ebb777dd86bbf264e06'] = 'Origine obligatoire';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_30c94c563402b0a87e4b5411518ab542'] = 'Mode obligatoire';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_aea21c9ea4f10d22071eb479eee918c3'] = 'Merci d\'entrer un numéro de téléphone';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_713569f69019a591adfda481f6668a06'] = 'Numéro de téléphone invalide';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_8394f2c720f3798ff8ef93fe7e331866'] = 'Commandes';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_ec3e48bb9aa902ba2ad608547fdcbfdc'] = 'CA';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_01411a97818b38fc6524d56590ca5a12'] = 'Mois';
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 581 B |
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
global $_MODULE;
|
||||
$_MODULE = array();
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_599f02a21a8d80cfa87a3a42f9aef067'] = 'Invia un SMS per ogni nuovo ordine';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_2c8be96b677dc6b891a343193822fea4'] = 'Sei sicuro di voler cancellare le tue informazioni?';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_088d3bfa945e4c27ac0fea363bb13d12'] = 'Messaggio inviato con successo';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_0cda570a27de3fbd0940da019f759721'] = 'Errore durante l\'invio del messaggio';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_884b60418e2f1f9a6a40f12e8ca0a64d'] = 'Login e numero di telefono';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_a82be0f551b8708bc08eb33cd9ded0cf'] = 'Informazioni';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_8b58aafd28dcaee7f6e92442c96e31db'] = 'Inviare SMS di prova:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_43e9e66e3a7acefd0663287c95acd407'] = 'Inserisci il tuo numero di telefono';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_35ba634a7df95f937550c54b7b94d2c5'] = 'es: 33642424242';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_2e1779891f69b099b16616ae7ea2e76c'] = 'Crediti SMS:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_00db7aae85aecb79c75afca7daa8f22e'] = 'Hai';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_928735d6f2c63bee316dd511c8ccaf55'] = 'crediti';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_f4f70727dc34561dfde1a3c529b6205c'] = 'Impostazioni';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_cac81c648846c9b8c3e6085a45782c7e'] = 'Nome utente:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_b341a59d5636ed3d6a819137495b08a0'] = 'Password:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_6c47d739c79e0f93ec0cd90663a68ebf'] = 'Relay:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_43e7396afc9f4633157a47bf5f5af96c'] = 'N. di telefono del mittente dell\'SMS ';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_1ee1c44c2dc81681f961235604247b81'] = 'Modalità:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_4f502b57d2835715eaa382c7d4c32e94'] = 'Simulazione';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_756d97bb256b8580d4d71ee0c547804e'] = 'Produzione';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_ea24be6a78dd661afe60448e87b75065'] = 'Segnalazioni del nuovo ordine:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_93cba07454f06a4a960172bbd6e2a435'] = 'Sì';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_7b357f8e4b60349aeba339f3032e4a84'] = 'Inviare SMS se viene fatto un nuovo ordine';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_ff914fecb4b37bd6edb2e4515ec1d4dc'] = 'Segnalazioni di quantità di prodotto:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_2ed5f5c1670d557c67c958d1f230cb2c'] = 'Inviare SMS se lo stock di prodotto viene aggiornato';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_d0759ad8efa7234c0f9b919f9ec88c2b'] = 'Rapporto giornaliero:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_a5d859ac85a50ed9d8b6d93be6abd217'] = 'Inviare una relazione quotidiana statistiche - È necessario impostare un CRON per';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_481bfc100d0a3590edb72f53679e310c'] = 'N. telefono ricevente SMS';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_b17f3f4dcf653a5776792498a9b44d6a'] = 'Aggiorna le impostazioni';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_c888438d14855d7d96a2724ee9c306bd'] = 'Impostazioni aggiornate';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_b1a293b0efa4e1e7c35ef375c3cd7a44'] = 'Il nome utente è obbligatorio';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_8c194fef39e0d251494686926884733e'] = 'Password è obbligatoria';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_6ac6840e86a7b09bf9eb326228060981'] = 'Route è obbligatoria';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_486493b98a473ebb777dd86bbf264e06'] = 'L\'origine è obbligatoria';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_30c94c563402b0a87e4b5411518ab542'] = 'Modalità è obbligatoria';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_aea21c9ea4f10d22071eb479eee918c3'] = 'Si prega di inserire un numero di telefono';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_713569f69019a591adfda481f6668a06'] = 'Numero di telefono non valido';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_8394f2c720f3798ff8ef93fe7e331866'] = 'Ordini:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_ec3e48bb9aa902ba2ad608547fdcbfdc'] = 'Vendite:';
|
||||
$_MODULE['<{tm4b}prestashop>tm4b_01411a97818b38fc6524d56590ca5a12'] = 'Mese:';
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 241 B |
@@ -1,5 +0,0 @@
|
||||
{shop_name}
|
||||
Kunde: {firstname} {lastname}
|
||||
Bestellung: {order_name}
|
||||
Zahlung: {payment}
|
||||
Gesamt TI: ({total_paid} {currency})
|
||||
@@ -1,5 +0,0 @@
|
||||
{shop_name}
|
||||
Dieser Artikel ist bald ausverkauft:
|
||||
Ref.: {product_ref}
|
||||
Id: {product_id}
|
||||
Menge: {qty}
|
||||
@@ -1,5 +0,0 @@
|
||||
{shop_name}
|
||||
Customer: {firstname} {lastname}
|
||||
Order: {order_name}
|
||||
Payment: {payment}
|
||||
Total TI: ({total_paid} {currency})
|
||||
@@ -1,5 +0,0 @@
|
||||
{shop_name}
|
||||
This product is soon out of stock:
|
||||
Ref: {product_ref}
|
||||
Id: {product_id}
|
||||
Qty: {qty}
|
||||
@@ -1,5 +0,0 @@
|
||||
nombre de la tienda: {shop_name}
|
||||
Este producto es poco fuera de stock:
|
||||
Ref: {product_ref}
|
||||
Id: {product_id}
|
||||
Cantidad: {qty}
|
||||
@@ -1,5 +0,0 @@
|
||||
{shop_name}
|
||||
Client : {firstname} {lastname}
|
||||
Commande : {order_name}
|
||||
Mode de paiement : {payment}
|
||||
Total TTC : ({total_paid} {currency})
|
||||
@@ -1,5 +0,0 @@
|
||||
{shop_name}
|
||||
Ce produit est bientot en rupture de stock :
|
||||
Ref: {product_ref}
|
||||
Id: {product_id}
|
||||
Quantité: {qty}
|
||||
@@ -1,5 +0,0 @@
|
||||
{shop_name}
|
||||
Cliente: {firstname} {lastname}
|
||||
Ordine: {order_name}
|
||||
Pagamento: {payment}
|
||||
Totale TI: ({total_paid} {currency})
|
||||
@@ -1,5 +0,0 @@
|
||||
{shop_name}
|
||||
Questo prodotto sarà presto non disponibile:
|
||||
Rif: {product_ref}
|
||||
Id: {product_id}
|
||||
Qtà: {qty}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 351 B |
@@ -1,383 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
if (!defined('_CAN_LOAD_FILES_'))
|
||||
exit;
|
||||
|
||||
class Tm4b extends Module
|
||||
{
|
||||
private $_html = '';
|
||||
private $_postErrors = array();
|
||||
private $_postSucess;
|
||||
|
||||
private $_data;
|
||||
private $_password;
|
||||
private $_user;
|
||||
private $_originator;
|
||||
private $_route;
|
||||
private $_simulation;
|
||||
private $_new_order_numbers;
|
||||
|
||||
private $_alert_new_order_active;
|
||||
private $_alert_update_quantity_active;
|
||||
private $_daily_report_active;
|
||||
|
||||
const __TM4B_LOWBALANCE__ = '20';
|
||||
const __TM4B_NUMBER_DELIMITOR__ = ',';
|
||||
|
||||
static private $_tpl_sms_files = array(
|
||||
'name' => array(
|
||||
'new_orders' => 'sms_new_order',
|
||||
'out_of_stock' => 'sms_out_of_stock'
|
||||
),
|
||||
'ext' => array(
|
||||
'new_orders' => '.txt',
|
||||
'out_of_stock' => '.txt'
|
||||
)
|
||||
);
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = 'tm4b';
|
||||
$this->displayName = 'SMS Tm4b';
|
||||
$this->description = $this->l('Sends an SMS for each new order');
|
||||
$this->tab = 'administration';
|
||||
$this->version = 1.1;
|
||||
$this->author = 'PrestaShop';
|
||||
|
||||
parent::__construct();
|
||||
|
||||
if ($this->id)
|
||||
{
|
||||
$this->_data = array('shopname' => Configuration::get('PS_SHOP_NAME'));
|
||||
|
||||
/* Get config vars */
|
||||
$this->_password = Configuration::get('TM4B_PASSWORD');
|
||||
$this->_user = Configuration::get('TM4B_USER');
|
||||
$this->_originator = Configuration::get('TM4B_ORIGINATOR');
|
||||
$this->_route = Configuration::get('TM4B_ROUTE');
|
||||
$this->_simulation = Configuration::get('TM4B_SIM');
|
||||
$this->_new_order_numbers = Configuration::get('TM4B_NEW_ORDER_NUMBERS');
|
||||
|
||||
$this->_alert_new_order_active = Configuration::get('TM4B_ALERT_NO_ACTIVE');
|
||||
$this->_alert_update_quantity_active = Configuration::get('TM4B_ALERT_UQ_ACTIVE');
|
||||
$this->_daily_report_active = Configuration::get('TM4B_DAILY_REPORT_ACTIVE');
|
||||
}
|
||||
|
||||
$this->displayName = 'SMS Tm4b';
|
||||
$this->description = $this->l('Sends an SMS for each new order');
|
||||
$this->confirmUninstall = $this->l('Are you sure you want to delete your info?');
|
||||
}
|
||||
|
||||
public function install()
|
||||
{
|
||||
if (!parent::install() OR
|
||||
!$this->registerHook('newOrder') OR
|
||||
!$this->registerHook('updateQuantity'))
|
||||
return false;
|
||||
|
||||
Configuration::updateValue('TM4B_SIM', 1);
|
||||
Configuration::updateValue('TM4B_ALERT_NO_ACTIVE', 1);
|
||||
Configuration::updateValue('TM4B_ALERT_UQ_ACTIVE', 1);
|
||||
Configuration::updateValue('TM4B_DAILY_REPORT_ACTIVE', 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
Configuration::deleteByName('TM4B_PASSWORD');
|
||||
Configuration::deleteByName('TM4B_USER');
|
||||
Configuration::deleteByName('TM4B_ORIGINATOR');
|
||||
Configuration::deleteByName('TM4B_ROUTE');
|
||||
Configuration::deleteByName('TM4B_SIM');
|
||||
Configuration::deleteByName('TM4B_NEW_ORDER_NUMBERS');
|
||||
Configuration::deleteByName('TM4B_ALERT_NO_ACTIVE');
|
||||
Configuration::deleteByName('TM4B_ALERT_UQ_ACTIVE');
|
||||
Configuration::deleteByName('TM4B_DAILY_REPORT_ACTIVE');
|
||||
Configuration::deleteByName('TM4B_LAST_REPORT');
|
||||
|
||||
return parent::uninstall();
|
||||
}
|
||||
|
||||
private function _getTplBody($tpl_file, $vars = array())
|
||||
{
|
||||
$iso = Language::getIsoById((int)(Configuration::get('PS_LANG_DEFAULT')));
|
||||
$file = dirname(__FILE__).'/mails/'.$iso.'/'.$tpl_file;
|
||||
if (!file_exists($file))
|
||||
die($file);
|
||||
$tpl = file($file);
|
||||
$template = str_replace(array_keys($vars), array_values($vars), $tpl);
|
||||
return (implode("\n", $template));
|
||||
}
|
||||
|
||||
public function hookNewOrder($params)
|
||||
{
|
||||
include_once (dirname(__FILE__).'/classes/Tm4bSms.php');
|
||||
|
||||
if ( !(int)($this->_alert_new_order_active) OR empty($this->_user) OR empty($this->_password)
|
||||
OR empty($this->_new_order_numbers))
|
||||
return ;
|
||||
$order = $params['order'];
|
||||
$customer = $params['customer'];
|
||||
$currency = $params['currency'];
|
||||
|
||||
$templateVars = array(
|
||||
'{firstname}' => utf8_decode($customer->firstname),
|
||||
'{lastname}' => utf8_decode($customer->lastname),
|
||||
'{order_name}' => sprintf("%06d", $order->id),
|
||||
'{shop_name}' => Configuration::get('PS_SHOP_NAME'),
|
||||
'{payment}' => $order->payment,
|
||||
'{total_paid}' => $order->total_paid,
|
||||
'{currency}' => $currency->sign);
|
||||
|
||||
$body = $this->_getTplBody(self::$_tpl_sms_files['name']['new_orders'].self::$_tpl_sms_files['ext']['new_orders'], $templateVars);
|
||||
|
||||
$sms = new Tm4bSms($this->_user, $this->_password, $this->_route, $this->_originator);
|
||||
$sms->msg = $body;
|
||||
$numbers = explode(self::__TM4B_NUMBER_DELIMITOR__, $this->_new_order_numbers);
|
||||
foreach ($numbers as $number)
|
||||
if ($number != '')
|
||||
$sms->addRecipient($number);
|
||||
$sms->Send($this->_simulation);
|
||||
}
|
||||
|
||||
public function hookUpdateQuantity($params)
|
||||
{
|
||||
if (!(int)($this->_alert_update_quantity_active) OR empty($this->_new_order_numbers))
|
||||
return ;
|
||||
|
||||
$product = $params['product'];
|
||||
$order = $params['order'];
|
||||
|
||||
$qty = (int)($params['product']['quantity_attribute'] ? $params['product']['quantity_attribute'] : $params['product']['stock_quantity']) - (int)($params['product']['quantity']);
|
||||
if ($qty <= (int)(Configuration::get('PS_LAST_QTIES')))
|
||||
{
|
||||
$templateVars = array(
|
||||
'{last_qty}' => (int)(Configuration::get('PS_LAST_QTIES')),
|
||||
'{qty}' => $qty,
|
||||
'{product}' => strval($params['product']['name']));
|
||||
|
||||
$body = $this->_getTplBody(self::$_tpl_sms_files['name']['out_of_stock'].self::$_tpl_sms_files['ext']['out_of_stock'], $templateVars);
|
||||
}
|
||||
|
||||
if (!empty($body))
|
||||
{
|
||||
$sms = new Tm4bSms($this->_user, $this->_password, $this->_route, $this->_originator);
|
||||
$sms->msg = $body;
|
||||
$numbers = explode(self::__TM4B_NUMBER_DELIMITOR__, $this->_new_order_numbers);
|
||||
foreach ($numbers as $number)
|
||||
if ($number != '')
|
||||
$sms->addRecipient($number);
|
||||
$sms->Send($this->_simulation);
|
||||
}
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
include_once (dirname(__FILE__).'/classes/Tm4bSms.php');
|
||||
$this->_html = '<h2>'.$this->displayName.'</h2>';
|
||||
|
||||
if (!empty($_POST))
|
||||
{
|
||||
if (isset($_POST['btnTestSms']))
|
||||
{
|
||||
if (!empty($this->_user) AND !empty($this->_password) AND !empty($_POST['test_number']) AND is_numeric($_POST['test_number']))
|
||||
{
|
||||
$sms = new Tm4bSms($this->_user, $this->_password, $this->_route, $this->_originator);
|
||||
$sms->msg = 'Test SMS for your PrestaShop website';
|
||||
$sms->addRecipient($_POST['test_number']);
|
||||
$ret = $sms->Send($this->_simulation);
|
||||
if ($sms->isSent())
|
||||
$this->_html .= $this->displayConfirmation($this->l('Message sent'));
|
||||
else
|
||||
$this->_html .= $this->displayError($this->l('Error while sending message'));
|
||||
}
|
||||
else
|
||||
$this->_html .= $this->displayError($this->l('Login and phone number'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_postValidation();
|
||||
if (!sizeof($this->_postErrors))
|
||||
$this->_postProcess();
|
||||
else
|
||||
foreach ($this->_postErrors AS $err)
|
||||
$this->_html .= $this->displayError($err);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_displayTm4b();
|
||||
$this->_displayForm();
|
||||
|
||||
return $this->_html;
|
||||
}
|
||||
|
||||
private function _displayTm4b()
|
||||
{
|
||||
include_once (dirname(__FILE__).'/classes/Tm4bSms.php');
|
||||
|
||||
$testsms_txt = 'Send';
|
||||
|
||||
$this->_html .= '
|
||||
<fieldset><legend><img src="'.$this->_path.'informations.gif" alt="" title="" /> '.$this->l('Information').'</legend>
|
||||
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
|
||||
<label>'.$this->l('Send test SMS:').'</label>
|
||||
<div class="margin-form"><input onclick="this.value=\'\'" type="text" style="margin-bottom:10px;" name="test_number" size="30" value="'.
|
||||
((isset($_POST) AND isset($_POST['test_number'])) ? $_POST['test_number'] : $this->l('Enter your phone number')).'">
|
||||
<input class="button" name="btnTestSms" value="'.$testsms_txt.'" type="submit" style="margin-bottom:10px;" /><br />'.$this->l('ex: 33642424242').'</div>';
|
||||
if (!empty($this->_user) AND !empty($this->_password))
|
||||
{
|
||||
$sms = new Tm4bSms($this->_user, $this->_password, $this->_route, $this->_originator);
|
||||
$credits = $sms->CheckCredits();
|
||||
$color = ($credits < self::__TM4B_LOWBALANCE__ ? '#900' : '#080');
|
||||
$this->_html .= '<label>'.$this->l('SMS credits:').'</label>
|
||||
<div class="margin-form" style="color:#000000; font-size:12px;">'.$this->l('You have').' <span style="font-weight: bold; color: '.$color.';">'.$credits.'</span> '.$this->l('credits').'</div>';
|
||||
}
|
||||
$this->_html .= '
|
||||
</form>
|
||||
</fieldset><br />';
|
||||
}
|
||||
|
||||
private function _displayForm()
|
||||
{
|
||||
if (!isset($_POST['btnSubmit']))
|
||||
{
|
||||
if ($this->_user)
|
||||
{
|
||||
$_POST['user'] = $this->_user;
|
||||
$_POST['password'] = $this->_password;
|
||||
$_POST['route'] = $this->_route;
|
||||
$_POST['originator'] = $this->_originator;
|
||||
$_POST['simulation'] = $this->_simulation;
|
||||
$_POST['new_order_numbers'] = str_replace(self::__TM4B_NUMBER_DELIMITOR__, "\n", $this->_new_order_numbers);
|
||||
$_POST['alert_new_order'] = $this->_alert_new_order_active;
|
||||
$_POST['alert_update_quantity'] = $this->_alert_update_quantity_active;
|
||||
$_POST['daily_report'] = $this->_daily_report_active;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_html .= '<fieldset><legend><img src="'.$this->_path.'prefs.gif" alt="" title="" /> '.$this->l('Settings').'</legend>
|
||||
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
|
||||
<label>'.$this->l('Username:').'</label>
|
||||
<div class="margin-form"><input type="text" name="user" value="'.(isset($_POST['user']) ? $_POST['user'] : '').'" /></div>
|
||||
<label>'.$this->l('Password:').'</label>
|
||||
<div class="margin-form"><input type="text" name="password" value="'.(isset($_POST['password']) ? $_POST['password'] : '').'" /></div>
|
||||
<label>'.$this->l('Relay:').'</label>
|
||||
<div class="margin-form"><select name="route">
|
||||
<option value="GD01" '.(isset($_POST['route']) ? ($_POST['route'] == 'GD01' ? 'selected="selected"' : '') : '').'>Global I</option>
|
||||
<option value="GD02" '.(isset($_POST['route']) ? ($_POST['route'] == 'GD02' ? 'selected="selected"' : '') : '').'>Global II</option>
|
||||
<option value="USS1" '.(isset($_POST['route']) ? ($_POST['route'] == 'USS1' ? 'selected="selected"' : '') : '').'>USA Direct</option>
|
||||
</select></div>
|
||||
<label>'.$this->l('SMS sender\'s phone #').'</label>
|
||||
<div class="margin-form"><input type="text" name="originator" value="'.(isset($_POST['originator']) ? $_POST['originator'] : '').'" style="margin-bottom:10px;" /><br />'.$this->l('ex: 33642424242').'</div>
|
||||
<label>'.$this->l('Mode:').'</label>
|
||||
<div class="margin-form"><input type="radio" name="simulation" value="1" style="vertical-align: middle;" '.( (isset($_POST['simulation']) AND $_POST['simulation'] == '1' ) ? 'checked' : '').' /> <span style="color: #900;">'.$this->l('Simulation').'</span>
|
||||
<input type="radio" name="simulation" value="0" style="vertical-align: middle;" '.( (!isset($_POST['simulation']) OR $_POST['simulation'] == '0') ? 'checked' : '').' /> <span style="color: #080;">'.$this->l('Production').'</div>
|
||||
<br />
|
||||
<label>'.$this->l('Alerts on new order:').'</label>
|
||||
<div class="margin-form"><div style="color:#000000; font-size:12px; margin-bottom:6px"><input type="checkbox" value="1" name="alert_new_order" '.( (isset($_POST['alert_new_order']) AND $_POST['alert_new_order'] == '1') ? 'checked' : '').' /> '.$this->l('Yes').'</div>'.$this->l('Send SMS if a new order is made').'</div>
|
||||
<label class="clear">'.$this->l('Alerts on product quantity:').'</label>
|
||||
<div class="margin-form"><div style="color:#000000; font-size:12px; margin-bottom:6px"><input type="checkbox" value="1" name="alert_update_quantity" '.( (isset($_POST['alert_update_quantity']) AND $_POST['alert_update_quantity'] == '1') ? 'checked' : '').' /> '.$this->l('Yes').'</div>'.$this->l('Send SMS if the stock of product is updated').'</div>
|
||||
<label class="clear">'.$this->l('Daily report:').'</label>
|
||||
<div class="margin-form"><div style="color:#000000; font-size:12px; margin-bottom:6px"><input type="checkbox" value="1" name="daily_report" '.( (isset($_POST['daily_report']) AND $_POST['daily_report'] == '1') ? 'checked' : '').' /> '.$this->l('Yes').'</div>'.$this->l('Send a daily stats report - You must set a CRON to').' /modules/tm4b/cron.php</div>
|
||||
<br />
|
||||
<label>'.$this->l('SMS receiver\'s phone #').'</label>
|
||||
<div class="margin-form"><input type="text" name="new_order_numbers" size="30" value="'.(isset($_POST['new_order_numbers']) ? $_POST['new_order_numbers'] : '').'" style="margin-bottom:10px;" /><br />'.$this->l('ex: 33642424242').'</div>
|
||||
<br />
|
||||
<div class="margin-form"><input class="button" name="btnSubmit" value="'.$this->l('Update settings').'" type="submit" /></div>
|
||||
</form></fieldset>';
|
||||
}
|
||||
|
||||
private function _postProcess()
|
||||
{
|
||||
Configuration::updateValue('TM4B_PASSWORD', $_POST['password']);
|
||||
Configuration::updateValue('TM4B_USER', $_POST['user']);
|
||||
Configuration::updateValue('TM4B_ORIGINATOR', $_POST['originator']);
|
||||
Configuration::updateValue('TM4B_ROUTE', $_POST['route']);
|
||||
Configuration::updateValue('TM4B_SIM', $_POST['simulation']);
|
||||
Configuration::updateValue('TM4B_ALERT_NO_ACTIVE', isset($_POST['alert_new_order']) ? 1 : 0);
|
||||
Configuration::updateValue('TM4B_ALERT_UQ_ACTIVE', isset($_POST['alert_update_quantity']) ? 1 : 0);
|
||||
Configuration::updateValue('TM4B_DAILY_REPORT_ACTIVE', isset($_POST['daily_report']) ? 1 : 0);
|
||||
|
||||
$numbers = explode("\n", $_POST['new_order_numbers']);
|
||||
$this->_new_order_numbers = '';
|
||||
foreach ($numbers as $number)
|
||||
{
|
||||
if (preg_match("/([0-9]+)/", $number, $regs))
|
||||
$this->_new_order_numbers .= $regs[1].self::__TM4B_NUMBER_DELIMITOR__;
|
||||
}
|
||||
Configuration::updateValue('TM4B_NEW_ORDER_NUMBERS', $this->_new_order_numbers);
|
||||
$this->_html .= $this->displayConfirmation($this->l('Settings updated'));
|
||||
}
|
||||
|
||||
private function _postValidation()
|
||||
{
|
||||
if (empty($_POST['user']))
|
||||
$this->_postErrors[] = $this->l('Username is mandatory');
|
||||
elseif (empty($_POST['password']))
|
||||
$this->_postErrors[] = $this->l('Password is mandatory');
|
||||
elseif (empty($_POST['route']) OR ($_POST['route'] != 'GD01' AND $_POST['route'] != 'GD02' AND $_POST['route'] != 'USS1'))
|
||||
$this->_postErrors[] = $this->l('Route is mandatory');
|
||||
elseif (empty($_POST['originator']))
|
||||
$this->_postErrors[] = $this->l('Origin is mandatory');
|
||||
elseif (!isset($_POST['simulation']) OR ($_POST['simulation'] != 0 AND $_POST['simulation'] != 1))
|
||||
$this->_postErrors[] = $this->l('Mode is mandatory');
|
||||
elseif (empty($_POST['new_order_numbers']))
|
||||
$this->_postErrors[] = $this->l('Please enter a phone number');
|
||||
elseif (preg_match('/([^0-9[:space:],])/', $_POST['new_order_numbers'], $regs))
|
||||
$this->_postErrors[] = $this->l('Phone number invalid');
|
||||
}
|
||||
|
||||
public function getStatsBody()
|
||||
{
|
||||
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
$currency->sign = $currency->iso_code;
|
||||
$query = '
|
||||
SELECT SUM(o.`total_paid_real`) as total_sales, COUNT(o.`total_paid_real`) as total_orders
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
WHERE (
|
||||
SELECT IF(os.`id_order_state` = 8, 0, 1)
|
||||
FROM `'._DB_PREFIX_.'orders` oo
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON oh.`id_order` = oo.`id_order`
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON os.`id_order_state` = oh.`id_order_state`
|
||||
WHERE oo.`id_order` = o.`id_order`
|
||||
ORDER BY oh.`date_add` DESC, oh.`id_order_history` DESC
|
||||
LIMIT 1
|
||||
) = 1 ';
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query.'
|
||||
AND o.`date_add` >= DATE_SUB(\''.date('Y-m-d').' 20:00:00\', INTERVAL 1 DAY)
|
||||
AND o.`date_add` < \''.date('Y-m-d').' 20:00:00\'');
|
||||
$result2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query.'AND o.`date_add` LIKE \''.date('Y-m').'-%\'');
|
||||
|
||||
return date('Y-m-d')."\n".
|
||||
$this->l('Orders:').' '.(int)($result['total_orders'])."\n".
|
||||
$this->l('Sales:').' '.Tools::displayPrice($result['total_sales'], $currency, true)."\n".
|
||||
'('.$this->l('Month:').' '.Tools::displayPrice($result2['total_sales'], $currency, true).')';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user