From a100faa4b13a168a4c5375040236714e220e2a65 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Sun, 15 Sep 2013 18:33:20 +0200 Subject: [PATCH 1/5] ability to copy contact address to clipboard --- htdocs/core/lib/company.lib.php | 59 ++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 2bd863b263f..6b39670fb77 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -4,6 +4,7 @@ * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013 Christophe Battarel * * 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 @@ -555,6 +556,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') $sql = "SELECT p.rowid, p.lastname, p.firstname, p.fk_pays, p.poste, p.phone, p.phone_mobile, p.fax, p.email, p.statut "; + $sql .= ", p.address, p.zip, p.town"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; $sql .= " WHERE p.fk_soc = ".$object->id; $sql .= " ORDER by p.datec"; @@ -582,17 +584,17 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') print ''.$obj->poste.''; - $country_code = getCountry($obj->fk_pays, 2); + $country_code = getCountry($obj->fk_pays, 'all'); // Lien click to dial print ''; - print dol_print_phone($obj->phone,$country_code,$obj->rowid,$object->id,'AC_TEL'); + print dol_print_phone($obj->phone,$country_code['code'],$obj->rowid,$object->id,'AC_TEL'); print ''; print ''; - print dol_print_phone($obj->phone_mobile,$country_code,$obj->rowid,$object->id,'AC_TEL'); + print dol_print_phone($obj->phone_mobile,$country_code['code'],$obj->rowid,$object->id,'AC_TEL'); print ''; print ''; - print dol_print_phone($obj->fax,$country_code,$obj->rowid,$object->id,'AC_FAX'); + print dol_print_phone($obj->fax,$country_code['code'],$obj->rowid,$object->id,'AC_FAX'); print ''; print ''; print dol_print_email($obj->email,$obj->rowid,$object->id,'AC_EMAIL'); @@ -600,6 +602,42 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') if ($obj->statut==0) print ''.$langs->trans('Disabled').' '.img_picto($langs->trans('StatusContactDraftShort'),'statut0').''; elseif ($obj->statut==1) print ''.$langs->trans('Enabled').' '.img_picto($langs->trans('StatusContactValidatedShort'),'statut1').''; + + // copy in clipboard + $coords = ''; + if (!empty($object->name)) + $coords .= addslashes($object->name)."
"; + if (!empty($obj->civilite)) + $coords .= addslashes($obj->civilite).' '; + if (!empty($obj->firstname)) + $coords .= addslashes($obj->firstname).' '; + if (!empty($obj->name)) + $coords .= addslashes($obj->name); + $coords .= "
"; + if (!empty($obj->address)) + { + $coords .= addslashes(dol_nl2br($obj->address,1,true))."
"; + if (!empty($obj->cp)) + $coords .= addslashes($obj->zip).' '; + if (!empty($obj->ville)) + $coords .= addslashes($obj->town); + if (!empty($obj->pays)) + $coords .= "
".addslashes($country_code['label']); + } + elseif (!empty($object->address)) + { + $coords .= addslashes(dol_nl2br($object->address,1,true))."
"; + if (!empty($object->zip)) + $coords .= addslashes($object->zip).' '; + if (!empty($object->town)) + $coords .= addslashes($object->town); + if (!empty($object->country)) + $coords .= "
".addslashes($object->country); + } + print ''; + print img_picto($langs->trans("Address"), 'object_address.png'); + print ''; + if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) { print ''; @@ -638,6 +676,19 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') print "\n\n"; print "
\n"; +?> + + + function copyToClipboard (text) { + text = text.replace(/
/g,"\n"); + var newElem = "

Ctrl+C pour copier dans le presse-papier"; + $("#dialog").html(newElem); + $( "#dialog" ).dialog(); + $("#coords").select(); + } + '; return $i; } From 33fbee51bdf06beffbe962691e8a31badc0aadcc Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Sun, 15 Sep 2013 19:09:22 +0200 Subject: [PATCH 2/5] ability to copy contact address to clipboard --- htdocs/core/lib/company.lib.php | 20 +++++++++++++------- htdocs/langs/en_US/main.lang | 1 + htdocs/langs/fr_FR/main.lang | 1 + 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 6b39670fb77..ffb8cb68618 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -537,7 +537,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') print "\n".''."\n"; - $colspan=6; + $colspan=8; print ''; print ''; print ''; @@ -552,11 +552,16 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') $colspan++; print ''; } + if ($user->rights->societe->contact->creer) + { + $colspan++; + print ''; + } print ""; $sql = "SELECT p.rowid, p.lastname, p.firstname, p.fk_pays, p.poste, p.phone, p.phone_mobile, p.fax, p.email, p.statut "; - $sql .= ", p.address, p.zip, p.town"; + $sql .= ", p.civilite, p.address, p.zip, p.town"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; $sql .= " WHERE p.fk_soc = ".$object->id; $sql .= " ORDER by p.datec"; @@ -611,8 +616,8 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') $coords .= addslashes($obj->civilite).' '; if (!empty($obj->firstname)) $coords .= addslashes($obj->firstname).' '; - if (!empty($obj->name)) - $coords .= addslashes($obj->name); + if (!empty($obj->lastname)) + $coords .= addslashes($obj->lastname); $coords .= "
"; if (!empty($obj->address)) { @@ -634,7 +639,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') if (!empty($object->country)) $coords .= "
".addslashes($object->country); } - print ''; @@ -677,16 +682,17 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') print "
\n"; ?> -
'.$langs->trans("Name").''.$langs->trans("Poste").'  
'; + print ''; print img_picto($langs->trans("Address"), 'object_address.png'); print '