dolibarr  9.0.0
clicktodial.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2005-2011 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 <http://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 
37 /*
38  * Actions
39  */
40 
41 if ($action == 'setvalue' && $user->admin)
42 {
43  $result=dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity);
44  $result=dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity);
45 
46  if ($result1 >= 0 && $result2 >= 0)
47  {
48  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
49  }
50  else
51  {
52  setEventMessages($langs->trans("Error"), null, 'errors');
53  }
54 }
55 
56 
57 /*
58  * View
59  */
60 
61 $user->fetch_clicktodial();
62 
63 $wikihelp='EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es';
64 llxHeader('',$langs->trans("ClickToDialSetup"),$wikihelp);
65 
66 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
67 print load_fiche_titre($langs->trans("ClickToDialSetup"),$linkback,'title_setup');
68 
69 print $langs->trans("ClickToDialDesc")."<br>\n";
70 
71 print '<br>';
72 print '<form method="post" action="clicktodial.php">';
73 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74 print '<input type="hidden" name="action" value="setvalue">';
75 
76 print '<table class="noborder" width="100%">';
77 print '<tr class="liste_titre">';
78 print '<td>'.$langs->trans("Name").'</td>';
79 print '<td>'.$langs->trans("Value").'</td>';
80 print "</tr>\n";
81 
82 
83 print '<tr class="oddeven"><td>';
84 print $langs->trans("ClickToDialUseTelLink").'</td><td>';
85 print $form->selectyesno("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", $conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS, 1).'<br>';
86 print '<br>';
87 print $langs->trans("ClickToDialUseTelLinkDesc");
88 print '</td></tr>';
89 
90 
91 print '<tr class="oddeven"><td>';
92 print $langs->trans("DefaultLink").'</td><td>';
93 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>';
94 print ajax_autoselect('CLICKTODIAL_URL');
95 print '<br>';
96 print $langs->trans("ClickToDialUrlDesc").'<br>';
97 print $langs->trans("Example").':<br>http://myphoneserver/mypage?login=__LOGIN__&password=__PASS__&caller=__PHONEFROM__&called=__PHONETO__';
98 
99 //if (! empty($user->clicktodial_url))
100 //{
101  print '<br>';
102  print info_admin($langs->trans("ValueOverwrittenByUserSetup"));
103 //}
104 
105 print '</td></tr>';
106 
107 print '</table>';
108 
109 print '<div class="center"><br><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
110 
111 print '</form><br><br>';
112 
113 
114 if (! empty($conf->global->CLICKTODIAL_URL))
115 {
116  $user->fetch_clicktodial();
117 
118  $phonefortest=$mysoc->phone;
119  if (GETPOST('phonefortest')) $phonefortest=GETPOST('phonefortest');
120 
121  print '<form action="'.$_SERVER["PHP_SELF"].'">';
122  print $langs->trans("LinkToTestClickToDial",$user->login).' : ';
123  print '<input class="flat" type="text" name="phonefortest" value="'.dol_escape_htmltag($phonefortest).'">';
124  print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("RefreshPhoneLink")).'">';
125  print '</form>';
126 
127  $setupcomplete=1;
128  if (preg_match('/__LOGIN__/',$conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_login)) $setupcomplete=0;
129  if (preg_match('/__PASSWORD__/',$conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_password)) $setupcomplete=0;
130  if (preg_match('/__PHONEFROM__/',$conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_poste)) $setupcomplete=0;
131 
132  if ($setupcomplete)
133  {
134  print $langs->trans("LinkToTest",$user->login).': '.dol_print_phone($phonefortest, '', 0, 0, 'AC_TEL');
135  }
136  else
137  {
138  $langs->load("errors");
139  print '<div class="warning">'.$langs->trans("WarningClickToDialUserSetupNotComplete").'</div>';
140  }
141 }
142 
143 // End of page
144 llxFooter();
145 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
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:510
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='')
Show information for admin users or standard users.
llxHeader()
Empty header.
Definition: wrapper.php:44
ajax_autoselect($htmlname, $addlink='')
Make content of an input box selected when we click into input field.
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