diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index bbbc307e420..f5dfb2bc8fb 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -181,7 +181,7 @@ if (! empty($conf->global->MAIN_MODULE_NOTIFICATION)) $var=!$var; if (!$obj->fk_societe) { - $username= $obj->firstname.' '.$obj->lastname; + $username=dolGetFirstLastname($obj->firstname,$obj->lastname); $internalusers[$obj->rowid] = $username; } @@ -254,7 +254,7 @@ if ($resql) $var=!$var; print ""; - print ''.$obj->firstname." ".$obj->lastname.''; + print ''.dolGetFirstLastname($obj->firstname,$obj->lastname).''; $label=($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label); print ''.$label.''; print 'rowid.'">'.img_delete().''; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 48307e19905..a6199580353 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -948,7 +948,7 @@ class ActionComm extends CommonObject $event['startdate']=$datestart; $event['duration']=$duration; // Not required with type 'journal' $event['enddate']=$dateend; // Not required with type 'journal' - $event['author']=$obj->firstname.($obj->lastname?" ".$obj->lastname:""); + $event['author']=dolGetFirstLastname($obj->firstname, $obj->lastname); $event['priority']=$obj->priority; $event['fulldayevent']=$obj->fulldayevent; $event['location']=$obj->location; diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index f16579051e1..0b182c7645f 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -486,7 +486,7 @@ if ($showbirthday) $event->datep=dol_mktime(0,0,0,$datearray['mon'],$datearray['mday'],$year,true); // For full day events, date are also GMT but they wont but converted during output $event->datef=$event->datep; $event->type_code='BIRTHDAY'; - $event->libelle=$langs->trans("Birthday").' '.$obj->firstname.' '.$obj->lastname; + $event->libelle=$langs->trans("Birthday").' '.dolGetFirstLastname($obj->firstname,$obj->lastname); $event->percentage=100; $event->fulldayevent=true; diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index ef2655ad80c..4b886f2d24f 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -209,7 +209,7 @@ if ($action == 'sendallconfirmed' && $confirm == 'yes') $obj = $db->fetch_object($resql); // sendto en RFC2822 - $sendto = str_replace(',',' ',$obj->firstname." ".$obj->lastname)." <".$obj->email.">"; + $sendto = str_replace(',',' ',dolGetFirstLastname($obj->firstname, $obj->lastname))." <".$obj->email.">"; // Make substitutions on topic and body. From (AA=YY;BB=CC;...) we keep YY, CC, ... $other=explode(';',$obj->other); diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 0c0c55ebf57..4c044314c63 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -540,7 +540,7 @@ class BonPrelevement extends CommonObject $this->method_trans = $method; $langs->load('withdrawals'); $subject = $langs->trans("InfoTransSubject", $this->ref); - $message = $langs->trans("InfoTransMessage", $this->ref, $user->firstname, $user->lastname); + $message = $langs->trans("InfoTransMessage", $this->ref, dolGetFirstLastname($user->firstname, $user->lastname)); $message .=$langs->trans("InfoTransData", price($this->amount), $this->methodes_trans[$this->method_trans], dol_print_date($date,'day')); // TODO Call trigger to create a notification using notification module diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 58655666755..50bd564e8d9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -73,21 +73,8 @@ abstract class CommonObject else $ret.=$this->civilite_id.' '; } - // If order not defined, we use the setup - if ($nameorder < 0) $nameorder=(empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)); + $ret.=dolGetFirstLastname($firstname, $lastname, $nameorder); - if ($nameorder) - { - $ret.=$firstname; - if ($firstname && $lastname) $ret.=' '; - $ret.=$lastname; - } - else - { - $ret.=$lastname; - if ($firstname && $lastname) $ret.=' '; - $ret.=$firstname; - } return dol_trunc($ret,$maxlen); } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 817396f97fc..3acf7983fe3 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3643,13 +3643,29 @@ function get_date_range($date_start,$date_end,$format = '',$outputlangs='') * * @param string $firstname Firstname * @param string $lastname Lastname + * @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname * @return string Firstname + lastname or Lastname + firstname */ -function dolGetFirstLastname($firstname,$lastname) +function dolGetFirstLastname($firstname,$lastname,$nameorder=-1) { global $conf; - if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) return $firstname.' '.$lastname; - else return $lastname.' '.$firstname; + + $ret=''; + // If order not defined, we use the setup + if ($nameorder < 0) $nameorder=(empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)); + if ($nameorder) + { + $ret.=$firstname; + if ($firstname && $lastname) $ret.=' '; + $ret.=$lastname; + } + else + { + $ret.=$lastname; + if ($firstname && $lastname) $ret.=' '; + $ret.=$firstname; + } + return $ret; } diff --git a/htdocs/holiday/fiche.php b/htdocs/holiday/fiche.php index 8602163b583..518a83908c4 100644 --- a/htdocs/holiday/fiche.php +++ b/htdocs/holiday/fiche.php @@ -319,7 +319,7 @@ if ($action == 'confirm_send') } $message.= "\n"; - $message.= "- ".$langs->transnoentitiesnoconv("Name")." : ".$expediteur->firstname." ".$expediteur->lastname."\n"; + $message.= "- ".$langs->transnoentitiesnoconv("Name")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; $message.= "- ".$langs->transnoentitiesnoconv("Period")." : ".dol_print_date($cp->date_debut,'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($cp->date_fin,'day')."\n"; $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/fiche.php?id=".$cp->rowid."\n\n"; $message.= "\n"; @@ -400,7 +400,7 @@ if($action == 'confirm_valid') $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; $message.= "\n"; $message.= "Votre demande de congés payés du ".dol_print_date($cp->date_debut,'day')." au ".dol_print_date($cp->date_fin,'day')." vient d'être validée!\n"; - $message.= "- ".$langs->transnoentitiesnoconv("ValidatedBy")." : ".$expediteur->firstname." ".$expediteur->lastname."\n"; + $message.= "- ".$langs->transnoentitiesnoconv("ValidatedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/fiche.php?id=".$cp->rowid."\n\n"; $message.= "\n"; @@ -469,7 +469,7 @@ if ($action == 'confirm_refuse') $message.= "\n"; $message.= "Votre demande de congés payés ".dol_print_date($cp->date_debut,'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($cp->date_fin,'day')." vient d'être refusée pour le motif suivant :\n"; $message.= $_POST['detail_refuse']."\n\n"; - $message.= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".$expediteur->firstname." ".$expediteur->lastname."\n"; + $message.= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/fiche.php?id=".$cp->rowid."\n\n"; $message.= "\n"; @@ -539,7 +539,7 @@ if ($action == 'confirm_cancel' && $_GET['confirm'] == 'yes') $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; $message.= "\n"; $message.= "Votre demande de congés ".dol_print_date($cp->date_debut,'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($cp->date_fin,'day')." va été annulée.\n"; - $message.= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".$expediteur->firstname." ".$expediteur->lastname."\n"; + $message.= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/fiche.php?id=".$cp->rowid."\n\n"; $message.= "\n"; diff --git a/htdocs/mailmanspip/class/mailmanspip.class.php b/htdocs/mailmanspip/class/mailmanspip.class.php index 845069327b0..9e10c315dfa 100644 --- a/htdocs/mailmanspip/class/mailmanspip.class.php +++ b/htdocs/mailmanspip/class/mailmanspip.class.php @@ -176,7 +176,7 @@ class MailmanSpip require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $mdpass=dol_hash($object->pass); $htpass=crypt($object->pass,makesalt()); - $query = "INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"".$object->firstname." ".$object->lastname."\",\"".$object->email."\",\"".$object->login."\",\"$mdpass\",\"$htpass\",FLOOR(32000*RAND()),\"1comite\")"; + $query = "INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"".dolGetFirstLastname($object->firstname,$object->lastname)."\",\"".$object->email."\",\"".$object->login."\",\"$mdpass\",\"$htpass\",FLOOR(32000*RAND()),\"1comite\")"; $result = $mydb->query($query); diff --git a/htdocs/public/donations/donateurs_code.php b/htdocs/public/donations/donateurs_code.php index f354cffe8a1..972ba6a657d 100644 --- a/htdocs/public/donations/donateurs_code.php +++ b/htdocs/public/donations/donateurs_code.php @@ -81,10 +81,10 @@ if ($resql) $objp = $db->fetch_object($resql); $var=!$var; - print ""; + print ""; if ($objp->public) { - print "".$objp->firstname." ".$objp->lastname." ".$objp->societe."\n"; + print "".dolGetFirstLastname($objp->firstname, $objp->lastname)." ".$objp->societe."\n"; } else { diff --git a/htdocs/public/members/public_list.php b/htdocs/public/members/public_list.php index 6f32d9e4715..de4044e3574 100644 --- a/htdocs/public/members/public_list.php +++ b/htdocs/public/members/public_list.php @@ -140,7 +140,7 @@ if ($result) $objp = $db->fetch_object($result); $var=!$var; print ""; - print ''.$objp->firstname.' '.$objp->lastname.($objp->societe?' / '.$objp->societe:'').''."\n"; + print ''.dolGetFirstLastname($obj->firstname, $obj->lastname).($objp->societe?' / '.$objp->societe:'').''."\n"; //print "$objp->naiss\n"; // est-ce nécessaire ?? print ''.$objp->email.''."\n"; print ''.$objp->zip.''."\n"; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 2a25314b5d4..c87a6ef11f4 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1616,7 +1616,7 @@ class Societe extends CommonObject $obj = $this->db->fetch_object($resql); if ($mode == 'email') $property=$obj->email; else if ($mode == 'mobile') $property=$obj->phone_mobile; - $contact_property[$obj->rowid] = trim($obj->firstname." ".$obj->lastname)." <".$property.">"; + $contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname,$obj->lastname))." <".$property.">"; $i++; } } @@ -1649,7 +1649,7 @@ class Societe extends CommonObject while ($i < $nump) { $obj = $this->db->fetch_object($resql); - $contacts[$obj->rowid] = $obj->firstname." ".$obj->lastname; + $contacts[$obj->rowid] = dolGetFirstLastname($obj->firstname,$obj->lastname); $i++; } } @@ -1685,7 +1685,7 @@ class Societe extends CommonObject { $obj = $this->db->fetch_object($resql); - if ($mode == 'email') $contact_property = "$obj->firstname $obj->lastname <$obj->email>"; + if ($mode == 'email') $contact_property = dolGetFirstLastname($obj->firstname, $obj->lastname)." <".$obj->email.">"; else if ($mode == 'mobile') $contact_property = $obj->phone_mobile; } return $contact_property; diff --git a/htdocs/societe/commerciaux.php b/htdocs/societe/commerciaux.php index 0fa9f78353b..a4f1dee5a7b 100644 --- a/htdocs/societe/commerciaux.php +++ b/htdocs/societe/commerciaux.php @@ -188,7 +188,7 @@ if ($_GET["socid"]) print ''; print img_object($langs->trans("ShowUser"),"user").' '; - print $obj->firstname." " .$obj->lastname."\n"; + print dolGetFirstLastname($obj->firstname, $obj->lastname)."\n"; print ' '; if ($user->rights->societe->creer) { @@ -254,7 +254,7 @@ if ($_GET["socid"]) print ""; print ''; print img_object($langs->trans("ShowUser"),"user").' '; - print $obj->firstname." " .$obj->lastname."\n"; + print dolGetFirstLastname($obj->firstname, $obj->lastname)."\n"; print ''; print ''.$obj->login.''; print ''.$langs->trans("Add").''; diff --git a/htdocs/societe/notify/index.php b/htdocs/societe/notify/index.php index 9a1fc344a53..943d55669bf 100644 --- a/htdocs/societe/notify/index.php +++ b/htdocs/societe/notify/index.php @@ -93,9 +93,9 @@ if ($result) $var=!$var; - print ""; - print "socid."\">$obj->nom\n"; - print "".$obj->firstname." ".$obj->lastname."\n"; + print ""; + print "socid."\">".$obj->nom."\n"; + print "".dolGetFirstLastname($obj->firstname, $obj->lastname)."\n"; print "".$obj->titre."\n"; print "\n"; $i++; @@ -108,7 +108,7 @@ else dol_print_error($db); } -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/scripts/emailings/cron-mailing-send.php b/scripts/emailings/cron-mailing-send.php index 658d899a677..e1290f4f769 100644 --- a/scripts/emailings/cron-mailing-send.php +++ b/scripts/emailings/cron-mailing-send.php @@ -120,7 +120,7 @@ if ($resql) $obj2 = $db->fetch_object($resql); // sendto en RFC2822 - $sendto = str_replace(',',' ',$obj2->firstname." ".$obj2->lastname) ." <".$obj2->email.">"; + $sendto = str_replace(',',' ',dolGetFirstLastname($obj2->firstname, $obj2->lastname)) ." <".$obj2->email.">"; // Make subtsitutions on topic and body $other=explode(';',$obj2->other); diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 953c967bcb2..6db9eb00c2a 100644 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -127,7 +127,7 @@ if ($resql) $obj = $db->fetch_object($resql); // sendto en RFC2822 - $sendto = str_replace(',',' ',$obj->firstname." ".$obj->lastname) ." <".$obj->email.">"; + $sendto = str_replace(',',' ',dolGetFirstLastname($obj->firstname, $obj->lastname) ." <".$obj->email.">"; // Make subtsitutions on topic and body $other=explode(';',$obj->other);