FIX Can't create a thirdparty from member if customer code is mandatory.
This commit is contained in:
parent
2e6a41228f
commit
31d032d5d3
@ -120,7 +120,7 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights
|
|||||||
{
|
{
|
||||||
// Creation of thirdparty
|
// Creation of thirdparty
|
||||||
$company = new Societe($db);
|
$company = new Societe($db);
|
||||||
$result=$company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha'));
|
$result=$company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha'), GETPOST('customercode', 'alpha'));
|
||||||
|
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
@ -854,6 +854,14 @@ if ($rowid > 0)
|
|||||||
array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"'),
|
array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"'),
|
||||||
array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"')
|
array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"')
|
||||||
);
|
);
|
||||||
|
// If customer code was forced to "required", we ask it at creation to avoid error later
|
||||||
|
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
|
||||||
|
{
|
||||||
|
$tmpcompany = new Societe($db);
|
||||||
|
$tmpcompany->name=$companyname;
|
||||||
|
$customercode = $tmpcompany->get_codeclient($tmpcompany,0);
|
||||||
|
$formquestion[]=array('label' => $langs->trans("CustomerCode"), 'type' => 'text', 'name' => 'customercode', 'value' => $customercode, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"');
|
||||||
|
}
|
||||||
|
|
||||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1);
|
print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3247,9 +3247,10 @@ class Societe extends CommonObject
|
|||||||
* @param Adherent $member Object member
|
* @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
|
* @param string $socalias Alias name of third party to force
|
||||||
|
* @param string $customercode Customer code
|
||||||
* @return int <0 if KO, id of created account if OK
|
* @return int <0 if KO, id of created account if OK
|
||||||
*/
|
*/
|
||||||
function create_from_member(Adherent $member, $socname='', $socalias='')
|
function create_from_member(Adherent $member, $socname='', $socalias='', $customercode='')
|
||||||
{
|
{
|
||||||
global $user,$langs;
|
global $user,$langs;
|
||||||
|
|
||||||
@ -3274,7 +3275,7 @@ class Societe extends CommonObject
|
|||||||
$this->skype=$member->skype;
|
$this->skype=$member->skype;
|
||||||
|
|
||||||
$this->client = 1; // A member is a customer by default
|
$this->client = 1; // A member is a customer by default
|
||||||
$this->code_client = -1;
|
$this->code_client = ($customercode?$customercode:-1);
|
||||||
$this->code_fournisseur = -1;
|
$this->code_fournisseur = -1;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user