New: Can defined a clicktodial setup per user

This commit is contained in:
Laurent Destailleur
2013-03-31 16:44:24 +02:00
parent a0dc4ae62e
commit cc69cf7b76
9 changed files with 84 additions and 33 deletions

View File

@@ -27,6 +27,7 @@ For users:
- New: [ task #748 ] Add a link "Dolibarr" into left menu - New: [ task #748 ] Add a link "Dolibarr" into left menu
- New: Script email_unpaid_invoices_to_representative accepts now a parameter test - New: Script email_unpaid_invoices_to_representative accepts now a parameter test
and a delay. and a delay.
- New: Can define a different clicktodial setup per user.
- First change to prepare feature click to print for PDF. - First change to prepare feature click to print for PDF.
For translators: For translators:

View File

@@ -54,6 +54,8 @@ if ($action == 'setvalue' && $user->admin)
* View * View
*/ */
$user->fetch_clicktodial();
$wikihelp='EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es'; $wikihelp='EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es';
llxHeader('',$langs->trans("ClickToDialSetup"),$wikihelp); llxHeader('',$langs->trans("ClickToDialSetup"),$wikihelp);
@@ -76,11 +78,18 @@ print '<td>'.$langs->trans("Value").'</td>';
print "</tr>\n"; print "</tr>\n";
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td valign="top">'; print '<tr '.$bc[$var].'><td valign="top">';
print $langs->trans("URL").'</td><td>'; print $langs->trans("DefaultLink").'</td><td>';
print '<input size="92" type="text" name="url" value="'.$conf->global->CLICKTODIAL_URL.'"><br>'; print '<input size="92" type="text" name="url" value="'.$conf->global->CLICKTODIAL_URL.'"><br>';
print '<br>'; print '<br>';
print $langs->trans("ClickToDialUrlDesc").'<br>'; print $langs->trans("ClickToDialUrlDesc").'<br>';
print $langs->trans("Example").':<br>http://myphoneserver/mypage?login=__LOGIN__&password=__PASS__&caller=__PHONEFROM__&called=__PHONETO__'; print $langs->trans("Example").':<br>http://myphoneserver/mypage?login=__LOGIN__&password=__PASS__&caller=__PHONEFROM__&called=__PHONETO__';
if (! empty($user->clicktodial_url))
{
print '<br>';
print info_admin($langs->trans("ValueOverwrittenByUserSetup"));
}
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
@@ -94,7 +103,14 @@ if (! empty($conf->global->CLICKTODIAL_URL))
{ {
$user->fetch_clicktodial(); $user->fetch_clicktodial();
print $langs->trans("LinkToTestClickToDial").' : '; $phonefortest=$mysoc->phone;
if (GETPOST('phonefortest')) $phonefortest=GETPOST('phonefortest');
print '<form action="'.$_SERVER["PHP_SELF"].'">';
print $langs->trans("LinkToTestClickToDial",$user->login).' : ';
print '<input class="flat" type="text" name="phonefortest" value="'.dol_escape_htmltag($phonefortest).'">';
print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("RefreshPhoneLink")).'">';
print '</form>';
$setupcomplete=1; $setupcomplete=1;
if (preg_match('/__LOGIN__/',$conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_login)) $setupcomplete=0; 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) 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 else
{ {
@@ -114,7 +130,8 @@ if (! empty($conf->global->CLICKTODIAL_URL))
dol_htmloutput_mesg($mesg); dol_htmloutput_mesg($mesg);
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@@ -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($user->clicktodial_loaded)) $user->fetch_clicktodial();
if (empty($conf->global->CLICKTODIAL_URL)) $urlmask='ErrorClickToDialModuleNotConfigured'; // Define urlmask
else $urlmask=$conf->global->CLICKTODIAL_URL; $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_poste=(! empty($user->clicktodial_poste)?urlencode($user->clicktodial_poste):'');
$clicktodial_login=(! empty($user->clicktodial_login)?urlencode($user->clicktodial_login):''); $clicktodial_login=(! empty($user->clicktodial_login)?urlencode($user->clicktodial_login):'');
$clicktodial_password=(! empty($user->clicktodial_password)?urlencode($user->clicktodial_password):''); $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=''; $type='AC_TEL'; $link='';
if ($addlink == 'AC_FAX') $type='AC_FAX'; if ($addlink == 'AC_FAX') $type='AC_FAX';
if (! empty($conf->global->AGENDA_ADDACTIONFORPHONE)) $link='<a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&amp;backtopage=1&amp;actioncode='.$type.($cid?'&amp;contactid='.$cid:'').($socid?'&amp;socid='.$socid:'').'">'.img_object($langs->trans("AddAction"),"calendar").'</a>'; if (! empty($conf->global->AGENDA_ADDACTIONFORPHONE)) $link='<a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&amp;backtopage=1&amp;actioncode='.$type.($cid?'&amp;contactid='.$cid:'').($socid?'&amp;socid='.$socid:'').'">'.img_object($langs->trans("AddAction"),"calendar").'</a>';
$newphone='<table class="nobordernopadding"><tr><td>'.$newphone.' </td><td>&nbsp;'.$link.'</td></tr></table>'; if ($link) $newphone='<table class="nobordernopadding"><tr><td>'.$newphone.' </td><td>&nbsp;'.$link.'</td></tr></table>';
} }
} }

View File

@@ -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_state integer DEFAULT 0;
ALTER TABLE llx_user ADD COLUMN fk_country integer DEFAULT 0; ALTER TABLE llx_user ADD COLUMN fk_country integer DEFAULT 0;
ALTER TABLE llx_user_clicktodial ADD COLUMN url varchar(255);

View File

@@ -22,6 +22,7 @@
create table llx_user_clicktodial create table llx_user_clicktodial
( (
fk_user integer PRIMARY KEY, fk_user integer PRIMARY KEY,
url varchar(255),
login varchar(32), login varchar(32),
pass varchar(64), pass varchar(64),
poste varchar(20) poste varchar(20)

View File

@@ -361,7 +361,12 @@ LibraryToBuildPDF=Library used to build PDF
WarningUsingFPDF=Warning: Your <b>conf.php</b> contains directive <b>dolibarr_pdf_force_fpdf=1</b>. 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.<br>To solve this and have a full support of PDF generation, please download <a href="http://www.tcpdf.org/" target="_blank">TCPDF library</a>, then comment or remove the line <b>$dolibarr_pdf_force_fpdf=1</b>, and add instead <b>$dolibarr_lib_TCPDF_PATH='path_to_TCPDF_dir'</b> WarningUsingFPDF=Warning: Your <b>conf.php</b> contains directive <b>dolibarr_pdf_force_fpdf=1</b>. 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.<br>To solve this and have a full support of PDF generation, please download <a href="http://www.tcpdf.org/" target="_blank">TCPDF library</a>, then comment or remove the line <b>$dolibarr_pdf_force_fpdf=1</b>, and add instead <b>$dolibarr_lib_TCPDF_PATH='path_to_TCPDF_dir'</b>
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:<br>1 : local tax apply on products and services without vat (vat is not applied on local tax)<br>2 : local tax apply on products and services before vat (vat is calculated on amount + localtax)<br>3 : local tax apply on products without vat (vat is not applied on local tax)<br>4 : local tax apply on products before vat (vat is calculated on amount + localtax)<br>5 : local tax apply on services without vat (vat is not applied on local tax)<br>6 : local tax apply on services before vat (vat is calculated on amount + localtax) 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:<br>1 : local tax apply on products and services without vat (vat is not applied on local tax)<br>2 : local tax apply on products and services before vat (vat is calculated on amount + localtax)<br>3 : local tax apply on products without vat (vat is not applied on local tax)<br>4 : local tax apply on products before vat (vat is calculated on amount + localtax)<br>5 : local tax apply on services without vat (vat is not applied on local tax)<br>6 : local tax apply on services before vat (vat is calculated on amount + localtax)
SMS=SMS 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 <strong>%s</strong>
RefreshPhoneLink=Refresh link
LinkToTest=Clickable link generated for user <strong>%s</strong> (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 # Modules
Module0Name=Users & groups Module0Name=Users & groups

View File

@@ -360,7 +360,12 @@ WarningUsingFPDF=Attention: Votre fichier <b>conf.php</b> 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:<br>1 : taxe locale sur les produits et services hors tva (la tva n'est pas appliquée sur la taxe locale)<br>2 : taxe locale sur les produits et services avant tva (la tva est appliquée sur le montant + la taxe locale)<br>3 : taxe locale uniquement sur les produits hors tva (la tva n'est pas appliquée sur la taxe locale)<br>4 : taxe locale uniquement sur les produits avant tva (la tva est appliquée sur le montant + la taxe locale)<br>5 : taxe locale uniquement sur les services hors tva (la tva n'est pas appliquée sur la taxe locale)<br>6 : taxe locale uniquement sur les service avant tva (la tva est appliquée sur le montant + la taxe locale) 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:<br>1 : taxe locale sur les produits et services hors tva (la tva n'est pas appliquée sur la taxe locale)<br>2 : taxe locale sur les produits et services avant tva (la tva est appliquée sur le montant + la taxe locale)<br>3 : taxe locale uniquement sur les produits hors tva (la tva n'est pas appliquée sur la taxe locale)<br>4 : taxe locale uniquement sur les produits avant tva (la tva est appliquée sur le montant + la taxe locale)<br>5 : taxe locale uniquement sur les services hors tva (la tva n'est pas appliquée sur la taxe locale)<br>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 SuhosinSessionEncrypt=Stockage des sessions encryptés par Suhosin
SMS=SMS 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 <strong>%s</strong>
RefreshPhoneLink=Rafraichir lien
LinkToTest=Lien clicable généré pour l'utilisateur <strong>%s</strong> (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 # Modules= undefined
Module0Name= Utilisateurs & groupes Module0Name= Utilisateurs & groupes

View File

@@ -81,6 +81,7 @@ class User extends CommonObject
var $phenix_pass; var $phenix_pass;
var $phenix_pass_crypted; var $phenix_pass_crypted;
var $clicktodial_url;
var $clicktodial_login; var $clicktodial_login;
var $clicktodial_password; var $clicktodial_password;
var $clicktodial_poste; var $clicktodial_poste;
@@ -1549,7 +1550,7 @@ class User extends CommonObject
*/ */
function fetch_clicktodial() function fetch_clicktodial()
{ {
$sql = "SELECT login, pass, poste "; $sql = "SELECT url, login, pass, poste ";
$sql.= " FROM ".MAIN_DB_PREFIX."user_clicktodial as u"; $sql.= " FROM ".MAIN_DB_PREFIX."user_clicktodial as u";
$sql.= " WHERE u.fk_user = ".$this->id; $sql.= " WHERE u.fk_user = ".$this->id;
@@ -1560,6 +1561,7 @@ class User extends CommonObject
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->clicktodial_url = $obj->url;
$this->clicktodial_login = $obj->login; $this->clicktodial_login = $obj->login;
$this->clicktodial_password = $obj->pass; $this->clicktodial_password = $obj->pass;
$this->clicktodial_poste = $obj->poste; $this->clicktodial_poste = $obj->poste;
@@ -1589,26 +1591,28 @@ class User extends CommonObject
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_clicktodial"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_clicktodial";
$sql .= " WHERE fk_user = ".$this->id; $sql .= " WHERE fk_user = ".$this->id;
dol_syslog(get_class($this).'::update_clicktodial sql='.$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."user_clicktodial"; $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 .= " VALUES (".$this->id;
$sql .= ", '". $this->clicktodial_login ."'"; $sql .= ", '". $this->db->escape($this->clicktodial_url) ."'";
$sql .= ", '". $this->clicktodial_password ."'"; $sql .= ", '". $this->db->escape($this->clicktodial_login) ."'";
$sql .= ", '". $this->clicktodial_poste."')"; $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); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$this->db->commit(); $this->db->commit();
return 0; return 1;
} }
else else
{ {
$this->db->rollback(); $this->db->rollback();
$this->error=$this->db->error(); $this->error=$this->db->lasterror();
return -1; return -1;
} }
} }

View File

@@ -51,11 +51,13 @@ if ($action == 'update' && ! $_POST['cancel'])
$edituser = new User($db); $edituser = new User($db);
$edituser->fetch($id); $edituser->fetch($id);
$edituser->clicktodial_login = $_POST["login"]; $edituser->clicktodial_url = GETPOST("url");
$edituser->clicktodial_password = $_POST["password"]; $edituser->clicktodial_login = GETPOST("login");
$edituser->clicktodial_poste = $_POST["poste"]; $edituser->clicktodial_password = GETPOST("password");
$edituser->clicktodial_poste = GETPOST("poste");
$result=$edituser->update_clicktodial(); $result=$edituser->update_clicktodial();
if ($result < 0) setEventMessage($edituser->error,'errors');
} }
@@ -110,7 +112,7 @@ if ($id > 0)
print "</table>\n"; print "</table>\n";
print "<br>\n"; print "<br>\n";
// Edit mode
if ($action == 'edit') if ($action == 'edit')
{ {
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$fuser->id.'" method="post">'; print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$fuser->id.'" method="post">';
@@ -122,12 +124,16 @@ if ($id > 0)
{ {
print '<tr><td width="25%" valign="top">ClickToDial URL</td>'; print '<tr><td width="25%" valign="top">ClickToDial URL</td>';
print '<td class="valeur">'; print '<td class="valeur">';
if (empty($conf->global->CLICKTODIAL_URL)) print '<input name="url" value="'.(! empty($fuser->clicktodial_url)?$fuser->clicktodial_url:'').'" size="92">';
if (empty($conf->global->CLICKTODIAL_URL) && empty($fuser->clicktodial_url))
{ {
$langs->load("errors"); $langs->load("errors");
print '<font class="error">'.$langs->trans("ErrorModuleSetupNotComplete").'</font>'; print '<font class="error">'.$langs->trans("ErrorModuleSetupNotComplete").'</font>';
} }
else print $form->textwithpicto($conf->global->CLICKTODIAL_URL,$langs->trans("ClickToDialUrlDesc")); else
{
print ' &nbsp; &nbsp; '.$form->textwithpicto($langs->trans("KeepEmptyToUseDefault").': '.$conf->global->CLICKTODIAL_URL,$langs->trans("ClickToDialUrlDesc"));
}
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
@@ -147,14 +153,16 @@ if ($id > 0)
print '<input name="poste" value="'.(! empty($fuser->clicktodial_poste)?$fuser->clicktodial_poste:'').'"></td>'; print '<input name="poste" value="'.(! empty($fuser->clicktodial_poste)?$fuser->clicktodial_poste:'').'"></td>';
print "</tr>\n"; print "</tr>\n";
print '<tr><td colspan="2" align="center"><input class="button" type="submit" value="'.$langs->trans("Save").'">'; print '</table>';
print '<br><center><input class="button" type="submit" value="'.$langs->trans("Save").'">';
print ' &nbsp; &nbsp; '; print ' &nbsp; &nbsp; ';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</td></tr>'; print '</center>';
print '</table></form>'; print '</form>';
} }
else else // View mode
{ {
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
@@ -163,12 +171,17 @@ if ($id > 0)
{ {
print "<tr>".'<td width="25%" valign="top">ClickToDial URL</td>'; print "<tr>".'<td width="25%" valign="top">ClickToDial URL</td>';
print '<td class="valeur">'; print '<td class="valeur">';
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"); $langs->load("errors");
print '<font class="error">'.$langs->trans("ErrorModuleSetupNotComplete").'</font>'; print '<font class="error">'.$langs->trans("ErrorModuleSetupNotComplete").'</font>';
} }
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 '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }