NEW add company alias name when create company from member
This commit is contained in:
parent
4a30448ff4
commit
f2d9288db5
@ -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);
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2012-2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
|
||||
@ -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.='<tr><td>'.$input['label'].'</td><td colspan="2" align="left"><input type="text" class="flat" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'" /></td></tr>'."\n";
|
||||
$more.='<tr><td>'.$input['label'].'</td><td colspan="2" align="left"><input type="text" class="flat'.$css.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'"'.$moreattr.' /></td></tr>'."\n";
|
||||
}
|
||||
else if ($input['type'] == 'password')
|
||||
{
|
||||
$more.='<tr><td>'.$input['label'].'</td><td colspan="2" align="left"><input type="password" class="flat" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'" /></td></tr>'."\n";
|
||||
$more.='<tr><td>'.$input['label'].'</td><td colspan="2" align="left"><input type="password" class="flat'.$css.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'"'.$moreattr.' /></td></tr>'."\n";
|
||||
}
|
||||
else if ($input['type'] == 'select')
|
||||
{
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user