Skip to content

Commit

Permalink
NEW add company alias name when create company from member
Browse files Browse the repository at this point in the history
  • Loading branch information
hregis committed Oct 9, 2017
1 parent 4a30448 commit f2d9288
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 19 deletions.
19 changes: 13 additions & 6 deletions htdocs/adherents/card.php
Expand Up @@ -223,7 +223,7 @@
{
// 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)
{
Expand Down Expand Up @@ -1319,18 +1319,25 @@ function initfieldrequired()
// 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);
}
Expand Down
24 changes: 15 additions & 9 deletions htdocs/adherents/subscription.php
@@ -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
Expand Down Expand Up @@ -109,7 +109,7 @@
{
// 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)
{
Expand Down Expand Up @@ -960,19 +960,25 @@
// 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);
}
Expand Down
6 changes: 4 additions & 2 deletions htdocs/core/class/html.form.class.php
Expand Up @@ -3572,14 +3572,16 @@ function formconfirm($page, $title, $question, $action, $formquestion='', $selec
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')
{
Expand Down
8 changes: 6 additions & 2 deletions htdocs/societe/class/societe.class.php
Expand Up @@ -2981,19 +2981,23 @@ function AddFournisseurInCategory($categorie_id)
* 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;
Expand Down

0 comments on commit f2d9288

Please sign in to comment.