dolibarr  7.0.0-beta
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 $langs->load("admin");
30 
31 if (!$user->admin) accessforbidden();
32 
33 $action = GETPOST('action','aZ09');
34 
35 
36 /*
37  * Actions
38  */
39 
40 if ($action == 'setvalue' && $user->admin)
41 {
42  $result=dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity);
43  $result=dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity);
44 
45  if ($result1 >= 0 && $result2 >= 0)
46  {
47  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
48  }
49  else
50  {
51  setEventMessages($langs->trans("Error"), null, 'errors');
52  }
53 }
54 
55 
56 /*
57  * View
58  */
59 
60 $user->fetch_clicktodial();
61 
62 $wikihelp='EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es';
63 llxHeader('',$langs->trans("ClickToDialSetup"),$wikihelp);
64 
65 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
66 print load_fiche_titre($langs->trans("ClickToDialSetup"),$linkback,'title_setup');
67 
68 print $langs->trans("ClickToDialDesc")."<br>\n";
69 
70 print '<br>';
71 print '<form method="post" action="clicktodial.php">';
72 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
73 print '<input type="hidden" name="action" value="setvalue">';
74 
75 $var=true;
76 
77 print '<table class="noborder" width="100%">';
78 print '<tr class="liste_titre">';
79 print '<td>'.$langs->trans("Name").'</td>';
80 print '<td>'.$langs->trans("Value").'</td>';
81 print "</tr>\n";
82 
83 
84 print '<tr class="oddeven"><td>';
85 print $langs->trans("ClickToDialUseTelLink").'</td><td>';
86 print $form->selectyesno("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", $conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS, 1).'<br>';
87 print '<br>';
88 print $langs->trans("ClickToDialUseTelLinkDesc");
89 print '</td></tr>';
90 
91 
92 print '<tr class="oddeven"><td>';
93 print $langs->trans("DefaultLink").'</td><td>';
94 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>';
95 print ajax_autoselect('CLICKTODIAL_URL');
96 print '<br>';
97 print $langs->trans("ClickToDialUrlDesc").'<br>';
98 print $langs->trans("Example").':<br>http://myphoneserver/mypage?login=__LOGIN__&password=__PASS__&caller=__PHONEFROM__&called=__PHONETO__';
99 
100 //if (! empty($user->clicktodial_url))
101 //{
102  print '<br>';
103  print info_admin($langs->trans("ValueOverwrittenByUserSetup"));
104 //}
105 
106 print '</td></tr>';
107 
108 print '</table>';
109 
110 print '<div class="center"><br><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
111 
112 print '</form><br><br>';
113 
114 
115 if (! empty($conf->global->CLICKTODIAL_URL))
116 {
117  $user->fetch_clicktodial();
118 
119  $phonefortest=$mysoc->phone;
120  if (GETPOST('phonefortest')) $phonefortest=GETPOST('phonefortest');
121 
122  print '<form action="'.$_SERVER["PHP_SELF"].'">';
123  print $langs->trans("LinkToTestClickToDial",$user->login).' : ';
124  print '<input class="flat" type="text" name="phonefortest" value="'.dol_escape_htmltag($phonefortest).'">';
125  print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("RefreshPhoneLink")).'">';
126  print '</form>';
127 
128  $setupcomplete=1;
129  if (preg_match('/__LOGIN__/',$conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_login)) $setupcomplete=0;
130  if (preg_match('/__PASSWORD__/',$conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_password)) $setupcomplete=0;
131  if (preg_match('/__PHONEFROM__/',$conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_poste)) $setupcomplete=0;
132 
133  if ($setupcomplete)
134  {
135  print $langs->trans("LinkToTest",$user->login).': '.dol_print_phone($phonefortest, '', 0, 0, 'AC_TEL');
136  }
137  else
138  {
139  $langs->load("errors");
140  print '<div class="warning">'.$langs->trans("WarningClickToDialUserSetupNotComplete").'</div>';
141  }
142 }
143 
144 llxFooter();
145 
146 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
ajax_autoselect($htmlname, $addlink='')
Make content of an input box selected when we click into input field.
Definition: ajax.lib.php:367
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:485
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
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')
Show information for admin users or standard users.
if(GETPOST('button_removefilter_x','alpha')||GETPOST('button_removefilter.x','alpha')||GETPOST('button_removefilter','alpha')) if($action=="save"&&empty($cancel)) if(preg_match('/set_(.*)/', $action, $reg)) if(preg_match('/del_(.*)/', $action, $reg) $wikihelp)
View.
Definition: agenda.php:143
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
print
Draft customers invoices.
Definition: index.php:91
dol_print_phone($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ="&nbsp;", $withpicto='', $titlealt='', $adddivfloat=0)
Format phone numbers according to country.