clicktodial.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. *
  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. /**
  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. // Load translation files required by the page
  27. $langs->load("admin");
  28. if (!$user->admin) {
  29. accessforbidden();
  30. }
  31. $action = GETPOST('action', 'aZ09');
  32. if (!in_array('clicktodial', $conf->modules)) {
  33. accessforbidden($langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module58Name")));
  34. }
  35. /*
  36. * Actions
  37. */
  38. if ($action == 'setvalue' && $user->admin) {
  39. $result1 = dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity);
  40. $result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity);
  41. if ($result1 >= 0 && $result2 >= 0) {
  42. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  43. } else {
  44. setEventMessages($langs->trans("Error"), null, 'errors');
  45. }
  46. }
  47. /*
  48. * View
  49. */
  50. $form = new Form($db);
  51. $user->fetch_clicktodial();
  52. $wikihelp = 'EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es';
  53. llxHeader('', $langs->trans("ClickToDialSetup"), $wikihelp);
  54. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  55. print load_fiche_titre($langs->trans("ClickToDialSetup"), $linkback, 'title_setup');
  56. print '<span class="opacitymedium">'.$langs->trans("ClickToDialDesc")."</span><br>\n";
  57. print '<br>';
  58. print '<form method="post" action="clicktodial.php">';
  59. print '<input type="hidden" name="token" value="'.newToken().'">';
  60. print '<input type="hidden" name="action" value="setvalue">';
  61. print '<div class="div-table-responsive-no-min">';
  62. print '<table class="noborder centpercent">';
  63. print '<tr class="liste_titre">';
  64. print '<td>'.$langs->trans("Name").'</td>';
  65. print '<td>'.$langs->trans("Value").'</td>';
  66. print "</tr>\n";
  67. print '<tr class="oddeven"><td>';
  68. print $langs->trans("ClickToDialUseTelLink").'</td><td>';
  69. print $form->selectyesno("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", $conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS, 1).'<br>';
  70. print '<br>';
  71. print $langs->trans("ClickToDialUseTelLinkDesc");
  72. print '</td></tr>';
  73. print '<tr class="oddeven"><td>';
  74. print $langs->trans("DefaultLink").'</td><td>';
  75. 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>';
  76. print ajax_autoselect('CLICKTODIAL_URL');
  77. print '<br>';
  78. print $langs->trans("ClickToDialUrlDesc").'<br>';
  79. print '<br>';
  80. print '<span class="opacitymedium">';
  81. print $langs->trans("Example").':<br>';
  82. print 'http://myphoneserver/mypage?login=__LOGIN__&password=__PASS__&caller=__PHONEFROM__&called=__PHONETO__<br>';
  83. print 'sip:__PHONETO__@my.sip.server';
  84. print '</span>';
  85. //if (! empty($user->clicktodial_url))
  86. //{
  87. print '<br>';
  88. print info_admin($langs->trans("ValueOverwrittenByUserSetup"));
  89. //}
  90. print '</td></tr>';
  91. print '</table>';
  92. print '</div>';
  93. print '<div class="center"><br><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
  94. print '</form><br><br>';
  95. if (!empty($conf->global->CLICKTODIAL_URL)) {
  96. $user->fetch_clicktodial();
  97. $phonefortest = $mysoc->phone;
  98. if (GETPOST('phonefortest')) {
  99. $phonefortest = GETPOST('phonefortest');
  100. }
  101. print '<form action="'.$_SERVER["PHP_SELF"].'">';
  102. print '<input type="hidden" name="token" value="'.newToken().'">';
  103. print $langs->trans("LinkToTestClickToDial", $user->login).' : ';
  104. print '<input class="flat" type="text" name="phonefortest" value="'.dol_escape_htmltag($phonefortest).'">';
  105. print '<input type="submit" class="button small" value="'.dol_escape_htmltag($langs->trans("RefreshPhoneLink")).'">';
  106. print '</form>';
  107. $setupcomplete = 1;
  108. if (preg_match('/__LOGIN__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_login)) {
  109. $setupcomplete = 0;
  110. }
  111. if (preg_match('/__PASSWORD__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_password)) {
  112. $setupcomplete = 0;
  113. }
  114. if (preg_match('/__PHONEFROM__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_poste)) {
  115. $setupcomplete = 0;
  116. }
  117. if ($setupcomplete) {
  118. print $langs->trans("LinkToTest", $user->login).': '.dol_print_phone($phonefortest, '', 0, 0, 'AC_TEL', '', 1);
  119. } else {
  120. $langs->load("errors");
  121. print '<div class="warning">'.$langs->trans("WarningClickToDialUserSetupNotComplete").'</div>';
  122. }
  123. }
  124. // End of page
  125. llxFooter();
  126. $db->close();