31 if (!defined(
'NOREQUIRESOC')) {
32 define(
'NOREQUIRESOC',
'1');
34 if (!defined(
'NOREQUIRETRAN')) {
35 define(
'NOREQUIRETRAN',
'1');
37 if (!defined(
'NOTOKENRENEWAL')) {
38 define(
'NOTOKENRENEWAL',
'1');
40 if (!defined(
'NOREQUIREMENU')) {
41 define(
'NOREQUIREMENU',
'1');
43 if (!defined(
'NOREQUIREHTML')) {
44 define(
'NOREQUIREHTML',
'1');
46 if (!defined(
'NOREQUIREAJAX')) {
47 define(
'NOREQUIREAJAX',
'1');
60 print
'<title>Asterisk redirection from Dolibarr...</title>'.
"\n";
72 print
"\n".
'</html>'.
"\n";
75 require_once
'../main.inc.php';
76 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
77 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
81 if (empty($conf->clicktodial->enabled)) {
88 if (!isset($conf->global->ASTERISK_HOST)) {
89 $conf->global->ASTERISK_HOST =
"127.0.0.1";
91 if (!isset($conf->global->ASTERISK_TYPE)) {
92 $conf->global->ASTERISK_TYPE =
"SIP/";
94 if (!isset($conf->global->ASTERISK_INDICATIF)) {
95 $conf->global->ASTERISK_INDICATIF =
"0";
97 if (!isset($conf->global->ASTERISK_PORT)) {
98 $conf->global->ASTERISK_PORT = 5038;
100 if ($conf->global->ASTERISK_INDICATIF ==
'NONE') {
101 $conf->global->ASTERISK_INDICATIF =
'';
103 if (!isset($conf->global->ASTERISK_CONTEXT)) {
104 $conf->global->ASTERISK_CONTEXT =
"from-internal";
106 if (!isset($conf->global->ASTERISK_WAIT_TIME)) {
107 $conf->global->ASTERISK_WAIT_TIME =
"30";
109 if (!isset($conf->global->ASTERISK_PRIORITY)) {
110 $conf->global->ASTERISK_PRIORITY =
"1";
112 if (!isset($conf->global->ASTERISK_MAX_RETRY)) {
113 $conf->global->ASTERISK_MAX_RETRY =
"2";
117 $login =
GETPOST(
'login',
'alphanohtml');
118 $password =
GETPOST(
'password',
'none');
119 $caller =
GETPOST(
'caller',
'alphanohtml');
120 $called =
GETPOST(
'called',
'alphanohtml');
123 $strHost = $conf->global->ASTERISK_HOST;
126 $channel = $conf->global->ASTERISK_TYPE;
128 $prefix = $conf->global->ASTERISK_INDICATIF;
130 $port = $conf->global->ASTERISK_PORT;
132 $strContext = $conf->global->ASTERISK_CONTEXT;
134 $strWaitTime = $conf->global->ASTERISK_WAIT_TIME;
136 $strPriority = $conf->global->ASTERISK_PRIORITY;
138 $strMaxRetry = $conf->global->ASTERISK_MAX_RETRY;
147 $sql =
"SELECT s.nom as name FROM ".MAIN_DB_PREFIX.
"societe as s";
148 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON sp.fk_soc = s.rowid";
149 $sql .=
" WHERE s.entity IN (".getEntity(
'societe').
")";
150 $sql .=
" AND (s.phone='".$db->escape($called).
"'";
151 $sql .=
" OR sp.phone='".$db->escape($called).
"'";
152 $sql .=
" OR sp.phone_perso='".$db->escape($called).
"'";
153 $sql .=
" OR sp.phone_mobile='".$db->escape($called).
"')";
154 $sql .= $db->plimit(1);
156 dol_syslog(
'click to dial search information with phone '.$called, LOG_DEBUG);
157 $resql = $db->query($sql);
159 $obj = $db->fetch_object(
$resql);
163 $found =
'Not found';
171 $number = strtolower($called);
172 $pos = strpos($number,
"local");
173 if (!empty($number)) {
174 if ($pos ===
false) {
177 $strCallerId =
"Dolibarr caller $found <".strtolower($number).
">";
178 $oSocket = @fsockopen($strHost, $port, $errno, $errstr, 10);
181 $txt =
"Failed to execute fsockopen($strHost, $port, \$errno, \$errstr, 10)<br>\n";
184 $txt = $errstr.
" (".$errno.
")<br>\n";
187 print
'</body>'.
"\n";
189 $txt =
"Call Asterisk dialer for caller: ".$caller.
", called: ".$called.
" clicktodiallogin: ".$login;
191 print
'<body onload="javascript:history.go(-1);">'.
"\n";
192 print
'<!-- '.$txt.
' -->';
193 fputs($oSocket,
"Action: login\r\n");
194 fputs($oSocket,
"Events: off\r\n");
195 fputs($oSocket,
"Username: $login\r\n");
196 fputs($oSocket,
"Secret: $password\r\n\r\n");
197 fputs($oSocket,
"Action: originate\r\n");
198 fputs($oSocket,
"Channel: ".$channel.$caller.
"\r\n");
199 fputs($oSocket,
"WaitTime: $strWaitTime\r\n");
200 fputs($oSocket,
"CallerId: $strCallerId\r\n");
201 fputs($oSocket,
"Exten: ".$prefix.$number.
"\r\n");
202 fputs($oSocket,
"Context: $strContext\r\n");
203 fputs($oSocket,
"Priority: $strPriority\r\n\r\n");
204 fputs($oSocket,
"Action: Logoff\r\n\r\n");
207 print
'</body>'.
"\n";
211 print
'Bad parameters in URL. Must be '.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?caller=99999&called=99999&login=xxxxx&password=xxxxx';
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.