71 print
"\n".
'</html>'.
"\n";
74require_once
'../main.inc.php';
75require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
76require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
80if (empty($conf->clicktodial->enabled)) {
87if (!isset($conf->global->ASTERISK_HOST)) {
88 $conf->global->ASTERISK_HOST =
"127.0.0.1";
90if (!isset($conf->global->ASTERISK_TYPE)) {
91 $conf->global->ASTERISK_TYPE =
"SIP/";
93if (!isset($conf->global->ASTERISK_INDICATIF)) {
94 $conf->global->ASTERISK_INDICATIF =
"0";
96if (!isset($conf->global->ASTERISK_PORT)) {
97 $conf->global->ASTERISK_PORT = 5038;
100 $conf->global->ASTERISK_INDICATIF =
'';
102if (!isset($conf->global->ASTERISK_CONTEXT)) {
103 $conf->global->ASTERISK_CONTEXT =
"from-internal";
105if (!isset($conf->global->ASTERISK_WAIT_TIME)) {
106 $conf->global->ASTERISK_WAIT_TIME =
"30";
108if (!isset($conf->global->ASTERISK_PRIORITY)) {
109 $conf->global->ASTERISK_PRIORITY =
"1";
111if (!isset($conf->global->ASTERISK_MAX_RETRY)) {
112 $conf->global->ASTERISK_MAX_RETRY =
"2";
116$login =
GETPOST(
'login',
'alphanohtml');
117$password =
GETPOST(
'password',
'none');
118$caller =
GETPOST(
'caller',
'alphanohtml');
119$called =
GETPOST(
'called',
'alphanohtml');
122$strHost = $conf->global->ASTERISK_HOST;
126$channel = $conf->global->ASTERISK_TYPE;
129$prefix = $conf->global->ASTERISK_INDICATIF;
132$port = $conf->global->ASTERISK_PORT;
135$strContext = $conf->global->ASTERISK_CONTEXT;
138$strWaitTime = $conf->global->ASTERISK_WAIT_TIME;
141$strPriority = $conf->global->ASTERISK_PRIORITY;
144$strMaxRetry = $conf->global->ASTERISK_MAX_RETRY;
153$sql =
"SELECT s.nom as name FROM ".MAIN_DB_PREFIX.
"societe as s";
154$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON sp.fk_soc = s.rowid";
155$sql .=
" WHERE s.entity IN (".getEntity(
'societe').
")";
156$sql .=
" AND (s.phone='".$db->escape($called).
"'";
157$sql .=
" OR sp.phone='".$db->escape($called).
"'";
158$sql .=
" OR sp.phone_perso='".$db->escape($called).
"'";
159$sql .=
" OR sp.phone_mobile='".$db->escape($called).
"')";
160$sql .= $db->plimit(1);
162dol_syslog(
'click to dial search information with phone '.$called, LOG_DEBUG);
163$resql = $db->query($sql);
165 $obj = $db->fetch_object($resql);
169 $found =
'Not found';
177$number = strtolower($called);
178$pos = strpos($number,
"local");
179if (!empty($number)) {
180 if ($pos ===
false) {
183 $strCallerId =
"Dolibarr caller $found <".strtolower($number).
">";
184 $oSocket = @fsockopen($strHost, $port, $errno, $errstr, 10);
187 $txt =
"Failed to execute fsockopen($strHost, $port, \$errno, \$errstr, 10)<br>\n";
190 $txt = $errstr.
" (".$errno.
")<br>\n";
193 print
'</body>'.
"\n";
195 $txt =
"Call Asterisk dialer for caller: ".$caller.
", called: ".$called.
" clicktodiallogin: ".$login;
197 print
'<body onload="history.go(-1);">'.
"\n";
198 print
'<!-- '.$txt.
' -->';
199 fputs($oSocket,
"Action: login\r\n");
200 fputs($oSocket,
"Events: off\r\n");
201 fputs($oSocket,
"Username: $login\r\n");
202 fputs($oSocket,
"Secret: $password\r\n\r\n");
203 fputs($oSocket,
"Action: originate\r\n");
204 fputs($oSocket,
"Channel: ".$channel.$caller.
"\r\n");
205 fputs($oSocket,
"WaitTime: $strWaitTime\r\n");
206 fputs($oSocket,
"CallerId: $strCallerId\r\n");
207 fputs($oSocket,
"Exten: ".$prefix.$number.
"\r\n");
208 fputs($oSocket,
"Context: $strContext\r\n");
209 fputs($oSocket,
"Priority: $strPriority\r\n\r\n");
210 fputs($oSocket,
"Action: Logoff\r\n\r\n");
213 print
'</body>'.
"\n";
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.