<?php

try {
    //récupération des valeurs $_GET
    $unite = User::get('nom');
    $msg = $this->waitParam('get', 'message', array(Request::PARAM_NOT_NULL));
    $lang = $this->waitParam('get', 'lang', array(Request::PARAM_NOT_NULL));
    // $code = User::get('code');
    $val = $this->waitParam('get', 'val', array(Request::PARAM_NOT_NULL, Request::PARAM_TYPE_INTEGER));
    $tel = $this->waitParam('get', 'tel', array(Request::PARAM_NOT_NULL, Request::PARAM_TYPE_TPH));
    $DB = new Database();
    $lastid = $DB->addSmsLock($unite, $msg, $lang, $tel, $val);
    $urlSMS = APP::getInstance()->config['url'];
    //génération texte suivant msg langue et code
    $sender = "GENDLOC";
    if ($msg == "Geoloc") {
        $text = "* Vérifier GPS et DATA à ON\r\n* Cliquer le lien " . $urlSMS . "/pos?c=" . $lastid . "\r\n* Accepter le partage\r\n* Patienter\r\n" . $unite;
    } elseif ($msg == "Tracking") {
        $text = "* Vérifier GPS et DATA à ON\r\n* Cliquer le lien " . $urlSMS . "/trace?c=" . $lastid . "\r\n* Accepter le partage\r\n" . $unite;
    }
    //envoi SMS et récupération du hash d'envoi
    // require('/js/thecallR/src/ThecallrClient.php');
    $config = APP::getInstance()->config['thecallr'];
    $thecallrLogin = $config['login'];
    $thecallrPassword = $config['password'];
    $THECALLR = new ThecallrClient($thecallrLogin, $thecallrPassword);
    $settings = $config['settings'];
    $res = $THECALLR->send($config['order']['set'], array($settings));
    // Options
    $options = new stdClass();
    $options->flash_message = FALSE;