From 719c062eef46815f240ec41fa4d0d76a8c5ca5b8 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 13 Dec 2017 19:28:54 +0100 Subject: [PATCH] SMS bugs solved, refactor --- debian/changelog | 2 +- forms/ecomerce/catalog/catalog.js | 2 +- forms/ecomerce/confirm/ui.xml | 2 +- package.json | 2 +- rest/misc/sms.php | 45 ++++++++++++++----------------- web/service.php | 3 ++- 6 files changed, 26 insertions(+), 30 deletions(-) diff --git a/debian/changelog b/debian/changelog index 3a68a565..18d9f50c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (1.405.46) stable; urgency=low +hedera-web (1.405.47) stable; urgency=low * Initial Release. diff --git a/forms/ecomerce/catalog/catalog.js b/forms/ecomerce/catalog/catalog.js index 0326669f..ee6d7a77 100644 --- a/forms/ecomerce/catalog/catalog.js +++ b/forms/ecomerce/catalog/catalog.js @@ -303,7 +303,7 @@ Hedera.Catalog = new Class { var sql = ''; var batch = new Sql.Batch (); - var query = new Sql.String ({query: 'CALL basket_item_add (#warehouse, #item, #amount);'}); + var query = new Sql.String ({query: 'CALL basketAddItem (#warehouse, #item, #amount);'}); var amountSum = 0; for (var warehouse in this.items) diff --git a/forms/ecomerce/confirm/ui.xml b/forms/ecomerce/confirm/ui.xml index 54cc0894..bbf125a7 100644 --- a/forms/ecomerce/confirm/ui.xml +++ b/forms/ecomerce/confirm/ui.xml @@ -25,7 +25,7 @@ - CALL basket_confirm () + CALL basketConfirm diff --git a/package.json b/package.json index 3431598d..2773895e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hedera-web", - "version": "1.405.46", + "version": "1.405.47", "description": "Verdnatura web page", "license": "GPL-3.0", "repository": { diff --git a/rest/misc/sms.php b/rest/misc/sms.php index 17f000cc..e5f825e1 100644 --- a/rest/misc/sms.php +++ b/rest/misc/sms.php @@ -11,39 +11,34 @@ class Sms extends Vn\Web\JsonRequest function run ($db) { - $smsConfig = $db->getRow ('SELECT uri, user, password, title FROM sms_config'); + $smsConfig = $db->getObject ('SELECT uri, user, password, title FROM sms_config'); - $sClient = new SoapClient ($smsConfig['uri']); + $sClient = new SoapClient ($smsConfig->uri); $xmlString = $sClient->sendSMS ( - $smsConfig['user'] - ,$smsConfig['password'] - ,$smsConfig['title'] + $smsConfig->user + ,$smsConfig->password + ,$smsConfig->title ,$_REQUEST['to'] ,$_REQUEST['text'] ); $xmlResponse = new SimpleXMLElement ($xmlString); + $res = $xmlResponse->sms; - $customer = empty ($_REQUEST['customer']) ? NULL : $_REQUEST['customer']; + $db->query ( + 'INSERT INTO vn2008.sms (Id_trabajador, `text`, `to`, `from`, sent, response, Id_Cliente) + VALUES (account.userGetId(), #, #, #, #, #, #)', + [ + $_REQUEST['text'] + ,$_REQUEST['to'] + ,$_REQUEST['to'] + ,$res->codigo + ,$res->descripcion + ,empty ($_REQUEST['customer']) ? NULL : $_REQUEST['customer'] + ] + ); - try { - $sms = $xmlResponse->sms; - $db->query ( - 'INSERT INTO vn2008.sms (Id_trabajador, `text`, `to`, `from`, sent, response, Id_Cliente) - VALUES (account.userGetId(), #, #, #, #, #, #)', - [ - $_REQUEST['text'] - ,$_REQUEST['to'] - ,$_REQUEST['to'] - ,$sms->codigo - ,$sms->descripcion - ,$customer - ] - ); - } - catch (Exception $e) - { - trigger_error ($e->getMessage (), E_USER_WARNING); - } + if ($sms->codigo != 0) + throw new Lib\UserException ($res->descripcion); return TRUE; } diff --git a/web/service.php b/web/service.php index a74d4193..14fc9093 100644 --- a/web/service.php +++ b/web/service.php @@ -87,7 +87,8 @@ abstract class Service if (isset ($_COOKIE['PHPSESSID']) || isset ($_SESSION['access']) - || isset ($_SESSION['skipVisit'])) + || isset ($_SESSION['skipVisit']) + || !isset ($_SERVER['HTTP_USER_AGENT'])) return; $agent = $_SERVER['HTTP_USER_AGENT'];