clicktodial.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. /**
  20. * \file htdocs/admin/clicktodial.php
  21. * \ingroup clicktodial
  22. * \brief Page to setup module clicktodial
  23. */
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  26. $langs->load("admin");
  27. if (!$user->admin) accessforbidden();
  28. $action = GETPOST('action','aZ09');
  29. /*
  30. * Actions
  31. */
  32. if ($action == 'setvalue' && $user->admin)
  33. {
  34. $result=dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity);
  35. $result=dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity);
  36. if ($result1 >= 0 && $result2 >= 0)
  37. {
  38. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  39. }
  40. else
  41. {
  42. setEventMessages($langs->trans("Error"), null, 'errors');
  43. }
  44. }
  45. /*
  46. * View
  47. */
  48. $user->fetch_clicktodial();
  49. $wikihelp='EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es';
  50. llxHeader('',$langs->trans("ClickToDialSetup"),$wikihelp);
  51. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  52. print load_fiche_titre($langs->trans("ClickToDialSetup"),$linkback,'title_setup');
  53. print $langs->trans("ClickToDialDesc")."<br>\n";
  54. print '<br>';
  55. print '<form method="post" action="clicktodial.php">';
  56. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  57. print '<input type="hidden" name="action" value="setvalue">';
  58. $var=true;
  59. print '<table class="noborder" width="100%">';
  60. print '<tr class="liste_titre">';
  61. print '<td>'.$langs->trans("Name").'</td>';
  62. print '<td>'.$langs->trans("Value").'</td>';
  63. print "</tr>\n";
  64. print '<tr class="oddeven"><td>';
  65. print $langs->trans("ClickToDialUseTelLink").'</td><td>';
  66. print $form->selectyesno("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", $conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS, 1).'<br>';
  67. print '<br>';
  68. print $langs->trans("ClickToDialUseTelLinkDesc");
  69. print '</td></tr>';
  70. print '<tr class="oddeven"><td>';
  71. print $langs->trans("DefaultLink").'</td><td>';
  72. 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>';
  73. print ajax_autoselect('CLICKTODIAL_URL');
  74. print '<br>';
  75. print $langs->trans("ClickToDialUrlDesc").'<br>';
  76. print $langs->trans("Example").':<br>http://myphoneserver/mypage?login=__LOGIN__&password=__PASS__&caller=__PHONEFROM__&called=__PHONETO__';
  77. //if (! empty($user->clicktodial_url))
  78. //{
  79. print '<br>';
  80. print info_admin($langs->trans("ValueOverwrittenByUserSetup"));
  81. //}
  82. print '</td></tr>';
  83. print '</table>';
  84. print '<div class="center"><br><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
  85. print '</form><br><br>';
  86. if (! empty($conf->global->CLICKTODIAL_URL))
  87. {
  88. $user->fetch_clicktodial();
  89. $phonefortest=$mysoc->phone;
  90. if (GETPOST('phonefortest')) $phonefortest=GETPOST('phonefortest');
  91. print '<form action="'.$_SERVER["PHP_SELF"].'">';
  92. print $langs->trans("LinkToTestClickToDial",$user->login).' : ';
  93. print '<input class="flat" type="text" name="phonefortest" value="'.dol_escape_htmltag($phonefortest).'">';
  94. print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("RefreshPhoneLink")).'">';
  95. print '</form>';
  96. $setupcomplete=1;
  97. if (preg_match('/__LOGIN__/',$conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_login)) $setupcomplete=0;
  98. if (preg_match('/__PASSWORD__/',$conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_password)) $setupcomplete=0;
  99. if (preg_match('/__PHONEFROM__/',$conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_poste)) $setupcomplete=0;
  100. if ($setupcomplete)
  101. {
  102. print $langs->trans("LinkToTest",$user->login).': '.dol_print_phone($phonefortest, '', 0, 0, 'AC_TEL');
  103. }
  104. else
  105. {
  106. $langs->load("errors");
  107. print '<div class="warning">'.$langs->trans("WarningClickToDialUserSetupNotComplete").'</div>';
  108. }
  109. }
  110. llxFooter();
  111. $db->close();