2016-09-01 11:42:11 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Vn\Lib;
|
|
|
|
|
|
|
|
class Sms extends Vn\Web\JsonRequest
|
|
|
|
{
|
2016-09-06 14:25:02 +00:00
|
|
|
const PARAMS = [
|
|
|
|
'to'
|
|
|
|
,'text'
|
|
|
|
];
|
2016-09-01 11:42:11 +00:00
|
|
|
|
2016-09-06 14:25:02 +00:00
|
|
|
function run ($db)
|
|
|
|
{
|
2016-09-01 11:42:11 +00:00
|
|
|
$smsConfig = $db->getRow ('SELECT uri, user, password, title FROM sms_config');
|
|
|
|
|
|
|
|
$sClient = new SoapClient ($smsConfig['uri']);
|
|
|
|
$xmlString = $sClient->sendSMS (
|
|
|
|
$smsConfig['user']
|
|
|
|
,$smsConfig['password']
|
|
|
|
,$smsConfig['title']
|
2016-09-06 14:25:02 +00:00
|
|
|
,$_REQUEST['to']
|
|
|
|
,$_REQUEST['text']
|
2016-09-01 11:42:11 +00:00
|
|
|
);
|
|
|
|
$xmlResponse = new SimpleXMLElement ($xmlString);
|
|
|
|
|
2016-09-06 14:25:02 +00:00
|
|
|
$customer = empty ($_REQUEST['customer']) ? NULL : $_REQUEST['customer'];
|
2016-09-01 11:42:11 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
$sms = $xmlResponse->sms;
|
|
|
|
$db->query (
|
|
|
|
'INSERT INTO vn2008.sms (Id_trabajador, `text`, `to`, `from`, sent, response, Id_Cliente)
|
|
|
|
VALUES (account.user_get_id(), #, #, #, #, #, #)',
|
|
|
|
[
|
2016-09-06 14:25:02 +00:00
|
|
|
$_REQUEST['text']
|
|
|
|
,$_REQUEST['to']
|
|
|
|
,$_REQUEST['to']
|
2016-09-01 11:42:11 +00:00
|
|
|
,$sms->codigo
|
|
|
|
,$sms->descripcion
|
|
|
|
,$customer
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
catch (Exception $e)
|
|
|
|
{
|
|
|
|
trigger_error ($e->getMessage (), E_USER_WARNING);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|