From b2ae991501c090c5847133cbc06725e504a64b7c Mon Sep 17 00:00:00 2001 From: atm-thibaultf Date: Wed, 30 Aug 2023 17:08:57 +0200 Subject: [PATCH 001/238] NEW_hide_external_user_in_combobox --- htdocs/admin/user.php | 25 +++++++++++++++++++ .../html.formadvtargetemailing.class.php | 3 +++ htdocs/core/class/html.form.class.php | 3 +++ htdocs/core/class/html.formother.class.php | 6 +++++ htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/fr_FR/admin.lang | 1 + test.php | 3 +++ 7 files changed, 42 insertions(+) create mode 100644 test.php diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index 20eb7a0c0b2..b6c0bcebbfd 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -116,6 +116,15 @@ if ($action == 'set_default') { } else { dol_print_error($db); } +} elseif ($action == 'sethideexternaluser') { + //Set hide external user into combox or select +$status = GETPOST('status', 'alpha'); + +if (dolibarr_set_const($db, "USER_HIDE_EXTERNAL_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity) > 0) { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; +} else { + dol_print_error($db); } @@ -184,6 +193,22 @@ if ($conf->use_javascript_ajax) { } print ''; +print ''; +print ''.$langs->trans("UserHideExternal").''; +print ' '; + +print ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('USER_HIDE_EXTERNAL_IN_COMBOBOX'); +} else { + if (empty($conf->global->USER_HIDE_EXTERNAL_IN_COMBOBOX)) { + print ''.img_picto($langs->trans("Disabled"), 'off').''; + } else { + print ''.img_picto($langs->trans("Enabled"), 'on').''; + } +} +print ''; + print ''; print ''; diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 50169438baa..00d31aac368 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -171,6 +171,9 @@ class FormAdvTargetEmailing extends Form if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) { $sql_usr .= " AND u2.statut<>0 "; } + if (!empty($conf->global->USER_HIDE_EXTERNAL_IN_COMBOBOX)) { + $sql_usr .= " AND u2.employee<>0 "; + } $sql_usr .= " ORDER BY name ASC"; // print $sql_usr;exit; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8f11af63f4a..117a56d42cd 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2050,6 +2050,9 @@ class Form if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $notdisabled) { $sql .= " AND u.statut <> 0"; } + if (!empty($conf->global->USER_HIDE_EXTERNAL_IN_COMBOBOX) || $notdisabled) { + $sql .= " AND u.employee <> 0"; + } if (!empty($morefilter)) { $sql .= " " . $morefilter; } diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index cce5cf7819d..b87ecc60f71 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -512,6 +512,12 @@ class FormOther if (!empty($user->socid)) { $sql_usr .= " AND u.fk_soc = ".((int) $user->socid); } + if (!empty($conf->global->USER_HIDE_EXTERNAL_IN_COMBOBOX)) { + $sql_usr .= " AND u.employee <> 0"; + } + if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) { + $sql_usr .= " AND u.statut <> 0"; + } //Add hook to filter on user (for exemple on usergroup define in custom modules) if (!empty($reshook)) { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 9c5d62fc38b..f809db92a95 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1416,6 +1416,7 @@ DisableForgetPasswordLinkOnLogonPage=Do not show the "Password Forgotten" link o UsersSetup=Users module setup UserMailRequired=Email required to create a new user UserHideInactive=Hide inactive users from all combo lists of users (Not recommended: this may means you won't be able to filter or search on old users on some pages) +UserHideExternal=Hide external users from all combo lists of users (Not recommended: this may means you won't be able to filter or search on external users on some pages) UsersDocModules=Document templates for documents generated from user record GroupsDocModules=Document templates for documents generated from a group record ##### HRM setup ##### diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 4fc55bfd30b..33a0314f83a 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1413,6 +1413,7 @@ DisableForgetPasswordLinkOnLogonPage=Cacher le lien "Mot de passe oublié" sur l UsersSetup=Configuration du module utilisateurs UserMailRequired=Email requis pour créer un nouvel utilisateur UserHideInactive=Masquer les utilisateurs inactifs sur toutes les listes déroulantes d'utilisateurs (non recommandé: cela peut signifier que vous ne pourrez pas filtrer ou rechercher les anciens utilisateurs sur certaines pages) +UserHideExternal=Masquer les utilisateurs externes (non salariés) sur toutes les listes déroulantes d'utilisateurs (non recommandé: cela peut signifier que vous ne pourrez pas filtrer ou rechercher les utilisateurs externes sur certaines pages) UsersDocModules=Modèles de documents pour les documents générés à partir de la fiche utilisateur GroupsDocModules=Modèles de documents pour les documents générés à partir de la fiche d'un groupe ##### HRM setup ##### diff --git a/test.php b/test.php new file mode 100644 index 00000000000..bacfe6c3edc --- /dev/null +++ b/test.php @@ -0,0 +1,3 @@ + From 81038fbfe744e5298dc471d92d0bfed3fdbec7f7 Mon Sep 17 00:00:00 2001 From: atm-thibaultf Date: Wed, 30 Aug 2023 17:30:40 +0200 Subject: [PATCH 002/238] Clean branch --- htdocs/admin/user.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index b6c0bcebbfd..16592f09dff 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -118,13 +118,13 @@ if ($action == 'set_default') { } } elseif ($action == 'sethideexternaluser') { //Set hide external user into combox or select -$status = GETPOST('status', 'alpha'); - -if (dolibarr_set_const($db, "USER_HIDE_EXTERNAL_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; -} else { - dol_print_error($db); + $status = GETPOST('status', 'alpha'); + if (dolibarr_set_const($db, "USER_HIDE_EXTERNAL_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity) > 0) { + header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } From 3fc49660da156717074d7a27482e557f6cbcf560 Mon Sep 17 00:00:00 2001 From: Thibault Fiacre <57494317+atm-thibaultf@users.noreply.github.com> Date: Wed, 30 Aug 2023 17:36:27 +0200 Subject: [PATCH 003/238] Delete test.php --- test.php | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 test.php diff --git a/test.php b/test.php deleted file mode 100644 index bacfe6c3edc..00000000000 --- a/test.php +++ /dev/null @@ -1,3 +0,0 @@ - From 199e5c1a467ed500b38d5f14563857806cc67877 Mon Sep 17 00:00:00 2001 From: atm-thibaultf Date: Tue, 5 Sep 2023 14:34:21 +0200 Subject: [PATCH 004/238] NEW hide external and non employee users in combobox --- htdocs/admin/user.php | 30 +++++++++++++++++++ .../html.formadvtargetemailing.class.php | 5 +++- htdocs/core/class/html.form.class.php | 5 +++- htdocs/core/class/html.formother.class.php | 5 +++- htdocs/langs/en_US/admin.lang | 3 +- htdocs/langs/fr_FR/admin.lang | 3 +- 6 files changed, 46 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index 16592f09dff..fa116202a1c 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -125,6 +125,16 @@ if ($action == 'set_default') { } else { dol_print_error($db); } +} elseif ($action == 'sethidenonemployeeuser') { + //Set hide non employee user into combox or select + $status = GETPOST('status', 'alpha'); + + if (dolibarr_set_const($db, "USER_HIDE_NONEMPLOYEE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity) > 0) { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } @@ -193,6 +203,26 @@ if ($conf->use_javascript_ajax) { } print ''; +// user hide non employee + +print ''; +print ''.$langs->trans("UserHideNonEmployee").''; +print ' '; + +print ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('USER_HIDE_NONEMPLOYEE_IN_COMBOBOX'); +} else { + if (empty($conf->global->USER_HIDE_NONEMPLOYEE_IN_COMBOBOX)) { + print ''.img_picto($langs->trans("Disabled"), 'off').''; + } else { + print ''.img_picto($langs->trans("Enabled"), 'on').''; + } +} +print ''; + +// user hide external + print ''; print ''.$langs->trans("UserHideExternal").''; print ' '; diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 00d31aac368..ab50676106d 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -171,9 +171,12 @@ class FormAdvTargetEmailing extends Form if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) { $sql_usr .= " AND u2.statut<>0 "; } - if (!empty($conf->global->USER_HIDE_EXTERNAL_IN_COMBOBOX)) { + if (!empty($conf->global->USER_HIDE_NONEMPLOYEE_IN_COMBOBOX)) { $sql_usr .= " AND u2.employee<>0 "; } + if (!empty($conf->global->USER_HIDE_EXTERNAL_IN_COMBOBOX)) { + $sql_usr .= " AND u2.fk_soc IS NULL "; + } $sql_usr .= " ORDER BY name ASC"; // print $sql_usr;exit; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8f17a927c2c..e7f8a24b91f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2082,9 +2082,12 @@ class Form if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $notdisabled) { $sql .= " AND u.statut <> 0"; } - if (!empty($conf->global->USER_HIDE_EXTERNAL_IN_COMBOBOX) || $notdisabled) { + if (!empty($conf->global->USER_HIDE_NONEMPLOYEE_IN_COMBOBOX) || $notdisabled) { $sql .= " AND u.employee <> 0"; } + if (!empty($conf->global->USER_HIDE_EXTERNAL_IN_COMBOBOX) || $notdisabled) { + $sql .= " AND u.fk_soc IS NULL"; + } if (!empty($morefilter)) { $sql .= " " . $morefilter; } diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 8ebb9538530..c6cfa14cf15 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -513,9 +513,12 @@ class FormOther if (!empty($user->socid)) { $sql_usr .= " AND u.fk_soc = ".((int) $user->socid); } - if (!empty($conf->global->USER_HIDE_EXTERNAL_IN_COMBOBOX)) { + if (!empty($conf->global->USER_HIDE_NONEMPLOYEE_IN_COMBOBOX)) { $sql_usr .= " AND u.employee <> 0"; } + if (!empty($conf->global->USER_HIDE_EXTERNAL_IN_COMBOBOX)) { + $sql_usr .= " AND u.fk_soc IS NULL"; + } if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) { $sql_usr .= " AND u.statut <> 0"; } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 0082c1a4e86..2e169294fde 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1419,7 +1419,8 @@ DisableForgetPasswordLinkOnLogonPage=Do not show the "Password Forgotten" link o UsersSetup=Users module setup UserMailRequired=Email required to create a new user UserHideInactive=Hide inactive users from all combo lists of users (Not recommended: this may means you won't be able to filter or search on old users on some pages) -UserHideExternal=Hide external users from all combo lists of users (Not recommended: this may means you won't be able to filter or search on external users on some pages) +UserHideExternal=Hide external users (not linked to a third party) from all combo lists of users (Not recommended: this may means you won't be able to filter or search on external users on some pages) +UserHideNonEmployee=Hide non employee users from all combo lists of users (Not recommended: this may means you won't be able to filter or search on non employee users on some pages) UsersDocModules=Document templates for documents generated from user record GroupsDocModules=Document templates for documents generated from a group record ##### HRM setup ##### diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 001c48bf5de..a84774cf925 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1419,7 +1419,8 @@ DisableForgetPasswordLinkOnLogonPage=Cacher le lien "Mot de passe oublié" sur l UsersSetup=Configuration du module utilisateurs UserMailRequired=Email requis pour créer un nouvel utilisateur UserHideInactive=Masquer les utilisateurs inactifs sur toutes les listes déroulantes d'utilisateurs (non recommandé: cela peut signifier que vous ne pourrez pas filtrer ou rechercher les anciens utilisateurs sur certaines pages) -UserHideExternal=Masquer les utilisateurs externes (non salariés) sur toutes les listes déroulantes d'utilisateurs (non recommandé: cela peut signifier que vous ne pourrez pas filtrer ou rechercher les utilisateurs externes sur certaines pages) +UserHideExternal=Masquer les utilisateurs externes (non liés à un tiers) sur toutes les listes déroulantes d'utilisateurs (non recommandé: cela peut signifier que vous ne pourrez pas filtrer ou rechercher les utilisateurs externes sur certaines pages) +UserHideNonEmployee=Masquer les utilisateurs externes (non salariés) sur toutes les listes déroulantes d'utilisateurs (non recommandé: cela peut signifier que vous ne pourrez pas filtrer ou rechercher les utilisateurs non salariés sur certaines pages) UsersDocModules=Modèles de documents pour les documents générés à partir de la fiche utilisateur GroupsDocModules=Modèles de documents pour les documents générés à partir de la fiche d'un groupe ##### HRM setup ##### From 57ef86fdde55a300db3ee59089df6ee36664d25b Mon Sep 17 00:00:00 2001 From: William Mead Date: Wed, 25 Oct 2023 15:52:20 +0200 Subject: [PATCH 005/238] NEW added address, zip & town to resource object --- htdocs/resource/class/dolresource.class.php | 42 +++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index e60f6a7a352..e5b3ae43b88 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -44,6 +44,12 @@ class Dolresource extends CommonObject */ public $picto = 'resource'; + /** + * @var string address variables + */ + public $address; + public $zip; + public $town; /** * @var int ID @@ -122,6 +128,15 @@ class Dolresource extends CommonObject if (isset($this->ref)) { $this->ref = trim($this->ref); } + if (isset($this->address)) { + $this->address = trim($this->address); + } + if (isset($this->zip)) { + $this->zip = trim($this->zip); + } + if (isset($this->town)) { + $this->town = trim($this->town); + } if (isset($this->description)) { $this->description = trim($this->description); } @@ -143,6 +158,9 @@ class Dolresource extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."("; $sql .= "entity,"; $sql .= "ref,"; + $sql .= "address,"; + $sql .= "zip,"; + $sql .= "town,"; $sql .= "description,"; $sql .= "fk_country,"; $sql .= "fk_code_type_resource,"; @@ -219,6 +237,9 @@ class Dolresource extends CommonObject $sql .= " t.rowid,"; $sql .= " t.entity,"; $sql .= " t.ref,"; + $sql .= " t.address,"; + $sql .= " t.zip,"; + $sql .= " t.town,"; $sql .= " t.description,"; $sql .= " t.fk_country,"; $sql .= " t.fk_code_type_resource,"; @@ -243,6 +264,9 @@ class Dolresource extends CommonObject $this->id = $obj->rowid; $this->entity = $obj->entity; $this->ref = $obj->ref; + $this->address = $obj->address; + $this->zip = $obj->zip; + $this->town = $obj->zip; $this->description = $obj->description; $this->country_id = $obj->fk_country; $this->fk_code_type_resource = $obj->fk_code_type_resource; @@ -281,6 +305,15 @@ class Dolresource extends CommonObject if (isset($this->ref)) { $this->ref = trim($this->ref); } + if (isset($this->address)) { + $this->address = trim($this->address); + } + if (isset($this->zip)) { + $this->zip = trim($this->zip); + } + if (isset($this->town)) { + $this->town = trim($this->town); + } if (isset($this->fk_code_type_resource)) { $this->fk_code_type_resource = trim($this->fk_code_type_resource); } @@ -299,6 +332,9 @@ class Dolresource extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; + $sql .= " address=".(isset($this->address) ? "'".$this->db->escape($this->address)."'" : "null").","; + $sql .= " zip=".(isset($this->zip) ? "'".$this->db->escape($this->zip)."'" : "null").","; + $sql .= " town=".(isset($this->town) ? "'".$this->db->escape($this->town)."'" : "null").","; $sql .= " description=".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").","; $sql .= " fk_country=".($this->country_id > 0 ? $this->country_id : "null").","; $sql .= " fk_code_type_resource=".(isset($this->fk_code_type_resource) ? "'".$this->db->escape($this->fk_code_type_resource)."'" : "null").","; @@ -517,6 +553,9 @@ class Dolresource extends CommonObject $sql .= " t.rowid,"; $sql .= " t.entity,"; $sql .= " t.ref,"; + $sql .= " t.address,"; + $sql .= " t.zip,"; + $sql .= " t.town,"; $sql .= " t.description,"; $sql .= " t.fk_country,"; $sql .= " t.fk_code_type_resource,"; @@ -560,6 +599,9 @@ class Dolresource extends CommonObject $line = new Dolresource($this->db); $line->id = $obj->rowid; $line->ref = $obj->ref; + $line->address = $obj->address; + $line->zip = $obj->zip; + $line->town = $obj->town; $line->description = $obj->description; $line->country_id = $obj->fk_country; $line->fk_code_type_resource = $obj->fk_code_type_resource; From 19484ac5d5700b6cfb39affd81f7f18c864b2920 Mon Sep 17 00:00:00 2001 From: William Mead Date: Wed, 25 Oct 2023 17:03:24 +0200 Subject: [PATCH 006/238] Added getBannerAddress method. Fixed fetching town. --- htdocs/resource/class/dolresource.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index e5b3ae43b88..4c6f99e6b26 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -266,7 +266,7 @@ class Dolresource extends CommonObject $this->ref = $obj->ref; $this->address = $obj->address; $this->zip = $obj->zip; - $this->town = $obj->zip; + $this->town = $obj->town; $this->description = $obj->description; $this->country_id = $obj->fk_country; $this->fk_code_type_resource = $obj->fk_code_type_resource; @@ -969,4 +969,12 @@ class Dolresource extends CommonObject return -1; } } + + /** + * @return string + */ + public function getBannerAddress() + { + return $this->getFullAddress(1,', '); + } } From 5871f1902746f2a09a56533498ca8b266ad6ef5c Mon Sep 17 00:00:00 2001 From: William Mead Date: Wed, 25 Oct 2023 17:03:52 +0200 Subject: [PATCH 007/238] Cleaned code --- htdocs/resource/card.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 3ee118d06c7..b0830755414 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -276,12 +276,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) { $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - $morehtmlref .= '
'; - - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref'); print '
'; From 40d22cf012cd5c1f6a6f55897a5b4ac2a8485ef6 Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 26 Oct 2023 09:09:26 +0200 Subject: [PATCH 008/238] Added address, zip & town form fields. Moved country field. --- htdocs/resource/card.php | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index b0830755414..301a02f8576 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -222,6 +222,34 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) { print ''.$langs->trans("ResourceFormLabel_ref").''; print ''; + // Address + print ''.$form->editfieldkey('Address', 'address', '', $object, 0).''; + print ''; + print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent'); + print ''; + + // Zip / Town + print ''.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).'browser->layout == 'phone' ? ' colspan="3"': '').'>'; + print $formresource->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100'); + print ''; + if ($conf->browser->layout == 'phone') { + print ''; + } + print ''.$form->editfieldkey('Town', 'town', '', $object, 0).'browser->layout == 'phone' ? ' colspan="3"': '').'>'; + print $formresource->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); + print $form->widgetForTranslation("town", $object, $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent'); + print ''; + + // Origin country + print ''.$langs->trans("CountryOrigin").''; + print $form->select_country($object->country_id, 'country_id'); + if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } + print ''; + // Type print ''.$langs->trans("ResourceType").''; print ''; @@ -236,14 +264,6 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) { $doleditor->Create(); print ''; - // Origin country - print ''.$langs->trans("CountryOrigin").''; - print $form->select_country($object->country_id, 'country_id'); - if ($user->admin) { - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } - print ''; - // Other attributes $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook From f685eb66f67ef1c150df1dd3e6442b666b632809 Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 26 Oct 2023 09:09:57 +0200 Subject: [PATCH 009/238] Added select_ziptown method --- .../class/html.formresource.class.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 527fa93a483..ef7101a12a5 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -239,4 +239,38 @@ class FormResource print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return a select list with zip codes and their town + * + * @param string $selected Preselected value + * @param string $htmlname HTML select name + * @param array $fields Array with key of fields to refresh after selection + * @param int $fieldsize Field size + * @param int $disableautocomplete 1 To disable ajax autocomplete features (browser autocomplete may still occurs) + * @param string $moreattrib Add more attribute on HTML input field + * @param string $morecss More css + * @return string + */ + public function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = array(), $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '') + { + // phpcs:enable + global $conf; + + $out = ''; + + $size = ''; + if (!empty($fieldsize)) { + $size = 'size="' . $fieldsize . '"'; + } + + if ($conf->use_javascript_ajax && empty($disableautocomplete)) { + $out .= ajax_multiautocompleter($htmlname, $fields, DOL_URL_ROOT . '/core/ajax/ziptown.php') . "\n"; + $moreattrib .= ' autocomplete="off"'; + } + $out .= '' . "\n"; + + return $out; + } } From 905471fbdd7eecb1efe766eb0e181ff68bf78cba Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 26 Oct 2023 09:30:10 +0200 Subject: [PATCH 010/238] Added address, zip & town to add, update & get logic. --- htdocs/resource/card.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 301a02f8576..326ad5a40ed 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -39,9 +39,12 @@ $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); $ref = GETPOST('ref', 'alpha'); +$address = GETPOST('address', 'alpha'); +$zip = GETPOST('zipcode', 'alpha'); +$town = GETPOST('town', 'alpha'); $description = GETPOST('description', 'restricthtml'); $confirm = GETPOST('confirm', 'aZ09'); -$fk_code_type_resource = GETPOST('fk_code_type_resource', 'alpha'); +$fk_code_type_resource = GETPOST('fk_code_type_resource', 'alpha'); $country_id = GETPOST('country_id', 'int'); // Protection if external user @@ -98,6 +101,9 @@ if (empty($reshook)) { $action = 'create'; } else { $object->ref = $ref; + $object->address = $address; + $object->zip = $zip; + $object->town = $town; $object->description = $description; $object->fk_code_type_resource = $fk_code_type_resource; $object->country_id = $country_id; @@ -138,6 +144,9 @@ if (empty($reshook)) { $res = $object->fetch($id); if ($res > 0) { $object->ref = $ref; + $object->address = $address; + $object->zip = $zip; + $object->town = $town; $object->description = $description; $object->fk_code_type_resource = $fk_code_type_resource; $object->country_id = $country_id; From 96d9b1c7925514b446f3986e1d57cd56c8c1e845 Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 26 Oct 2023 11:44:42 +0200 Subject: [PATCH 011/238] Added address state --- htdocs/resource/card.php | 20 ++++++++++++++++++++ htdocs/resource/class/dolresource.class.php | 18 +++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 326ad5a40ed..cc84eb6275e 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -46,6 +46,7 @@ $description = GETPOST('description', 'restricthtml'); $confirm = GETPOST('confirm', 'aZ09'); $fk_code_type_resource = GETPOST('fk_code_type_resource', 'alpha'); $country_id = GETPOST('country_id', 'int'); +$state_id = GETPOST('state_id', 'int'); // Protection if external user if ($user->socid > 0) { @@ -107,6 +108,7 @@ if (empty($reshook)) { $object->description = $description; $object->fk_code_type_resource = $fk_code_type_resource; $object->country_id = $country_id; + $object->state_id = $state_id; // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -150,6 +152,7 @@ if (empty($reshook)) { $object->description = $description; $object->fk_code_type_resource = $fk_code_type_resource; $object->country_id = $country_id; + $object->state_id = $state_id; // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); @@ -259,6 +262,23 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) { } print ''; + // State + if (empty($conf->global->SOCIETE_DISABLE_STATE)) { + if ((getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 1 || getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 2)) { + print ''.$form->editfieldkey('Region-State', 'state_id', '', $object, 0).''; + } else { + print ''.$form->editfieldkey('State', 'state_id', '', $object, 0).''; + } + + if ($object->country_id) { + print img_picto('', 'state', 'class="pictofixedwidth"'); + print $formresource->select_state($object->state_id, $object->country_code); + } else { + print $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; + } + print ''; + } + // Type print ''.$langs->trans("ResourceType").''; print ''; diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 4c6f99e6b26..0d80b2e08e8 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -63,8 +63,11 @@ class Dolresource extends CommonObject */ public $description; + /** + * @var int ID + */ public $fk_country; - + public $fk_state; // Variable for a link of resource @@ -143,6 +146,9 @@ class Dolresource extends CommonObject if (!is_numeric($this->country_id)) { $this->country_id = 0; } + if (!is_numeric($this->state_id)) { + $this->state_id = 0; + } if (isset($this->fk_code_type_resource)) { $this->fk_code_type_resource = trim($this->fk_code_type_resource); } @@ -163,6 +169,7 @@ class Dolresource extends CommonObject $sql .= "town,"; $sql .= "description,"; $sql .= "fk_country,"; + $sql .= "fk_state,"; $sql .= "fk_code_type_resource,"; $sql .= "note_public,"; $sql .= "note_private"; @@ -171,6 +178,7 @@ class Dolresource extends CommonObject $sql .= " ".(!isset($this->ref) ? 'NULL' : "'".$this->db->escape($this->ref)."'").","; $sql .= " ".(!isset($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").","; $sql .= " ".($this->country_id > 0 ? $this->country_id : 'null').","; + $sql .= " ".($this->state_id > 0 ? $this->state_id : 'null').","; $sql .= " ".(!isset($this->fk_code_type_resource) ? 'NULL' : "'".$this->db->escape($this->fk_code_type_resource)."'").","; $sql .= " ".(!isset($this->note_public) ? 'NULL' : "'".$this->db->escape($this->note_public)."'").","; $sql .= " ".(!isset($this->note_private) ? 'NULL' : "'".$this->db->escape($this->note_private)."'"); @@ -242,6 +250,7 @@ class Dolresource extends CommonObject $sql .= " t.town,"; $sql .= " t.description,"; $sql .= " t.fk_country,"; + $sql .= " t.fk_state,"; $sql .= " t.fk_code_type_resource,"; $sql .= " t.note_public,"; $sql .= " t.note_private,"; @@ -269,6 +278,7 @@ class Dolresource extends CommonObject $this->town = $obj->town; $this->description = $obj->description; $this->country_id = $obj->fk_country; + $this->state_id = $obj->fk_state; $this->fk_code_type_resource = $obj->fk_code_type_resource; $this->note_public = $obj->note_public; $this->note_private = $obj->note_private; @@ -323,6 +333,9 @@ class Dolresource extends CommonObject if (!is_numeric($this->country_id)) { $this->country_id = 0; } + if (!is_numeric($this->state_id)) { + $this->state_id = 0; + } // $this->oldcopy should have been set by the caller of update (here properties were already modified) if (empty($this->oldcopy)) { @@ -337,6 +350,7 @@ class Dolresource extends CommonObject $sql .= " town=".(isset($this->town) ? "'".$this->db->escape($this->town)."'" : "null").","; $sql .= " description=".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").","; $sql .= " fk_country=".($this->country_id > 0 ? $this->country_id : "null").","; + $sql .= " fk_state=".($this->state_id > 0 ? $this->state_id : "null").","; $sql .= " fk_code_type_resource=".(isset($this->fk_code_type_resource) ? "'".$this->db->escape($this->fk_code_type_resource)."'" : "null").","; $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null'); $sql .= " WHERE rowid=".((int) $this->id); @@ -558,6 +572,7 @@ class Dolresource extends CommonObject $sql .= " t.town,"; $sql .= " t.description,"; $sql .= " t.fk_country,"; + $sql .= " t.fk_state,"; $sql .= " t.fk_code_type_resource,"; $sql .= " t.tms,"; // Add fields from extrafields @@ -604,6 +619,7 @@ class Dolresource extends CommonObject $line->town = $obj->town; $line->description = $obj->description; $line->country_id = $obj->fk_country; + $line->state_id = $obj->fk_state; $line->fk_code_type_resource = $obj->fk_code_type_resource; $line->type_label = $obj->type_label; From bef4a371d07bdcef3ea00dbbc466fb3e84b5770b Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 26 Oct 2023 11:44:58 +0200 Subject: [PATCH 012/238] Added select_state method --- .../class/html.formresource.class.php | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index ef7101a12a5..2c391cf733e 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -273,4 +273,116 @@ class FormResource return $out; } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Returns the drop-down list of departments/provinces/cantons for all countries or for a given country. + * In the case of an all-country list, the display breaks on the country. + * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). + * Thus the links with the departments are done on a department independently of its name. + * + * @param int $selected Code state preselected (mus be state id) + * @param integer $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show + * @param string $htmlname Id of department. If '', we want only the string with