From 510da33c338f3f6be53cb9ec90626bcb404aeab7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 29 Jan 2025 08:35:55 +0100 Subject: [PATCH 1/6] FIX #32840 --- htdocs/categories/class/categorie.class.php | 35 ++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 330baf65469..b3721d1bee7 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -285,6 +285,38 @@ class Categorie extends CommonObject */ public $imgHeight; + /** + * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') + * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed (Example: 1 or 'getDolGlobalString("MY_SETUP_PARAM")' + * 'position' is the sort order of field. + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'noteditable' says if field is not editable (1 or 0) + * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created. + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommended to name the field fk_...). + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' is the CSS style to use on field. For example: 'maxwidth200' + * 'help' is a string visible as a tooltip on field + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. + * 'arrayofkeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1. + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * + * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. + */ + + /** + * @var array|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields = array( + 'label' => array('type' => 'varchar(255)', 'label' => 'Label', 'enabled' => 1, 'visible' => 1, 'showoncombobox' => 1), + ); + /** * Constructor * @@ -1751,7 +1783,8 @@ class Categorie extends CommonObject } // Check contrast with background and correct text color - $forced_color = 'categtextwhite'; + //$forced_color = 'categtextwhite'; // TODO This css class hide the link + $forced_color = 'categtextblack'; if ($this->color) { if (colorIsLight($this->color)) { $forced_color = 'categtextblack'; From e7088d779415b158720aa3081ca01a44f30ec31c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 29 Jan 2025 09:14:37 +0100 Subject: [PATCH 2/6] FIX add other fields --- htdocs/categories/class/categorie.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index b3721d1bee7..305649da4e4 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -314,7 +314,9 @@ class Categorie extends CommonObject * @var array|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( - 'label' => array('type' => 'varchar(255)', 'label' => 'Label', 'enabled' => 1, 'visible' => 1, 'showoncombobox' => 1), + 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'index' => 1, 'position' => 1, 'comment' => 'Id'), + 'entity' => array('type' => 'integer', 'label' => 'Entity', 'enabled' => 1, 'visible' => 0, 'default' => '1', 'notnull' => 1, 'index' => 1, 'position' => 5), + 'label' => array('type' => 'varchar(255)', 'label' => 'Label', 'enabled' => 1, 'visible' => 1, 'showoncombobox' => 1, 'position' => 15, 'csslist' => 'tdoverflowmax250'), ); /** From 4fc66c6ee16062b44747ce3442e8be307af53570 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 29 Jan 2025 19:44:50 +0100 Subject: [PATCH 3/6] FIX missing quick edit for extrafields --- htdocs/core/tpl/extrafields_view.tpl.php | 3 +++ htdocs/projet/card.php | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 10481b4ad10..26c11f099a6 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -159,6 +159,9 @@ if (empty($reshook) && !empty($object->table_element) && isset($extrafields->att if ($object->element == 'product') { $keyforperm = 'produit'; } + if ($object->element == 'project') { + $keyforperm = 'projet'; + } if (isset($user->rights->$keyforperm)) { $permok = $user->hasRight($keyforperm, 'creer') || $user->hasRight($keyforperm, 'create') || $user->hasRight($keyforperm, 'write'); } diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 1b17aff16af..fd6fa35d136 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -553,6 +553,30 @@ if (empty($reshook)) { } } + // Quick edit for extrafields + if ($action == 'update_extras' && $permissiontoadd) { + $object->oldcopy = dol_clone($object, 2); + + // Fill array 'array_options' with data from update form + $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); + if ($ret < 0) { + $error++; + } + + if (!$error) { + // Actions on extra fields + $result = $object->insertExtraFields('PROJECT_MODIFY'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + } + + if ($error) { + $action = 'edit_extras'; + } + } + // Actions to send emails $triggersendname = 'PROJECT_SENTBYMAIL'; $paramname = 'id'; From 65ebb94181d55c268040d50a0292617ee783e21d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 30 Jan 2025 01:12:50 +0100 Subject: [PATCH 4/6] FIX wrong var name --- htdocs/societe/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b00bb69b3fb..bc59136f69e 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1578,7 +1578,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio // Vat is used print ''.$form->editfieldkey('VATIsUsed', 'assujtva_value', '', $object, 0).''; print ''; - print ''; // Assujeti par default en creation + print ''; // Assujeti par default en creation print ''; if ($conf->browser->layout == 'phone') { print ''; From 7fa1baf1ddbf35d4710f175d1a5ad387672abcc0 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 30 Jan 2025 13:34:26 +0100 Subject: [PATCH 5/6] Fix regression --- htdocs/categories/class/categorie.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 305649da4e4..5dd92761cdb 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1785,10 +1785,9 @@ class Categorie extends CommonObject } // Check contrast with background and correct text color - //$forced_color = 'categtextwhite'; // TODO This css class hide the link - $forced_color = 'categtextblack'; + $forced_color = 'categtextwhite'; // We want color white because the background is dark (grey or other) if ($this->color) { - if (colorIsLight($this->color)) { + if (colorIsLight($this->color)) { // If color is light, we force color to dark $forced_color = 'categtextblack'; } } From 301c189c498c09272bcffe21d7bd1795fd76798c Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 30 Jan 2025 23:06:03 +0100 Subject: [PATCH 6/6] Restore full list. Close #32092 --- htdocs/hrm/class/position.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index 7d257e5d41c..2002f565869 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -97,7 +97,7 @@ class Position extends CommonObject 'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'position' => 500, 'notnull' => 1, 'visible' => -2,), 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 501, 'notnull' => 0, 'visible' => -2,), 'fk_contrat' => array('type' => 'integer:Contrat:contrat/class/contrat.class.php', 'label' => 'fk_contrat', 'enabled' => 'isModEnabled("contract")', 'position' => 50, 'notnull' => 0, 'visible' => 0,), - 'fk_user' => array('type' => 'integer:User:user/class/user.class.php:0:(t.statut:=:1)', 'label' => 'Employee', 'enabled' => 1, 'position' => 55, 'notnull' => 1, 'visible' => 1, 'default' => '0', 'picto' => 'user', 'css' => 'maxwidth300 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150'), + 'fk_user' => array('type' => 'integer:User:user/class/user.class.php:0', 'label' => 'Employee', 'enabled' => 1, 'position' => 55, 'notnull' => 1, 'visible' => 1, 'default' => '0', 'picto' => 'user', 'css' => 'maxwidth300 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150'), 'fk_job' => array('type' => 'integer:Job:/hrm/class/job.class.php', 'label' => 'JobProfile', 'enabled' => 1, 'position' => 56, 'notnull' => 1, 'visible' => 1, 'picto' => 'jobprofile', 'css' => 'maxwidth300 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150'), 'date_start' => array('type' => 'date', 'label' => 'DateStart', 'enabled' => 1, 'position' => 101, 'notnull' => 1, 'visible' => 1,), 'date_end' => array('type' => 'date', 'label' => 'DateEnd', 'enabled' => 1, 'position' => 102, 'notnull' => 0, 'visible' => 1,),