diff --git a/ChangeLog b/ChangeLog index db9fc3b9f8e..ab1fe32aa8f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -27,6 +27,7 @@ For users: - New: [ task #748 ] Add a link "Dolibarr" into left menu - New: Script email_unpaid_invoices_to_representative accepts now a parameter test and a delay. +- New: Can define a different clicktodial setup per user. - First change to prepare feature click to print for PDF. For translators: diff --git a/htdocs/admin/clicktodial.php b/htdocs/admin/clicktodial.php index 99241a8342f..0ddd7f1abdc 100644 --- a/htdocs/admin/clicktodial.php +++ b/htdocs/admin/clicktodial.php @@ -38,7 +38,7 @@ $action = GETPOST("action"); */ if ($action == 'setvalue' && $user->admin) { - $result=dolibarr_set_const($db, "CLICKTODIAL_URL",GETPOST("url"),'chaine',0,'',$conf->entity); + $result=dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("url"), 'chaine', 0, '', $conf->entity); if ($result >= 0) { $mesg = "".$langs->trans("SetupSaved").""; @@ -54,6 +54,8 @@ if ($action == 'setvalue' && $user->admin) * View */ +$user->fetch_clicktodial(); + $wikihelp='EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es'; llxHeader('',$langs->trans("ClickToDialSetup"),$wikihelp); @@ -76,11 +78,18 @@ print ''.$langs->trans("Value").''; print "\n"; $var=!$var; print ''; -print $langs->trans("URL").''; +print $langs->trans("DefaultLink").''; print '
'; print '
'; print $langs->trans("ClickToDialUrlDesc").'
'; print $langs->trans("Example").':
http://myphoneserver/mypage?login=__LOGIN__&password=__PASS__&caller=__PHONEFROM__&called=__PHONETO__'; + +if (! empty($user->clicktodial_url)) +{ + print '
'; + print info_admin($langs->trans("ValueOverwrittenByUserSetup")); +} + print ''; print ''; @@ -94,7 +103,14 @@ if (! empty($conf->global->CLICKTODIAL_URL)) { $user->fetch_clicktodial(); - print $langs->trans("LinkToTestClickToDial").' : '; + $phonefortest=$mysoc->phone; + if (GETPOST('phonefortest')) $phonefortest=GETPOST('phonefortest'); + + print '
'; + print $langs->trans("LinkToTestClickToDial",$user->login).' : '; + print ''; + print ''; + print '
'; $setupcomplete=1; if (preg_match('/__LOGIN__/',$conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_login)) $setupcomplete=0; @@ -103,7 +119,7 @@ if (! empty($conf->global->CLICKTODIAL_URL)) if ($setupcomplete) { - print dol_print_phone($mysoc->phone, '', 0, 0, 'AC_TEL'); + print $langs->trans("LinkToTest",$user->login).': '.dol_print_phone($phonefortest, '', 0, 0, 'AC_TEL'); } else { @@ -114,7 +130,8 @@ if (! empty($conf->global->CLICKTODIAL_URL)) dol_htmloutput_mesg($mesg); -$db->close(); llxFooter(); + +$db->close(); ?> \ No newline at end of file diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c1e4f2b61d1..656841297ad 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1199,8 +1199,11 @@ function dol_print_phone($phone,$country='',$cid=0,$socid=0,$addlink='',$separ=" { if (empty($user->clicktodial_loaded)) $user->fetch_clicktodial(); - if (empty($conf->global->CLICKTODIAL_URL)) $urlmask='ErrorClickToDialModuleNotConfigured'; - else $urlmask=$conf->global->CLICKTODIAL_URL; + // Define urlmask + $urlmask='ErrorClickToDialModuleNotConfigured'; + if (! empty($conf->global->CLICKTODIAL_URL)) $urlmask=$conf->global->CLICKTODIAL_URL; + if (! empty($user->clicktodial_url)) $urlmask=$user->clicktodial_url; + $clicktodial_poste=(! empty($user->clicktodial_poste)?urlencode($user->clicktodial_poste):''); $clicktodial_login=(! empty($user->clicktodial_login)?urlencode($user->clicktodial_login):''); $clicktodial_password=(! empty($user->clicktodial_password)?urlencode($user->clicktodial_password):''); @@ -1224,7 +1227,7 @@ function dol_print_phone($phone,$country='',$cid=0,$socid=0,$addlink='',$separ=" $type='AC_TEL'; $link=''; if ($addlink == 'AC_FAX') $type='AC_FAX'; if (! empty($conf->global->AGENDA_ADDACTIONFORPHONE)) $link=''.img_object($langs->trans("AddAction"),"calendar").''; - $newphone='
'.$newphone.'  '.$link.'
'; + if ($link) $newphone='
'.$newphone.'  '.$link.'
'; } } diff --git a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql index db609d76ad1..5c2a86122ea 100755 --- a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql +++ b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql @@ -208,3 +208,5 @@ ALTER TABLE llx_user ADD COLUMN town varchar(50); ALTER TABLE llx_user ADD COLUMN fk_state integer DEFAULT 0; ALTER TABLE llx_user ADD COLUMN fk_country integer DEFAULT 0; + +ALTER TABLE llx_user_clicktodial ADD COLUMN url varchar(255); diff --git a/htdocs/install/mysql/tables/llx_user_clicktodial.sql b/htdocs/install/mysql/tables/llx_user_clicktodial.sql index da97b33057b..bdaf90e8ae9 100644 --- a/htdocs/install/mysql/tables/llx_user_clicktodial.sql +++ b/htdocs/install/mysql/tables/llx_user_clicktodial.sql @@ -22,6 +22,7 @@ create table llx_user_clicktodial ( fk_user integer PRIMARY KEY, + url varchar(255), login varchar(32), pass varchar(64), poste varchar(20) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index fef12f037fa..ff28b59e083 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -361,7 +361,12 @@ LibraryToBuildPDF=Library used to build PDF WarningUsingFPDF=Warning: Your conf.php contains directive dolibarr_pdf_force_fpdf=1. This means you use the FPDF library to generate PDF files. This library is old and does not support a lot of features (Unicode, image transparency, cyrillic, arab and asiatic languages, ...), so you may experience errors during PDF generation.
To solve this and have a full support of PDF generation, please download TCPDF library, then comment or remove the line $dolibarr_pdf_force_fpdf=1, and add instead $dolibarr_lib_TCPDF_PATH='path_to_TCPDF_dir' LocalTaxDesc=Some countries apply 2 or 3 taxes on each invoice line. If this is the case, choose type for second and third tax and its rate. Possible type are:
1 : local tax apply on products and services without vat (vat is not applied on local tax)
2 : local tax apply on products and services before vat (vat is calculated on amount + localtax)
3 : local tax apply on products without vat (vat is not applied on local tax)
4 : local tax apply on products before vat (vat is calculated on amount + localtax)
5 : local tax apply on services without vat (vat is not applied on local tax)
6 : local tax apply on services before vat (vat is calculated on amount + localtax) SMS=SMS -LinkToTestClickToDial=Link to test the ClickToDial +LinkToTestClickToDial=Enter a phone number to call to show a link to test the ClickToDial url for user %s +RefreshPhoneLink=Refresh link +LinkToTest=Clickable link generated for user %s (click phone number to test) +KeepEmptyToUseDefault=Keep empty to use default value +DefaultLink=Default link +ValueOverwrittenByUserSetup=Warning, this value may be overwritten by user specific setup (each user can set his own clicktodial url) # Modules Module0Name=Users & groups diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 6ffd8fba44a..8b56650b43b 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -360,7 +360,12 @@ WarningUsingFPDF=Attention: Votre fichier conf.php contient la directive LocalTaxDesc=Certains pays appliquent 2 voir 3 taux sur chaque ligne de facture. Si c'est le cas, choisissez le type du deuxième et troisième taux et sa valeur. Les types possibles sont:
1 : taxe locale sur les produits et services hors tva (la tva n'est pas appliquée sur la taxe locale)
2 : taxe locale sur les produits et services avant tva (la tva est appliquée sur le montant + la taxe locale)
3 : taxe locale uniquement sur les produits hors tva (la tva n'est pas appliquée sur la taxe locale)
4 : taxe locale uniquement sur les produits avant tva (la tva est appliquée sur le montant + la taxe locale)
5 : taxe locale uniquement sur les services hors tva (la tva n'est pas appliquée sur la taxe locale)
6 : taxe locale uniquement sur les service avant tva (la tva est appliquée sur le montant + la taxe locale) SuhosinSessionEncrypt=Stockage des sessions encryptés par Suhosin SMS=SMS -LinkToTestClickToDial=Lien pour tester le ClickToDial +LinkToTestClickToDial=Entrez un numéro de téléphone à appeler pour tester le lien d'appel ClickToDial pour l'utilisateur %s +RefreshPhoneLink=Rafraichir lien +LinkToTest=Lien clicable généré pour l'utilisateur %s (cliquer le numéro pour tester) +KeepEmptyToUseDefault=Laisser ce champ vide pour utiliser la valeure par défaut +DefaultLink=Lien par défaut +ValueOverwrittenByUserSetup=Attention, cette valeur peut être écrasée par une valeur spécifique à la configuration de l'utilisateur (chaque utilisateur pouvant avoir sa propre url clicktodial) # Modules= undefined Module0Name= Utilisateurs & groupes diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index de4876bd275..a61289e7d09 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -81,6 +81,7 @@ class User extends CommonObject var $phenix_pass; var $phenix_pass_crypted; + var $clicktodial_url; var $clicktodial_login; var $clicktodial_password; var $clicktodial_poste; @@ -1549,7 +1550,7 @@ class User extends CommonObject */ function fetch_clicktodial() { - $sql = "SELECT login, pass, poste "; + $sql = "SELECT url, login, pass, poste "; $sql.= " FROM ".MAIN_DB_PREFIX."user_clicktodial as u"; $sql.= " WHERE u.fk_user = ".$this->id; @@ -1560,6 +1561,7 @@ class User extends CommonObject { $obj = $this->db->fetch_object($resql); + $this->clicktodial_url = $obj->url; $this->clicktodial_login = $obj->login; $this->clicktodial_password = $obj->pass; $this->clicktodial_poste = $obj->poste; @@ -1589,26 +1591,28 @@ class User extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_clicktodial"; $sql .= " WHERE fk_user = ".$this->id; + dol_syslog(get_class($this).'::update_clicktodial sql='.$sql); $result = $this->db->query($sql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_clicktodial"; - $sql .= " (fk_user,login,pass,poste)"; + $sql .= " (fk_user,url,login,pass,poste)"; $sql .= " VALUES (".$this->id; - $sql .= ", '". $this->clicktodial_login ."'"; - $sql .= ", '". $this->clicktodial_password ."'"; - $sql .= ", '". $this->clicktodial_poste."')"; + $sql .= ", '". $this->db->escape($this->clicktodial_url) ."'"; + $sql .= ", '". $this->db->escape($this->clicktodial_login) ."'"; + $sql .= ", '". $this->db->escape($this->clicktodial_password) ."'"; + $sql .= ", '". $this->db->escape($this->clicktodial_poste) ."')"; + dol_syslog(get_class($this).'::update_clicktodial sql='.$sql); $result = $this->db->query($sql); - if ($result) { $this->db->commit(); - return 0; + return 1; } else { $this->db->rollback(); - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -1; } } diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index bd39655b730..48f02ca5603 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -51,11 +51,13 @@ if ($action == 'update' && ! $_POST['cancel']) $edituser = new User($db); $edituser->fetch($id); - $edituser->clicktodial_login = $_POST["login"]; - $edituser->clicktodial_password = $_POST["password"]; - $edituser->clicktodial_poste = $_POST["poste"]; + $edituser->clicktodial_url = GETPOST("url"); + $edituser->clicktodial_login = GETPOST("login"); + $edituser->clicktodial_password = GETPOST("password"); + $edituser->clicktodial_poste = GETPOST("poste"); $result=$edituser->update_clicktodial(); + if ($result < 0) setEventMessage($edituser->error,'errors'); } @@ -110,7 +112,7 @@ if ($id > 0) print "\n"; print "
\n"; - + // Edit mode if ($action == 'edit') { print '
'; @@ -122,13 +124,17 @@ if ($id > 0) { print 'ClickToDial URL'; print ''; - if (empty($conf->global->CLICKTODIAL_URL)) + print ''; + if (empty($conf->global->CLICKTODIAL_URL) && empty($fuser->clicktodial_url)) { $langs->load("errors"); print ''.$langs->trans("ErrorModuleSetupNotComplete").''; } - else print $form->textwithpicto($conf->global->CLICKTODIAL_URL,$langs->trans("ClickToDialUrlDesc")); - print ''; + else + { + print '     '.$form->textwithpicto($langs->trans("KeepEmptyToUseDefault").': '.$conf->global->CLICKTODIAL_URL,$langs->trans("ClickToDialUrlDesc")); + } + print ''; print ''; } @@ -147,14 +153,16 @@ if ($id > 0) print ''; print "\n"; - print ''; - print '     '; - print ''; - print ''; + print ''; - print '
'; + print '
'; + print '     '; + print ''; + print '
'; + + print ''; } - else + else // View mode { print ''; @@ -163,12 +171,17 @@ if ($id > 0) { print "".''; print ''; print ''; }
ClickToDial URL'; - if (empty($conf->global->CLICKTODIAL_URL)) + $url=$conf->global->CLICKTODIAL_URL; + if (! empty($fuser->clicktodial_url)) $url=$fuser->clicktodial_url; + if (empty($url)) { $langs->load("errors"); print ''.$langs->trans("ErrorModuleSetupNotComplete").''; } - else print $form->textwithpicto($conf->global->CLICKTODIAL_URL,$langs->trans("ClickToDialUrlDesc")); + else + { + print $form->textwithpicto((empty($fuser->clicktodial_url)?$langs->trans("DefaultLink").': ':'').$url,$langs->trans("ClickToDialUrlDesc")); + } print '