diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 6e5389e346a..c95b62e1dc0 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -223,7 +223,7 @@ if (empty($reshook)) { // User creation $company = new Societe($db); - $result=$company->create_from_member($object,GETPOST('companyname')); + $result=$company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha')); if ($result < 0) { @@ -1319,18 +1319,25 @@ else // Confirm create third party if ($action == 'create_thirdparty') { - $name = $object->getFullName($langs); - if (! empty($name)) + $companyalias=''; + $fullname = $object->getFullName($langs); + + if ($object->morphy == 'mor') { - if ($object->societe) $name.=' ('.$object->societe.')'; + $companyname=$object->societe; + if (! empty($fullname)) $companyalias=$fullname; } else { - $name=$object->societe; + $companyname=$fullname; + if (! empty($object->societe)) $companyalias=$object->societe; } // Create a form array - $formquestion=array( array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $name)); + $formquestion=array( + array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'css' => 'minwidth300', 'moreattr' => 'maxlength="128"'), + array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'css' => 'minwidth300', 'moreattr' => 'maxlength="128"') + ); print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1); } diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 4b8f3b50648..405fe689816 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -1,8 +1,8 @@ +/* Copyright (C) 2001-2004 Rodolphe Quiedeville * Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2004-2014 Laurent Destailleur - * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2012-2017 Regis Houssin * Copyright (C) 2015-2016 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -109,7 +109,7 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights { // Creation user $company = new Societe($db); - $result=$company->create_from_member($object,$_POST["companyname"]); + $result=$company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha')); if ($result < 0) { @@ -960,19 +960,25 @@ if ($rowid > 0) // Confirm create third party if ($action == 'create_thirdparty') { - $name = $object->getFullName($langs); - if (! empty($name)) + $companyalias=''; + $fullname = $object->getFullName($langs); + + if ($object->morphy == 'mor') { - if ($object->morphy == 'mor' && ! empty($object->societe)) $name=$object->societe.' ('.$name.')'; - else if ($object->societe) $name.=' ('.$object->societe.')'; + $companyname=$object->societe; + if (! empty($fullname)) $companyalias=$fullname; } else { - $name=$object->societe; + $companyname=$fullname; + if (! empty($object->societe)) $companyalias=$object->societe; } // Create a form array - $formquestion=array(array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $name)); + $formquestion=array( + array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'css' => 'minwidth300', 'moreattr' => 'maxlength="128"'), + array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'css' => 'minwidth300', 'moreattr' => 'maxlength="128"') + ); print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1); } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 93c24990af0..d4c8ce6f288 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3572,14 +3572,16 @@ class Form if (is_array($input) && ! empty($input)) { $size=(! empty($input['size'])?' size="'.$input['size'].'"':''); + $moreattr=(! empty($input['moreattr'])?' '.$input['moreattr']:''); + $css=(! empty($input['css'])?' '.$input['css']:''); if ($input['type'] == 'text') { - $more.=''.$input['label'].''."\n"; + $more.=''.$input['label'].''."\n"; } else if ($input['type'] == 'password') { - $more.=''.$input['label'].''."\n"; + $more.=''.$input['label'].''."\n"; } else if ($input['type'] == 'select') { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1c8c515545a..bf449f30976 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2981,19 +2981,23 @@ class Societe extends CommonObject * Create a third party into database from a member object * * @param Adherent $member Object member - * @param string $socname Name of third party to force + * @param string $socname Name of third party to force + * @param string $socalias Alias name of third party to force * @return int <0 if KO, id of created account if OK */ - function create_from_member(Adherent $member,$socname='') + function create_from_member(Adherent $member, $socname='', $socalias='') { global $user,$langs; $name = $socname?$socname:$member->societe; if (empty($name)) $name=$member->getFullName($langs); + $alias = $socalias?$socalias:''; + // Positionne parametres $this->nom=$name; // TODO deprecated $this->name=$name; + $this->name_alias=$alias; $this->address=$member->address; $this->zip=$member->zip; $this->town=$member->town;