diff --git a/htdocs/core/js/lib_head.js b/htdocs/core/js/lib_head.js
index cfb2977c370..a9b7f9e4c18 100644
--- a/htdocs/core/js/lib_head.js
+++ b/htdocs/core/js/lib_head.js
@@ -899,6 +899,24 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton,
});
})( jQuery );
+
+/*
+ * Function to output a dialog bog for copy/paste
+ *
+ * @param string text Text to put into copy/paste area
+ * @param string text2 Text to put under the copy/paste area
+ */
+function copyToClipboard(text,text2)
+{
+ text = text.replace(/
/g,"\n");
+ var newElem = "
"+text2;
+ $("#dialog").html(newElem);
+ $("#dialog").dialog();
+ $("#coords").select();
+ return false;
+}
+
+
/*
* Timer for delayed keyup function
*
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 849b8901ab3..42da0b04d38 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -637,12 +637,12 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
print "";
- $sql = "SELECT p.rowid, p.lastname, p.firstname, p.fk_pays, p.poste, p.phone, p.phone_mobile, p.fax, p.email, p.skype, p.statut ";
+ $sql = "SELECT p.rowid, p.lastname, p.firstname, p.fk_pays as country_id, p.poste, p.phone, p.phone_mobile, p.fax, p.email, p.skype, p.statut ";
$sql .= ", p.civilite, p.address, p.zip, p.town";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
$sql .= " WHERE p.fk_soc = ".$object->id;
if ($search_status!='') $sql .= " AND p.statut = ".$db->escape($search_status);
- if ($search_name) $sql .= " AND (p.lastname LIKE '%".$db->escape(strtolower($search_name))."%' OR p.firstname LIKE '%".$db->escape(strtolower($search_name))."%')";
+ if ($search_name) $sql .= " AND (p.lastname LIKE '%".$db->escape($search_name)."%' OR p.firstname LIKE '%".$db->escape($search_name)."%')";
$sql.= " ORDER BY $sortfield $sortorder";
dol_syslog('core/lib/company.lib.php :: show_contacts sql='.$sql,LOG_DEBUG);
@@ -665,12 +665,13 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
$contactstatic->statut = $obj->statut;
$contactstatic->lastname = $obj->lastname;
$contactstatic->firstname = $obj->firstname;
+ $contactstatic->civilite = $obj->civilite;
print $contactstatic->getNomUrl(1);
print '';
print '
'.$obj->poste.' | ';
- $country_code = getCountry($obj->fk_pays, 'all');
+ $country_code = getCountry($obj->country_id, 'all');
// Lien click to dial
print '';
@@ -695,41 +696,26 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
// Status
print ' | '.$contactstatic->getLibStatut(5).' | ';
- // Copy to 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->lastname))
- $coords .= addslashes($obj->lastname);
- $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 ' | ';
+ print '';
+ if (! empty($conf->use_javascript_ajax))
+ {
+ // Copy to clipboard
+ $coords = '';
+ if (!empty($object->name)) $coords .= $object->name." ";
+ $coords .= $contactstatic->getFullName($langs,1).' ';
+ $coords .= " ";
+ if (!empty($obj->address))
+ {
+ $coords .= dol_nl2br($obj->address,1,true)." ";
+ if (!empty($obj->zip)) $coords .= $obj->zip.' ';
+ if (!empty($obj->town)) $coords .= $obj->town;
+ if (!empty($obj->country_id)) $coords .= " ".$country_code['label'];
+ }
+ print '';
+ print img_picto($langs->trans("Address"), 'object_address.png');
+ print '';
+ }
+ print ' | ';
// Add to agenda
if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create)
@@ -761,7 +747,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
}
}
else
- {
+ {
print "";
print '| '.$langs->trans("None").' | ';
print "
\n";
@@ -775,16 +761,6 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
- function copyToClipboard (text) {
- text = text.replace(/
/g,"\n");
- var newElem = "
'.$langs->trans('HelpCopyToClipboard').'";
- $("#dialog").html(newElem);
- $( "#dialog" ).dialog();
- $("#coords").select();
- return false;
- }
- ';
return $i;
}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index b9e25aa58f1..19d2adeea93 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -438,7 +438,7 @@ function dol_string_nospecial($str,$newstr='_',$badchars='')
* Returns text escaped for inclusion into javascript code
*
* @param string $stringtoescape String to escape
- * @param string $mode 0=Escape also ' and " into ', 1=Escape ' but not " for usage into 'string', 2=Escape " but not ' for usage into "string"
+ * @param string $mode 0=Escape also ' and " into ', 1=Escape ' but not " for usage into 'string', 2=Escape " but not ' for usage into "string", 3=Escape ' and " with \
* @return string Escaped string. Both ' and " are escaped into ' if they are escaped.
*/
function dol_escape_js($stringtoescape, $mode=0)
@@ -449,6 +449,7 @@ function dol_escape_js($stringtoescape, $mode=0)
if (empty($mode)) { $substitjs["'"]="\\'"; $substitjs['"']="\\'"; }
else if ($mode == 1) $substitjs["'"]="\\'";
else if ($mode == 2) { $substitjs['"']='\\"'; }
+ else if ($mode == 3) { $substitjs["'"]="\\'"; $substitjs['"']="\\\""; }
return strtr($stringtoescape, $substitjs);
}