From 7dfa9b7d33d2f9fb7f84051ca2711d53e162bf3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 28 Oct 2024 19:49:01 +0100 Subject: [PATCH 1/4] remove unused code (#31610) * remove unused code * remove unused code * fix typo * fix * fix * fix --- htdocs/asset/class/asset.class.php | 37 +--------- htdocs/asset/class/assetmodel.class.php | 74 ++----------------- .../facture/class/api_invoices.class.php | 10 +-- htdocs/core/class/conf.class.php | 23 ++++-- htdocs/core/class/link.class.php | 23 +++++- htdocs/core/lib/ecm.lib.php | 2 +- htdocs/webportal/class/context.class.php | 3 + 7 files changed, 52 insertions(+), 120 deletions(-) diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 1026fd092bb..88088e6f26a 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -256,7 +256,7 @@ class Asset extends CommonObject */ public function __construct(DoliDB $db) { - global $conf, $langs; + global $langs; $this->db = $db; @@ -343,13 +343,7 @@ class Asset extends CommonObject // // // Load source object // $result = $object->fetchCommon($fromid); - // if ($result > 0 && !empty($object->table_element_line)) { - // $object->fetchLines(); - // } // - // // get lines so they will be clone - // //foreach($this->lines as $line) - // // $line->fetch_optionals(); // // // Reset some properties // unset($object->id); @@ -420,6 +414,7 @@ class Asset extends CommonObject // $this->db->rollback(); // return -1; // } + return -1; } @@ -434,10 +429,6 @@ class Asset extends CommonObject { $result = $this->fetchCommon($id, $ref); if ($result > 0) { - if (!empty($this->table_element_line)) { - $this->fetchLines(); - } - $res = $this->hasDepreciationLinesInBookkeeping(); if ($res < 0) { return -1; @@ -454,18 +445,6 @@ class Asset extends CommonObject return $result; } - /** - * Load object lines in memory from the database - * - * @return int Return integer <0 if KO, 0 if not found, >0 if OK - */ - public function fetchLines() - { - $this->lines = array(); - - return 1; - } - /** * Load list of objects in memory from the database. @@ -1591,18 +1570,6 @@ class Asset extends CommonObject return $this->initAsSpecimenCommon(); } - /** - * Create an array of lines - * - * @return array|int array of lines if OK, <0 if KO - */ - public function getLinesArray() - { - $this->lines = array(); - - return $this->lines; - } - /** * Returns the reference to the following non used object depending on the active numbering module. * diff --git a/htdocs/asset/class/assetmodel.class.php b/htdocs/asset/class/assetmodel.class.php index ac9dc8c778c..c39d6eb47f5 100644 --- a/htdocs/asset/class/assetmodel.class.php +++ b/htdocs/asset/class/assetmodel.class.php @@ -1,8 +1,8 @@ - * Copyright (C) 2021 Open-Dsi - * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW +/* Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2021 Open-Dsi + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -263,13 +263,6 @@ class AssetModel extends CommonObject // Load source object $result = $object->fetchCommon($fromid); - if ($result > 0 && !empty($object->table_element_line)) { - $object->fetchLines(); - } - - // get lines so they will be clone - //foreach($this->lines as $line) - // $line->fetch_optionals(); // Reset some properties unset($object->id); @@ -354,25 +347,10 @@ class AssetModel extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && !empty($this->table_element_line)) { - $this->fetchLines(); - } + return $result; } - /** - * Load object lines in memory from the database - * - * @return int Return integer <0 if KO, 0 if not found, >0 if OK - */ - public function fetchLines() - { - $this->lines = array(); - - return 1; - } - - /** * Load list of objects in memory from the database. * @@ -810,46 +788,4 @@ class AssetModel extends CommonObject return $this->initAsSpecimenCommon(); } - - /** - * Create an array of lines - * - * @return array|int array of lines if OK, <0 if KO - */ - public function getLinesArray() - { - $this->lines = array(); - - return $this->lines; - } - - /** - * Action executed by scheduler - * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters' - * Use public function doScheduledJob($param1, $param2, ...) to get parameters - * - * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) - */ - public function doScheduledJob() - { - //global $conf, $langs; - - //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; - - $error = 0; - $this->output = ''; - $this->error = ''; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $now = dol_now(); - - $this->db->begin(); - - // ... - - $this->db->commit(); - - return $error; - } } diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index db5378949d1..ef5939be02f 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1,9 +1,9 @@ - * Copyright (C) 2020 Thibault FOUCART - * Copyright (C) 2023 Joachim Kueter +/* Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2020 Thibault FOUCART + * Copyright (C) 2023 Joachim Kueter * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW * * 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 @@ -47,7 +47,7 @@ class Invoices extends DolibarrApi private $invoice; /** - * @var FactureRec $templte_invoice {@type FactureRec} + * @var FactureRec $template_invoice {@type FactureRec} */ private $template_invoice; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 9e926c1c054..0d3e7184e6b 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -1,9 +1,10 @@ - * Copyright (C) 2003 Xavier Dutoit - * Copyright (C) 2004-2020 Laurent Destailleur - * Copyright (C) 2005-2017 Regis Houssin - * Copyright (C) 2006 Jean Heimburger +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2003 Xavier Dutoit + * Copyright (C) 2004-2020 Laurent Destailleur + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2006 Jean Heimburger + * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -141,10 +142,20 @@ class Conf extends stdClass public $format_date_hour_text_short; public $format_date_hour_text; + /** + * @var int limit for list + */ public $liste_limit; + + /** + * @var int checkboxes are on left column if 1 + */ public $main_checkbox_left_column; - public $tzuserinputkey = 'tzserver'; // Use 'tzuserrel' to always store date in GMT and show date in time zone of user. + /** + * @var string Use 'tzuserrel' to always store date in GMT and show date in time zone of user. + */ + public $tzuserinputkey = 'tzserver'; // TODO Remove this part. diff --git a/htdocs/core/class/link.class.php b/htdocs/core/class/link.class.php index 8ea08e7d52a..53e7614701d 100644 --- a/htdocs/core/class/link.class.php +++ b/htdocs/core/class/link.class.php @@ -1,6 +1,7 @@ - * Copyright (C) 2024 MDW +/* Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,7 +45,14 @@ class Link extends CommonObject */ public $entity; + /** + * @var int|'' date add + */ public $datea; + + /** + * @var string Object url + */ public $url; /** @@ -52,7 +60,14 @@ class Link extends CommonObject */ public $label; + /** + * @var string Object type + */ public $objecttype; + + /** + * @var int Object ID + */ public $objectid; @@ -167,11 +182,11 @@ class Link extends CommonObject } // Clean parameters - $this->url = clean_url($this->url, 1); + $this->url = clean_url($this->url, 1); if (empty($this->label)) { $this->label = basename($this->url); } - $this->label = trim($this->label); + $this->label = trim($this->label); $this->db->begin(); diff --git a/htdocs/core/lib/ecm.lib.php b/htdocs/core/lib/ecm.lib.php index 8c421b7c26f..20f8b91125f 100644 --- a/htdocs/core/lib/ecm.lib.php +++ b/htdocs/core/lib/ecm.lib.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2008-2014 Laurent Destailleur * Copyright (C) 2022-2024 Frédéric France * Copyright (C) 2024 MDW * diff --git a/htdocs/webportal/class/context.class.php b/htdocs/webportal/class/context.class.php index 82503fb5530..0bd07a2ffed 100644 --- a/htdocs/webportal/class/context.class.php +++ b/htdocs/webportal/class/context.class.php @@ -125,6 +125,9 @@ class Context */ public $rootUrl; + /** + * @var string[] + */ public $menu_active = array(); /** From a0b6e9522e813b3cf32718b488e91c6d1e48ce13 Mon Sep 17 00:00:00 2001 From: Pichi1966 <57623859+josett225@users.noreply.github.com> Date: Mon, 28 Oct 2024 19:57:21 +0100 Subject: [PATCH 2/4] FIX Update asset.class.php PHP Error and $depreciation_date_end (#31611) This fix corrects 2 issues: - PHP Error required (float) - $depreciation_date_end was incorrect with an extra day. This was impacting last calculation period. e.g; 5 years period starting the 30/09/2019 means $depreciation_date_end = 29/09/2024. It was returning 30/09/2024 --- htdocs/asset/class/asset.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 88088e6f26a..fc5c9324121 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2018-2024 Alexandre Spangaro * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 MDW + * Copyright (C) 2024 Jose MARTINEZ * * 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 @@ -1007,7 +1008,7 @@ class Asset extends CommonObject // Get depreciation period $depreciation_date_start = $this->date_start > $this->date_acquisition ? $this->date_start : $this->date_acquisition; - $depreciation_date_end = dol_time_plus_duree((int) $depreciation_date_start, $fields['duration'], $fields['duration_type'] == 1 ? 'm' : ($fields['duration_type'] == 2 ? 'd' : 'y')); + $depreciation_date_end = dol_time_plus_duree(dol_time_plus_duree((int) $depreciation_date_start, $fields['duration'], $fields['duration_type'] == 1 ? 'm' : ($fields['duration_type'] == 2 ? 'd' : 'y')), -1, 'd'); $depreciation_amount = $fields['amount_base_depreciation_ht']; if ($fields['duration_type'] == 2) { // Daily $fiscal_period_start = $depreciation_date_start; @@ -1020,7 +1021,7 @@ class Asset extends CommonObject $fiscal_period_start = $init_fiscal_period_start; $fiscal_period_end = $init_fiscal_period_end; } - $cumulative_depreciation_ht = $last_cumulative_depreciation_ht; + $cumulative_depreciation_ht = (float) $last_cumulative_depreciation_ht; $depreciation_period_amount = $depreciation_amount - (float) $this->reversal_amount_ht; $start_date = $depreciation_date_start; $disposal_date = isset($this->disposal_date) && $this->disposal_date !== "" ? $this->disposal_date : ""; From 94de6f5ea7099baf2894b91a0d62003818107775 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+BB2A-Anthony@users.noreply.github.com> Date: Mon, 28 Oct 2024 21:15:01 +0100 Subject: [PATCH 3/4] NEW - replenishment if the warehouse is set to the default selected user (#31229) * NEW - replenishment if the warehouse is set to the default selected user * FIX --------- Co-authored-by: Anthony Berton --- htdocs/product/stock/replenish.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index f8ad4f06ce3..ebad79a6d09 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -86,6 +86,10 @@ while ($tmpobj = $db->fetch_object($resWar)) { if ($count == 1 && (empty($fk_entrepot) || $fk_entrepot <= 0) && getDolGlobalString('MULTICOMPANY_PRODUCT_SHARING_ENABLED')) { $fk_entrepot = $lastWarehouseID; } +//If the warehouse is set to the default selected user +if (!GETPOSTISSET('fk_warehouse') && (empty($fk_entrepot) || $fk_entrepot <= 0) && getDolGlobalString('MAIN_DEFAULT_WAREHOUSE_USER')) { + $fk_entrepot = $user->fk_warehouse; +} $texte = ''; From abf5323484ab2a1c9188333ebd1ded0d108a4228 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Oct 2024 21:23:54 +0100 Subject: [PATCH 4/4] FIX showing the receipt for print will generate a unalterable log --- htdocs/blockedlog/ajax/block-add.php | 2 +- htdocs/main.inc.php | 2 +- htdocs/takepos/receipt.php | 39 ++++++++++++++++++++++++---- htdocs/theme/eldy/style.css.php | 2 +- 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/htdocs/blockedlog/ajax/block-add.php b/htdocs/blockedlog/ajax/block-add.php index 1318447ee35..6538c1fe2ee 100644 --- a/htdocs/blockedlog/ajax/block-add.php +++ b/htdocs/blockedlog/ajax/block-add.php @@ -60,7 +60,7 @@ if (empty($action)) { exit; } -if ($element === 'facture') { +if ($element === 'facture') { // Test on permission done in top of page require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 0befd9431f7..c301d46211f 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -3929,7 +3929,7 @@ if (!function_exists("llxFooter")) { print ''."\n"; } - // Wrapper to add log when clicking on download or preview + // JS wrapper to add log when clicking on download or preview if (isModEnabled('blockedlog') && is_object($object) && !empty($object->id) && $object->id > 0) { if (in_array($object->element, array('facture')) && $object->statut > 0) { // Restrict for the moment to element 'facture' print "\n\n"; diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index e667a8b2215..cbce49031ab 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -68,7 +68,7 @@ if (!$user->hasRight('takepos', 'run')) { * View */ -top_httphead('text/html', 1); +top_htmlhead('', '', 1); if ($place > 0) { $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'"; @@ -81,6 +81,25 @@ if ($place > 0) { $object = new Facture($db); $object->fetch($facid); + +// Record entry in blocked logs +// DOL_DOCUMENT_ROOT.'/blockedlog/ajax/block-add.php?id='.$object->id.'&element='.$object->element.'&action=DOC_PREVIEW&token='.newToken(); +print " +"; + + // Call to external receipt modules if exist $parameters = array(); $hookmanager->initHooks(array('takeposfrontend')); @@ -103,6 +122,16 @@ if (!empty($hookmanager->resPrint)) { .left { text-align: left; } +.centpercent { + width: 100%; +} +@media only screen and (min-width: 1024px) +{ + body { + margin-left: 50px; + margin-right: 50px; + } +}
@@ -132,7 +161,7 @@ print $langs->trans('Date')." ".dol_print_date($object->date, 'day').'
'; if (getDolGlobalString('TAKEPOS_RECEIPT_NAME')) { print getDolGlobalString('TAKEPOS_RECEIPT_NAME') . " "; } -if ($object->statut == Facture::STATUS_DRAFT) { +if ($object->status == Facture::STATUS_DRAFT) { print str_replace(")", "", str_replace("-", " ".$langs->trans('Place')." ", str_replace("(PROV-POS", $langs->trans("Terminal")." ", $object->ref))); } else { print $object->ref; @@ -155,7 +184,7 @@ if (getDolGlobalString('TAKEPOS_SHOW_DATE_OF_PRINING')) {


- +
@@ -194,7 +223,7 @@ if (getDolGlobalString('TAKEPOS_SHOW_DATE_OF_PRINING')) { product_label)) { echo $line->product_label; } else { - echo $line->description; + echo $line->desc; } ?> @@ -219,7 +248,7 @@ if (getDolGlobalString('TAKEPOS_SHOW_DATE_OF_PRINING')) {
trans("Label"); ?> qty; ?>

- +
trans("TotalHT"); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 2f2b735e97b..8164157664b 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -372,7 +372,7 @@ print 'fontsizesmaller='.$fontsizesmaller."\n"; print 'topMenuFontSize='.$topMenuFontSize."\n"; print 'toolTipBgColor='.$toolTipBgColor."\n"; print 'toolTipFontColor='.$toolTipFontColor."\n"; -print 'conf->global->THEME_SATURATE_RATIO='.(!getDolGlobalString('THEME_SATURATE_RATIO') ? '' : $conf->global->THEME_SATURATE_RATIO)." (must be between 0 and 1)\n"; +print 'conf->global->THEME_SATURATE_RATIO='.getDolGlobalString('THEME_SATURATE_RATIO')." (must be between 0 and 1)\n"; print '*/'."\n";