From 3f20cae6d349acf7769f0976b29e3f7e2f1ab44a Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 6 Feb 2019 10:54:11 +0100 Subject: [PATCH 1/5] NEW: setup default thridparty type (customer or prospect/customer) --- htdocs/core/class/html.formcompany.class.php | 40 +++++++++++++ htdocs/langs/en_US/admin.lang | 3 +- htdocs/societe/admin/societe.php | 63 ++++++++------------ htdocs/societe/card.php | 26 ++++---- htdocs/societe/list.php | 5 +- 5 files changed, 83 insertions(+), 54 deletions(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 58c9950898c..d28b867dc93 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -888,4 +888,44 @@ class FormCompany } } } + + function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname='customerprospect', $typeinput='form',$morecss = '') { + + global $conf,$langs; + + $out = ''; + + return $out; + } } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d92a0b47bcc..99b92e67074 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -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' \ No newline at end of file +ThisValueCanOverwrittenOnUserLevel=This value can be overwritten by each user from its user page - tab '%s' +DefaultCustomerType=Default thirdparty type for "New customer" creation form \ No newline at end of file diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 6f808b8307a..e283d3220b2 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -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 ''; print ''; -/*print ''; -print ''.$langs->trans("OnSearchAndListGoOnCustomerOrSupplierCard").''; -print ' '; -print ''; -if (!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)) -{ - print ''; - print img_picto($langs->trans("Activated"),'switch_on'); - -} -else -{ - print ''; - print img_picto($langs->trans("Disabled"),'switch_off'); -} -print ''; -print ''; -*/ - -/* -// COMPANY_USE_SEARCH_TO_SELECT - +// Default Prospect/Customer thirdparty type on customer création print ''; -print ''.$langs->trans("HideClosedThirdpartyComboBox").''; -if (! empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) -{ - print ''; - print img_picto($langs->trans("Activated"),'switch_on'); - print ''; -} -else -{ - print ''; - print img_picto($langs->trans("Disabled"),'switch_off'); - print ''; -} +print ''.$langs->trans("DefaultCustomerType").''; +print ''; +print $formcompany->selectProspectCustomerType($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT,'defaultcustomertype','defaultcustomertype','admin'); +print ''; +print ''; +print ''; +print ''; print ''; -*/ print ''; print ''; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index bde8dffbb8f..d1ac49813f7 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -937,7 +937,13 @@ else $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")=='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 +1185,8 @@ else print ''.$form->editfieldkey('ProspectCustomer', 'customerprospect', '', $object, 0, 'string', '', 1).''; print ''; $selected=GETPOST('client', 'int')!=''?GETPOST('client', 'int'):$object->client; - print ''; + print $formcompany->selectProspectCustomerType($selected,'client'); + print ''; print ''.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).''; print ''; - print ''; + print ''; print '
'; @@ -1770,12 +1771,9 @@ else // Prospect/Customer print '
'.$form->editfieldkey('ProspectCustomer', 'customerprospect', '', $object, 0, 'string', '', 1).''; + print $formcompany->selectProspectCustomerType($object->client,'client'); + print ''.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).''; print ''; } // Prospect level From 813a7a008511d9ac3c146b5beda6dde25397867d Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 6 Feb 2019 10:57:11 +0100 Subject: [PATCH 2/5] remove comment --- htdocs/societe/list.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 23e40ccc317..9258cd56ba6 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -832,13 +832,6 @@ if (! empty($arrayfields['customerorsupplier']['checked'])) print ''; } // Prospect level From 3f6187fe120b477738690c631023adb49319ea5d Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 6 Feb 2019 10:58:40 +0100 Subject: [PATCH 3/5] remove useless parameters --- htdocs/societe/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index d1ac49813f7..a2c2acdd9a7 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1185,7 +1185,7 @@ else print ''; print ''; print ''; print ''; print '
'; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 9a3dd044923..23e40ccc317 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -831,13 +831,14 @@ if (! empty($arrayfields['customerorsupplier']['checked'])) { print ''; if ($type != '') print ''; - print ''; print ''; if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print ''; if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print ''; //if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print ''; print ''; - print ''; + print '';*/ print ''; if ($type != '') print ''; print $formcompany->selectProspectCustomerType($search_type,'search_type', 'search_type', 'list'); - /*print '
'.$form->editfieldkey('ProspectCustomer', 'customerprospect', '', $object, 0, 'string', '', 1).''; $selected=GETPOST('client', 'int')!=''?GETPOST('client', 'int'):$object->client; - print $formcompany->selectProspectCustomerType($selected,'client'); + print $formcompany->selectProspectCustomerType($selected); print ''.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).''; @@ -1772,7 +1772,7 @@ else // Prospect/Customer print '
'.$form->editfieldkey('ProspectCustomer', 'customerprospect', '', $object, 0, 'string', '', 1).''; - print $formcompany->selectProspectCustomerType($object->client,'client'); + print $formcompany->selectProspectCustomerType($object->client); print ''.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).''; From f0f0b69d87d0ea04a49d3045f392868391330202 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 6 Feb 2019 10:59:24 +0100 Subject: [PATCH 4/5] add comment --- htdocs/societe/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index a2c2acdd9a7..69f3f9b880d 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -937,6 +937,7 @@ else $object->client=-1; if (! empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT)) { $object->client=3; } } + // Prospect / Customer if (GETPOST("type")=='c') { if (! empty($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT)) { $object->client=$conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT; From 6ee5a9e2a6784ee508aee3b9638c9f3835296313 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 7 Feb 2019 12:21:33 +0100 Subject: [PATCH 5/5] fix travis --- htdocs/core/class/html.formcompany.class.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index d28b867dc93..282320444cd 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -889,7 +889,18 @@ class FormCompany } } - function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname='customerprospect', $typeinput='form',$morecss = '') { + /** + * 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;