From 3f0aef062eb346d447d7985028dfbde803cbf220 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Oct 2024 19:09:00 +0200 Subject: [PATCH] Standardize code --- .../adherents/class/adherent_type.class.php | 22 +++++++++++++ htdocs/adherents/type.php | 33 +++++++++++++++---- htdocs/langs/en_US/members.lang | 4 +-- htdocs/theme/eldy/global.inc.php | 3 +- 4 files changed, 53 insertions(+), 9 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index a6b0ebe0513..2947f20b158 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -143,6 +143,28 @@ class AdherentType extends CommonObject public $multilangs = array(); + // BEGIN MODULEBUILDER PROPERTIES + /** + * @inheritdoc + * Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields = array( + "rowid" => array("type" => "integer", "label" => "TechnicalID", "enabled" => "1", 'position' => 10, 'notnull' => 1, "visible" => "-1",), + "tms" => array("type" => "timestamp", "label" => "DateModification", "enabled" => "1", 'position' => 20, 'notnull' => 1, "visible" => "-1",), + "statut" => array("type" => "smallint(6)", "label" => "Statut", "enabled" => "1", 'position' => 500, 'notnull' => 1, "visible" => "-1",), + "libelle" => array("type" => "varchar(50)", "label" => "Label", "enabled" => "1", 'position' => 30, 'notnull' => 1, "visible" => "-1",), + "subscription" => array("type" => "varchar(3)", "label" => "Subscription", "enabled" => "1", 'position' => 35, 'notnull' => 1, "visible" => "-1",), + "amount" => array("type" => "double(24,8)", "label" => "Amount", "enabled" => "1", 'position' => 40, 'notnull' => 0, "visible" => "-1",), + "caneditamount" => array("type" => "integer", "label" => "Caneditamount", "enabled" => "1", 'position' => 45, 'notnull' => 0, "visible" => "-1",), + "vote" => array("type" => "varchar(3)", "label" => "Vote", "enabled" => "1", 'position' => 50, 'notnull' => 1, "visible" => "-1",), + "note" => array("type" => "longtext", "label" => "Note", "enabled" => "1", 'position' => 55, 'notnull' => 0, "visible" => "-1",), + "mail_valid" => array("type" => "longtext", "label" => "Mailvalid", "enabled" => "1", 'position' => 60, 'notnull' => 0, "visible" => "-1",), + "morphy" => array("type" => "varchar(3)", "label" => "Morphy", "enabled" => "1", 'position' => 65, 'notnull' => 0, "visible" => "-1",), + "duration" => array("type" => "varchar(6)", "label" => "Duration", "enabled" => "1", 'position' => 70, 'notnull' => 0, "visible" => "-1",), + ); + // END MODULEBUILDER PROPERTIES + + /** * Constructor * diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 478402f3018..1f2916e0957 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -100,6 +100,25 @@ $hookmanager->initHooks(array('membertypecard', 'globalcard')); // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); + +// Definition of array of fields for columns +$tableprefix = 't'; +$arrayfields = array(); +foreach ($object->fields as $key => $val) { + // If $val['visible']==0, then we never show the field + if (!empty($val['visible'])) { + $visible = (int) dol_eval((string) $val['visible'], 1); + $arrayfields[$tableprefix.'.'.$key] = array( + 'label' => $val['label'], + 'checked' => (($visible < 0) ? 0 : 1), + 'enabled' => (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)), + 'position' => $val['position'], + 'help' => isset($val['help']) ? $val['help'] : '' + ); + } +} + + // Security check $result = restrictedArea($user, 'adherent', $rowid, 'adherent_type'); @@ -420,16 +439,18 @@ if (!$rowid && $action != 'create' && $action != 'edit') { $i++; } + // Show total line + include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + // If no record found if ($num == 0) { - /*$colspan = 1; + $colspan = 1; foreach ($arrayfields as $key => $val) { - if (!empty($val['checked'])) { + //if (!empty($val['checked'])) { $colspan++; - } - }*/ - $colspan = 9; - print ''.$langs->trans("NoRecordFound").''; + //} + } + print ''.$langs->trans("NoRecordFound").''; } print ""; diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 4434ad072ac..8f444e389ba 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -99,8 +99,8 @@ SubscriptionRequiredDesc=If subscription is required, a subscription with a star DeleteType=Delete VoteAllowed=Vote allowed Physical=Individual -Moral=Corporation -MorAndPhy=Corporation and Individual +Moral=Legal entty +MorAndPhy=Legal entity and Individual Reenable=Re-enable ExcludeMember=Exclude a member Exclude=Exclude diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index ab56a7e4fb8..5f0fffe3db6 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -3887,10 +3887,11 @@ a.tabTitle { .imgTabTitle { max-height: 14px; } +/* div.tabs div.tabsElem:first-of-type a.tab { margin-left: 0px !important; } - +*/ a.tabunactive { color: var(--colortextlink) !important; }