dolibarr 23.0.3
clicktodial.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005-2021 Laurent Destailleur <eldy@users.sourceforge.org>
4 * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
5 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
40
41// Load translation files required by the page
42$langs->load("admin");
43
44if (!$user->admin) {
46}
47
48$action = GETPOST('action', 'aZ09');
49
50if (!isModEnabled('clicktodial')) {
51 accessforbidden($langs->transnoentitiesnoconv("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module58Name")));
52}
53
54
55/*
56 * Actions
57 */
58
59if ($action == 'setvalue'/* && $user->admin */) {
60 $result1 = dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity);
61 $result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity);
62 $result3 = dolibarr_set_const($db, "CLICKTODIAL_KEY_FOR_CIDLOOKUP", GETPOST("CLICKTODIAL_KEY_FOR_CIDLOOKUP"), 'chaine', 0, '', $conf->entity);
63
64 if ($result1 >= 0 && $result2 >= 0 && $result3 >= 0) {
65 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
66 } else {
67 setEventMessages($langs->trans("Error"), null, 'errors');
68 }
69}
70
71
72/*
73 * View
74 */
75
76$form = new Form($db);
77
78$user->fetch_clicktodial();
79
80$wikihelp = 'EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es';
81llxHeader('', $langs->trans("ClickToDialSetup"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-clicktodial');
82
83$linkback = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/admin/modules.php', ['restore_lastsearch_values' => 1]).'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
84
85print load_fiche_titre($langs->trans("ClickToDialSetup"), $linkback, 'title_setup');
86
87print '<span class="opacitymedium">'.$langs->trans("ClickToDialDesc")."</span><br>\n";
88
89print '<br>';
90print '<form method="post" action="clicktodial.php">';
91print '<input type="hidden" name="token" value="'.newToken().'">';
92print '<input type="hidden" name="action" value="setvalue">';
93
94print '<div class="div-table-responsive-no-min">';
95print '<table class="noborder centpercent">';
96print '<tr class="liste_titre">';
97print '<td class="minwidth200">'.$langs->trans("Parameter").'</td>';
98print '<td></td>';
99print "</tr>\n";
100
101
102print '<tr class="oddeven"><td>';
103print $langs->trans("ClickToDialUseTelLink").'</td><td>';
104print $form->selectyesno("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", getDolGlobalString('CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS'), 1).'<br>';
105print '<br>';
106print '<span class="opacitymedium small">'.$langs->trans("ClickToDialUseTelLinkDesc").'</span>';
107print '</td></tr>';
108
109
110print '<tr class="oddeven"><td>';
111print $langs->trans("DefaultLink").'</td><td>';
112print '<input class="quatrevingtpercent" type="text" id="CLICKTODIAL_URL" name="CLICKTODIAL_URL"'.(getDolGlobalString('CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS') ? ' disabled="disabled"' : '').' value="'.getDolGlobalString('CLICKTODIAL_URL').'"><br>';
113print ajax_autoselect('CLICKTODIAL_URL');
114print '<br>';
115print $langs->trans("ClickToDialUrlDesc").'<br>';
116print '<br>';
117print '<span class="opacitymedium">';
118print $langs->trans("Examples").':<br>';
119print '* https://myphoneserver/phoneurl?login=__LOGIN__&password=__PASS__&caller=__PHONEFROM__&called=__PHONETO__<br>';
120print '* sip:__PHONETO__@my.sip.server';
121print '</span>';
122
123//if (!empty($user->clicktodial_url))
124//{
125 print '<br>';
126 print info_admin($langs->trans("ValueOverwrittenByUserSetup"));
127//}
128
129print '</td></tr>';
130
131print '<tr class="oddeven">';
132print '<td>'.$langs->trans("SecurityKey").'</td>';
133print '<td>';
134
136
137// Define $urlwithroot
138$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
139$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
140//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
141
142// Url for CIDLookup
143//print '<div class="div-table-responsive-no-min">';
144$url = $urlwithroot.'/public/clicktodial/cidlookup.php?securitykey='.getDolGlobalString('CLICKTODIAL_KEY_FOR_CIDLOOKUP', 'ValueToDefine').'&phone=...';
145//print img_picto('', 'globe').' <a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$url."</a><br>\n";
146//print '</div>';
147//print '<br>';
148
149
150print '<span class="opacitymedium">'.$langs->trans("CIDLookupURL").'</span>';
151print '<br>'.$url;
152print '<br>';
153print '<br>';
154print '<input type="text" class="flat minwidth300" id="CLICKTODIAL_KEY_FOR_CIDLOOKUP" name="CLICKTODIAL_KEY_FOR_CIDLOOKUP" value="'.(GETPOST('CLICKTODIAL_KEY_FOR_CIDLOOKUP') ? GETPOST('CLICKTODIAL_KEY_FOR_CIDLOOKUP') : getDolGlobalString('CLICKTODIAL_KEY_FOR_CIDLOOKUP')).'">';
155if (!empty($conf->use_javascript_ajax)) {
156 print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
157}
158print '</td>';
159print '</tr>';
160
161print '</table>';
162print '</div>';
163
164print $form->buttonsSaveCancel("Modify", '');
165
166print '</form><br><br>';
167
168
169if (getDolGlobalString('CLICKTODIAL_URL')) {
170 $user->fetch_clicktodial();
171
172 $phonefortest = $mysoc->phone ?? '';
173 if (GETPOST('phonefortest')) {
174 $phonefortest = GETPOST('phonefortest');
175 }
176
177 print '<form action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
178 print '<input type="hidden" name="token" value="'.newToken().'">';
179 print $langs->trans("LinkToTestClickToDial", $user->login).' : ';
180 print '<input class="flat" type="text" name="phonefortest" value="'.dol_escape_htmltag($phonefortest).'">';
181 print '<input type="submit" class="button small" value="'.dol_escape_htmltag($langs->trans("RefreshPhoneLink")).'">';
182 print '</form>';
183
184 $setupcomplete = 1;
185 if (preg_match('/__LOGIN__/', getDolGlobalString('CLICKTODIAL_URL')) && empty($user->clicktodial_login)) {
186 $setupcomplete = 0;
187 }
188 if (preg_match('/__PASSWORD__/', getDolGlobalString('CLICKTODIAL_URL')) && empty($user->clicktodial_password)) {
189 $setupcomplete = 0;
190 }
191 if (preg_match('/__PHONEFROM__/', getDolGlobalString('CLICKTODIAL_URL')) && empty($user->clicktodial_poste)) {
192 $setupcomplete = 0;
193 }
194
195 if ($setupcomplete) {
196 print $langs->trans("LinkToTest", $user->login).': &nbsp; '.dol_print_phone($phonefortest, '', 0, 0, 'AC_TEL', '', 'mobile');
197 } else {
198 $langs->load("errors");
199 print '<div class="warning">'.$langs->trans("WarningClickToDialUserSetupNotComplete").'</div>';
200 }
201}
202
203// Add button to autosuggest a key
204include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
205print dolJSToSetRandomPassword('CLICKTODIAL_KEY_FOR_CIDLOOKUP');
206
207
208// End of page
209llxFooter();
210$db->close();
global $dolibarr_main_url_root
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage generation of HTML components Only common components must be here.
global $mysoc
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dol_print_phone($phone, $countrycode='', $contactid=0, $socid=0, $addlink='', $separ="&nbsp;", $withpicto='', $titlealt='', $adddivfloat=0, $morecss='paddingright')
Format phone numbers according to country.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Output javascript to autoset a generated password using default module into a HTML element.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.