From 7c352c9cefe8e241c0dd862d9c148dff11519b33 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 9 Dec 2022 17:00:11 +0100 Subject: [PATCH 01/43] BOM : calculate total cost of lines --- htdocs/bom/class/bom.class.php | 3 ++- htdocs/bom/tpl/objectline_view.tpl.php | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 0e57bebd922..4dfb47a3887 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1073,7 +1073,8 @@ class BOM extends CommonObject if ($res>0) { $bom_child->calculateCosts(); $line->childBom[] = $bom_child; - $this->total_cost += $bom_child->total_cost * $line->qty; + $line->total_cost = price2num( $bom_child->total_cost * $line->qty, 'MT'); + $this->total_cost += $line->total_cost; } else { $this->error = $bom_child->error; return -2; diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 61b394a3b0f..3897b875652 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -239,13 +239,13 @@ if ($resql) { // Cost if (!empty($sub_bom->id)) { $sub_bom->calculateCosts(); - print ''.price($sub_bom->total_cost * $sub_bom_line->qty * $line->qty).''; + print ''.price2num($sub_bom->total_cost * $sub_bom_line->qty * $line->qty, 'MT').''; $total_cost+= $sub_bom->total_cost * $sub_bom_line->qty * $line->qty; } elseif ($sub_bom_product->cost_price > 0) { - print ''.price($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty).''; + print ''.price2num($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty, 'MT').''; $total_cost+= $sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty; } elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined - print ''.price($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty).''; + print ''.price2num($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty, 'MT').''; $total_cost.= $sub_bom_product->pmp * $sub_bom_line->qty * $line->qty; } else { // Minimum purchase price if cost price and PMP aren't defined $sql_supplier_price = 'SELECT MIN(price) AS min_price, quantity AS qty FROM '.MAIN_DB_PREFIX.'product_fournisseur_price'; @@ -255,7 +255,7 @@ if ($resql) { $obj = $object->db->fetch_object($resql_supplier_price); $line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty * $line->qty; - print ''.price($line_cost).''; + print ''.price2num($line_cost, 'MT').''; $total_cost+= $line_cost; } } From 92bff0fcfbbba88af2b422d4cefa6b4c3d38cd8f Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 12 Dec 2022 11:41:54 +0100 Subject: [PATCH 02/43] Missing Unit TD for sub-bom lines --- htdocs/bom/tpl/objectline_view.tpl.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 3897b875652..bb83e62c07f 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -218,11 +218,16 @@ if ($resql) { } // Qty + $label = $sub_bom_product->getLabelOfUnit('long'); if ($sub_bom_line->qty_frozen > 0) { print ''.price($sub_bom_line->qty, 0, '', 0, 0).''; + print ''.($label !== '') ? $langs->trans($label) : '' . ''; print ''.$langs->trans('Yes').''; } else { print ''.price($sub_bom_line->qty * $line->qty, 0, '', 0, 0).''; + print ''; + print ''.($label !== '') ? $langs->trans($label) : '' . ''; + print ''; print ' '; } From b597a43b21a7488bd271f05d99da65539a3f0d96 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 14 Dec 2022 08:37:30 +0000 Subject: [PATCH 03/43] Fixing style errors. --- htdocs/bom/class/bom.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 4dfb47a3887..7f9a1aa09c6 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1073,7 +1073,7 @@ class BOM extends CommonObject if ($res>0) { $bom_child->calculateCosts(); $line->childBom[] = $bom_child; - $line->total_cost = price2num( $bom_child->total_cost * $line->qty, 'MT'); + $line->total_cost = price2num($bom_child->total_cost * $line->qty, 'MT'); $this->total_cost += $line->total_cost; } else { $this->error = $bom_child->error; From 1ebd2135e0f15c34fa62674ec9b19a7fcf4e6412 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 15 Dec 2022 15:00:27 +0100 Subject: [PATCH 04/43] Fix stickler error --- htdocs/bom/tpl/objectline_view.tpl.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index bb83e62c07f..f9b39c517e9 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -221,12 +221,15 @@ if ($resql) { $label = $sub_bom_product->getLabelOfUnit('long'); if ($sub_bom_line->qty_frozen > 0) { print ''.price($sub_bom_line->qty, 0, '', 0, 0).''; - print ''.($label !== '') ? $langs->trans($label) : '' . ''; + print ''; + if ($label !== '') print $langs->trans($label); + print ''; print ''.$langs->trans('Yes').''; } else { print ''.price($sub_bom_line->qty * $line->qty, 0, '', 0, 0).''; print ''; - print ''.($label !== '') ? $langs->trans($label) : '' . ''; + if($label !== '') print $langs->trans($label); + print ''; print ''; print ' '; } From 48b4caaa70178498146b230b9c1fceb826502c1c Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 19 Dec 2022 09:41:39 +0000 Subject: [PATCH 05/43] Fixing style errors. --- htdocs/bom/tpl/objectline_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index f9b39c517e9..85bd4d6b02a 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -228,7 +228,7 @@ if ($resql) { } else { print ''.price($sub_bom_line->qty * $line->qty, 0, '', 0, 0).''; print ''; - if($label !== '') print $langs->trans($label); + if ($label !== '') print $langs->trans($label); print ''; print ''; print ' '; From 6dbffb53989f8f75f7d5b1d863c7c72328f1a3b6 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 2 Jan 2023 09:48:34 +0100 Subject: [PATCH 06/43] Add price() to pricetonum() on bomline view --- htdocs/bom/tpl/objectline_view.tpl.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 85bd4d6b02a..fc6b7709d14 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -247,13 +247,13 @@ if ($resql) { // Cost if (!empty($sub_bom->id)) { $sub_bom->calculateCosts(); - print ''.price2num($sub_bom->total_cost * $sub_bom_line->qty * $line->qty, 'MT').''; + print ''.price(price2num($sub_bom->total_cost * $sub_bom_line->qty * $line->qty, 'MT')).''; $total_cost+= $sub_bom->total_cost * $sub_bom_line->qty * $line->qty; } elseif ($sub_bom_product->cost_price > 0) { - print ''.price2num($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty, 'MT').''; + print ''.price(price2num($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty, 'MT')).''; $total_cost+= $sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty; } elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined - print ''.price2num($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty, 'MT').''; + print ''.price(price2num($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty, 'MT')).''; $total_cost.= $sub_bom_product->pmp * $sub_bom_line->qty * $line->qty; } else { // Minimum purchase price if cost price and PMP aren't defined $sql_supplier_price = 'SELECT MIN(price) AS min_price, quantity AS qty FROM '.MAIN_DB_PREFIX.'product_fournisseur_price'; From 88c3f33e1811408afb6bab925d5e8daa58ff8056 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 8 Jan 2023 15:52:20 +0100 Subject: [PATCH 07/43] Fix php 8 error --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index ae4afc695e6..ef954794964 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2422,7 +2422,7 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = function dol_most_recent_file($dir, $regexfilter = '', $excludefilter = array('(\.meta|_preview.*\.png)$', '^\.'), $nohook = false, $mode = '') { $tmparray = dol_dir_list($dir, 'files', 0, $regexfilter, $excludefilter, 'date', SORT_DESC, $mode, $nohook); - return $tmparray[0]; + return isset($tmparray[0])?$tmparray[0]:null; } /** From 12885deb468598be223c441e3b14d4af4d5ec4f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NASSIET?= Date: Wed, 11 Jan 2023 21:19:33 +0100 Subject: [PATCH 08/43] correction bug selection contact dans emailing --- htdocs/core/modules/mailings/contacts1.modules.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 7406779054b..be77cf155d2 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -122,7 +122,7 @@ class mailing_contacts1 extends MailingTargets */ public function formFilter() { - global $langs; + global $langs,$conf; // Load translation files required by the page $langs->loadLangs(array("commercial", "companies", "suppliers", "categories")); @@ -308,11 +308,12 @@ class mailing_contacts1 extends MailingTargets $s .= ajax_combobox("filter_category_supplier_contact"); // Choose language - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; - $formadmin = new FormAdmin($this->db); - $s .= ''.$langs->trans("DefaultLang").': '; - $s .= $formadmin->select_language($langs->getDefaultLang(1), 'filter_lang', 0, 0, 1, 0, 0, '', 0, 0, 0, null, 1); - + if (getDolGlobalInt('MAIN_MULTILANGS')) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; + $formadmin = new FormAdmin($this->db); + $s .= ''.$langs->trans("DefaultLang").': '; + $s .= $formadmin->select_language($langs->getDefaultLang(1), 'filter_lang', 0, 0, 1, 0, 0, '', 0, 0, 0, null, 1); + } return $s; } From 272f131b070a82ded90ab8fcb4131cd17070066a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Cendrier?= Date: Thu, 12 Jan 2023 10:18:47 +0100 Subject: [PATCH 09/43] do not let closed inventories reset stock with URL --- htdocs/product/inventory/inventory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index fd82300fdda..cbe5d782082 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -118,7 +118,7 @@ if (empty($reshook)) { } // Close inventory by recording the stock movements - if ($action == 'update' && !empty($user->rights->stock->mouvement->creer)) { + if ($action == 'update' && !empty($user->rights->stock->mouvement->creer) && $object->status == $object::STATUS_VALIDATED) { $stockmovment = new MouvementStock($db); $stockmovment->setOrigin($object->element, $object->id); From 4fdf9302694fd39fbe5d496cc6590aa4869319d2 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 12 Jan 2023 12:49:45 +0100 Subject: [PATCH 10/43] make PDF custom volume work as it work on expedition/card.php --- .../core/modules/expedition/doc/pdf_espadon.modules.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 97be43da689..fd5c2ee1980 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -846,12 +846,13 @@ class pdf_espadon extends ModelePdfExpedition $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); } if ($object->trueVolume) { - $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); + if ($object->volume_units < 50) { + $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); + } else { + $totalVolumetoshow = price($object->trueVolume, 0, $outputlangs, 0, 0).' '.measuringUnitString(0, "volume", $object->volume_units); + } } - - - if ($this->getColumnStatus('desc')) { $this->printStdColumnContent($pdf, $tab2_top, 'desc', $outputlangs->transnoentities("Total")); } From 04ce79191fb24085c27969e5bbe60e5096340970 Mon Sep 17 00:00:00 2001 From: hystepik Date: Fri, 13 Jan 2023 12:18:58 +0100 Subject: [PATCH 11/43] Fix #23531 : fix update bom line --- htdocs/core/modules/modBom.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php index 2e92d3baeaf..d6b9e7a6ff3 100644 --- a/htdocs/core/modules/modBom.class.php +++ b/htdocs/core/modules/modBom.class.php @@ -422,7 +422,7 @@ class modBom extends DolibarrModules $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'bom_bomline'); $this->import_regex_array[$r] = array(); - $this->import_updatekeys_array[$r] = array('bd.fk_bom' => 'BOM Id'); + $this->import_updatekeys_array[$r] = array('bd.fk_bom' => 'BOM Id', 'bd.fk_product' => 'ProductRef'); $this->import_convertvalue_array[$r] = array( 'bd.fk_bom' => array( 'rule' => 'fetchidfromref', From 79ecc945e9b1351b0364f64a9eb8cfe5780ab2bc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Jan 2023 11:43:47 +0100 Subject: [PATCH 12/43] Fix warning --- htdocs/bookmarks/list.php | 1 + htdocs/core/menus/standard/eldy_menu.php | 2 +- htdocs/core/search_page.php | 4 ++-- htdocs/modulebuilder/template/myobject_list.php | 10 +++++----- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index 9434cf031a2..2500d40e25d 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -37,6 +37,7 @@ $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bookmarklist'; // To manage different context of search $id = GETPOST("id", 'int'); $optioncss = GETPOST('optioncss', 'alpha'); +$mode = GETPOST('mode', 'aZ09'); // Load variable for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; diff --git a/htdocs/core/menus/standard/eldy_menu.php b/htdocs/core/menus/standard/eldy_menu.php index bbcd0cacf25..596e1e4cc3f 100644 --- a/htdocs/core/menus/standard/eldy_menu.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -204,7 +204,7 @@ class MenuManager //if ($tmpmainmenu=='accountancy') { //var_dump($submenu->liste); exit; //} - $nexturl = dol_buildpath($submenu->liste[0]['url'], 1); + $nexturl = dol_buildpath(empty($submenu->liste[0]['url']) ? '' : $submenu->liste[0]['url'], 1); $canonrelurl = preg_replace('/\?.*$/', '', $relurl); $canonnexturl = preg_replace('/\?.*$/', '', $nexturl); diff --git a/htdocs/core/search_page.php b/htdocs/core/search_page.php index 4f6911497e4..2e5cad17c58 100644 --- a/htdocs/core/search_page.php +++ b/htdocs/core/search_page.php @@ -109,8 +109,8 @@ if ($conf->use_javascript_ajax && 1 == 2) { // select2 is not best with smartp $keysearch = 'search_all'; $accesskey = ''; - if (!$accesskeyalreadyassigned[$val['label'][0]]) { - $accesskey = $val['label'][0]; + if (empty($accesskeyalreadyassigned[$val['label'][0]])) { + $accesskey = $val['label'][0]; // First char of string $accesskeyalreadyassigned[$accesskey] = $accesskey; } diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 29c9205b1f0..1135f6d9498 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -87,7 +87,7 @@ require_once __DIR__.'/class/myobject.class.php'; // Load translation files required by the page $langs->loadLangs(array("mymodule@mymodule", "other")); -$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation @@ -96,7 +96,7 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$mode = GETPOST('mode', 'aZ'); +$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...) $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -182,9 +182,9 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); // Set $enablepermissioncheck to 1 to enable a minimum low level of checks $enablepermissioncheck = 0; if ($enablepermissioncheck) { - $permissiontoread = $user->rights->mymodule->myobject->read; - $permissiontoadd = $user->rights->mymodule->myobject->write; - $permissiontodelete = $user->rights->mymodule->myobject->delete; + $permissiontoread = $user->hasRight('mymodule', 'myobject', 'read'); + $permissiontoadd = $user->hasRight('mymodule', 'myobject', 'write'); + $permissiontodelete = $user->hasRight('mymodule', 'myobject', 'delete'); } else { $permissiontoread = 1; $permissiontoadd = 1; From b7c56f5680c74a33809b9999a1ad02d1742c447b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Jan 2023 11:54:05 +0100 Subject: [PATCH 13/43] Fix warning --- htdocs/bookmarks/card.php | 8 +++++--- htdocs/bookmarks/list.php | 10 ++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 5b22b8918d9..245161ed253 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -188,7 +188,8 @@ if ($action == 'create') { // Visibility / Owner print ''.$langs->trans("Visibility").''; - print img_picto('', 'user').' '.$form->select_dolusers(GETPOSTISSET('userid') ? GETPOST('userid', 'int') : $user->id, 'userid', 0, '', 0, ($user->admin ? '' : array($user->id)), '', 0, 0, 0, '', ($user->admin) ? 1 : 0, '', 'maxwidth300 widthcentpercentminusx'); + print img_picto('', 'user', 'class="pictofixedwidth"'); + print $form->select_dolusers(GETPOSTISSET('userid') ? GETPOST('userid', 'int') : $user->id, 'userid', 0, '', 0, ($user->admin ? '' : array($user->id)), '', 0, 0, 0, '', ($user->admin) ? 1 : 0, '', 'maxwidth300 widthcentpercentminusx'); print ''; // Position @@ -282,12 +283,13 @@ if ($id > 0 && !preg_match('/^add/i', $action)) { // Visibility / owner print ''.$langs->trans("Visibility").''; if ($action == 'edit' && $user->admin) { - print img_picto('', 'user').' '.$form->select_dolusers(GETPOSTISSET('userid') ? GETPOST('userid', 'int') : ($object->fk_user ? $object->fk_user : ''), 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300 widthcentpercentminusx'); + print img_picto('', 'user', 'class="pictofixedwidth"'); + print $form->select_dolusers(GETPOSTISSET('userid') ? GETPOST('userid', 'int') : ($object->fk_user ? $object->fk_user : ''), 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300 widthcentpercentminusx'); } else { if ($object->fk_user > 0) { $fuser = new User($db); $fuser->fetch($object->fk_user); - print $fuser->getNomUrl(1); + print $fuser->getNomUrl(-1); } else { print ''.$langs->trans("Everybody").''; } diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index 2500d40e25d..2adef615a70 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -212,8 +212,6 @@ print_liste_field_titre("Position", $_SERVER["PHP_SELF"], "b.position", "", $par print_liste_field_titre(''); print "\n"; -$cacheOfUsers = array(); - $i = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -268,13 +266,13 @@ while ($i < min($num, $limit)) { // Author print ''; if ($obj->fk_user) { - if (empty($cacheOfUsers[$obj->fk_user])) { + if (empty($conf->cache['users'][$obj->fk_user])) { $tmpuser = new User($db); $tmpuser->fetch($obj->fk_user); - $cacheOfUsers[$obj->fk_user] = $tmpuser; + $conf->cache['users'][$obj->fk_user] = $tmpuser; } - $tmpuser = $cacheOfUsers[$obj->fk_user]; - print $tmpuser->getNomUrl(1); + $tmpuser = $conf->cache['users'][$obj->fk_user]; + print $tmpuser->getNomUrl(-1); } else { print ''.$langs->trans("Everybody").''; if (!$user->admin) { From e4515f01c04763794b3789e5fadcfcf16bf81b9d Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 14 Jan 2023 11:56:41 +0100 Subject: [PATCH 14/43] Fix php 8 warnings --- htdocs/core/lib/ticket.lib.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 5d0d691228e..2c218421543 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -91,7 +91,7 @@ function ticket_prepare_head($object) $head[$h][2] = 'tabTicket'; $h++; - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid) && isModEnabled("societe")) { + if (!getDolGlobalInt('MAIN_DISABLE_CONTACTS_TAB') && empty($user->socid) && isModEnabled("societe")) { $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id; $head[$h][1] = $langs->trans('ContactsAddresses'); @@ -166,7 +166,7 @@ function showDirectPublicLink($object) } $out = ''; - if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { + if (!getDolGlobalInt('TICKET_ENABLE_PUBLIC_INTERFACE')) { $langs->load('errors'); $out .= ''.$langs->trans("ErrorPublicInterfaceNotEnabled").''; } else { @@ -223,9 +223,9 @@ function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $ print '
'; // Define urllogo - if (!empty($conf->global->TICKET_SHOW_COMPANY_LOGO) || !empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) { + if (getDolGlobalInt('TICKET_SHOW_COMPANY_LOGO') || getDolGlobalString('TICKET_PUBLIC_INTERFACE_TOPIC')) { // Print logo - if (!empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) { + if (getDolGlobalInt('TICKET_SHOW_COMPANY_LOGO')) { $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png'; if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { @@ -239,28 +239,28 @@ function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $ } // Output html code for logo - if ($urllogo || !empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) { + if ($urllogo || getDolGlobalInt('TICKET_PUBLIC_INTERFACE_TOPIC')) { print '
'; print '
'; if ($urllogo) { - print ''; + print ''; print ''; print ''; } - if (!empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) { - print '
'.($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")).''; + if (getDolGlobalInt('TICKET_PUBLIC_INTERFACE_TOPIC')) { + print '
'.(getDolGlobalString('TICKET_PUBLIC_INTERFACE_TOPIC') ? getDolGlobalString('TICKET_PUBLIC_INTERFACE_TOPIC') : $langs->trans("TicketSystem")).''; } print '
'; - if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { + if (!getDolGlobalInt('MAIN_HIDE_POWERED_BY')) { print ''; } print '
'; } - if (!empty($conf->global->TICKET_IMAGE_PUBLIC_INTERFACE)) { + if (getDolGlobalInt('TICKET_IMAGE_PUBLIC_INTERFACE')) { print '
'; - print ''; + print ''; print '
'; } From f0f3deb6198130d6e8a150021db0a6422534acbe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Jan 2023 13:06:13 +0100 Subject: [PATCH 15/43] Debug v17 --- htdocs/compta/bank/class/account.class.php | 6 +- htdocs/user/bank.php | 89 +++++++-------------- htdocs/user/class/userbankaccount.class.php | 61 +++++++++++++- htdocs/user/notify/card.php | 6 +- 4 files changed, 95 insertions(+), 67 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 4aea92a510e..74db4005126 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1077,8 +1077,6 @@ class Account extends CommonObject */ public function delete(User $user = null) { - global $conf; - $error = 0; $this->db->begin(); @@ -1096,8 +1094,8 @@ class Account extends CommonObject } if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_account"; - $sql .= " WHERE rowid = ".((int) $this->rowid); + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index fb795ecc6e4..1552ff94d82 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -25,7 +25,7 @@ /** * \file htdocs/user/bank.php * \ingroup HRM - * \brief Tab for HRM + * \brief Tab for HR and bank */ // Load Dolibarr environment @@ -79,7 +79,6 @@ if (empty($account->userid)) { $account->userid = $object->id; } - // Define value to know what current user can do on users $canadduser = (!empty($user->admin) || $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write); $canreaduser = (!empty($user->admin) || $user->rights->user->user->lire || $user->rights->hrm->read_personal_information->read); @@ -143,49 +142,6 @@ if ($action == 'add' && !$cancel && $permissiontoaddbankaccount) { if ($action == 'update' && !$cancel && $permissiontoaddbankaccount) { $account->userid = $object->id; - /* - if ($action == 'update' && !$cancel) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - if ($canedituser) // Case we can edit all field - { - $error = 0; - - if (!$error) - { - $objectuser->fetch($id); - - $objectuser->oldcopy = dol_clone($objectuser); - - $db->begin(); - - $objectuser->default_range = GETPOST('default_range'); - $objectuser->default_c_exp_tax_cat = GETPOST('default_c_exp_tax_cat'); - - if (!$error) { - $ret = $objectuser->update($user); - if ($ret < 0) { - $error++; - if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorLoginAlreadyExists", $objectuser->login), null, 'errors'); - } else { - setEventMessages($objectuser->error, $objectuser->errors, 'errors'); - } - } - } - - if (!$error && !count($objectuser->errors)) { - setEventMessages($langs->trans("UserModified"), null, 'mesgs'); - $db->commit(); - } else { - $db->rollback(); - } - } - } - }*/ - $account->bank = GETPOST('bank', 'alpha'); $account->label = GETPOST('label', 'alpha'); $account->courant = GETPOST('courant', 'alpha'); @@ -214,6 +170,18 @@ if ($action == 'update' && !$cancel && $permissiontoaddbankaccount) { } } +if ($action == 'delete_confirmed' && !$cancel && $permissiontoaddbankaccount) { + $result = $account->delete($user); + if ($result < 0) { + setEventMessages($account->error, $account->errors, 'errors'); + } else { + setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); + header("Location: ".DOL_URL_ROOT.'/user/bank.php?id='.$object->id); + exit; + } + $action = ''; +} + // update birth if ($action == 'setbirth' && $canadduser && !$cancel) { $object->birth = dol_mktime(0, 0, 0, GETPOST('birthmonth', 'int'), GETPOST('birthday', 'int'), GETPOST('birthyear', 'int')); @@ -819,32 +787,32 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac if ($account->id > 0) { print ''; // Label - print ''.$account->label.''; + print ''.dol_escape_htmltag($account->label).''; // Bank name - print ''.$account->bank.''; + print ''.dol_escape_htmltag($account->bank).''; // Account number print ''; - $string = ''; + $stringescaped = ''; foreach ($account->getFieldsToShow() as $val) { if ($val == 'BankCode') { - $string .= $account->code_banque.' '; + $stringescaped .= dol_escape_htmltag($account->code_banque).' '; } elseif ($val == 'BankAccountNumber') { - $string .= $account->number.' '; + $stringescaped .= dol_escape_htmltag($account->number).' '; } elseif ($val == 'DeskCode') { - $string .= $account->code_guichet.' '; + $stringescaped .= dol_escape_htmltag($account->code_guichet).' '; } elseif ($val == 'BankAccountNumberKey') { - $string .= $account->cle_rib.' '; + $stringescaped .= dol_escape_htmltag($account->cle_rib).' '; } } if (!empty($account->label) && $account->number) { if (!checkBanForAccount($account)) { - $string .= ' '.img_picto($langs->trans("ValueIsNotValid"), 'warning'); + $stringescaped .= ' '.img_picto($langs->trans("ValueIsNotValid"), 'warning'); } else { - $string .= ' '.img_picto($langs->trans("ValueIsValid"), 'info'); + $stringescaped .= ' '.img_picto($langs->trans("ValueIsValid"), 'info'); } } - print $string; + print $stringescaped; print ''; // IBAN print ''.getIbanHumanReadable($account); @@ -855,7 +823,8 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac } print ''; // BIC - print ''.$account->bic; + print ''; + print dol_escape_htmltag($account->bic); if (!empty($account->bic)) { if (!checkSwiftForAccount($account)) { print ' '.img_picto($langs->trans("SwiftNotValid"), 'warning'); @@ -869,9 +838,13 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac // Edit/Delete print ''; if ($permissiontoaddbankaccount) { - print ''; + print ''; print img_picto($langs->trans("Modify"), 'edit'); print ''; + + print ''; + print img_picto($langs->trans("Delete"), 'delete'); + print ''; } print ''; @@ -880,7 +853,7 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac if ($account->id == 0) { - $colspan = 6; + $colspan = 7; print ''.$langs->trans("NoBANRecord").''; } diff --git a/htdocs/user/class/userbankaccount.class.php b/htdocs/user/class/userbankaccount.class.php index 6e9cc8e52af..857f60d55e5 100644 --- a/htdocs/user/class/userbankaccount.class.php +++ b/htdocs/user/class/userbankaccount.class.php @@ -117,8 +117,6 @@ class UserBankAccount extends Account */ public function update(User $user = null, $notrigger = 0) { - global $conf; - if (!$this->id) { $this->create(); } @@ -193,7 +191,7 @@ class UserBankAccount extends Account $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; - $this->userid = $obj->fk_soc; + $this->userid = $obj->fk_user; $this->bank = $obj->bank; $this->code_banque = $obj->code_banque; $this->code_guichet = $obj->code_guichet; @@ -226,6 +224,63 @@ class UserBankAccount extends Account } } + /** + * Delete user bank account from database + * + * @param User $user User deleting + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user = null) + { + $error = 0; + + $this->db->begin(); + + // Delete link between tag and bank account + /* + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account"; + $sql .= " WHERE fk_account = ".((int) $this->id); + + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->error = "Error ".$this->db->lasterror(); + } + } + */ + + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE rowid = ".((int) $this->id); + + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + // Remove extrafields + /* + if (!$error) { + $result = $this->deleteExtraFields(); + if ($result < 0) { + $error++; + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); + } + }*/ + } else { + $error++; + $this->error = "Error ".$this->db->lasterror(); + } + } + + if (!$error) { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } + /** * Return RIB * diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index e20d7be3d9a..f55a42ca159 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -332,7 +332,8 @@ if ($result > 0) { $userstatic->email = $obj->email; $userstatic->statut = $obj->status; - print ''.$userstatic->getNomUrl(1); + print ''; + print ''.$userstatic->getNomUrl(1); if ($obj->type == 'email') { if (isValidEmail($obj->email)) { print ' <'.$obj->email.'>'; @@ -359,8 +360,9 @@ if ($result > 0) { $i++; } $db->free($resql); + } else { + print ''.$langs->trans("None").''; } - // List of notifications enabled for fixed email /* foreach($conf->global as $key => $val) { From f9158c9a0201b23906458fd881f1bf2056f178f1 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 14 Jan 2023 14:47:58 +0100 Subject: [PATCH 16/43] Fix php 8 warnings --- htdocs/societe/paymentmodes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 744d2763b71..de2c45381cb 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -6,7 +6,7 @@ * Copyright (C) 2013 Peter Fontaine * Copyright (C) 2015-2016 Marcos García * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2018-2021 Thibault FOUCART + * Copyright (C) 2018-2023 Thibault FOUCART * Copyright (C) 2021 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -1378,7 +1378,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' if (is_array($currencybalance)) { foreach ($currencybalance as $cpt) { - print ''.$langs->trans("Currency".strtoupper($cpt['currency'])).''.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt['available'] + $cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''; + print ''.$langs->trans("Currency".strtoupper($cpt['currency'])).''.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price(isset($cpt->pending)?$cpt->pending:0, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt['available'] + (isset($cpt->pending)?$cpt->pending:0), 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''; } } From 3e273d40042a7fd9f3769a25da155566d9dbc238 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Jan 2023 15:11:15 +0100 Subject: [PATCH 17/43] Debug v17 --- htdocs/accountancy/expensereport/list.php | 1 - htdocs/accountancy/journal/bankjournal.php | 12 +- htdocs/compta/accounting-files.php | 5 + htdocs/compta/stats/byratecountry.php | 4 +- htdocs/compta/stats/casoc.php | 14 +- htdocs/compta/stats/index.php | 12 +- .../class/conferenceorbooth.class.php | 10 +- .../conferenceorbooth_list.php | 204 ++++++++++++------ htdocs/holiday/list.php | 23 +- htdocs/holiday/month_report.php | 75 ++++--- htdocs/hrm/class/establishment.class.php | 31 +-- .../knowledgerecord_list.php | 2 +- .../modulebuilder/template/myobject_list.php | 1 + .../recruitmentcandidature_agenda.php | 1 + .../recruitmentjobposition_agenda.php | 9 +- htdocs/user/agenda_extsites.php | 30 +++ htdocs/user/perms.php | 17 ++ 17 files changed, 311 insertions(+), 140 deletions(-) diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 9cfbd940875..25b86a8d527 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -443,7 +443,6 @@ if ($result) { $expensereport_static->id = $objp->erid; $userstatic->id = $objp->userid; - $userstatic->ref = $objp->label; $userstatic->login = $objp->login; $userstatic->statut = $objp->statut; $userstatic->email = $objp->email; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 699002395ab..c23392cada0 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -349,7 +349,11 @@ if ($result) { $societestatic->email = $tabcompany[$obj->rowid]['email']; $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); if ($compta_soc) { - $tabtp[$obj->rowid][$compta_soc] += $amounttouse; + if (empty($tabtp[$obj->rowid][$compta_soc])) { + $tabtp[$obj->rowid][$compta_soc] = $amounttouse; + } else { + $tabtp[$obj->rowid][$compta_soc] += $amounttouse; + } } } elseif ($links[$key]['type'] == 'user') { $userstatic->id = $links[$key]['url_id']; @@ -510,7 +514,11 @@ if ($result) { } } - $tabbq[$obj->rowid][$compta_bank] += $amounttouse; + if (empty($tabbq[$obj->rowid][$compta_bank])) { + $tabbq[$obj->rowid][$compta_bank] = $amounttouse; + } else { + $tabbq[$obj->rowid][$compta_bank] += $amounttouse; + } // If no links were found to know the amount on thirdparty, we try to guess it. // This may happens on bank entries without the links lines to 'company'. diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 2f2f5816ae1..af8d626eba1 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -376,6 +376,9 @@ if (($action == 'searchfiles' || $action == 'dl')) { $nofile['country_code'] = $objd->country_code; $nofile['vatnum'] = $objd->vatnum; $nofile['sens'] = $objd->sens; + $nofile['currency'] = $objd->currency; + $nofile['link'] = ''; + $nofile['name'] = ''; $filesarray[$nofile['item'].'_'.$nofile['id']] = $nofile; } else { @@ -396,6 +399,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $file['country_code'] = $objd->country_code; $file['vatnum'] = $objd->vatnum; $file['sens'] = $objd->sens; + $file['currency'] = $objd->currency; // Save record into array (only the first time it is found) if (empty($filesarray[$file['item'].'_'.$file['id']])) { @@ -415,6 +419,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { 'relpathnamelang' => $langs->trans($file['item']).'/'.$file['name'], 'modulepart' => $modulepart, 'subdir' => $subdir, + 'currency' => $file['currency'] ); //var_dump($file['item'].'_'.$file['id']); //var_dump($filesarray[$file['item'].'_'.$file['id']]['files']); diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php index fb8ad4de1a5..b9dd6c7429d 100644 --- a/htdocs/compta/stats/byratecountry.php +++ b/htdocs/compta/stats/byratecountry.php @@ -461,9 +461,9 @@ if ($modecompta == 'CREANCES-DETTES') { $j -= 12; } $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); - print ''.price($totalpermonth[$j]).''; + print ''.price(empty($totalpermonth[$j]) ? 0 : $totalpermonth[$j]).''; } - print ''.price($totalpermonth['total']).''; + print ''.price(empty($totalpermonth['total']) ? 0 : $totalpermonth['total']).''; print ''; } else { print $db->lasterror(); // Show last sql error diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index d24e5a5452a..b499ca17c71 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -406,12 +406,16 @@ if ($modecompta == "RECETTES-DEPENSES") { while ($i < $num) { $obj = $db->fetch_object($result); - $amount[$obj->rowid] += $obj->amount_ttc; + if (empty($amount[$obj->socid])) { + $amount[$obj->socid] = $obj->amount_ttc; + } else { + $amount[$obj->socid] += $obj->amount_ttc; + } - $name[$obj->rowid] = $obj->name; - $address_zip[$obj->rowid] = $obj->zip; - $address_town[$obj->rowid] = $obj->town; - $address_pays[$obj->rowid] = getCountry($obj->fk_pays); + $name[$obj->socid] = $obj->name; + $address_zip[$obj->socid] = ''; + $address_town[$obj->socid] = ''; + $address_pays[$obj->socid] = 0; $catotal += $obj->amount_ttc; diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 058fba33177..7d70bc10527 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -577,7 +577,7 @@ for ($annee = $year_start; $annee <= $year_end; $annee++) { // Montant total HT if ($total_ht[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear))) { print ''; - print ($total_ht[$annee] ?price($total_ht[$annee]) : "0"); + print (empty($total_ht[$annee]) ? '0' : price($total_ht[$annee])); print ""; } else { print ' '; @@ -587,7 +587,7 @@ for ($annee = $year_start; $annee <= $year_end; $annee++) { // Total amount if (!empty($total[$annee]) || ($annee >= $minyear && $annee <= max($nowyear, $maxyear))) { print ''; - print ($total[$annee] ?price($total[$annee]) : "0"); + print (empty($total[$annee]) ? '0' : price($total[$annee])); print ""; } else { print ' '; @@ -595,19 +595,19 @@ for ($annee = $year_start; $annee <= $year_end; $annee++) { // Pourcentage total if ($annee > $minyear && $annee <= max($nowyear, $maxyear)) { - if ($total[$annee - 1] && $total[$annee]) { + if (!empty($total[$annee - 1]) && !empty($total[$annee])) { $percent = (round(($total[$annee] - $total[$annee - 1]) / $total[$annee - 1], 4) * 100); print ''; print ($percent >= 0 ? "+$percent" : "$percent").'%'; print ''; } - if ($total[$annee - 1] && !$total[$annee]) { + if (!empty($total[$annee - 1]) && empty($total[$annee])) { print '-100%'; } - if (!$total[$annee - 1] && $total[$annee]) { + if (empty($total[$annee - 1]) && !empty($total[$annee])) { print '+'.$langs->trans('Inf').'%'; } - if (!$total[$annee - 1] && !$total[$annee]) { + if (empty($total[$annee - 1]) && empty($total[$annee])) { print '+0%'; } } else { diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 556443a25e8..db0928efc7d 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -104,12 +104,12 @@ class ConferenceOrBooth extends ActionComm */ public $fields = array( 'id' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), - 'ref' => array('type'=>'integer', 'label'=>'Ref', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>2, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), - 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax125', 'help'=>"OrganizationEvenLabelName", 'showoncombobox'=>'1',), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"OrganizationEventLinkToThirdParty", 'picto'=>'company', 'css'=>'tdoverflowmax150 maxwidth500'), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1:t.usage_organize_event=1', 'label'=>'Project', 'enabled'=>"isModEnabled('project')", 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1, 'picto'=>'project', 'css'=>'tdoverflowmax150 maxwidth500'), + 'ref' => array('type'=>'integer', 'label'=>'Ref', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>2, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'csslist'=>'left', 'comment'=>"Id"), + 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax125', 'help'=>"OrganizationEvenLabelName", 'showoncombobox'=>'1', 'autofocusoncreate'=>1), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"OrganizationEventLinkToThirdParty", 'picto'=>'company', 'css'=>'tdoverflowmax150 maxwidth500', 'csslist'=>'width100'), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1:t.usage_organize_event=1', 'label'=>'Project', 'enabled'=>"isModEnabled('project')", 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1, 'picto'=>'project', 'css'=>'tdoverflowmax150 maxwidth500', 'csslist'=>'width100'), 'note' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1), - 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1, 'css'=>'width300'), + 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1, 'css'=>'width100'), 'datep' => array('type'=>'datetime', 'label'=>'DateStart', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'2',), 'datep2' => array('type'=>'datetime', 'label'=>'DateEnd', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'3',), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index dd7bfd93a47..1dd77122384 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -25,17 +25,14 @@ // Load Dolibarr environment require '../main.inc.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; global $dolibarr_main_url_root; @@ -56,6 +53,7 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'conferenceorboothlist'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...) $id = GETPOST('id', 'int'); $projectid = GETPOST('projectid', 'int'); @@ -67,8 +65,9 @@ $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; -} // If $page is not defined, or '' or -1 or if we click on clear filters +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -120,11 +119,11 @@ $arrayfields = array(); foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field if (!empty($val['visible'])) { - $visible = (int) dol_eval($val['visible'], 1, 1, '1'); + $visible = (int) dol_eval($val['visible'], 1); $arrayfields['t.'.$key] = array( 'label'=>$val['label'], 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')), + 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)), 'position'=>$val['position'], 'help'=> isset($val['help']) ? $val['help'] : '' ); @@ -235,9 +234,11 @@ if (empty($reshook)) { $form = new Form($db); $now = dol_now(); -$title = $langs->trans('ListOfConferencesOrBooths'); //$help_url="EN:Module_ConferenceOrBooth|FR:Module_ConferenceOrBooth_FR|ES:Módulo_ConferenceOrBooth"; $help_url = ''; +$title = $langs->trans('ListOfConferencesOrBooths'); +$morejs = array(); +$morecss = array(); if ($projectid > 0 || $projectref) { $project = new Project($db); @@ -524,9 +525,13 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); +//$sql .= ", COUNT(rc.rowid) as anotherfield"; + +$sqlfields = $sql; // $sql fields to remove for count total + $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.id = ef.fk_object)"; +if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } $sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_actioncomm as cact ON cact.id=t.fk_action AND cact.module LIKE '%@eventorganization'"; // Add table from hooks @@ -554,17 +559,17 @@ foreach ($search as $key => $val) { $mode_search = 2; } if ($search[$key] != '') { - $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search)); } } else { if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key); if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { if (preg_match('/_dtstart$/', $key)) { - $sql .= " AND t.".$columnName." >= '".$db->idate($search[$key])."'"; + $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'"; } if (preg_match('/_dtend$/', $key)) { - $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'"; + $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'"; } } } @@ -582,35 +587,42 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql .= $db->order($sortfield, $sortorder); - // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } + + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); } -// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { - $num = $nbtotalofrecords; -} else { - if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); - } - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - exit; - } +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); - $num = $db->num_rows($resql); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); } +$resql = $db->query($sql); +if (!$resql) { + dol_print_error($db); + exit; +} + +$num = $db->num_rows($resql); + // Direct jump if only one record found if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { $obj = $db->fetch_object($resql); @@ -622,6 +634,9 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -629,11 +644,17 @@ if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) { + if (is_array($search[$key])) { foreach ($search[$key] as $skey) { - $param .= '&search_'.$key.'[]='.urlencode($skey); + if ($skey != '') { + $param .= '&search_'.$key.'[]='.urlencode($skey); + } } - } else { + } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) { + $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int')); + $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int')); + $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int')); + } elseif ($search[$key] != '') { $param .= '&search_'.$key.'='.urlencode($search[$key]); } } @@ -655,7 +676,7 @@ $arrayofmassactions = array( 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail").' ('.$langs->trans("ToSpeakers").')', //'presend_attendees'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail").' - '.$langs->trans("Attendees"), ); -if ($permissiontodelete) { +if (!empty($permissiontodelete)) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { @@ -672,8 +693,11 @@ print ''; print ''; print ''; +print ''; print ''; print ''; +print ''; + $title = $langs->trans("EventOrganizationConfOrBoothes"); @@ -683,7 +707,7 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sort // Add code for pre mass action (confirmation or email presend form) -$topicmail = $projectstatic->title; +$topicmail = ''; $modelmail = "conferenceorbooth"; $objecttmp = new ConferenceOrBooth($db); $trackid = 'conferenceorbooth_'.$object->id; @@ -692,10 +716,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { + $setupstring = ''; foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); + $setupstring .= $key."=".$val.";"; } - print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; + print ''."\n"; + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; } $moreforfilter = ''; @@ -718,7 +745,7 @@ if (!empty($moreforfilter)) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); @@ -729,9 +756,15 @@ print ''; +// Action column +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} foreach ($object->fields as $key => $val) { - $searchkey = (empty($search[$key]) ? '' : $search[$key]); - + $searchkey = empty($search[$key]) ? '' : $search[$key]; $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { $cssforfield .= ($cssforfield ? ' ' : '').'center'; @@ -739,17 +772,15 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; } @@ -769,16 +806,23 @@ $parameters = array('arrayfields'=>$arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -print ''; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} print ''."\n"; +$totalarray = array(); +$totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print ''; +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { @@ -787,27 +831,32 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'ref')) && $val['label'] != 'TechnicalID') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $key != 'ref' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } + $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label if (!empty($arrayfields['t.'.$key]['checked'])) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + $totalarray['nbfield']++; } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} +$totalarray['nbfield']++; print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { +if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { if (preg_match('/\$object/', $val)) { $needToFetchEachLine++; // There is at least one compute field that use $object @@ -819,8 +868,11 @@ if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_a // Loop on record // -------------------------------------------------------------------- $i = 0; +$savnbfield = $totalarray['nbfield']; $totalarray = array(); -while ($i < ($limit ? min($num, $limit) : $num)) { +$totalarray['nbfield'] = 0; +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); if (empty($obj)) { break; // Should not happen @@ -830,10 +882,22 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $object->setVarsFromFetchObj($obj); // Show here line of result - print ''; - $totalarray['nbfield'] = 0; + $j = 0; + print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['css']) ? '' : $val['css']); + $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif ($key == 'status') { @@ -843,7 +907,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; } elseif ($key == 'ref') { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap left'; + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; } if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'ref', 'status'))) { @@ -852,7 +916,11 @@ while ($i < ($limit ? min($num, $limit) : $num)) { //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; + print ''; if ($key == 'status') { print $object->getLibStatut(5); } elseif ($key == 'ref') { @@ -885,15 +953,17 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column - print ''; } - print ''; if (!$i) { $totalarray['nbfield']++; } @@ -921,7 +991,7 @@ if ($num == 0) { $db->free($resql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $searchkey, $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); - } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) { - print $object->showInputField($val, $key, $searchkey, '', '', 'search_', 'maxwidth125', 1); - } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - print ''; + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status onrightofpage' : ''), 1); + } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { + print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1); } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { print '
'; print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); @@ -757,6 +788,12 @@ foreach ($object->fields as $key => $val) { print '
'; print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); print '
'; + } elseif ($key == 'lang') { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; + $formadmin = new FormAdmin($db); + print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2); + } else { + print ''; } print '
'; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print '
'."\n"; diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 564fb8a2a96..dedfed07157 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -827,6 +827,9 @@ if ($resql) { print ''; } print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['cp.ref']['checked'])) { print ''; @@ -849,8 +852,11 @@ if ($resql) { } } if (!empty($arrayfields['cp.fk_type']['checked'])) { - $labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code']) != $typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']); - $labeltypeleavetoshow = empty($typeleaves[$obj->fk_type]['label']) ? $langs->trans("TypeWasDisabledOrRemoved", $obj->fk_type) : $labeltypeleavetoshow; + if (empty($typeleaves[$obj->fk_type])) { + $labeltypeleavetoshow = $langs->trans("TypeWasDisabledOrRemoved", $obj->fk_type); + } else { + $labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code']) != $typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']); + } print ''; print $labeltypeleavetoshow; @@ -941,9 +947,9 @@ if ($resql) { print ''; } print ''; - } - if (!$i) { - $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } print ''."\n"; @@ -954,6 +960,9 @@ if ($resql) { // Add a line for total if there is a total to show if (!empty($arrayfields['duration']['checked'])) { print ''; + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) { if ($key == 'duration') { @@ -964,7 +973,9 @@ if ($resql) { } } // status - print ''; + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } print ''; } } diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index a1a23715126..fe2d33ff78a 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -227,27 +227,34 @@ print '
'; $moreforfilter = ''; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = ''; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; -print ''; +print '
'; -print ''; +print ''; + +// Action column +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; +} // Filter: Ref if (!empty($arrayfields['cp.ref']['checked'])) { - print ''; } // Filter: Employee if (!empty($arrayfields['cp.fk_user']['checked'])) { - print ''; } // Filter: Type @@ -259,45 +266,50 @@ if (!empty($arrayfields['cp.fk_type']['checked'])) { $arraytypeleaves[$val['rowid']] = $labeltoshow; } - print ''; } if (!empty($arrayfields['cp.date_debut']['checked'])) { - print ''; + print ''; } if (!empty($arrayfields['cp.date_fin']['checked'])) { - print ''; + print ''; } if (!empty($arrayfields['used_days']['checked'])) { - print ''; + print ''; } if (!empty($arrayfields['date_start_month']['checked'])) { - print ''; + print ''; } if (!empty($arrayfields['date_end_month']['checked'])) { - print ''; + print ''; } if (!empty($arrayfields['used_days_month']['checked'])) { - print ''; + print ''; } // Filter: Description if (!empty($arrayfields['cp.description']['checked'])) { - print ''; } - // Action column -print ''; +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; +} print ''; print ''; +// Action column +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} if (!empty($arrayfields['cp.ref']['checked'])) { print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], 'cp.ref', '', '', '', $sortfield, $sortorder); } @@ -331,11 +343,14 @@ if (!empty($arrayfields['used_days_month']['checked'])) { if (!empty($arrayfields['cp.description']['checked'])) { print_liste_field_titre($arrayfields['cp.description']['label'], $_SERVER["PHP_SELF"], 'cp.description', '', '', '', $sortfield, $sortorder); } -print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +// Action column +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} print ''; if ($num == 0) { - print ''; + print ''; } else { while ($obj = $db->fetch_object($resql)) { $user = new User($db); @@ -385,6 +400,10 @@ if ($num == 0) { $holidaystatic->ref = $obj->ref; print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } if (!empty($arrayfields['cp.ref']['checked'])) { print ''; @@ -430,8 +449,10 @@ if ($num == 0) { if (!empty($arrayfields['cp.description']['checked'])) { print ''; } - - print ''; + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } print ''; } } diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index 6a37ba1e929..05bd8d47cf8 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -285,7 +285,7 @@ class Establishment extends CommonObject * Load an object from database * * @param int $id Id of record to load - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >=0 if OK */ public function fetch($id) { @@ -299,21 +299,24 @@ class Establishment extends CommonObject $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); + if ($obj) { + $this->id = $obj->rowid; + $this->ref = $obj->ref; + $this->label = $obj->label; + $this->address = $obj->address; + $this->zip = $obj->zip; + $this->town = $obj->town; + $this->status = $obj->status; + $this->entity = $obj->entity; - $this->id = $obj->rowid; - $this->ref = $obj->ref; - $this->label = $obj->label; - $this->address = $obj->address; - $this->zip = $obj->zip; - $this->town = $obj->town; - $this->status = $obj->status; - $this->entity = $obj->entity; + $this->country_id = $obj->country_id; + $this->country_code = $obj->country_code; + $this->country = $obj->country; - $this->country_id = $obj->country_id; - $this->country_code = $obj->country_code; - $this->country = $obj->country; - - return 1; + return 1; + } else { + return 0; + } } else { $this->error = $this->db->lasterror(); return -1; diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index dffd3d63d7b..cafb5776cf7 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -501,7 +501,7 @@ if (!empty($moreforfilter)) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 1135f6d9498..95442195ff9 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -492,6 +492,7 @@ print ''; print ''; print ''; print ''; +print ''; print ''; diff --git a/htdocs/recruitment/recruitmentcandidature_agenda.php b/htdocs/recruitment/recruitmentcandidature_agenda.php index 04118f55572..3648b8ca13b 100644 --- a/htdocs/recruitment/recruitmentcandidature_agenda.php +++ b/htdocs/recruitment/recruitmentcandidature_agenda.php @@ -41,6 +41,7 @@ $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); $socid = GETPOST('socid', 'int'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); diff --git a/htdocs/recruitment/recruitmentjobposition_agenda.php b/htdocs/recruitment/recruitmentjobposition_agenda.php index f2f4d37484b..fab164dcd2f 100644 --- a/htdocs/recruitment/recruitmentjobposition_agenda.php +++ b/htdocs/recruitment/recruitmentjobposition_agenda.php @@ -40,6 +40,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); @@ -79,7 +80,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id; + $upload_dir = $conf->recruitment->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id; } $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php @@ -163,11 +164,11 @@ if ($object->id > 0) { $morehtmlref .= '
'; $morehtmlref .= ''; $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, 0, $object->fk_project, 'none', 0, 0, 0, 1); } } else { if (!empty($object->fk_project)) { @@ -228,7 +229,7 @@ if ($object->id > 0) { print '
'; if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $param = '&id='.$object->id.'&socid='.$socid; + $param = '&id='.$object->id; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php index 4891480cc2d..c2b58c4e2a0 100644 --- a/htdocs/user/agenda_extsites.php +++ b/htdocs/user/agenda_extsites.php @@ -176,8 +176,38 @@ $morehtmlref .= ''; dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', $morehtmlref); +print '
'; print '
'; +print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; + print ''; print ''; - print ''; + print ''; + print ''; print $form->select_dolusers($search_employee, "search_employee", 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth100'); - print ''; + print ''; + print ''; print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1, 0, 0, '', 0, 0, 0, '', '', 1); - print ''; + print ''; + print ''; print ''; - print ''; + print ''; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'.$langs->trans('None').'
'.$langs->trans('None').'
'.$holidaystatic->getNomUrl(1, 1).''.dolGetFirstLineOfText(dol_string_nohtmltag($obj->description, 1)).'
'; + +// Login +print ''; +if (!empty($object->ldap_sid) && $object->statut == 0) { + print ''; +} else { + print ''; +} +print ''."\n"; + +print '
'.$langs->trans("Login").''; + print $langs->trans("LoginAccountDisableInDolibarr"); + print ''; + $addadmin = ''; + if (property_exists($object, 'admin')) { + if (isModEnabled('multicompany') && !empty($object->admin) && empty($object->entity)) { + $addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "redstar", 'class="paddingleft"'); + } elseif (!empty($object->admin)) { + $addadmin .= img_picto($langs->trans("AdministratorDesc"), "star", 'class="paddingleft"'); + } + } + print showValueWithClipboardCPButton($object->login).$addadmin; + print '
'; + +print '
'; + +print dol_get_fiche_end(); + print '
'; print ''.$langs->trans("AgendaExtSitesDesc")."
\n"; diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index a65762b6183..1cd094d882d 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -288,6 +288,23 @@ if (!empty($object->ldap_sid) && $object->statut == 0) { } print ''."\n"; +// Type +print ''; +$text = $langs->trans("Type"); +print $form->textwithpicto($text, $langs->trans("InternalExternalDesc")); +print ''; +$type = $langs->trans("Internal"); +if ($object->socid > 0) { + $type = $langs->trans("External"); +} +print ''; +print $type; +if ($object->ldap_sid) { + print ' ('.$langs->trans("DomainUser").')'; +} +print ''; +print ''."\n"; + print ''; print '
'; From b54a15f5047ae977bf39ec959161aa6931c7763f Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 15 Jan 2023 09:11:29 +0100 Subject: [PATCH 18/43] Fix missing keywords in dol_dir_list_in_database --- htdocs/core/lib/files.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 21c290b595d..4195dee8dc1 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -344,6 +344,7 @@ function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir) $filearray[$key]['position_name'] = ($filearrayindatabase[$key2]['position'] ? $filearrayindatabase[$key2]['position'] : '0').'_'.$filearrayindatabase[$key2]['name']; $filearray[$key]['position'] = $filearrayindatabase[$key2]['position']; $filearray[$key]['cover'] = $filearrayindatabase[$key2]['cover']; + $filearray[$key]['keywords'] = $filearrayindatabase[$key2]['keywords']; $filearray[$key]['acl'] = $filearrayindatabase[$key2]['acl']; $filearray[$key]['rowid'] = $filearrayindatabase[$key2]['rowid']; $filearray[$key]['label'] = $filearrayindatabase[$key2]['label']; From fe2a58cf1d4beb1650c3089a306a7295b388451c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Jan 2023 11:36:31 +0100 Subject: [PATCH 19/43] Fix popup of companies in contract home page --- htdocs/contrat/index.php | 113 ++++++++++++++++++++++++++++----------- 1 file changed, 81 insertions(+), 32 deletions(-) diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index d537934a299..c14775449c6 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -241,7 +241,7 @@ print "
"; if (isModEnabled('contrat') && $user->rights->contrat->lire) { $sql = "SELECT c.rowid, c.ref,"; - $sql .= " s.nom as name, s.rowid as socid"; + $sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -266,8 +266,6 @@ if (isModEnabled('contrat') && $user->rights->contrat->lire) { print ''; print ''.$langs->trans("DraftContracts").($num ? ''.$num.'' : '').''; if ($num) { - $companystatic = new Societe($db); - $i = 0; //$tot_ttc = 0; while ($i < $num) { @@ -276,22 +274,29 @@ if (isModEnabled('contrat') && $user->rights->contrat->lire) { $staticcontrat->ref = $obj->ref; $staticcontrat->id = $obj->rowid; - $companystatic->id = $obj->socid; - $companystatic->name = $obj->name; - $companystatic->client = 1; + $staticcompany->id = $obj->socid; + $staticcompany->name = $obj->name; + $staticcompany->name_alias = $obj->name_alias; + $staticcompany->photo = 1; + $staticcompany->code_client = $obj->code_client; + $staticcompany->code_fournisseur = $obj->code_fournisseur; + $staticcompany->code_compta = $obj->code_compta; + $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur; + $staticcompany->client = $obj->client; + $staticcompany->fournisseur = $obj->fournisseur; print ''; print $staticcontrat->getNomUrl(1, ''); print ''; print ''; - print $companystatic->getNomUrl(1, '', 16); + print $staticcompany->getNomUrl(1, '', 16); print ''; print ''; //$tot_ttc+=$obj->total_ttc; $i++; } } else { - print ''.$langs->trans("NoContracts").''; + print ''.$langs->trans("NoContracts").''; } print "
"; $db->free($resql); @@ -312,7 +317,8 @@ $sql .= " sum(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd. $sql .= " sum(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')", 1, 0).') as nb_expired,'; $sql .= " sum(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now - $conf->contrat->services->expires->warning_delay)."')", 1, 0).') as nb_late,'; $sql .= " sum(".$db->ifsql("cd.statut=5", 1, 0).') as nb_closed,'; -$sql .= " c.rowid as cid, c.ref, c.datec, c.tms, c.statut, s.nom as name, s.rowid as socid"; +$sql .= " c.rowid as cid, c.ref, c.datec, c.tms, c.statut,"; +$sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,"; @@ -328,7 +334,8 @@ if (empty($user->rights->societe->client->voir) && !$socid) { if ($socid) { $sql .= " AND s.rowid = ".((int) $socid); } -$sql .= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.statut, s.nom, s.rowid"; +$sql .= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.statut,"; +$sql .= " s.nom, s.name_alias, s.logo, s.rowid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; $sql .= " ORDER BY c.tms DESC"; $sql .= $db->plimit($max); @@ -356,6 +363,14 @@ if ($result) { $staticcompany->id = $obj->socid; $staticcompany->name = $obj->name; + $staticcompany->name_alias = $obj->name_alias; + $staticcompany->photo = 1; + $staticcompany->code_client = $obj->code_client; + $staticcompany->code_fournisseur = $obj->code_fournisseur; + $staticcompany->code_compta = $obj->code_compta; + $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur; + $staticcompany->client = $obj->client; + $staticcompany->fournisseur = $obj->fournisseur; print ''; print ''; @@ -389,9 +404,9 @@ if ($result) { print '
'; // Last modified services -$sql = "SELECT c.ref, c.fk_soc, "; +$sql = "SELECT c.ref, c.fk_soc as socid,"; $sql .= " cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat, cd.date_fin_validite,"; -$sql .= " s.nom as name,"; +$sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity"; $sql .= " FROM (".MAIN_DB_PREFIX."contrat as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; @@ -427,9 +442,23 @@ if ($resql) { print ''; print ''; + $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat); $staticcontrat->id = $obj->fk_contrat; + + $staticcompany->id = $obj->socid; + $staticcompany->name = $obj->name; + $staticcompany->name_alias = $obj->name_alias; + $staticcompany->photo = 1; + $staticcompany->code_client = $obj->code_client; + $staticcompany->code_fournisseur = $obj->code_fournisseur; + $staticcompany->code_compta = $obj->code_compta; + $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur; + $staticcompany->client = $obj->client; + $staticcompany->fournisseur = $obj->fournisseur; + print $staticcontrat->getNomUrl(1, 16); + //if (1 == 1) print img_warning($langs->trans("Late")); print ''; print ''; @@ -449,8 +478,6 @@ if ($resql) { } print ''; print ''; - $staticcompany->id = $obj->fk_soc; - $staticcompany->name = $obj->name; print $staticcompany->getNomUrl(1, '', 20); print ''; print ''; @@ -471,7 +498,7 @@ print '
'; // Not activated services $sql = "SELECT c.ref, c.fk_soc, cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat,"; -$sql .= " s.nom as name,"; +$sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity"; $sql .= " FROM (".MAIN_DB_PREFIX."contrat as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; @@ -507,19 +534,32 @@ if ($resql) { while ($i < $num) { $obj = $db->fetch_object($resql); + $staticcompany->id = $obj->fk_soc; + $staticcompany->name = $obj->name; + $staticcompany->name_alias = $obj->name_alias; + $staticcompany->photo = 1; + $staticcompany->code_client = $obj->code_client; + $staticcompany->code_fournisseur = $obj->code_fournisseur; + $staticcompany->code_compta = $obj->code_compta; + $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur; + $staticcompany->client = $obj->client; + $staticcompany->fournisseur = $obj->fournisseur; + + $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat); + $staticcontrat->id = $obj->fk_contrat; + + $productstatic->id = $obj->fk_product; + $productstatic->type = $obj->ptype; + $productstatic->ref = $obj->pref; + $productstatic->entity = $obj->pentity; + print ''; print ''; - $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat); - $staticcontrat->id = $obj->fk_contrat; print $staticcontrat->getNomUrl(1, 16); print ''; print ''; if ($obj->fk_product > 0) { - $productstatic->id = $obj->fk_product; - $productstatic->type = $obj->ptype; - $productstatic->ref = $obj->pref; - $productstatic->entity = $obj->pentity; print $productstatic->getNomUrl(1, '', 20); } else { print '
'.img_object($langs->trans("ShowService"), "service"); @@ -531,8 +571,6 @@ if ($resql) { } print ''; print ''; - $staticcompany->id = $obj->fk_soc; - $staticcompany->name = $obj->name; print $staticcompany->getNomUrl(1, '', 20); print ''; print ''; @@ -553,7 +591,7 @@ print '
'; // Expired services $sql = "SELECT c.ref, c.fk_soc, cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat,"; -$sql .= " s.nom as name,"; +$sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity"; $sql .= " FROM (".MAIN_DB_PREFIX."contrat as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; @@ -590,19 +628,32 @@ if ($resql) { while ($i < $num) { $obj = $db->fetch_object($resql); + $staticcompany->id = $obj->fk_soc; + $staticcompany->name = $obj->name; + $staticcompany->name_alias = $obj->name_alias; + $staticcompany->photo = 1; + $staticcompany->code_client = $obj->code_client; + $staticcompany->code_fournisseur = $obj->code_fournisseur; + $staticcompany->code_compta = $obj->code_compta; + $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur; + $staticcompany->client = $obj->client; + $staticcompany->fournisseur = $obj->fournisseur; + + $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat); + $staticcontrat->id = $obj->fk_contrat; + + $productstatic->id = $obj->fk_product; + $productstatic->type = $obj->ptype; + $productstatic->ref = $obj->pref; + $productstatic->entity = $obj->pentity; + print ''; print ''; - $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat); - $staticcontrat->id = $obj->fk_contrat; print $staticcontrat->getNomUrl(1, 16); print ''; print ''; if ($obj->fk_product > 0) { - $productstatic->id = $obj->fk_product; - $productstatic->type = $obj->ptype; - $productstatic->ref = $obj->pref; - $productstatic->entity = $obj->pentity; print $productstatic->getNomUrl(1, '', 20); } else { print '
'.img_object($langs->trans("ShowService"), "service"); @@ -614,8 +665,6 @@ if ($resql) { } print ''; print ''; - $staticcompany->id = $obj->fk_soc; - $staticcompany->name = $obj->name; print $staticcompany->getNomUrl(1, '', 20); print ''; print ''; From 5867b6249661cbd15873e4ec3a9a63a8ffb772c9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Jan 2023 10:57:31 +0100 Subject: [PATCH 20/43] Fix do not change password if same --- .../triggers/interface_50_modAgenda_ActionsAuto.class.php | 2 +- htdocs/langs/en_US/users.lang | 3 ++- htdocs/user/card.php | 2 +- htdocs/user/class/user.class.php | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index e3f798dec62..686f59a70c7 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -920,7 +920,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid = 0; } else { // TODO Merge all previous cases into this generic one - // $action = BILL_DELETE, TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, CONTACT_SENTBYMAIL, RECRUITMENTCANDIDATURE_MODIFY, ... + // $action = PASSWORD, BILL_DELETE, TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, CONTACT_SENTBYMAIL, RECRUITMENTCANDIDATURE_MODIFY, ... // Can also be a value defined by an external module like SENTBYSMS, COMPANY_SENTBYSMS, MEMBER_SENTBYSMS, ... // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function). // Note that these key can be set in agenda setup, only if defined into llx_c_action_trigger diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index 757e9f1dedf..cfd8cbb0362 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -66,7 +66,8 @@ LinkedToDolibarrUser=Link to user LinkedToDolibarrThirdParty=Link to third party CreateDolibarrLogin=Create a user CreateDolibarrThirdParty=Create a third party -LoginAccountDisableInDolibarr=Account disabled in Dolibarr. +LoginAccountDisableInDolibarr=Account disabled in Dolibarr +PASSWORDInDolibarr=Password modified in Dolibarr UsePersonalValue=Use personal value ExportDataset_user_1=Users and their properties DomainUser=Domain user %s diff --git a/htdocs/user/card.php b/htdocs/user/card.php index aa8460ec9d5..775a4db05dc 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -516,7 +516,7 @@ if (empty($reshook)) { } if (!$error) { - $ret = $object->update($user); + $ret = $object->update($user); // This may include call to setPassword if password has changed if ($ret < 0) { $error++; if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index e90252877d1..1f179758d57 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2032,9 +2032,9 @@ class User extends CommonObject // Update password if (!empty($this->pass)) { - if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) { + if ($this->pass != $this->pass_indatabase && !dol_verifyHash($this->pass, $this->pass_indatabase_crypted)) { // If a new value for password is set and different than the one crypted into database - $result = $this->setPassword($user, $this->pass, 0, $notrigger, $nosyncmemberpass); + $result = $this->setPassword($user, $this->pass, 0, $notrigger, $nosyncmemberpass, 0, 1); if ($result < 0) { return -5; } From 3fc2f9273d02a2104210546b36ac3ec69902091c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Jan 2023 12:33:54 +0100 Subject: [PATCH 21/43] Fix warning php8 --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 1188dd023ab..2ed8b1a012f 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -975,7 +975,7 @@ if (!defined('NOLOGIN')) { // Hooks on failed login $action = ''; $hookmanager->initHooks(array('login')); - $parameters = array('dol_authmode'=>$dol_authmode, 'dol_loginmesg'=>$_SESSION["dol_loginmesg"]); + $parameters = array('dol_authmode' => (isset($dol_authmode) ? $dol_authmode : ''), 'dol_loginmesg' => $_SESSION["dol_loginmesg"]); $reshook = $hookmanager->executeHooks('afterLoginFailed', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $error++; From 481215eef45175bafcada49258666abd7a2ec2f1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 16 Jan 2023 14:40:35 +0100 Subject: [PATCH 22/43] FIX Multicompany use "element" name and not "table_element" --- htdocs/asset/class/asset.class.php | 2 +- htdocs/asset/class/assetmodel.class.php | 2 +- htdocs/bom/class/bom.class.php | 4 ++-- htdocs/core/class/commonobject.class.php | 2 +- htdocs/eventorganization/class/conferenceorbooth.class.php | 2 +- .../class/conferenceorboothattendee.class.php | 2 +- htdocs/hrm/class/evaluation.class.php | 2 +- htdocs/hrm/class/evaluationdet.class.php | 2 +- htdocs/hrm/class/job.class.php | 2 +- htdocs/hrm/class/position.class.php | 2 +- htdocs/hrm/class/skill.class.php | 2 +- htdocs/hrm/class/skilldet.class.php | 2 +- htdocs/hrm/class/skillrank.class.php | 2 +- htdocs/knowledgemanagement/class/knowledgerecord.class.php | 2 +- htdocs/mrp/class/mo.class.php | 4 ++-- htdocs/partnership/class/partnership.class.php | 2 +- htdocs/partnership/class/partnership_type.class.php | 2 +- .../product/stock/stocktransfer/class/stocktransfer.class.php | 2 +- .../stock/stocktransfer/class/stocktransferline.class.php | 2 +- htdocs/recruitment/class/recruitmentcandidature.class.php | 2 +- htdocs/recruitment/class/recruitmentjobposition.class.php | 2 +- htdocs/ticket/class/cticketcategory.class.php | 2 +- htdocs/webhook/class/target.class.php | 2 +- htdocs/workstation/class/workstation.class.php | 2 +- 24 files changed, 26 insertions(+), 26 deletions(-) diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 7c2b55c045e..c01f4b967c4 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -410,7 +410,7 @@ class Asset extends CommonObject $sql .= $this->getFieldList('t'); $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= " WHERE t.entity IN (".getEntity($this->table_element).")"; + $sql .= " WHERE t.entity IN (".getEntity($this->element).")"; } else { $sql .= " WHERE 1 = 1"; } diff --git a/htdocs/asset/class/assetmodel.class.php b/htdocs/asset/class/assetmodel.class.php index fb574e6ea18..a973abc3764 100644 --- a/htdocs/asset/class/assetmodel.class.php +++ b/htdocs/asset/class/assetmodel.class.php @@ -348,7 +348,7 @@ class AssetModel extends CommonObject $sql .= $this->getFieldList('t'); $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= " WHERE t.entity IN (".getEntity($this->table_element).")"; + $sql .= " WHERE t.entity IN (".getEntity($this->element).")"; } else { $sql .= " WHERE 1 = 1"; } diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index cd5b119cabf..b819e438161 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -476,7 +476,7 @@ class BOM extends CommonObject $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if ($this->ismultientitymanaged) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } @@ -1736,7 +1736,7 @@ class BOMLine extends CommonObjectLine $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if ($this->ismultientitymanaged) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f1920c74931..471d835f4a3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9331,7 +9331,7 @@ abstract class CommonObject $sql .= ' WHERE 1 = 1'; // usage with empty id and empty ref is very rare } if (empty($id) && isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' AND t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' AND t.entity IN ('.getEntity($this->element).')'; } if ($morewhere) { $sql .= $morewhere; diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index db0928efc7d..bc21d7bb1c5 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -284,7 +284,7 @@ class ConferenceOrBooth extends ActionComm $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_actioncomm as cact ON cact.id=t.fk_action AND cact.module LIKE '%@eventorganization'"; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index 595eaf67eeb..be06f70979e 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -423,7 +423,7 @@ class ConferenceOrBoothAttendee extends CommonObject $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id = t.fk_actioncomm"; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } diff --git a/htdocs/hrm/class/evaluation.class.php b/htdocs/hrm/class/evaluation.class.php index 23ccc6c9fd2..51f8c8bc985 100644 --- a/htdocs/hrm/class/evaluation.class.php +++ b/htdocs/hrm/class/evaluation.class.php @@ -404,7 +404,7 @@ class Evaluation extends CommonObject $sql .= $this->getFieldList('t'); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } diff --git a/htdocs/hrm/class/evaluationdet.class.php b/htdocs/hrm/class/evaluationdet.class.php index 5489065e52d..50d2fac8821 100644 --- a/htdocs/hrm/class/evaluationdet.class.php +++ b/htdocs/hrm/class/evaluationdet.class.php @@ -373,7 +373,7 @@ class Evaluationline extends CommonObject $sql .= $this->getFieldList('t'); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } diff --git a/htdocs/hrm/class/job.class.php b/htdocs/hrm/class/job.class.php index 93950979a1a..076e223679d 100644 --- a/htdocs/hrm/class/job.class.php +++ b/htdocs/hrm/class/job.class.php @@ -374,7 +374,7 @@ class Job extends CommonObject $sql .= $this->getFieldList('t'); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index 98b5fd89be9..b685147a9b9 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -385,7 +385,7 @@ class Position extends CommonObject $sql .= $this->getFieldList('t'); $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN (' . getEntity($this->table_element) . ')'; + $sql .= ' WHERE t.entity IN (' . getEntity($this->element) . ')'; } else { $sql .= ' WHERE 1 = 1'; } diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index 3f56294a7b2..ec994a35746 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -443,7 +443,7 @@ class Skill extends CommonObject $sql .= $this->getFieldList('t'); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } diff --git a/htdocs/hrm/class/skilldet.class.php b/htdocs/hrm/class/skilldet.class.php index 4dface42230..3db74d26da1 100644 --- a/htdocs/hrm/class/skilldet.class.php +++ b/htdocs/hrm/class/skilldet.class.php @@ -366,7 +366,7 @@ class Skilldet extends CommonObject $sql .= $this->getFieldList('t'); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } diff --git a/htdocs/hrm/class/skillrank.class.php b/htdocs/hrm/class/skillrank.class.php index 2d75425823e..a08a647ca03 100644 --- a/htdocs/hrm/class/skillrank.class.php +++ b/htdocs/hrm/class/skillrank.class.php @@ -405,7 +405,7 @@ class SkillRank extends CommonObject $sql .= $this->getFieldList('t'); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } diff --git a/htdocs/knowledgemanagement/class/knowledgerecord.class.php b/htdocs/knowledgemanagement/class/knowledgerecord.class.php index bf2bf38bbef..1cdb3aff9f5 100644 --- a/htdocs/knowledgemanagement/class/knowledgerecord.class.php +++ b/htdocs/knowledgemanagement/class/knowledgerecord.class.php @@ -381,7 +381,7 @@ class KnowledgeRecord extends CommonObject $sql .= $this->getFieldList('t'); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 13d0f67316c..68523ace9da 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -451,7 +451,7 @@ class Mo extends CommonObject $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } @@ -1717,7 +1717,7 @@ class MoLine extends CommonObjectLine $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index d7242f4e16c..a9645efaae2 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -483,7 +483,7 @@ class Partnership extends CommonObject $sql .= $this->getFieldList('t'); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } diff --git a/htdocs/partnership/class/partnership_type.class.php b/htdocs/partnership/class/partnership_type.class.php index 0c42dae87d2..ba0f2c2a1ab 100644 --- a/htdocs/partnership/class/partnership_type.class.php +++ b/htdocs/partnership/class/partnership_type.class.php @@ -168,7 +168,7 @@ class PartnershipType extends CommonObject $sql .= $this->getFieldList('t'); $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= " WHERE t.entity IN (".getEntity($this->table_element).")"; + $sql .= " WHERE t.entity IN (".getEntity($this->element).")"; } else { $sql .= " WHERE 1 = 1"; } diff --git a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php index 60f13396b80..0711815da15 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php @@ -428,7 +428,7 @@ class StockTransfer extends CommonObject $sql = 'SELECT '; $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; else $sql .= ' WHERE 1 = 1'; // Manage filter $sqlwhere = array(); diff --git a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php index 4ee2f1db631..0460430c337 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php @@ -338,7 +338,7 @@ class StockTransferLine extends CommonObjectLine $sql = 'SELECT '; $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; else $sql .= ' WHERE 1 = 1'; // Manage filter $sqlwhere = array(); diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php index 1690f13da56..25d8b352a81 100644 --- a/htdocs/recruitment/class/recruitmentcandidature.class.php +++ b/htdocs/recruitment/class/recruitmentcandidature.class.php @@ -374,7 +374,7 @@ class RecruitmentCandidature extends CommonObject $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index 7a9d077f910..6b3fcf7eeb8 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -391,7 +391,7 @@ class RecruitmentJobPosition extends CommonObject $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } diff --git a/htdocs/ticket/class/cticketcategory.class.php b/htdocs/ticket/class/cticketcategory.class.php index dd8b75292ad..334ea7cd1ab 100644 --- a/htdocs/ticket/class/cticketcategory.class.php +++ b/htdocs/ticket/class/cticketcategory.class.php @@ -384,7 +384,7 @@ class CTicketCategory extends CommonObject $sql .= $this->getFieldList('t'); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } diff --git a/htdocs/webhook/class/target.class.php b/htdocs/webhook/class/target.class.php index 51a2a1beffa..701c74fbf4d 100644 --- a/htdocs/webhook/class/target.class.php +++ b/htdocs/webhook/class/target.class.php @@ -385,7 +385,7 @@ class Target extends CommonObject $sql .= $this->getFieldList('t'); $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= " WHERE t.entity IN (".getEntity($this->table_element).")"; + $sql .= " WHERE t.entity IN (".getEntity($this->element).")"; } else { $sql .= " WHERE 1 = 1"; } diff --git a/htdocs/workstation/class/workstation.class.php b/htdocs/workstation/class/workstation.class.php index d3b098784da..58f326e3749 100644 --- a/htdocs/workstation/class/workstation.class.php +++ b/htdocs/workstation/class/workstation.class.php @@ -419,7 +419,7 @@ class Workstation extends CommonObject $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } From 90137268a126be6e29adbe24d461ecb45f9d4be1 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 16 Jan 2023 22:15:02 +0100 Subject: [PATCH 23/43] FIX: missing tokan on Supplier proposal links --- htdocs/supplier_proposal/card.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 399d1271037..d09b6793dd0 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1968,30 +1968,30 @@ if ($action == 'create') { // Create an order if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) && $object->statut == SupplierProposal::STATUS_SIGNED) { if ($usercancreateorder) { - print ''; + print ''; } } // Set accepted/refused if ($object->statut == SupplierProposal::STATUS_VALIDATED && $usercanclose) { - print '
global->MAIN_JUMP_TAG) ? '' : '#acceptedrefused').'"'; + print ''; } // Close if ($object->statut == SupplierProposal::STATUS_SIGNED && $usercanclose) { - print '
global->MAIN_JUMP_TAG) ? '' : '#close').'"'; + print ''; } // Clone if ($usercancreate) { - print ''; + print ''; } // Delete if (($object->statut == SupplierProposal::STATUS_DRAFT && $usercancreate) || $usercandelete) { - print ''; } } From dbc9ca981628577dea9245ff7d6823c3e48b5142 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 16 Jan 2023 22:17:22 +0100 Subject: [PATCH 24/43] FIX: missing token on Supplier proposal links --- htdocs/supplier_proposal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index d09b6793dd0..d4bb56b3304 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1986,7 +1986,7 @@ if ($action == 'create') { // Clone if ($usercancreate) { - print ''; + print ''; } // Delete From 4ca7f0df3cea4d0c0ad826e80d196d00bb915c4f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Jan 2023 20:38:03 +0100 Subject: [PATCH 25/43] Add a method for test/dev purpose --- htdocs/core/login/functions_http.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/htdocs/core/login/functions_http.php b/htdocs/core/login/functions_http.php index a23047c8f1c..73f5824c3cd 100644 --- a/htdocs/core/login/functions_http.php +++ b/htdocs/core/login/functions_http.php @@ -63,3 +63,25 @@ function check_user_password_http($usertotest, $passwordtotest, $entitytotest) return $login; } + + +/** + * Decode the value found into the Authorization HTTP header. + * Ex: "Authorization: Basic bG9naW46cGFzcw==", $value is "Basic bG9naW46cGFzcw==" and after base64decode is "login:pass" + * Note: the $_SERVER["REMOTE_USER"] contains only the login used in the HTTP Basic form + * Method not used yet, but we keep it for some dev/test purposes. + * + * @param string $value Ex: $_SERVER["REMOTE_USER"] + * @return Object object.login & object.password + */ +function decodeHttpBasicAuth($value) +{ + $encoded_basic_auth = substr($value, 6); // Remove the "Basic " string + $decoded_basic_auth = base64_decode($encoded_basic_auth); + $credentials_basic_auth = explode(':', $decoded_basic_auth); + + return (object) [ + 'username'=> $credentials_basic_auth[0], + 'password' => $credentials_basic_auth[1] + ]; +} From 28c3d185837b0530b2a2584fd6117967614a7e87 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Jan 2023 11:47:16 +0100 Subject: [PATCH 26/43] FIX Component js to generate password --- htdocs/core/ajax/security.php | 9 +++++---- htdocs/core/lib/security2.lib.php | 7 ++++--- htdocs/user/card.php | 14 ++++++++------ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/htdocs/core/ajax/security.php b/htdocs/core/ajax/security.php index e5dc91c05d1..b01c952662e 100644 --- a/htdocs/core/ajax/security.php +++ b/htdocs/core/ajax/security.php @@ -36,9 +36,10 @@ if (!defined('NOREQUIREAJAX')) { if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } -if (!defined('NOREQUIRETRAN')) { +// We need langs because the getRandomPassword may use user language to define some rules of pass generation +/*if (!defined('NOREQUIRETRAN')) { define('NOREQUIRETRAN', '1'); -} +}*/ // Load Dolibarr environment require '../../main.inc.php'; @@ -55,9 +56,9 @@ top_httphead(); //print ''."\n"; -// Registering the location of boxes +// Return a new generated password if ($action) { - if ($action == 'getrandompassword' && ($user->admin || $user->rights->api->apikey->generate)) { + if ($action == 'getrandompassword') { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $generic = GETPOST('generic') ? true : false; echo getRandomPassword($generic); diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index b33ad1333ef..76ec442841c 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -561,10 +561,11 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len * * @param string $htmlname HTML name of element to insert key into * @param string $htmlnameofbutton HTML name of button + * @param int $generic 1=Return a generic pass, 0=Return a pass following setup rules * @return string HTML javascript code to set a password * @see getRandomPassword() */ -function dolJSToSetRandomPassword($htmlname, $htmlnameofbutton = 'generate_token') +function dolJSToSetRandomPassword($htmlname, $htmlnameofbutton = 'generate_token', $generic = 1) { global $conf; @@ -572,10 +573,10 @@ function dolJSToSetRandomPassword($htmlname, $htmlnameofbutton = 'generate_token print "\n".' - \n"; From e5d4ea1b7cc6184bafa1aa0ccda8ee829af0f14d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 17 Jan 2023 18:30:06 +0100 Subject: [PATCH 33/43] FIX error with dol_banner_tab, ref is needed --- htdocs/contrat/agenda.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index d654ac38d9f..3e51e9a1de5 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -54,7 +54,11 @@ $ref = GETPOST('ref', 'alpha'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'contrat', $id, ''); + +// Security check +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($id) ? 'rowid' : 'ref'); +$result = restrictedArea($user, 'contrat', $fieldvalue, '', '', '', $fieldtype); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -73,6 +77,13 @@ if (!$sortorder) { $sortorder = 'DESC,DESC'; } + +$object = new Contrat($db); + +if ($id > 0 || !empty($ref)) { + $result = $object->fetch($id, $ref); +} + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('agendacontract', 'globalcard')); @@ -81,7 +92,7 @@ $hookmanager->initHooks(array('agendacontract', 'globalcard')); * Actions */ -$parameters = array('id'=>$id); +$parameters = array('id' => $id, 'ref' => $ref); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -102,8 +113,6 @@ if (empty($reshook)) { } - - /* * View */ @@ -114,7 +123,7 @@ if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } -if ($id > 0) { +if ($object->id > 0) { // Load object modContract $module = (!empty($conf->global->CONTRACT_ADDON) ? $conf->global->CONTRACT_ADDON : 'mod_contract_serpis'); if (substr($module, 0, 13) == 'mod_contract_' && substr($module, -3) == 'php') { @@ -128,8 +137,6 @@ if ($id > 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $object = new Contrat($db); - $result = $object->fetch($id); $object->fetch_thirdparty(); $title = $langs->trans("Agenda"); @@ -205,13 +212,13 @@ if ($id > 0) { } $morehtmlref .= '
'; - dol_banner_tab($object, 'id', $linkback, 1, 'ref', 'none', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); print '
'; print '
'; - $object->info($id); + $object->info($object->id); dol_print_object_info($object, 1); print '
'; @@ -254,7 +261,7 @@ if ($id > 0) { if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { print '
'; - $param = '&id='.$id; + $param = '&id='.$object->id; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.$contextpage; } From 82cccc82f58a342b52b3ce2d33bf81fda3abf6be Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 17 Jan 2023 19:23:01 +0000 Subject: [PATCH 34/43] Fixing style errors. --- htdocs/bom/tpl/objectline_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index be12ec460ba..2c18ffbd87f 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -170,7 +170,7 @@ $total_cost = 0; $tmpbom->calculateCosts(); print ''; $coldisplay++; -if(!empty($line->fk_bom_child)) { +if (!empty($line->fk_bom_child)) { echo ''.price($tmpbom->total_cost).''; } else { echo ''.price($line->total_cost).''; From 708e284381f15d06da6fbf9591fc89f5ed73831a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 18 Jan 2023 00:13:21 +0100 Subject: [PATCH 35/43] Enhance backward compatibility --- htdocs/societe/class/societe.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 5876e8aff4a..2b233f3e0f6 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -794,6 +794,9 @@ class Societe extends CommonObject public $partnerships = array(); + const STATUS_CEASED = 0; + const STATUS_INACTIVITY = 1; + /** * @var Account|string Default BAN account From 29966d8499b59a9f01562979c7f472f1ab1cd44a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Wed, 18 Jan 2023 09:29:11 +0100 Subject: [PATCH 36/43] FIX: Add missing token when deleting template inn order_supplier admin menu --- htdocs/admin/supplier_order.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 7cf64e4800d..5b7a9845c10 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -381,7 +381,7 @@ foreach ($dirmodels as $reldir) { if (in_array($name, $def)) { print ''."\n"; if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF != "$name") { - print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'; + print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; } else { From d344e108c95d29e2d6d4101148ce9fae4f37baab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Wed, 18 Jan 2023 09:44:23 +0100 Subject: [PATCH 37/43] FIX: Errors Handling for CreateFrom Hooks --- htdocs/comm/action/class/actioncomm.class.php | 2 ++ htdocs/comm/propal/card.php | 1 + htdocs/comm/propal/class/propal.class.php | 2 ++ htdocs/commande/card.php | 1 + htdocs/commande/class/commande.class.php | 4 ++++ htdocs/compta/facture/class/facture.class.php | 4 ++++ htdocs/contrat/card.php | 1 + htdocs/contrat/class/contrat.class.php | 2 ++ htdocs/expensereport/class/expensereport.class.php | 2 ++ htdocs/fichinter/class/fichinter.class.php | 2 ++ htdocs/fourn/class/fournisseur.commande.class.php | 2 ++ htdocs/fourn/commande/card.php | 1 + htdocs/supplier_proposal/card.php | 1 + htdocs/supplier_proposal/class/supplier_proposal.class.php | 2 ++ 14 files changed, 27 insertions(+) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 769bd9ddd50..8032ead20ba 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -708,6 +708,8 @@ class ActionComm extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index da4c756705f..ea2ab40db42 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -567,6 +567,7 @@ if (empty($reshook)) { $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index f36b8027461..6567e11cdbf 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1412,6 +1412,8 @@ class Propal extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index d394df997ff..b74114164b0 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -445,6 +445,7 @@ if (empty($reshook)) { // Note that $action and $object may be modified by hook $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 33de271b45d..bd3be625561 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1252,6 +1252,8 @@ class Commande extends CommonOrder $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } @@ -1406,6 +1408,8 @@ class Commande extends CommonOrder $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 862a86e9e16..ba5eab04d16 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1299,6 +1299,8 @@ class Facture extends CommonInvoice $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } @@ -1432,6 +1434,8 @@ class Facture extends CommonInvoice $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 624d59b0d94..2acf59593ff 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -341,6 +341,7 @@ if (empty($reshook)) { $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 309df80605e..3d397fcb6c1 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2564,6 +2564,8 @@ class Contrat extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $clonedObj, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 3f62087dd0b..fa69245dc58 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -455,6 +455,8 @@ class ExpenseReport extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 000b654bf72..d8e213d31e8 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1211,6 +1211,8 @@ class Fichinter extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index e78dd9dd02a..c5f700dd6a7 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1654,6 +1654,8 @@ class CommandeFournisseur extends CommonOrder $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 86e34ce39a1..f7e339c6c9a 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1314,6 +1314,7 @@ if (empty($reshook)) { $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 4ad5fa9ff56..2f4dd6e0540 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -407,6 +407,7 @@ if (empty($reshook)) { $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 78fc1c7fd15..dc18f7dcb2b 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1160,6 +1160,8 @@ class SupplierProposal extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } From 4ee0ede6d8e8205e9431da95463de6ef886312f6 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 18 Jan 2023 08:53:28 +0000 Subject: [PATCH 38/43] Fixing style errors. --- htdocs/comm/action/class/actioncomm.class.php | 4 ++-- htdocs/comm/propal/card.php | 2 +- htdocs/comm/propal/class/propal.class.php | 4 ++-- htdocs/commande/card.php | 2 +- htdocs/commande/class/commande.class.php | 8 ++++---- htdocs/compta/facture/class/facture.class.php | 8 ++++---- htdocs/contrat/card.php | 2 +- htdocs/contrat/class/contrat.class.php | 4 ++-- htdocs/expensereport/class/expensereport.class.php | 4 ++-- htdocs/fichinter/class/fichinter.class.php | 4 ++-- htdocs/fourn/class/fournisseur.commande.class.php | 4 ++-- htdocs/fourn/commande/card.php | 2 +- htdocs/supplier_proposal/card.php | 2 +- .../supplier_proposal/class/supplier_proposal.class.php | 4 ++-- 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 8032ead20ba..f5e1fe40b1f 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -708,8 +708,8 @@ class ActionComm extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index ea2ab40db42..e575195799c 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -567,7 +567,7 @@ if (empty($reshook)) { $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 6567e11cdbf..edd443c1b58 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1412,8 +1412,8 @@ class Propal extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index b74114164b0..e099aafc9ca 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -445,7 +445,7 @@ if (empty($reshook)) { // Note that $action and $object may be modified by hook $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index bd3be625561..c636b4e905d 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1252,8 +1252,8 @@ class Commande extends CommonOrder $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } @@ -1408,8 +1408,8 @@ class Commande extends CommonOrder $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ba5eab04d16..2af2b35240d 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1299,8 +1299,8 @@ class Facture extends CommonInvoice $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } @@ -1434,8 +1434,8 @@ class Facture extends CommonInvoice $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 2acf59593ff..a63e8d7c6ca 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -341,7 +341,7 @@ if (empty($reshook)) { $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 3d397fcb6c1..f16b26646bc 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2564,8 +2564,8 @@ class Contrat extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $clonedObj, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index fa69245dc58..a0fe9fa8335 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -455,8 +455,8 @@ class ExpenseReport extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index d8e213d31e8..0205fec9e39 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1211,8 +1211,8 @@ class Fichinter extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index c5f700dd6a7..112708a92b7 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1654,8 +1654,8 @@ class CommandeFournisseur extends CommonOrder $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index f7e339c6c9a..a8ee29fc974 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1314,7 +1314,7 @@ if (empty($reshook)) { $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 2f4dd6e0540..01f9ad5e2dd 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -407,7 +407,7 @@ if (empty($reshook)) { $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index dc18f7dcb2b..088594f6ab4 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1160,8 +1160,8 @@ class SupplierProposal extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } From cb963780312edca5445f075d516eecd6955856a7 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Wed, 18 Jan 2023 10:48:18 +0100 Subject: [PATCH 39/43] FIX: API access for deactivated users --- htdocs/api/class/api_access.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 5a4097b089b..09bb46ed98e 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2023 Ferran Marcet * * 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 @@ -147,6 +148,9 @@ class DolibarrApiAccess implements iAuthenticate if ($result <= 0) { throw new RestException(503, 'Error when fetching user :'.$fuser->error.' (conf->entity='.$conf->entity.')'); } + if ($fuser->statut == 0) { + throw new RestException(503, 'Error when fetching user. This user has been locked or disabled'); + } $fuser->getrights(); From 6d8f80d46e778dc65b5edbad47d0e3ae69a95b18 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 18 Jan 2023 16:10:21 +0100 Subject: [PATCH 40/43] fix: module builder, backport workgin solution form 15.0 --- htdocs/modulebuilder/index.php | 50 ++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 25034194119..fcfea65dd83 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1295,33 +1295,35 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) && $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors'); } - } - if (!$error) { - $addfieldentry = array( - 'name'=>GETPOST('propname', 'aZ09'), - 'label'=>GETPOST('proplabel', 'alpha'), - 'type'=>GETPOST('proptype', 'alpha'), - 'arrayofkeyval'=>GETPOST('proparrayofkeyval', 'restricthtml'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}' - 'visible'=>GETPOST('propvisible', 'int'), - 'enabled'=>GETPOST('propenabled', 'int'), - 'position'=>GETPOST('propposition', 'int'), - 'notnull'=>GETPOST('propnotnull', 'int'), - 'index'=>GETPOST('propindex', 'int'), - 'searchall'=>GETPOST('propsearchall', 'int'), - 'isameasure'=>GETPOST('propisameasure', 'int'), - 'comment'=>GETPOST('propcomment', 'alpha'), - 'help'=>GETPOST('prophelp', 'alpha'), - 'css'=>GETPOST('propcss', 'aZ09'), - 'cssview'=>GETPOST('propcssview', 'aZ09'), - 'csslist'=>GETPOST('propcsslist', 'aZ09'), - 'default'=>GETPOST('propdefault', 'restricthtml'), - 'noteditable'=>intval(GETPOST('propnoteditable', 'int')), - ); + if (!$error && !GETPOST('regenerateclasssql')&& !GETPOST('regeneratemissing')) { + $addfieldentry = array( + 'name'=>GETPOST('propname', 'aZ09'), + 'label'=>GETPOST('proplabel', 'alpha'), + 'type'=>GETPOST('proptype', 'alpha'), + 'arrayofkeyval'=>GETPOST('proparrayofkeyval', 'restricthtml'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}' + 'visible'=>GETPOST('propvisible', 'int'), + 'enabled'=>GETPOST('propenabled', 'int'), + 'position'=>GETPOST('propposition', 'int'), + 'notnull'=>GETPOST('propnotnull', 'int'), + 'index'=>GETPOST('propindex', 'int'), + 'searchall'=>GETPOST('propsearchall', 'int'), + 'isameasure'=>GETPOST('propisameasure', 'int'), + 'comment'=>GETPOST('propcomment', 'alpha'), + 'help'=>GETPOST('prophelp', 'alpha'), + 'css'=>GETPOST('propcss', 'aZ09'), + 'cssview'=>GETPOST('propcssview', 'aZ09'), + 'csslist'=>GETPOST('propcsslist', 'aZ09'), + 'default'=>GETPOST('propdefault', 'restricthtml'), + 'noteditable'=>intval(GETPOST('propnoteditable', 'int')), + ); - if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) { - $addfieldentry['arrayofkeyval'] = json_decode($addfieldentry['arrayofkeyval'], true); + if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) { + $addfieldentry['arrayofkeyval'] = json_decode($addfieldentry['arrayofkeyval'], true); + } } + } else { + $addfieldentry = array(); } /*if (GETPOST('regeneratemissing')) From a00fa5a192dd339c8ca49e7f489ce4ecb31a5feb Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Wed, 18 Jan 2023 16:11:22 +0100 Subject: [PATCH 41/43] FIX: Do not convert negative line to discount if variable is active --- htdocs/commande/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index eb8b824ef3e..2211422f3c5 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -9,7 +9,7 @@ * Copyright (C) 2015-2018 Frédéric France * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2016-2021 Ferran Marcet + * Copyright (C) 2016-2023 Ferran Marcet * Copyright (C) 2018 Charlene Benke * Copyright (C) 2021 Anthony Berton * @@ -403,7 +403,7 @@ if (empty($reshook)) { $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day')); } - if ($lines[$i]->subprice < 0) { + if ($lines[$i]->subprice < 0 && empty($conf->global->INVOICE_KEEP_DISCOUNT_LINES_AS_IN_ORIGIN)) { // Negative line, we create a discount line $discount = new DiscountAbsolute($db); $discount->fk_soc = $objecttmp->socid; From a3d4eb404df858202eeacf5f872d6fc3d7b1cd3d Mon Sep 17 00:00:00 2001 From: GregM Date: Wed, 18 Jan 2023 17:36:05 +0100 Subject: [PATCH 42/43] Fix contact firstname lastname extrafields --- htdocs/core/class/extrafields.class.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 1d5bd8dc7ef..6644548d87c 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1457,15 +1457,15 @@ class ExtraFields $labeltoshow = dol_trunc($labeltoshow, 45); if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { + $labeltoshow = ''; foreach ($fields_label as $field_toshow) { $translabel = $langs->trans($obj->$field_toshow); if ($translabel != $obj->$field_toshow) { - $labeltoshow = dol_trunc($translabel, 18).' '; + $labeltoshow .= ' '.dol_trunc($translabel, 18).' '; } else { - $labeltoshow = dol_trunc($obj->$field_toshow, 18).' '; + $labeltoshow .= ' '.dol_trunc($obj->$field_toshow, 18).' '; } } - $data[$obj->rowid] = $labeltoshow; } else { if (!$notrans) { @@ -1774,17 +1774,20 @@ class ExtraFields $fields_label = explode('|', $InfoFieldList[1]); if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { if (is_array($fields_label) && count($fields_label) > 1) { + $label = '
  • '; foreach ($fields_label as $field_toshow) { $translabel = ''; if (!empty($obj->$field_toshow)) { $translabel = $langs->trans($obj->$field_toshow); } if ($translabel != $field_toshow) { - $toprint[] = '
  • '.dol_trunc($translabel, 18).'
  • '; + $label .= ' '.dol_trunc($translabel, 18); } else { - $toprint[] = '
  • '.$obj->$field_toshow.'
  • '; + $label .= ' '.$obj->$field_toshow; } } + $label .= ''; + $toprint[] = $label; } else { $translabel = ''; if (!empty($obj->{$InfoFieldList[1]})) { From aa273d215572d896ba26f1dae8489edd1238e4c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 18 Jan 2023 20:11:12 +0100 Subject: [PATCH 43/43] Update index.php --- htdocs/modulebuilder/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index fcfea65dd83..052b1189b3d 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1296,7 +1296,7 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) && setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors'); } - if (!$error && !GETPOST('regenerateclasssql')&& !GETPOST('regeneratemissing')) { + if (!$error && !GETPOST('regenerateclasssql') && !GETPOST('regeneratemissing')) { $addfieldentry = array( 'name'=>GETPOST('propname', 'aZ09'), 'label'=>GETPOST('proplabel', 'alpha'),