31 if (!defined(
'NOREQUIRESOC')) define(
'NOREQUIRESOC',
'1');
32 if (!defined(
'NOREQUIRETRAN')) define(
'NOREQUIRETRAN',
'1');
33 if (!defined(
'NOCSRFCHECK')) define(
'NOCSRFCHECK',
'1');
34 if (!defined(
'NOTOKENRENEWAL')) define(
'NOTOKENRENEWAL',
'1');
35 if (!defined(
'NOREQUIREMENU')) define(
'NOREQUIREMENU',
'1');
36 if (!defined(
'NOREQUIREHTML')) define(
'NOREQUIREHTML',
'1');
37 if (!defined(
'NOREQUIREAJAX')) define(
'NOREQUIREAJAX',
'1');
49 print '<title>Asterisk redirection from Dolibarr...</title>'.
"\n";
61 print "\n".
'</html>'.
"\n";
64 require_once
'../main.inc.php';
65 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
66 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
70 if (empty($conf->clicktodial->enabled))
78 if (!isset($conf->global->ASTERISK_HOST)) $conf->global->ASTERISK_HOST =
"127.0.0.1";
79 if (!isset($conf->global->ASTERISK_TYPE)) $conf->global->ASTERISK_TYPE =
"SIP/";
80 if (!isset($conf->global->ASTERISK_INDICATIF)) $conf->global->ASTERISK_INDICATIF =
"0";
81 if (!isset($conf->global->ASTERISK_PORT)) $conf->global->ASTERISK_PORT = 5038;
82 if ($conf->global->ASTERISK_INDICATIF ==
'NONE') $conf->global->ASTERISK_INDICATIF =
'';
83 if (!isset($conf->global->ASTERISK_CONTEXT)) $conf->global->ASTERISK_CONTEXT =
"from-internal";
84 if (!isset($conf->global->ASTERISK_WAIT_TIME)) $conf->global->ASTERISK_WAIT_TIME =
"30";
85 if (!isset($conf->global->ASTERISK_PRIORITY)) $conf->global->ASTERISK_PRIORITY =
"1";
86 if (!isset($conf->global->ASTERISK_MAX_RETRY)) $conf->global->ASTERISK_MAX_RETRY =
"2";
90 $password =
GETPOST(
'password');
95 $strHost = $conf->global->ASTERISK_HOST;
98 $channel = $conf->global->ASTERISK_TYPE;
100 $prefix = $conf->global->ASTERISK_INDICATIF;
102 $port = $conf->global->ASTERISK_PORT;
104 $strContext = $conf->global->ASTERISK_CONTEXT;
106 $strWaitTime = $conf->global->ASTERISK_WAIT_TIME;
108 $strPriority = $conf->global->ASTERISK_PRIORITY;
110 $strMaxRetry = $conf->global->ASTERISK_MAX_RETRY;
119 $sql =
"SELECT s.nom as name FROM ".MAIN_DB_PREFIX.
"societe as s";
120 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON sp.fk_soc = s.rowid";
121 $sql .=
" WHERE s.entity IN (".getEntity(
'societe').
")";
122 $sql .=
" AND (s.phone='".$db->escape($called).
"'";
123 $sql .=
" OR sp.phone='".$db->escape($called).
"'";
124 $sql .=
" OR sp.phone_perso='".$db->escape($called).
"'";
125 $sql .=
" OR sp.phone_mobile='".$db->escape($called).
"')";
126 $sql .= $db->plimit(1);
128 dol_syslog(
'click to dial search information with phone '.$called, LOG_DEBUG);
129 $resql = $db->query($sql);
132 $obj = $db->fetch_object(
$resql);
145 $number = strtolower($called);
146 $pos = strpos($number,
"local");
153 $strCallerId =
"Dolibarr call $found <".strtolower($number).
">";
154 $oSocket = @fsockopen($strHost, $port, $errno, $errstr, 10);
158 $txt =
"Failed to execute fsockopen($strHost, $port, \$errno, \$errstr, 10)<br>\n";
161 $txt = $errstr.
" (".$errno.
")<br>\n";
164 print '</body>'.
"\n";
166 $txt =
"Call Asterisk dialer for caller: ".$caller.
", called: ".$called.
" clicktodiallogin: ".$login;
168 print '<body onload="javascript:history.go(-1);">'.
"\n";
169 print '<!-- '.$txt.
' -->';
170 fputs($oSocket,
"Action: login\r\n");
171 fputs($oSocket,
"Events: off\r\n");
172 fputs($oSocket,
"Username: $login\r\n");
173 fputs($oSocket,
"Secret: $password\r\n\r\n");
174 fputs($oSocket,
"Action: originate\r\n");
175 fputs($oSocket,
"Channel: ".$channel.$caller.
"\r\n");
176 fputs($oSocket,
"WaitTime: $strWaitTime\r\n");
177 fputs($oSocket,
"CallerId: $strCallerId\r\n");
178 fputs($oSocket,
"Exten: ".$prefix.$number.
"\r\n");
179 fputs($oSocket,
"Context: $strContext\r\n");
180 fputs($oSocket,
"Priority: $strPriority\r\n\r\n");
181 fputs($oSocket,
"Action: Logoff\r\n\r\n");
184 print '</body>'.
"\n";
188 print 'Bad parameters in URL. Must be '.$_SERVER[
'PHP_SELF'].
'?caller=99999&called=99999&login=xxxxx&password=xxxxx';
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 Calling this function terminate execution ...
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $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...