2005-01-14 15:08:01 +01:00
|
|
|
<?php
|
2006-02-20 23:32:07 +01:00
|
|
|
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2021-06-30 18:22:40 +02:00
|
|
|
* Copyright (C) 2005-2021 Laurent Destailleur <eldy@users.sourceforge.org>
|
2013-08-14 11:11:49 +02:00
|
|
|
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
|
2025-02-19 19:51:46 +01:00
|
|
|
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
|
2005-01-14 15:08:01 +01:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2013-01-16 15:36:08 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2005-01-14 15:08:01 +01:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2019-09-23 21:55:30 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2005-01-14 15:08:01 +01:00
|
|
|
*/
|
2010-03-24 14:12:34 +01:00
|
|
|
|
|
|
|
|
/**
|
2010-03-01 10:20:41 +01:00
|
|
|
* \file htdocs/admin/clicktodial.php
|
|
|
|
|
* \ingroup clicktodial
|
2021-06-30 18:22:40 +02:00
|
|
|
* \brief Page to setup module ClickToDial
|
2010-03-01 10:20:41 +01:00
|
|
|
*/
|
2005-01-14 15:08:01 +01:00
|
|
|
|
2022-09-07 20:08:59 +02:00
|
|
|
// Load Dolibarr environment
|
2012-08-22 23:24:21 +02:00
|
|
|
require '../main.inc.php';
|
2012-08-22 23:11:24 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
2005-01-14 15:08:01 +01:00
|
|
|
|
2024-11-04 23:53:20 +01:00
|
|
|
/**
|
|
|
|
|
* @var Conf $conf
|
|
|
|
|
* @var DoliDB $db
|
|
|
|
|
* @var HookManager $hookmanager
|
|
|
|
|
* @var Societe $mysoc
|
|
|
|
|
* @var Translate $langs
|
|
|
|
|
* @var User $user
|
|
|
|
|
*/
|
|
|
|
|
|
2018-05-26 18:41:16 +02:00
|
|
|
// Load translation files required by the page
|
2005-01-14 15:08:01 +01:00
|
|
|
$langs->load("admin");
|
|
|
|
|
|
2021-02-26 22:04:03 +01:00
|
|
|
if (!$user->admin) {
|
|
|
|
|
accessforbidden();
|
|
|
|
|
}
|
2011-09-21 15:24:27 +02:00
|
|
|
|
2019-01-27 11:55:16 +01:00
|
|
|
$action = GETPOST('action', 'aZ09');
|
2005-01-14 15:08:01 +01:00
|
|
|
|
2022-09-09 13:58:54 +02:00
|
|
|
if (!isModEnabled('clicktodial')) {
|
|
|
|
|
accessforbidden($langs->transnoentitiesnoconv("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module58Name")));
|
2020-07-23 23:57:12 +02:00
|
|
|
}
|
|
|
|
|
|
2005-01-14 15:08:01 +01:00
|
|
|
|
2011-09-06 12:52:42 +02:00
|
|
|
/*
|
|
|
|
|
* Actions
|
|
|
|
|
*/
|
2019-08-01 12:42:12 +02:00
|
|
|
|
2025-02-19 19:51:46 +01:00
|
|
|
if ($action == 'setvalue'/* && $user->admin */) {
|
2020-10-31 14:32:18 +01:00
|
|
|
$result1 = dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity);
|
|
|
|
|
$result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity);
|
2022-07-16 02:03:38 +02:00
|
|
|
$result3 = dolibarr_set_const($db, "CLICKTODIAL_KEY_FOR_CIDLOOKUP", GETPOST("CLICKTODIAL_KEY_FOR_CIDLOOKUP"), 'chaine', 0, '', $conf->entity);
|
2019-08-01 12:42:12 +02:00
|
|
|
|
2022-07-16 02:03:38 +02:00
|
|
|
if ($result1 >= 0 && $result2 >= 0 && $result3 >= 0) {
|
2015-10-23 12:58:30 +02:00
|
|
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
2020-10-31 14:32:18 +01:00
|
|
|
} else {
|
|
|
|
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
|
|
|
|
}
|
2005-01-14 15:08:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2011-09-06 12:52:42 +02:00
|
|
|
* View
|
2005-01-14 15:08:01 +01:00
|
|
|
*/
|
|
|
|
|
|
2020-07-27 02:25:09 +02:00
|
|
|
$form = new Form($db);
|
|
|
|
|
|
2013-03-31 16:44:24 +02:00
|
|
|
$user->fetch_clicktodial();
|
|
|
|
|
|
2020-04-10 10:59:32 +02:00
|
|
|
$wikihelp = 'EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es';
|
2024-06-08 14:53:14 +02:00
|
|
|
llxHeader('', $langs->trans("ClickToDialSetup"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-clicktodial');
|
2006-02-20 23:32:07 +01:00
|
|
|
|
2020-04-10 10:59:32 +02:00
|
|
|
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
2019-01-27 11:55:16 +01:00
|
|
|
print load_fiche_titre($langs->trans("ClickToDialSetup"), $linkback, 'title_setup');
|
2005-01-14 15:08:01 +01:00
|
|
|
|
2020-02-27 01:12:53 +01:00
|
|
|
print '<span class="opacitymedium">'.$langs->trans("ClickToDialDesc")."</span><br>\n";
|
2008-05-19 03:43:52 +02:00
|
|
|
|
2005-01-14 22:09:22 +01:00
|
|
|
print '<br>';
|
2005-01-14 15:08:01 +01:00
|
|
|
print '<form method="post" action="clicktodial.php">';
|
2019-12-18 23:12:31 +01:00
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
2005-01-14 15:08:01 +01:00
|
|
|
print '<input type="hidden" name="action" value="setvalue">';
|
2006-02-20 23:32:07 +01:00
|
|
|
|
2020-07-27 02:27:27 +02:00
|
|
|
print '<div class="div-table-responsive-no-min">';
|
2019-11-05 21:24:41 +01:00
|
|
|
print '<table class="noborder centpercent">';
|
2005-01-14 22:09:22 +01:00
|
|
|
print '<tr class="liste_titre">';
|
2025-01-24 13:12:48 +01:00
|
|
|
print '<td class="minwidth200">'.$langs->trans("Parameter").'</td>';
|
|
|
|
|
print '<td></td>';
|
2005-01-14 15:08:01 +01:00
|
|
|
print "</tr>\n";
|
2015-10-26 16:20:09 +01:00
|
|
|
|
2017-04-14 11:22:48 +02:00
|
|
|
|
2017-04-14 13:02:29 +02:00
|
|
|
print '<tr class="oddeven"><td>';
|
2015-10-26 16:20:09 +01:00
|
|
|
print $langs->trans("ClickToDialUseTelLink").'</td><td>';
|
2024-05-06 14:18:21 +02:00
|
|
|
print $form->selectyesno("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", getDolGlobalString('CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS'), 1).'<br>';
|
2015-10-26 16:20:09 +01:00
|
|
|
print '<br>';
|
2022-07-16 02:03:38 +02:00
|
|
|
print '<span class="opacitymedium small">'.$langs->trans("ClickToDialUseTelLinkDesc").'</span>';
|
2015-10-26 16:20:09 +01:00
|
|
|
print '</td></tr>';
|
|
|
|
|
|
2017-04-14 11:22:48 +02:00
|
|
|
|
2017-04-14 13:02:29 +02:00
|
|
|
print '<tr class="oddeven"><td>';
|
2013-03-31 16:44:24 +02:00
|
|
|
print $langs->trans("DefaultLink").'</td><td>';
|
2022-07-16 02:10:21 +02:00
|
|
|
print '<input class="quatrevingtpercent" type="text" id="CLICKTODIAL_URL" name="CLICKTODIAL_URL"'.(getDolGlobalString('CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS') ? ' disabled="disabled"' : '').' value="'.getDolGlobalString('CLICKTODIAL_URL').'"><br>';
|
2017-05-01 13:01:05 +02:00
|
|
|
print ajax_autoselect('CLICKTODIAL_URL');
|
2011-03-05 19:29:02 +01:00
|
|
|
print '<br>';
|
2008-11-01 01:16:34 +01:00
|
|
|
print $langs->trans("ClickToDialUrlDesc").'<br>';
|
2021-06-30 18:22:40 +02:00
|
|
|
print '<br>';
|
|
|
|
|
print '<span class="opacitymedium">';
|
2021-08-04 20:18:14 +02:00
|
|
|
print $langs->trans("Examples").':<br>';
|
2022-07-16 02:03:38 +02:00
|
|
|
print '* https://myphoneserver/phoneurl?login=__LOGIN__&password=__PASS__&caller=__PHONEFROM__&called=__PHONETO__<br>';
|
|
|
|
|
print '* sip:__PHONETO__@my.sip.server';
|
2021-06-30 18:22:40 +02:00
|
|
|
print '</span>';
|
2013-03-31 16:44:24 +02:00
|
|
|
|
2022-08-31 22:14:20 +02:00
|
|
|
//if (!empty($user->clicktodial_url))
|
2013-06-05 16:24:32 +02:00
|
|
|
//{
|
|
|
|
|
print '<br>';
|
|
|
|
|
print info_admin($langs->trans("ValueOverwrittenByUserSetup"));
|
|
|
|
|
//}
|
2013-03-31 16:44:24 +02:00
|
|
|
|
2005-01-14 15:08:01 +01:00
|
|
|
print '</td></tr>';
|
|
|
|
|
|
2022-07-16 02:03:38 +02:00
|
|
|
print '<tr class="oddeven">';
|
|
|
|
|
print '<td>'.$langs->trans("SecurityKey").'</td>';
|
|
|
|
|
print '<td>';
|
|
|
|
|
|
|
|
|
|
global $dolibarr_main_url_root;
|
|
|
|
|
|
|
|
|
|
// Define $urlwithroot
|
|
|
|
|
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
|
|
|
|
|
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
|
|
|
|
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
|
|
|
|
|
|
|
|
|
// Url for CIDLookup
|
|
|
|
|
//print '<div class="div-table-responsive-no-min">';
|
|
|
|
|
$url = $urlwithroot.'/public/clicktodial/cidlookup.php?securitykey='.getDolGlobalString('CLICKTODIAL_KEY_FOR_CIDLOOKUP', 'ValueToDefine').'&phone=...';
|
|
|
|
|
//print img_picto('', 'globe').' <a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$url."</a><br>\n";
|
|
|
|
|
//print '</div>';
|
|
|
|
|
//print '<br>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print '<span class="opacitymedium">'.$langs->trans("CIDLookupURL").'</span>';
|
|
|
|
|
print '<br>'.$url;
|
|
|
|
|
print '<br>';
|
|
|
|
|
print '<br>';
|
2023-10-24 17:00:13 +02:00
|
|
|
print '<input type="text" class="flat minwidth300" id="CLICKTODIAL_KEY_FOR_CIDLOOKUP" name="CLICKTODIAL_KEY_FOR_CIDLOOKUP" value="'.(GETPOST('CLICKTODIAL_KEY_FOR_CIDLOOKUP') ? GETPOST('CLICKTODIAL_KEY_FOR_CIDLOOKUP') : (getDolGlobalString('CLICKTODIAL_KEY_FOR_CIDLOOKUP') ? $conf->global->CLICKTODIAL_KEY_FOR_CIDLOOKUP : '')).'">';
|
2022-07-16 02:03:38 +02:00
|
|
|
if (!empty($conf->use_javascript_ajax)) {
|
|
|
|
|
print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
|
|
|
|
|
}
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
2013-03-31 04:03:08 +02:00
|
|
|
print '</table>';
|
2020-07-27 02:27:27 +02:00
|
|
|
print '</div>';
|
2005-01-14 15:08:01 +01:00
|
|
|
|
2021-08-24 16:10:20 +02:00
|
|
|
print $form->buttonsSaveCancel("Modify", '');
|
2013-03-31 04:03:08 +02:00
|
|
|
|
2013-03-31 16:51:49 +02:00
|
|
|
print '</form><br><br>';
|
2013-03-31 04:03:08 +02:00
|
|
|
|
|
|
|
|
|
2023-10-24 17:00:13 +02:00
|
|
|
if (getDolGlobalString('CLICKTODIAL_URL')) {
|
2013-03-31 04:03:08 +02:00
|
|
|
$user->fetch_clicktodial();
|
|
|
|
|
|
2020-04-10 10:59:32 +02:00
|
|
|
$phonefortest = $mysoc->phone;
|
2021-02-26 22:04:03 +01:00
|
|
|
if (GETPOST('phonefortest')) {
|
|
|
|
|
$phonefortest = GETPOST('phonefortest');
|
|
|
|
|
}
|
2013-03-31 16:44:24 +02:00
|
|
|
|
|
|
|
|
print '<form action="'.$_SERVER["PHP_SELF"].'">';
|
2020-10-31 14:32:18 +01:00
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
2019-01-27 11:55:16 +01:00
|
|
|
print $langs->trans("LinkToTestClickToDial", $user->login).' : ';
|
2013-03-31 16:44:24 +02:00
|
|
|
print '<input class="flat" type="text" name="phonefortest" value="'.dol_escape_htmltag($phonefortest).'">';
|
2021-08-04 00:09:33 +02:00
|
|
|
print '<input type="submit" class="button small" value="'.dol_escape_htmltag($langs->trans("RefreshPhoneLink")).'">';
|
2013-03-31 16:44:24 +02:00
|
|
|
print '</form>';
|
2013-03-31 04:03:08 +02:00
|
|
|
|
2020-04-10 10:59:32 +02:00
|
|
|
$setupcomplete = 1;
|
2021-02-26 22:04:03 +01:00
|
|
|
if (preg_match('/__LOGIN__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_login)) {
|
|
|
|
|
$setupcomplete = 0;
|
|
|
|
|
}
|
|
|
|
|
if (preg_match('/__PASSWORD__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_password)) {
|
|
|
|
|
$setupcomplete = 0;
|
|
|
|
|
}
|
|
|
|
|
if (preg_match('/__PHONEFROM__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_poste)) {
|
|
|
|
|
$setupcomplete = 0;
|
|
|
|
|
}
|
2013-03-31 04:03:08 +02:00
|
|
|
|
2021-02-26 22:04:03 +01:00
|
|
|
if ($setupcomplete) {
|
2021-08-04 00:12:49 +02:00
|
|
|
print $langs->trans("LinkToTest", $user->login).': '.dol_print_phone($phonefortest, '', 0, 0, 'AC_TEL', '', 'mobile');
|
2020-05-21 09:35:30 +02:00
|
|
|
} else {
|
2013-03-31 04:03:08 +02:00
|
|
|
$langs->load("errors");
|
|
|
|
|
print '<div class="warning">'.$langs->trans("WarningClickToDialUserSetupNotComplete").'</div>';
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-28 23:12:30 +02:00
|
|
|
|
2022-07-27 13:42:32 +02:00
|
|
|
// Add button to autosuggest a key
|
|
|
|
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
|
|
|
|
print dolJSToSetRandomPassword('CLICKTODIAL_KEY_FOR_CIDLOOKUP');
|
|
|
|
|
|
2022-07-16 02:03:38 +02:00
|
|
|
|
2018-07-28 17:26:56 +02:00
|
|
|
// End of page
|
2011-08-27 16:24:16 +02:00
|
|
|
llxFooter();
|
2013-03-31 16:44:24 +02:00
|
|
|
$db->close();
|