Option THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT and

THIRDPARTY_SUPPLIER_BY_DEFAULT to have fields customer/prospect/supplier
set when creating a new thirdparty.
This commit is contained in:
Laurent Destailleur 2016-04-30 14:59:40 +02:00
parent e61e717cac
commit de59d115d9

View File

@ -783,10 +783,14 @@ else
$modCodeFournisseur = new $module;
// Define if customer/prospect or supplier status is set or not
if (GETPOST("type")!='f' && empty($conf->global->THIRDPARTY_NOTCUSTOMERPROSPECT_BY_DEFAULT)) { $object->client=3; }
if (GETPOST("type")=='c') { $object->client=1; }
if (GETPOST("type")!='f')
{
$object->client=-1;
if (! empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT)) { $object->client=3; }
}
if (GETPOST("type")=='c') { $object->client=3; } // Prospect / Customer
if (GETPOST("type")=='p') { $object->client=2; }
if (! empty($conf->fournisseur->enabled) && (GETPOST("type")=='f' || (GETPOST("type")=='' && empty($conf->global->THIRDPARTY_NOTSUPPLIER_BY_DEFAULT)))) { $object->fournisseur=1; }
if (! empty($conf->fournisseur->enabled) && (GETPOST("type")=='f' || (GETPOST("type")=='' && ! empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)))) { $object->fournisseur=1; }
$object->name = GETPOST('name', 'alpha');
$object->firstname = GETPOST('firstname', 'alpha');
@ -983,8 +987,9 @@ else
// Prospect/Customer
print '<tr><td width="25%">'.fieldLabel('ProspectCustomer','customerprospect',1).'</td>';
print '<td width="25%" class="maxwidthonsmartphone"><select class="flat" name="client" id="customerprospect">';
$selected=isset($_POST['client'])?GETPOST('client'):$object->client;
print '<td width="25%" class="maxwidthonsmartphone">';
$selected=isset($_POST['client'])?GETPOST('client'):$object->client;
print '<select class="flat" name="client" id="customerprospect">';
if (GETPOST("type") == '') print '<option value="-1"></option>';
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2"'.($selected==2?' selected':'').'>'.$langs->trans('Prospect').'</option>';
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="3"'.($selected==3?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>';
@ -1008,7 +1013,9 @@ else
// Supplier
print '<tr>';
print '<td>'.fieldLabel('Supplier','fournisseur',1).'</td><td>';
print $form->selectyesno("fournisseur", (isset($_POST['fournisseur'])?GETPOST('fournisseur'):(GETPOST("type") == '' ? -1 : $object->fournisseur)), 1, 0, (GETPOST("type") == '' ? 1 : 0));
$default = -1;
if (! empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)) $default=1;
print $form->selectyesno("fournisseur", (isset($_POST['fournisseur'])?GETPOST('fournisseur'):(GETPOST("type") == '' ? $default : $object->fournisseur)), 1, 0, (GETPOST("type") == '' ? 1 : 0));
print '</td>';
print '<td>'.fieldLabel('SupplierCode','supplier_code').'</td><td>';
print '<table class="nobordernopadding"><tr><td>';