Merge pull request #10514 from atm-florian/dev_defautselectcustomertype
Dev defautselectcustomertype
This commit is contained in:
commit
7334f02e5c
@ -888,4 +888,55 @@ class FormCompany
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a HTML select for thirdparty type
|
||||
*
|
||||
* @param int $selected selected value
|
||||
* @param string $htmlname HTML select name
|
||||
* @param string $htmlidname HTML select id
|
||||
* @param string $typeinput HTML output
|
||||
* @param string $morecss More css
|
||||
* @return string HTML string
|
||||
*/
|
||||
function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname = 'customerprospect', $typeinput = 'form', $morecss = '')
|
||||
{
|
||||
|
||||
global $conf,$langs;
|
||||
|
||||
$out = '<select class="flat '.$morecss.'" name="'.$htmlname.'" id="'.$htmlidname.'">';
|
||||
if ($typeinput=='form') {
|
||||
if ($selected == '') $out .= '<option value="-1"> </option>';
|
||||
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
|
||||
$out .= '<option value="2"'.($selected==2?' selected':'').'>'.$langs->trans('Prospect').'</option>';
|
||||
}
|
||||
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
|
||||
$out .= '<option value="3"'.($selected==3?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>';
|
||||
}
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
|
||||
$out .= '<option value="1"'.($selected==1?' selected':'').'>'.$langs->trans('Customer').'</option>';
|
||||
}
|
||||
$out .= '<option value="0"'.((string) $selected == '0'?' selected':'').'>'.$langs->trans('NorProspectNorCustomer').'</option>';
|
||||
} elseif ($typeinput=='list') {
|
||||
$out .= '<option value="-1"'.($selected==''?' selected':'').'> </option>';
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
|
||||
$out .= '<option value="1,3"'.($selected=='1,3'?' selected':'').'>'.$langs->trans('Customer').'</option>';
|
||||
}
|
||||
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
|
||||
$out .= '<option value="2,3"'.($selected=='2,3'?' selected':'').'>'.$langs->trans('Prospect').'</option>';
|
||||
}
|
||||
$out .= '<option value="4"'.($selected=='4'?' selected':'').'>'.$langs->trans('Supplier').'</option>';
|
||||
$out .= '<option value="0"'.($selected=='0'?' selected':'').'>'.$langs->trans('Others').'</option>';
|
||||
} elseif ($typeinput=='admin') {
|
||||
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
|
||||
$out .= '<option value="3"'.($selected==3?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>';
|
||||
}
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
|
||||
$out .= '<option value="1"'.($selected==1?' selected':'').'>'.$langs->trans('Customer').'</option>';
|
||||
}
|
||||
}
|
||||
$out .= '</select>';
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1854,4 +1854,5 @@ OnMobileOnly=On small screen (smartphone) only
|
||||
DisableProspectCustomerType=Disable the "Prospect + Customer" third party type (so third party must be Prospect or Customer but can't be both)
|
||||
MAIN_OPTIMIZEFORTEXTBROWSER=Simplify interface for blind person
|
||||
MAIN_OPTIMIZEFORTEXTBROWSERDesc=Enable this option if you are a blind person, or if you use the application from a text browser like Lynx or Links.
|
||||
ThisValueCanOverwrittenOnUserLevel=This value can be overwritten by each user from its user page - tab '%s'
|
||||
ThisValueCanOverwrittenOnUserLevel=This value can be overwritten by each user from its user page - tab '%s'
|
||||
DefaultCustomerType=Default thirdparty type for "New customer" creation form
|
||||
@ -28,6 +28,7 @@
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
|
||||
$langs->loadLangs(array("admin", "companies", "other"));
|
||||
|
||||
@ -36,6 +37,8 @@ $value=GETPOST('value', 'alpha');
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
$formcompany = new FormCompany($db);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@ -101,6 +104,21 @@ if ($action == 'updateoptions')
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if (GETPOST('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT'))
|
||||
{
|
||||
$customertypedefault = GETPOST('defaultcustomertype', 'int');
|
||||
$res = dolibarr_set_const($db, "THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT", $customertypedefault, 'chaine', 0, '', $conf->entity);
|
||||
if (! $res > 0) $error++;
|
||||
if (! $error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Activate a document generator module
|
||||
@ -306,7 +324,6 @@ if($action=='setonsearchandlistgooncustomerorsuppliercard'){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
@ -861,44 +878,16 @@ else
|
||||
print '</a></td>';
|
||||
print '</tr>';
|
||||
|
||||
/*print '<tr class="oddeven">';
|
||||
print '<td width="80%">'.$langs->trans("OnSearchAndListGoOnCustomerOrSupplierCard").'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="center">';
|
||||
if (!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD))
|
||||
{
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setonsearchandlistgooncustomerorsuppliercard&value=0">';
|
||||
print img_picto($langs->trans("Activated"),'switch_on');
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setonsearchandlistgooncustomerorsuppliercard&value=1">';
|
||||
print img_picto($langs->trans("Disabled"),'switch_off');
|
||||
}
|
||||
print '</a></td>';
|
||||
print '</tr>';
|
||||
*/
|
||||
|
||||
/*
|
||||
// COMPANY_USE_SEARCH_TO_SELECT
|
||||
|
||||
// Default Prospect/Customer thirdparty type on customer création
|
||||
print '<tr class="oddeven">';
|
||||
print '<td width="80%">'.$langs->trans("HideClosedThirdpartyComboBox").'</td>';
|
||||
if (! empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX))
|
||||
{
|
||||
print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=sethideinactivethirdparty&status=0">';
|
||||
print img_picto($langs->trans("Activated"),'switch_on');
|
||||
print '</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=sethideinactivethirdparty&status=1">';
|
||||
print img_picto($langs->trans("Disabled"),'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
print '<td width="80%">'.$langs->trans("DefaultCustomerType").'</td>';
|
||||
print '<td>';
|
||||
print $formcompany->selectProspectCustomerType($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT,'defaultcustomertype','defaultcustomertype','admin');
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print '<input type="submit" class="button" name="THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT" value="'.$langs->trans("Modify").'">';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
*/
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
@ -937,7 +937,14 @@ else
|
||||
$object->client=-1;
|
||||
if (! empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT)) { $object->client=3; }
|
||||
}
|
||||
if (GETPOST("type")=='c') { $object->client=3; } // Prospect / Customer
|
||||
// Prospect / Customer
|
||||
if (GETPOST("type")=='c') {
|
||||
if (! empty($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT)) {
|
||||
$object->client=$conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT;
|
||||
} else {
|
||||
$object->client=3;
|
||||
}
|
||||
}
|
||||
if (GETPOST("type")=='p') { $object->client=2; }
|
||||
if (! empty($conf->fournisseur->enabled) && (GETPOST("type")=='f' || (GETPOST("type")=='' && ! empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)))) { $object->fournisseur=1; }
|
||||
|
||||
@ -1179,13 +1186,8 @@ else
|
||||
print '<tr><td class="titlefieldcreate">'.$form->editfieldkey('ProspectCustomer', 'customerprospect', '', $object, 0, 'string', '', 1).'</td>';
|
||||
print '<td class="maxwidthonsmartphone">';
|
||||
$selected=GETPOST('client', 'int')!=''?GETPOST('client', 'int'):$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) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) print '<option value="3"'.($selected==3?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>';
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="1"'.($selected==1?' selected':'').'>'.$langs->trans('Customer').'</option>';
|
||||
print '<option value="0"'.((string) $selected == '0'?' selected':'').'>'.$langs->trans('NorProspectNorCustomer').'</option>';
|
||||
print '</select></td>';
|
||||
print $formcompany->selectProspectCustomerType($selected);
|
||||
print '</td>';
|
||||
|
||||
print '<td>'.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).'</td><td>';
|
||||
print '<table class="nobordernopadding"><tr><td>';
|
||||
@ -1770,12 +1772,9 @@ else
|
||||
|
||||
// Prospect/Customer
|
||||
print '<tr><td>'.$form->editfieldkey('ProspectCustomer', 'customerprospect', '', $object, 0, 'string', '', 1).'</td>';
|
||||
print '<td class="maxwidthonsmartphone"><select class="flat" name="client" id="customerprospect">';
|
||||
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2"'.($object->client==2?' selected':'').'>'.$langs->trans('Prospect').'</option>';
|
||||
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="3"'.($object->client==3?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>';
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="1"'.($object->client==1?' selected':'').'>'.$langs->trans('Customer').'</option>';
|
||||
print '<option value="0"'.($object->client==0?' selected':'').'>'.$langs->trans('NorProspectNorCustomer').'</option>';
|
||||
print '</select></td>';
|
||||
print '<td class="maxwidthonsmartphone">';
|
||||
print $formcompany->selectProspectCustomerType($object->client);
|
||||
print '</td>';
|
||||
print '<td>'.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).'</td><td>';
|
||||
|
||||
print '<table class="nobordernopadding"><tr><td>';
|
||||
|
||||
@ -838,13 +838,7 @@ if (! empty($arrayfields['customerorsupplier']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre maxwidthonsmartphone" align="middle">';
|
||||
if ($type != '') print '<input type="hidden" name="type" value="'.$type.'">';
|
||||
print '<select class="flat" name="search_type">';
|
||||
print '<option value="-1"'.($search_type==''?' selected':'').'> </option>';
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="1,3"'.($search_type=='1,3'?' selected':'').'>'.$langs->trans('Customer').'</option>';
|
||||
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2,3"'.($search_type=='2,3'?' selected':'').'>'.$langs->trans('Prospect').'</option>';
|
||||
//if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="3"'.($search_type=='3'?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>';
|
||||
print '<option value="4"'.($search_type=='4'?' selected':'').'>'.$langs->trans('Supplier').'</option>';
|
||||
print '<option value="0"'.($search_type=='0'?' selected':'').'>'.$langs->trans('Others').'</option>';
|
||||
print $formcompany->selectProspectCustomerType($search_type,'search_type', 'search_type', 'list');
|
||||
print '</select></td>';
|
||||
}
|
||||
// Prospect level
|
||||
|
||||
Loading…
Reference in New Issue
Block a user