SMS bugs solved

This commit is contained in:
Juan Ferrer Toribio 2017-12-19 10:08:11 +01:00
parent e0ced87f7c
commit 723b584af9
4 changed files with 25 additions and 15 deletions

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
hedera-web (1.405.52) stable; urgency=low
hedera-web (1.405.53) stable; urgency=low
* Initial Release.

View File

@ -1,6 +1,6 @@
{
"name": "hedera-web",
"version": "1.405.52",
"version": "1.405.53",
"description": "Verdnatura web page",
"license": "GPL-3.0",
"repository": {

View File

@ -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);
}

View File

@ -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;