dolibarr  13.0.2
clicktodial.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2005-2020 Laurent Destailleur <eldy@users.sourceforge.org>
4  * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
26 require '../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
28 
29 // Load translation files required by the page
30 $langs->load("admin");
31 
32 if (!$user->admin) accessforbidden();
33 
34 $action = GETPOST('action', 'aZ09');
35 
36 if (!in_array('clicktodial', $conf->modules)) {
37  accessforbidden($langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module58Name")));
38 }
39 
40 
41 /*
42  * Actions
43  */
44 
45 if ($action == 'setvalue' && $user->admin)
46 {
47  $result1 = dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity);
48  $result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity);
49 
50  if ($result1 >= 0 && $result2 >= 0)
51  {
52  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
53  } else {
54  setEventMessages($langs->trans("Error"), null, 'errors');
55  }
56 }
57 
58 
59 /*
60  * View
61  */
62 
63 $form = new Form($db);
64 
65 $user->fetch_clicktodial();
66 
67 $wikihelp = 'EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es';
68 llxHeader('', $langs->trans("ClickToDialSetup"), $wikihelp);
69 
70 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
71 print load_fiche_titre($langs->trans("ClickToDialSetup"), $linkback, 'title_setup');
72 
73 print '<span class="opacitymedium">'.$langs->trans("ClickToDialDesc")."</span><br>\n";
74 
75 print '<br>';
76 print '<form method="post" action="clicktodial.php">';
77 print '<input type="hidden" name="token" value="'.newToken().'">';
78 print '<input type="hidden" name="action" value="setvalue">';
79 
80 print '<div class="div-table-responsive-no-min">';
81 print '<table class="noborder centpercent">';
82 print '<tr class="liste_titre">';
83 print '<td>'.$langs->trans("Name").'</td>';
84 print '<td>'.$langs->trans("Value").'</td>';
85 print "</tr>\n";
86 
87 
88 print '<tr class="oddeven"><td>';
89 print $langs->trans("ClickToDialUseTelLink").'</td><td>';
90 print $form->selectyesno("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", $conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS, 1).'<br>';
91 print '<br>';
92 print $langs->trans("ClickToDialUseTelLinkDesc");
93 print '</td></tr>';
94 
95 
96 print '<tr class="oddeven"><td>';
97 print $langs->trans("DefaultLink").'</td><td>';
98 print '<input class="quatrevingtpercent" type="text" id="CLICKTODIAL_URL" name="CLICKTODIAL_URL"'.($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS ? ' disabled="disabled"' : '').' value="'.$conf->global->CLICKTODIAL_URL.'"><br>';
99 print ajax_autoselect('CLICKTODIAL_URL');
100 print '<br>';
101 print $langs->trans("ClickToDialUrlDesc").'<br>';
102 print $langs->trans("Example").':<br>http://myphoneserver/mypage?login=__LOGIN__&password=__PASS__&caller=__PHONEFROM__&called=__PHONETO__';
103 
104 //if (! empty($user->clicktodial_url))
105 //{
106  print '<br>';
107  print info_admin($langs->trans("ValueOverwrittenByUserSetup"));
108 //}
109 
110 print '</td></tr>';
111 
112 print '</table>';
113 print '</div>';
114 
115 print '<div class="center"><br><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
116 
117 print '</form><br><br>';
118 
119 
120 if (!empty($conf->global->CLICKTODIAL_URL))
121 {
122  $user->fetch_clicktodial();
123 
124  $phonefortest = $mysoc->phone;
125  if (GETPOST('phonefortest')) $phonefortest = GETPOST('phonefortest');
126 
127  print '<form action="'.$_SERVER["PHP_SELF"].'">';
128  print '<input type="hidden" name="token" value="'.newToken().'">';
129  print $langs->trans("LinkToTestClickToDial", $user->login).' : ';
130  print '<input class="flat" type="text" name="phonefortest" value="'.dol_escape_htmltag($phonefortest).'">';
131  print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("RefreshPhoneLink")).'">';
132  print '</form>';
133 
134  $setupcomplete = 1;
135  if (preg_match('/__LOGIN__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_login)) $setupcomplete = 0;
136  if (preg_match('/__PASSWORD__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_password)) $setupcomplete = 0;
137  if (preg_match('/__PHONEFROM__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_poste)) $setupcomplete = 0;
138 
139  if ($setupcomplete)
140  {
141  print $langs->trans("LinkToTest", $user->login).': '.dol_print_phone($phonefortest, '', 0, 0, 'AC_TEL');
142  } else {
143  $langs->load("errors");
144  print '<div class="warning">'.$langs->trans("WarningClickToDialUserSetupNotComplete").'</div>';
145  }
146 }
147 
148 // End of page
149 llxFooter();
150 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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).
Definition: admin.lib.php:575
dol_print_phone($phone, $countrycode= '', $cid=0, $socid=0, $addlink= '', $separ="&nbsp;", $withpicto= '', $titlealt= '', $adddivfloat=0)
Format phone numbers according to country.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $wikihelp
View.
Definition: agenda.php:120
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
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 ...
ajax_autoselect($htmlname, $addlink= '')
Make content of an input box selected when we click into input field.
print
Draft customers invoices.
Definition: index.php:89
llxFooter()
Empty footer.
Definition: wrapper.php:59
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.