From cd289ca8ac2145b751f9b5236406c1d02f9dd1cd Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 8 Feb 2023 19:09:05 +0100 Subject: [PATCH 01/29] fix(qodana) fix function comment wrong return --- htdocs/compta/facture/class/api_invoices.class.php | 2 +- htdocs/core/ajax/fileupload.php | 1 - htdocs/core/class/dolreceiptprinter.class.php | 2 +- htdocs/core/class/fileupload.class.php | 6 ++++-- htdocs/core/class/hookmanager.class.php | 2 +- .../core/modules/asset/doc/pdf_standard_asset.modules.php | 2 +- htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php | 2 +- htdocs/core/modules/cheque/doc/pdf_blochet.class.php | 2 +- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 2 +- htdocs/core/modules/import/import_csv.modules.php | 2 +- htdocs/core/modules/import/import_xlsx.modules.php | 2 +- htdocs/core/modules/mrp/doc/pdf_vinci.modules.php | 2 +- htdocs/core/modules/product/modules_product.class.php | 2 +- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 2 +- htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 2 +- .../core/modules/supplier_order/doc/pdf_cornas.modules.php | 2 +- .../modules/supplier_order/doc/pdf_muscadet.modules.php | 2 +- .../modules/supplier_proposal/doc/pdf_aurore.modules.php | 2 +- htdocs/fourn/class/paiementfourn.class.php | 2 +- htdocs/projet/class/api_projects.class.php | 2 +- htdocs/user/class/api_users.class.php | 2 +- 21 files changed, 23 insertions(+), 22 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index bae53bce6a8..76275eadb16 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -778,7 +778,7 @@ class Invoices extends DolibarrApi * * @url POST {id}/contacts * - * @return array + * @return object * * @throws RestException 304 * @throws RestException 401 diff --git a/htdocs/core/ajax/fileupload.php b/htdocs/core/ajax/fileupload.php index 67f95700976..b57e03972f1 100644 --- a/htdocs/core/ajax/fileupload.php +++ b/htdocs/core/ajax/fileupload.php @@ -48,7 +48,6 @@ $element = GETPOST('element', 'alpha'); $upload_handler = new FileUpload(null, $fk_element, $element); - /* * View */ diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 3b10f38d238..2bc26fa324c 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -935,7 +935,7 @@ class dolReceiptPrinter extends Printer * Function Init Printer * * @param int $printerid Printer id - * @return int 0 if OK; >0 if KO + * @return void|int 0 if OK; >0 if KO */ public function initPrinter($printerid) { diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index 906933c9701..895cf6f8835 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -488,8 +488,9 @@ class FileUpload */ public function post() { + var_dump("here");exit; if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') { - return $this->delete(); + echo $this->delete(); } $upload = isset($_FILES[$this->options['param_name']]) ? $_FILES[$this->options['param_name']] : null; @@ -556,6 +557,7 @@ class FileUpload } } header('Content-type: application/json'); - echo json_encode($success); + $response = json_encode($success); + return $response; } } diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index bcd5a506946..9c0441b3ced 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -77,7 +77,7 @@ class HookManager * Then when a hook executeHooks('aMethod'...) is called, the method aMethod found into class will be executed. * * @param string[] $arraycontext Array list of searched hooks tab/features. For example: 'thirdpartycard' (for hook methods into page card thirdparty), 'thirdpartydao' (for hook methods into Societe), ... - * @return int Always 1 + * @return int|void Always 1 */ public function initHooks($arraycontext) { diff --git a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php index 8ebd1051a06..b20f60fe084 100644 --- a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php +++ b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php @@ -916,7 +916,7 @@ class pdf_standard_asset extends ModelePDFAsset * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output * @param Translate $outputlangsbis Object lang for output bis - * @return void + * @return float */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null) { diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index e296663f39a..ecf7a2a6ad9 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -478,7 +478,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc * @param CompanyBankAccount $object Object to show * @param int $posy Y * @param Translate $outputlangs Langs object - * @return void + * @return float */ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) { diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index 3985cb6be90..43db9a615e6 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -401,7 +401,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts * @param Object $object Object to show * @param Translate $outputlangs Object lang for output * @param int $hidefreetext 1=Hide free text - * @return void + * @return mixed */ protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index f24517d0667..1e9339c55e2 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -2057,7 +2057,7 @@ class pdf_sponge extends ModelePDFFactures * @param int $showaddress 0=no, 1=yes (usually set to 1 for first page, and 0 for next pages) * @param Translate $outputlangs Object lang for output * @param Translate $outputlangsbis Object lang for output bis - * @return int top shift of linked object lines + * @return array top shift of linked object lines */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null) { diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index a9a82e7cb00..1213cc4cf16 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -238,7 +238,7 @@ class ImportCsv extends ModeleImports /** * Return array of next record in input file. * - * @return Array Array of field values. Data are UTF8 encoded. [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=not empty string) + * @return array|boolean Array of field values. Data are UTF8 encoded. [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=not empty string) */ public function import_read_record() { diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 0854a0f56c5..c7f6df31d03 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -304,7 +304,7 @@ class ImportXlsx extends ModeleImports /** * Return array of next record in input file. * - * @return Array Array of field values. Data are UTF8 encoded. [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=not empty string) + * @return array|boolean Array of field values. Data are UTF8 encoded. [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=not empty string) */ public function import_read_record() { diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index 8e3eeeafa33..492385a53a3 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -1067,7 +1067,7 @@ class pdf_vinci extends ModelePDFMo * @param CommandeFournisseur $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output - * @return void + * @return float|int */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { diff --git a/htdocs/core/modules/product/modules_product.class.php b/htdocs/core/modules/product/modules_product.class.php index 3a856763144..e5f5e7e09eb 100644 --- a/htdocs/core/modules/product/modules_product.class.php +++ b/htdocs/core/modules/product/modules_product.class.php @@ -191,7 +191,7 @@ abstract class ModeleProductCode * * @param DoliDB $dbs Database handler * @param integer $maxfilenamelength Max length of value to show - * @return array List of numbers + * @return array|int List of numbers */ public static function liste_modeles($dbs, $maxfilenamelength = 0) { diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 5f637373507..9ea524f2977 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1484,7 +1484,7 @@ class pdf_azur extends ModelePDFPropales * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output * @param Translate $outputlangsbis Object lang for output bis - * @return void + * @return int|float */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null) { diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 88b56eb8fa6..8a41e680fc5 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1547,7 +1547,7 @@ class pdf_cyan extends ModelePDFPropales * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output * @param Translate $outputlangsbis Object lang for output bis - * @return void + * @return float|int */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null) { diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 186ea465568..2343885cb4d 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -1223,7 +1223,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders * @param CommandeFournisseur $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output - * @return void + * @return float|int */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 2fdf9828aff..1de4acd1550 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -1130,7 +1130,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * @param CommandeFournisseur $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output - * @return void + * @return float|int */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index ff90b500969..2f264cfb928 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -1232,7 +1232,7 @@ class pdf_aurore extends ModelePDFSupplierProposal * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output - * @return void + * @return float|int */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index bdf4f8aa457..21dae0e85b2 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -535,7 +535,7 @@ class PaiementFourn extends Paiement * Return list of supplier invoices the payment point to * * @param string $filter SQL filter. Warning: This value must not come from a user input. - * @return array Array of supplier invoice id + * @return array|int Array of supplier invoice id | <0 si ko */ public function getBillsArray($filter = '') { diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index fc10f49d38d..fa936969754 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -229,7 +229,7 @@ class Projects extends DolibarrApi * * @param int $id Id of project * @param int $includetimespent 0=Return only list of tasks. 1=Include a summary of time spent, 2=Include details of time spent lines - * @return int + * @return array * * @url GET {id}/tasks */ diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 2bbadd267cf..d91fcafffa6 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -593,7 +593,7 @@ class Users extends DolibarrApi * * @param int $group ID of group * @param int $load_members Load members list or not {@min 0} {@max 1} - * @return array Array of User objects + * @return object object of User objects * * @throws RestException 401 Not allowed * @throws RestException 404 User not found From 629f354800e591e549a3a227e19a794845d621ac Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 8 Feb 2023 19:20:55 +0100 Subject: [PATCH 02/29] fix(qodana) remove a var_dump --- htdocs/core/class/fileupload.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index 895cf6f8835..84ff0a9ed33 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -488,7 +488,6 @@ class FileUpload */ public function post() { - var_dump("here");exit; if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') { echo $this->delete(); } From 9bf878a635dab70742f2b7e8332b46c9b10f5d86 Mon Sep 17 00:00:00 2001 From: FLIO Date: Sat, 11 Feb 2023 19:23:32 +0100 Subject: [PATCH 03/29] fix (qodana) delete the edit of the fuction post in the fileupload and edit the comment --- htdocs/core/class/fileupload.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index 84ff0a9ed33..75662d57f94 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -484,12 +484,12 @@ class FileUpload /** * Output data * - * @return void + * @return string|void */ public function post() { if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') { - echo $this->delete(); + return $this->delete(); } $upload = isset($_FILES[$this->options['param_name']]) ? $_FILES[$this->options['param_name']] : null; @@ -556,7 +556,6 @@ class FileUpload } } header('Content-type: application/json'); - $response = json_encode($success); - return $response; + echo json_encode($success); } } From 92c4eed7c68eb6322e5ce294688b0f3f6340f718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 11 Feb 2023 21:34:21 +0100 Subject: [PATCH 04/29] add ajax tooltip on knowledge record --- htdocs/core/ajax/ajaxtooltip.php | 4 ++ .../class/knowledgerecord.class.php | 59 +++++++++++++++---- 2 files changed, 53 insertions(+), 10 deletions(-) diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php index 60220a221ff..3933f03533b 100644 --- a/htdocs/core/ajax/ajaxtooltip.php +++ b/htdocs/core/ajax/ajaxtooltip.php @@ -163,6 +163,10 @@ if ($objecttype == 'facture' || $objecttype == 'invoice') { $classpath = 'opensurvey/class'; $module = 'opensurvey'; $myobject = 'opensurveysondage'; +} elseif ($objecttype == 'knowledgerecord') { + $classpath = 'knowledgemanagement/class'; + $module = 'knowledgemanagement'; + $myobject = 'knowledgerecord'; } // Generic case for $classfile and $classname diff --git a/htdocs/knowledgemanagement/class/knowledgerecord.class.php b/htdocs/knowledgemanagement/class/knowledgerecord.class.php index 3f9f1b40223..d5cd5a82a51 100644 --- a/htdocs/knowledgemanagement/class/knowledgerecord.class.php +++ b/htdocs/knowledgemanagement/class/knowledgerecord.class.php @@ -129,7 +129,15 @@ class KnowledgeRecord extends CommonObject public $fk_user_valid; public $import_key; public $model_pdf; + + /** + * @var string question asked + */ public $question; + + /** + * @var string answer to question + */ public $answer; public $url; public $status; @@ -265,8 +273,8 @@ class KnowledgeRecord extends CommonObject if (property_exists($object, 'ref')) { $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; } - if (property_exists($object, 'label')) { - $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; + if (property_exists($object, 'question')) { + $object->question = empty($this->fields['question']['default']) ? $langs->trans("CopyOf")." ".$object->question : $this->fields['question']['default']; } if (property_exists($object, 'status')) { $object->status = self::STATUS_DRAFT; @@ -706,6 +714,32 @@ class KnowledgeRecord extends CommonObject return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'KNOWLEDGERECORD_REOPEN'); } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs; + + $langs->loadLangs(['knowledgemanagement', 'languages']); + + $datas = []; + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("KnowledgeRecord").''; + if (isset($this->statut)) { + $datas['picto'] .= ' '.$this->getLibStatut(5); + } + $datas['label'] = '
'.$langs->trans('Ref').': '.$this->ref; + $datas['question'] = '
'.$langs->trans('Question').': '.$this->question; + $labellang = ($this->lang ? $langs->trans('Language_'.$this->lang) : ''); + $datas['lang'] = '
'.$langs->trans('Language').': ' . picto_from_langcode($this->lang, 'class="paddingrightonly saturatemedium opacitylow"') . $labellang; + + return $datas; + } + /** * Return a link to the object card (with optionaly the picto) * @@ -726,12 +760,17 @@ class KnowledgeRecord extends CommonObject $result = ''; - $label = img_picto('', $this->picto).' '.$langs->trans("KnowledgeRecord").''; - if (isset($this->status)) { - $label .= ' '.$this->getLibStatut(5); + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); } - $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref; + $label = implode($this->getTooltipContentArray($params)); $url = dol_buildpath('/knowledgemanagement/knowledgerecord_card.php', 1).'?id='.$this->id; @@ -752,8 +791,8 @@ class KnowledgeRecord extends CommonObject $label = $langs->trans("ShowKnowledgeRecord"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + $linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } @@ -774,7 +813,7 @@ class KnowledgeRecord extends CommonObject if (empty($this->showphoto_on_popup)) { if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } } else { if ($withpicto) { From 00898291ed9f23fd3d0fa7fe6bc29f7d0abc0fd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 11 Feb 2023 21:49:06 +0100 Subject: [PATCH 05/29] add ajax tooltip on knowledge record --- .../knowledgemanagement/class/knowledgerecord.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/knowledgemanagement/class/knowledgerecord.class.php b/htdocs/knowledgemanagement/class/knowledgerecord.class.php index d5cd5a82a51..0d233f37af6 100644 --- a/htdocs/knowledgemanagement/class/knowledgerecord.class.php +++ b/htdocs/knowledgemanagement/class/knowledgerecord.class.php @@ -735,7 +735,13 @@ class KnowledgeRecord extends CommonObject $datas['label'] = '
'.$langs->trans('Ref').': '.$this->ref; $datas['question'] = '
'.$langs->trans('Question').': '.$this->question; $labellang = ($this->lang ? $langs->trans('Language_'.$this->lang) : ''); - $datas['lang'] = '
'.$langs->trans('Language').': ' . picto_from_langcode($this->lang, 'class="paddingrightonly saturatemedium opacitylow"') . $labellang; + $datas['lang'] = '
'.$langs->trans('Language').': ' . picto_from_langcode($this->lang, 'class="paddingrightonly saturatemedium opacitylow"') . $labellang; + // show categories for this record + if (isModEnabled('categorie')) { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $form = new Form($this->db); + $datas['categories'] = '
' . $form->showCategories($this->id, Categorie::TYPE_KNOWLEDGEMANAGEMENT, 1); + } return $datas; } From f50a43c8822ee1c28da21a12ab88ef3c9bfd7ebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 11 Feb 2023 21:58:57 +0100 Subject: [PATCH 06/29] add ajax tooltip on knowledge record --- htdocs/knowledgemanagement/class/knowledgerecord.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/knowledgemanagement/class/knowledgerecord.class.php b/htdocs/knowledgemanagement/class/knowledgerecord.class.php index 0d233f37af6..77493590d9d 100644 --- a/htdocs/knowledgemanagement/class/knowledgerecord.class.php +++ b/htdocs/knowledgemanagement/class/knowledgerecord.class.php @@ -728,6 +728,7 @@ class KnowledgeRecord extends CommonObject $langs->loadLangs(['knowledgemanagement', 'languages']); $datas = []; + $nofetch = empty($params['nofetch']) ? false : true; $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("KnowledgeRecord").''; if (isset($this->statut)) { $datas['picto'] .= ' '.$this->getLibStatut(5); @@ -736,8 +737,8 @@ class KnowledgeRecord extends CommonObject $datas['question'] = '
'.$langs->trans('Question').': '.$this->question; $labellang = ($this->lang ? $langs->trans('Language_'.$this->lang) : ''); $datas['lang'] = '
'.$langs->trans('Language').': ' . picto_from_langcode($this->lang, 'class="paddingrightonly saturatemedium opacitylow"') . $labellang; - // show categories for this record - if (isModEnabled('categorie')) { + // show categories for this record only in ajax to not overload lists + if (isModEnabled('categorie') && !$nofetch) { require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $form = new Form($this->db); $datas['categories'] = '
' . $form->showCategories($this->id, Categorie::TYPE_KNOWLEDGEMANAGEMENT, 1); @@ -769,6 +770,8 @@ class KnowledgeRecord extends CommonObject $params = [ 'id' => $this->id, 'objecttype' => $this->element, + 'option' => $option, + 'nofetch' => 1, ]; $classfortooltip = 'classfortooltip'; $dataparams = ''; From beba616f3c90574aa959cd05f87b9d23d993acf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 11 Feb 2023 22:13:15 +0100 Subject: [PATCH 07/29] clean code --- htdocs/api/class/api_documents.class.php | 2 +- htdocs/categories/class/api_categories.class.php | 2 +- .../modules/modKnowledgeManagement.class.php | 4 ++-- .../class/api_knowledgemanagement.class.php | 10 +++++----- .../class/knowledgerecord.class.php | 4 ++-- .../knowledgerecord_agenda.php | 2 +- .../knowledgemanagement/knowledgerecord_card.php | 16 ++++++++-------- .../knowledgerecord_contact.php | 2 +- .../knowledgerecord_document.php | 6 +++--- .../knowledgemanagement/knowledgerecord_list.php | 8 ++++---- .../knowledgemanagement/knowledgerecord_note.php | 4 ++-- htdocs/ticket/index.php | 2 +- 12 files changed, 31 insertions(+), 31 deletions(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index d4f252bfd43..8dae305a989 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -461,7 +461,7 @@ class Documents extends DolibarrApi } elseif ($modulepart == 'knowledgemanagement') { require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/class/knowledgerecord.class.php'; - if (!DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->read && !DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->read) { + if (!DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read') && !DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) { throw new RestException(401); } diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index e59ff070aec..2de1f43d071 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -323,7 +323,7 @@ class Categories extends DolibarrApi throw new RestException(401); } elseif ($type == Categorie::TYPE_PROJECT && !DolibarrApiAccess::$user->rights->projet->lire) { throw new RestException(401); - } elseif ($type == Categorie::TYPE_KNOWLEDGEMANAGEMENT && !DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->read) { + } elseif ($type == Categorie::TYPE_KNOWLEDGEMANAGEMENT && !DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) { throw new RestException(401); } diff --git a/htdocs/core/modules/modKnowledgeManagement.class.php b/htdocs/core/modules/modKnowledgeManagement.class.php index b331c56a917..68754f530b3 100644 --- a/htdocs/core/modules/modKnowledgeManagement.class.php +++ b/htdocs/core/modules/modKnowledgeManagement.class.php @@ -271,7 +271,7 @@ class modKnowledgeManagement extends DolibarrModules 'langs'=>'knowledgemanagement', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000 + $r, 'enabled'=>'$conf->knowledgemanagement->enabled', // Define condition to show or hide menu entry. Use '$conf->knowledgemanagement->enabled' if entry must be visible if module is enabled. - 'perms'=>'1', // Use 'perms'=>'$user->rights->knowledgemanagement->knowledgerecord->read' if you want your menu with a permission rules + 'perms'=>'1', // Use 'perms'=>'$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')' if you want your menu with a permission rules 'target'=>'', 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both ); @@ -334,7 +334,7 @@ class modKnowledgeManagement extends DolibarrModules // Define condition to show or hide menu entry. Use '$conf->knowledgemanagement->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'enabled'=>'$conf->knowledgemanagement->enabled', // Use 'perms'=>'$user->rights->knowledgemanagement->level1->level2' if you want your menu with a permission rules - 'perms'=>'$user->rights->knowledgemanagement->knowledgerecord->write', + 'perms'=>'$user->hasRight("knowledgemanagement", "knowledgerecord", "write")', 'target'=>'', // 0=Menu for internal users, 1=external users, 2=both 'user'=>2 diff --git a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php index 8232287b23b..0806514b968 100644 --- a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php +++ b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php @@ -70,7 +70,7 @@ class KnowledgeManagement extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->read) { + if (!DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) { throw new RestException(401); } @@ -144,7 +144,7 @@ class KnowledgeManagement extends DolibarrApi $obj_ret = array(); $tmpobject = new KnowledgeRecord($this->db); - if (!DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->read) { + if (!DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) { throw new RestException(401); } @@ -249,7 +249,7 @@ class KnowledgeManagement extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->write) { + if (!DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'write')) { throw new RestException(401); } @@ -282,7 +282,7 @@ class KnowledgeManagement extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->write) { + if (!DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'write')) { throw new RestException(401); } @@ -324,7 +324,7 @@ class KnowledgeManagement extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->delete) { + if (!DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'delete')) { throw new RestException(401); } $result = $this->knowledgerecord->fetch($id); diff --git a/htdocs/knowledgemanagement/class/knowledgerecord.class.php b/htdocs/knowledgemanagement/class/knowledgerecord.class.php index 77493590d9d..f85b2f8e9cf 100644 --- a/htdocs/knowledgemanagement/class/knowledgerecord.class.php +++ b/htdocs/knowledgemanagement/class/knowledgerecord.class.php @@ -200,7 +200,7 @@ class KnowledgeRecord extends CommonObject } // Example to show how to set values of fields definition dynamically - /*if ($user->rights->knowledgemanagement->knowledgerecord->read) { + /*if ($user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) { $this->fields['myfield']['visible'] = 1; $this->fields['myfield']['noteditable'] = 0; }*/ @@ -538,7 +538,7 @@ class KnowledgeRecord extends CommonObject return 0; } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->knowledgemanagement->knowledgerecord->write)) + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->knowledgemanagement->knowledgerecord->knowledgerecord_advance->validate)))) { $this->error='NotEnoughPermissions'; diff --git a/htdocs/knowledgemanagement/knowledgerecord_agenda.php b/htdocs/knowledgemanagement/knowledgerecord_agenda.php index e24e23b14e7..6cf8428d06b 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_agenda.php +++ b/htdocs/knowledgemanagement/knowledgerecord_agenda.php @@ -90,7 +90,7 @@ if ($id > 0 || !empty($ref)) { $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, '', 'rowid', $isdraft); -$permissiontoadd = $user->rights->knowledgemanagement->knowledgerecord->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoadd = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_addupdatedelete.inc.php /* diff --git a/htdocs/knowledgemanagement/knowledgerecord_card.php b/htdocs/knowledgemanagement/knowledgerecord_card.php index 52143048f72..495b095fb4d 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_card.php +++ b/htdocs/knowledgemanagement/knowledgerecord_card.php @@ -74,12 +74,12 @@ if (empty($action) && empty($id) && empty($ref)) { include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. -$permissiontoread = $user->rights->knowledgemanagement->knowledgerecord->read; -$permissiontovalidate = $user->rights->knowledgemanagement->knowledgerecord->write; -$permissiontoadd = $user->rights->knowledgemanagement->knowledgerecord->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->knowledgemanagement->knowledgerecord->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); -$permissionnote = $user->rights->knowledgemanagement->knowledgerecord->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->knowledgemanagement->knowledgerecord->write; // Used by the include of actions_dellink.inc.php +$permissiontoread = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'read'); +$permissiontovalidate = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); +$permissiontoadd = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissionnote = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_dellink.inc.php $upload_dir = $conf->knowledgemanagement->multidir_output[isset($object->entity) ? $object->entity : 1]; // Security check - Protection if external user @@ -538,8 +538,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $relativepath = $objref.'/'.$objref.'.pdf'; $filedir = $conf->knowledgemanagement->dir_output.'/'.$object->element.'/'.$objref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->knowledgemanagement->knowledgerecord->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->knowledgemanagement->knowledgerecord->write; // If you can create/edit, you can remove a file on card + $genallowed = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'read'); // If you can read, you can build the PDF to read content + $delallowed = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // If you can create/edit, you can remove a file on card print $formfile->showdocuments('knowledgemanagement:KnowledgeRecord', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); } diff --git a/htdocs/knowledgemanagement/knowledgerecord_contact.php b/htdocs/knowledgemanagement/knowledgerecord_contact.php index 4e557a3e1ae..751cdff5c9e 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_contact.php +++ b/htdocs/knowledgemanagement/knowledgerecord_contact.php @@ -56,7 +56,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, '', 'rowid', $isdraft); -$permission = $user->rights->knowledgemanagement->knowledgerecord->write; +$permission = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); /* diff --git a/htdocs/knowledgemanagement/knowledgerecord_document.php b/htdocs/knowledgemanagement/knowledgerecord_document.php index 7430de8a495..8d8fe6ac769 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_document.php +++ b/htdocs/knowledgemanagement/knowledgerecord_document.php @@ -81,7 +81,7 @@ if ($id > 0 || !empty($ref)) { $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, '', 'rowid', $isdraft); -$permissiontoadd = $user->rights->knowledgemanagement->knowledgerecord->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php +$permissiontoadd = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php @@ -183,9 +183,9 @@ if ($object->id) { print dol_get_fiche_end(); $modulepart = 'knowledgemanagement'; - //$permission = $user->rights->knowledgemanagement->knowledgerecord->write; + //$permission = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); $permission = 1; - //$permtoedit = $user->rights->knowledgemanagement->knowledgerecord->write; + //$permtoedit = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); $permtoedit = 1; $param = '&id='.$object->id; diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index 7cd5a24c764..3a916cb96ef 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -140,9 +140,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = $user->rights->knowledgemanagement->knowledgerecord->read; -$permissiontoadd = $user->rights->knowledgemanagement->knowledgerecord->write; -$permissiontodelete = $user->rights->knowledgemanagement->knowledgerecord->delete; +$permissiontoread = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'read'); +$permissiontoadd = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); +$permissiontodelete = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'delete'); // Security check if (empty($conf->knowledgemanagement->enabled)) { @@ -428,7 +428,7 @@ if ($permissiontodelete) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } -if (isModEnabled('category') && $user->rights->knowledgemanagement->knowledgerecord->write) { +if (isModEnabled('category') && $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write')) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } diff --git a/htdocs/knowledgemanagement/knowledgerecord_note.php b/htdocs/knowledgemanagement/knowledgerecord_note.php index 28a2bcaa9d0..ea1052ccc98 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_note.php +++ b/htdocs/knowledgemanagement/knowledgerecord_note.php @@ -52,8 +52,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->knowledgemanagement->multidir_output[$object->entity]."/".$object->id; } -$permissionnote = $user->rights->knowledgemanagement->knowledgerecord->write; // Used by the include of actions_setnotes.inc.php -$permissiontoadd = $user->rights->knowledgemanagement->knowledgerecord->write; // Used by the include of actions_addupdatedelete.inc.php +$permissionnote = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiontoadd = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_addupdatedelete.inc.php // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/ticket/index.php b/htdocs/ticket/index.php index 243084ec89f..f75a93f7082 100644 --- a/htdocs/ticket/index.php +++ b/htdocs/ticket/index.php @@ -65,7 +65,7 @@ $object = new Ticket($db); // Security check //$result = restrictedArea($user, 'ticket|knowledgemanagement', 0, '', '', '', ''); -if (empty($user->rights->ticket->read) && empty($user->rights->knowledgemanagement->knowledgerecord->read)) { +if (empty($user->rights->ticket->read) && !$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) { accessforbidden('Not enought permissions'); } From 6144b6e99d973c2c1bb289258c79856470a8eaec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 12 Feb 2023 09:54:57 +0100 Subject: [PATCH 08/29] add two widgets --- .../core/boxes/box_last_knowledgerecord.php | 187 ++++++++++++++++++ .../box_last_modified_knowledgerecord.php | 187 ++++++++++++++++++ .../modules/modKnowledgeManagement.class.php | 14 +- htdocs/langs/en_US/knowledgemanagement.lang | 8 +- 4 files changed, 389 insertions(+), 7 deletions(-) create mode 100644 htdocs/core/boxes/box_last_knowledgerecord.php create mode 100644 htdocs/core/boxes/box_last_modified_knowledgerecord.php diff --git a/htdocs/core/boxes/box_last_knowledgerecord.php b/htdocs/core/boxes/box_last_knowledgerecord.php new file mode 100644 index 00000000000..20510a5b3b0 --- /dev/null +++ b/htdocs/core/boxes/box_last_knowledgerecord.php @@ -0,0 +1,187 @@ + + * Copyright (C) 2016 Christophe Battarel + * Copyright (C) 2018-2023 Frédéric France + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_last_knowledgerecord.php + * \ingroup knowledgerecord + * \brief This box shows latest created knowledgerecords + */ +require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; + +/** + * Class to manage the box + */ +class box_last_knowledgerecord extends ModeleBoxes +{ + + public $boxcode = "box_last_knowledgerecord"; + public $boximg = "knowledgemanagement"; + public $boxlabel; + public $depends = array("knowledgemanagement"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + public $info_box_head = array(); + public $info_box_contents = array(); + + /** + * Constructor + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $langs; + $langs->load("boxes", "languages"); + $this->db = $db; + + $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastKnowledgerecord"); + } + + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; + + $this->max = $max; + + require_once DOL_DOCUMENT_ROOT."/knowledgemanagement/class/knowledgerecord.class.php"; + + $text = $langs->trans("BoxLastKnowledgerecordDescription", $max); + $this->info_box_head = array( + 'text' => $text, + 'limit' => dol_strlen($text), + ); + + $this->info_box_contents[0][0] = array( + 'td' => 'class="left"', + 'text' => $langs->trans("BoxLastKnowledgerecordContent"), + ); + + if ($user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) { + $sql = 'SELECT k.rowid as id, k.date_creation, k.ref, k.lang, k.question, k.status as status'; + $sql .= " FROM ".MAIN_DB_PREFIX."knowledgemanagement_knowledgerecord as k"; + $sql .= " WHERE k.entity IN (".getEntity('knowledgemanagement').")"; + + if ($user->socid) { + $sql .= " AND k.fk_soc= ".((int) $user->socid); + } + + $sql.= " AND k.status > 0"; + + $sql .= " ORDER BY k.date_creation DESC, k.rowid DESC "; + $sql .= $this->db->plimit($max, 0); + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + + $i = 0; + + while ($i < $num) { + $objp = $this->db->fetch_object($resql); + + $datec = $this->db->jdate($objp->date_creation); + + $knowledgerecord = new KnowledgeRecord($this->db); + $knowledgerecord->id = $objp->id; + $knowledgerecord->date_creation = $objp->date_creation; + $knowledgerecord->ref = $objp->ref; + $knowledgerecord->status = $objp->status; + $knowledgerecord->question = $objp->question; + + $r = 0; + + // Ticket + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="nowraponall"', + 'text' => $knowledgerecord->getNomUrl(1), + 'asis' => 1 + ); + $r++; + + // Question + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="tdoverflowmax200"', + 'text' => ''.dol_escape_htmltag($objp->question).'', + 'url' => DOL_URL_ROOT."/knowledgemanagement/knowledgerecord_card.php?id=".urlencode($objp->id), + ); + $r++; + + // Language + $labellang = ($objp->lang ? $langs->trans('Language_'.$objp->lang) : ''); + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="tdoverflowmax100"', + 'text' => picto_from_langcode($objp->lang, 'class="paddingrightonly saturatemedium opacitylow"') . $labellang, + 'asis' => 1, + ); + $r++; + + // Date creation + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateCreation").': '.dol_print_date($datec, 'dayhour', 'tzuserrel')).'"', + 'text' => dol_print_date($objp->datec, 'dayhour', 'tzuserrel'), + ); + $r++; + + // Statut + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="right nowraponall"', + 'text' => $knowledgerecord->getLibStatut(3), + ); + $r++; + + $i++; + } + + if ($num == 0) { + $this->info_box_contents[$i][0] = array('td' => '', 'text' => ''.$langs->trans("BoxLastTicketNoRecordedTickets").''); + } + } else { + dol_print_error($this->db); + } + } else { + $this->info_box_contents[0][0] = array('td' => '', + 'text' => ''.$langs->trans("ReadPermissionNotAllowed").''); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/boxes/box_last_modified_knowledgerecord.php b/htdocs/core/boxes/box_last_modified_knowledgerecord.php new file mode 100644 index 00000000000..5e23ee54602 --- /dev/null +++ b/htdocs/core/boxes/box_last_modified_knowledgerecord.php @@ -0,0 +1,187 @@ + + * Copyright (C) 2016 Christophe Battarel + * Copyright (C) 2018-2023 Frédéric France + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_last_modified_knowledgerecord.php + * \ingroup knowledgerecord + * \brief This box shows latest created knowledgerecords + */ +require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; + +/** + * Class to manage the box + */ +class box_last_modified_knowledgerecord extends ModeleBoxes +{ + + public $boxcode = "box_last_modified_knowledgerecord"; + public $boximg = "knowledgemanagement"; + public $boxlabel; + public $depends = array("knowledgemanagement"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + public $info_box_head = array(); + public $info_box_contents = array(); + + /** + * Constructor + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $langs; + $langs->load("boxes", "knowledgemanagement", "languages"); + $this->db = $db; + + $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastModifiedKnowledgerecord"); + } + + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; + + $this->max = $max; + + require_once DOL_DOCUMENT_ROOT."/knowledgemanagement/class/knowledgerecord.class.php"; + + $text = $langs->trans("BoxLastModifiedKnowledgerecordDescription", $max); + $this->info_box_head = array( + 'text' => $text, + 'limit' => dol_strlen($text), + ); + + $this->info_box_contents[0][0] = array( + 'td' => 'class="left"', + 'text' => $langs->trans("BoxLastKnowledgerecordContent"), + ); + + if ($user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) { + $sql = 'SELECT k.rowid as id, k.date_creation, k.ref, k.lang, k.question, k.status as status'; + $sql .= " FROM ".MAIN_DB_PREFIX."knowledgemanagement_knowledgerecord as k"; + $sql .= " WHERE k.entity IN (".getEntity('knowledgemanagement').")"; + + if ($user->socid) { + $sql .= " AND k.fk_soc= ".((int) $user->socid); + } + + $sql.= " AND k.status > 0"; + + $sql .= " ORDER BY k.tms DESC, k.rowid DESC "; + $sql .= $this->db->plimit($max, 0); + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + + $i = 0; + + while ($i < $num) { + $objp = $this->db->fetch_object($resql); + + $datec = $this->db->jdate($objp->date_creation); + + $knowledgerecord = new KnowledgeRecord($this->db); + $knowledgerecord->id = $objp->id; + $knowledgerecord->date_creation = $objp->date_creation; + $knowledgerecord->ref = $objp->ref; + $knowledgerecord->status = $objp->status; + $knowledgerecord->question = $objp->question; + + $r = 0; + + // Ticket + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="nowraponall"', + 'text' => $knowledgerecord->getNomUrl(1), + 'asis' => 1 + ); + $r++; + + // Question + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="tdoverflowmax200"', + 'text' => ''.dol_escape_htmltag($objp->question).'', + 'url' => DOL_URL_ROOT."/knowledgemanagement/knowledgerecord_card.php?id=".urlencode($objp->id), + ); + $r++; + + // Language + $labellang = ($objp->lang ? $langs->trans('Language_'.$objp->lang) : ''); + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="tdoverflowmax100"', + 'text' => picto_from_langcode($objp->lang, 'class="paddingrightonly saturatemedium opacitylow"') . $labellang, + 'asis' => 1, + ); + $r++; + + // Date creation + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateCreation").': '.dol_print_date($datec, 'dayhour', 'tzuserrel')).'"', + 'text' => dol_print_date($objp->datec, 'dayhour', 'tzuserrel'), + ); + $r++; + + // Statut + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="right nowraponall"', + 'text' => $knowledgerecord->getLibStatut(3), + ); + $r++; + + $i++; + } + + if ($num == 0) { + $this->info_box_contents[$i][0] = array('td' => '', 'text' => ''.$langs->trans("BoxLastTicketNoRecordedTickets").''); + } + } else { + dol_print_error($this->db); + } + } else { + $this->info_box_contents[0][0] = array('td' => '', + 'text' => ''.$langs->trans("ReadPermissionNotAllowed").''); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/modules/modKnowledgeManagement.class.php b/htdocs/core/modules/modKnowledgeManagement.class.php index 68754f530b3..c372f611c60 100644 --- a/htdocs/core/modules/modKnowledgeManagement.class.php +++ b/htdocs/core/modules/modKnowledgeManagement.class.php @@ -201,12 +201,14 @@ class modKnowledgeManagement extends DolibarrModules // Boxes/Widgets // Add here list of php file(s) stored in knowledgemanagement/core/boxes that contains a class to show a widget. $this->boxes = array( - // 0 => array( - // 'file' => 'knowledgemanagementwidget1.php@knowledgemanagement', - // 'note' => 'Widget provided by KnowledgeManagement', - // 'enabledbydefaulton' => 'Home', - // ), - // ... + 0 => array( + 'file' => 'box_last_knowledgerecord.php', + 'enabledbydefaulton' => 'ticketindex', + ), + 1 => array( + 'file' => 'box_last_modified_knowledgerecord.php', + 'enabledbydefaulton' => 'ticketindex', + ), ); // Cronjobs (List of cron jobs entries to add when module is enabled) diff --git a/htdocs/langs/en_US/knowledgemanagement.lang b/htdocs/langs/en_US/knowledgemanagement.lang index 38c1624afad..050ecbcc03a 100644 --- a/htdocs/langs/en_US/knowledgemanagement.lang +++ b/htdocs/langs/en_US/knowledgemanagement.lang @@ -51,4 +51,10 @@ SuggestedForTicketsInGroup=Suggested on ticket creation SetObsolete=Set as obsolete ConfirmCloseKM=Do you confirm the closing of this article as obsolete ? -ConfirmReopenKM=Do you want to restore this article to status "Validated" ? \ No newline at end of file +ConfirmReopenKM=Do you want to restore this article to status "Validated" ? +BoxLastKnowledgerecordDescription=Last %s articles +BoxLastKnowledgerecord=Last articles +BoxLastKnowledgerecordContent=Last articles +BoxLastKnowledgerecordModifiedContent=Last modified articles +BoxLastModifiedKnowledgerecordDescription=Last %s modified articles +BoxLastModifiedKnowledgerecord=Last modified articles From daba310395ed40c88b32e38f3858187215bdac2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 12 Feb 2023 11:39:10 +0100 Subject: [PATCH 09/29] clean code --- .../core/boxes/box_last_knowledgerecord.php | 40 ++++++++++++++++--- .../box_last_modified_knowledgerecord.php | 40 ++++++++++++++++--- 2 files changed, 70 insertions(+), 10 deletions(-) diff --git a/htdocs/core/boxes/box_last_knowledgerecord.php b/htdocs/core/boxes/box_last_knowledgerecord.php index 20510a5b3b0..13635481341 100644 --- a/htdocs/core/boxes/box_last_knowledgerecord.php +++ b/htdocs/core/boxes/box_last_knowledgerecord.php @@ -30,10 +30,24 @@ require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; */ class box_last_knowledgerecord extends ModeleBoxes { - + /** + * @var string boxcode + */ public $boxcode = "box_last_knowledgerecord"; + + /** + * @var string box img + */ public $boximg = "knowledgemanagement"; + + /** + * @var string boc label + */ public $boxlabel; + + /** + * @var array box dependancies + */ public $depends = array("knowledgemanagement"); /** @@ -41,8 +55,19 @@ class box_last_knowledgerecord extends ModeleBoxes */ public $db; + /** + * @var string param + */ public $param; + + /** + * @var array box info heads + */ public $info_box_head = array(); + + /** + * @var array box info content + */ public $info_box_contents = array(); /** @@ -67,7 +92,7 @@ class box_last_knowledgerecord extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs; + global $user, $langs; $this->max = $max; @@ -161,14 +186,19 @@ class box_last_knowledgerecord extends ModeleBoxes } if ($num == 0) { - $this->info_box_contents[$i][0] = array('td' => '', 'text' => ''.$langs->trans("BoxLastTicketNoRecordedTickets").''); + $this->info_box_contents[$i][0] = array( + 'td' => '', + 'text' => ''.$langs->trans("BoxLastTicketNoRecordedTickets").'', + ); } } else { dol_print_error($this->db); } } else { - $this->info_box_contents[0][0] = array('td' => '', - 'text' => ''.$langs->trans("ReadPermissionNotAllowed").''); + $this->info_box_contents[0][0] = array( + 'td' => '', + 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'', + ); } } diff --git a/htdocs/core/boxes/box_last_modified_knowledgerecord.php b/htdocs/core/boxes/box_last_modified_knowledgerecord.php index 5e23ee54602..01ee0771ee1 100644 --- a/htdocs/core/boxes/box_last_modified_knowledgerecord.php +++ b/htdocs/core/boxes/box_last_modified_knowledgerecord.php @@ -30,10 +30,24 @@ require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; */ class box_last_modified_knowledgerecord extends ModeleBoxes { - + /** + * @var string boxcode + */ public $boxcode = "box_last_modified_knowledgerecord"; + + /** + * @var string box img + */ public $boximg = "knowledgemanagement"; + + /** + * @var string boc label + */ public $boxlabel; + + /** + * @var array box dependancies + */ public $depends = array("knowledgemanagement"); /** @@ -41,8 +55,19 @@ class box_last_modified_knowledgerecord extends ModeleBoxes */ public $db; + /** + * @var string param + */ public $param; + + /** + * @var array box info heads + */ public $info_box_head = array(); + + /** + * @var array box info content + */ public $info_box_contents = array(); /** @@ -67,7 +92,7 @@ class box_last_modified_knowledgerecord extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs; + global $user, $langs; $this->max = $max; @@ -161,14 +186,19 @@ class box_last_modified_knowledgerecord extends ModeleBoxes } if ($num == 0) { - $this->info_box_contents[$i][0] = array('td' => '', 'text' => ''.$langs->trans("BoxLastTicketNoRecordedTickets").''); + $this->info_box_contents[$i][0] = array( + 'td' => '', + 'text' => ''.$langs->trans("BoxLastTicketNoRecordedTickets").'', + ); } } else { dol_print_error($this->db); } } else { - $this->info_box_contents[0][0] = array('td' => '', - 'text' => ''.$langs->trans("ReadPermissionNotAllowed").''); + $this->info_box_contents[0][0] = array( + 'td' => '', + 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'', + ); } } From a7c5140fd6c7e366971e8e3ee324c7dcfa9b9dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 12 Feb 2023 12:05:14 +0100 Subject: [PATCH 10/29] clean code --- htdocs/core/boxes/box_last_knowledgerecord.php | 2 +- htdocs/core/boxes/box_last_modified_knowledgerecord.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_last_knowledgerecord.php b/htdocs/core/boxes/box_last_knowledgerecord.php index 13635481341..2cb4818d6ac 100644 --- a/htdocs/core/boxes/box_last_knowledgerecord.php +++ b/htdocs/core/boxes/box_last_knowledgerecord.php @@ -171,7 +171,7 @@ class box_last_knowledgerecord extends ModeleBoxes // Date creation $this->info_box_contents[$i][$r] = array( 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateCreation").': '.dol_print_date($datec, 'dayhour', 'tzuserrel')).'"', - 'text' => dol_print_date($objp->datec, 'dayhour', 'tzuserrel'), + 'text' => dol_print_date($datec, 'dayhour', 'tzuserrel'), ); $r++; diff --git a/htdocs/core/boxes/box_last_modified_knowledgerecord.php b/htdocs/core/boxes/box_last_modified_knowledgerecord.php index 01ee0771ee1..2c5319151fa 100644 --- a/htdocs/core/boxes/box_last_modified_knowledgerecord.php +++ b/htdocs/core/boxes/box_last_modified_knowledgerecord.php @@ -171,7 +171,7 @@ class box_last_modified_knowledgerecord extends ModeleBoxes // Date creation $this->info_box_contents[$i][$r] = array( 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateCreation").': '.dol_print_date($datec, 'dayhour', 'tzuserrel')).'"', - 'text' => dol_print_date($objp->datec, 'dayhour', 'tzuserrel'), + 'text' => dol_print_date($datec, 'dayhour', 'tzuserrel'), ); $r++; From 509dfacbf72a1e0562360d0756807f2d1dcb7afb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 12 Feb 2023 18:02:58 +0100 Subject: [PATCH 11/29] missing translations --- htdocs/langs/en_US/mrp.lang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 82cf7c38012..6c8af64f69a 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -119,3 +119,5 @@ BomCantAddChildBom=The nomenclature %s is already present in the tree leading to BOMNetNeeds = BOM Net Needs BOMProductsList=BOM's products BOMServicesList=BOM's services +Manufacturing=Manufacturing +Disassemble=Disassemble From 3a6b8ebfe7142b9960c6c8092b006cb4e2a57cb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 12 Feb 2023 18:31:35 +0100 Subject: [PATCH 12/29] clean code --- htdocs/mrp/class/mo.class.php | 51 ++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index ddfd8a7f57b..afdac2d16a8 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -93,7 +93,6 @@ class Mo extends CommonObject * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. */ - // BEGIN MODULEBUILDER PROPERTIES /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ @@ -126,6 +125,10 @@ class Mo extends CommonObject public $rowid; public $entity; public $ref; + + /** + * @var int mrptype + */ public $mrptype; public $label; public $qty; @@ -154,8 +157,17 @@ class Mo extends CommonObject public $fk_user_modif; public $import_key; public $status; + + /** + * @var int ID of product + */ public $fk_product; + /** + * @var Product product object + */ + public $product; + /** * @var integer|string date_start_planned */ @@ -167,10 +179,20 @@ class Mo extends CommonObject public $date_end_planned; + /** + * @var int ID bom + */ public $fk_bom; - public $fk_project; - // END MODULEBUILDER PROPERTIES + /** + * @var Bom bom + */ + public $bom; + + /** + * @var int ID project + */ + public $fk_project; // If this object has a subtable with lines @@ -204,12 +226,24 @@ class Mo extends CommonObject */ public $lines = array(); + /** + * @var MoLine MO line + */ + public $line = array(); + /** * @var integer Mo parent line * */ + /** + * @var int ID of parent line + */ public $fk_parent_line; + /** + * @var array tpl + */ + public $tpl = array(); /** * Constructor @@ -1100,6 +1134,9 @@ class Mo extends CommonObject if (isset($this->label)) { $datas['label'] = '
'.$langs->trans('Label').': '.$this->label; } + if (isset($this->mrptype)) { + $datas['type'] = '
'.$langs->trans('Type').': '.$this->fields['mrptype']['arrayofkeyval'][$this->mrptype]; + } return $datas; } @@ -1458,7 +1495,7 @@ class Mo extends CommonObject * If lines are into a template, title must also be into a template * But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * - * @param CommonObjectLine $line Line + * @param MoLine $line Line * @param string $var Var * @param string $restrictlist ''=All lines, 'services'=Restrict to services only (strike line if not) * @param string $defaulttpldir Directory where to find the template @@ -1519,7 +1556,7 @@ class Mo extends CommonObject /** * Function used to return childs of Mo * - * @return array|int array if OK, -1 if KO + * @return Mo[]|int array if OK, -1 if KO */ public function getMoChilds() { @@ -1557,7 +1594,7 @@ class Mo extends CommonObject /** * Function used to return childs of Mo * - * @return Object|int MO object if OK, -1 if KO, 0 if not exist + * @return Mo|int MO object if OK, -1 if KO, 0 if not exist */ public function getMoParent() { @@ -1680,6 +1717,7 @@ class MoLine extends CommonObjectLine public $qty; public $qty_frozen; public $disable_stock_change; + public $efficiency; public $batch; public $role; public $fk_mrp_production; @@ -1689,6 +1727,7 @@ class MoLine extends CommonObjectLine public $fk_user_creat; public $fk_user_modif; public $import_key; + public $fk_parent_line; /** * Constructor From c3425919c2e10a70d7d243f753f2a0324c2a96c0 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sun, 12 Feb 2023 20:18:39 +0100 Subject: [PATCH 13/29] Update hookmanager.class.php --- htdocs/core/class/hookmanager.class.php | 28 ++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index bcd5a506946..0e679493ae8 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -166,32 +166,32 @@ class HookManager // TODO Remove hooks with type 'output' (exemple createFrom). All hooks must be converted into 'addreplace' hooks. if (in_array($method, array( 'createFrom', - 'dashboardMembers', - 'dashboardEmailings', - 'dashboardPropals', - 'dashboardPropals', - 'dashboardCommercials', - 'dashboardOrders', - 'dashboardSpecialBills', 'dashboardAccountancy', + 'dashboardActivities', + 'dashboardCommercials', 'dashboardContracts', 'dashboardDonation', - 'dashboardWarehouseSendings', + 'dashboardEmailings', 'dashboardExpenseReport', - 'dashboardInterventions', - 'dashboardOrdersSuppliers', 'dashboardHRM', + 'dashboardInterventions', 'dashboardMRP', + 'dashboardMembers', 'dashboardOpensurvey', - 'dashboardWarehouse', + 'dashboardOrders', + 'dashboardOrdersSuppliers', 'dashboardProductServices', - 'dashboardActivities', 'dashboardProjects', - 'dashboardWarehouseReceptions', - 'dashboardThirdparties', + 'dashboardPropals', + 'dashboardPropals', + 'dashboardSpecialBills', 'dashboardSupplierProposal', + 'dashboardThirdparties', 'dashboardTickets', 'dashboardUsersGroups', + 'dashboardWarehouse', + 'dashboardWarehouseReceptions', + 'dashboardWarehouseSendings', 'insertExtraHeader', 'insertExtraFooter', 'printLeftBlock', From 6e3966abaeda0628503250c231c265fbb883ccc1 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sun, 12 Feb 2023 20:21:11 +0100 Subject: [PATCH 14/29] Update hookmanager.class.php saw now 'dashboardPropals' was twice --- htdocs/core/class/hookmanager.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 0e679493ae8..f973bffba93 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -183,7 +183,6 @@ class HookManager 'dashboardProductServices', 'dashboardProjects', 'dashboardPropals', - 'dashboardPropals', 'dashboardSpecialBills', 'dashboardSupplierProposal', 'dashboardThirdparties', From ffa4e58addc09215dcbe79d540b41bd912acf2b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 12 Feb 2023 20:26:40 +0100 Subject: [PATCH 15/29] fix warning listUsersForGroup with mode = 1 return array of user id --- htdocs/holiday/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 42c64613933..05568e08992 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -3,7 +3,7 @@ * Copyright (C) 2013-2020 Laurent Destailleur * Copyright (C) 2012-2016 Regis Houssin * Copyright (C) 2018 Charlene Benke - * Copyright (C) 2019-2022 Frédéric France + * Copyright (C) 2019-2023 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -620,7 +620,7 @@ if ($resql) { $valideurobjects = $validator->listUsersForGroup($excludefilter, 1); $valideurarray = array(); foreach ($valideurobjects as $val) { - $valideurarray[$val->id] = $val->id; + $valideurarray[$val] = $val; } print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth125'); print ''; From 814075d36b943413bc244bfeffa7619a703203e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 12 Feb 2023 20:28:39 +0100 Subject: [PATCH 16/29] Update view_log.php --- htdocs/holiday/view_log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index 4235b7261eb..d0ba35add68 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -336,7 +336,7 @@ if (!empty($arrayfields['cpl.fk_user_action']['checked'])) { $valideurobjects = $validator->listUsersForGroup($excludefilter, 1); $valideurarray = array(); foreach ($valideurobjects as $val) { - $valideurarray[$val->id] = $val->id; + $valideurarray[$val] = $val; } print ''; From af1b9d319474ce70fb1a3f100d4d2aa3c400e91d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 12 Feb 2023 20:48:19 +0100 Subject: [PATCH 17/29] fix warnings --- htdocs/comm/mailing/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 32207425d2a..26e8e6ec63a 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -736,9 +736,9 @@ if ($action == 'create') { print ''.$langs->trans("MailTitle").''; - print ''.$langs->trans("MailFrom").''; + print ''.$langs->trans("MailFrom").''; - print ''.$langs->trans("MailErrorsTo").''; + print ''.$langs->trans("MailErrorsTo").''; // Other attributes $parameters = array(); From 4e00810ca63ab843495eb178a5341d8ce88ddcbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 12 Feb 2023 20:54:28 +0100 Subject: [PATCH 18/29] fix warnings --- htdocs/hrm/evaluation_list.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/hrm/evaluation_list.php b/htdocs/hrm/evaluation_list.php index 999d6d0d44e..adf642597f2 100644 --- a/htdocs/hrm/evaluation_list.php +++ b/htdocs/hrm/evaluation_list.php @@ -134,13 +134,13 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); // Permissions -$permissiontoread = $user->rights->hrm->evaluation->read; -$permissiontoreadall = $user->rights->hrm->evaluation->readall; -$permissiontoadd = $user->rights->hrm->evaluation->write; -$permissiontodelete = $user->rights->hrm->evaluation->delete; +$permissiontoread = $user->hasRight('hrm', 'evaluation', 'read'); +$permissiontoreadall = $user->hasRight('hrm', 'evaluation', 'readall'); +$permissiontoadd = $user->hasRight('hrm', 'evaluation', 'write'); +$permissiontodelete = $user->hasRight('hrm', 'evaluation', 'delete'); // Security check -if (empty($conf->hrm->enabled)) { +if (!isModEnabled('hrm')) { accessforbidden('Module not enabled'); } From 85a594aa6130c3f97ac4018e7086e9d9274cd53d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 12 Feb 2023 21:01:02 +0100 Subject: [PATCH 19/29] clean code --- htdocs/opensurvey/class/opensurveysondage.class.php | 5 +++++ htdocs/ticket/class/ticket.class.php | 4 ++-- htdocs/ticket/contact.php | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index e928c2f3cd6..b141da8d392 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -115,6 +115,11 @@ class Opensurveysondage extends CommonObject */ public $allow_spy; + /** + * @var array fields + */ + public $fields = array(); + /** * Draft status (not used) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 932ed171cea..6884d2e830d 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1440,10 +1440,10 @@ class Ticket extends CommonObject $datas['track_id'] = '
'.$langs->trans('TicketTrackId').': '.$this->track_id; $datas['subject'] = '
'.$langs->trans('Subject').': '.$this->subject; if ($this->date_creation) { - $datas['date_creation'] = '
'.$langs->trans('DateCreation').': '.$this->date_creation; + $datas['date_creation'] = '
'.$langs->trans('DateCreation').': '.dol_print_date($this->date_creation, 'dayhour'); } if ($this->date_modification) { - $datas['date_modification'] = '
'.$langs->trans('DateModification').': '.$this->date_modification; + $datas['date_modification'] = '
'.$langs->trans('DateModification').': '.dol_print_date($this->date_modification, 'dayhour'); } return $datas; diff --git a/htdocs/ticket/contact.php b/htdocs/ticket/contact.php index b5453ed638b..d858a4d7334 100644 --- a/htdocs/ticket/contact.php +++ b/htdocs/ticket/contact.php @@ -252,7 +252,7 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) { $linkback = ''.$langs->trans("BackToList").' '; - dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, $param, 0, '', '', 1, ''); + dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1, ''); print dol_get_fiche_end(); From f043345706eb469d7277adf2233f811e330e2f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 12 Feb 2023 21:06:39 +0100 Subject: [PATCH 20/29] clean code --- htdocs/societe/class/societe.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index bc0e8cff3bd..10c13d0313f 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2612,6 +2612,7 @@ class Societe extends CommonObject $datas = []; $option = $params['option'] ?? ''; + $nofetch = empty($params['nofetch']) ? false : true; $name = $this->name; if (!empty($this->name_alias) && empty($noaliasinname)) { @@ -2724,6 +2725,12 @@ class Societe extends CommonObject if (isModEnabled('accounting') && $this->fournisseur) { $datas['accountancysuppliercode'] = '
'.$langs->trans('SupplierAccountancyCode').': '.$this->code_compta_fournisseur; } + // show categories for this record only in ajax to not overload lists + if (isModEnabled('categorie') && !$nofetch) { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $form = new Form($this->db); + $datas['categories'] = '
' . $form->showCategories($this->id, Categorie::TYPE_CUSTOMER, 1); + } $datas['divclose'] = ''; @@ -2789,6 +2796,7 @@ class Societe extends CommonObject 'id' => $this->id, 'objecttype' => $this->element, 'option' => $option, + 'nofetch' => 1, ]; $classfortooltip = 'classfortooltip'; $dataparams = ''; From 0f4adbedab3466eacbe41296fd9a1ae9b69bec43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 12 Feb 2023 21:15:16 +0100 Subject: [PATCH 21/29] clean code --- htdocs/product/class/product.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 9db4565ca49..c8b3104aed0 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5012,6 +5012,7 @@ class Product extends CommonObject $langs->load('products'); $datas = []; + $nofetch = empty($params['nofetch']) ? false : true; if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { return ['optimize' => $langs->trans("ShowProduct")]; @@ -5103,6 +5104,12 @@ class Product extends CommonObject $datas['accountancybuy'] = $buylabel; } } + // show categories for this record only in ajax to not overload lists + if (isModEnabled('categorie') && !$nofetch) { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $form = new Form($this->db); + $datas['categories'] = '
' . $form->showCategories($this->id, Categorie::TYPE_PRODUCT, 1); + } return $datas; } @@ -5135,6 +5142,7 @@ class Product extends CommonObject 'id' => $this->id, 'objecttype' => $this->element, 'option' => $option, + 'nofetch' => 1, ]; $classfortooltip = 'classfortooltip'; $dataparams = ''; From c17463d2f4ec4a1c8f419c511b04b7db9e2e41f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 12 Feb 2023 22:03:39 +0100 Subject: [PATCH 22/29] clean code --- htdocs/societe/class/societe.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 10c13d0313f..ea99b9c9eef 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2729,7 +2729,12 @@ class Societe extends CommonObject if (isModEnabled('categorie') && !$nofetch) { require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $form = new Form($this->db); - $datas['categories'] = '
' . $form->showCategories($this->id, Categorie::TYPE_CUSTOMER, 1); + if ($this->client) { + $datas['categories_customer'] = '
' . $form->showCategories($this->id, Categorie::TYPE_CUSTOMER, 1); + } + if ($this->fournisseur) { + $datas['categories_supplier'] = '
' . $form->showCategories($this->id, Categorie::TYPE_SUPPLIER, 1); + } } $datas['divclose'] = ''; From 43ac67c3d825dac14addf51a876ec0e7d67758ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 12 Feb 2023 23:13:45 +0100 Subject: [PATCH 23/29] clean code --- htdocs/ticket/class/ticket.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 6884d2e830d..bc50c0e31f8 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1433,6 +1433,7 @@ class Ticket extends CommonObject $langs->load('ticket'); + $nofetch = empty($params['nofetch']) ? false : true; $datas = []; $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Ticket").''; $datas['picto'] .= ' '.$this->getLibStatut(4); @@ -1445,6 +1446,12 @@ class Ticket extends CommonObject if ($this->date_modification) { $datas['date_modification'] = '
'.$langs->trans('DateModification').': '.dol_print_date($this->date_modification, 'dayhour'); } + // show categories for this record only in ajax to not overload lists + if (isModEnabled('categorie') && !$nofetch) { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $form = new Form($this->db); + $datas['categories'] = '
' . $form->showCategories($this->id, Categorie::TYPE_TICKET, 1); + } return $datas; } @@ -1474,6 +1481,8 @@ class Ticket extends CommonObject $params = [ 'id' => $this->id, 'objecttype' => $this->element, + 'option' => $option, + 'nofetch' => 1, ]; $classfortooltip = 'classfortooltip'; $dataparams = ''; From e1ca6ef019f19a7dc3c5f9b80470e4ce37676c7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 12 Feb 2023 23:19:03 +0100 Subject: [PATCH 24/29] clean code --- htdocs/adherents/class/adherent.class.php | 8 ++++++++ htdocs/comm/action/class/actioncomm.class.php | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index b0ca0986ffb..6e77fd3fa95 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2288,6 +2288,7 @@ class Adherent extends CommonObject $datas = []; + $nofetch = empty($params['nofetch']) ? false : true; if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $langs->load("users"); return ['optimize' => $langs->trans("ShowUser")]; @@ -2318,6 +2319,12 @@ class Adherent extends CommonObject $datas['email'] = '
'.$langs->trans("EMail").': '.$this->email; } $datas['address'] = '
'.$langs->trans("Address").': '.dol_format_address($this, 1, ' ', $langs); + // show categories for this record only in ajax to not overload lists + if (isModEnabled('categorie') && !$nofetch) { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $form = new Form($this->db); + $datas['categories'] = '
' . $form->showCategories($this->id, Categorie::TYPE_MEMBER, 1); + } $datas['divclose'] = ''; return $datas; @@ -2353,6 +2360,7 @@ class Adherent extends CommonObject 'id' => $this->id, 'objecttype' => $this->element, 'option' => $option, + 'nofetch' => 1, ]; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { $classfortooltip = 'classforajaxtooltip'; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index fd5b55e70fe..11cb4f98dbd 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1580,6 +1580,7 @@ class ActionComm extends CommonObject $langs->load('agenda'); $datas = []; + $nofetch = empty($params['nofetch']) ? false : true; // Set label of type $labeltype = ''; if ($this->type_code) { @@ -1631,6 +1632,12 @@ class ActionComm extends CommonObject $datas['note'] .= (dol_textishtml($texttoshow) ? str_replace(array("\r", "\n"), "", $texttoshow) : str_replace(array("\r", "\n"), '
', $texttoshow)); $datas['note'] .= ''; } + // show categories for this record only in ajax to not overload lists + if (isModEnabled('categorie') && !$nofetch) { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $form = new Form($this->db); + $datas['categories'] = '
' . $form->showCategories($this->id, Categorie::TYPE_ACTIONCOMM, 1); + } return $datas; } @@ -1734,6 +1741,7 @@ class ActionComm extends CommonObject 'id' => $this->id, 'objecttype' => $this->element, 'option' => $option, + 'nofetch' => 1, ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); From b0a1d8058fb0c8a49323028ea945330cd558b79d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 12 Feb 2023 23:28:14 +0100 Subject: [PATCH 25/29] clean code --- htdocs/compta/bank/class/account.class.php | 43 ++++++++-------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 7032f9c40e2..4ccdf93cb58 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1417,6 +1417,7 @@ class Account extends CommonObject $datas = []; + $nofetch = empty($params['nofetch']) ? false : true; $pictos = img_picto('', $this->picto).' '.$langs->trans("BankAccount").''; if (isset($this->status)) { $pictos .= ' '.$this->getLibStatut(5); @@ -1434,6 +1435,12 @@ class Account extends CommonObject $datas['accountaccounting'] = '
'.$langs->trans('AccountAccounting').': '.length_accountg($this->account_number); $datas['accountancyjournal'] = '
'.$langs->trans('AccountancyJournal').': '.$this->accountancy_journal; } + // show categories for this record only in ajax to not overload lists + if (isModEnabled('categorie') && !$nofetch) { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $form = new Form($this->db); + $datas['categories'] = '
' . $form->showCategories($this->id, Categorie::TYPE_ACCOUNT, 1); + } return $datas; } @@ -1454,38 +1461,20 @@ class Account extends CommonObject include_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; $result = ''; - $label = img_picto('', $this->picto).' '.$langs->trans("BankAccount").''; - if (isset($this->status)) { - $label .= ' '.$this->getLibStatut(5); - } - $label .= '
'.$langs->trans('Label').': '.$this->label; - $label .= '
'.$langs->trans('AccountNumber').': '.$this->number; - $label .= '
'.$langs->trans('IBAN').': '.getIbanHumanReadable($this); - $label .= '
'.$langs->trans('BIC').': '.$this->bic; - $label .= '
'.$langs->trans("AccountCurrency").': '.$this->currency_code; - - if (empty($user->rights->banque->lire) || !empty($user->socid)) { - $option = 'nolink'; - } - - if (isModEnabled('accounting')) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $langs->load("accountancy"); - $label .= '
'.$langs->trans('AccountAccounting').': '.length_accountg($this->account_number); - $label .= '
'.$langs->trans('AccountancyJournal').': '.$this->accountancy_journal; - } $classfortooltip = 'classfortooltip'; $dataparams = ''; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + 'nofetch' => 1, + ]; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - $params = [ - 'id' => $this->id, - 'objecttype' => $this->element, - 'option' => $option, - ]; $classfortooltip = 'classforajaxtooltip'; $dataparams = ' data-params='.json_encode($params); - $label = $langs->trans('Loading'); } + $label = implode($this->getTooltipContentArray($params)); + $linkclose = '"'.$dataparams.' title="'.dol_escape_htmltag($label, 1).'" class="'.$classfortooltip.'">'; $url = DOL_URL_ROOT.'/compta/bank/card.php?id='.$this->id; @@ -1871,7 +1860,7 @@ class Account extends CommonObject /** * Class to manage bank transaction lines */ -class AccountLine extends CommonObject +class AccountLine extends CommonObjectLine { /** * @var string Error code (or message) From 30b81e2ac94fe4714af2a2574b5aebab81316e54 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Feb 2023 06:03:42 +0000 Subject: [PATCH 26/29] Bump JetBrains/qodana-action from 2022.3.2 to 2022.3.3 Bumps [JetBrains/qodana-action](https://github.com/JetBrains/qodana-action) from 2022.3.2 to 2022.3.3. - [Release notes](https://github.com/JetBrains/qodana-action/releases) - [Commits](https://github.com/JetBrains/qodana-action/compare/v2022.3.2...v2022.3.3) --- updated-dependencies: - dependency-name: JetBrains/qodana-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/code_quality.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml index e5351acaf78..9b4fd68efe7 100644 --- a/.github/workflows/code_quality.yml +++ b/.github/workflows/code_quality.yml @@ -18,7 +18,7 @@ jobs: fetch-depth: 1 #php-version: '7.1' - name: 'Qodana Scan' - uses: JetBrains/qodana-action@v2022.3.2 + uses: JetBrains/qodana-action@v2022.3.3 #with: # php-version: '7.1' env: From c90e5094455511e5282ec3429741e8517ef1884b Mon Sep 17 00:00:00 2001 From: priojk Date: Mon, 13 Feb 2023 10:09:48 +0100 Subject: [PATCH 27/29] NEW: Possibility to link to German pages in help --- htdocs/main.inc.php | 17 ++++++++++++----- htdocs/mrp/mo_movements.php | 2 +- htdocs/mrp/mo_production.php | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 1ea68780746..dc9d9d90c02 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -15,6 +15,7 @@ * Copyright (C) 2020 Charlene Benke * Copyright (C) 2021 Frédéric France * Copyright (C) 2021 Alexandre Spangaro + * Copyright (C) 2023 Joachim Küter * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1397,7 +1398,7 @@ if (!function_exists("llxHeader")) { * @param string $head Optionnal head lines * @param string $title HTML title * @param string $help_url Url links to help page - * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage + * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage|DE:GermanPage * For other external page: http://server/url * @param string $target Target to use on links * @param int $disablejs More content into html header @@ -1958,7 +1959,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr * @param array $arrayofcss Array of css files to add in header * @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails) * @param string $helppagename Name of wiki page for help ('' by default). - * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage + * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage|DE:GermanPage * For other external page: http://server/url * @return void */ @@ -2091,7 +2092,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead $helppresent = ''; if (empty($helppagename)) { - $helppagename = 'EN:User_documentation|FR:Documentation_utilisateur|ES:Documentación_usuarios'; + $helppagename = 'EN:User_documentation|FR:Documentation_utilisateur|ES:Documentación_usuarios|DE:Benutzerdokumentation'; } else { $helppresent = 'helppresent'; } @@ -2888,7 +2889,7 @@ function top_menu_search() * * @param array $menu_array_before Table of menu entries to show before entries of menu handler. This param is deprectaed and must be provided to ''. * @param string $helppagename Name of wiki page for help ('' by default). - * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage + * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage|DE:GermanPage * For other external page: http://server/url * @param string $notused Deprecated. Used in past to add content into left menu. Hooks can be used now. * @param array $menu_array_after Table of menu entries to show after entries of menu handler @@ -3176,7 +3177,7 @@ function main_area($title = '') /** * Return helpbaseurl, helppage and mode * - * @param string $helppagename Page name ('EN:xxx,ES:eee,FR:fff...' or 'http://localpage') + * @param string $helppagename Page name ('EN:xxx,ES:eee,FR:fff,DE:ddd...' or 'http://localpage') * @param Translate $langs Language * @return array Array of help urls */ @@ -3206,6 +3207,12 @@ function getHelpParamFor($helppagename, $langs) $helppage = $reg[1]; } } + if (preg_match('/^de/i', $langs->defaultlang)) { + $helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s'; + if (preg_match('/DE:([^|]+)/i', $helppagename, $reg)) { + $helppage = $reg[1]; + } + } if (empty($helppage)) { // If help page not already found $helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s'; if (preg_match('/EN:([^|]+)/i', $helppagename, $reg)) { diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index c0357aa5e4b..a82f36c913e 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -257,7 +257,7 @@ $productlot = new ProductLot($db); $warehousestatic = new Entrepot($db); $userstatic = new User($db); -$help_url = 'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication'; +$help_url = 'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag'; llxHeader('', $langs->trans('Mo'), $help_url); diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index b274f4b89df..4e149201ba3 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -431,7 +431,7 @@ $tmpwarehouse = new Entrepot($db); $tmpbatch = new Productlot($db); $tmpstockmovement = new MouvementStock($db); -$help_url = 'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication'; +$help_url = 'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag'; llxHeader('', $langs->trans('Mo'), $help_url, '', 0, 0, array('/mrp/js/lib_dispatch.js.php')); $newToken = newToken(); From a34703532f3f6a476e9d1fc36a23f53b8324b7b7 Mon Sep 17 00:00:00 2001 From: jyhere Date: Mon, 13 Feb 2023 10:37:36 +0100 Subject: [PATCH 28/29] [FIX] extrafield with visibility '5' update bug When using a visibility = 5 (not editable extrafield, but visible on card and list), updating the object will result in an empty value in database for this extrafield. --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 71d5dfdb06d..be34ccd1a8b 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2114,7 +2114,7 @@ class ExtraFields ) { continue; } - if (empty($visibility)) { + if (empty($visibility) || $visibility == 5) { continue; } if (empty($perms)) { From 08838d4debdc817d0143a7511046ba42845aa54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 13 Feb 2023 13:16:27 +0100 Subject: [PATCH 29/29] clean code --- htdocs/core/boxes/box_members_subscriptions_by_year.php | 2 +- htdocs/langs/en_US/members.lang | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_members_subscriptions_by_year.php b/htdocs/core/boxes/box_members_subscriptions_by_year.php index 716b8ed0482..228ba016ceb 100644 --- a/htdocs/core/boxes/box_members_subscriptions_by_year.php +++ b/htdocs/core/boxes/box_members_subscriptions_by_year.php @@ -191,7 +191,7 @@ class box_members_subscriptions_by_year extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', + 'td' => 'class="left" colspan="4"', 'text' => $langs->trans("NoRecordedMembers"), ); } else { diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 5876a019d25..b0237c5578b 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -233,3 +233,4 @@ CreateDolibarrThirdPartyDesc=A thirdparty is the legal entity that will be used MemberFirstname=Member firstname MemberLastname=Member lastname MemberCodeDesc=Member Code, unique for all members +NoRecordedMembers=No registered member