From 723b584af95f04a3f579af8bc5079e93b9777e25 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 19 Dec 2017 10:08:11 +0100 Subject: [PATCH] SMS bugs solved --- debian/changelog | 2 +- package.json | 2 +- rest/dms/invoice.php | 3 ++- rest/misc/sms.php | 33 +++++++++++++++++++++------------ 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/debian/changelog b/debian/changelog index 0243479a..dbc862d8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (1.405.52) stable; urgency=low +hedera-web (1.405.53) stable; urgency=low * Initial Release. diff --git a/package.json b/package.json index fbb41034..96751192 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hedera-web", - "version": "1.405.52", + "version": "1.405.53", "description": "Verdnatura web page", "license": "GPL-3.0", "repository": { diff --git a/rest/dms/invoice.php b/rest/dms/invoice.php index 78548d38..1b2e9cad 100644 --- a/rest/dms/invoice.php +++ b/rest/dms/invoice.php @@ -2,6 +2,7 @@ use Vn\Web\Security; use Vn\Web\Util; +use Vn\Lib; class Invoice extends Vn\Web\RestRequest { @@ -14,7 +15,7 @@ class Invoice extends Vn\Web\RestRequest ['invoice' => (int) $_GET['invoice']]); if (!$pdfPath) - throw new Exception (s('Invoice id not found')); + throw new Lib\UserException (s('Invoice id not found')); Util::printFile ($pdfPath); } diff --git a/rest/misc/sms.php b/rest/misc/sms.php index 529d0ddf..8b329ca8 100644 --- a/rest/misc/sms.php +++ b/rest/misc/sms.php @@ -5,39 +5,48 @@ use Vn\Lib; class Sms extends Vn\Web\JsonRequest { const PARAMS = [ - 'to' - ,'text' + 'destination' + ,'message' + ]; + + const OK_STATES = [ + 0, // Ok + 127 // Processing ]; function run ($db) { - $smsConfig = $db->getObject ('SELECT uri, user, password, title FROM sms_config'); + $smsConfig = $db->getObject ('SELECT uri, user, password, title FROM vn.smsConfig'); $sClient = new SoapClient ($smsConfig->uri); $xmlString = $sClient->sendSMS ( $smsConfig->user ,$smsConfig->password ,$smsConfig->title - ,$_REQUEST['to'] - ,$_REQUEST['text'] + ,$_REQUEST['destination'] + ,$_REQUEST['message'] ); $xmlResponse = new SimpleXMLElement ($xmlString); $res = $xmlResponse->sms; $db->query ( - 'INSERT INTO vn2008.sms (Id_trabajador, `text`, `to`, `from`, sent, response, Id_Cliente) - VALUES (account.userGetId(), #, #, #, #, #, #)', + 'INSERT INTO vn.sms SET + `senderFk` = account.userGetId(), + `destinationFk` = #, + `destination` = #, + `message` = #, + `statusCode` = #, + `status` = #', [ - $_REQUEST['text'] - ,$_REQUEST['to'] - ,$_REQUEST['to'] + empty ($_REQUEST['destinationId']) ? NULL : $_REQUEST['destinationId'] + ,$_REQUEST['destination'] + ,$_REQUEST['message'] ,$res->codigo ,$res->descripcion - ,empty ($_REQUEST['customer']) ? NULL : $_REQUEST['customer'] ] ); - if ($res->codigo != 0) + if (!in_array ($res->codigo, self::OK_STATES)) throw new Lib\UserException ($res->descripcion); return TRUE;