From 382f9ce95dd6d3def274c467bd3fa3b46cfda0c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Fri, 8 Dec 2023 00:24:44 +0100 Subject: [PATCH 001/714] Fix #27029 --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 2f4d4fe2f83..deb14e0b06d 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -1051,7 +1051,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= " WHERE dbt.rowid IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbt.".$dbt_keyfield." = ".((int) $user->socid); - } elseif (isModEnabled("societe") && empty($user->rights->societe->client->voir)) { + } elseif (isModEnabled("societe") && empty($user->rights->societe->client->voir)&& ($feature != 'knowledgemanagement')) { // If internal user without permission to see all thirdparties: Check permission for internal users that are restricted on their objects if ($feature != 'ticket') { if (empty($dbt_keyfield)) { From 28769a13ebeec17db4745a949a9d6747a0c247f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Wed, 27 Dec 2023 00:08:18 +0100 Subject: [PATCH 002/714] Update security.lib.php Better fix as proposed by eldy --- htdocs/core/lib/security.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index deb14e0b06d..893cb3d8355 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -892,7 +892,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl $checkonentitydone = 0; // Array to define rules of checks to do - $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website', 'recruitment', 'chargesociales'); // Test on entity only (Objects with no link to company) + $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website', 'recruitment', 'chargesociales', 'knowledgemanagement'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for object Societe $checkparentsoc = array('agenda', 'contact', 'contrat'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet', 'project'); // Test for project object @@ -1051,7 +1051,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= " WHERE dbt.rowid IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbt.".$dbt_keyfield." = ".((int) $user->socid); - } elseif (isModEnabled("societe") && empty($user->rights->societe->client->voir)&& ($feature != 'knowledgemanagement')) { + } elseif (isModEnabled("societe") && empty($user->rights->societe->client->voir)) { // If internal user without permission to see all thirdparties: Check permission for internal users that are restricted on their objects if ($feature != 'ticket') { if (empty($dbt_keyfield)) { From ab206910ab509c76bd592501463688a2a9154d7f Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 15 Jan 2024 09:40:59 +0100 Subject: [PATCH 003/714] change to receptiondet_batch into scripts --- ...php => receptiondet_batch_extrafields.php} | 4 ++-- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/lib/reception.lib.php | 6 ++--- htdocs/core/modules/modReception.class.php | 6 ++--- htdocs/expedition/dispatch.php | 2 +- .../class/fournisseur.commande.class.php | 8 +++---- .../fournisseur.commande.dispatch.class.php | 2 +- htdocs/fourn/commande/dispatch.php | 4 ++-- htdocs/product/class/product.class.php | 2 +- .../product/stock/class/productlot.class.php | 4 ++-- .../product/stock/lib/replenishment.lib.php | 2 +- htdocs/product/stock/replenish.php | 2 +- .../stock/stats/commande_fournisseur.php | 2 +- htdocs/product/stock/stats/reception.php | 2 +- htdocs/reception/card.php | 4 ++-- htdocs/reception/class/reception.class.php | 24 +++++++++---------- htdocs/reception/dispatch.php | 4 ++-- 17 files changed, 40 insertions(+), 40 deletions(-) rename htdocs/admin/{commande_fournisseur_dispatch_extrafields.php => receptiondet_batch_extrafields.php} (94%) diff --git a/htdocs/admin/commande_fournisseur_dispatch_extrafields.php b/htdocs/admin/receptiondet_batch_extrafields.php similarity index 94% rename from htdocs/admin/commande_fournisseur_dispatch_extrafields.php rename to htdocs/admin/receptiondet_batch_extrafields.php index 277d61e1b2f..ea98618dda0 100644 --- a/htdocs/admin/commande_fournisseur_dispatch_extrafields.php +++ b/htdocs/admin/receptiondet_batch_extrafields.php @@ -25,7 +25,7 @@ */ /** - * \file htdocs/admin/commande_fournisseur_dispatch_extrafields.php + * \file htdocs/admin/receptiondet_batch.php * \ingroup reception * \brief Page to setup extra fields of reception */ @@ -56,7 +56,7 @@ foreach ($tmptype2label as $key => $val) { $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); -$elementtype = 'commande_fournisseur_dispatch'; //Must be the $table_element of the class that manage extrafield +$elementtype = 'receptiondet_batch'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) { accessforbidden(); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 75fd4a5e47a..4dc6a6dad58 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4535,7 +4535,7 @@ abstract class CommonObject if ($elementTable == 'expensereport') { $fieldstatus = "fk_statut"; } - if ($elementTable == 'commande_fournisseur_dispatch') { + if ($elementTable == 'receptiondet_batch') { $fieldstatus = "status"; } if ($elementTable == 'prelevement_bons') { diff --git a/htdocs/core/lib/reception.lib.php b/htdocs/core/lib/reception.lib.php index 2dce74e6a11..b5f5a0c7067 100644 --- a/htdocs/core/lib/reception.lib.php +++ b/htdocs/core/lib/reception.lib.php @@ -122,7 +122,7 @@ function reception_admin_prepare_head() $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label('reception'); - $extrafields->fetch_name_optionals_label('commande_fournisseur_dispatch'); + $extrafields->fetch_name_optionals_label('receptiondet_batch'); $h = 0; $head = array(); @@ -146,9 +146,9 @@ function reception_admin_prepare_head() } if (getDolGlobalString('MAIN_SUBMODULE_RECEPTION')) { - $head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php'; + $head[$h][0] = DOL_URL_ROOT.'/admin/receptiondet_batch_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsLines"); - $nbExtrafields = $extrafields->attributes['commande_fournisseur_dispatch']['count']; + $nbExtrafields = $extrafields->attributes['receptiondet_batch']['count']; if ($nbExtrafields > 0) { $head[$h][1] .= ''.$nbExtrafields.''; } diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php index f5f8429f5db..f0327612b7d 100644 --- a/htdocs/core/modules/modReception.class.php +++ b/htdocs/core/modules/modReception.class.php @@ -218,7 +218,7 @@ class modReception extends DolibarrModules $keyforelement = 'reception'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect = 'commande_fournisseur_dispatch'; + $keyforselect = 'receptiondet_batch'; $keyforelement = 'reception_line'; $keyforaliasextra = 'extra2'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; @@ -232,8 +232,8 @@ class modReception extends DolibarrModules } $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; - $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch as ed'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch_extrafields as extra2 ON ed.rowid = extra2.fk_object'; + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'receptiondet_batch as ed'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'receptiondet_batch_extrafields as extra2 ON ed.rowid = extra2.fk_object'; $this->export_sql_end[$r] .= ' , '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid'; if ($idcontacts && getDolGlobalString('RECEPTION_ADD_CONTACTS_IN_EXPORT')) { diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php index 8ba6e6d7768..1daba85e87f 100644 --- a/htdocs/expedition/dispatch.php +++ b/htdocs/expedition/dispatch.php @@ -774,7 +774,7 @@ if ($object->id > 0 || !empty($object->ref)) { print ''; // Warehouse column /*$sql = "SELECT cfd.rowid, cfd.qty, cfd.fk_entrepot, cfd.batch, cfd.eatby, cfd.sellby, cfd.fk_product"; - $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd"; + $sql .= " FROM ".MAIN_DB_PREFIX."receptiondet_batch as cfd"; $sql .= " WHERE cfd.fk_commandefourndet = ".(int) $objp->rowid;*/ $sql = "SELECT ed.rowid, ed.qty, ed.fk_entrepot,"; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 81570e7e320..102399eb4d9 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2103,7 +2103,7 @@ class CommandeFournisseur extends CommonOrder /** - * Save a receiving into the tracking table of receiving (commande_fournisseur_dispatch) and add product into stock warehouse. + * Save a receiving into the tracking table of receiving (receptiondet_batch) and add product into stock warehouse. * * @param User $user User object making change * @param int $product Id of product to dispatch @@ -2148,7 +2148,7 @@ class CommandeFournisseur extends CommonOrder if (($this->statut == self::STATUS_ORDERSENT || $this->statut == self::STATUS_RECEIVED_PARTIALLY || $this->statut == self::STATUS_RECEIVED_COMPLETELY)) { $this->db->begin(); - $sql = "INSERT INTO ".$this->db->prefix()."commande_fournisseur_dispatch"; + $sql = "INSERT INTO ".$this->db->prefix()."receptiondet_batch"; $sql .= " (fk_commande, fk_product, qty, fk_entrepot, fk_user, datec, fk_commandefourndet, status, comment, eatby, sellby, batch, fk_reception) VALUES"; $sql .= " ('".$this->id."','".$product."','".$qty."',".($entrepot > 0 ? "'".$entrepot."'" : "null").",'".$user->id."','".$this->db->idate($now)."','".$fk_commandefourndet."', ".$dispatchstatus.", '".$this->db->escape($comment)."', "; $sql .= ($eatby ? "'".$this->db->idate($eatby)."'" : "null").", ".($sellby ? "'".$this->db->idate($sellby)."'" : "null").", ".($batch ? "'".$this->db->escape($batch)."'" : "null").", ".($fk_reception > 0 ? "'".$this->db->escape($fk_reception)."'" : "null"); @@ -2395,7 +2395,7 @@ class CommandeFournisseur extends CommonOrder $sql .= " e.rowid as warehouse_id, e.ref as entrepot,"; $sql .= " cfd.rowid as dispatchedlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status, cfd.fk_commandefourndet"; $sql .= " FROM ".$this->db->prefix()."product as p,"; - $sql .= " ".$this->db->prefix()."commande_fournisseur_dispatch as cfd"; + $sql .= " ".$this->db->prefix()."receptiondet_batch as cfd"; $sql .= " LEFT JOIN ".$this->db->prefix()."entrepot as e ON cfd.fk_entrepot = e.rowid"; $sql .= " WHERE cfd.fk_commande = ".((int) $this->id); $sql .= " AND cfd.fk_product = p.rowid"; @@ -3556,7 +3556,7 @@ class CommandeFournisseur extends CommonOrder $sql = 'SELECT cd.rowid, cd.fk_product,'; $sql .= ' sum(cfd.qty) as qty'; - $sql .= ' FROM '.$this->db->prefix().'commande_fournisseur_dispatch as cfd,'; + $sql .= ' FROM '.$this->db->prefix().'receptiondet_batch as cfd,'; if ($filtre_statut >= 0) { $sql .= ' '.$this->db->prefix().'reception as e,'; } diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index 044a14119c9..7374ccb9111 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -56,7 +56,7 @@ class CommandeFournisseurDispatch extends CommonObjectLine /** * @var string Name of table without prefix where object is stored */ - public $table_element = 'commande_fournisseur_dispatch'; //!< Name of table without prefix where object is stored + public $table_element = 'receptiondet_batch'; //!< Name of table without prefix where object is stored public $lines = array(); /** diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 6241d2bd202..5c0a245310e 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -655,7 +655,7 @@ if ($id > 0 || !empty($ref)) { // Set $products_dispatched with qty dispatched for each product id $products_dispatched = array(); $sql = "SELECT l.rowid, cfd.fk_product, sum(cfd.qty) as qty"; - $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd"; + $sql .= " FROM ".MAIN_DB_PREFIX."receptiondet_batch as cfd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as l on l.rowid = cfd.fk_commandefourndet"; $sql .= " WHERE cfd.fk_commande = ".((int) $object->id); $sql .= " GROUP BY l.rowid, cfd.fk_product"; @@ -1158,7 +1158,7 @@ if ($id > 0 || !empty($ref)) { $sql .= " ,cfd.fk_reception, r.date_delivery"; } $sql .= " FROM ".MAIN_DB_PREFIX."product as p,"; - $sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd"; + $sql .= " ".MAIN_DB_PREFIX."receptiondet_batch as cfd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as cd ON cd.rowid = cfd.fk_commandefourndet"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e ON cfd.fk_entrepot = e.rowid"; if ($conf->reception->enabled) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 5a7ae18ee1d..99279e0b173 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3427,7 +3427,7 @@ class Product extends CommonObject $sql = "SELECT COUNT(DISTINCT cf.fk_soc) as nb_suppliers, COUNT(DISTINCT cf.rowid) as nb,"; $sql .= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty"; - $sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as fd"; + $sql .= " FROM ".$this->db->prefix()."receptiondet_batch as fd"; $sql .= ", ".$this->db->prefix()."commande_fournisseur as cf"; $sql .= ", ".$this->db->prefix()."societe as s"; if (!$user->hasRight('societe', 'client', 'voir') && !$forVirtualStock) { diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 0e9852fba82..9c145073f94 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -835,7 +835,7 @@ class Productlot extends CommonObject $sql = "SELECT COUNT(DISTINCT cf.fk_soc) as nb_customers, COUNT(DISTINCT cf.rowid) as nb,"; $sql .= " COUNT(cfd.rowid) as nb_rows, SUM(cfdi.qty) as qty"; - $sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as cfdi"; + $sql .= " FROM ".$this->db->prefix()."receptiondet_batch as cfdi"; $sql .= " INNER JOIN ".$this->db->prefix()."commande_fournisseurdet as cfd ON (cfd.rowid = cfdi.fk_commandefourndet)"; $sql .= " INNER JOIN ".$this->db->prefix()."commande_fournisseur as cf ON (cf.rowid = cfd.fk_commande)"; // $sql .= ", ".$this->db->prefix()."societe as s"; @@ -910,7 +910,7 @@ class Productlot extends CommonObject $sql = "SELECT COUNT(DISTINCT recep.fk_soc) as nb_customers, COUNT(DISTINCT recep.rowid) as nb,"; $sql .= " COUNT(cfdi.rowid) as nb_rows, SUM(cfdi.qty) as qty"; - $sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as cfdi"; + $sql .= " FROM ".$this->db->prefix()."receptiondet_batch as cfdi"; $sql .= " INNER JOIN ".$this->db->prefix()."reception as recep ON (recep.rowid = cfdi.fk_reception)"; // $sql .= ", ".$this->db->prefix()."societe as s"; if (!$user->hasRight('societe', 'client', 'voir')) { diff --git a/htdocs/product/stock/lib/replenishment.lib.php b/htdocs/product/stock/lib/replenishment.lib.php index 8751935cb13..e6bf9d8a060 100644 --- a/htdocs/product/stock/lib/replenishment.lib.php +++ b/htdocs/product/stock/lib/replenishment.lib.php @@ -38,7 +38,7 @@ function dolDispatchToDo($order_id) $ordered = array(); // Count nb of quantity dispatched per product - $sql = 'SELECT fk_product, SUM(qty) as qtydispatched FROM '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch'; + $sql = 'SELECT fk_product, SUM(qty) as qtydispatched FROM '.MAIN_DB_PREFIX.'receptiondet_batch'; $sql .= ' WHERE fk_commande = '.((int) $order_id); $sql .= ' GROUP BY fk_product'; $sql .= ' ORDER by fk_product'; diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index a9ae3c62195..b3e9b4aa510 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -451,7 +451,7 @@ if ($usevirtualstock) { $sqlReceptionFourn = "(SELECT ".$db->ifsql("SUM(fd4.qty) IS NULL", "0", "SUM(fd4.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL $sqlReceptionFourn .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf4,"; - $sqlReceptionFourn .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd4"; + $sqlReceptionFourn .= " ".MAIN_DB_PREFIX."receptiondet_batch as fd4"; $sqlReceptionFourn .= " WHERE fd4.fk_commande = cf4.rowid AND cf4.entity IN (".getEntity(getDolGlobalString('STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE') ? 'stock' : 'supplier_order').")"; $sqlReceptionFourn .= " AND fd4.fk_product = p.rowid"; $sqlReceptionFourn .= " AND cf4.fk_statut IN (3,4))"; diff --git a/htdocs/product/stock/stats/commande_fournisseur.php b/htdocs/product/stock/stats/commande_fournisseur.php index 756f814f575..4365c91e460 100644 --- a/htdocs/product/stock/stats/commande_fournisseur.php +++ b/htdocs/product/stock/stats/commande_fournisseur.php @@ -224,7 +224,7 @@ if ($id > 0 || !empty($ref)) { $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseur as cf ON (cf.fk_soc = s.rowid)"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as cfd ON (cfd.fk_commande = cf.rowid)"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfdi ON (cfdi.fk_commandefourndet = cfd.rowid)"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."receptiondet_batch as cfdi ON (cfdi.fk_commandefourndet = cfd.rowid)"; if (!$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } diff --git a/htdocs/product/stock/stats/reception.php b/htdocs/product/stock/stats/reception.php index 63c4b942310..cc7165e3f4b 100644 --- a/htdocs/product/stock/stats/reception.php +++ b/htdocs/product/stock/stats/reception.php @@ -223,7 +223,7 @@ if ($id > 0 || !empty($ref)) { } $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."reception as recep ON (recep.fk_soc = s.rowid)"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as d ON (d.fk_reception = recep.rowid)"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."receptiondet_batch as d ON (d.fk_reception = recep.rowid)"; if (!$user->hasRight('societe', 'client', 'voir')) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 0498c8d06bc..96835b53dc5 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1035,7 +1035,7 @@ if ($action == 'create') { // Note that if an extrafield with the same name exists in the origin supplier order line, the value // from the HTTP query will be ignored foreach ($suffix2numAsked as $suffix => $n) { - $dispatchLines[$n]['array_options'] = $extrafields->getOptionalsFromPost('commande_fournisseur_dispatch', '_' . $suffix, ''); + $dispatchLines[$n]['array_options'] = $extrafields->getOptionalsFromPost('receptiondet_batch', '_' . $suffix, ''); } print ''; + print ''; + } + print ''; print ''; print ''; From 3a0bf96e925fc88a80788cfadf80be331cdacc3c Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Wed, 13 Mar 2024 11:49:03 +0100 Subject: [PATCH 157/714] add password and genericpassword entry types --- htdocs/core/class/html.formsetup.class.php | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index e5199267d31..700a66d422a 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -905,6 +905,10 @@ class FormSetupItem $selected = (empty($this->fieldValue) ? '' : $this->fieldValue); $out.= $this->form->select_comptes($selected, $this->confKey, 0, '', 0, '', 0, '', 1); } + } elseif ($this->type == 'password') { + $out.= $this->generateInputFieldPassword('dolibarr'); + } elseif ($this->type == 'genericpassword') { + $out.= $this->generateInputFieldPassword('generic'); } else { $out.= $this->generateInputFieldText(); } @@ -1028,6 +1032,37 @@ class FormSetupItem } + /** + * generate input field for a password + * + * @param [type] $type 'dolibarr' (dolibarr password rules apply) or 'generic' + * + * @return string + */ + public function generateInputFieldPassword($type = 'generic') + { + global $conf, $langs, $user; + + $min = 8; + $max = 50; + if ($type == 'dolibarr') { + $gen = getDolGlobalString('USER_PASSWORD_GENERATED', 'standard'); + if ($gen == 'none') { + $gen = 'standard'; + } + $nomclass = "modGeneratePass".ucfirst($gen); + $nomfichier = $nomclass.".class.php"; + require_once DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomfichier; + $genhandler = new $nomclass($this->db, $conf, $langs, $user); + $min = $genhandler->length; + $max = $genhandler->length2; + } + $out = ''; + return $out; + } + + + /** * generateInputFieldMultiSelect * @@ -1209,6 +1244,8 @@ class FormSetupItem } elseif ($resbank < 0) { $this->setErrors($bankaccount->errors); } + } elseif ($this->type == 'password' || $this->type == 'genericpassword') { + $out.= str_repeat('*', strlen($this->fieldValue)); } else { $out.= $this->fieldValue; } @@ -1480,4 +1517,28 @@ class FormSetupItem $this->type = 'selectBankAccount'; return $this; } + + /** + * Set type of input as a password with dolibarr password rules apply. + * Hide entry on display. + * + * @return self + */ + public function setAsPassword() + { + $this->type = 'password'; + return $this; + } + + /** + * Set type of input as a generic password without dolibarr password rules (for external passwords for example). + * Hide entry on display. + * + * @return self + */ + public function setAsGenericPassword() + { + $this->type = 'genericpassword'; + return $this; + } } From 3d449b8fce548e77e37d8312af389465ee09f1f5 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Wed, 13 Mar 2024 11:54:05 +0100 Subject: [PATCH 158/714] phpdoc missing argument type, thanks to phpstan ! --- htdocs/core/class/html.formsetup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 700a66d422a..999603adf8a 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -1035,7 +1035,7 @@ class FormSetupItem /** * generate input field for a password * - * @param [type] $type 'dolibarr' (dolibarr password rules apply) or 'generic' + * @param string $type 'dolibarr' (dolibarr password rules apply) or 'generic' * * @return string */ From b9007acbf18f6272509d35d3c9378142a5f8475e Mon Sep 17 00:00:00 2001 From: William Mead Date: Wed, 13 Mar 2024 14:03:27 +0100 Subject: [PATCH 159/714] Fixed PHP warnings --- .../comm/action/class/cactioncomm.class.php | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index bc6f454539a..d308ce7bd1c 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -192,9 +192,21 @@ class CActionComm $nump = $this->db->num_rows($resql); if ($nump) { $idforallfornewmodule = 96; - $TSystem = array(); - $TSystemAuto = array(); - $TModule = array(); + $TSystem = array( + 'id' => [], + 'code' => [], + 'all' => [] + ); + $TSystemAuto = array( + 'id' => [], + 'code' => [], + 'all' => [] + ); + $TModule = array( + 'id' => [], + 'code' => [], + 'all' => [] + ); $i = 0; while ($i < $nump) { $obj = $this->db->fetch_object($resql); @@ -319,8 +331,8 @@ class CActionComm } if ($onlyautoornot > 0 && preg_match('/^module/', $obj->type) && $obj->module) { - $TModule['code'][$obj->code] .= ' ('.$langs->trans("Module").': '.$obj->module.')'; - $TModule['all'][$obj->code]['label'] .= ' ('.$langs->trans("Module").': '.$obj->module.')'; + array_key_exists($obj->code, $TModule['code']) ? ($TModule['code'][$obj->code] .= ' ('.$langs->trans("Module").': '.$obj->module.')') : ($TModule['code'][$obj->code] = ' ('.$langs->trans("Module").': '.$obj->module.')'); + array_key_exists($obj->code, $TModule['all']) ? ($TModule['all'][$obj->code]['label'] .= ' ('.$langs->trans("Module").': '.$obj->module.')') : ($TModule['all'][$obj->code]['label'] = ' ('.$langs->trans("Module").': '.$obj->module.')'); } } $i++; From 2baab69aa01dcf869aadad7244221fa08322b7fd Mon Sep 17 00:00:00 2001 From: William Mead Date: Wed, 13 Mar 2024 14:34:46 +0100 Subject: [PATCH 160/714] Cleaned code. Fixed undefined userSID warning when LDAP bind failed. Added attribute table error message when LDAP bind failed. --- htdocs/user/ldap.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index ab95f1ad25e..47b9017b008 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -33,7 +33,7 @@ $langs->loadLangs(array('users', 'admin', 'companies', 'ldap')); $id = GETPOSTINT('id'); $action = GETPOST('action', 'aZ09'); -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'userldap'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?: 'userldap'; // To manage different context of search // Security check $socid = 0; @@ -125,9 +125,7 @@ print ''; if (getDolGlobalString('LDAP_SERVER_TYPE') == "activedirectory") { $ldap = new Ldap(); $result = $ldap->connectBind(); - if ($result > 0) { - $userSID = $ldap->getObjectSid($object->login); - } + ($result > 0) ? ($userSID = $ldap->getObjectSid($object->login)) : $userSID = ''; print ''.$langs->trans("SID").''; print ''.$userSID.''; print "\n"; @@ -204,6 +202,7 @@ if ($result > 0) { $ldap->unbind(); } else { + print ''.$langs->trans("ErrorFailedToReadLDAP").''; setEventMessages($ldap->error, $ldap->errors, 'errors'); } From 06a593a2c3aee24940e8f733ee15f17646a8a920 Mon Sep 17 00:00:00 2001 From: William Mead Date: Wed, 13 Mar 2024 14:36:04 +0100 Subject: [PATCH 161/714] Added contributor details --- htdocs/user/ldap.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index 47b9017b008..f2e9a3708d2 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -1,6 +1,7 @@ - * Copyright (C) 2006-2021 Regis Houssin +/* Copyright (C) 2006-2012 Laurent Destailleur + * Copyright (C) 2006-2021 Regis Houssin + * Copyright (C) 2024 William Mead * * 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 From c314bdc82d6784769c817cc494b783f93d748d0a Mon Sep 17 00:00:00 2001 From: Hystepik Date: Wed, 13 Mar 2024 15:34:00 +0100 Subject: [PATCH 162/714] fix trad not showing --- htdocs/admin/pdf_other.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php index 20603909699..dd803f2ad71 100644 --- a/htdocs/admin/pdf_other.php +++ b/htdocs/admin/pdf_other.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; // Load translation files required by the page -$langs->loadLangs(array('admin', 'bills', 'companies', 'languages', 'members', 'other', 'products', 'propal', 'receptions', 'stocks', 'trips')); +$langs->loadLangs(array('admin', 'bills', 'companies', 'languages', 'members', 'other', 'products', 'propal', 'receptions', 'stocks', 'trips', 'orders')); if (!$user->admin) { accessforbidden(); From 3668efcd90b81342a62f4e3c55f08ba3fa72ce26 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Wed, 13 Mar 2024 15:34:29 +0100 Subject: [PATCH 163/714] fix warnings phpstan --- htdocs/mrp/class/mo.class.php | 2 +- htdocs/user/class/user.class.php | 350 ++++++++++++++++--------------- 2 files changed, 178 insertions(+), 174 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 4b91802fd5a..c55149fe424 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1844,7 +1844,7 @@ class Mo extends CommonObject * Function used to return all child MOs recursively * * @param int $depth Depth for recursing loop count - * @return Mo[]|int[] array of MOs if OK, -1 if KO + * @return Mo[]|int[]|int array of MOs if OK, -1 if KO */ public function getAllMoChilds($depth = 0) { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index fd6b5d6dc3a..641189725fd 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1187,15 +1187,17 @@ class User extends CommonObject { global $conf; + $alreadyloaded = false; + if (empty($forcereload)) { if ($moduletag && isset($this->_tab_loaded[$moduletag]) && $this->_tab_loaded[$moduletag]) { // Rights for this module are already loaded, so we leave - return; + $alreadyloaded = true; } if (!empty($this->all_permissions_are_loaded)) { // We already loaded all rights for this user, so we leave - return; + $alreadyloaded = true; } } @@ -1209,211 +1211,213 @@ class User extends CommonObject // Get permission of users + Get permissions of groups - // First user permissions - $sql = "SELECT DISTINCT r.module, r.perms, r.subperms"; - $sql .= " FROM ".$this->db->prefix()."user_rights as ur,"; - $sql .= " ".$this->db->prefix()."rights_def as r"; - $sql .= " WHERE r.id = ur.fk_id"; - if (getDolGlobalString('MULTICOMPANY_BACKWARD_COMPATIBILITY')) { - // on old version, we use entity defined into table r only - $sql .= " AND r.entity IN (0,".(isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') ? "1," : "").$conf->entity.")"; - } else { - // On table r=rights_def, the unique key is (id, entity) because id is hard coded into module descriptor and insert during module activation. - // So we must include the filter on entity on both table r. and ur. - $sql .= " AND r.entity = ".((int) $conf->entity)." AND ur.entity = ".((int) $conf->entity); - } - $sql .= " AND ur.fk_user= ".((int) $this->id); - $sql .= " AND r.perms IS NOT NULL"; - if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { - $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled - } - if ($moduletag) { - $sql .= " AND r.module = '".$this->db->escape($moduletag)."'"; - } - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) { - $obj = $this->db->fetch_object($resql); - - if ($obj) { - $module = $obj->module; - $perms = $obj->perms; - $subperms = $obj->subperms; - - if (!empty($perms)) { - if (!empty($module)) { - if (!isset($this->rights->$module) || !is_object($this->rights->$module)) { - $this->rights->$module = new stdClass(); - } - if (!empty($subperms)) { - if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) { - $this->rights->$module->$perms = new stdClass(); - } - if (empty($this->rights->$module->$perms->$subperms)) { - $this->nb_rights++; - } - $this->rights->$module->$perms->$subperms = 1; - } else { - if (empty($this->rights->$module->$perms)) { - $this->nb_rights++; - } - $this->rights->$module->$perms = 1; - } - } - } - } - $i++; - } - $this->db->free($resql); - } - - // Now permissions of groups - $sql = "SELECT DISTINCT r.module, r.perms, r.subperms"; - $sql .= " FROM ".$this->db->prefix()."usergroup_rights as gr,"; - $sql .= " ".$this->db->prefix()."usergroup_user as gu,"; - $sql .= " ".$this->db->prefix()."rights_def as r"; - $sql .= " WHERE r.id = gr.fk_id"; - // A very strange business rules. Must be same than into user->getrights() user/perms.php and user/group/perms.php - if (getDolGlobalString('MULTICOMPANY_BACKWARD_COMPATIBILITY')) { - if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) { - $sql .= " AND gu.entity IN (0,".$conf->entity.")"; + if (!$alreadyloaded) { + // First user permissions + $sql = "SELECT DISTINCT r.module, r.perms, r.subperms"; + $sql .= " FROM ".$this->db->prefix()."user_rights as ur,"; + $sql .= " ".$this->db->prefix()."rights_def as r"; + $sql .= " WHERE r.id = ur.fk_id"; + if (getDolGlobalString('MULTICOMPANY_BACKWARD_COMPATIBILITY')) { + // on old version, we use entity defined into table r only + $sql .= " AND r.entity IN (0,".(isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') ? "1," : "").$conf->entity.")"; } else { - $sql .= " AND r.entity = ".((int) $conf->entity); + // On table r=rights_def, the unique key is (id, entity) because id is hard coded into module descriptor and insert during module activation. + // So we must include the filter on entity on both table r. and ur. + $sql .= " AND r.entity = ".((int) $conf->entity)." AND ur.entity = ".((int) $conf->entity); + } + $sql .= " AND ur.fk_user= ".((int) $this->id); + $sql .= " AND r.perms IS NOT NULL"; + if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { + $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled + } + if ($moduletag) { + $sql .= " AND r.module = '".$this->db->escape($moduletag)."'"; } - } else { - $sql .= " AND gr.entity = ".((int) $conf->entity); // Only groups created in current entity - // The entity on the table usergroup_user should be useless and should never be used because it is already into gr and r. - // but when using MULTICOMPANY_TRANSVERSE_MODE, we may insert record that make rubbish result due to duplicate record of - // other entities, so we are forced to add a filter here - $sql .= " AND gu.entity IN (0,".$conf->entity.")"; - $sql .= " AND r.entity = ".((int) $conf->entity); // Only permission of modules enabled in current entity - } - // End of strange business rule - $sql .= " AND gr.fk_usergroup = gu.fk_usergroup"; - $sql .= " AND gu.fk_user = ".((int) $this->id); - $sql .= " AND r.perms IS NOT NULL"; - if ($moduletag) { - $sql .= " AND r.module = '".$this->db->escape($moduletag)."'"; - } - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) { - $obj = $this->db->fetch_object($resql); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) { + $obj = $this->db->fetch_object($resql); - if ($obj) { - $module = $obj->module; - $perms = $obj->perms; - $subperms = $obj->subperms; + if ($obj) { + $module = $obj->module; + $perms = $obj->perms; + $subperms = $obj->subperms; - if (!empty($perms)) { - if (!empty($module)) { - if (!isset($this->rights->$module) || !is_object($this->rights->$module)) { - $this->rights->$module = new stdClass(); - } - if (!empty($subperms)) { - if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) { - $this->rights->$module->$perms = new stdClass(); + if (!empty($perms)) { + if (!empty($module)) { + if (!isset($this->rights->$module) || !is_object($this->rights->$module)) { + $this->rights->$module = new stdClass(); } - if (empty($this->rights->$module->$perms->$subperms)) { - $this->nb_rights++; - } - $this->rights->$module->$perms->$subperms = 1; - } else { - if (empty($this->rights->$module->$perms)) { - $this->nb_rights++; - } - // if we have already define a subperm like this $this->rights->$module->level1->level2 with llx_user_rights, we don't want override level1 because the level2 can be not define on user group - if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) { + if (!empty($subperms)) { + if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) { + $this->rights->$module->$perms = new stdClass(); + } + if (empty($this->rights->$module->$perms->$subperms)) { + $this->nb_rights++; + } + $this->rights->$module->$perms->$subperms = 1; + } else { + if (empty($this->rights->$module->$perms)) { + $this->nb_rights++; + } $this->rights->$module->$perms = 1; } } } } + $i++; } - $i++; + $this->db->free($resql); } - $this->db->free($resql); - } - // Force permission on user for admin - if (!empty($this->admin)) { - if (empty($this->rights->user->user)) { - $this->rights->user->user = new stdClass(); - } - $listofpermtotest = array('lire', 'creer', 'password', 'supprimer', 'export'); - foreach ($listofpermtotest as $permtotest) { - if (empty($this->rights->user->user->$permtotest)) { - $this->rights->user->user->$permtotest = 1; - $this->nb_rights++; + // Now permissions of groups + $sql = "SELECT DISTINCT r.module, r.perms, r.subperms"; + $sql .= " FROM ".$this->db->prefix()."usergroup_rights as gr,"; + $sql .= " ".$this->db->prefix()."usergroup_user as gu,"; + $sql .= " ".$this->db->prefix()."rights_def as r"; + $sql .= " WHERE r.id = gr.fk_id"; + // A very strange business rules. Must be same than into user->getrights() user/perms.php and user/group/perms.php + if (getDolGlobalString('MULTICOMPANY_BACKWARD_COMPATIBILITY')) { + if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) { + $sql .= " AND gu.entity IN (0,".$conf->entity.")"; + } else { + $sql .= " AND r.entity = ".((int) $conf->entity); } + } else { + $sql .= " AND gr.entity = ".((int) $conf->entity); // Only groups created in current entity + // The entity on the table usergroup_user should be useless and should never be used because it is already into gr and r. + // but when using MULTICOMPANY_TRANSVERSE_MODE, we may insert record that make rubbish result due to duplicate record of + // other entities, so we are forced to add a filter here + $sql .= " AND gu.entity IN (0,".$conf->entity.")"; + $sql .= " AND r.entity = ".((int) $conf->entity); // Only permission of modules enabled in current entity } - if (empty($this->rights->user->self)) { - $this->rights->user->self = new stdClass(); + // End of strange business rule + $sql .= " AND gr.fk_usergroup = gu.fk_usergroup"; + $sql .= " AND gu.fk_user = ".((int) $this->id); + $sql .= " AND r.perms IS NOT NULL"; + if ($moduletag) { + $sql .= " AND r.module = '".$this->db->escape($moduletag)."'"; } - $listofpermtotest = array('creer', 'password'); - foreach ($listofpermtotest as $permtotest) { - if (empty($this->rights->user->self->$permtotest)) { - $this->rights->user->self->$permtotest = 1; - $this->nb_rights++; + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) { + $obj = $this->db->fetch_object($resql); + + if ($obj) { + $module = $obj->module; + $perms = $obj->perms; + $subperms = $obj->subperms; + + if (!empty($perms)) { + if (!empty($module)) { + if (!isset($this->rights->$module) || !is_object($this->rights->$module)) { + $this->rights->$module = new stdClass(); + } + if (!empty($subperms)) { + if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) { + $this->rights->$module->$perms = new stdClass(); + } + if (empty($this->rights->$module->$perms->$subperms)) { + $this->nb_rights++; + } + $this->rights->$module->$perms->$subperms = 1; + } else { + if (empty($this->rights->$module->$perms)) { + $this->nb_rights++; + } + // if we have already define a subperm like this $this->rights->$module->level1->level2 with llx_user_rights, we don't want override level1 because the level2 can be not define on user group + if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) { + $this->rights->$module->$perms = 1; + } + } + } + } + } + $i++; } + $this->db->free($resql); } - // Add test on advanced permissions - if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { - if (empty($this->rights->user->user_advance)) { - $this->rights->user->user_advance = new stdClass(); + + // Force permission on user for admin + if (!empty($this->admin)) { + if (empty($this->rights->user->user)) { + $this->rights->user->user = new stdClass(); } - $listofpermtotest = array('readperms', 'write'); + $listofpermtotest = array('lire', 'creer', 'password', 'supprimer', 'export'); foreach ($listofpermtotest as $permtotest) { - if (empty($this->rights->user->user_advance->$permtotest)) { - $this->rights->user->user_advance->$permtotest = 1; + if (empty($this->rights->user->user->$permtotest)) { + $this->rights->user->user->$permtotest = 1; $this->nb_rights++; } } - if (empty($this->rights->user->self_advance)) { - $this->rights->user->self_advance = new stdClass(); + if (empty($this->rights->user->self)) { + $this->rights->user->self = new stdClass(); } - $listofpermtotest = array('readperms', 'writeperms'); + $listofpermtotest = array('creer', 'password'); foreach ($listofpermtotest as $permtotest) { - if (empty($this->rights->user->self_advance->$permtotest)) { - $this->rights->user->self_advance->$permtotest = 1; + if (empty($this->rights->user->self->$permtotest)) { + $this->rights->user->self->$permtotest = 1; $this->nb_rights++; } } - if (empty($this->rights->user->group_advance)) { - $this->rights->user->group_advance = new stdClass(); - } - $listofpermtotest = array('read', 'readperms', 'write', 'delete'); - foreach ($listofpermtotest as $permtotest) { - if (empty($this->rights->user) || empty($this->rights->user->group_advance->$permtotest)) { - $this->rights->user->group_advance->$permtotest = 1; - $this->nb_rights++; + // Add test on advanced permissions + if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { + if (empty($this->rights->user->user_advance)) { + $this->rights->user->user_advance = new stdClass(); + } + $listofpermtotest = array('readperms', 'write'); + foreach ($listofpermtotest as $permtotest) { + if (empty($this->rights->user->user_advance->$permtotest)) { + $this->rights->user->user_advance->$permtotest = 1; + $this->nb_rights++; + } + } + if (empty($this->rights->user->self_advance)) { + $this->rights->user->self_advance = new stdClass(); + } + $listofpermtotest = array('readperms', 'writeperms'); + foreach ($listofpermtotest as $permtotest) { + if (empty($this->rights->user->self_advance->$permtotest)) { + $this->rights->user->self_advance->$permtotest = 1; + $this->nb_rights++; + } + } + if (empty($this->rights->user->group_advance)) { + $this->rights->user->group_advance = new stdClass(); + } + $listofpermtotest = array('read', 'readperms', 'write', 'delete'); + foreach ($listofpermtotest as $permtotest) { + if (empty($this->rights->user) || empty($this->rights->user->group_advance->$permtotest)) { + $this->rights->user->group_advance->$permtotest = 1; + $this->nb_rights++; + } } } } - } - // For backward compatibility - if (isset($this->rights->propale) && !isset($this->rights->propal)) { - $this->rights->propal = $this->rights->propale; - } - if (isset($this->rights->propal) && !isset($this->rights->propale)) { - $this->rights->propale = $this->rights->propal; - } + // For backward compatibility + if (isset($this->rights->propale) && !isset($this->rights->propal)) { + $this->rights->propal = $this->rights->propale; + } + if (isset($this->rights->propal) && !isset($this->rights->propale)) { + $this->rights->propale = $this->rights->propal; + } - if (!$moduletag) { - // If the module was not define, then everything is loaded. - // Therefore, we can consider that the permissions are cached - // because they were all loaded for this user instance. - $this->all_permissions_are_loaded = 1; - } else { - // If the module is defined, we flag it as loaded into cache - $this->_tab_loaded[$moduletag] = 1; + if (!$moduletag) { + // If the module was not define, then everything is loaded. + // Therefore, we can consider that the permissions are cached + // because they were all loaded for this user instance. + $this->all_permissions_are_loaded = 1; + } else { + // If the module is defined, we flag it as loaded into cache + $this->_tab_loaded[$moduletag] = 1; + } } } From 5e5792d1449ff796a19a3b850a4f1d2be6a8e6e3 Mon Sep 17 00:00:00 2001 From: Jonathan lescaut Date: Wed, 13 Mar 2024 15:38:29 +0100 Subject: [PATCH 164/714] add import kit --- htdocs/core/modules/modProduct.class.php | 22 +++++++++++++++++++ .../install/mysql/migration/19.0.0-20.0.0.sql | 2 ++ .../tables/llx_product_association.key.sql | 1 + .../mysql/tables/llx_product_association.sql | 3 ++- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 28b5f19174c..258a0fc5b33 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -944,6 +944,28 @@ class modProduct extends DolibarrModules $this->import_examplevalues_array[$r] = array('l.fk_product'=>'ref:PRODUCT_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US'); $this->import_updatekeys_array[$r] = array('l.fk_product'=>'ProductOrService', 'l.lang'=>'Language'); } + + if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) { + // Import products kit + $r++; + $this->import_code[$r] = $this->rights_class . '_' . $r; + $this->import_label[$r] = "AssociatedProducts"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('pa' => MAIN_DB_PREFIX . 'product_association'); + $this->import_fields_array[$r] = array('pa.fk_product_pere' => 'ParentProducts', 'pa.fk_product_fils' => 'ComposedProduct', 'pa.qty' => 'Qty', 'pa.incdec' => 'ComposedProductIncDecStock', 'pa.rang' => 'rang'); + + $this->import_convertvalue_array[$r] = array( + 'pa.fk_product_pere' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product'), + 'pa.fk_product_fils' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product') + ); + $this->import_examplevalues_array[$r] = array( + 'pa.fk_product_pere' => "ref:PREF123456", + 'pa.fk_product_fils' => "ref:PREF123456", + 'pa.qty' => "100", + 'pa.incdec' => "0", + 'pa.rang' => "1"); + } } diff --git a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql index 4f50ee95936..1a109507a36 100644 --- a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql +++ b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql @@ -268,3 +268,5 @@ ALTER TABLE llx_facture_fourn ADD INDEX idx_facture_fourn_tms (tms); ALTER TABLE llx_element_element MODIFY COLUMN sourcetype VARCHAR(64) NOT NULL; ALTER TABLE llx_element_element MODIFY COLUMN targettype VARCHAR(64) NOT NULL; ALTER TABLE llx_c_type_contact MODIFY COLUMN element VARCHAR(64) NOT NULL; + +ALTER TABLE llx_product_association ADD COLUMN import_key varchar(14) DEFAULT NULL; diff --git a/htdocs/install/mysql/tables/llx_product_association.key.sql b/htdocs/install/mysql/tables/llx_product_association.key.sql index 9eb9fdd457b..c9dca6e611e 100644 --- a/htdocs/install/mysql/tables/llx_product_association.key.sql +++ b/htdocs/install/mysql/tables/llx_product_association.key.sql @@ -20,3 +20,4 @@ ALTER TABLE llx_product_association ADD UNIQUE INDEX uk_product_association (fk_product_pere, fk_product_fils); ALTER TABLE llx_product_association ADD INDEX idx_product_association_fils (fk_product_fils); + diff --git a/htdocs/install/mysql/tables/llx_product_association.sql b/htdocs/install/mysql/tables/llx_product_association.sql index f97e2aa6a0b..55ce8cc9d78 100644 --- a/htdocs/install/mysql/tables/llx_product_association.sql +++ b/htdocs/install/mysql/tables/llx_product_association.sql @@ -24,6 +24,7 @@ create table llx_product_association fk_product_fils integer NOT NULL DEFAULT 0, -- id du sous-produit qty double NULL, incdec integer DEFAULT 1, -- when set to 1 changing stock of product will change stock of linked product too - rang integer DEFAULT 0 + rang integer DEFAULT 0, + import_key varchar(14) DEFAULT NULL )ENGINE=innodb; From b9ed346711072c479607050e8c742751145d414d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Mar 2024 15:54:15 +0100 Subject: [PATCH 165/714] FIX edit bank suggested for credit transfer payment in invoice setup when bank is closed. --- htdocs/admin/facture.php | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 19f1182e608..7bf83eb4a9c 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -618,13 +618,14 @@ if (getDolGlobalString('INVOICE_USE_DEFAULT_DOCUMENT')) { // Hidden conf print '
'; print ''; print ''; + print ''; print '
'; print ''; print ''; print ''; print ''; - print ''; + print ''; print "\n"; $listtype = array( @@ -660,6 +661,7 @@ print load_fiche_titre($langs->trans("SuggestedPaymentModesIfNotDefinedInInvoice print ''; print ''; +print ''; print '
'; print '
'.$langs->trans("Type").''.$langs->trans("Name").'
'; @@ -668,17 +670,16 @@ print ''; print ''; -print ''; +print ''; print "\n"; print ''; print ""; print ""; print "
'; print ''; print $langs->trans("PaymentMode").'
".$langs->trans("SuggestPaymentByRIBOnAccount").""; if (isModEnabled('banque')) { - $sql = "SELECT rowid, label"; + $sql = "SELECT rowid, label, clos"; $sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; - $sql .= " WHERE clos = 0"; - $sql .= " AND courant = 1"; + $sql .= " WHERE courant = 1"; $sql .= " AND entity IN (".getEntity('bank_account').")"; $resql = $db->query($sql); if ($resql) { @@ -688,15 +689,19 @@ if (isModEnabled('banque')) { print '"; + print ajax_combobox("rib"); } else { print ''.$langs->trans("NoActiveBankAccountDefined").''; } @@ -736,6 +741,8 @@ if ($resql) { } } print ""; +print ajax_combobox("chq", array(), 0, 0, 'resolve', -2); + print "
"; print '
'; @@ -758,12 +765,13 @@ print "\n"; print ''; print ''; print ''; +print ''; print ''; print $langs->trans("ForceInvoiceDate"); print ''; print $form->selectyesno("forcedate", getDolGlobalInt('FAC_FORCE_DATE_VALIDATION', 0), 1); print ''; -print ''; +print ''; print "\n"; print '
'; @@ -778,6 +786,7 @@ $htmltext .= ''; print '
'; print ''; print ''; +print ''; print ''; print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'INVOICE_FREE_TEXT'; @@ -789,7 +798,7 @@ if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) { print $doleditor->Create(); } print ''; -print ''; +print ''; print "\n"; print '
'; @@ -797,12 +806,13 @@ print ''; print '
'; print ''; print ''; +print ''; print ''; print $form->textwithpicto($langs->trans("WatermarkOnDraftBill"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; print ''; print ''; print ''; -print ''; +print ''; print "\n"; print '
'; From b3b7afa07aff27b15b417658a8301a6b8efa5bd5 Mon Sep 17 00:00:00 2001 From: William Mead Date: Wed, 13 Mar 2024 16:26:10 +0100 Subject: [PATCH 166/714] Fixed warning undefined userId & nbevent. --- htdocs/user/agenda.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/agenda.php b/htdocs/user/agenda.php index 7c692bb9ba4..af23913a051 100644 --- a/htdocs/user/agenda.php +++ b/htdocs/user/agenda.php @@ -89,7 +89,7 @@ if (($object->id != $user->id) && !$user->hasRight('user', 'user', 'lire')) { accessforbidden(); } -$parameters = array('id' => $userId); +$parameters = array('id' => $user->id); $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'); @@ -195,7 +195,7 @@ if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || // Try to know count of actioncomm from cache require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; $cachekey = 'count_events_user_'.$object->id; - //$nbEvent = dol_getcache($cachekey); // TODO Add nb into badge in menu so we can get it from cache also here + $nbEvent = dol_getcache($cachekey); $titlelist = $langs->trans("ActionsOnCompany").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); if (!empty($conf->dol_optimize_smallscreen)) { From cd727f22a6c0f5cb0f458ea55a18620d560506fa Mon Sep 17 00:00:00 2001 From: William Mead Date: Wed, 13 Mar 2024 16:26:52 +0100 Subject: [PATCH 167/714] Fixed event count --- htdocs/core/lib/usergroups.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 87e6e367cb3..2ffc38d1072 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -197,9 +197,9 @@ function user_prepare_head(User $object) if (!is_null($dataretrieved)) { $nbEvent = $dataretrieved; } else { - $sql = "SELECT COUNT(id) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm"; - $sql .= " WHERE fk_user_done = ".((int) $object->id); + $sql = "SELECT COUNT(ac.id) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as ac"; + $sql .= " WHERE fk_user_action = ".((int) $object->id); $sql .= " AND entity IN (".getEntity('agenda').")"; $resql = $db->query($sql); if ($resql) { From 04282f9c5f96c3e03390397d4049194619f2f7d4 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 16:45:14 +0100 Subject: [PATCH 168/714] Fix PhanTypeInvalidUnaryOperandIncOrDec by typing $error # Fix PhanTypeInvalidUnaryOperandIncOrDec by typing $error For some strange reason phan determined that $error was not an int, so forced the typing to fix the PhanTypeInvalidUnaryOperandIncOrDec notifications in this file --- htdocs/website/index.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 31b79d9722e..566a1c2feb9 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1,6 +1,7 @@ * Copyright (C) 2020 Nicolas ZABOURI + * 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 @@ -747,6 +748,8 @@ if ($action == 'addsite' && $usercanedit) { } } +'@phan-var-force int $error'; + // Add page/container if ($action == 'addcontainer' && $usercanedit) { dol_mkdir($pathofwebsite); @@ -761,6 +764,7 @@ if ($action == 'addcontainer' && $usercanedit) { $grabimagesinto = GETPOST('grabimagesinto', 'alpha'); include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + // The include seems to break typing on variables if (empty($urltograb)) { $error++; From e4331877dfeea79da0165e175e88c9fb747d15f7 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 16:46:21 +0100 Subject: [PATCH 169/714] Fix: Remove stray $i++ --- htdocs/barcode/printsheet.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 9dbc437758c..6ee4e9c9ac7 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003 Rodolphe Quiedeville * Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2006-2017 Laurent Destailleur + * 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 @@ -253,8 +254,6 @@ if (empty($reshook)) { } } - $i++; - // Build and output PDF if (!$error && $mode == 'label') { if (!count($arrayofrecords)) { From 1daa77650cc7bac7bc0e3ffd9764a860263ee2ea Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 16:50:28 +0100 Subject: [PATCH 170/714] Fix Initialise array to fix PhanTypeInvalidUnaryOperandIncOrDec --- htdocs/compta/cashcontrol/report.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index 83b0a56e563..5a863e5e410 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -8,6 +8,7 @@ * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2017 Alexandre Spangaro * Copyright (C) 2018 Andreu Bisquerra + * 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 @@ -59,13 +60,13 @@ $sortorder = 'ASC'; $sortfield = 'b.datev,b.dateo,b.rowid'; $arrayfields = array( - 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), - 'b.num_chq'=>array('label'=>$langs->trans("Number"), 'checked'=>1), - 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1), - 'cp.code'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1), - 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600), - 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), + 'b.rowid' => array('label' => $langs->trans("Ref"), 'checked' => 1), + 'b.dateo' => array('label' => $langs->trans("DateOperationShort"), 'checked' => 1), + 'b.num_chq' => array('label' => $langs->trans("Number"), 'checked' => 1), + 'ba.ref' => array('label' => $langs->trans("BankAccount"), 'checked' => 1), + 'cp.code' => array('label' => $langs->trans("PaymentMode"), 'checked' => 1), + 'b.debit' => array('label' => $langs->trans("Debit"), 'checked' => 1, 'position' => 600), + 'b.credit' => array('label' => $langs->trans("Credit"), 'checked' => 1, 'position' => 605), ); $syear = $object->year_close; @@ -209,7 +210,7 @@ if ($resql) { $transactionspertype = array(); $amountpertype = array(); - $totalarray = array(); + $totalarray = array('nbfield' => 0,'pos' => array()); while ($i < $num) { $objp = $db->fetch_object($resql); From 393dacd59e42b214293f48ab411be46850693b34 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 16:52:05 +0100 Subject: [PATCH 171/714] Fix Initialise var to fix PhanTypeInvalidUnaryOperandIncOrDec --- htdocs/core/actions_massactions.inc.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 9649ef6252c..382cb71fca4 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1040,6 +1040,7 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' $objecttmp = new $objectclass($db); $nbok = 0; + $nbignored = 0; $TMsg = array(); //$toselect could contain duplicate entries, cf https://github.com/Dolibarr/dolibarr/issues/26244 @@ -1200,6 +1201,7 @@ if (!$error && $massaction == 'generate_doc' && $permissiontoread) { } if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd) { + $nbok = 0; $db->begin(); $affecttag_type = GETPOST('affecttag_type', 'alpha'); @@ -1221,7 +1223,6 @@ if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd } //For each valid categ type set common categ - $nbok = 0; if (!empty($to_affecttag_type_array)) { foreach ($to_affecttag_type_array as $categ_type) { $contcats = GETPOST('contcats_' . $categ_type, 'array'); @@ -1256,6 +1257,7 @@ if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd } if (!$error && ($action == 'updateprice' && $confirm == 'yes') && $permissiontoadd) { + $nbok = 0; $db->begin(); if (GETPOSTISSET('pricerate')) { $pricepercentage = GETPOSTINT('pricerate'); @@ -1300,6 +1302,7 @@ if (!$error && ($action == 'updateprice' && $confirm == 'yes') && $permissiontoa } if (!$error && ($action == 'setsupervisor' && $confirm == 'yes') && $permissiontoadd) { + $nbok = 0; $db->begin(); $supervisortoset = GETPOST('supervisortoset'); if (!empty($supervisortoset)) { @@ -1335,6 +1338,7 @@ if (!$error && ($action == 'setsupervisor' && $confirm == 'yes') && $permissiont } if (!$error && ($action == 'affectuser' && $confirm == 'yes') && $permissiontoadd) { + $nbok = 0; $db->begin(); $usertoaffect = GETPOST('usertoaffect'); From a0ea2ed65487a47736e1cba6f50060c9d8793fbb Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 16:55:14 +0100 Subject: [PATCH 172/714] Fix: Remove stray $i++ --- htdocs/core/lib/company.lib.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 2384751a523..d8113ce1356 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -2230,7 +2230,6 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr } $out .= "\n"; - $i++; } if (empty($histo)) { $colspan = 9; From 3ffa85eb496a83176aca506c1837be50896af1d6 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 16:57:50 +0100 Subject: [PATCH 173/714] Fix: Remove stray $i++ --- htdocs/core/lib/functions.lib.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2c94e4d4a8c..2f794579b7b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13804,8 +13804,6 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null, $out .= ''; $out .= ''; - - $i++; } $out .= "\n"; From dfaa8358fb8a80c92549c5447a2660f6fc0e23b2 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 17:02:37 +0100 Subject: [PATCH 174/714] Fix: Comment unused $errorforemail (outside loop) --- htdocs/emailcollector/class/emailcollector.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 518529630fb..8efeda93635 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -3363,7 +3363,7 @@ class EmailCollector extends CommonObject if (empty($mode) && empty($error)) { $res = imap_mail_move($connection, $imapemail, $targetdir, CP_UID); if ($res == false) { - $errorforemail++; + // $errorforemail++; // Not in loop, not needed, not initialised $this->error = imap_last_error(); $this->errors[] = $this->error; From 636d552499835135f171a524be8a082fce3b000d Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 17:03:36 +0100 Subject: [PATCH 175/714] Fix: Remove stray $i++ --- htdocs/product/popuprop.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index 455fcf636b8..0af9c8052ae 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -260,7 +260,6 @@ if ($mode && $mode != '-1') { print ''.dol_escape_htmltag($vals['label']).''; print ''.$vals['nbline'].''; print "\n"; - $i++; } } else { print ''.$langs->trans("SelectTheTypeOfObjectToAnalyze").''; From 8ed09542f23ed5a4d5919880e6d204aee68c865b Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 17:04:40 +0100 Subject: [PATCH 176/714] Fix Initialise $error to fix PhanTypeInvalidUnaryOperandIncOrDec --- htdocs/product/stock/movement_card.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index d1ae82983e4..eae9deb3ef0 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -5,6 +5,7 @@ * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2019 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 @@ -249,6 +250,7 @@ if ($action == "correct_stock") { // Transfer stock from a warehouse to another warehouse if ($action == "transfert_stock" && !$cancel) { + $error = 0; $product = new Product($db); if (!empty($product_id)) { $result = $product->fetch($product_id); From 3183079e306d2e39f157b09e6f39e9ff3ba9f275 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 17:05:36 +0100 Subject: [PATCH 177/714] Fix Initialise $error to fix PhanTypeInvalidUnaryOperandIncOrDec --- htdocs/product/stock/movement_list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index fbc888a2793..9a054d18375 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -429,6 +429,7 @@ if ($action == "correct_stock") { // Transfer stock from a warehouse to another warehouse if ($action == "transfert_stock" && !$cancel) { + $error = 0; $product = new Product($db); if (!empty($product_id)) { $result = $product->fetch($product_id); From 29d650960c2a4014ca71a0fa3c1e3884ffda42ef Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 17:08:13 +0100 Subject: [PATCH 178/714] Fix Initialise $numline to fix PhanTypeInvalidUnaryOperandIncOrDec --- htdocs/reception/dispatch.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/reception/dispatch.php b/htdocs/reception/dispatch.php index 69055aa130c..94258089bed 100644 --- a/htdocs/reception/dispatch.php +++ b/htdocs/reception/dispatch.php @@ -9,6 +9,7 @@ * Copyright (C) 2017-2022 Ferran Marcet * Copyright (C) 2018-2022 Frédéric France * Copyright (C) 2019-2020 Christophe Battarel + * 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 @@ -304,6 +305,7 @@ $supplierorderdispatch = new CommandeFournisseurDispatch($db); $title = $object->ref." - ".$langs->trans('ReceptionDistribution'); $help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; $morejs = array('/fourn/js/lib_dispatch.js.php'); +$numline = 0; llxHeader('', $title, $help_url, '', 0, 0, $morejs); From 344ae9e5b470cde09fd402bf1cff220ea30aac87 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 17:09:04 +0100 Subject: [PATCH 179/714] Fix: Remove stray $i++ --- htdocs/societe/admin/societe.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 9821a24974b..285beb5742d 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011-2012 Juanjo Menent + * 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 @@ -735,7 +736,6 @@ foreach ($profid as $key => $val) { print "\n"; } - $i++; } // VAT ID From 0127cc76f5e18ee9b69ab0893572a1c2bc3d3294 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 17:10:09 +0100 Subject: [PATCH 180/714] Qual: Enable PhanTypeInvalidUnaryOperandIncOrDec (all fixed) --- dev/tools/phan/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index 5c021217ac4..4771e953a36 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -482,7 +482,7 @@ return [ 'PhanTypeInvalidPropertyName', 'PhanPluginDuplicateCatchStatementBody', 'PhanPluginUndeclaredVariableIsset', - 'PhanTypeInvalidUnaryOperandIncOrDec', + // 'PhanTypeInvalidUnaryOperandIncOrDec', // 'PhanPluginDescriptionlessCommentOnClass', 'PhanPluginEmptyStatementIf', 'PhanPluginInlineHTMLTrailing', From 8b165963fa078a7f7776154c4194eed9adb89ffb Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Wed, 13 Mar 2024 18:03:10 +0100 Subject: [PATCH 181/714] Fix Update prompts for each functions --- htdocs/ai/admin/custom_prompt.php | 74 ++++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 10 deletions(-) diff --git a/htdocs/ai/admin/custom_prompt.php b/htdocs/ai/admin/custom_prompt.php index ee62b646604..699479bbb9e 100644 --- a/htdocs/ai/admin/custom_prompt.php +++ b/htdocs/ai/admin/custom_prompt.php @@ -80,8 +80,8 @@ $arrayofaifeatures = array( */ $functioncode = GETPOST('functioncode', 'alpha'); -$pre_prompt = GETPOST('prePrompt', 'alpha'); -$post_prompt = GETPOST('postPrompt', 'alpha'); +$pre_prompt = GETPOST('prePrompt'); +$post_prompt = GETPOST('postPrompt'); // get all configs in const AI $currentConfigurationsJson = getDolGlobalString('AI_CONFIGURATIONS_PROMPT'); @@ -126,10 +126,31 @@ if ($action == 'update' && !GETPOST('cancel')) { $action = 'edit'; } -if ($action == 'confirm_deleteproperty') { +if ($action == 'updatePrompts') { + $key = GETPOST('key', 'alpha'); + + $currentConfigurations[$key] = [ + 'prePrompt' => $pre_prompt, + 'postPrompt' => $post_prompt, + ]; + + $newConfigurationsJson = json_encode($currentConfigurations, JSON_UNESCAPED_UNICODE); + $result = dolibarr_set_const($db, 'AI_CONFIGURATIONS_PROMPT', $newConfigurationsJson, 'chaine', 0, '', $conf->entity); + if (!$error) { + $action = 'dodo'; + if ($result) { + header("Location: ".$_SERVER['PHP_SELF']); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + exit; + } else { + setEventMessages($langs->trans("ErrorUpdating"), null, 'errors'); + } + } +} + +if ($action == 'confirm_deleteproperty' && GETPOST('confirm') == 'yes') { $key = GETPOST('key', 'alpha'); - //var_dump($currentConfigurations[$key]);exit; if (isset($currentConfigurations[$key])) { unset($currentConfigurations[$key]); @@ -144,6 +165,9 @@ if ($action == 'confirm_deleteproperty') { } } } +if ($action == 'confirm_deleteproperty') { + var_dump(GETPOST('confirm'));exit; +} /* @@ -249,7 +273,7 @@ if ($action == 'edit') { $out .= ''; $out .= $form->buttonsSaveCancel("Add", ""); - + $out .= ''; $out .= '


'; print $out; @@ -269,19 +293,24 @@ if ($action == 'edit' || $action == 'create') { $out .= ''; $out .= ''; $out .= ''.$arrayofaifeatures[$key]['picto'].' '.$langs->trans($arrayofaifeatures[$key]['label']); - $out .= ''.img_edit().''; + $out .= ''.img_edit().''; $out .= ''.img_delete().''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; + + $out .= '
'; + $out .= ''; + $out .= ''; + $out .= ''; $out .= ''; $out .= ''; $out .= 'pre-Prompt'; $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; $out .= ''; $out .= ''; $out .= ''; @@ -289,15 +318,16 @@ if ($action == 'edit' || $action == 'create') { $out .= 'Post-prompt'; $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; + $out .= '
'; $out .= ''; $out .= ''; + $out .= '
'; } $out .= ''; $out .= ''; } - $out .= ''; $out .= ""; print $out; From f15725ee33017963885ef13cf75bd7db669484ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Mar 2024 18:10:30 +0100 Subject: [PATCH 182/714] Update usergroups.lib.php --- htdocs/core/lib/usergroups.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 2ffc38d1072..2a0dc0d4bc8 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -199,8 +199,8 @@ function user_prepare_head(User $object) } else { $sql = "SELECT COUNT(ac.id) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as ac"; - $sql .= " WHERE fk_user_action = ".((int) $object->id); - $sql .= " AND entity IN (".getEntity('agenda').")"; + $sql .= " WHERE ac.fk_user_action = ".((int) $object->id); + $sql .= " AND ac.entity IN (".getEntity('agenda').")"; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); From 7b4c0536c75ad80408733d640b3fbe1e8ae51422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Wed, 13 Mar 2024 18:11:40 +0100 Subject: [PATCH 183/714] fix warnings --- htdocs/hrm/compare.php | 8 +++++--- htdocs/hrm/skill_tab.php | 7 +++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/htdocs/hrm/compare.php b/htdocs/hrm/compare.php index a75965f797e..8286c7f0cf4 100644 --- a/htdocs/hrm/compare.php +++ b/htdocs/hrm/compare.php @@ -4,6 +4,7 @@ * Copyright (C) 2021 Greg Rastklan * Copyright (C) 2021 Jean-Pascal BOUDET * Copyright (C) 2021 Grégory BLEMAND + * 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 @@ -278,6 +279,7 @@ $fk_usergroup1 = GETPOST('fk_usergroup1'); print dol_get_fiche_end(); llxFooter(); +$db->close(); @@ -357,10 +359,10 @@ function rate(&$TMergedSkills, $field) } /** - * return a html ul list of skills + * return a html ul list of skills * - * @param array $TMergedSkills skill list for display - * @return string (ul list in html ) + * @param array $TMergedSkills skill list for display + * @return string (ul list in html ) */ function skillList(&$TMergedSkills) { diff --git a/htdocs/hrm/skill_tab.php b/htdocs/hrm/skill_tab.php index c7a0e1bd988..a1e71528361 100644 --- a/htdocs/hrm/skill_tab.php +++ b/htdocs/hrm/skill_tab.php @@ -4,6 +4,7 @@ * Copyright (C) 2021 Greg Rastklan * Copyright (C) 2021 Jean-Pascal BOUDET * Copyright (C) 2021 Grégory BLEMAND + * 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 @@ -481,6 +482,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $rslt = $db->query($sqlEval); $numEval = $db->num_rows($sqlEval); + $page = 0; print_barre_liste($langs->trans("Evaluations"), $page, $_SERVER["PHP_SELF"], '', '', '', '', $numEval, $numEval, $evaltmp->picto, 0); print '
'; @@ -547,6 +549,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } print dol_get_fiche_end(); - - llxFooter(); } + +llxFooter(); +$db->close(); From e01d9452d50a5526277b3941ab4cc6d9374553b5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Mar 2024 18:12:00 +0100 Subject: [PATCH 184/714] Update agenda.php --- htdocs/user/agenda.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/agenda.php b/htdocs/user/agenda.php index af23913a051..229c299a2e7 100644 --- a/htdocs/user/agenda.php +++ b/htdocs/user/agenda.php @@ -89,7 +89,7 @@ if (($object->id != $user->id) && !$user->hasRight('user', 'user', 'lire')) { accessforbidden(); } -$parameters = array('id' => $user->id); +$parameters = array('id' => $id); $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'); From 09b11719c436a01c87e155bc73e7dca003d5d46f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Mar 2024 18:15:36 +0100 Subject: [PATCH 185/714] Update report.php --- htdocs/compta/cashcontrol/report.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index 5a863e5e410..bf6a7310720 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -210,7 +210,7 @@ if ($resql) { $transactionspertype = array(); $amountpertype = array(); - $totalarray = array('nbfield' => 0,'pos' => array()); + $totalarray = array('nbfield' => 0, 'pos' => array()); while ($i < $num) { $objp = $db->fetch_object($resql); From f7ec65f10415292eec3f274b7dbb054596b9892e Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Wed, 13 Mar 2024 18:16:55 +0100 Subject: [PATCH 186/714] Add error msg foin ai generate_content --- htdocs/ai/ajax/generate_content.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/ai/ajax/generate_content.php b/htdocs/ai/ajax/generate_content.php index 2d65256ad01..11aaa3e787b 100644 --- a/htdocs/ai/ajax/generate_content.php +++ b/htdocs/ai/ajax/generate_content.php @@ -72,6 +72,8 @@ if (is_array($generatedContent) && $generatedContent['error']) { if ($generatedContent['code'] >= 400) { print "Error : " . $generatedContent['message']; print '
'.$langs->trans('Check Config of Module').''; + } elseif ($generatedContent['code'] == 429) { + print "Quota or allowed period exceeded. Retry Later !"; } else { print "Error returned by API call: " . $generatedContent['message']; } From 26fe76733c717a3fa1191edfe69df149a20e7f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Wed, 13 Mar 2024 18:20:41 +0100 Subject: [PATCH 187/714] fix warnings --- htdocs/commande/class/commande.class.php | 4 ++-- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/class/utils.class.php | 5 +++-- htdocs/core/lib/company.lib.php | 2 +- htdocs/core/lib/functions.lib.php | 2 +- .../core/modules/asset/doc/doc_generic_asset_odt.modules.php | 4 ++-- htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php | 4 ++-- htdocs/core/modules/hrm/mod_evaluation_advanced.php | 2 +- htdocs/core/modules/hrm/mod_evaluation_standard.php | 2 +- htdocs/core/tpl/advtarget.tpl.php | 3 ++- 10 files changed, 16 insertions(+), 14 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index b7d2e37c24d..07dccd2bf24 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1317,8 +1317,8 @@ class Commande extends CommonOrder { global $conf, $hookmanager; - dol_include_once('/multicurrency/class/multicurrency.class.php'); - dol_include_once('/core/class/extrafields.class.php'); + require_once DOL_DOCUMENT_ROOT . '/multicurrency/class/multicurrency.class.php'; + require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $error = 0; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4a3f654a83e..cee9e9bfafd 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6009,7 +6009,7 @@ class Form print ''; print ''; } else { - dol_include_once('/core/lib/company.lib.php'); + require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; print !empty($selected) ? currency_name($selected, 1) : ' '; } } diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 810ee8f24fc..6b00c3bc17b 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2022 Anthony Berton * Copyright (C) 2023-2024 William Mead * 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 @@ -1006,7 +1007,7 @@ class Utils return -1; } - dol_include_once('/core/lib/files.lib.php'); + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $nbSaves = intval(getDolGlobalString('SYSLOG_FILE_SAVES', 10)); @@ -1412,7 +1413,7 @@ class Utils dol_syslog("Utils::cleanUnfinishedCronjob Starting cleaning"); // Import Cronjob class if not present - dol_include_once('/cron/class/cronjob.class.php'); + require_once DOL_DOCUMENT_ROOT . '/cron/class/cronjob.class.php'; // Get this job object $this_job = new Cronjob($db); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 2384751a523..07395e49191 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1615,7 +1615,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr $tms_start = ''; $tms_end = ''; } - dol_include_once('/comm/action/class/actioncomm.class.php'); + require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; // Check parameters if (!is_object($filterobj) && !is_object($objcon)) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2c94e4d4a8c..7b0edc2931b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13129,7 +13129,7 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null, global $param, $massactionbutton; - dol_include_once('/comm/action/class/actioncomm.class.php'); + require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; // Check parameters if (!is_object($filterobj) && !is_object($objcon)) { diff --git a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php index 7e6405baf78..b01f50afb70 100644 --- a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php +++ b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php @@ -4,7 +4,7 @@ * Copyright (C) 2014 Marcos García * Copyright (C) 2016 Charlie Benke * Copyright (C) 2018-2021 Philippe Grand - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-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 @@ -27,7 +27,7 @@ * \brief File of class to build ODT documents for assets */ -dol_include_once('/asset/core/modules/asset/modules_asset.php'); +require_once DOL_DOCUMENT_ROOT . '/asset/core/modules/asset/modules_asset.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php index 15a9d3bf15c..5b6dc78bf0c 100644 --- a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php +++ b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php @@ -8,7 +8,7 @@ * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-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 @@ -31,7 +31,7 @@ * \brief File of class to generate document from standard template */ -dol_include_once('/asset/core/modules/asset/modules_asset.php'); +require_once DOL_DOCUMENT_ROOT . '/asset/core/modules/asset/modules_asset.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/core/modules/hrm/mod_evaluation_advanced.php b/htdocs/core/modules/hrm/mod_evaluation_advanced.php index 78d396d909b..f5b236d4594 100644 --- a/htdocs/core/modules/hrm/mod_evaluation_advanced.php +++ b/htdocs/core/modules/hrm/mod_evaluation_advanced.php @@ -26,7 +26,7 @@ * \brief File containing class for advanced numbering model of Evaluation */ -dol_include_once('/core/modules/hrm/modules_evaluation.php'); + require_once DOL_DOCUMENT_ROOT . '/core/modules/hrm/modules_evaluation.php'; /** diff --git a/htdocs/core/modules/hrm/mod_evaluation_standard.php b/htdocs/core/modules/hrm/mod_evaluation_standard.php index 9a568923e44..eb69f3c0953 100644 --- a/htdocs/core/modules/hrm/mod_evaluation_standard.php +++ b/htdocs/core/modules/hrm/mod_evaluation_standard.php @@ -23,7 +23,7 @@ * \ingroup hrm * \brief File of class to manage Evaluation numbering rules standard */ -dol_include_once('/core/modules/hrm/modules_evaluation.php'); +require_once DOL_DOCUMENT_ROOT . '/core/modules/hrm/modules_evaluation.php'; /** diff --git a/htdocs/core/tpl/advtarget.tpl.php b/htdocs/core/tpl/advtarget.tpl.php index 225707f0828..a4c13f5cd4f 100644 --- a/htdocs/core/tpl/advtarget.tpl.php +++ b/htdocs/core/tpl/advtarget.tpl.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France */ /* * @@ -274,7 +275,7 @@ if (!getDolGlobalString('MAIN_EXTRAFIELDS_DISABLED')) { $socstatic = new Societe($db); $elementtype = $socstatic->table_element; // fetch optionals attributes and labels - dol_include_once('/core/class/extrafields.class.php'); + require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype); foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) { From 439654a634209b505c367fb2334ce089e195c129 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Mar 2024 18:24:35 +0100 Subject: [PATCH 188/714] Fix ternary of ternary too difficult to read --- htdocs/user/ldap.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index f2e9a3708d2..328e14910ae 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -126,7 +126,10 @@ print ''; if (getDolGlobalString('LDAP_SERVER_TYPE') == "activedirectory") { $ldap = new Ldap(); $result = $ldap->connectBind(); - ($result > 0) ? ($userSID = $ldap->getObjectSid($object->login)) : $userSID = ''; + $userSID = ''; + if ($result > 0) { + $userSID = $ldap->getObjectSid($object->login); + } print ''.$langs->trans("SID").''; print ''.$userSID.''; print "\n"; From 769fafbdea5890d29e53ed34f63942fac61198c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Wed, 13 Mar 2024 18:24:59 +0100 Subject: [PATCH 189/714] fix warnings --- .../conferenceorboothattendee_note.php | 54 ++----------------- 1 file changed, 4 insertions(+), 50 deletions(-) diff --git a/htdocs/eventorganization/conferenceorboothattendee_note.php b/htdocs/eventorganization/conferenceorboothattendee_note.php index 99768a9b738..66caf29a247 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_note.php +++ b/htdocs/eventorganization/conferenceorboothattendee_note.php @@ -1,6 +1,7 @@ * Copyright (C) ---Put here your own copyright and developer email--- + * 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 @@ -22,59 +23,12 @@ * \brief Tab for notes on ConferenceOrBoothAttendee */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; - $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; -dol_include_once('/eventorganization/class/conferenceorboothattendee.class.php'); -dol_include_once('/eventorganization/lib/eventorganization_conferenceorboothattendee.lib.php'); +require_once DOL_DOCUMENT_ROOT . '/eventorganization/class/conferenceorboothattendee.class.php'; +require_once DOL_DOCUMENT_ROOT . '/eventorganization/lib/eventorganization_conferenceorboothattendee.lib.php'; // Load translation files required by the page $langs->loadLangs(array('eventorganization', 'companies')); From 3cc9467ee4a00f6bfb8604e84ca210309bec651a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Mar 2024 18:39:51 +0100 Subject: [PATCH 190/714] Clean code --- htdocs/core/class/CMailFile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index c3cfdf85fca..91e7d127486 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -198,7 +198,7 @@ class CMailFile } } if (empty($this->sendmode)) { - $this->sendmode = (getDolGlobalString('MAIN_MAIL_SENDMODE') ? $conf->global->MAIN_MAIL_SENDMODE : 'mail'); + $this->sendmode = getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'); } // Add a Feedback-ID. Must be used for stats on spam report only. From ec7ff74f2561cd685cf9fd75751c6fae0e67d25b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Wed, 13 Mar 2024 18:45:02 +0100 Subject: [PATCH 191/714] clean code --- htdocs/ai/admin/custom_prompt.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/htdocs/ai/admin/custom_prompt.php b/htdocs/ai/admin/custom_prompt.php index 699479bbb9e..c791479eca8 100644 --- a/htdocs/ai/admin/custom_prompt.php +++ b/htdocs/ai/admin/custom_prompt.php @@ -1,6 +1,7 @@ * Copyright (C) 2022 Alice Adminson + * 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 @@ -137,7 +138,7 @@ if ($action == 'updatePrompts') { $newConfigurationsJson = json_encode($currentConfigurations, JSON_UNESCAPED_UNICODE); $result = dolibarr_set_const($db, 'AI_CONFIGURATIONS_PROMPT', $newConfigurationsJson, 'chaine', 0, '', $conf->entity); if (!$error) { - $action = 'dodo'; + $action = ''; if ($result) { header("Location: ".$_SERVER['PHP_SELF']); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -165,9 +166,6 @@ if ($action == 'confirm_deleteproperty' && GETPOST('confirm') == 'yes') { } } } -if ($action == 'confirm_deleteproperty') { - var_dump(GETPOST('confirm'));exit; -} /* @@ -344,7 +342,7 @@ if ($action == 'edit' || $action == 'create') { $('#postPromptInput').val(''); } }); - + $('.showInputBtn').click(function() { event.preventDefault(); var index = $(this).data('index'); @@ -357,7 +355,7 @@ if ($action == 'edit' || $action == 'create') { $(this).html($(this).data('icon-cancel')); $(this).data('state', 'cancel'); - } else { + } else { $('#prePromptInput_'+index).attr('disabled', 'disabled'); $('#postPromptInput_'+index).attr('disabled', 'disabled'); @@ -367,8 +365,8 @@ if ($action == 'edit' || $action == 'create') { } }); }); - - + + "; print $out; From 45a68ba612d3d4bf8b442605a784428690e72c1e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Mar 2024 20:17:26 +0100 Subject: [PATCH 192/714] Better error management --- htdocs/core/lib/files.lib.php | 14 +++++----- htdocs/core/lib/modulebuilder.lib.php | 27 +++++++++++++++---- htdocs/langs/en_US/errors.lang | 2 +- htdocs/modulebuilder/index.php | 21 ++++++++------- .../core/modules/modMyModule.class.php | 10 +++++-- 5 files changed, 49 insertions(+), 25 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index d19e28faa01..960d9ee7eec 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -644,19 +644,17 @@ function dol_fileperm($pathoffile) /** * Make replacement of strings into a file. * - * @param string $srcfile Source file (can't be a directory) + * @param string $srcfile Source file (can't be a directory) * @param array $arrayreplacement Array with strings to replace. Example: array('valuebefore'=>'valueafter', ...) - * @param string $destfile Destination file (can't be a directory). If empty, will be same than source file. - * @param string $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666' - * @param int $indexdatabase 1=index new file into database. - * @param int $arrayreplacementisregex 1=Array of replacement is already an array with key that is a regex. Warning: the key must be escaped with preg_quote for '/' - * @return int Return integer <0 if error, 0 if nothing done (dest file already exists), >0 if OK + * @param string $destfile Destination file (can't be a directory). If empty, will be same than source file. + * @param string $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666' + * @param int $indexdatabase 1=index new file into database. + * @param int $arrayreplacementisregex 1=Array of replacement is already an array with key that is a regex. Warning: the key must be escaped with preg_quote for '/' + * @return int Return integer <0 if error, 0 if nothing done (dest file already exists), >0 if OK * @see dol_copy() */ function dolReplaceInFile($srcfile, $arrayreplacement, $destfile = '', $newmask = '0', $indexdatabase = 0, $arrayreplacementisregex = 0) { - global $conf; - dol_syslog("files.lib.php::dolReplaceInFile srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." indexdatabase=".$indexdatabase." arrayreplacementisregex=".$arrayreplacementisregex); if (empty($srcfile)) { diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 19d9c9319a2..68e8b982cce 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -456,20 +456,37 @@ function dolGetListOfObjectClasses($destdir) return -1; } + /** - * function for check if comment begin an end exist in modMyModule class - * @param string $file filename or path - * @param int $number 0 = For Menus,1 = For permissions, 2 = For Dictionaries - * @return int 1 if OK , -1 if KO + * Function to check if comment begin an end exist in modMyModule class + * + * @param string $file Filename or path + * @param int $number 0 = For Menus,1 = For permissions, 2 = For Dictionaries + * @return int 1 if OK , -1 if KO */ function checkExistComment($file, $number) { if (!file_exists($file)) { return -1; } + $content = file_get_contents($file); if ($number === 0) { - if (strpos($content, '/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT */') !== false && strpos($content, '/* END MODULEBUILDER LEFTMENU MYOBJECT */') !== false) { + $ret = 0; + if (strpos($content, '/* BEGIN MODULEBUILDER TOPMENU MYOBJECT */') !== false) { + $ret++; + } + if (strpos($content, '/* END MODULEBUILDER TOPMENU MYOBJECT */') !== false) { + $ret++; + } + if (strpos($content, '/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT */') !== false) { + $ret++; + } + if (strpos($content, '/* END MODULEBUILDER LEFTMENU MYOBJECT */') !== false) { + $ret++; + } + + if ($ret == 4) { return 1; } } elseif ($number === 1) { diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 3290d9a2251..fe7cb304610 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -374,7 +374,7 @@ WarningModuleNeedRefresh = Module %s has been disabled. Don't forget to e WarningPermissionAlreadyExist=Existing permissions for this object WarningGoOnAccountancySetupToAddAccounts=If this list is empty, go into menu %s - %s - %s to load or create accounts for your chart of account. WarningCorrectedInvoiceNotFound=Corrected invoice not found -WarningCommentNotFound=Please check placement of start and end comments for %s section in file %s before submitting your action +WarningCommentNotFound=Warning: Can't find the start and/or end comments for the section %s into the file %s WarningAlreadyReverse=Stock movement already reversed SwissQrOnlyVIR = SwissQR invoice can only be added on invoices set to be paid with credit transfer payments. diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 6d1a5a85d06..1e78c341f06 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1017,6 +1017,8 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) { // Init an object if ($dirins && $action == 'initobject' && $module && $objectname) { + $warning = 0; + $objectname = ucfirst($objectname); $dirins = $dirread = $listofmodules[strtolower($module)]['moduledescriptorrootpath']; @@ -1365,13 +1367,12 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { } } - if (!$error) { foreach ($filetogenerate as $srcfile => $destfile) { $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile, $newmask, 0); if ($result <= 0) { if ($result < 0) { - $error++; + $warning++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFailToCopyFile", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'errors'); } else { @@ -1383,6 +1384,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { '/myobject\.class\.php/' => strtolower($objectname).'.class.php', '/myobject\.lib\.php/' => strtolower($objectname).'.lib.php', ); + dolReplaceInFile($destdir.'/'.$destfile, $arrayreplacement, '', 0, 0, 1); } } @@ -1529,8 +1531,8 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { if (!$counter) { $checkComment = checkExistComment($moduledescriptorfile, 0); if ($checkComment < 0) { - $error++; - setEventMessages($langs->trans("WarningCommentNotFound", $langs->trans("Menus"), "mod".$module."class.php"), null, 'warnings'); + $warning++; + setEventMessages($langs->trans("WarningCommentNotFound", $langs->trans("Menus"), basename($moduledescriptorfile)), null, 'warnings'); } else { $arrayofreplacement = array('/* END MODULEBUILDER LEFTMENU MYOBJECT */' => '/*LEFTMENU '.strtoupper($objectname).'*/'.$stringtoadd."\n\t\t".'/*END LEFTMENU '.strtoupper($objectname).'*/'."\n\t\t".'/* END MODULEBUILDER LEFTMENU MYOBJECT */'); dolReplaceInFile($moduledescriptorfile, $arrayofreplacement); @@ -1580,7 +1582,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { if (is_numeric($object) && $object <= 0) { $pathoffiletoeditsrc = $destdir.'/class/'.strtolower($objectname).'.class.php'; setEventMessages($langs->trans('ErrorFailToCreateFile', $pathoffiletoeditsrc), null, 'errors'); - $error++; + $warning++; } // check if documentation was generate and add table of properties object $file = $destdir.'/class/'.strtolower($objectname).'.class.php'; @@ -1610,7 +1612,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { // check if module is enabled if (isModEnabled(strtolower($module))) { $result = unActivateModule(strtolower($module)); - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity); if ($result) { setEventMessages($result, null, 'errors'); } @@ -1898,11 +1900,12 @@ if ($dirins && $action == 'confirm_deletemodule') { } else { $error++; $langs->load("errors"); - dol_print_error($db, $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); - exit; + setEventMessages($langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module), null, 'warnings'); } - $moduleobj->remove(); + if ($moduleobj) { + $moduleobj->remove(); + } $result = dol_delete_dir_recursive($dir); diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 0b166dd54b1..53c7957cf78 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -28,6 +28,7 @@ */ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; + /** * Description and activation class for module MyModule */ @@ -303,8 +304,10 @@ class modMyModule extends DolibarrModules // Main menu entries to add $this->menu = array(); $r = 0; + // Add here entries to declare new menus - /* BEGIN MODULEBUILDER TOPMENU */ + + /* BEGIN MODULEBUILDER TOPMENU MYOBJECT */ $this->menu[$r++] = array( 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'top', // This is a Top menu entry @@ -320,7 +323,8 @@ class modMyModule extends DolibarrModules 'target'=>'', 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both ); - /* END MODULEBUILDER TOPMENU */ + /* END MODULEBUILDER TOPMENU MYOBJECT */ + /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT */ /*$this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode @@ -366,6 +370,8 @@ class modMyModule extends DolibarrModules 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both );*/ /* END MODULEBUILDER LEFTMENU MYOBJECT */ + + // Exports profiles provided by this module $r = 1; /* BEGIN MODULEBUILDER EXPORT MYOBJECT */ From 345edd56fb7de26ad1e90f5a2c1c2f7651e7550e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Wed, 13 Mar 2024 21:07:56 +0100 Subject: [PATCH 193/714] clean code --- htdocs/hrm/class/evaluation.class.php | 39 ++---------------- htdocs/hrm/class/evaluationdet.class.php | 44 ++------------------- htdocs/hrm/class/job.class.php | 40 ++----------------- htdocs/hrm/class/position.class.php | 38 +----------------- htdocs/hrm/class/skill.class.php | 41 ++----------------- htdocs/hrm/class/skilldet.class.php | 35 +---------------- htdocs/hrm/class/skillrank.class.php | 50 +----------------------- 7 files changed, 18 insertions(+), 269 deletions(-) diff --git a/htdocs/hrm/class/evaluation.class.php b/htdocs/hrm/class/evaluation.class.php index 06eb51043b1..d44468aaf8f 100644 --- a/htdocs/hrm/class/evaluation.class.php +++ b/htdocs/hrm/class/evaluation.class.php @@ -30,8 +30,7 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT . '/hrm/class/evaluationdet.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + /** * Class for Evaluation @@ -322,8 +321,7 @@ class Evaluation extends CommonObject $result = $object->createCommon($user); if ($result < 0) { $error++; - $this->error = $object->error; - $this->errors = $object->errors; + $this->setErrorsFromObject($object); } if (!$error) { @@ -920,8 +918,7 @@ class Evaluation extends CommonObject $result = $objectline->fetchAll('ASC', '', 0, 0, '(fk_evaluation:=:'.((int) $this->id).')'); if (is_numeric($result)) { - $this->error = $objectline->error; - $this->errors = $objectline->errors; + $this->setErrorsFromObject($objectline); return $result; } else { $this->lines = $result; @@ -1022,36 +1019,6 @@ class Evaluation extends CommonObject return $result; } - /** - * 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; - } - /** * Return clicable link of object (with eventually picto) * diff --git a/htdocs/hrm/class/evaluationdet.class.php b/htdocs/hrm/class/evaluationdet.class.php index f0f2612d0c1..5635afc434f 100644 --- a/htdocs/hrm/class/evaluationdet.class.php +++ b/htdocs/hrm/class/evaluationdet.class.php @@ -28,10 +28,9 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/commonobjectline.class.php'; require_once DOL_DOCUMENT_ROOT . '/hrm/class/skillrank.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + /** * Class for EvaluationLine @@ -288,8 +287,7 @@ class EvaluationLine extends CommonObjectLine $result = $object->createCommon($user); if ($result < 0) { $error++; - $this->error = $object->error; - $this->errors = $object->errors; + $this->setErrorsFromObject($object); } if (!$error) { @@ -890,8 +888,7 @@ class EvaluationLine extends CommonObjectLine $result = $objectline->fetchAll('ASC', 'position', 0, 0, '(fk_evaluationdet:=:'.((int) $this->id).')'); if (is_numeric($result)) { - $this->error = $objectline->error; - $this->errors = $objectline->errors; + $this->setErrorsFromObject($objectline); return $result; } else { $this->lines = $result; @@ -992,37 +989,4 @@ class EvaluationLine extends CommonObjectLine return $result; } - - /** - * 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; - } } - - -require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; diff --git a/htdocs/hrm/class/job.class.php b/htdocs/hrm/class/job.class.php index c0ec08939d4..19c22de1b02 100644 --- a/htdocs/hrm/class/job.class.php +++ b/htdocs/hrm/class/job.class.php @@ -29,8 +29,7 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + /** * Class for Job @@ -292,8 +291,7 @@ class Job extends CommonObject $result = $object->createCommon($user); if ($result < 0) { $error++; - $this->error = $object->error; - $this->errors = $object->errors; + $this->setErrorsFromObject($object); } if (!$error) { @@ -928,8 +926,7 @@ class Job extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, '(fk_job:=:'.((int) $this->id).')'); if (is_numeric($result)) { - $this->error = $objectline->error; - $this->errors = $objectline->errors; + $this->setErrorsFromObject($objectline); return $result; } else { $this->lines = $result; @@ -1031,36 +1028,6 @@ class Job extends CommonObject return $result; } - /** - * 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; - } - /** * Return clicable link of object (with eventually picto) * @@ -1097,6 +1064,7 @@ class Job extends CommonObject $return .= '
'; return $return; } + /** * function for get required skills associate to job object * @param int $id Id of object diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index f15e98131ca..68467a84c43 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -29,8 +29,6 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; /** * Class for Position @@ -301,8 +299,7 @@ class Position extends CommonObject $result = $object->createCommon($user); if ($result < 0) { $error++; - $this->error = $object->error; - $this->errors = $object->errors; + $this->setErrorsFromObject($object); } if (!$error) { @@ -970,8 +967,7 @@ class Position extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, '(fk_position:=:'.((int) $this->id).')'); if (is_numeric($result)) { - $this->error = $objectline->error; - $this->errors = $objectline->errors; + $this->setErrorsFromObject($objectline); return $result; } else { $this->lines = $result; @@ -1088,36 +1084,6 @@ class Position extends CommonObject return $result; } - /** - * 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; - } - /** * Return clicable link of object (with eventually picto) * diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index aefd68a0bea..bd2fea61de8 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -29,8 +29,6 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; /** * Class for Skill @@ -351,8 +349,7 @@ class Skill extends CommonObject $result = $object->createCommon($user); if ($result < 0) { $error++; - $this->error = $object->error; - $this->errors = $object->errors; + $this->setErrorsFromObject($object); } if (!$error) { @@ -414,8 +411,7 @@ class Skill extends CommonObject if (is_array($this->lines)) { return (count($this->lines) > 0) ? $this->lines : array(); } elseif ($this->lines < 0) { - $this->errors = array_merge($this->errors, $skilldet->errors); - $this->error = $skilldet->error; + $this->setErrorsFromObject($skilldet); return $this->lines; } return []; @@ -969,8 +965,7 @@ class Skill extends CommonObject $result = $objectline->fetchAll('ASC', 'rankorder', 0, 0, '(fk_skill:=:'.((int) $this->id).')'); if (is_numeric($result)) { - $this->error = $objectline->error; - $this->errors = $objectline->errors; + $this->setErrorsFromObject($objectline); return $result; } else { $this->lines = $result; @@ -1072,36 +1067,6 @@ class Skill extends CommonObject return $result; } - /** - * 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; - } - /** * @param int $code number of code label * @return int|string diff --git a/htdocs/hrm/class/skilldet.class.php b/htdocs/hrm/class/skilldet.class.php index 83ccae8c5ab..edfc3886843 100644 --- a/htdocs/hrm/class/skilldet.class.php +++ b/htdocs/hrm/class/skilldet.class.php @@ -29,8 +29,6 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; /** * Class for Skilldet @@ -283,8 +281,7 @@ class Skilldet extends CommonObjectLine $result = $object->createCommon($user); if ($result < 0) { $error++; - $this->error = $object->error; - $this->errors = $object->errors; + $this->setErrorsFromObject($object); } if (!$error) { @@ -959,34 +956,4 @@ class Skilldet extends CommonObjectLine return $result; } - - /** - * 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/hrm/class/skillrank.class.php b/htdocs/hrm/class/skillrank.class.php index 245a6d8ba6c..27400f33638 100644 --- a/htdocs/hrm/class/skillrank.class.php +++ b/htdocs/hrm/class/skillrank.class.php @@ -309,8 +309,7 @@ class SkillRank extends CommonObject $result = $object->createCommon($user); if ($result < 0) { $error++; - $this->error = $object->error; - $this->errors = $object->errors; + $this->setErrorsFromObject($object); } if (!$error) { @@ -1033,51 +1032,4 @@ class SkillRank extends CommonObject return $result; } - - /** - * 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; - } - - /** - * @param array $val - * @param string $key - * @param string $value - * @param string $moreparam - * @param string $keysuffix - * @param string $keyprefix - * @param string $morecss - * @return string - */ - // public function showOutputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '') - // { - // if ($key == "rank") { - // return displayRankInfos($this); - // } else return parent::showOutputField($val, $key, $value, $moreparam, $keysuffix, $keyprefix, $morecss); - // } } From 93d2cad7fec316ef245917b09ef028ff8dba0ec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Wed, 13 Mar 2024 21:33:51 +0100 Subject: [PATCH 194/714] fix warnings --- htdocs/user/messaging.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/htdocs/user/messaging.php b/htdocs/user/messaging.php index f28ee2aa0cc..319a00e9f5e 100644 --- a/htdocs/user/messaging.php +++ b/htdocs/user/messaging.php @@ -6,6 +6,7 @@ * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2015 Marcos García + * 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 @@ -50,6 +51,8 @@ if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$id = GETPOSTINT('userid') ? GETPOSTINT('userid') : GETPOSTINT('id'); +$ref = GETPOST('ref', 'alpha'); $search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); @@ -74,6 +77,9 @@ if (!$sortorder) { $object = new User($db); if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref, '', 1); + if ($result <= 0) { + accessforbidden('User not found'); + } $object->getrights(); } @@ -81,18 +87,17 @@ if ($id > 0 || !empty($ref)) { $hookmanager->initHooks(array('agendathirdparty', 'globalcard')); // Security check -$userid = GETPOSTINT('userid') ? GETPOSTINT('userid') : GETPOSTINT('id'); if ($user->id) { - $userId = $user->id; + $id = $user->id; } -$result = $object->fetch($userid); -if ($result <= 0) { - accessforbidden('User not found'); +// Security check +$socid = 0; +if ($user->socid > 0) { + $socid = $user->socid; } - -$result = restrictedArea($user, 'user', $userId, '&user'); - +$feature2 = (($socid && $user->hasRight('user', 'self', 'creer')) ? '' : 'user'); +$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); /* @@ -153,7 +158,7 @@ $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->tra dol_banner_tab($object, 'id', $linkback, $user->hasRight('user', 'user', 'lire') || $user->admin, 'rowid', 'ref', $morehtmlref); -$object->info($userid); +$object->info($id); print '
'; @@ -196,7 +201,7 @@ if (isModEnabled('agenda')) { if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allaactions', 'read'))) { print '
'; - $param = '&userid='.urlencode((string) ($userid)); + $param = '&userid='.urlencode((string) ($id)); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -208,7 +213,7 @@ if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || // Try to know count of actioncomm from cache require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; $cachekey = 'count_events_user_'.$object->id; - //$nbEvent = dol_getcache($cachekey); // TODO Add nb into badge in menu so we can get it from cache also here + $nbEvent = dol_getcache($cachekey); // TODO Add nb into badge in menu so we can get it from cache also here $titlelist = $langs->trans("ActionsOnCompany").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); if (!empty($conf->dol_optimize_smallscreen)) { From a0b26ae7cd293306e8908ff166e41bfc2cbe07e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Mar 2024 21:41:55 +0100 Subject: [PATCH 195/714] FIX Amount of localtaxes in foreign currency was wrong on screen and PDF --- htdocs/comm/propal/card.php | 8 ++++++-- htdocs/comm/propal/class/propal.class.php | 2 ++ htdocs/commande/card.php | 8 ++++++-- htdocs/commande/class/commande.class.php | 2 ++ htdocs/compta/facture/card.php | 8 ++++++-- htdocs/compta/facture/class/facture.class.php | 2 ++ .../commande/doc/pdf_einstein.modules.php | 17 +++++++++++++---- .../commande/doc/pdf_eratosthene.modules.php | 17 +++++++++++++---- .../modules/facture/doc/pdf_crabe.modules.php | 19 +++++++++++++------ .../facture/doc/pdf_sponge.modules.php | 19 +++++++++++++------ .../modules/propale/doc/pdf_azur.modules.php | 19 +++++++++++++------ .../modules/propale/doc/pdf_cyan.modules.php | 19 +++++++++++++------ 12 files changed, 102 insertions(+), 38 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 3e201e1f683..97ed893601d 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2857,7 +2857,9 @@ if ($action == 'create') { print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ''; print '' . price($object->total_localtax1, '', $langs, 0, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + $object->multicurrency_total_localtax1 = price2num($object->total_localtax1 * $object->multicurrency_tx, 'MT'); + + print '' . price($object->multicurrency_total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; } print ''; @@ -2866,7 +2868,9 @@ if ($action == 'create') { print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; print '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + $object->multicurrency_total_localtax2 = price2num($object->total_localtax2 * $object->multicurrency_tx, 'MT'); + + print '' . price($object->multicurrency_total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; } print ''; } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index ec2fa41b991..48efe44c41c 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -272,6 +272,8 @@ class Propal extends CommonObject public $multicurrency_total_ht; public $multicurrency_total_tva; public $multicurrency_total_ttc; + public $multicurrency_total_localtax1; // not in database + public $multicurrency_total_localtax2; // not in database /** diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 71aefc2e708..bf55cdd65e2 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2770,7 +2770,9 @@ if ($action == 'create' && $usercancreate) { print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ''; print '' . price($object->total_localtax1, '', $langs, 0, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + $object->multicurrency_total_localtax1 = price2num($object->total_localtax1 * $object->multicurrency_tx, 'MT'); + + print '' . price($object->multicurrency_total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; } print ''; @@ -2780,7 +2782,9 @@ if ($action == 'create' && $usercancreate) { print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; print '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + $object->multicurrency_total_localtax2 = price2num($object->total_localtax2 * $object->multicurrency_tx, 'MT'); + + print '' . price($object->multicurrency_total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; } print ''; } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 6b6037d62d5..3ab9910376c 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -275,6 +275,8 @@ class Commande extends CommonOrder public $multicurrency_total_ht; public $multicurrency_total_tva; public $multicurrency_total_ttc; + public $multicurrency_total_localtax1; // not in database + public $multicurrency_total_localtax2; // not in database //! key of module source when order generated from a dedicated module ('cashdesk', 'takepos', ...) public $module_source; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 43b1087d89c..4310d340844 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4904,7 +4904,9 @@ if ($action == 'create') { print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ''; print '' . price($sign * $object->total_localtax1, '', $langs, 0, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($sign * $object->total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + $object->multicurrency_total_localtax1 = price2num($object->total_localtax1 * $object->multicurrency_tx, 'MT'); + + print '' . price($sign * $object->multicurrency_total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; } print ''; @@ -4913,7 +4915,9 @@ if ($action == 'create') { print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; print '' . price($sign * $object->total_localtax2, '', $langs, 0, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($sign * $object->total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + $object->multicurrency_total_localtax2 = price2num($object->total_localtax2 * $object->multicurrency_tx, 'MT'); + + print '' . price($sign * $object->multicurrency_total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; } print ''; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index cf84bbd1b44..405d14e39ed 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -262,6 +262,8 @@ class Facture extends CommonInvoice public $multicurrency_total_ht; public $multicurrency_total_tva; public $multicurrency_total_ttc; + public $multicurrency_total_localtax1; // not in database + public $multicurrency_total_localtax2; // not in database /** * @var int Situation cycle reference number diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 3f1a62c1b2b..b9d4661b679 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -988,8 +988,10 @@ class pdf_einstein extends ModelePDFCommandes $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1018,8 +1020,10 @@ class pdf_einstein extends ModelePDFCommandes $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1079,8 +1083,11 @@ class pdf_einstein extends ModelePDFCommandes $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1112,8 +1119,10 @@ class pdf_einstein extends ModelePDFCommandes $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index f6f9cf79bfa..449d29f62a8 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -1194,8 +1194,10 @@ class pdf_eratosthene extends ModelePDFCommandes $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1224,8 +1226,10 @@ class pdf_eratosthene extends ModelePDFCommandes $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1285,8 +1289,11 @@ class pdf_eratosthene extends ModelePDFCommandes $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1318,8 +1325,10 @@ class pdf_eratosthene extends ModelePDFCommandes $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index a0b26a8b17c..9a8e48e6f83 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1426,8 +1426,6 @@ class pdf_crabe extends ModelePDFFactures if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) { // Nothing to do } else { - // FIXME amount of vat not supported with multicurrency - //Local tax 1 before VAT //if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ @@ -1454,8 +1452,10 @@ class pdf_crabe extends ModelePDFFactures $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1485,8 +1485,10 @@ class pdf_crabe extends ModelePDFFactures $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1546,8 +1548,11 @@ class pdf_crabe extends ModelePDFFactures $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1576,8 +1581,10 @@ class pdf_crabe extends ModelePDFFactures $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } //} diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 57596f3edca..1b583bab5f4 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1689,8 +1689,6 @@ class pdf_sponge extends ModelePDFFactures if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) { // Nothing to do } else { - // FIXME amount of vat not supported with multicurrency - //Local tax 1 before VAT //if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ @@ -1717,8 +1715,10 @@ class pdf_sponge extends ModelePDFFactures $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1748,8 +1748,10 @@ class pdf_sponge extends ModelePDFFactures $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1833,8 +1835,11 @@ class pdf_sponge extends ModelePDFFactures $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1866,8 +1871,10 @@ class pdf_sponge extends ModelePDFFactures $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 85576e467ec..50a5af68ad4 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1168,8 +1168,10 @@ class pdf_azur extends ModelePDFPropales $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1186,8 +1188,6 @@ class pdf_azur extends ModelePDFPropales if ($tvakey != 0) { // On affiche pas taux 0 //$this->atleastoneratenotnull++; - - $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); @@ -1200,8 +1200,10 @@ class pdf_azur extends ModelePDFPropales $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1260,8 +1262,11 @@ class pdf_azur extends ModelePDFPropales $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1292,8 +1297,10 @@ class pdf_azur extends ModelePDFPropales $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 153a0460d84..67e49fca891 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1289,8 +1289,10 @@ class pdf_cyan extends ModelePDFPropales $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1307,8 +1309,6 @@ class pdf_cyan extends ModelePDFPropales if ($tvakey != 0) { // On affiche pas taux 0 //$this->atleastoneratenotnull++; - - $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); @@ -1322,8 +1322,10 @@ class pdf_cyan extends ModelePDFPropales $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1377,8 +1379,11 @@ class pdf_cyan extends ModelePDFPropales $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1410,8 +1415,10 @@ class pdf_cyan extends ModelePDFPropales $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } From 9c876b28419c1c2cfcb398693022ed799caf9ab6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Mar 2024 22:22:32 +0100 Subject: [PATCH 196/714] Fix phpunit --- htdocs/ai/admin/custom_prompt.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/htdocs/ai/admin/custom_prompt.php b/htdocs/ai/admin/custom_prompt.php index 699479bbb9e..7790c822249 100644 --- a/htdocs/ai/admin/custom_prompt.php +++ b/htdocs/ai/admin/custom_prompt.php @@ -165,9 +165,6 @@ if ($action == 'confirm_deleteproperty' && GETPOST('confirm') == 'yes') { } } } -if ($action == 'confirm_deleteproperty') { - var_dump(GETPOST('confirm'));exit; -} /* @@ -344,7 +341,7 @@ if ($action == 'edit' || $action == 'create') { $('#postPromptInput').val(''); } }); - + $('.showInputBtn').click(function() { event.preventDefault(); var index = $(this).data('index'); @@ -357,7 +354,7 @@ if ($action == 'edit' || $action == 'create') { $(this).html($(this).data('icon-cancel')); $(this).data('state', 'cancel'); - } else { + } else { $('#prePromptInput_'+index).attr('disabled', 'disabled'); $('#postPromptInput_'+index).attr('disabled', 'disabled'); @@ -367,8 +364,8 @@ if ($action == 'edit' || $action == 'create') { } }); }); - - + + "; print $out; From ee214ae7fd8500afe493720afb4845aa8858b71d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Mar 2024 22:39:41 +0100 Subject: [PATCH 197/714] Test to avoid not found method --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2f794579b7b..bcc2e9864e9 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8322,7 +8322,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, '__USER_SIGNATURE__' => (string) (($usersignature && !getDolGlobalString('MAIN_MAIL_DO_NOT_USE_SIGN')) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($usersignature), 30) : $usersignature) : '') )); - if (is_object($user)) { + if (is_object($user) && ($user instanceof User)) { $substitutionarray = array_merge($substitutionarray, array( '__USER_ID__' => (string) $user->id, '__USER_LOGIN__' => (string) $user->login, From a50bab344e34abb188280bd89ff546d9ca702852 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 14 Mar 2024 00:26:45 +0100 Subject: [PATCH 198/714] Fix problem in phpStan --- htdocs/ai/admin/custom_prompt.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/ai/admin/custom_prompt.php b/htdocs/ai/admin/custom_prompt.php index ee62b646604..abdf755ffd5 100644 --- a/htdocs/ai/admin/custom_prompt.php +++ b/htdocs/ai/admin/custom_prompt.php @@ -129,7 +129,6 @@ if ($action == 'update' && !GETPOST('cancel')) { if ($action == 'confirm_deleteproperty') { $key = GETPOST('key', 'alpha'); - //var_dump($currentConfigurations[$key]);exit; if (isset($currentConfigurations[$key])) { unset($currentConfigurations[$key]); From a504207ed1ce43e90f4ceb1409871d8ccbfa7875 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 14 Mar 2024 01:28:30 +0100 Subject: [PATCH 199/714] New msg for prompt ai before display result --- htdocs/core/class/html.formmail.class.php | 6 ++++++ htdocs/langs/en_US/help.lang | 1 + htdocs/theme/eldy/global.inc.php | 3 +++ 3 files changed, 10 insertions(+) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index be4e7a242e2..00e2cd60f04 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1454,6 +1454,7 @@ class FormMail extends Form $out .= ''; $out .= ''; $out .= ''; + $out .= '
'.$langs->trans("AIProcessingPleaseWait").'
'; $out .= "\n"; $out .= " From da543ac96d472dfe18ea239086856913a9c22211 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Thu, 14 Mar 2024 10:00:48 +0100 Subject: [PATCH 202/714] codespell and datee --- dev/tools/codespell/codespell-ignore.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/tools/codespell/codespell-ignore.txt b/dev/tools/codespell/codespell-ignore.txt index c71e990a467..0c84807010b 100644 --- a/dev/tools/codespell/codespell-ignore.txt +++ b/dev/tools/codespell/codespell-ignore.txt @@ -57,3 +57,4 @@ dur fonction espace methode +datee From 89d6fe8d5d9638794bbf5de21527e9f37b787c58 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Thu, 14 Mar 2024 10:02:23 +0100 Subject: [PATCH 203/714] add project list linked by a contact --- htdocs/core/lib/company.lib.php | 98 ++++++++++++++++++++++++++++++++ htdocs/langs/fr_FR/admin.lang | 2 + htdocs/langs/fr_FR/projects.lang | 1 + htdocs/projet/admin/project.php | 12 ++++ 4 files changed, 113 insertions(+) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index d8113ce1356..63f1e382fa7 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -960,6 +960,104 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel dol_print_error($db); } + //projects linked to that thirdpart because of a people of that company is linked to a project + if (getDolGlobalString('PROJECT_DISPLAY_LINKED_BY_CONTACT')) { + print "\n"; + print load_fiche_titre($langs->trans("ProjectsLinkedToThisThirdParty"), '', ''); + + + print '
'."\n"; + print ''; + + $sql = "SELECT p.rowid as id, p.entity, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount"; + $sql .= ", cls.code as opp_status_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact as ec on p.rowid = ec.element_id"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sc on ec.fk_socpeople = sc.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_contact as tc on ec.fk_c_type_contact = tc.rowid"; + $sql .= " WHERE sc.fk_soc = ".((int) $object->id); + $sql .= " AND p.entity IN (".getEntity('project').")"; + $sql .= " AND tc.element = 'project'"; + $sql .= " ORDER BY p.dateo DESC"; + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + if ($num > 0) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + + $projecttmp = new Project($db); + + $i = 0; + + while ($i < $num) { + $obj = $db->fetch_object($result); + $projecttmp->fetch($obj->id); + + // To verify role of users + $userAccess = $projecttmp->restrictedProjectArea($user); + + if ($user->rights->projet->lire && $userAccess > 0) { + print ''; + + // Ref + print ''; + + // Label + print ''; + // Date start + print ''; + // Date end + print ''; + // Opp amount + print ''; + // Opp status + print ''; + // Opp percent + print ''; + // Status + print ''; + + print ''; + } + $i++; + } + } else { + print ''; + } + $db->free($result); + } else { + dol_print_error($db); + } + } + $parameters = array('sql' => $sql, 'function' => 'show_projects'); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 2857c585ba4..3750b9bab8a 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -88,6 +88,8 @@ SearchString=Chaîne de recherche NotAvailableWhenAjaxDisabled=Non disponible quand Ajax est désactivé AllowToSelectProjectFromOtherCompany=Sur les éléments d'un tiers, autorise la sélection d'un projet lié à un autre tiers TimesheetPreventAfterFollowingMonths=Empêcher l'enregistrement du temps consacré après le nombre de mois suivant +PROJECT_DISPLAY_LINKED_BY_CONTACT=Afficher les projets liés par un contact +PROJECT_DISPLAY_LINKED_BY_CONTACT_help=Cette option permet d'ajouter la liste de tous les projets dans lesquels un des contact du tiers est rattaché JavascriptDisabled=Javascript désactivé UsePreviewTabs=Afficher les onglets "Aperçu" ShowPreview=Afficher aperçu diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang index 962372b874b..d5d1f2ce01c 100644 --- a/htdocs/langs/fr_FR/projects.lang +++ b/htdocs/langs/fr_FR/projects.lang @@ -142,6 +142,7 @@ DoNotShowMyTasksOnly=Voir aussi les tâches qui ne me sont pas affectées ShowMyTasksOnly=Ne voir que les tâches qui me sont affectées TaskRessourceLinks=Contacts de la tâche ProjectsDedicatedToThisThirdParty=Projets dédiés à ce tiers +ProjectsLinkedToThisThirdParty=Projets liés à ce tiers par un contact commun NoTasks=Aucune tâche pour ce projet LinkedToAnotherCompany=Liés à autre société TaskIsNotAssignedToUser=Tâche non assignée à l'utilisateur. Utilisez le bouton '%s' pour assigner la tâche maintenant. diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index 184f8ac6104..9dc673aa745 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -841,6 +841,18 @@ print ''; print ''; print ''; + +$key = 'PROJECT_DISPLAY_LINKED_BY_CONTACT'; +echo '', + '', + '', + ''; + + print '
'.$langs->trans("Ref").''.$langs->trans("Name").''.$langs->trans("DateStart").''.$langs->trans("DateEnd").''.$langs->trans("OpportunityAmountShort").''.$langs->trans("OpportunityStatusShort").''.$langs->trans("OpportunityProbabilityShort").''.$langs->trans("Status").'
'; + print $projecttmp->getNomUrl(1, '', 0, '', '-', 0, 1, '', 'project:'.$_SERVER["PHP_SELF"].'?socid=__SOCID__'); + print ''.dol_escape_htmltag($obj->title).''.dol_print_date($db->jdate($obj->do), "day").''.dol_print_date($db->jdate($obj->de), "day").''; + if ($obj->opp_status_code) { + print ''.price($obj->opp_amount, 1, '', 1, -1, -1, '').''; + } + print ''; + if ($obj->opp_status_code) { + print $langs->trans("OppStatus".$obj->opp_status_code); + } + print ''; + if ($obj->opp_percent) { + print price($obj->opp_percent, 1, '', 1, 0).'%'; + } + print ''.$projecttmp->getLibStatut(5).'
'.$langs->trans("None").'
', + $form->textwithpicto($langs->transnoentities($key), $langs->transnoentities($key . '_help')), + '', + ajax_constantonoff($key), + '
'; print '
'; From a4d85d870671ae610a51af9ad017d679f5c3784f Mon Sep 17 00:00:00 2001 From: jyhere Date: Thu, 14 Mar 2024 10:11:54 +0100 Subject: [PATCH 204/714] UPDATE: improved extrafields code autofill Add normalize() (to convert accented chars to unaccented chars) and replace whitespaces by underscores to make the db column name more readable. --- htdocs/core/tpl/admin_extrafields_add.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 19245020f26..7b8092ef81d 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -140,7 +140,7 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
Contact:con global->MAIN_EXTRAFIELDS_CODE_AUTOFILL_DISABLED)) : ?> jQuery("#label").keyup(function() { console.log("Update new field"); - $("#attrname").val( $(this).val().replace(/[^a-zA-Z0-9_]/g, '').toLowerCase() ); + $("#attrname").val( $(this).val().normalize('NFD').replace(/\s/g, "_").replace(/[^a-zA-Z0-9_]/g, '').toLowerCase() ); }); }); From 07fe0f6cd0a66dbcdfb8310fd1ab26d474400401 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2024 10:29:36 +0100 Subject: [PATCH 205/714] NEW: Module Website: Can link/unlink translation between web pages --- htdocs/website/index.php | 57 +++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 566a1c2feb9..37430439427 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1155,7 +1155,17 @@ if ($action == 'addcontainer' && $usercanedit) { $substitutionarray = array(); $substitutionarray['__WEBSITE_CREATE_BY__'] = $user->getFullName($langs); - // Define id of page the new page is translation of + // Define id of the page the new page is translation of + /* + if ($objectpage->lang == $object->lang) { + // If + $pageidfortranslation = (GETPOSTINT('pageidfortranslation') > 0 ? GETPOSTINT('pageidfortranslation') : 0); + if ($pageidfortranslation > 0) { + // We must update the page $pageidfortranslation to set fk_page = $object->id. + // But what if page $pageidfortranslation is already linked to another ? + } + } else { + */ $pageidfortranslation = (GETPOSTINT('pageidfortranslation') > 0 ? GETPOSTINT('pageidfortranslation') : 0); if ($pageidfortranslation > 0) { // Check if the page we are translation of is already a translation of a source page. if yes, we will use source id instead @@ -1166,6 +1176,7 @@ if ($action == 'addcontainer' && $usercanedit) { } } $objectpage->fk_page = $pageidfortranslation; + //} $sample = GETPOST('sample', 'alpha'); if (empty($sample)) { @@ -2406,6 +2417,22 @@ if ($usercanedit && (($action == 'updatesource' || $action == 'updatecontent' || } } +if ($action == 'deletelang' && $usercanedit) { + $sql = "UPDATE ".MAIN_DB_PREFIX."website_page SET fk_page = NULL"; + $sql .= " WHERE rowid = ".GETPOSTINT('deletelangforid'); + //$sql .= " AND fk_page = ".((int) $objectpage->id); + + $resql = $db->query($sql); + if (!$resql) { + setEventMessages($db->lasterror(), null, 'errors'); + } else { + $objectpage->fk_page = null; + } + + $action = 'editmeta'; +} + + // Export site if ($action == 'exportsite' && $user->hasRight('website', 'export')) { $fileofzip = $object->exportWebSite(); @@ -4360,7 +4387,9 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties if ($i > 0) { $tmpstring .= '
'; } - $tmpstring .= $tmppage->getNomUrl(1).' ('.$tmppage->lang.')'; + $tmpstring .= $tmppage->getNomUrl(1).' '.picto_from_langcode($tmppage->lang).' '.$tmppage->lang; + // Button unlink + $tmpstring .= ' id).'">'.img_picto($langs->trans("Remove"), 'unlink').''; $translatedby++; $i++; } @@ -4376,17 +4405,27 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties dol_print_error($db); } } - if (empty($translatedby) && ($action == 'editmeta' || $action == 'createcontainer' || $objectpage->fk_page > 0)) { + if ((empty($translatedby) || ($objectpage->lang != $object->lang)) && ($action == 'editmeta' || $action == 'createcontainer' || $objectpage->fk_page > 0)) { $sourcepage = new WebsitePage($db); - $result = $sourcepage->fetch($objectpage->fk_page); - if ($result == 0) { - // not found, we can reset value to clean database - } elseif ($result > 0) { + $result = 1; + if ($objectpage->fk_page > 0) { + $result = $sourcepage->fetch($objectpage->fk_page); + if ($result == 0) { + // not found, we can reset value to clean database + // TODO + } + } + if ($result >= 0) { + if ($translatedby) { + print '
'; + } $translationof = $objectpage->fk_page; print ''.$langs->trans('ThisPageIsTranslationOf').' '; - print $formwebsite->selectContainer($website, 'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action, 'minwidth300', array($objectpage->id)); + print $sourcepage->getNomUrl(2).' '.$formwebsite->selectContainer($website, 'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action, 'minwidth300', array($objectpage->id)); if ($translationof > 0 && $sourcepage->lang) { - print $sourcepage->getNomUrl(2).' ('.$sourcepage->lang.')'; + print picto_from_langcode($sourcepage->lang).' '.$sourcepage->lang; + // Button unlink + print ' id).'">'.img_picto($langs->trans("Remove"), 'unlink').''; } } } From 90210c3bfcc423858f22fef1b1fe8cce5ce750fd Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Thu, 14 Mar 2024 10:36:55 +0100 Subject: [PATCH 206/714] translation --- htdocs/langs/en_US/admin.lang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 576180c6371..f20f46f5c03 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -88,6 +88,8 @@ SearchString=Search string NotAvailableWhenAjaxDisabled=Not available when Ajax disabled AllowToSelectProjectFromOtherCompany=On document of a third party, can choose a project linked to another third party TimesheetPreventAfterFollowingMonths=Prevent recording time spent after the following number of months +PROJECT_DISPLAY_LINKED_BY_CONTACT=Display project linked by a common contact +PROJECT_DISPLAY_LINKED_BY_CONTACT_help=That option add a new list on Project tab with all projects linked to that thirdparty via a contact relationship JavascriptDisabled=JavaScript disabled UsePreviewTabs=Use preview tabs ShowPreview=Show preview From d4ea162cfb158992d4929441000b65ee798b6297 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Thu, 14 Mar 2024 10:37:46 +0100 Subject: [PATCH 207/714] locale --- htdocs/langs/en_US/projects.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index f0d303285d4..e522a34fd1e 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -142,6 +142,7 @@ DoNotShowMyTasksOnly=See also tasks not assigned to me ShowMyTasksOnly=View only tasks assigned to me TaskRessourceLinks=Contacts of task ProjectsDedicatedToThisThirdParty=Projects dedicated to this third party +ProjectsLinkedToThisThirdParty=Projects linked to that third party thanks to a contact NoTasks=No tasks for this project LinkedToAnotherCompany=Linked to other third party TaskIsNotAssignedToUser=Task not assigned to user. Use button '%s' to assign task now. From 4e872df2a646f8e18308e1c7fe3f486238eca0ed Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 14 Mar 2024 10:45:37 +0100 Subject: [PATCH 208/714] New change input to textarea for prompts in ai module --- htdocs/ai/admin/custom_prompt.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/ai/admin/custom_prompt.php b/htdocs/ai/admin/custom_prompt.php index 7790c822249..8974e25a66c 100644 --- a/htdocs/ai/admin/custom_prompt.php +++ b/htdocs/ai/admin/custom_prompt.php @@ -255,7 +255,7 @@ if ($action == 'edit') { $out .= 'pre-Prompt'; $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; $out .= ''; $out .= ''; $out .= ''; @@ -263,7 +263,7 @@ if ($action == 'edit') { $out .= 'Post-prompt'; $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; $out .= ''; $out .= ''; $out .= ''; @@ -307,7 +307,7 @@ if ($action == 'edit' || $action == 'create') { $out .= 'pre-Prompt'; $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; $out .= ''; $out .= ''; $out .= ''; @@ -315,8 +315,9 @@ if ($action == 'edit' || $action == 'create') { $out .= 'Post-prompt'; $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; $out .= '
'; + $out .= ''; $out .= ''; $out .= ''; From 5008a324c633ef650d9dac68c16e6eaac6fed370 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2024 11:24:09 +0100 Subject: [PATCH 209/714] Fix warning --- htdocs/accountancy/admin/accountmodel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index dbe02a3ff02..e14477b9158 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -191,10 +191,10 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { // Si verif ok et action add, on ajoute la ligne if ($ok && GETPOST('actionadd', 'alpha')) { + $newid = 0; if ($tabrowid[$id]) { // Get free id for insert - $newid = 0; - $sql = "SELECT MAX(".$db->sanitize($tabrowid[$id]).") newid FROM ".$db->sanitize($tabname[$id]); + $sql = "SELECT MAX(".$db->sanitize($tabrowid[$id]).") as newid FROM ".$db->sanitize($tabname[$id]); $result = $db->query($sql); if ($result) { $obj = $db->fetch_object($result); From fc753daa26352a838228982f5d01faf042eda0c1 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 14 Mar 2024 11:58:23 +0100 Subject: [PATCH 210/714] NEW functionality for delete contact of company list --- htdocs/core/lib/company.lib.php | 14 ++++++++++++++ htdocs/langs/en_US/users.lang | 2 ++ htdocs/societe/contact.php | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index d8113ce1356..62e6840351d 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1417,6 +1417,13 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl print ''; } + // Delete + if ($user->hasRight('societe', 'contact', 'delete')) { + print ''; + print img_delete(); + print ''; + } + print ''; } @@ -1513,6 +1520,13 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl print ''; } + // Delete + if ($user->hasRight('societe', 'contact', 'delete')) { + print ''; + print img_delete(); + print ''; + } + print ''; } diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index c4695d86791..3cfa2ee7236 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -134,3 +134,5 @@ UserPublicPageDesc=You can enable a virtual card for this user. An url with the EnablePublicVirtualCard=Enable the user's virtual business card UserEnabledDisabled=User status changed: %s AlternativeEmailForOAuth2=Alternative Email for OAuth2 login +ConfirmDeleteContact= Are you sure that you want delete this contact ? +ContactDeleted= Contact has been delete successfully diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php index 1fd810a9793..c56ca5ccfb4 100644 --- a/htdocs/societe/contact.php +++ b/htdocs/societe/contact.php @@ -133,6 +133,27 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; } +if ($action == 'confirm_delete') { + $id = GETPOST('id', 'int'); + if (!empty($id) && $socid > 0) { + $sql = "DELETE t, et FROM llx_socpeople AS t"; + $sql .= " LEFT JOIN llx_socpeople_extrafields AS et ON t.rowid = et.fk_object"; + $sql .= " WHERE t.fk_soc = ".((int) $socid); + $sql .= " AND t.rowid = ".((int) $id); + $sql .= " AND ((t.fk_user_creat = ".((int) $user->id)." AND t.priv = 1) OR t.priv = 0)"; + + $result = $db->query($sql); + if (!$result) { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + } else { + $db->commit(); + setEventMessages('ContactDeleted', null, 'mesgs'); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$socid); + exit(); + } + } +} /* * View @@ -184,6 +205,18 @@ if ($action != 'presend') { $result = show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1); } } +if ($action == 'delete') { + $formconfirm = $form->formconfirm( + $_SERVER["PHP_SELF"].'?id='.GETPOST('id').'&socid='.$object->id, + $langs->trans('Delete'), + $langs->trans('ConfirmDeleteContact', GETPOST('id', 'alpha')), + 'confirm_delete', + '', + 0, + 1 + ); + print $formconfirm; +} // End of page llxFooter(); From fb85f17ef4d9cb8a0bad6193ec4f5ad0d207dfa7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2024 12:09:35 +0100 Subject: [PATCH 211/714] FIX: Better error management in loading a website template --- htdocs/core/lib/files.lib.php | 23 +++++++++++++++-------- htdocs/core/lib/functions.lib.php | 2 +- htdocs/website/class/website.class.php | 19 ++++++++++++++----- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 960d9ee7eec..5b18aee94af 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -857,14 +857,14 @@ function dol_copy($srcfile, $destfile, $newmask = '0', $overwriteifexists = 1, $ /** * Copy a dir to another dir. This include recursive subdirectories. * - * @param string $srcfile Source file (a directory) - * @param string $destfile Destination file (a directory) - * @param string $newmask Mask for new file ('0' by default means getDolGlobalString('MAIN_UMASK')). Example: '0666' - * @param int $overwriteifexists Overwrite file if exists (1 by default) + * @param string $srcfile Source file (a directory) + * @param string $destfile Destination file (a directory) + * @param string $newmask Mask for new file ('0' by default means getDolGlobalString('MAIN_UMASK')). Example: '0666' + * @param int $overwriteifexists Overwrite file if exists (1 by default) * @param array $arrayreplacement Array to use to replace filenames with another one during the copy (works only on file names, not on directory names). - * @param int $excludesubdir 0=Do not exclude subdirectories, 1=Exclude subdirectories, 2=Exclude subdirectories if name is not a 2 chars (used for country codes subdirectories). - * @param string[] $excludefileext Exclude some file extensions - * @return int Return integer <0 if error, 0 if nothing done (all files already exists and overwriteifexists=0), >0 if OK + * @param int $excludesubdir 0=Do not exclude subdirectories, 1=Exclude subdirectories, 2=Exclude subdirectories if name is not a 2 chars (used for country codes subdirectories). + * @param string[] $excludefileext Exclude some file extensions + * @return int Return integer <0 if error, 0 if nothing done (all files already exists and overwriteifexists=0), >0 if OK * @see dol_copy() */ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayreplacement = null, $excludesubdir = 0, $excludefileext = null) @@ -878,6 +878,7 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep } $destexists = dol_is_dir($destfile); + //if (! $overwriteifexists && $destexists) return 0; // The overwriteifexists is for files only, so propagated to dol_copy only. if (!$destexists) { @@ -888,7 +889,13 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep $dirmaskdec = octdec(getDolGlobalString('MAIN_UMASK')); } $dirmaskdec |= octdec('0200'); // Set w bit required to be able to create content for recursive subdirs files - dol_mkdir($destfile, '', decoct($dirmaskdec)); + + $result = dol_mkdir($destfile, '', decoct($dirmaskdec)); + + if (!dol_is_dir($destfile)) { + // The output directory does not exists and we failed to create it. So we stop here. + return -1; + } } $ossrcfile = dol_osencode($srcfile); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bcc2e9864e9..e74be328a4b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7424,7 +7424,7 @@ function dol_mkdir($dir, $dataroot = '', $newmask = '') } $dirmaskdec |= octdec('0111'); // Set x bit required for directories if (!@mkdir($ccdir_osencoded, $dirmaskdec)) { - // Si le is_dir a renvoye une fausse info, alors on passe ici. + // If the is_dir has returned a false information, we arrive here dol_syslog("functions.lib::dol_mkdir: Fails to create directory '".$ccdir."' or directory already exists.", LOG_WARNING); $nberr++; } else { diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 47d572654be..7bfe8b0373e 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -1262,8 +1262,17 @@ class Website extends CommonObject $error++; } - dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/medias/image/websitekey', $conf->website->dir_output.'/'.$object->ref.'/medias/image/'.$object->ref, 0, 1); // Medias can be shared, do not overwrite if exists - dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/medias/js/websitekey', $conf->website->dir_output.'/'.$object->ref.'/medias/js/'.$object->ref, 0, 1); // Medias can be shared, do not overwrite if exists + $result = dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/medias/image/websitekey', $conf->website->dir_output.'/'.$object->ref.'/medias/image/'.$object->ref, 0, 1); + if ($result < 0) { + $this->errors[] = 'Failed to copy files into '.$conf->website->dir_output.'/'.$object->ref.'/medias/image/'.$object->ref.'.'; + return -5; + } + + $result = dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/medias/js/websitekey', $conf->website->dir_output.'/'.$object->ref.'/medias/js/'.$object->ref, 0, 1); + if ($result < 0) { + $this->errors[] = 'Failed to copy files into '.$conf->website->dir_output.'/'.$object->ref.'/medias/js/'.$object->ref.'.'; + return -5; + } $sqlfile = $conf->website->dir_temp."/".$object->ref.'/website_pages.sql'; @@ -1301,13 +1310,13 @@ class Website extends CommonObject $newid = ($reg[2] + $maxrowid); $aliasesarray = explode(',', $reg[3]); - dol_syslog("Found ID ".$oldid." to replace with ID ".$newid." and shortcut aliases to create: ".$reg[3]); + dol_syslog("In sql source file, we have the page ID ".$oldid." to replace with the new ID ".$newid.", and we must create the shortcut aliases: ".$reg[3]); - dol_move($conf->website->dir_output.'/'.$object->ref.'/page'.$oldid.'.tpl.php', $conf->website->dir_output.'/'.$object->ref.'/page'.$newid.'.tpl.php', 0, 1, 0, 0); + //dol_move($conf->website->dir_output.'/'.$object->ref.'/page'.$oldid.'.tpl.php', $conf->website->dir_output.'/'.$object->ref.'/page'.$newid.'.tpl.php', 0, 1, 0, 0); $objectpagestatic->fetch($newid); - // The move is not enough, so we regenerate pageX.tpl.php + // We regenerate the pageX.tpl.php $filetpl = $conf->website->dir_output.'/'.$object->ref.'/page'.$newid.'.tpl.php'; $result = dolSavePageContent($filetpl, $object, $objectpagestatic); if (!$result) { From 0903b4da87bde9285b5be6d8991ee989a44d8c13 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Thu, 14 Mar 2024 12:35:19 +0100 Subject: [PATCH 212/714] disable auto correct login field on smartphone --- htdocs/core/tpl/login.tpl.php | 2 +- htdocs/core/tpl/passwordforgotten.tpl.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 7f460587248..1567392285a 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -180,7 +180,7 @@ if ($disablenofollow) { } ?> -" name="username" class="flat input-icon-user minwidth150" value="" tabindex="1" autofocus="autofocus" /> +" name="username" class="flat input-icon-user minwidth150" value="" tabindex="1" autofocus="autofocus" autocapitalize="off" autocomplete="off" spellcheck="false" autocorrect="off" />
diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index 6fe5ddad2d6..4b6cd2392f2 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -129,7 +129,7 @@ if (!empty($disablenofollow)) {
-" id="username" name="username" class="flat input-icon-user minwidth150" value="" tabindex="1" /> +" id="username" name="username" class="flat input-icon-user minwidth150" value="" tabindex="1" autocapitalize="off" autocomplete="off" spellcheck="false" autocorrect="off" />
From 1c9129497ff25e1f06eb54a5d70b713838eec5b6 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Thu, 14 Mar 2024 12:36:01 +0100 Subject: [PATCH 213/714] autocomplete on --- htdocs/core/tpl/login.tpl.php | 2 +- htdocs/core/tpl/passwordforgotten.tpl.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 1567392285a..cbb89e80b3b 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -180,7 +180,7 @@ if ($disablenofollow) { } ?> -" name="username" class="flat input-icon-user minwidth150" value="" tabindex="1" autofocus="autofocus" autocapitalize="off" autocomplete="off" spellcheck="false" autocorrect="off" /> +" name="username" class="flat input-icon-user minwidth150" value="" tabindex="1" autofocus="autofocus" autocapitalize="off" autocomplete="on" spellcheck="false" autocorrect="off" /> diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index 4b6cd2392f2..8d78c4fa41a 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -129,7 +129,7 @@ if (!empty($disablenofollow)) {
-" id="username" name="username" class="flat input-icon-user minwidth150" value="" tabindex="1" autocapitalize="off" autocomplete="off" spellcheck="false" autocorrect="off" /> +" id="username" name="username" class="flat input-icon-user minwidth150" value="" tabindex="1" autocapitalize="off" autocomplete="on" spellcheck="false" autocorrect="off" />
From c664cdae0f62775af2dd58b8a4a9494b4728d4bc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2024 12:39:42 +0100 Subject: [PATCH 214/714] NEW Init of a module with a website template copy also the preview --- htdocs/core/modules/DolibarrModules.class.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 15fbe56aa32..04081ba6a02 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -453,7 +453,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $err += $this->insert_tabs(); } - // Insert activation of module's parts + // Insert activation of module's parts. Copy website templates into doctemplates. if (!$err) { $err += $this->insert_module_parts(); } @@ -2310,6 +2310,15 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $this->errors[] = ($errormsg ? $errormsg : $langs->trans('ErrorFailToCreateZip', $dest)); } } + + // Copy also the preview website_xxx.jpg file + $docs = dol_dir_list($srcroot, 'files', 0, 'website_.*\.jpg$'); + foreach ($docs as $cursorfile) { + $src = $srcroot.'/'.$cursorfile['name']; + $dest = DOL_DATA_ROOT.'/doctemplates/websites/'.$cursorfile['name']; + + dol_copy($src, $dest); + } } $entity = $conf->entity; // Reset the current entity From 5399e3aef5c0d6a43134ef1d8c54964a074a6574 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2024 12:59:35 +0100 Subject: [PATCH 215/714] Debug import website template --- htdocs/website/class/website.class.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 7bfe8b0373e..290f18606f9 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -1305,7 +1305,11 @@ class Website extends CommonObject // Warning fgets with second parameter that is null or 0 hang. $buf = fgets($fp, 65000); + $newid = 0; + + // Scan the line if (preg_match('/^-- Page ID (\d+)\s[^\s]+\s(\d+).*Aliases\s(.*)\s--;/i', $buf, $reg)) { + // Example of line: "-- Page ID 179 -> 1__+MAX_llx_website_page__ - Aliases about-us --;" $oldid = $reg[1]; $newid = ($reg[2] + $maxrowid); $aliasesarray = explode(',', $reg[3]); @@ -1313,7 +1317,15 @@ class Website extends CommonObject dol_syslog("In sql source file, we have the page ID ".$oldid." to replace with the new ID ".$newid.", and we must create the shortcut aliases: ".$reg[3]); //dol_move($conf->website->dir_output.'/'.$object->ref.'/page'.$oldid.'.tpl.php', $conf->website->dir_output.'/'.$object->ref.'/page'.$newid.'.tpl.php', 0, 1, 0, 0); + } elseif (preg_match('/^-- Page ID (\d+).*Aliases\s(.*)\s--;/i', $buf, $reg)) { + // Example of line: "-- Page ID 1__+MAX_llx_website_page__ - Aliases about-us --;" + $newid = ($reg[1] + $maxrowid); + $aliasesarray = explode(',', $reg[2]); + dol_syslog("In sql source file, we have the page with the new ID ".$newid.", and we must create the shortcut aliases: ".$reg[3]); + } + + if ($newid) { $objectpagestatic->fetch($newid); // We regenerate the pageX.tpl.php From b51be1117180fe5c146d1ebeb1144d3e6c69a9cd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2024 13:39:24 +0100 Subject: [PATCH 216/714] Clean code --- htdocs/website/class/website.class.php | 208 ++----------------------- 1 file changed, 12 insertions(+), 196 deletions(-) diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 290f18606f9..5f91c26ebd2 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -1244,7 +1244,8 @@ class Website extends CommonObject $arrayreplacement['__LOGO_MINI_KEY__'] = $this->db->escape($mysoc->logo_mini); $arrayreplacement['__LOGO_KEY__'] = $this->db->escape($mysoc->logo); - // Copy containers + + // Copy containers directory dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/containers', $conf->website->dir_output.'/'.$object->ref, 0, 1); // Overwrite if exists // Make replacement into css and htmlheader file @@ -1297,7 +1298,7 @@ class Website extends CommonObject $objectpagestatic = new WebsitePage($this->db); - // Make replacement of IDs + // Regenerate the php files for pages $fp = fopen($sqlfile, "r"); if ($fp) { while (!feof($fp)) { @@ -1367,7 +1368,7 @@ class Website extends CommonObject } } - // Regenerate index page to point to the new index page + // Regenerate the index.php page to point to the new index page $pathofwebsite = $conf->website->dir_output.'/'.$object->ref; dolSaveIndexPage($pathofwebsite, $pathofwebsite.'/index.php', $pathofwebsite.'/page'.$object->fk_default_home.'.tpl.php', $pathofwebsite.'/wrapper.php', $object); @@ -1705,173 +1706,20 @@ class Website extends CommonObject // Export on target sources $resultarray = dol_uncompress($pathtotmpzip, $destdir); + // Remove the file README and LICENSE from the $destdir (already into the containers directory) + dol_delete_file($destdir.'/README.md'); + dol_delete_file($destdir.'/LICENSE'); + + // Remove non required files (will be re-generated during the import) + dol_delete_file($destdir.'/containers/index.php'); + dol_delete_file($destdir.'/containers/master.inc.php'); + if (!empty($resultarray)) { setEventMessages("Error, failed to unzip the export into target dir", null, 'errors'); } else { setEventMessages("Website content written into ".$destdirrel, null, 'mesgs'); } - /* - $sourcedir = $conf->website->dir_output."/".$website->ref; - - // Get array with hash of files (for the last sync) - $fichierEtat = $sourcedir . '/filelist-'.dol_sanitizeFileName($destdir).'.txt'; - $etatPrecedent = $this->checkPreviousState($fichierEtat); - - // Get list of all source files of the website - $arraySourcedir = dol_dir_list($sourcedir); - - // Get list of modified files - $modifications = []; - foreach ($arraySourcedir as $file) { - if (substr($file['name'], -4) === '.old') { - continue; - } - $hashActuel = hash_file('md5', $file['fullname']); - - // Check whether the file is new or has been modified - if (!isset($etatPrecedent[$file['name']]) || $etatPrecedent[$file['name']] !== $hashActuel) { - $modifications[] = $file; - } - - $etatPrecedent[$file['name']] = $hashActuel; // we store he new hash to record it later on disk. - } - - $arraydestdir = dol_dir_list($destdir, "all", 1); - $differences = []; - $names = array_column($arraydestdir, 'name'); - $namesSource = array_column($arraySourcedir, 'name'); - - if (count($modifications) > 1) { - foreach ($modifications as $fichierModifie) { - $nomFichierModifie = $fichierModifie['name']; - if ($nomFichierModifie == basename($fichierEtat)) { - continue; - } - $success = 0; - - //check if it is a new file - if ((!preg_match('/^page\d+\.tpl\.php$/', $nomFichierModifie)) && (!in_array($nomFichierModifie, $names))) { - if (file_exists($fichierModifie['fullname']) && dol_is_dir($destdir.'/containers')) { - $cp = dol_copy($fichierModifie['fullname'], $destdir.'/containers/'.$nomFichierModifie, '0664'); - if ($cp > 0) { - if (file_exists($destdir.'/containers/'.$nomFichierModifie)) { - $tabnumpage = array(); - foreach ($arraydestdir as $fileDest) { - if ($this->extractNumberFromFilename($fileDest['name']) !== -1) { - $tabnumpage[] = $this->extractNumberFromFilename($fileDest['name']); - } - } - $getContentSource = file_get_contents($destdir.'/containers/'.$nomFichierModifie); - $nextpage = max($tabnumpage) + 1; - $chaineModifiee = preg_replace('/page\d+\.tpl\.php/', 'page' . $nextpage . '.tpl.php', $getContentSource); - $write = file_put_contents($destdir.'/containers/'.$nomFichierModifie, $chaineModifiee); - if ($write !== false) { - if (!touch($destdir.'/containers/'."page" . $nextpage . ".tpl.php")) { - setEventMessages("Please check permission to create page" . $nextpage . ".tpl.php in template ".$website->name_template."", null, 'errors'); - } - $filesFound = ''; - foreach ($arraySourcedir as $file) { - if ($file['name'] == $nomFichierModifie) { - $fileContent = file_get_contents($file['fullname']); - $matches = array(); - if (preg_match("/page\d+\.tpl\.php/", $fileContent, $matches)) { - $filesFound = $matches[0]; - break; - } - } - } - foreach ($arraySourcedir as $file) { - if ($file['name'] == $filesFound) { - if (!is_writable($file['fullname'])) { - dolChmod($file['fullname'], '0664'); - } - $diff = $this->showDifferences(file_get_contents($destdir.'/containers/'."page" . $nextpage . ".tpl.php"), file_get_contents($file['fullname']), array($nextpage,$this->extractNumberFromFilename($file['name']))); - if ($diff != -1) { - $replace = $this->replaceLineUsingNum($destdir.'/containers/'."page" . $nextpage . ".tpl.php", $diff); - if ($replace !== false) { - setEventMessages("Copy file page".$nextpage.".tpl.php in template ".$this->name_template." with success", null, 'warnings'); - } - } - } - } - } - } - - $this->saveState($etatPrecedent, $fichierEtat); - setEventMessages("file ".$nomFichierModifie." was created in template ".$website->name_template."", null, 'warnings'); - - header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website->ref); - exit(); - } - } else { - setEventMessages("Error, target dir containers not found", null, 'errors'); - $error = 1; - break; - } - } - - // Find the corresponding file in the destination folder - if (!$error && in_array($nomFichierModifie, $namesSource)) { - foreach ($arraydestdir as $destFile) { - if ($destFile['name'] == $nomFichierModifie) { - $sourceContent = file_get_contents($fichierModifie['fullname']); - $destContent = file_get_contents($destFile['fullname']); - - if ($sourceContent !== $destContent) { - $differences[$nomFichierModifie] = $this->showDifferences($destContent, $sourceContent); - if (count($differences[$nomFichierModifie]) > 0) { - $result = $this->replaceLineUsingNum($destFile['fullname'], $differences[$nomFichierModifie]); - if ($result >= 0) { - setEventMessages("file ".$nomFichierModifie." was modified in template ".$website->name_template."", null, 'warnings'); - } else { - if ($result == -2) { - setEventMessages("No permissions to write into file ".$destdirrel.'/'.$nomFichierModifie." from the current website ".$website->name_template."", null, 'errors'); - - header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website->ref); - exit(); - } - setEventMessages("file ".$nomFichierModifie." was not modified", null, 'errors'); - } - } - } - } - - if (preg_match('/page(\d+)\.tpl\.php/', $nomFichierModifie)) { - $differences[$nomFichierModifie] = $this->compareFichierModifie($sourcedir, $destdir, $fichierModifie); - if (count($differences[$nomFichierModifie]) > 0) { - $result = $this->replaceLineUsingNum($differences[$nomFichierModifie]['file_destination']['fullname'], $differences[$nomFichierModifie]); - if ($result !== false) { - if ($result == -2) { - setEventMessages("No permissions to write into file ".$destdirrel.'/'.$differences[$nomFichierModifie]['file_destination']['name']." from the current website ".$website->name_template."", null, 'errors'); - header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website->ref); - exit(); - } - $success++; - } - } - } - } - } - } - if ($success > 0) { - // Save the state file filelist.txt - $this->saveState($etatPrecedent, $fichierEtat); - setEventMessages("file ".$differences[$nomFichierModifie]['file_destination']['name']." was modified in template ".$website->name_template."", null, 'warnings'); - - header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website->ref); - exit(); - } - } else { - setEventMessages("No file has been modified", null, 'errors'); - } - - // save state file - if (!$error) { - $this->saveState($etatPrecedent, $fichierEtat); - } - */ - header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website->ref); exit(); } @@ -1939,38 +1787,6 @@ class Website extends CommonObject return file_put_contents($pathname, serialize($etat)); } - /** - * create file for save state of all files in folder - * - * @param string $sourcedir path of folder - * @return void - */ - /* - public function initFilesStatus($sourcedir) - { - $fichierEtat = $sourcedir . '/filelist-lastwrite-doctemplates.txt'; - - $etatPrecedent = $this->checkPreviousState($fichierEtat); - - // for first save state when create file - if (empty($etatPrecedent)) { - $arraySourcedir = dol_dir_list($sourcedir, "files"); - $etatFichiers = []; - - foreach ($arraySourcedir as $file) { - // Ignore .old files and the status file itself - if (substr($file['name'], -4) === '.old' || $file['name'] === basename($fichierEtat)) { - continue; - } - - $hashActuel = hash_file('md5', $file['fullname']); - $etatFichiers[$file['name']] = $hashActuel; - } - $this->saveState($etatFichiers, $fichierEtat); - } - } - */ - /** * Compare two files has not same name but same content * @param string $dossierSource filepath of folder source From 1134d9a7f06a4481a59361ec4577dc7403ca5603 Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 14 Mar 2024 13:39:43 +0100 Subject: [PATCH 217/714] Deleted userdoneid. Cleaned code. --- htdocs/comm/action/class/actioncomm.class.php | 25 ++----------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index dff69c1ab21..b8364ea8dbc 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -240,12 +240,6 @@ class ActionComm extends CommonObject */ public $userownerid; - /** - * @var int Id of user that has done the event. Used only if AGENDA_ENABLE_DONEBY is set. - * @deprecated Use $userownerid instead - */ - public $userdoneid; - /** * @var int[] Array of contact ids */ @@ -494,7 +488,6 @@ class ActionComm extends CommonObject } $userownerid = $this->userownerid; - $userdoneid = $this->userdoneid; // Be sure assigned user is defined as an array of array('id'=>,'mandatory'=>,...). if (empty($this->userassigned) || count($this->userassigned) == 0 || !is_array($this->userassigned)) { @@ -544,7 +537,6 @@ class ActionComm extends CommonObject $sql .= "fk_contact,"; $sql .= "fk_user_author,"; $sql .= "fk_user_action,"; - $sql .= "fk_user_done,"; $sql .= "label,percent,priority,fulldayevent,location,"; $sql .= "transparency,"; $sql .= "fk_element,"; @@ -583,7 +575,6 @@ class ActionComm extends CommonObject $sql .= ((isset($this->contact_id) && $this->contact_id > 0) ? ((int) $this->contact_id) : "null").", "; // deprecated, use ->socpeopleassigned $sql .= (isset($user->id) && $user->id > 0 ? $user->id : "null").", "; $sql .= ($userownerid > 0 ? $userownerid : "null").", "; - $sql .= ($userdoneid > 0 ? $userdoneid : "null").", "; $sql .= "'".$this->db->escape($this->label)."', "; $sql .= "'".$this->db->escape($this->percentage)."', "; $sql .= "'".$this->db->escape($this->priority)."', "; @@ -812,7 +803,7 @@ class ActionComm extends CommonObject $sql .= " a.fk_soc,"; $sql .= " a.fk_project,"; $sql .= " a.fk_user_author, a.fk_user_mod,"; - $sql .= " a.fk_user_action, a.fk_user_done,"; + $sql .= " a.fk_user_action,"; $sql .= " a.fk_contact, a.percent as percentage,"; $sql .= " a.fk_element as elementid, a.elementtype,"; $sql .= " a.priority, a.fulldayevent, a.location, a.transparency,"; @@ -1162,16 +1153,9 @@ class ActionComm extends CommonObject $this->fk_project = 0; } - // Check parameters - if ($this->percentage == 0 && $this->userdoneid > 0) { - $this->error = "ErrorCantSaveADoneUserWithZeroPercentage"; - return -1; - } - $socid = (($this->socid > 0) ? $this->socid : 0); $contactid = (($this->contact_id > 0) ? $this->contact_id : 0); $userownerid = ($this->userownerid ? $this->userownerid : 0); - $userdoneid = ($this->userdoneid ? $this->userdoneid : 0); // If a type_id is set, we must also have the type_code set if ($this->type_id > 0) { @@ -1209,7 +1193,6 @@ class ActionComm extends CommonObject $sql .= ", transparency = '".$this->db->escape($this->transparency)."'"; $sql .= ", fk_user_mod = ".((int) $user->id); $sql .= ", fk_user_action = ".($userownerid > 0 ? ((int) $userownerid) : "null"); - $sql .= ", fk_user_done = ".($userdoneid > 0 ? ((int) $userdoneid) : "null"); if (!empty($this->fk_element)) { $sql .= ", fk_element=".($this->fk_element ? ((int) $this->fk_element) : "null"); } @@ -1432,7 +1415,7 @@ class ActionComm extends CommonObject } $sql .= " AND a.entity IN (".getEntity('agenda').")"; if (!$user->hasRight('agenda', 'allactions', 'read')) { - $sql .= " AND (a.fk_user_author = ".((int) $user->id)." OR a.fk_user_action = ".((int) $user->id)." OR a.fk_user_done = ".((int) $user->id); + $sql .= " AND (a.fk_user_author = ".((int) $user->id)." OR a.fk_user_action = ".((int) $user->id); $sql .= " OR ar.fk_element = ".((int) $user->id); $sql .= ")"; } @@ -2004,7 +1987,6 @@ class ActionComm extends CommonObject $buildfile = true; $login = ''; $logina = ''; - $logind = ''; $logint = ''; $eventorganization = ''; @@ -2355,9 +2337,6 @@ class ActionComm extends CommonObject if ($logint) { $more = $langs->transnoentities("ActionsToDoBy").' '.$logint; } - if ($logind) { - $more = $langs->transnoentities("ActionsDoneBy").' '.$logind; - } if ($eventorganization) { $langs->load("eventorganization"); $title = $langs->transnoentities("OrganizedEvent").(empty($eventarray[0]['label']) ? '' : ' '.$eventarray[0]['label']); From 93a2ab24c8600133530f40c07c543cd08904e28d Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 14 Mar 2024 13:43:44 +0100 Subject: [PATCH 218/714] Deleted AGENDA_ENABLE_DONEBY option. Cleaned code. --- htdocs/comm/action/card.php | 47 ------------------------------------- 1 file changed, 47 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index f5d96eec190..1e27f3d54f8 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -426,12 +426,6 @@ if (empty($reshook) && $action == 'add') { } } - if (!$error && getDolGlobalString('AGENDA_ENABLE_DONEBY')) { - if (GETPOST("doneby") > 0) { - $object->userdoneid = GETPOSTINT("doneby"); - } - } - $object->note_private = trim(GETPOST("note", "restricthtml")); if (GETPOSTISSET("contactid")) { @@ -877,12 +871,6 @@ if (empty($reshook) && $action == 'update') { $object->transparency = $transparency; // We set transparency on event (even if we can also store it on each user, standard says this property is for event) // TODO store also transparency on owner user - if (getDolGlobalString('AGENDA_ENABLE_DONEBY')) { - if (GETPOST("doneby")) { - $object->userdoneid = GETPOSTINT("doneby"); - } - } - // Check parameters if (GETPOSTISSET('actioncode') && !GETPOST('actioncode', 'aZ09')) { // actioncode is '0' $error++; @@ -1230,16 +1218,6 @@ if ($action == 'create') { setdatefields(); }); - $("#selectcomplete").change(function() { - console.log("we change the complete status - set the doneby"); - if ($("#selectcomplete").val() == 100) { - if ($("#doneby").val() <= 0) $("#doneby").val(\''.((int) $user->id).'\'); - } - if ($("#selectcomplete").val() == 0) { - $("#doneby").val(-1); - } - }); - $("#actioncode").change(function() { if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired"); else $("#dateend").removeClass("fieldrequired"); @@ -1444,13 +1422,6 @@ if ($action == 'create') { print ''; print ''; - // Done by - if (getDolGlobalString('AGENDA_ENABLE_DONEBY')) { - print ''.$langs->trans("ActionDoneBy").''; - print $form->select_dolusers(GETPOSTISSET("doneby") ? GETPOSTINT("doneby") : (!empty($object->userdoneid) && $percent == 100 ? $object->userdoneid : 0), 'doneby', 1); - print ''; - } - // Location if (!getDolGlobalString('AGENDA_DISABLE_LOCATION')) { print ''.$langs->trans("Location").''; @@ -1995,13 +1966,6 @@ if ($id > 0) { }*/ print ''; - // Realised by - if (getDolGlobalString('AGENDA_ENABLE_DONEBY')) { - print ''.$langs->trans("ActionDoneBy").''; - print $form->select_dolusers($object->userdoneid > 0 ? $object->userdoneid : -1, 'doneby', 1); - print ''; - } - // Location if (!getDolGlobalString('AGENDA_DISABLE_LOCATION')) { print ''.$langs->trans("Location").''; @@ -2427,17 +2391,6 @@ if ($id > 0) { */ print ' '; - // Done by - if (getDolGlobalString('AGENDA_ENABLE_DONEBY')) { - print ''.$langs->trans("ActionDoneBy").''; - if ($object->userdoneid > 0) { - $tmpuser = new User($db); - $tmpuser->fetch($object->userdoneid); - print $tmpuser->getNomUrl(1); - } - print ''; - } - // Categories if (isModEnabled('category')) { print ''.$langs->trans("Categories").''; From 2b187c4b308a3b5a79ca4250a22b39e2c5235b13 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2024 13:45:55 +0100 Subject: [PATCH 219/714] Fix: the line "file generated" must appears once. --- htdocs/website/class/website.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 5f91c26ebd2..335c3447e6a 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -1075,15 +1075,15 @@ class Website extends CommonObject $i++; } + $line = '-- File generated by Dolibarr '.DOL_VERSION.' --;'."\n"; + $line .= "\n"; + foreach ($listofpages as $pageid => $objectpageold) { $oldpageid = $objectpageold->id; $allaliases = $objectpageold->pageurl; $allaliases .= ($objectpageold->aliasalt ? ','.$objectpageold->aliasalt : ''); - $line = '-- File generated by Dolibarr '.DOL_VERSION.' -- '.dol_print_date(dol_now('gmt'), 'standard', 'gmt').' UTC --;'."\n"; - $line .= "\n"; - if (!getDolGlobalInt('WEBSITE_EXPORT_KEEP_FILES_OF_PAGES')) { // We don't need to keep the PHP files of pages and aliases (they are regenerated at import) so we remove them. You can ask to keep them in the export // Delete the pageX.tpl.php page dol_delete_file($conf->website->dir_temp.'/'.$website->ref.'/containers/page'.$objectpageold->id.'.tpl.php', 0, 0, 0, null, false, 0); From 71e7adac7fa75ec25797dfe8296bc94c69e5a6f5 Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 14 Mar 2024 13:48:00 +0100 Subject: [PATCH 220/714] Deleted fk_user_done --- htdocs/install/mysql/tables/llx_actioncomm.sql | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_actioncomm.sql b/htdocs/install/mysql/tables/llx_actioncomm.sql index 54eac887362..eccb6f49fe8 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm.sql @@ -17,7 +17,7 @@ -- along with this program. If not, see . -- -- --- Table of events and actions (past and to do). +-- Table of events and actions (past and to do). -- This is also the table to track events on other Dolibarr objects. -- ======================================================================== @@ -31,7 +31,7 @@ create table llx_actioncomm datep2 datetime, -- date end fk_action integer, -- type of action (optional link with id in llx_c_actioncomm or null) - code varchar(50) NULL, -- code of action for automatic action ('AC_OTH_AUTO' for automatic actions, 'AC_EMAILIN_AUTO' for email input, 'AC_xxx' for manual action...) + code varchar(50) NULL, -- code of action for automatic action ('AC_OTH_AUTO' for automatic actions, 'AC_EMAILIN_AUTO' for email input, 'AC_xxx' for manual action...) datec datetime, -- date creation tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- last modification date @@ -43,7 +43,6 @@ create table llx_actioncomm fk_contact integer, fk_parent integer NOT NULL default 0, fk_user_action integer, -- user id of owner of action (note that users assigned to event are stored into table 'actioncomm_resources') - fk_user_done integer, -- user id of user that has made action (deprecated) transparency integer, -- transparency (ical standard). used to say if user assigned to event are busy or not by event. This field may be deprecated if we want to store transparency for each assigned user, moved into table llx_actioncomm_resources. @@ -56,9 +55,9 @@ create table llx_actioncomm label varchar(255) NOT NULL, -- label/title of event or topic of email note mediumtext, -- private note of event or content of email - + calling_duration integer, -- when event is a phone call, duration of phone call - + email_subject varchar(255), -- when event was an email, we store here the subject. content is stored into note. email_msgid varchar(255), -- when event was an email, we store here the msgid email_from varchar(255), -- when event was an email, we store here the from @@ -68,7 +67,7 @@ create table llx_actioncomm email_tobcc varchar(255), -- when event was an email, we store here the email_tobcc errors_to varchar(255), -- when event was an email, we store here the erros_to reply_to varchar(255), -- when event was an email, we store here the reply_to - + recurid varchar(128), -- used to store event id to link each other all the repeating event record. It can be the 'iCalUID' as in RFC5545 (an id similar for all the same serie) recurrule varchar(128), -- contains string with ical format recurring rule like 'FREQ=MONTHLY;INTERVAL=2;BYMONTHDAY=19' or 'FREQ=WEEKLY;BYDAY=MO' recurdateend datetime, -- no more recurring event after this date From da2546d9d3605bf9ceb217bfe3fb7f564ac1f3b5 Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 14 Mar 2024 13:48:44 +0100 Subject: [PATCH 221/714] Added contributor details --- htdocs/comm/action/class/actioncomm.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index b8364ea8dbc..db8eadee618 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -6,7 +6,8 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW + * Copyright (C) 2024 William Mead * * 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 From 7264621c75e02dd535dd7131aa4fdeb2cd5670dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2024 13:55:47 +0100 Subject: [PATCH 222/714] Fix: the line "file generated" must appears once. --- htdocs/website/class/website.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 335c3447e6a..2dbc2227f9d 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -1077,6 +1077,7 @@ class Website extends CommonObject $line = '-- File generated by Dolibarr '.DOL_VERSION.' --;'."\n"; $line .= "\n"; + fwrite($fp, $line); foreach ($listofpages as $pageid => $objectpageold) { $oldpageid = $objectpageold->id; @@ -1098,13 +1099,12 @@ class Website extends CommonObject } // This comment syntax is important, it is parsed by import to get information on page ID and all aliases to regenerate - $line .= '-- Page ID '.$objectpageold->newid.'__+MAX_llx_website_page__ - Aliases '.$allaliases.' --;'; // newid start at 1, 2... + $line = '-- Page ID '.$objectpageold->newid.'__+MAX_llx_website_page__ - Aliases '.$allaliases.' --;'; // newid start at 1, 2... $line .= "\n"; fwrite($fp, $line); // Warning: We must keep llx_ here. It is a generic SQL. $line = 'INSERT INTO llx_website_page(rowid, fk_page, fk_website, pageurl, aliasalt, title, description, lang, image, keywords, status, date_creation, tms, import_key, grabbed_from, type_container, htmlheader, content, author_alias, allowed_in_frames)'; - $line .= " VALUES("; $line .= $objectpageold->newid."__+MAX_llx_website_page__, "; $line .= ($objectpageold->newfk_page ? $this->db->escape($objectpageold->newfk_page)."__+MAX_llx_website_page__" : "null").", "; @@ -1170,7 +1170,7 @@ class Website extends CommonObject fwrite($fp, $line); } - $line .= "\n"; + fwrite($fp, "\n"); } $line = "\n-- For Dolibarr v14+ --;\n"; @@ -1180,6 +1180,7 @@ class Website extends CommonObject fwrite($fp, $line); fclose($fp); + dolChmod($filesql); // Build zip file From ca3141c255834b478dd89bc8e7f253d912d291d6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2024 14:03:21 +0100 Subject: [PATCH 223/714] Fix picto --- htdocs/core/modules/modAi.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modAi.class.php b/htdocs/core/modules/modAi.class.php index 3194a93ed5a..c0a527a6463 100644 --- a/htdocs/core/modules/modAi.class.php +++ b/htdocs/core/modules/modAi.class.php @@ -78,7 +78,7 @@ class modAi extends DolibarrModules // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' // To use a supported fa-xxx css style of font awesome, use this->picto='xxx' - $this->picto = 'fa-microchip'; + $this->picto = 'fa-magic'; // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) $this->module_parts = array( From 9dbc249cf0ee9b9f91df9a4bcb5023d89ce99118 Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 14 Mar 2024 14:59:04 +0100 Subject: [PATCH 224/714] Fixed undefined task object --- htdocs/core/lib/project.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index ab142a50675..12974209afe 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -934,7 +934,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Extra fields $extrafieldsobjectkey = $taskstatic->table_element; $extrafieldsobjectprefix = 'efpt.'; - $obj = $lines[$i]->obj; + $obj = $lines[$i]; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook $parameters = array('arrayfields' => $arrayfields, 'obj' => $lines[$i]); From a25e8ee14de2c08067dba4ad24bdea1f8a51a682 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 14 Mar 2024 15:09:44 +0100 Subject: [PATCH 225/714] FIX PHPStan warnings --- htdocs/core/modules/member/doc/pdf_standard.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index 8585f4ee1b4..5ce0565f4eb 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -263,7 +263,7 @@ class pdf_standard extends CommonStickerGenerator /** * Function to build PDF on disk, then output on HTTP stream. * - * @param Adherent $object Member object. Old usage: Array of record information (array('textleft'=>,'textheader'=>, ...'id'=>,'photo'=>) + * @param mixed $object Member object. Old usage: Array of record information (array('textleft'=>,'textheader'=>, ...'id'=>,'photo'=>) * @param Translate $outputlangs Lang object for output language * @param string $srctemplatepath Full path of source filename for generator using a template file. Example: '5161', 'AVERYC32010', 'CARD', ... * @param string $mode Tell if doc module is called for 'member', ... From 21b291a87ad94a14ba426da94b61912e78dd1a21 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 14 Mar 2024 15:21:39 +0100 Subject: [PATCH 226/714] FIX variable assignement for PHPStan warnings --- htdocs/expensereport/payment/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/expensereport/payment/list.php b/htdocs/expensereport/payment/list.php index 88cd5ecb2d0..bd3ba374d76 100644 --- a/htdocs/expensereport/payment/list.php +++ b/htdocs/expensereport/payment/list.php @@ -517,9 +517,9 @@ while ($i < $imaxinloop) { if ($objp->bid) { $accountstatic->fetch($objp->bid); - $paymentexpensereportstatic->fk_bank = $accountstatic->getNomUrl(1); + $paymentexpensereportstatic->fk_bank = $accountstatic->id; } else { - $paymentexpensereportstatic->fk_bank = null; + $paymentexpensereportstatic->fk_bank = 0; } $userstatic->id = $objp->userid; From 560d5618d2b4eb02b5de1a3f8947aa9945fbd433 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 14 Mar 2024 15:31:11 +0100 Subject: [PATCH 227/714] FIX type in doc for variable childtables --- htdocs/hrm/class/job.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/hrm/class/job.class.php b/htdocs/hrm/class/job.class.php index c0ec08939d4..34893a805b2 100644 --- a/htdocs/hrm/class/job.class.php +++ b/htdocs/hrm/class/job.class.php @@ -148,7 +148,7 @@ class Job extends CommonObject // public $class_element_line = 'Jobline'; // /** - // * @var array List of child tables. To test if we can delete object. + // * @var string[] List of child tables. To test if we can delete object. // */ protected $childtables = array('hrm_evaluation', 'hrm_job_user'); From b818a6a137cc6023903b3a37bc3c6cac4f53f543 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 14 Mar 2024 15:52:37 +0100 Subject: [PATCH 228/714] Fix return type in getAllMochilds (PHPStan warnings) --- htdocs/mrp/class/mo.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 2a1c580a03b..0244bfd3866 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -236,7 +236,7 @@ class Mo extends CommonObject public $lines = array(); /** - * @var MoLine MO line + * @var MoLine|null MO line */ public $line = array(); @@ -1859,7 +1859,7 @@ class Mo extends CommonObject * Function used to return all child MOs recursively * * @param int $depth Depth for recursing loop count - * @return Mo[]|int[] array of MOs if OK, -1 if KO + * @return Mo[]|int array of MOs if OK, -1 if KO */ public function getAllMoChilds($depth = 0) { From 3c7f5391e5b27a64232bb0534698bc685709cfdf Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 14 Mar 2024 16:00:43 +0100 Subject: [PATCH 229/714] FIX variable by adding a type BOMLine (PHPStan warnings) --- htdocs/mrp/class/mo.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 2a1c580a03b..da5b1caf030 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -231,7 +231,7 @@ class Mo extends CommonObject protected $childtablesoncascade = array('mrp_production'); /** - * @var MoLine[] Array of subtable lines + * @var MoLine[]|BOMLine[] Array of subtable lines */ public $lines = array(); From c46e5ac34b6abcc09b210766c523de933e685fd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Mar 2024 16:01:12 +0100 Subject: [PATCH 230/714] some fix for vinci --- .../modules/mrp/doc/pdf_vinci.modules.php | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index cc5bc784df0..1fd7f7d6005 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -5,7 +5,7 @@ * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2018-2023 Frédéric France + * Copyright (C) 2018-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 @@ -124,13 +124,13 @@ class pdf_vinci extends ModelePDFMo /** * Function to build pdf onto disk * - * @param CommandeFournisseur $object Id of object to generate - * @param Translate $outputlangs Lang output object - * @param string $srctemplatepath Full path of source filename for generator using a template file - * @param int $hidedetails Do not show line details - * @param int $hidedesc Do not show desc - * @param int $hideref Do not show ref - * @return int 1=OK, 0=KO + * @param Mo $object Id of object to generate + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return int 1=OK, 0=KO */ public function write_file($object, $outputlangs = null, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { @@ -235,10 +235,10 @@ class pdf_vinci extends ModelePDFMo $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); - $pdf->SetSubject($outputlangs->transnoentities("Mo")); + $pdf->SetSubject($outputlangs->transnoentities("ManufacturingOrder")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Mo")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("ManufacturingOrder")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) { $pdf->SetCompression(false); } @@ -657,7 +657,7 @@ class pdf_vinci extends ModelePDFMo * Show payments table * * @param TCPDF $pdf Object PDF - * @param CommandeFournisseur $object Object order + * @param Mo $object Object order * @param int $posy Position y in PDF * @param Translate $outputlangs Object langs for output * @return int Return integer <0 if KO, >0 if OK @@ -674,7 +674,7 @@ class pdf_vinci extends ModelePDFMo * Show miscellaneous information (payment mode, payment term, ...) * * @param TCPDF $pdf Object PDF - * @param CommandeFournisseur $object Object to show + * @param Mo $object Object to show * @param int $posy Y * @param Translate $outputlangs Langs object * @return integer @@ -1016,7 +1016,7 @@ class pdf_vinci extends ModelePDFMo * Show top header of page. * * @param TCPDF $pdf Object PDF - * @param CommandeFournisseur $object Object to show + * @param Mo $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output * @return float|int Return topshift value @@ -1031,7 +1031,7 @@ class pdf_vinci extends ModelePDFMo } // Load translation files required by the page - $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "sendings")); + $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "sendings", "mrp")); $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1074,7 +1074,7 @@ class pdf_vinci extends ModelePDFMo $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $title = $outputlangs->transnoentities("Mo")." ".$outputlangs->convToOutputCharset($object->ref); + $title = $outputlangs->transnoentities("ManufacturingOrder")." ".$outputlangs->convToOutputCharset($object->ref); $pdf->MultiCell(100, 3, $title, '', 'R'); $posy += 1; @@ -1311,7 +1311,7 @@ class pdf_vinci extends ModelePDFMo * Show footer of page. Need this->emetteur object * * @param TCPDF $pdf PDF - * @param CommandeFournisseur $object Object to show + * @param Mo $object Object to show * @param Translate $outputlangs Object lang for output * @param int $hidefreetext 1=Hide free text * @return int Return height of bottom margin including footer text @@ -1323,15 +1323,14 @@ class pdf_vinci extends ModelePDFMo } - /** * Define Array Column Field * - * @param object $object common object + * @param Mo $object common object * @param Translate $outputlangs langs - * @param int $hidedetails Do not show line details - * @param int $hidedesc Do not show desc - * @param int $hideref Do not show ref + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref * @return void */ public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) From 0bb1dfca0c2d9c2b6c5c2dd7f3d1dfaab5809705 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 14 Mar 2024 16:09:10 +0100 Subject: [PATCH 231/714] FIX the variable type by adding null to the variable document --- htdocs/multicurrency/class/multicurrency.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index 57a6c1ee69a..f2ff645052c 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -90,7 +90,7 @@ class MultiCurrency extends CommonObject public $fk_user; /** - * @var CurrencyRate The currency rate + * @var CurrencyRate|null The currency rate */ public $rate; From 98d0ed71107163544cbc2d1e45bb2dddeed40c4d Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 14 Mar 2024 16:14:55 +0100 Subject: [PATCH 232/714] FIX assignement variable (PHPStan warnings) --- .../dynamic_price/class/price_global_variable_updater.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php index 42030aa290e..c0ec8226e3d 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php @@ -456,7 +456,7 @@ class PriceGlobalVariableUpdater $langs->load("errors"); dol_syslog(__METHOD__, LOG_DEBUG); - $this->error = null; + $this->error = ''; $this->checkParameters(); //Try to load the target global variable and abort if fails From 8ae32dd865f29845d7e77f483ff1715b0d1bf631 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 14 Mar 2024 16:19:41 +0100 Subject: [PATCH 233/714] FIX variable by casting it with int --- htdocs/product/price.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 747604f0f70..30b9502a78a 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -292,7 +292,7 @@ if (empty($reshook)) { $newlocaltax2_type = GETPOST('localtax2_type', 'array'); //Shall we generate prices using price rules? - $object->price_autogen = GETPOST('usePriceRules') == 'on'; + $object->price_autogen = (int) GETPOST('usePriceRules') == 'on'; for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { if (!isset($newprice[$i])) { From 9acd54b5a73c7dece9d148e1f251bf029ab293f7 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 14 Mar 2024 16:26:43 +0100 Subject: [PATCH 234/714] Fix return method by changing boolean to exception in api_warehouse (PHPStan warnings) --- htdocs/product/stock/class/api_warehouses.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/class/api_warehouses.class.php b/htdocs/product/stock/class/api_warehouses.class.php index e39ede65299..1af08af0534 100644 --- a/htdocs/product/stock/class/api_warehouses.class.php +++ b/htdocs/product/stock/class/api_warehouses.class.php @@ -222,9 +222,9 @@ class Warehouses extends DolibarrApi if ($this->warehouse->update($id, DolibarrApiAccess::$user)) { return $this->get($id); + } else { + throw new RestException(500, $this->warehouse->error); } - - return false; } /** From 05a9dc5f72b8a9f45f7d817c27a468399fb0ce15 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Thu, 14 Mar 2024 16:33:38 +0100 Subject: [PATCH 235/714] Fix: Correction for batches with letters in Takepos --- htdocs/takepos/invoice.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index d0e0d179efc..cf3e3cde9b6 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -3,6 +3,7 @@ * Copyright (C) 2018 Andreu Bisquerra * Copyright (C) 2021 Nicolas ZABOURI * Copyright (C) 2022-2023 Christophe Battarel + * Copyright (C) 2024 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 @@ -923,7 +924,7 @@ if (empty($reshook)) { if ($action=="setbatch" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) { $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set batch=".$db->escape($batch).", fk_warehouse=".getDolGlobalString($constantforkey)." where rowid=".((int) $idoflineadded); + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set batch='".$db->escape($batch)."', fk_warehouse=".getDolGlobalString($constantforkey)." where rowid=".((int) $idoflineadded); $db->query($sql); } From 2670287dd4543035cb4834b22b3cd0a4d093a911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Mar 2024 16:34:41 +0100 Subject: [PATCH 236/714] translation --- htdocs/core/modules/mrp/doc/pdf_vinci.modules.php | 2 +- htdocs/langs/en_US/main.lang | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index 1fd7f7d6005..81e910d4e19 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -1421,7 +1421,7 @@ class pdf_vinci extends ModelePDFMo 'status' => true, 'width' => 25, // in mm 'title' => array( - 'textkey' => 'Size' + 'textkey' => 'Dimensions' ), 'border-left' => true, // add left line separator ); diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 95042a5cc24..f519e098d01 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -562,6 +562,7 @@ New=New Discount=Discount Unknown=Unknown General=General +Dimensions=Dimensions Size=Size OriginalSize=Original size RotateImage=Rotate 90° From 3f4033a8e22d2925519a56f07d560b4a6548df14 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Thu, 14 Mar 2024 16:39:08 +0100 Subject: [PATCH 237/714] Fix: Correction for batches with letters in Takepos --- .../class/multicurrency.class.php | 2 - htdocs/multicurrency/multicurrency_rate.php | 38 +------------------ 2 files changed, 2 insertions(+), 38 deletions(-) diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index 81d85b7c470..5433bb23f28 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -4,7 +4,6 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Pierre-Henry Favre - * Copyright (C) 2024 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 @@ -914,7 +913,6 @@ class CurrencyRate extends CommonObjectLine // Update request $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql .= " SET rate = ".((float) $this->rate); - $sql .= ", rate_indirect = ".((float) $this->rate_indirect); if (!empty($this->date_sync)) { $sql .= ", date_sync = '".$this->db->idate($this->date_sync)."'"; } diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 40fb99eba4a..782834bbaa5 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -10,7 +10,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Adolfo segura * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2016-2024 Ferran Marcet + * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2023 Lenin Rivas * * This program is free software; you can redistribute it and/or modify @@ -58,7 +58,7 @@ $search_code = GETPOST('search_code', 'alpha'); $multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $dateinput = dol_mktime(0, 0, 0, GETPOST('dateinputmonth', 'int'), GETPOST('dateinputday', 'int'), GETPOST('dateinputyear', 'int')); $rateinput = price2num(GETPOST('rateinput', 'alpha')); -$rateindirectinput = price2num(GETPOST('rateindirectinput', 'alpha')); +$rateindirectinput = price2num(GETPOST('rateinidirectinput', 'alpha')); $optioncss = GETPOST('optioncss', 'alpha'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -168,7 +168,6 @@ if ($action == 'update') { $currencyRate->date_sync = $dateinput; $currencyRate->fk_multicurrency = $fk_currency; $currencyRate->rate = $rateinput; - $currencyRate->rate_indirect = $rateindirectinput; $res = $currencyRate->update(); if ($res) { setEventMessages($langs->trans('successUpdateRate'), null); @@ -245,7 +244,6 @@ if (empty($reshook)) { $search_date_sync = ""; $search_date_sync_end=""; $search_rate = ""; - $search_rate_indirect = ""; $search_code = ""; $search_array_options = array(); } @@ -349,9 +347,6 @@ if ($search_date_sync && $search_date_sync_end) { if ($search_rate) { $sql .= natural_search('cr.rate', $search_rate, 1); } -if ($search_rate_indirect) { - $sql .= natural_search('cr.rate_indirect', $search_rate_indirect, 1); -} if ($search_code) { $sql .= natural_search('m.code', $search_code); } @@ -413,9 +408,6 @@ if ($resql) { if ($search_rate) { $param = "&search_rate=".urlencode($search_rate); } - if ($search_rate_indirect) { - $param = "&search_rate_indirect=".urlencode($search_rate_indirect); - } if ($search_code != '') { $param.="&search_code=".urlencode($search_code); } @@ -510,12 +502,6 @@ if ($resql) { print ''; print ''; } - // rate indirect - if (!empty($arrayfields['cr.rate_indirect']['checked'])) { - print ''; - print ''; - print ''; - } // Fields from hook $parameters = array('arrayfields'=>$arrayfields); @@ -545,9 +531,6 @@ if ($resql) { if (!empty($arrayfields['cr.rate']['checked'])) { print_liste_field_titre($arrayfields['cr.rate']['label'], $_SERVER["PHP_SELF"], "cr.rate", "", $param, "", $sortfield, $sortorder); } - if (!empty($arrayfields['cr.rate_indirect']['checked'])) { - print_liste_field_titre($arrayfields['cr.rate_indirect']['label'], $_SERVER["PHP_SELF"], "cr.rate_indirect", "", $param, "", $sortfield, $sortorder); - } // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); @@ -576,23 +559,6 @@ if ($resql) { print '' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . ''; print ''; - if (getDolGlobalString('MULTICURRENCY_USE_RATE_INDIRECT')) { - print ''; - // LRR Calculate Rate Direct - print ''; - print ''; - } - print ''; print ''; print ''; From 967c444d8d7bfaf85a0fe64dd302b86eafadc4b9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2024 16:39:12 +0100 Subject: [PATCH 238/714] FIX support of multiobject in APIs generated by modulebuilder --- htdocs/core/lib/modulebuilder.lib.php | 139 ++++++++++++++++---------- htdocs/modulebuilder/index.php | 29 ++++-- 2 files changed, 105 insertions(+), 63 deletions(-) diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 68e8b982cce..bb1ce99fa52 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -839,7 +839,8 @@ function deletePropsAndPermsFromDoc($file, $objectname) /** - * Search a string and return all lines needed from file + * Search a string and return all lines needed from file. Does not include line $start nor $end + * * @param string $file file for searching * @param string $start start line if exist * @param string $end end line if exist @@ -953,106 +954,136 @@ function writePermsInAsciiDoc($file, $destfile) /** * Add Object in ModuleApi File - * @param string $file path of file - * @param array $objects array of objects in the module - * @param string $modulename name of module - * @return int 1 if OK, -1 if KO + * + * @param string $srcfile Source file to use as example + * @param string $file Path of modified file + * @param array $objects Array of objects in the module + * @param string $modulename Name of module + * @return int Return 1 if OK, -1 if KO */ -function addObjectsToApiFile($file, $objects, $modulename) +function addObjectsToApiFile($srcfile, $file, $objects, $modulename) { + global $langs, $user; + if (!file_exists($file)) { return -1; } - $content = file($file); - $includeClass = "dol_include_once('/mymodule/class/myobject.class.php');"; - $props = "public \$myobject;"; - $varcomented = "@var MyObject \$myobject {@type MyObject}"; - $constructObj = "\$this->myobject = new MyObject(\$this->db);"; + + $now = dol_now(); + $content = file($file); // $content is an array + + $includeClass = "dol_include_once\(\'\/\w+\/class\/\w+\.class\.php\'\);"; + $props = 'public\s+\$\w+;'; + $varcommented = '@var\s+\w+\s+\$\w+\s+{@type\s+\w+}'; + $constructObj = '\$this->\w+\s+=\s+new\s+\w+\(\$this->db\);'; // add properties and declare them in constructor foreach ($content as $lineNumber => &$lineContent) { - if (strpos($lineContent, $varcomented) !== false) { + if (preg_match('/'.$varcommented.'/', $lineContent)) { $lineContent = ''; - foreach ($objects as $object) { - $lineContent .= "\t * @var ".$object." \$".strtolower($object)." {@type ".$object."}". PHP_EOL; + foreach ($objects as $objectname) { + $lineContent .= "\t * @var ".$objectname." \$".strtolower($objectname)." {@type ".$objectname."}". PHP_EOL; } //var_dump($lineContent);exit; - } - if (strpos($lineContent, $props) !== false) { + } elseif (preg_match('/'.$props.'/', $lineContent)) { $lineContent = ''; - foreach ($objects as $object) { - $lineContent .= "\tpublic \$".strtolower($object).";". PHP_EOL; + foreach ($objects as $objectname) { + $lineContent .= "\tpublic \$".strtolower($objectname).";". PHP_EOL; } - } - if (strpos($lineContent, $constructObj) !== false) { + } elseif (preg_match('/'.$constructObj.'/', $lineContent)) { $lineContent = ''; - foreach ($objects as $object) { - $lineContent .= "\t\t\$this->".strtolower($object)." = new ".$object."(\$this->db);". PHP_EOL; + foreach ($objects as $objectname) { + $lineContent .= "\t\t\$this->".strtolower($objectname)." = new ".$objectname."(\$this->db);". PHP_EOL; } - } - if (strpos($lineContent, $includeClass) !== false) { + } elseif (preg_match('/'.$includeClass.'/', $lineContent)) { $lineContent = ''; - foreach ($objects as $object) { - $lineContent .= "dol_include_once('/".strtolower($modulename)."/class/".strtolower($object).".class.php');". PHP_EOL; + foreach ($objects as $objectname) { + $lineContent .= "dol_include_once('/".strtolower($modulename)."/class/".strtolower($objectname).".class.php');". PHP_EOL; } } } + $allContent = implode("", $content); file_put_contents($file, $allContent); - //add methods for each object - $allContent = getFromFile($file, '/*begin methods CRUD*/', '/*end methods CRUD*/'); - foreach ($objects as $object) { - $contentReplaced = str_replace(["myobject","MyObject"], [strtolower($object),$object], $allContent); - dolReplaceInFile($file, array('/*end methods CRUD*/' => '/*CRUD FOR '.strtoupper($object).'*/'."\n".$contentReplaced."\n\t".'/*END CRUD FOR '.strtoupper($object).'*/'."\n\t".'/*end methods CRUD*/')); + // Add methods for each object + $allContent = getFromFile($srcfile, '/* BEGIN MODULEBUILDER API MYOBJECT */', '/* END MODULEBUILDER API MYOBJECT */'); + foreach ($objects as $objectname) { + $arrayreplacement = array( + 'mymodule' => strtolower($modulename), + 'MyModule' => $modulename, + 'MYMODULE' => strtoupper($modulename), + 'My module' => $modulename, + 'my module' => $modulename, + 'Mon module' => $modulename, + 'mon module' => $modulename, + 'htdocs/modulebuilder/template' => strtolower($modulename), + 'myobject' => strtolower($objectname), + 'MyObject' => $objectname, + 'MYOBJECT' => strtoupper($objectname), + '---Put here your own copyright and developer email---' => dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') + ); + $contentReplaced = make_substitutions($allContent, $arrayreplacement, null); + //$contentReplaced = str_replace(["myobject","MyObject"], [strtolower($object),$object], $allContent); + + dolReplaceInFile($file, array( + '/* BEGIN MODULEBUILDER API MYOBJECT */' => '/* BEGIN MODULEBUILDER API '.strtoupper($objectname).' */'.$contentReplaced."\t".'/* END MODULEBUILDER API '.strtoupper($objectname).' */'."\n\n\n\t".'/* BEGIN MODULEBUILDER API MYOBJECT */' + )); } - dolReplaceInFile($file, array($allContent => '','MyModule' => ucfirst($modulename))); + + // Remove the block $allContent found in src file + // TODO Replace with a replacement of all text including into /* BEGIN MODULEBUILDER API MYOBJECT */ and /* END MODULEBUILDER API MYOBJECT */ + dolReplaceInFile($file, array($allContent => '')); + return 1; } /** - * Remove Object variables and methods from API_Module File - * @param string $file file api module - * @param string $objectname name of object want to remove - * @param string $modulename name of module - * @return int 1 if OK, -1 if KO + * Remove Object variables and methods from API_Module File + * + * @param string $file File api module + * @param array $objects Array of objects in the module + * @param string $objectname Name of object want to remove + * @return int 1 if OK, -1 if KO */ -function removeObjectFromApiFile($file, $objectname, $modulename) +function removeObjectFromApiFile($file, $objects, $objectname) { - $begin = '/*CRUD FOR '.strtoupper($objectname).'*/'; - $end = '/*END CRUD FOR '.strtoupper($objectname).'*/'; - $includeClass = "dol_include_once('/".strtolower($modulename)."/class/".strtolower($objectname).".class.php');"; - $varcomentedDel = "\t * @var ".$objectname." \$".strtolower($objectname)." {@type ".$objectname."}"; - $propsDel = "\tpublic \$".strtolower($objectname).";"; - $constructObjDel = "\t\t\$this->".strtolower($objectname)." = new ".$objectname."(\$this->db);"; - if (!file_exists($file)) { return -1; } - $content = file($file); - // for delete property and the initialization from the construct + + $content = file($file); // $content is an array + + $includeClass = "dol_include_once\(\'\/\w+\/class\/".strtolower($objectname)."\.class\.php\'\);"; + $props = 'public\s+\$'.strtolower($objectname); + $varcommented = '@var\s+\w+\s+\$'.strtolower($objectname).'\s+{@type\s+\w+}'; + $constructObj = '\$this->'.strtolower($objectname).'\s+=\s+new\s+\w+\(\$this->db\);'; + + // add properties and declare them in constructor foreach ($content as $lineNumber => &$lineContent) { - if (strpos($lineContent, $includeClass) !== false) { + if (preg_match('/'.$varcommented.'/i', $lineContent)) { $lineContent = ''; - } - if (strpos($lineContent, $varcomentedDel) !== false) { + } elseif (preg_match('/'.$props.'/i', $lineContent)) { $lineContent = ''; - } - if (strpos($lineContent, $propsDel) !== false) { + } elseif (preg_match('/'.$constructObj.'/i', $lineContent)) { $lineContent = ''; - } - if (strpos($lineContent, $constructObjDel) !== false) { + } elseif (preg_match('/'.$includeClass.'/i', $lineContent)) { $lineContent = ''; } } + $allContent = implode("", $content); file_put_contents($file, $allContent); + // for delete methods of object + $begin = '/* BEGIN MODULEBUILDER API '.strtoupper($objectname).' */'; + $end = '/* END MODULEBUILDER API '.strtoupper($objectname).' */'; $allContent = getFromFile($file, $begin, $end); $check = dolReplaceInFile($file, array($allContent => '')); if ($check) { dolReplaceInFile($file, array($begin => '', $end => '')); } + return 1; } diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 1e78c341f06..e0acefa2b0e 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -467,13 +467,13 @@ if ($dirins && in_array($action, array('initapi', 'initphpunit', 'initpagecontac '---Put here your own copyright and developer email---' => dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') ); - if (count($objects) > 1) { - addObjectsToApiFile($destfile, $objects, $modulename); + if ($action == 'initapi') { + if (count($objects) >= 1) { + addObjectsToApiFile($srcfile, $destfile, $objects, $modulename); + } } else { // @phan-suppress-next-line PhanPluginSuspiciousParamPosition dolReplaceInFile($destfile, $arrayreplacement); - // @phan-suppress-next-line PhanPluginSuspiciousParamPosition - dolReplaceInFile($destfile, array('/*begin methods CRUD*/' => '/*begin methods CRUD*/'."\n\t".'/*CRUD FOR '.strtoupper($objectname).'*/', '/*end methods CRUD*/' => '/*END CRUD FOR '.strtoupper($objectname).'*/'."\n\t".'/*end methods CRUD*/')); } if ($varnametoupdate) { @@ -952,20 +952,31 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) { $filetodelete = $dirins.'/'.$relativefilename; $dirtodelete = $dirins.'/'.$dirnametodelete; - //check when we want delete api_file + // Get list of existing objects + $objects = dolGetListOfObjectClasses($destdir); + + $keyofobjecttodelete = array_search($objectname, $objects); + if ($keyofobjecttodelete !== false) { + unset($objects[$keyofobjecttodelete]); + } + + // Delete or modify the file if (strpos($relativefilename, 'api') !== false) { $file_api = $destdir.'/class/api_'.strtolower($module).'.class.php'; - $removeFile = removeObjectFromApiFile($file_api, $objectname, $module); - $var = getFromFile($file_api, '/*begin methods CRUD*/', '/*end methods CRUD*/'); - if (str_word_count($var) == 0) { + + $removeFile = removeObjectFromApiFile($file_api, $objects, $objectname); + + if (count($objects) == 0) { $result = dol_delete_file($filetodelete); } + if ($removeFile) { setEventMessages($langs->trans("ApiObjectDeleted"), null); } } else { $result = dol_delete_file($filetodelete); } + if (!$result) { setEventMessages($langs->trans("ErrorFailToDeleteFile", basename($filetodelete)), null, 'errors'); } else { @@ -4209,7 +4220,7 @@ if ($module == 'initmodule') { print ''.$langs->trans("ApiExplorer").''; } } else { - print ''.img_picto('AddAPIsForThisObject', 'generate', 'class="paddingleft"').''; + print ''.img_picto($langs->trans('AddAPIsForThisObject'), 'generate', 'class="paddingleft"').''; } } else { print ''.img_picto('Generate', 'generate', 'class="paddingleft"').''; From c22a6219ece134d053e6ec54df9a45151a3e31ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2024 16:40:06 +0100 Subject: [PATCH 239/714] Debug v20 --- htdocs/core/lib/functions.lib.php | 4 +++- htdocs/core/modules/modAi.class.php | 2 +- htdocs/core/modules/modBookCal.class.php | 2 +- htdocs/langs/en_US/modulebuilder.lang | 7 ++++--- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e74be328a4b..40afe9b9dc8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4618,7 +4618,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $srco if (empty($srconly) && in_array($pictowithouttext, array( '1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected', 'accountancy', 'accounting_account', 'account', 'accountline', 'action', 'add', 'address', 'ai', 'angle-double-down', 'angle-double-up', 'asset', - 'bank_account', 'barcode', 'bank', 'bell', 'bill', 'billa', 'billr', 'billd', 'birthday-cake', 'bookmark', 'bom', 'briefcase-medical', 'bug', 'building', + 'bank_account', 'barcode', 'bank', 'bell', 'bill', 'billa', 'billr', 'billd', 'birthday-cake', 'bom', 'bookcal', 'bookmark', 'briefcase-medical', 'bug', 'building', 'card', 'calendarlist', 'calendar', 'calendarmonth', 'calendarweek', 'calendarday', 'calendarperuser', 'calendarpertype', 'cash-register', 'category', 'chart', 'check', 'clock', 'clone', 'close_title', 'code', 'cog', 'collab', 'company', 'contact', 'country', 'contract', 'conversation', 'cron', 'cross', 'cubes', 'check-circle', 'check-square', 'currency', 'multicurrency', @@ -4666,6 +4666,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $srco 'asset' => 'money-check-alt', 'autofill' => 'fill', 'bank_account' => 'university', 'bill' => 'file-invoice-dollar', 'billa' => 'file-excel', 'billr' => 'file-invoice-dollar', 'billd' => 'file-medical', + 'bookcal' => 'calendar-check', 'supplier_invoice' => 'file-invoice-dollar', 'supplier_invoicea' => 'file-excel', 'supplier_invoicer' => 'file-invoice-dollar', 'supplier_invoiced' => 'file-medical', 'bom' => 'shapes', 'card' => 'address-card', 'chart' => 'chart-line', 'company' => 'building', 'contact' => 'address-book', 'contract' => 'suitcase', 'collab' => 'people-arrows', 'conversation' => 'comments', 'country' => 'globe-americas', 'cron' => 'business-time', 'cross' => 'times', @@ -4764,6 +4765,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $srco 'action' => 'infobox-action', 'account' => 'infobox-bank_account', 'accounting_account' => 'infobox-bank_account', 'accountline' => 'infobox-bank_account', 'accountancy' => 'infobox-bank_account', 'asset' => 'infobox-bank_account', 'bank_account' => 'infobox-bank_account', 'bill' => 'infobox-commande', 'billa' => 'infobox-commande', 'billr' => 'infobox-commande', 'billd' => 'infobox-commande', + 'bookcal' => 'infobox-action', 'margin' => 'infobox-bank_account', 'conferenceorbooth' => 'infobox-project', 'cash-register' => 'infobox-bank_account', 'contract' => 'infobox-contrat', 'check' => 'font-status4', 'collab' => 'infobox-action', 'conversation' => 'infobox-contrat', 'donation' => 'infobox-commande', 'dolly' => 'infobox-commande', 'dollyrevert' => 'flip infobox-order_supplier', diff --git a/htdocs/core/modules/modAi.class.php b/htdocs/core/modules/modAi.class.php index c0a527a6463..3c47eb376d3 100644 --- a/htdocs/core/modules/modAi.class.php +++ b/htdocs/core/modules/modAi.class.php @@ -69,7 +69,7 @@ class modAi extends DolibarrModules $this->descriptionlong = "AiDescriptionLong"; // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = 'development'; + $this->version = 'experimental'; // Key used in llx_const table to save module status enabled/disabled (where BOOKCAL is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); diff --git a/htdocs/core/modules/modBookCal.class.php b/htdocs/core/modules/modBookCal.class.php index a778ac8ffc7..0b2ce6c2c77 100644 --- a/htdocs/core/modules/modBookCal.class.php +++ b/htdocs/core/modules/modBookCal.class.php @@ -78,7 +78,7 @@ class modBookCal extends DolibarrModules // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' // To use a supported fa-xxx css style of font awesome, use this->picto='xxx' - $this->picto = 'fa-calendar-check'; + $this->picto = 'bookcal'; // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) $this->module_parts = array( diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index c59c4271710..9ff542d9799 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -165,7 +165,7 @@ BadValueForType=Bad value for type %s DefinePropertiesFromExistingTable=Define the fields/properties from an existing table DefinePropertiesFromExistingTableDesc=If a table in the database (for the object to create) already exists, you can use it to define the properties of the object. DefinePropertiesFromExistingTableDesc2=Keep empty if the table does not exist yet. The code generator will use different kinds of fields to build an example of table that you can edit later. -GeneratePermissions=I want to manage permissions on this object +GeneratePermissions=I want to manage permissions on this object GeneratePermissionsHelp=If you check this, some code will be added to manage permissions to read, write and delete record of the objects PermissionDeletedSuccesfuly=Permission has been successfully removed PermissionUpdatedSuccesfuly=Permission has been successfully updated @@ -173,6 +173,7 @@ PermissionAddedSuccesfuly=Permission has been successfully added MenuDeletedSuccessfuly=Menu has been successfully deleted MenuAddedSuccessfuly=Menu has been successfully added MenuUpdatedSuccessfuly=Menu has been successfully updated +AddAPIsForThisObject=Add APIs for this object ApiObjectDeleted=API for object %s has been successfully deleted CRUDRead=Read CRUDCreateWrite=Create or Update @@ -181,8 +182,8 @@ DictionariesCreated=Dictionary %s created successfully DictionaryDeleted=Dictionary %s removed successfully PropertyModuleUpdated=Property %s has been update successfully InfoForApiFile=* When you generate file for the first time then all methods will be created for each object.
* When you click in remove you just remove all methods for the selected object. -SetupFile=Page for module setup +SetupFile=Page for module setup EmailingSelectors=Emails selectors EmailingSelectorDesc=You can generate and edit here the class files to provide new email target selectors for the mass emailing module EmailingSelectorFile=Emails selector file -NoEmailingSelector=No emails selector file \ No newline at end of file +NoEmailingSelector=No emails selector file From 7fddff930225e9ca90753967fa76effce2887850 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Thu, 14 Mar 2024 16:40:14 +0100 Subject: [PATCH 240/714] Fix: Correction for batches with letters in Takepos --- htdocs/multicurrency/class/multicurrency.class.php | 2 +- htdocs/multicurrency/multicurrency_rate.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index 5433bb23f28..a7ef2153c9f 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -912,7 +912,7 @@ class CurrencyRate extends CommonObjectLine // Update request $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET rate = ".((float) $this->rate); + $sql .= "SET rate = ".((float) $this->rate); if (!empty($this->date_sync)) { $sql .= ", date_sync = '".$this->db->idate($this->date_sync)."'"; } diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 782834bbaa5..947c5ac3a2b 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -557,7 +557,7 @@ if ($resql) { } print ''; print '' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . ''; - print ''; + print ''; print ''; print ''; From 54bdad710d1b074fe0fd3c0abe2a0748403f33a2 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Thu, 14 Mar 2024 16:40:54 +0100 Subject: [PATCH 241/714] Fix: Correction for batches with letters in Takepos --- htdocs/multicurrency/multicurrency_rate.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 947c5ac3a2b..94c0438f71e 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -558,7 +558,6 @@ if ($resql) { print ''; print '' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . ''; print ''; - print ''; print ''; print ''; From 9430bebbb1ddf25da9fccc7e175e0c29f263a146 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Thu, 14 Mar 2024 16:44:07 +0100 Subject: [PATCH 242/714] Fix: Correction so that warehouse does not have to be indicated if it is a service --- htdocs/expedition/class/expedition.class.php | 4 ++-- htdocs/takepos/invoice.php | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 9588e8c9852..0ec2cf6aa77 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2014-2017 Francis Appels * Copyright (C) 2015 Claudio Aschieri - * Copyright (C) 2016-2022 Ferran Marcet + * Copyright (C) 2016-2024 Ferran Marcet * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018-2022 Frédéric France * Copyright (C) 2020 Lenin Rivas @@ -920,7 +920,7 @@ class Expedition extends CommonObject if (isModEnabled('stock') && !empty($orderline->fk_product)) { $fk_product = $orderline->fk_product; - if (!($entrepot_id > 0) && !getDolGlobalString('STOCK_WAREHOUSE_NOT_REQUIRED_FOR_SHIPMENTS')) { + if (!($entrepot_id > 0) && !getDolGlobalString('STOCK_WAREHOUSE_NOT_REQUIRED_FOR_SHIPMENTS') && !(getDolGlobalString('SHIPMENT_SUPPORTS_SERVICES') && $line->product_type == Product::TYPE_SERVICE)) { $langs->load("errors"); $this->error = $langs->trans("ErrorWarehouseRequiredIntoShipmentLine"); return -1; diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index cf3e3cde9b6..d0e0d179efc 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -3,7 +3,6 @@ * Copyright (C) 2018 Andreu Bisquerra * Copyright (C) 2021 Nicolas ZABOURI * Copyright (C) 2022-2023 Christophe Battarel - * Copyright (C) 2024 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 @@ -924,7 +923,7 @@ if (empty($reshook)) { if ($action=="setbatch" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) { $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set batch='".$db->escape($batch)."', fk_warehouse=".getDolGlobalString($constantforkey)." where rowid=".((int) $idoflineadded); + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set batch=".$db->escape($batch).", fk_warehouse=".getDolGlobalString($constantforkey)." where rowid=".((int) $idoflineadded); $db->query($sql); } From 6b48e098549c3ee0dcf56ae3f8ce7bdab8200ad8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2024 16:49:29 +0100 Subject: [PATCH 243/714] Debug --- htdocs/modulebuilder/template/admin/about.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/admin/about.php b/htdocs/modulebuilder/template/admin/about.php index 7ec1d1f30f3..ecacf04f4c1 100644 --- a/htdocs/modulebuilder/template/admin/about.php +++ b/htdocs/modulebuilder/template/admin/about.php @@ -83,7 +83,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); $form = new Form($db); $help_url = ''; -$title = "MyModuleAbout"; +$title = "MyModuleSetup"; llxHeader('', $langs->trans($title), $help_url, '', 0, 0, '', '', '', 'mod-mymodule page-admin_about'); From 1e252dd5871f15181d17dd95194470fde7f4e778 Mon Sep 17 00:00:00 2001 From: MDW Date: Thu, 14 Mar 2024 17:05:27 +0100 Subject: [PATCH 244/714] Add spelling exception (datee + error in Changelog) --- dev/tools/codespell/codespell-ignore.txt | 1 - dev/tools/codespell/codespell-lines-ignore.txt | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dev/tools/codespell/codespell-ignore.txt b/dev/tools/codespell/codespell-ignore.txt index 0c84807010b..c71e990a467 100644 --- a/dev/tools/codespell/codespell-ignore.txt +++ b/dev/tools/codespell/codespell-ignore.txt @@ -57,4 +57,3 @@ dur fonction espace methode -datee diff --git a/dev/tools/codespell/codespell-lines-ignore.txt b/dev/tools/codespell/codespell-lines-ignore.txt index 2c0fb95a96f..80e4f25e296 100644 --- a/dev/tools/codespell/codespell-lines-ignore.txt +++ b/dev/tools/codespell/codespell-lines-ignore.txt @@ -79,6 +79,7 @@ $object->periode = $dateperiod; $return .= '
'.$langs->trans("Payement").' : '.$this->type_payment.''; $sortfield = "datea"; + $sql = "SELECT p.rowid as id, p.entity, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount"; $sql .= " '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.date_ech as date, t.periode as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; $sql .= " , datee = ".(!empty($obj->datee) ? "'".$this->db->escape($obj->datee)."'" : "null"); $sql .= " AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)"; @@ -325,6 +326,7 @@ $usercanread = (($user->hasRight('stock', 'mouvement', 'lire'))); * The hook contaxt thirdpartycard has been renamed thirdpartycontact * The private array ->status_short, ->statuts and ->status_long are now array ->labelStatusShort and ->labelStatus everywhere. - New: Add proposals into referer page of thirdparty. +NEW: ModuleBuilder: Checkin comments begin and end before each actions for /F "tokens=2 delims=," %%i in ('tasklist /FI "IMAGENAME eq php.exe" /FO CSV /NH') do ( foreach ($TWeek as $week_number) { function checkES($IentOfi, $InumCta) From 587c4eb2ee90d45f058d766f2b2398eab9cb16e3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2024 17:24:52 +0100 Subject: [PATCH 245/714] Escape ouput --- htdocs/adherents/ldap.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index edfa8adbb2f..f94cc476321 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -120,12 +120,13 @@ print '
'; print ''; // Login -print ''; +print ''; // If there is a link to the unencrypted password, we show the value in database here so we can compare because it is shown nowhere else +// This is for very old situation. Password are now encrypted and $object->pass is empty. if (getDolGlobalString('LDAP_MEMBER_FIELD_PASSWORD')) { print ''; - print ''; + print ''; print "\n"; } From b6b4acf5f9feaf323d0f2692fd6b5d7f5d9df293 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2024 17:53:48 +0100 Subject: [PATCH 246/714] Complet security file --- SECURITY.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SECURITY.md b/SECURITY.md index 0cc37b96ce6..4d335d63737 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -104,3 +104,6 @@ Scope is the web application (backoffice) and the APIs. * SSL/TLS best practices * Invalid or missing SPF (Sender Policy Framework) records (Incomplete or missing SPF/DKIM/DMARC) * Physical or social engineering attempts or issues that require physical access to a victim’s computer/device +* Ability to include javascript into a page of the website using the website page editor are not qualified (this is the expected behaviour) +* Ability to execute PHP code on the server using the website using the website page editor by a user that own the super permission "add php code into pages" are not qualified (this is the expected behaviour). + From 8da1bc8b74791b9be692095a6fd3bb3467777135 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 14 Mar 2024 17:55:49 +0100 Subject: [PATCH 247/714] FIX variable assignment (PHPStan warning) --- htdocs/product/stock/class/productlot.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index f1941283842..f9787f8e3eb 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -1220,7 +1220,7 @@ class Productlot extends CommonObject $this->specimen = 1; $this->entity = $conf->entity; - $this->fk_product = null; + $this->fk_product = 0; $this->batch = ''; $this->eatby = $now - 100000; $this->sellby = $now - 100000; From 2c1be590d9f752ae456f6c6019b44c7c9b64de19 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 14 Mar 2024 18:03:32 +0100 Subject: [PATCH 248/714] FIX variables in project class (PHPStan Warnings) --- htdocs/projet/class/project.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 13d4c426bc7..e8911500494 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -2670,10 +2670,10 @@ class Project extends CommonObject $actioncomm->email_sender = ''; $actioncomm->email_to = $to; - $actioncomm->errors_to = $errors_to; + $actioncomm->errors_to = (string) $errors_to; $actioncomm->elementtype = 'project_task'; - $actioncomm->fk_element = $this->element; + $actioncomm->fk_element = (int) $this->element; $actioncomm->create($user); } else { @@ -2704,10 +2704,10 @@ class Project extends CommonObject $actioncomm->email_sender = ''; $actioncomm->email_to = $to; - $actioncomm->errors_to = $errors_to; + $actioncomm->errors_to = (string) $errors_to; $actioncomm->elementtype = 'project_task'; - $actioncomm->fk_element = $this->element; + $actioncomm->fk_element = (int) $this->element; $actioncomm->create($user); } From 385732c12d0eeb4992efed32fab5fa2d4c71eeda Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Thu, 14 Mar 2024 10:00:48 +0100 Subject: [PATCH 249/714] codespell and datee --- dev/tools/codespell/codespell-ignore.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/tools/codespell/codespell-ignore.txt b/dev/tools/codespell/codespell-ignore.txt index c71e990a467..0c84807010b 100644 --- a/dev/tools/codespell/codespell-ignore.txt +++ b/dev/tools/codespell/codespell-ignore.txt @@ -57,3 +57,4 @@ dur fonction espace methode +datee From fb5dab71caa1fec472376b8bd1603c7919cf07c6 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 14 Mar 2024 18:25:47 +0100 Subject: [PATCH 250/714] FIX variable assignment for newPayment (PHPStan warnings) --- htdocs/public/payment/newpayment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index d57987f4434..feec219703d 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1619,7 +1619,7 @@ if ($source == 'member' || $source == 'membersubscription') { // Set the new member type $member->typeid = $newtypeid; - $member->type = dol_getIdFromCode($db, $newtypeid, 'adherent_type', 'rowid', 'libelle'); + $member->type = (string) dol_getIdFromCode($db, $newtypeid, 'adherent_type', 'rowid', 'libelle'); // list member type if (!$action) { From 4577a4d43221479f21caeffb4a9d88d63134734c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 14 Mar 2024 18:40:31 +0100 Subject: [PATCH 251/714] fix phpstan is incompatible with --- htdocs/core/modules/fichinter/mod_arctic.php | 15 ++++++---- htdocs/core/modules/fichinter/mod_pacific.php | 13 +++++---- .../product/mod_codeproduct_leopard.php | 2 +- .../modules/product/modules_product.class.php | 4 +-- .../modules/project/mod_project_simple.php | 15 ---------- .../modules/project/task/mod_task_simple.php | 21 +++----------- .../project/task/mod_task_universal.php | 24 ++++----------- .../societe/mod_codeclient_elephant.php | 29 ++++++++----------- .../societe/mod_codeclient_leopard.php | 18 ++++++------ .../modules/societe/mod_codeclient_monkey.php | 18 ++++++------ .../societe/mod_codecompta_aquarium.php | 10 +++---- .../societe/mod_codecompta_digitaria.php | 16 +++++----- .../societe/mod_codecompta_panicum.php | 13 +++++---- .../modules/societe/modules_societe.class.php | 10 +++---- .../mod_commande_fournisseur_muguet.php | 4 +-- .../mod_commande_fournisseur_orchidee.php | 4 +-- phpstan.neon.dist | 1 - 17 files changed, 88 insertions(+), 129 deletions(-) diff --git a/htdocs/core/modules/fichinter/mod_arctic.php b/htdocs/core/modules/fichinter/mod_arctic.php index e8f79c9c084..33fce191c0e 100644 --- a/htdocs/core/modules/fichinter/mod_arctic.php +++ b/htdocs/core/modules/fichinter/mod_arctic.php @@ -121,11 +121,11 @@ class mod_arctic extends ModeleNumRefFicheinter /** * Return next free value * - * @param Societe $objsoc Object thirdparty - * @param Fichinter $object Object we need next value for - * @return string|0 Value if OK, 0 if KO + * @param Societe|string $objsoc Object thirdparty + * @param Fichinter|string $object Object we need next value for + * @return string|0 Value if OK, 0 if KO */ - public function getNextValue($objsoc = 0, $object = '') + public function getNextValue($objsoc = '', $object = '') { global $db, $conf; @@ -138,8 +138,11 @@ class mod_arctic extends ModeleNumRefFicheinter $this->error = 'NotConfigured'; return 0; } - - $numFinal = get_next_value($db, $mask, 'fichinter', 'ref', '', $objsoc, $object->datec); + $datec = ''; + if (!empty($object->datec)) { + $datec = $object->datec; + } + $numFinal = get_next_value($db, $mask, 'fichinter', 'ref', '', $objsoc, $datec); return $numFinal; } diff --git a/htdocs/core/modules/fichinter/mod_pacific.php b/htdocs/core/modules/fichinter/mod_pacific.php index f05a1ec320f..0f780ee2bb6 100644 --- a/htdocs/core/modules/fichinter/mod_pacific.php +++ b/htdocs/core/modules/fichinter/mod_pacific.php @@ -121,11 +121,11 @@ class mod_pacific extends ModeleNumRefFicheinter /** * Return next free value * - * @param Societe $objsoc Object thirdparty - * @param Fichinter $object Object we need next value for - * @return string Value if KO, <0 if KO + * @param Societe|string $objsoc Object thirdparty + * @param Fichinter|string $object Object we need next value for + * @return string Value if KO, <0 if KO */ - public function getNextValue($objsoc = 0, $object = '') + public function getNextValue($objsoc = '', $object = '') { global $db, $conf; @@ -147,7 +147,10 @@ class mod_pacific extends ModeleNumRefFicheinter } //$date=time(); - $date = $object->datec; + $date = ''; + if (!empty($object->datec)) { + $date = $object->datec; + } $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { diff --git a/htdocs/core/modules/product/mod_codeproduct_leopard.php b/htdocs/core/modules/product/mod_codeproduct_leopard.php index 126527a55bf..990d55b691e 100644 --- a/htdocs/core/modules/product/mod_codeproduct_leopard.php +++ b/htdocs/core/modules/product/mod_codeproduct_leopard.php @@ -85,7 +85,7 @@ class mod_codeproduct_leopard extends ModeleProductCode /** * Return an example of result returned by getNextValue * - * @param Product $objproduct Object product + * @param ?Product $objproduct Object product * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return next value */ diff --git a/htdocs/core/modules/product/modules_product.class.php b/htdocs/core/modules/product/modules_product.class.php index 893dc9dc2dc..6d9e87bf023 100644 --- a/htdocs/core/modules/product/modules_product.class.php +++ b/htdocs/core/modules/product/modules_product.class.php @@ -64,11 +64,11 @@ abstract class ModeleProductCode extends CommonNumRefGenerator /** * Return next value available * - * @param Product $objproduct Object product + * @param ?Product $objproduct Object product * @param int $type Type * @return string Value */ - public function getNextValue($objproduct = 0, $type = -1) + public function getNextValue($objproduct = null, $type = -1) { global $langs; return $langs->trans("Function_getNextValue_InModuleNotWorking"); diff --git a/htdocs/core/modules/project/mod_project_simple.php b/htdocs/core/modules/project/mod_project_simple.php index a153b3a590d..1ef51d36c95 100644 --- a/htdocs/core/modules/project/mod_project_simple.php +++ b/htdocs/core/modules/project/mod_project_simple.php @@ -165,19 +165,4 @@ class mod_project_simple extends ModeleNumRefProjects dol_syslog("mod_project_simple::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next reference not yet used as a reference - * - * @param Societe $objsoc Object third party - * @param Project $project Object project - * @return string|-1 Next not used reference, -1 if KO - */ - public function project_get_num($objsoc = 0, $project = '') - { - // phpcs:enable - return $this->getNextValue($objsoc, $project); - } } diff --git a/htdocs/core/modules/project/task/mod_task_simple.php b/htdocs/core/modules/project/task/mod_task_simple.php index 0eea8129ca3..e75fd1b5e8a 100644 --- a/htdocs/core/modules/project/task/mod_task_simple.php +++ b/htdocs/core/modules/project/task/mod_task_simple.php @@ -1,6 +1,7 @@ * Copyright (C) 2010 Laurent Destailleur + * 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 @@ -122,9 +123,9 @@ class mod_task_simple extends ModeleNumRefTask /** * Return next value * - * @param Societe $objsoc Object third party - * @param Task $object Object Task - * @return string|-1 Value if OK, -1 if KO + * @param Societe|string $objsoc Object third party + * @param Task|string $object Object Task + * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $object) { @@ -161,18 +162,4 @@ class mod_task_simple extends ModeleNumRefTask dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next reference not yet used as a reference - * - * @param Societe $objsoc Object third party - * @param Task $object Object task - * @return string|-1 Next not used reference, -1 if KO - */ - public function task_get_num($objsoc = 0, $object = '') - { - return $this->getNextValue($objsoc, $object); - } } diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php index 95c7d392ed0..52b7b9b18d9 100644 --- a/htdocs/core/modules/project/task/mod_task_universal.php +++ b/htdocs/core/modules/project/task/mod_task_universal.php @@ -1,5 +1,6 @@ + * 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 @@ -119,11 +120,11 @@ class mod_task_universal extends ModeleNumRefTask /** * Return next value * - * @param Societe $objsoc Object third party - * @param Task $object Object task - * @return string|0 Value if OK, 0 if KO + * @param Societe|string $objsoc Object third party + * @param Task|string $object Object task + * @return string|0 Value if OK, 0 if KO */ - public function getNextValue($objsoc, $object) + public function getNextValue($objsoc = '', $object = '') { global $db, $conf; @@ -141,19 +142,4 @@ class mod_task_universal extends ModeleNumRefTask return $numFinal; } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next reference not yet used as a reference - * - * @param Societe $objsoc Object third party - * @param Task $object Object task - * @return string|0 Next not used reference, 0 if KO - */ - public function project_get_num($objsoc = 0, $object = '') - { - // phpcs:enable - return $this->getNextValue($objsoc, $object); - } } diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index f83ec00dc77..6e1d61e165d 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -124,14 +124,13 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode /** * Return an example of result returned by getNextValue * - * @param Translate $langs Object langs - * @param Societe $objsoc Object thirdparty - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) - * @return string Return string example + * @param Translate $langs Object langs + * @param Societe|string $objsoc Object thirdparty + * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string Return string example */ - public function getExample($langs, $objsoc = 0, $type = -1) + public function getExample($langs, $objsoc = '', $type = -1) { - $error = 0; $examplecust = ''; $examplesup = ''; $errmsg = array( @@ -150,12 +149,10 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode if (!$examplecust && ($cssforerror == 'error' || $this->error != 'NotConfigured')) { $langs->load("errors"); $examplecust = ''.$langs->trans('ErrorBadMask').''; - $error = 1; } if (in_array($examplecust, $errmsg)) { $langs->load("errors"); $examplecust = ''.$langs->trans($examplecust).''; - $error = 1; } } if ($type != 0) { @@ -163,12 +160,10 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode if (!$examplesup && ($cssforerror == 'error' || $this->error != 'NotConfigured')) { $langs->load("errors"); $examplesup = ''.$langs->trans('ErrorBadMask').''; - $error = 1; } if (in_array($examplesup, $errmsg)) { $langs->load("errors"); $examplesup = ''.$langs->trans($examplesup).''; - $error = 1; } } @@ -184,23 +179,23 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode /** * Return next value * - * @param Societe $objsoc Object third party - * @param int $type Client ou fournisseur (0:customer, 1:supplier) - * @return string|-1 Value if OK, '' if module not configured, -1 if KO + * @param Societe|string $objsoc Object third party + * @param int $type Client ou fournisseur (0:customer, 1:supplier) + * @return string|-1 Value if OK, '' if module not configured, -1 if KO */ - public function getNextValue($objsoc = 0, $type = -1) + public function getNextValue($objsoc = '', $type = -1) { - global $db, $conf; + global $db; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Get Mask value $mask = ''; if ($type == 0) { - $mask = !getDolGlobalString('COMPANY_ELEPHANT_MASK_CUSTOMER') ? '' : $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; + $mask = getDolGlobalString('COMPANY_ELEPHANT_MASK_CUSTOMER'); } if ($type == 1) { - $mask = !getDolGlobalString('COMPANY_ELEPHANT_MASK_SUPPLIER') ? '' : $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; + $mask = getDolGlobalString('COMPANY_ELEPHANT_MASK_SUPPLIER'); } if (!$mask) { $this->error = 'NotConfigured'; diff --git a/htdocs/core/modules/societe/mod_codeclient_leopard.php b/htdocs/core/modules/societe/mod_codeclient_leopard.php index 98343987765..1f592057adb 100644 --- a/htdocs/core/modules/societe/mod_codeclient_leopard.php +++ b/htdocs/core/modules/societe/mod_codeclient_leopard.php @@ -77,12 +77,12 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode /** * Return an example of result returned by getNextValue * - * @param Translate $langs Object langs - * @param Societe $objsoc Object thirdparty - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) - * @return string Return string example + * @param Translate $langs Object langs + * @param Societe|string $objsoc Object thirdparty + * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string Return string example */ - public function getExample($langs, $objsoc = 0, $type = -1) + public function getExample($langs, $objsoc = '', $type = -1) { return ''; } @@ -90,11 +90,11 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode /** * Return an example of result returned by getNextValue * - * @param Societe $objsoc Object thirdparty - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) - * @return string Return next value + * @param Societe|string $objsoc Object thirdparty + * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string Return next value */ - public function getNextValue($objsoc = 0, $type = -1) + public function getNextValue($objsoc = '', $type = -1) { return ''; } diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index 9019ff44d29..e46b5dc3f7a 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -76,12 +76,12 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode /** * Return an example of result returned by getNextValue * - * @param Translate $langs Object langs - * @param Societe $objsoc Object thirdparty - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) - * @return string Return string example + * @param Translate $langs Object langs + * @param Societe|string $objsoc Object thirdparty + * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string Return string example */ - public function getExample($langs, $objsoc = 0, $type = -1) + public function getExample($langs, $objsoc = '', $type = -1) { return $this->prefixcustomer.'0901-00001
'.$this->prefixsupplier.'0901-00001'; } @@ -90,11 +90,11 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode /** * Return next value * - * @param Societe $objsoc Object third party - * @param int $type Client ou fournisseur (1:client, 2:fournisseur) - * @return string|-1 Value if OK, '' if module not configured, -1 if KO + * @param Societe|string $objsoc Object third party + * @param int $type Client ou fournisseur (1:client, 2:fournisseur) + * @return string|-1 Value if OK, '' if module not configured, -1 if KO */ - public function getNextValue($objsoc = 0, $type = -1) + public function getNextValue($objsoc = '', $type = -1) { global $db; diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index 264ee51741b..64b65be81e5 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -130,12 +130,12 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode /** * Return an example of result returned by getNextValue * - * @param Translate $langs Object langs - * @param Societe $objsoc Object thirdparty - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) - * @return string Return string example + * @param Translate $langs Object langs + * @param Societe|string $objsoc Object thirdparty + * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string Return string example */ - public function getExample($langs, $objsoc = 0, $type = -1) + public function getExample($langs, $objsoc = '', $type = -1) { $s = ''; $s .= $this->prefixcustomeraccountancycode.'CUSTCODE'; diff --git a/htdocs/core/modules/societe/mod_codecompta_digitaria.php b/htdocs/core/modules/societe/mod_codecompta_digitaria.php index fc9feb6b25f..a902fc80ac8 100644 --- a/htdocs/core/modules/societe/mod_codecompta_digitaria.php +++ b/htdocs/core/modules/societe/mod_codecompta_digitaria.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2010 Laurent Destailleur * Copyright (C) 2019 Alexandre Spangaro - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-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 @@ -160,12 +160,12 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode /** * Return an example of result returned by getNextValue * - * @param Translate $langs Object langs - * @param Societe $objsoc Object thirdparty - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) - * @return string Example + * @param Translate $langs Object langs + * @param Societe|string $objsoc Object thirdparty + * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string Example */ - public function getExample($langs, $objsoc = 0, $type = -1) + public function getExample($langs, $objsoc = '', $type = -1) { global $conf, $mysoc; @@ -188,7 +188,7 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode * * @param DoliDB $db Database handler * @param Societe $societe Third party object - * @param int $type 'customer' or 'supplier' + * @param string $type 'customer' or 'supplier' * @return int >=0 if OK, <0 if KO */ public function get_code($db, $societe, $type = '') @@ -277,7 +277,7 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode * * @param DoliDB $db Database handler * @param string $code Code of third party - * @param int $type 'customer' or 'supplier' + * @param string $type 'customer' or 'supplier' * @return int >=0 if OK, <0 if KO */ public function checkIfAccountancyCodeIsAlreadyUsed($db, $code, $type = '') diff --git a/htdocs/core/modules/societe/mod_codecompta_panicum.php b/htdocs/core/modules/societe/mod_codecompta_panicum.php index 1cec3d33dad..9dd740313f9 100644 --- a/htdocs/core/modules/societe/mod_codecompta_panicum.php +++ b/htdocs/core/modules/societe/mod_codecompta_panicum.php @@ -1,6 +1,7 @@ * Copyright (C) 2010 Laurent Destailleur + * 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 @@ -71,12 +72,12 @@ class mod_codecompta_panicum extends ModeleAccountancyCode /** * Return an example of result returned by getNextValue * - * @param Translate $langs Object langs - * @param Societe $objsoc Object thirdparty - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) - * @return string Example + * @param Translate $langs Object langs + * @param Societe|string $objsoc Object thirdparty + * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string Example */ - public function getExample($langs, $objsoc = 0, $type = -1) + public function getExample($langs, $objsoc = '', $type = -1) { return ''; } @@ -87,7 +88,7 @@ class mod_codecompta_panicum extends ModeleAccountancyCode * * @param DoliDB $db Database handler * @param Societe $societe Third party object - * @param int $type 'customer' or 'supplier' + * @param string $type 'customer' or 'supplier' * @return int >=0 if OK, <0 if KO */ public function get_code($db, $societe, $type = '') diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php index dff42b63e86..8cc1ddd8082 100644 --- a/htdocs/core/modules/societe/modules_societe.class.php +++ b/htdocs/core/modules/societe/modules_societe.class.php @@ -72,11 +72,11 @@ abstract class ModeleThirdPartyCode extends CommonNumRefGenerator /** * Return next value available * - * @param Societe $objsoc Object thirdparty - * @param int $type Type - * @return string Value + * @param Societe|string $objsoc Object thirdparty + * @param int $type Type + * @return string Value */ - public function getNextValue($objsoc = 0, $type = -1) + public function getNextValue($objsoc = '', $type = -1) { global $langs; return $langs->trans("Function_getNextValue_InModuleNotWorking"); @@ -254,7 +254,7 @@ abstract class ModeleAccountancyCode extends CommonNumRefGenerator * * @param DoliDB $db Database handler * @param Societe $societe Third party object - * @param int $type 'customer' or 'supplier' + * @param string $type 'customer' or 'supplier' * @return int >=0 if OK, <0 if KO */ public function get_code($db, $societe, $type = '') diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php index 740dbfbfd17..cd6d9f78d0e 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php @@ -131,11 +131,11 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders /** * Return next value * - * @param Societe $objsoc Object third party + * @param Societe|string $objsoc Object third party * @param CommandeFournisseur $object Object * @return string Value if OK, 0 if KO */ - public function getNextValue($objsoc = 0, $object = '') + public function getNextValue($objsoc = '', $object = '') { global $db, $conf; diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php index db138369a53..03f948de1c1 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php @@ -122,11 +122,11 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders /** * Return next value * - * @param Societe $objsoc Object third party + * @param Societe|string $objsoc Object third party * @param CommandeFournisseur $object Object * @return string|0 Value if OK, 0 if KO */ - public function getNextValue($objsoc = 0, $object = '') + public function getNextValue($objsoc = '', $object = '') { global $db, $conf; diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 78867274e30..c354dfd5d84 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -54,7 +54,6 @@ parameters: - '#(\$force_dolibarr_lib|\$dolibarr_main_db).*in empty\(\) is never defined.#' - '#Sprain\\SwissQrBill\\#' - '#Constructor of class .* has an unused parameter #' - - '#Default value of the parameter#' internalErrorsCountLimit: 50 cache: nodesByFileCountMax: 512 From f4c1d824461f66366c5bd040cd4caac264084308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Thu, 14 Mar 2024 18:40:56 +0100 Subject: [PATCH 252/714] add hook to list category from external module --- htdocs/categories/viewcat.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index efcd10ddbb9..8466119ffd8 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -102,7 +102,7 @@ if ($confirm == 'no') { } } -$parameters = array(); +$parameters = array('type' => $type, 'id' => $id, 'label' => $label); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Remove element from category if ($id > 0 && $removeelem > 0 && $action == 'unlink') { @@ -1355,6 +1355,10 @@ if ($type == Categorie::TYPE_TICKET) { } } +// Note that $action and $object may have been modified by some hooks +$parameters = array('type' => $type, 'id' => $id, 'label' => $label); +$reshook = $hookmanager->executeHooks('addMoreCategorieList', $parameters, $object, $action); + // End of page llxFooter(); $db->close(); From f8eb9da0b57ceeb763d0f1436bd23aec49925364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 14 Mar 2024 18:43:22 +0100 Subject: [PATCH 253/714] fix phpstan is incompatible with --- .../doc/doc_generic_supplier_invoice_odt.modules.php | 4 ++-- .../doc/doc_generic_supplier_order_odt.modules.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php index d149b5ff576..e03a9fcb835 100644 --- a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php @@ -4,7 +4,7 @@ * Copyright (C) 2014 Marcos García * Copyright (C) 2016 Charlie Benke * Copyright (C) 2018-2019 Philippe Grand - * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2019 Tim Otte * * This program is free software; you can redistribute it and/or modify @@ -123,7 +123,7 @@ class doc_generic_supplier_invoice_odt extends ModelePDFSuppliersInvoices // List of directories area $texte .= '
'; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 7557a9d89ce..f9cde0e1d1a 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1004,6 +1004,8 @@ class FormMail extends Form $out .= ''; $out .= '\n"; $out .= ""; if ($nbofsuggested > 0) { + $quantityToBeDelivered = 0; echo "
".$langs->trans("SearchIntoBatch").": $nbofsuggested

'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("Login").' / '.$langs->trans("Id").''.dol_escape_htmltag($object->login).' 
'.$langs->trans("LDAPFieldPasswordNotCrypted").''.$object->pass.''.dol_escape_htmltag($object->pass).'
'; $texttitle = $langs->trans("ListOfDirectories"); - $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH))); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim(getDolGlobalString('SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH')))); $listoffiles = array(); diff --git a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php index a0963e88c04..049683aa1f5 100644 --- a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php +++ b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php @@ -4,7 +4,7 @@ * Copyright (C) 2014 Marcos García * Copyright (C) 2016 Charlie Benke * Copyright (C) 2018-2019 Philippe Grand - * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2019 Tim Otte * * This program is free software; you can redistribute it and/or modify @@ -123,7 +123,7 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders // List of directories area $texte .= '
'; $texttitle = $langs->trans("ListOfDirectories"); - $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->SUPPLIER_ORDER_ADDON_PDF_ODT_PATH))); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim(getDolGlobalString('SUPPLIER_ORDER_ADDON_PDF_ODT_PATH')))); $listoffiles = array(); foreach ($listofdir as $key => $tmpdir) { $tmpdir = trim($tmpdir); From ad13f6fc76d32d363a54dca9142cd67f02500e62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 14 Mar 2024 18:46:17 +0100 Subject: [PATCH 254/714] fix phpstan is incompatible with --- htdocs/fourn/class/fournisseur.facture.class.php | 6 +++--- phpstan.neon.dist | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 5130c4ad2bd..cd90cf86179 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2313,13 +2313,13 @@ class FactureFournisseur extends CommonInvoice * @param double $txlocaltax2 LocalTax2 Rate * @param double $qty Quantity * @param int $idproduct Id produit - * @param double $price_base_type HT or TTC + * @param string $price_base_type HT or TTC * @param int $info_bits Miscellaneous information of line * @param int $type Type of line (0=product, 1=service) * @param double $remise_percent Percentage discount of the line * @param int $notrigger Disable triggers - * @param integer $date_start Date start of service - * @param integer $date_end Date end of service + * @param int|string $date_start Date start of service + * @param int|string $date_end Date end of service * @param array $array_options extrafields array * @param int|null $fk_unit Code of the unit to use. Null to use the default one * @param double $pu_devise Amount in currency diff --git a/phpstan.neon.dist b/phpstan.neon.dist index c354dfd5d84..78867274e30 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -54,6 +54,7 @@ parameters: - '#(\$force_dolibarr_lib|\$dolibarr_main_db).*in empty\(\) is never defined.#' - '#Sprain\\SwissQrBill\\#' - '#Constructor of class .* has an unused parameter #' + - '#Default value of the parameter#' internalErrorsCountLimit: 50 cache: nodesByFileCountMax: 512 From a9847bb44c166d25a66df6e39c2d3dfee84cb021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 14 Mar 2024 19:02:16 +0100 Subject: [PATCH 255/714] fix phpstan is incompatible with --- .../core/modules/product/mod_codeproduct_elephant.php | 10 +++++----- .../core/modules/product/mod_codeproduct_leopard.php | 8 ++++---- htdocs/core/modules/product/modules_product.class.php | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/core/modules/product/mod_codeproduct_elephant.php b/htdocs/core/modules/product/mod_codeproduct_elephant.php index 644808826d5..397312fbb5f 100644 --- a/htdocs/core/modules/product/mod_codeproduct_elephant.php +++ b/htdocs/core/modules/product/mod_codeproduct_elephant.php @@ -118,12 +118,12 @@ class mod_codeproduct_elephant extends ModeleProductCode /** * Return an example of result returned by getNextValue * - * @param Translate $langs Object langs - * @param Product $objproduct Object product - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) - * @return string Return string example + * @param Translate $langs Object langs + * @param Product|string $objproduct Object product + * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string Return string example */ - public function getExample($langs, $objproduct = null, $type = -1) + public function getExample($langs, $objproduct = '', $type = -1) { $exampleproduct = $exampleservice = ''; diff --git a/htdocs/core/modules/product/mod_codeproduct_leopard.php b/htdocs/core/modules/product/mod_codeproduct_leopard.php index 990d55b691e..d8ae7f91676 100644 --- a/htdocs/core/modules/product/mod_codeproduct_leopard.php +++ b/htdocs/core/modules/product/mod_codeproduct_leopard.php @@ -85,11 +85,11 @@ class mod_codeproduct_leopard extends ModeleProductCode /** * Return an example of result returned by getNextValue * - * @param ?Product $objproduct Object product - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) - * @return string Return next value + * @param Product|string $objproduct Object product + * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string Return next value */ - public function getNextValue($objproduct = null, $type = -1) + public function getNextValue($objproduct = '', $type = -1) { return ''; } diff --git a/htdocs/core/modules/product/modules_product.class.php b/htdocs/core/modules/product/modules_product.class.php index 6d9e87bf023..cfe79891429 100644 --- a/htdocs/core/modules/product/modules_product.class.php +++ b/htdocs/core/modules/product/modules_product.class.php @@ -64,11 +64,11 @@ abstract class ModeleProductCode extends CommonNumRefGenerator /** * Return next value available * - * @param ?Product $objproduct Object product - * @param int $type Type - * @return string Value + * @param Product|string $objproduct Object product + * @param int $type Type + * @return string Value */ - public function getNextValue($objproduct = null, $type = -1) + public function getNextValue($objproduct = '', $type = -1) { global $langs; return $langs->trans("Function_getNextValue_InModuleNotWorking"); From 2a7eac534e481a81a3138bf0c2fbd81682e59526 Mon Sep 17 00:00:00 2001 From: MDW Date: Thu, 14 Mar 2024 03:02:54 +0100 Subject: [PATCH 256/714] Fix call to rollback (was NOOP property access) --- htdocs/compta/cashcontrol/cashcontrol_card.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index fe4d5a15f77..74cce92938d 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -6,6 +6,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Marcos García * Copyright (C) 2018 Andreu Bisquerra + * 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 @@ -68,7 +69,7 @@ if ($contextpage == 'takepos') { $_GET['optioncss'] = 'print'; } -$arrayofpaymentmode = array('cash'=>'Cash', 'cheque'=>'Cheque', 'card'=>'CreditCard'); +$arrayofpaymentmode = array('cash' => 'Cash', 'cheque' => 'Cheque', 'card' => 'CreditCard'); $arrayofposavailable = array(); if (isModEnabled('cashdesk')) { @@ -180,7 +181,7 @@ if ($action == "start") { $db->commit(); $action = "view"; } else { - $db->rollback; + $db->rollback(); $action = "view"; } } From 6d2ad5b180a4d07f8dd6b5e34bddf0b82208fff0 Mon Sep 17 00:00:00 2001 From: MDW Date: Thu, 14 Mar 2024 03:04:22 +0100 Subject: [PATCH 257/714] Comment NOOP access to unset property --- htdocs/fichinter/card-rec.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index 8e7aad352be..4c71562da9b 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -10,6 +10,7 @@ * Copyright (C) 2016-2018 Charlie Benke * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2024 William Mead + * 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 @@ -730,9 +731,7 @@ if ($action == 'create') { // Show product and description if (isset($object->lines[$i]->product_type)) { $type = $object->lines[$i]->product_type; - } else { - $object->lines[$i]->fk_product_type; - } + } // else { $object->lines[$i]->fk_product_type; } // Try to enhance type detection using date_start and date_end for free lines when type // was not saved. if (!empty($objp->date_start)) { From b28f6a2cbad8ebc5e9516a148c868acf8a8721e9 Mon Sep 17 00:00:00 2001 From: MDW Date: Thu, 14 Mar 2024 03:06:41 +0100 Subject: [PATCH 258/714] Enable PhanNoopProperty --- dev/tools/phan/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index 4771e953a36..a80290c1fb0 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -549,7 +549,7 @@ return [ // 'PhanSyntaxReturnValueInVoid', // 'PhanTypeInstantiateTraitStaticOrSelf', // 'PhanUndeclaredInvokeInCallable', - 'PhanNoopProperty', + // 'PhanNoopProperty', 'PhanNoopVariable', // 'PhanPluginPrintfUnusedArgument', // 'PhanSyntaxReturnExpectedValue', From 49416784ce3646fd942d8164e11d8968f74b04fd Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:28:10 +0100 Subject: [PATCH 259/714] Fix PhanPluginSuspiciousParamPosition --- dev/tools/phan/baseline.txt | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 68fc0c015e7..c56fd81b5d6 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -9,8 +9,9 @@ */ return [ // # Issue statistics: - // PhanPluginSuspiciousParamPosition : 45+ occurrences + // PhanPluginDuplicateIfStatements : 30+ occurrences // PhanParamSignatureMismatch : 25+ occurrences + // PhanPluginSuspiciousParamPosition : 15+ occurrences // PhanUndeclaredConstant : 15+ occurrences // PhanPluginDuplicateExpressionBinaryOp : 10+ occurrences // PhanTypeArraySuspiciousNull : 10+ occurrences @@ -33,34 +34,21 @@ return [ 'htdocs/adherents/stats/geo.php' => ['PhanTypeArraySuspiciousNull'], 'htdocs/adherents/type.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/admin/receiptprinter.php' => ['PhanRedefineFunctionInternal'], - 'htdocs/admin/translation.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/api/class/api_documents.class.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/barcode/printsheet.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/categories/class/api_categories.class.php' => ['PhanAccessMethodProtected'], 'htdocs/categories/viewcat.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/collab/index.php' => ['PhanParamTooMany'], - 'htdocs/comm/action/index.php' => ['PhanPluginSuspiciousParamPosition', 'PhanTypeArraySuspiciousNull', 'PhanTypeInvalidUnaryOperandNumeric'], + 'htdocs/comm/action/index.php' => ['PhanTypeArraySuspiciousNull', 'PhanTypeInvalidUnaryOperandNumeric'], 'htdocs/comm/mailing/card.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/comm/mailing/cibles.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/comm/mailing/info.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/compta/accounting-files.php' => ['PhanTypeInvalidUnaryOperandNumeric'], - 'htdocs/compta/bank/various_payment/card.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/compta/bank/various_payment/document.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/compta/bank/various_payment/info.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/compta/cashcontrol/cashcontrol_card.php' => ['PhanPluginDuplicateExpressionBinaryOp'], - 'htdocs/compta/facture/agenda-rec.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/compta/facture/card-rec.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/compta/prelevement/class/bonprelevement.class.php' => ['PhanParamTooMany'], 'htdocs/compta/prelevement/create.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/compta/sociales/class/paymentsocialcontribution.class.php' => ['PhanTypeInvalidUnaryOperandNumeric'], - 'htdocs/compta/sociales/document.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/compta/sociales/info.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/compta/sociales/note.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/compta/tva/class/paymentvat.class.php' => ['PhanTypeInvalidUnaryOperandNumeric'], - 'htdocs/compta/tva/document.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/core/actions_massactions.inc.php' => ['PhanPluginSuspiciousParamOrder'], 'htdocs/core/class/commondocgenerator.class.php' => ['PhanTypeArraySuspiciousNull'], - 'htdocs/core/class/commonobject.class.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/core/class/evalmath.class.php' => ['PhanPluginUnsafeEval'], 'htdocs/core/class/html.form.class.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/core/class/html.formmail.class.php' => ['PhanNoopArray'], @@ -68,7 +56,6 @@ return [ 'htdocs/core/db/mysqli.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/core/db/pgsql.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/core/db/sqlite3.class.php' => ['PhanParamSignatureMismatch'], - 'htdocs/core/filemanagerdol/connectors/php/connector.lib.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/core/get_info.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/core/lib/files.lib.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/core/lib/functions.lib.php' => ['PhanParamTooMany', 'PhanPluginAlwaysReturnFunction', 'PhanPluginUnsafeEval', 'PhanRedefineFunctionInternal'], @@ -78,7 +65,6 @@ return [ 'htdocs/core/menus/standard/eldy_menu.php' => ['PhanParamSuspiciousOrder'], 'htdocs/core/menus/standard/empty.php' => ['PhanParamSuspiciousOrder'], 'htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php' => ['PhanParamSignatureMismatch'], - 'htdocs/core/modules/import/import_xlsx.modules.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/core/modules/member/doc/pdf_standard.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/core/modules/movement/doc/pdf_standard.modules.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/core/modules/mrp/doc/pdf_vinci.modules.php' => ['PhanTypeArraySuspiciousNull'], @@ -87,18 +73,10 @@ return [ 'htdocs/don/class/don.class.php' => ['PhanParamTooMany'], 'htdocs/expensereport/class/paymentexpensereport.class.php' => ['PhanTypeInvalidUnaryOperandNumeric'], 'htdocs/fourn/class/api_supplier_invoices.class.php' => ['PhanPluginSuspiciousParamOrder'], - 'htdocs/fourn/facture/card-rec.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/intracommreport/list.php' => ['PhanAccessPropertyStaticAsNonStatic'], - 'htdocs/loan/card.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/loan/class/paymentloan.class.php' => ['PhanTypeInvalidUnaryOperandNumeric'], - 'htdocs/loan/document.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/loan/info.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/loan/note.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/loan/payment/card.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/loan/schedule.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/mrp/class/mo.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/product/admin/product_tools.php' => ['PhanNoopStringLiteral'], - 'htdocs/product/card.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/projet/tasks/list.php' => ['PhanTypeArraySuspiciousNull'], 'htdocs/public/bookcal/index.php' => ['PhanTypeInvalidUnaryOperandNumeric'], 'htdocs/public/opensurvey/index.php' => ['PhanPluginSuspiciousParamOrder'], From 0efd899509de91afff51d3d828718ee8b6de98a1 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:28:14 +0100 Subject: [PATCH 260/714] Fix PhanPluginSuspiciousParamPosition --- htdocs/admin/translation.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 0dbeab0db6d..307f4e3a579 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2020 Laurent Destailleur * Copyright (C) 2009-2017 Regis Houssin * Copyright (C) 2017 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 @@ -301,7 +302,9 @@ foreach ($modulesdir as $keydir => $tmpsearchdir) { } //var_dump($i.' - '.$keydir.' - '.$dir_lang_osencoded.' -> '.$moduledirname . ' / ' . $tmpfile.' -> '.$langkey); + // @phan-suppress-next-line PhanPluginSuspiciousParamPosition $result = $newlang->load($langkey, 0, 0, '', 0); // Load translation files + database overwrite + // @phan-suppress-next-line PhanPluginSuspiciousParamPosition $result = $newlangfileonly->load($langkey, 0, 0, '', 1); // Load translation files only if ($result < 0) { print 'Failed to load language file '.$tmpfile.'
'."\n"; @@ -313,6 +316,7 @@ foreach ($modulesdir as $keydir => $tmpsearchdir) { } //print 'After loading lang '.$langkey.', newlang has '.count($newlang->tab_translate).' records
'."\n"; + // @phan-suppress-next-line PhanPluginSuspiciousParamPosition $result = $langsenfileonly->load($langkey, 0, 0, '', 1); // Load translation files only } $i++; From a7274050d205b0cd9d9602987ae44280080eaf37 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:28:17 +0100 Subject: [PATCH 261/714] Fix PhanPluginSuspiciousParamPosition --- htdocs/comm/action/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 68e6b4d7169..92bd8159976 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -302,8 +302,8 @@ if (empty($user->conf->AGENDA_DISABLE_EXT)) { 'src' => getDolUserString($source), 'name' => dol_string_nohtmltag(getDolUserString($name)), 'offsettz' => (int) (empty($user->conf->$offsettz) ? 0 : $user->conf->$offsettz), - // @phan-suppress-next-line PhanPluginSuspiciousParamPosition 'color' => dol_string_nohtmltag(getDolUserString($color)), + // @phan-suppress-next-line PhanPluginSuspiciousParamPosition 'default' => dol_string_nohtmltag(getDolUserString($default)), 'buggedfile' => dol_string_nohtmltag(isset($user->conf->buggedfile) ? $user->conf->buggedfile : '') ); From 06cf35634af3cc6f90d2fce63f86ba323eb21085 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:28:19 +0100 Subject: [PATCH 262/714] Fix PhanPluginSuspiciousParamPosition --- htdocs/compta/prelevement/create.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 00934b0f0e6..a6b326ac456 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -6,6 +6,7 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018-2023 Frédéric France * Copyright (C) 2019 Markus Welters + * 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 @@ -241,6 +242,7 @@ if ($type == 'bank-transfer') { llxHeader('', $title); +// @phan-suppress-next-line PhanPluginSuspiciousParamPosition $head = bon_prelevement_prepare_head($bprev, $bprev->nbOfInvoiceToPay($type), $bprev->nbOfInvoiceToPay($type, 'salary')); if ($type) { print dol_get_fiche_head($head, (!GETPOSTISSET('sourcetype') ? 'invoice' : 'salary'), $langs->trans("Invoices"), -1, $bprev->picto); From 27e89df94db179b3e4ecdb45f78f85d6eb29e6be Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:28:20 +0100 Subject: [PATCH 263/714] Fix PhanPluginSuspiciousParamPosition --- htdocs/core/class/commonobject.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 6d3d2c65557..dba5ffd306a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9785,6 +9785,7 @@ abstract class CommonObject foreach ($fieldvalues as $k => $v) { $keys[$k] = $k; $value = $this->fields[$k]; + // @phan-suppress-next-line PhanPluginSuspiciousParamPosition $values[$k] = $this->quote($v, $value); // May return string 'NULL' if $value is null } @@ -10087,7 +10088,9 @@ abstract class CommonObject foreach ($fieldvalues as $k => $v) { $keys[$k] = $k; $value = $this->fields[$k]; + // @phan-suppress-next-line PhanPluginSuspiciousParamPosition $values[$k] = $this->quote($v, $value); + // @phan-suppress-next-line PhanPluginSuspiciousParamPosition $tmp[] = $k.'='.$this->quote($v, $this->fields[$k]); } From bd0447a8a3544eea86bdc6bc02d4744111350a85 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:28:22 +0100 Subject: [PATCH 264/714] Fix PhanPluginSuspiciousParamPosition --- htdocs/core/filemanagerdol/connectors/php/connector.lib.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/filemanagerdol/connectors/php/connector.lib.php b/htdocs/core/filemanagerdol/connectors/php/connector.lib.php index 656ca060471..afdfa2b6ffd 100644 --- a/htdocs/core/filemanagerdol/connectors/php/connector.lib.php +++ b/htdocs/core/filemanagerdol/connectors/php/connector.lib.php @@ -551,8 +551,8 @@ function GetParentFolder($folderPath) /** * CreateServerFolder * - * @param string $folderPath Folder - * @param string $lastFolder Folder + * @param string $folderPath Folder - Folder to create (recursively) + * @param ?string $lastFolder Internal - Child Folder we are creating, prevents recursion * @return string ''=success, error message otherwise */ function CreateServerFolder($folderPath, $lastFolder = null) @@ -585,6 +585,7 @@ function CreateServerFolder($folderPath, $lastFolder = null) return "Can't create $folderPath directory"; } + // @phan-suppress-next-line PhanPluginSuspiciousParamPosition $sErrorMsg = CreateServerFolder($sParent, $folderPath); if ($sErrorMsg != '') { return $sErrorMsg; From 8ff08adbbfbb6e92642dd9891c1b61ccd3099c9e Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:28:25 +0100 Subject: [PATCH 265/714] Fix PhanPluginSuspiciousParamPosition --- htdocs/core/modules/import/import_xlsx.modules.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index def42e03d9c..6a6d33df252 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -3,6 +3,7 @@ * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2012-2016 Juanjo Menent + * 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 @@ -519,6 +520,7 @@ class ImportXlsx extends ModeleImports // @phan-suppress-next-line PhanPluginSuspiciousParamPosition $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); } elseif (!empty($objimport->array_import_convertvalue[0][$val]['element'])) { + // @phan-suppress-next-line PhanPluginSuspiciousParamPosition $this->errors[$error]['lib'] = $langs->trans('ErrorFieldRefNotIn', $key, $newval, $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['element'])); } else { $this->errors[$error]['lib'] = 'ErrorBadDefinitionOfImportProfile'; From 4d4aa6b4736f5fa942a44f1fe67648064be383d4 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:31:41 +0100 Subject: [PATCH 266/714] Fix PhanPluginSuspiciousParamPosition --- htdocs/product/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index d18442094ca..3b028e50d73 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -974,6 +974,7 @@ if (empty($reshook)) { } else { if (count($clone->errors)) { setEventMessages($clone->error, $clone->errors, 'errors'); + // @phan-suppress-next-line PhanPluginSuspiciousParamPosition dol_print_error($db, $clone->errors); } else { setEventMessages($langs->trans($clone->error), null, 'errors'); From 4719e1a28041cdbdaa75f18585a9a42d761df560 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:49:52 +0100 Subject: [PATCH 267/714] Fix PhanPluginSuspiciousParamPosition by renaming arg (local assign) --- htdocs/comm/mailing/card.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 559530a6873..216ec9bbdd8 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -1023,20 +1023,20 @@ if ($action == 'create') { $morehtmlref .= $form->editfieldval("", 'title', $object->title, $object, $user->hasRight('mailing', 'creer'), 'string', '', null, null, '', 1); $morehtmlref .= ''; - $morehtmlright = ''; + $morehtmlstatus = ''; $nbtry = $nbok = 0; if ($object->status == 2 || $object->status == 3) { $nbtry = $object->countNbOfTargets('alreadysent'); $nbko = $object->countNbOfTargets('alreadysentko'); - $morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail; + $morehtmlstatus .= ' ('.$nbtry.'/'.$object->nbemail; if ($nbko) { - $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error"); + $morehtmlstatus .= ' - '.$nbko.' '.$langs->trans("Error"); } - $morehtmlright .= ')   '; + $morehtmlstatus .= ')   '; } - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus); print '
'; print '
'; @@ -1345,20 +1345,20 @@ if ($action == 'create') { $morehtmlref .= $form->editfieldval("", 'title', $object->title, $object, $user->hasRight('mailing', 'creer'), 'string', '', null, null, '', 1); $morehtmlref .= '
'; - $morehtmlright = ''; + $morehtmlstatus = ''; $nbtry = $nbok = 0; if ($object->status == 2 || $object->status == 3) { $nbtry = $object->countNbOfTargets('alreadysent'); $nbko = $object->countNbOfTargets('alreadysentko'); - $morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail; + $morehtmlstatus .= ' ('.$nbtry.'/'.$object->nbemail; if ($nbko) { - $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error"); + $morehtmlstatus .= ' - '.$nbko.' '.$langs->trans("Error"); } - $morehtmlright .= ')   '; + $morehtmlstatus .= ')   '; } - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus); print '
'; print '
'; From 8b00d0c359a4e74cdea9940e9fec6bc4de22b64a Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:49:55 +0100 Subject: [PATCH 268/714] Fix PhanPluginSuspiciousParamPosition by renaming arg (local assign) --- htdocs/comm/mailing/cibles.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 95ffc1f0c38..108974d986e 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -278,21 +278,21 @@ if ($object->fetch($id) >= 0) { $morehtmlref .= $form->editfieldval("", 'title', $object->title, $object, 0, 'string', '', null, null, '', 1); $morehtmlref .= '
'; - $morehtmlright = ''; + $morehtmlstatus = ''; $nbtry = $nbok = 0; if ($object->status == $object::STATUS_SENTPARTIALY || $object->status == $object::STATUS_SENTCOMPLETELY) { $nbtry = $object->countNbOfTargets('alreadysent'); $nbko = $object->countNbOfTargets('alreadysentko'); $nbok = ($nbtry - $nbko); - $morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail; + $morehtmlstatus .= ' ('.$nbtry.'/'.$object->nbemail; if ($nbko) { - $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error"); + $morehtmlstatus .= ' - '.$nbko.' '.$langs->trans("Error"); } - $morehtmlright .= ')   '; + $morehtmlstatus .= ')   '; } - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus); print '
'; print '
'; From 6745fe4a5164060a33fa3166c269967df2ef7967 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:49:59 +0100 Subject: [PATCH 269/714] Fix PhanPluginSuspiciousParamPosition by renaming arg (local assign) --- htdocs/comm/mailing/info.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/mailing/info.php b/htdocs/comm/mailing/info.php index 0bf7e9cb4ad..08aaad90c2a 100644 --- a/htdocs/comm/mailing/info.php +++ b/htdocs/comm/mailing/info.php @@ -64,20 +64,20 @@ if ($object->fetch($id) >= 0) { $morehtmlref .= $form->editfieldval("", 'title', $object->title, $object, 0, 'string', '', null, null, '', 1); $morehtmlref .= '
'; - $morehtmlright = ''; + $morehtmlstatus = ''; $nbtry = $nbok = 0; if ($object->status == 2 || $object->status == 3) { $nbtry = $object->countNbOfTargets('alreadysent'); $nbko = $object->countNbOfTargets('alreadysentko'); - $morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail; + $morehtmlstatus .= ' ('.$nbtry.'/'.$object->nbemail; if ($nbko) { - $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error"); + $morehtmlstatus .= ' - '.$nbko.' '.$langs->trans("Error"); } - $morehtmlright .= ')   '; + $morehtmlstatus .= ')   '; } - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus); print '

'; From 715b5ef38e09237ffabe9ec8deb9acc25454718f Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:50:02 +0100 Subject: [PATCH 270/714] Fix PhanPluginSuspiciousParamPosition by renaming arg (local assign) --- htdocs/compta/facture/agenda-rec.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/facture/agenda-rec.php b/htdocs/compta/facture/agenda-rec.php index 542dfd8f6c1..3636c91fce7 100644 --- a/htdocs/compta/facture/agenda-rec.php +++ b/htdocs/compta/facture/agenda-rec.php @@ -175,9 +175,9 @@ if ($object->id > 0) { } $morehtmlref .= '
'; - $morehtmlright = ''; + $morehtmlstatus = ''; - dol_banner_tab($object, 'ref', $linkback, 1, 'title', 'none', $morehtmlref, '', 0, '', $morehtmlright); + dol_banner_tab($object, 'ref', $linkback, 1, 'title', 'none', $morehtmlref, '', 0, '', $morehtmlstatus); print '
'; print '
'; @@ -211,19 +211,19 @@ if ($object->id > 0) { //$out.=""; } - $morehtmlright = ''; + $morehtmlstatus = ''; //$messagingUrl = DOL_URL_ROOT.'/societe/messaging.php?socid='.$object->id; - //$morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1); + //$morehtmlstatus .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1); //$messagingUrl = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id; - //$morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2); + //$morehtmlstatus .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2); if (isModEnabled('agenda')) { /* if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { - $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); + $morehtmlstatus .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); } else { - $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out, '', 0); + $morehtmlstatus .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out, '', 0); } */ } @@ -245,8 +245,8 @@ if ($object->id > 0) { $cachekey = 'count_events_facture_'.$object->id; $nbEvent = dol_getcache($cachekey); - print_barre_liste($langs->trans("ActionsOnBillRec").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1); - //print_barre_liste($langs->trans("ActionsOnBill"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1); + print_barre_liste($langs->trans("ActionsOnBillRec").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlstatus, '', 0, 1, 1); + //print_barre_liste($langs->trans("ActionsOnBill"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlstatus, '', 0, 1, 1); // List of all actions $filters = array(); From 3874830fc04ebef049c12a8ebe69a10d4d35eba0 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:50:04 +0100 Subject: [PATCH 271/714] Fix PhanPluginSuspiciousParamPosition by renaming arg (local assign) --- htdocs/compta/facture/card-rec.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 59318f1a753..3502f31d822 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -1282,9 +1282,9 @@ if ($action == 'create') { } $morehtmlref .= '
'; - $morehtmlright = ''; + $morehtmlstatus = ''; - dol_banner_tab($object, 'ref', $linkback, 1, 'title', 'none', $morehtmlref, '', 0, '', $morehtmlright); + dol_banner_tab($object, 'ref', $linkback, 1, 'title', 'none', $morehtmlref, '', 0, '', $morehtmlstatus); print '
'; print '
'; From 7ecc9cfc2a3db17b4424771c1927106ca2da79b8 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:50:07 +0100 Subject: [PATCH 272/714] Fix PhanPluginSuspiciousParamPosition by renaming arg (local assign) --- htdocs/compta/sociales/document.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index c66056c47ca..0666335cc4d 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -142,9 +142,9 @@ if ($object->id) { $object->totalpaid = $alreadypayed; // To give a chance to dol_banner_tab to use already paid amount to show correct status - $morehtmlright = ''; + $morehtmlstatus = ''; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus); print '
'; print '
'; From e6c29dacdaffb9e4cdd39a2494eb8f308ff3c0e4 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:50:09 +0100 Subject: [PATCH 273/714] Fix PhanPluginSuspiciousParamPosition by renaming arg (local assign) --- htdocs/compta/sociales/info.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/sociales/info.php b/htdocs/compta/sociales/info.php index 24181ae4b7b..e6ad4953129 100644 --- a/htdocs/compta/sociales/info.php +++ b/htdocs/compta/sociales/info.php @@ -111,8 +111,8 @@ $linkback = ''; print '
'; From dabd4e9f8031c65bd5c7252983f59f59a0d084b1 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:50:10 +0100 Subject: [PATCH 274/714] Fix PhanPluginSuspiciousParamPosition by renaming arg (local assign) --- htdocs/compta/sociales/note.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/sociales/note.php b/htdocs/compta/sociales/note.php index 2f5487497f6..53c6fe187e6 100644 --- a/htdocs/compta/sociales/note.php +++ b/htdocs/compta/sociales/note.php @@ -116,9 +116,9 @@ if ($id > 0 || !empty($ref)) { //$object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status - $morehtmlright = ''; + $morehtmlstatus = ''; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus); print '
'; From a308f7c178c18d460828eabcfca764f615474c1b Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:50:12 +0100 Subject: [PATCH 275/714] Fix PhanPluginSuspiciousParamPosition by renaming arg (local assign) --- htdocs/compta/tva/document.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index f2670861833..b9cf49d5dff 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -126,8 +126,8 @@ if ($object->id) { $linkback = ''.$langs->trans("BackToList").''; - $morehtmlright = ''; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + $morehtmlstatus = ''; + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus); print '
'; print '
'; From cbd42a79061889a5caa103354f8608427f4e6d4f Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:50:14 +0100 Subject: [PATCH 276/714] Fix PhanPluginSuspiciousParamPosition by renaming arg (local assign) --- htdocs/fourn/facture/card-rec.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/facture/card-rec.php b/htdocs/fourn/facture/card-rec.php index d8f899d7bb1..a5dc3d0eba1 100644 --- a/htdocs/fourn/facture/card-rec.php +++ b/htdocs/fourn/facture/card-rec.php @@ -1184,9 +1184,9 @@ if ($action == 'create') { } $morehtmlref .= '
'; - $morehtmlright = ''; + $morehtmlstatus = ''; - dol_banner_tab($object, 'ref', $linkback, 1, 'title', 'none', $morehtmlref, '', 0, '', $morehtmlright); + dol_banner_tab($object, 'ref', $linkback, 1, 'title', 'none', $morehtmlref, '', 0, '', $morehtmlstatus); print '
'; print '
'; From e90ce779cc0ba07f0b2180aaa9a6c03178603bc1 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:50:16 +0100 Subject: [PATCH 277/714] Fix PhanPluginSuspiciousParamPosition by renaming arg (local assign) --- htdocs/loan/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 17fd78aa8c1..803717ae085 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -258,7 +258,7 @@ if (empty($reshook)) { $form = new Form($db); $formproject = new FormProjets($db); -$morehtmlright = ''; +$morehtmlstatus = ''; $outputlangs = $langs; if (isModEnabled('accounting')) { $formaccounting = new FormAccounting($db); @@ -474,7 +474,7 @@ if ($id > 0) { $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus); print '
'; print '
'; From 5d77c882829bccbfc309ed2b3aa04b0fbfd0d867 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:50:17 +0100 Subject: [PATCH 278/714] Fix PhanPluginSuspiciousParamPosition by renaming arg (local assign) --- htdocs/loan/payment/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/loan/payment/card.php b/htdocs/loan/payment/card.php index 2afeb25b322..31b71d49a3d 100644 --- a/htdocs/loan/payment/card.php +++ b/htdocs/loan/payment/card.php @@ -103,9 +103,9 @@ if ($action == 'delete') { $linkback = ''; $morehtmlref = ''; -$morehtmlright = ''; +$morehtmlstatus = ''; -dol_banner_tab($payment, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); +dol_banner_tab($payment, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus); print '
'; print '
'; From 4735ff5c278d389d7f5257665d208ed33627e5fb Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 12 Mar 2024 19:50:19 +0100 Subject: [PATCH 279/714] Fix PhanPluginSuspiciousParamPosition by renaming arg (local assign) --- htdocs/loan/schedule.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/loan/schedule.php b/htdocs/loan/schedule.php index 1864c309298..ae61486bcfe 100644 --- a/htdocs/loan/schedule.php +++ b/htdocs/loan/schedule.php @@ -185,9 +185,9 @@ if (isModEnabled('project')) { } $morehtmlref .= '
'; -$morehtmlright = ''; +$morehtmlstatus = ''; -dol_banner_tab($object, 'loanid', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); +dol_banner_tab($object, 'loanid', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus); ?> '; } if ($formmail->withfckeditor) { - $out .= $formmail->getModelEmailTemplate(); + $out .= $formmail->getModelEmailTemplate('bodyemail'); } if ($formmail->withaiprompt && isModEnabled('ai')) { - $out .= $formmail->getSectionForAIPrompt(); + $out .= $formmail->getSectionForAIPrompt('', 'bodyemail'); } print $out; print '
'; + $this->withaiprompt = 'html'; + $this->withlayout = 1; // Add link to add layout if ($this->withlayout && $this->withfckeditor) { $out .= ''; @@ -1440,9 +1442,10 @@ class FormMail extends Form * Return Html code for AI instruction of message and autofill result * * @param string $format Format for output ('', 'html', ...) + * @param string $htmlContent HTML name of WYSIWIG field * @return string HTML code to ask AI instruction and autofill result */ - public function getSectionForAIPrompt($format = '') + public function getSectionForAIPrompt($format = '', $htmlContent = 'message') { global $langs; @@ -1473,8 +1476,8 @@ class FormMail extends Form $('#ai_status_message').show(); //editor on readonly - if (CKEDITOR.instances.message) { - CKEDITOR.instances.message.setReadOnly(1); + if (CKEDITOR.instances.".$htmlContent.") { + CKEDITOR.instances.".$htmlContent.".setReadOnly(1); } $.ajax({ @@ -1486,13 +1489,13 @@ class FormMail extends Form 'instructions': instructions, }), success: function(response) { - console.log('Add response into field message: '+response); + console.log('Add response into field ".$htmlContent.": '+response); - jQuery('#message').val(response); + jQuery('#".$htmlContent."').val(response); - if (CKEDITOR.instances && CKEDITOR.instances.message && ".getDolGlobalInt('FCKEDITOR_ENABLE_MAIL', 0).") { - CKEDITOR.instances.message.setReadOnly(0); - CKEDITOR.instances.message.setData(response); + if (CKEDITOR.instances && CKEDITOR.instances.".$htmlContent." && ".getDolGlobalInt('FCKEDITOR_ENABLE_MAIL', 0).") { + CKEDITOR.instances.".$htmlContent.".setReadOnly(0); + CKEDITOR.instances.".$htmlContent.".setData(response); } // remove readonly @@ -1516,10 +1519,10 @@ class FormMail extends Form /** * Return HTML code for selection of email layout - * + * @param string $htmlContent HTML name of WYSIWIG field * @return string HTML for model email boxes */ - public function getModelEmailTemplate() + public function getModelEmailTemplate($htmlContent = 'message') { require_once DOL_DOCUMENT_ROOT.'/core/lib/emaillayout.lib.php'; @@ -1551,7 +1554,7 @@ class FormMail extends Form var template = $(this).data('template'); var contentHtml = $(this).data('content'); - var editorInstance = CKEDITOR.instances.message; + var editorInstance = CKEDITOR.instances.".$htmlContent."; if (editorInstance) { editorInstance.setData(contentHtml); } From 7d49d0e20b4fcb976ea8884389b5c5bb76684992 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Fri, 15 Mar 2024 18:05:32 +0100 Subject: [PATCH 461/714] NEW annimation for display spinner when waiting response --- htdocs/core/class/html.formmail.class.php | 8 +++- htdocs/theme/eldy/global.inc.php | 46 +++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 7557a9d89ce..290c4ffec6d 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1454,7 +1454,8 @@ class FormMail extends Form $out .= ''; $out .= ''; $out .= ''; - $out .= '
'.$langs->trans("AIProcessingPleaseWait").'
'; + $out .= '
'; + $out .= ''.$langs->trans("AIProcessingPleaseWait").'
'; $out .= "
"; foreach ($prod->stock_warehouse[getDolGlobalString($constantforkey)]->detail_batch as $dbatch) { // $dbatch is instance of Productbatch $batchStock = + $dbatch->qty; // To get a numeric @@ -1604,6 +1605,7 @@ if (!empty($_SESSION["basiclayout"]) && $_SESSION["basiclayout"] == 1) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $categorie = new Categorie($db); $categories = $categorie->get_full_arbo('product'); + $htmlforlines = ''; foreach ($categories as $row) { if (defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) { $htmlforlines .= '
Date: Mon, 18 Mar 2024 13:54:05 +0100 Subject: [PATCH 690/714] Fix PhanPossiblyUndeclaredGlobalVariable and PhanPossiblyUndeclaredGlobalVariable --- htdocs/compta/prelevement/factures.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 1fe40efa05e..d100cf59961 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -274,10 +274,10 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; + $param = "&id=".$id; if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.((int) $limit); } - $param = "&id=".urlencode((string) ($id)); // Lines of title fields print '
'; @@ -325,10 +325,14 @@ if ($resql) { while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if ($salaryBonPl) { + $itemurl = ''; + $partyurl = ''; + if ($salaryBonPl && ($salarytmp instanceof Salary) && ($user instanceof User)) { $salarytmp->fetch($obj->salaryid); $usertmp->fetch($obj->userid); - } else { + $itemurl = $salarytmp->getNomUrl(1); + $partyurl = $usertmp->getNomUrl(1); + } elseif ($invoicetmp instanceof Facture && $invoicetmpsupplier instanceof FactureFournisseur) { if ($obj->type == 'bank-transfer') { $invoicetmp = $invoicetmpsupplier; } else { @@ -337,22 +341,24 @@ if ($resql) { $invoicetmp->fetch($obj->facid); $thirdpartytmp->fetch($obj->socid); + $itemurl = $invoicetmp->getNomUrl(1); + $partyurl = $thirdpartytmp->getNomUrl(1); } print '
'; print '\n"; - if ($object->type == 'bank-transfer' && !$salaryBonPl) { + if ($object->type == 'bank-transfer' && !$salaryBonPl && $invoicetmp instanceof Facture) { print '\n"; } print '\n"; // Amount of invoice From c5b62a4a73631999e7183273266aa43345861815 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 18 Mar 2024 13:55:03 +0100 Subject: [PATCH 691/714] Add typing to fix PhanTypeMismatchDimFetch --- htdocs/compta/prelevement/class/bonprelevement.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 2cc21fb215d..e3a3eb07439 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -83,6 +83,9 @@ class BonPrelevement extends CommonObject public $factures = array(); + /** + * @var array + */ public $methodes_trans = array(); public $invoice_in_error = array(); @@ -171,6 +174,9 @@ class BonPrelevement extends CommonObject public $credite; public $note; public $date_trans; + /** + * @var int Current transport method, index to $methodes_trans + */ public $method_trans; public $fk_user_trans; public $date_credit; From 33680415871f97af621095c1503ef7af131c24c0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 14:04:10 +0100 Subject: [PATCH 692/714] Fix filter --- htdocs/compta/facture/invoicetemplate_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 13a119e35b5..63e01dac397 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -91,7 +91,7 @@ $search_date_when_endmonth = GETPOSTINT('search_date_when_endmonth'); $search_date_when_endyear = GETPOSTINT('search_date_when_endyear'); $search_date_when_start = dol_mktime(0, 0, 0, $search_date_when_startmonth, $search_date_when_startday, $search_date_when_startyear); // Use tzserver $search_date_when_end = dol_mktime(23, 59, 59, $search_date_when_endmonth, $search_date_when_endday, $search_date_when_endyear); -$search_recurring = GETPOSTINT('search_recurring'); +$search_recurring = GETPOST('search_recurring', 'intcomma'); $search_frequency = GETPOST('search_frequency', 'alpha'); $search_unit_frequency = GETPOST('search_unit_frequency', 'alpha'); $search_nb_gen_done = GETPOST('search_nb_gen_done', 'alpha'); From 9913778da0cd573c2f95718c4cb7a8370503918a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 18 Mar 2024 14:04:51 +0100 Subject: [PATCH 693/714] fix migration for postgresql 19.0.0 -> 20.0.0 --- htdocs/install/mysql/migration/19.0.0-20.0.0.sql | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql index cbbb6d34cdc..170f02a9ec1 100644 --- a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql +++ b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql @@ -227,8 +227,10 @@ ALTER TABLE llx_product ADD COLUMN last_main_doc varchar(255); ALTER TABLE llx_knowledgemanagement_knowledgerecord MODIFY COLUMN answer longtext; -ALTER TABLE llx_commande_fournisseur_dispatch_extrafields RENAME llx_receptiondet_batch_extrafields; -ALTER TABLE llx_commande_fournisseur_dispatch RENAME llx_receptiondet_batch; +-- VMYSQL4.3 ALTER TABLE llx_commande_fournisseur_dispatch_extrafields RENAME llx_receptiondet_batch_extrafields; +-- VMYSQL4.3 ALTER TABLE llx_commande_fournisseur_dispatch RENAME llx_receptiondet_batch; +-- VPGSQL8.2 ALTER TABLE llx_commande_fournisseur_dispatch_extrafields RENAME TO llx_receptiondet_batch_extrafields; +-- VPGSQL8.2 ALTER TABLE llx_commande_fournisseur_dispatch RENAME TO llx_receptiondet_batch; -- Rename const to add customer categories on not customer/prospect third-party if enabled UPDATE llx_const SET name = 'THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT' WHERE name = 'THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER'; From 1783d68fd4aa9542a4a58006c642287d2021e23d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 18 Mar 2024 14:10:55 +0100 Subject: [PATCH 694/714] Update pgsql.class.php --- htdocs/core/db/pgsql.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index a76fbfb6857..ecb9b0f0df9 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -724,7 +724,7 @@ class DoliDBPgsql extends DoliDB */ public function escape($stringtoencode) { - return pg_escape_string($stringtoencode); + return pg_escape_string($this->db, $stringtoencode); } /** From 6640354e79ad6b2b3abed9f16daa50136b1ee84b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 14:32:59 +0100 Subject: [PATCH 695/714] Move to use the english key name ofmodule --- htdocs/admin/workflow.php | 2 +- htdocs/core/lib/functions.lib.php | 6 ++-- htdocs/core/menus/init_menu_auguria.sql | 38 ++++++++++++------------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 648f7706ad9..d68b7c054ef 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -158,7 +158,7 @@ $workflowcodes = array( 'WORKFLOW_SHIPPING_CLASSIFY_CLOSED_INVOICE' => array( 'family' => 'classify_shipping', 'position' => 90, - 'enabled' => isModEnabled("expedition") && isModEnabled("facture"), + 'enabled' => isModEnabled("shipping") && isModEnabled("invoice"), 'picto' => 'shipment', 'deprecated' => 1 ), diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7554f5e5851..bb5abcf9f4c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -11765,9 +11765,9 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st * @param string $actionType 'default', 'danger', 'email', 'clone', 'cancel', 'delete', ... * @param string|array $url Url for link or array of subbutton description ('label'=>, 'url'=>, 'lang'=>, 'perm'=> ) * Example when an array is used: $arrayforbutaction = array( - * 10 => array('lang'=>'propal', 'enabled'=>isModEnabled("propal"), 'perm'=>$user->hasRight('propal', 'creer'), 'label' => 'AddProp', 'url'=>'/comm/propal/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid), - * 20 => array('lang'=>'orders', 'enabled'=>isModEnabled("commande"), 'perm'=>$user->hasRight('commande', 'creer'), 'label' => 'CreateOrder', 'url'=>'/commande/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid), - * 30 => array('lang'=>'bills', 'enabled'=>isModEnabled("facture"), 'perm'=>$user->hasRight('facture', 'creer'), 'label' => 'CreateBill', 'url'=>'/compta/facture/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid), + * 10 => array('lang'=>'propal', 'enabled'=>isModEnabled("proposal"), 'perm'=>$user->hasRight('propal', 'creer'), 'label' => 'AddProp', 'url'=>'/comm/propal/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid), + * 20 => array('lang'=>'orders', 'enabled'=>isModEnabled("order"), 'perm'=>$user->hasRight('commande', 'creer'), 'label' => 'CreateOrder', 'url'=>'/commande/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid), + * 30 => array('lang'=>'bills', 'enabled'=>isModEnabled("invoice"), 'perm'=>$user->hasRight('facture', 'creer'), 'label' => 'CreateBill', 'url'=>'/compta/facture/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid), * ); * @param string $id Attribute id of action button. Example 'action-delete'. This can be used for full ajax confirm if this code is reused into the ->formconfirm() method. * @param int|boolean $userRight User action right diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index e661fb3db4c..d177030b841 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -18,7 +18,7 @@ insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, left insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ( 16__+MAX_llx_menu__, 'bom|mrp', 'isModEnabled("bom") || isModEnabled("mrp")', __HANDLER__, 'top', 'mrp', '', 0, '/mrp/index.php?mainmenu=mrp&leftmenu=', 'TMenuMRP', -1, 'mrp', '$user->hasRight("bom","read") || $user->hasRight("mrp","read")', '', 0, 31, __ENTITY__, ''); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ( 7__+MAX_llx_menu__, 'projet', 'isModEnabled("project")', __HANDLER__, 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&leftmenu=', 'Projects', -1, 'projects', '$user->hasRight("projet","lire")', '', 2, 32, __ENTITY__, ''); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ( 5__+MAX_llx_menu__, 'propal|commande|fournisseur|supplier_order|supplier_invoice|contrat|ficheinter', 'isModEnabled("propal") || isModEnabled("commande") || isModEnabled("supplier_order") || isModEnabled("contrat") || isModEnabled("ficheinter")', __HANDLER__, 'top', 'commercial', '', 0, '/comm/index.php?mainmenu=commercial&leftmenu=', 'Commercial', -1, 'commercial', '$user->hasRight("societe","lire") || $user->hasRight("societe","contact","lire")', '', 2, 40, __ENTITY__, ''); -insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ( 6__+MAX_llx_menu__, 'facture|don|tax|salaries|loan|banque', 'isModEnabled("comptabilite") || isModEnabled("accounting") || isModEnabled("facture") || isModEnabled("don") || isModEnabled("tax") || isModEnabled("salaries") || isModEnabled("supplier_invoice") || isModEnabled("loan") || isModEnabled("banque")', __HANDLER__, 'top', 'billing', '', 0, '/compta/index.php?mainmenu=billing&leftmenu=', 'MenuFinancial', -1, 'compta', '$user->hasRight("facture","lire") || $user->hasRight("don","lire") || $user->hasRight("tax","charges","lire") || $user->hasRight("salaries","read") || $user->hasRight("loan","read") || $user->hasRight("banque","lire") || $user->hasRight("fournisseur","facture","lire") || $user->hasRight("supplier_invoice","read")', '', 2, 50, __ENTITY__, ''); +insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ( 6__+MAX_llx_menu__, 'facture|don|tax|salaries|loan|banque', 'isModEnabled("comptabilite") || isModEnabled("accounting") || isModEnabled("invoice") || isModEnabled("don") || isModEnabled("tax") || isModEnabled("salaries") || isModEnabled("supplier_invoice") || isModEnabled("loan") || isModEnabled("banque")', __HANDLER__, 'top', 'billing', '', 0, '/compta/index.php?mainmenu=billing&leftmenu=', 'MenuFinancial', -1, 'compta', '$user->hasRight("facture","lire") || $user->hasRight("don","lire") || $user->hasRight("tax","charges","lire") || $user->hasRight("salaries","read") || $user->hasRight("loan","read") || $user->hasRight("banque","lire") || $user->hasRight("fournisseur","facture","lire") || $user->hasRight("supplier_invoice","read")', '', 2, 50, __ENTITY__, ''); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ( 14__+MAX_llx_menu__, 'banque|prelevement', 'isModEnabled("banque") || isModEnabled("prelevement")', __HANDLER__, 'top', 'bank', '', 0, '/compta/bank/list.php?mainmenu=bank&leftmenu=bank', 'MenuBankCash', -1, 'banks', '$user->hasRight("banque","lire") || $user->hasRight("prelevement","bons","lire")', '', 0, 52, __ENTITY__, ''); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ( 9__+MAX_llx_menu__, 'comptabilite|accounting|asset', 'isModEnabled("comptabilite") || isModEnabled("accounting") || isModEnabled("asset")', __HANDLER__, 'top', 'accountancy', '', 0, '/compta/index.php?mainmenu=accountancy&leftmenu=accountancy', 'MenuAccountancy', -1, 'main', '$user->hasRight("compta","resultat","lire") || $user->hasRight("accounting","mouvements","lire") || $user->hasRight("asset","read")', '', 2, 54, __ENTITY__, ''); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity, prefix) values ( 8__+MAX_llx_menu__, '', '', __HANDLER__, 'top', 'tools', '', 0, '/core/tools.php?mainmenu=tools&leftmenu=', 'Tools', -1, 'other', '', '', 2, 90, __ENTITY__, ''); @@ -231,23 +231,23 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("supplier_invoice")', __HANDLER__, 'left', 1604__+MAX_llx_menu__, 'billing', 'customers_bills_stats', 1600__+MAX_llx_menu__, '/compta/facture/stats/index.php?mainmenu=billing&leftmenu=customers_bills_stats&mode=supplier', 'Statistics', 1, 'bills', '$user->rights->fournisseur->facture->lire', '', 2, 8, __ENTITY__); -- Billing - Customer invoice -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("facture")', __HANDLER__, 'left', 1700__+MAX_llx_menu__, 'billing', 'customer_bills', 6__+MAX_llx_menu__, '/compta/facture/list.php?mainmenu=billing&leftmenu=customers_bills', 'BillsCustomers', 0, 'bills', '$user->rights->facture->lire', '', 2, 3, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("facture")', __HANDLER__, 'left', 1701__+MAX_llx_menu__, 'billing', '', 1700__+MAX_llx_menu__, '/compta/facture/card.php?mainmenu=billing&action=create&leftmenu=customers_bills', 'NewBill', 1, 'bills', '$user->rights->facture->creer', '', 2, 3, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("facture")', __HANDLER__, 'left', 1705__+MAX_llx_menu__, 'billing', '', 1700__+MAX_llx_menu__, '/compta/facture/list.php?mainmenu=billing&leftmenu=customers_bills', 'List', 1, 'bills', '$user->rights->facture->lire', '', 2, 4, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("invoice")', __HANDLER__, 'left', 1700__+MAX_llx_menu__, 'billing', 'customer_bills', 6__+MAX_llx_menu__, '/compta/facture/list.php?mainmenu=billing&leftmenu=customers_bills', 'BillsCustomers', 0, 'bills', '$user->rights->facture->lire', '', 2, 3, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("invoice")', __HANDLER__, 'left', 1701__+MAX_llx_menu__, 'billing', '', 1700__+MAX_llx_menu__, '/compta/facture/card.php?mainmenu=billing&action=create&leftmenu=customers_bills', 'NewBill', 1, 'bills', '$user->rights->facture->creer', '', 2, 3, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("invoice")', __HANDLER__, 'left', 1705__+MAX_llx_menu__, 'billing', '', 1700__+MAX_llx_menu__, '/compta/facture/list.php?mainmenu=billing&leftmenu=customers_bills', 'List', 1, 'bills', '$user->rights->facture->lire', '', 2, 4, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("facture")', __HANDLER__, 'left', 1720__+MAX_llx_menu__, 'billing', '', 1705__+MAX_llx_menu__, '/compta/facture/list.php?mainmenu=billing&leftmenu=customers_bills_draft&search_status=0', 'BillShortStatusDraft', 2, 'bills', '$user->rights->facture->lire', '', 2, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("facture")', __HANDLER__, 'left', 1721__+MAX_llx_menu__, 'billing', '', 1705__+MAX_llx_menu__, '/compta/facture/list.php?mainmenu=billing&leftmenu=customers_bills_notpaid&search_status=1', 'BillShortStatusNotPaid', 2, 'bills', '$user->rights->facture->lire', '', 2, 2, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("facture")', __HANDLER__, 'left', 1722__+MAX_llx_menu__, 'billing', '', 1705__+MAX_llx_menu__, '/compta/facture/list.php?mainmenu=billing&leftmenu=customers_bills_paid&search_status=2', 'BillShortStatusPaid', 2, 'bills', '$user->rights->facture->lire', '', 2, 3, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("facture")', __HANDLER__, 'left', 1723__+MAX_llx_menu__, 'billing', '', 1705__+MAX_llx_menu__, '/compta/facture/list.php?mainmenu=billing&leftmenu=customers_bills_canceled&search_status=3', 'BillShortStatusCanceled', 2, 'bills', '$user->rights->facture->lire', '', 2, 4, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("invoice")', __HANDLER__, 'left', 1720__+MAX_llx_menu__, 'billing', '', 1705__+MAX_llx_menu__, '/compta/facture/list.php?mainmenu=billing&leftmenu=customers_bills_draft&search_status=0', 'BillShortStatusDraft', 2, 'bills', '$user->rights->facture->lire', '', 2, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("invoice")', __HANDLER__, 'left', 1721__+MAX_llx_menu__, 'billing', '', 1705__+MAX_llx_menu__, '/compta/facture/list.php?mainmenu=billing&leftmenu=customers_bills_notpaid&search_status=1', 'BillShortStatusNotPaid', 2, 'bills', '$user->rights->facture->lire', '', 2, 2, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("invoice")', __HANDLER__, 'left', 1722__+MAX_llx_menu__, 'billing', '', 1705__+MAX_llx_menu__, '/compta/facture/list.php?mainmenu=billing&leftmenu=customers_bills_paid&search_status=2', 'BillShortStatusPaid', 2, 'bills', '$user->rights->facture->lire', '', 2, 3, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("invoice")', __HANDLER__, 'left', 1723__+MAX_llx_menu__, 'billing', '', 1705__+MAX_llx_menu__, '/compta/facture/list.php?mainmenu=billing&leftmenu=customers_bills_canceled&search_status=3', 'BillShortStatusCanceled', 2, 'bills', '$user->rights->facture->lire', '', 2, 4, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("facture")', __HANDLER__, 'left', 1702__+MAX_llx_menu__, 'billing', '', 1700__+MAX_llx_menu__, '/compta/facture/invoicetemplate_list.php?mainmenu=billing&leftmenu=customers_bills', 'ListOfTemplates', 1, 'bills', '$user->rights->facture->lire', '', 2, 5, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("invoice")', __HANDLER__, 'left', 1702__+MAX_llx_menu__, 'billing', '', 1700__+MAX_llx_menu__, '/compta/facture/invoicetemplate_list.php?mainmenu=billing&leftmenu=customers_bills', 'ListOfTemplates', 1, 'bills', '$user->rights->facture->lire', '', 2, 5, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("facture")', __HANDLER__, 'left', 1704__+MAX_llx_menu__, 'billing', 'customers_bills_payment', 1700__+MAX_llx_menu__, '/compta/paiement/list.php?mainmenu=billing&leftmenu=customers_bills_payment', 'Payments', 1, 'bills', '$user->rights->facture->lire', '', 2, 6, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("facture")', __HANDLER__, 'left', 1710__+MAX_llx_menu__, 'billing', 'customers_bills_reports', 1704__+MAX_llx_menu__, '/compta/paiement/rapport.php?mainmenu=billing&leftmenu=customers_bills_reports', 'Reportings', 2, 'bills', '$user->rights->facture->lire', '', 2, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("facture")', __HANDLER__, 'left', 1714__+MAX_llx_menu__, 'billing', 'customers_bills_stats', 1700__+MAX_llx_menu__, '/compta/facture/stats/index.php?mainmenu=billing&leftmenu=customers_bills_stats', 'Statistics', 1, 'bills', '$user->rights->facture->lire', '', 2, 8, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("invoice")', __HANDLER__, 'left', 1704__+MAX_llx_menu__, 'billing', 'customers_bills_payment', 1700__+MAX_llx_menu__, '/compta/paiement/list.php?mainmenu=billing&leftmenu=customers_bills_payment', 'Payments', 1, 'bills', '$user->rights->facture->lire', '', 2, 6, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("invoice")', __HANDLER__, 'left', 1710__+MAX_llx_menu__, 'billing', 'customers_bills_reports', 1704__+MAX_llx_menu__, '/compta/paiement/rapport.php?mainmenu=billing&leftmenu=customers_bills_reports', 'Reportings', 2, 'bills', '$user->rights->facture->lire', '', 2, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("invoice")', __HANDLER__, 'left', 1714__+MAX_llx_menu__, 'billing', 'customers_bills_stats', 1700__+MAX_llx_menu__, '/compta/facture/stats/index.php?mainmenu=billing&leftmenu=customers_bills_stats', 'Statistics', 1, 'bills', '$user->rights->facture->lire', '', 2, 8, __ENTITY__); -- Billing - Orders to bill -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("commande")', __HANDLER__, 'left', 1900__+MAX_llx_menu__, 'billing', 'orders', 6__+MAX_llx_menu__, '/commande/list.php?mainmenu=billing&leftmenu=orders&search_status=3', 'MenuOrdersToBill', 0, 'orders', '$user->rights->commande->lire', '', 0, 3, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("order")', __HANDLER__, 'left', 1900__+MAX_llx_menu__, 'billing', 'orders', 6__+MAX_llx_menu__, '/commande/list.php?mainmenu=billing&leftmenu=orders&search_status=3', 'MenuOrdersToBill', 0, 'orders', '$user->rights->commande->lire', '', 0, 3, __ENTITY__); -- Donations insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("don")', __HANDLER__, 'left', 2000__+MAX_llx_menu__, 'billing', 'donations', 6__+MAX_llx_menu__, '/don/index.php?mainmenu=billing&leftmenu=donations', 'Donations', 0, 'donations', '$user->rights->don->lire', '', 2, 4, __ENTITY__); @@ -316,9 +316,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("accounting") && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2450__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_period', 2451__+MAX_llx_menu__, '/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'FiscalPeriod', 1, 'admin', '', '', 2, 80, __ENTITY__); -- Binding -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("accounting") && isModEnabled("facture") && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_customer', 2400__+MAX_llx_menu__, '/accountancy/customer/index.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer', 'CustomersVentilation', 1, 'accountancy', '$user->hasRight("accounting","bind","write")', '', 0, 2, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("accounting") && isModEnabled("facture") && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES) && $leftmenu=="accountancy_dispatch_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->hasRight("accounting","bind","write")', '', 0, 3, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("accounting") && isModEnabled("facture") && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES) && $leftmenu=="accountancy_dispatch_customer"', __HANDLER__, 'left', 2403__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->hasRight("accounting","bind","write")', '', 0, 4, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("accounting") && isModEnabled("invoice") && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_customer', 2400__+MAX_llx_menu__, '/accountancy/customer/index.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer', 'CustomersVentilation', 1, 'accountancy', '$user->hasRight("accounting","bind","write")', '', 0, 2, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("accounting") && isModEnabled("invoice") && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES) && $leftmenu=="accountancy_dispatch_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->hasRight("accounting","bind","write")', '', 0, 3, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("accounting") && isModEnabled("invoice") && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES) && $leftmenu=="accountancy_dispatch_customer"', __HANDLER__, 'left', 2403__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->hasRight("accounting","bind","write")', '', 0, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("accounting") && isModEnabled("supplier_invoice") && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)', __HANDLER__, 'left', 2410__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_supplier', 2400__+MAX_llx_menu__, '/accountancy/supplier/index.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier', 'SuppliersVentilation', 1, 'accountancy', '$user->hasRight("accounting","bind","write")', '', 0, 5, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("accounting") && isModEnabled("supplier_invoice") && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES) && $leftmenu=="accountancy_dispatch_supplier"', __HANDLER__, 'left', 2411__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->hasRight("accounting","bind","write")', '', 0, 6, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("accounting") && isModEnabled("supplier_invoice") && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES) && $leftmenu=="accountancy_dispatch_supplier"', __HANDLER__, 'left', 2412__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->hasRight("accounting","bind","write")', '', 0, 7, __ENTITY__); @@ -379,9 +379,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("asset") && $leftmenu=="asset"', __HANDLER__, 'left', 3006__+MAX_llx_menu__, 'asset', '', 3004__+MAX_llx_menu__, '/asset/type.php?mainmenu=accountancy', 'MenuListTypeAssets', 3, 'assets', '($conf->global->MAIN_USE_ADVANCED_PERMS?$user->hasRight("asset","model_advance","read"):$user->hasRight("asset","read"))', '', 0, 25, __ENTITY__); -- Check deposit -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && isModEnabled("banque") && (isModEnabled("facture") || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))', __HANDLER__, 'left', 1711__+MAX_llx_menu__, 'accountancy', 'checks', 14__+MAX_llx_menu__, '/compta/paiement/cheque/index.php?mainmenu=bank&leftmenu=checks', 'MenuChequeDeposits', 0, 'bills', '$user->hasRight("banque","lire")', '', 2, 9, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && isModEnabled("banque") && (isModEnabled("facture") || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))', __HANDLER__, 'left', 1712__+MAX_llx_menu__, 'accountancy', '', 1711__+MAX_llx_menu__, '/compta/paiement/cheque/card.php?mainmenu=bank&leftmenu=checks&action=new', 'NewCheckDeposit', 1, 'compta', '$user->hasRight("banque","lire")', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && isModEnabled("banque") && (isModEnabled("facture") || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))', __HANDLER__, 'left', 1713__+MAX_llx_menu__, 'accountancy', '', 1711__+MAX_llx_menu__, '/compta/paiement/cheque/list.php?mainmenu=bank&leftmenu=checks', 'List', 1, 'bills', '$user->hasRight("banque","lire")', '', 2, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && isModEnabled("bank") && (isModEnabled("invoice") || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))', __HANDLER__, 'left', 1711__+MAX_llx_menu__, 'accountancy', 'checks', 14__+MAX_llx_menu__, '/compta/paiement/cheque/index.php?mainmenu=bank&leftmenu=checks', 'MenuChequeDeposits', 0, 'bills', '$user->hasRight("banque","lire")', '', 2, 9, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && isModEnabled("bank") && (isModEnabled("invoice") || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))', __HANDLER__, 'left', 1712__+MAX_llx_menu__, 'accountancy', '', 1711__+MAX_llx_menu__, '/compta/paiement/cheque/card.php?mainmenu=bank&leftmenu=checks&action=new', 'NewCheckDeposit', 1, 'compta', '$user->hasRight("banque","lire")', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && isModEnabled("bank") && (isModEnabled("invoice") || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))', __HANDLER__, 'left', 1713__+MAX_llx_menu__, 'accountancy', '', 1711__+MAX_llx_menu__, '/compta/paiement/cheque/list.php?mainmenu=bank&leftmenu=checks', 'List', 1, 'bills', '$user->hasRight("banque","lire")', '', 2, 1, __ENTITY__); -- PaymentByDirectDebit insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("prelevement")', __HANDLER__, 'left', 2500__+MAX_llx_menu__, 'accountancy', 'withdraw', 14__+MAX_llx_menu__, '/compta/prelevement/index.php?mainmenu=bank&leftmenu=withdraw', 'PaymentByDirectDebit', 0, 'withdrawals', '$user->hasRight("prelevement","bons","lire")', '', 2, 9, __ENTITY__); From 90882d46b2532beff42b1d87add039af46551dc8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 14:36:09 +0100 Subject: [PATCH 696/714] Update factures.php --- htdocs/compta/prelevement/factures.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index d100cf59961..1dc1fd3d76d 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -274,7 +274,7 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - $param = "&id=".$id; + $param = "&id=".((int) $id); if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.((int) $limit); } From d73d27466bbd4a8592173d683f95fb861e8e63c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 14:40:47 +0100 Subject: [PATCH 697/714] Update 19.0.0-20.0.0.sql --- htdocs/install/mysql/migration/19.0.0-20.0.0.sql | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql index 170f02a9ec1..acd230f65cb 100644 --- a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql +++ b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql @@ -5,7 +5,7 @@ -- -- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y -- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y --- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; +-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; -- Note that "RENAME TO" is both compatible mysql/postgesql, not "RENAME" alone. -- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; -- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); -- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; @@ -227,10 +227,8 @@ ALTER TABLE llx_product ADD COLUMN last_main_doc varchar(255); ALTER TABLE llx_knowledgemanagement_knowledgerecord MODIFY COLUMN answer longtext; --- VMYSQL4.3 ALTER TABLE llx_commande_fournisseur_dispatch_extrafields RENAME llx_receptiondet_batch_extrafields; --- VMYSQL4.3 ALTER TABLE llx_commande_fournisseur_dispatch RENAME llx_receptiondet_batch; --- VPGSQL8.2 ALTER TABLE llx_commande_fournisseur_dispatch_extrafields RENAME TO llx_receptiondet_batch_extrafields; --- VPGSQL8.2 ALTER TABLE llx_commande_fournisseur_dispatch RENAME TO llx_receptiondet_batch; +ALTER TABLE llx_commande_fournisseur_dispatch_extrafields RENAME TO llx_receptiondet_batch_extrafields; +ALTER TABLE llx_commande_fournisseur_dispatch RENAME TO llx_receptiondet_batch; -- Rename const to add customer categories on not customer/prospect third-party if enabled UPDATE llx_const SET name = 'THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT' WHERE name = 'THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER'; From 034ce8cb98ac13c01f8fb35eba62c5e37e8626fa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 14:44:18 +0100 Subject: [PATCH 698/714] Fix trans key code --- htdocs/core/lib/emaillayout.lib.php | 4 ++-- htdocs/langs/en_US/mails.lang | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/emaillayout.lib.php b/htdocs/core/lib/emaillayout.lib.php index 9ae359f26df..75b7b589c44 100644 --- a/htdocs/core/lib/emaillayout.lib.php +++ b/htdocs/core/lib/emaillayout.lib.php @@ -43,10 +43,10 @@ function getHtmlOfLayout($name) } else { $out .= 'Gray rectangle'; } - $out .= ' + $out .= '

'.$langs->trans('TitleOfMailHolder').'

'; if (!(empty($user->signature))) { $out .= '

'.dol_htmlentities($user->signature).'

'; diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 4160930b410..da25fc5a5f9 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -192,4 +192,4 @@ YouCanMakeSomeInstructionForEmail=You can make some instructions for your Email ModelTemplate=Email template YouCanChooseAModelForYouMailContent= You can choose one of template models or generate one with AI TitleOfMailHolder=Title of the e-mail goes here -ContentOfMailHOlder=Content of email goes here... \ No newline at end of file +ContentOfMailHolder=Content of email goes here... From 72d758e05455f94766dd936a4c5e94a29695811b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 14:56:54 +0100 Subject: [PATCH 699/714] Doc --- .../interface_99_modMyModule_MyModuleTriggers.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php index db9cb264f7b..c68c6a4f33e 100644 --- a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php +++ b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php @@ -139,7 +139,8 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers //case 'ORDER_DELETE': //case 'ORDER_CANCEL': //case 'ORDER_SENTBYMAIL': - //case 'ORDER_CLASSIFY_BILLED': + //case 'ORDER_CLASSIFY_BILLED': // TODO Replace it with ORDER_MODIFY + //case 'ORDER_CLASSIFY_UNBILLED': // TODO Replace it with ORDER_MODIFY //case 'ORDER_SETDRAFT': //case 'LINEORDER_INSERT': //case 'LINEORDER_UPDATE': @@ -151,6 +152,8 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers //case 'ORDER_SUPPLIER_VALIDATE': //case 'ORDER_SUPPLIER_DELETE': //case 'ORDER_SUPPLIER_APPROVE': + //case 'ORDER_SUPPLIER_CLASSIFY_BILLED': // TODO Replace with ORDER_SUPPLIER_MODIFY + //case 'ORDER_SUPPLIER_CLASSIFY_UNBILLED': // TODO Replace with ORDER_SUPPLIER_MODIFY //case 'ORDER_SUPPLIER_REFUSE': //case 'ORDER_SUPPLIER_CANCEL': //case 'ORDER_SUPPLIER_SENTBYMAIL': @@ -165,6 +168,8 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers //case 'PROPAL_MODIFY': //case 'PROPAL_VALIDATE': //case 'PROPAL_SENTBYMAIL': + //case 'PROPAL_CLASSIFY_BILLED': // TODO Replace it with PROPAL_MODIFY + //case 'PROPAL_CLASSIFY_UNBILLED': // TODO Replace it with PROPAL_MODIFY //case 'PROPAL_CLOSE_SIGNED': //case 'PROPAL_CLOSE_REFUSED': //case 'PROPAL_DELETE': @@ -240,6 +245,8 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers //case 'FICHINTER_CREATE': //case 'FICHINTER_MODIFY': //case 'FICHINTER_VALIDATE': + //case 'FICHINTER_CLASSIFY_BILLED': // TODO Replace it with FICHINTER_MODIFY + //case 'FICHINTER_CLASSIFY_UNBILLED': // TODO Replace it with FICHINTER_MODIFY //case 'FICHINTER_DELETE': //case 'LINEFICHINTER_CREATE': //case 'LINEFICHINTER_UPDATE': From b72b38f5d1b6fc29552e103aec60d4679f2caa9b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 15:03:41 +0100 Subject: [PATCH 700/714] Doc --- ...ace_99_modMyModule_MyModuleTriggers.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php index c68c6a4f33e..3ab08016799 100644 --- a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php +++ b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php @@ -139,8 +139,8 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers //case 'ORDER_DELETE': //case 'ORDER_CANCEL': //case 'ORDER_SENTBYMAIL': - //case 'ORDER_CLASSIFY_BILLED': // TODO Replace it with ORDER_MODIFY - //case 'ORDER_CLASSIFY_UNBILLED': // TODO Replace it with ORDER_MODIFY + //case 'ORDER_CLASSIFY_BILLED': // TODO Replace it with ORDER_BILLED + //case 'ORDER_CLASSIFY_UNBILLED': // TODO Replace it with ORDER_UNBILLED //case 'ORDER_SETDRAFT': //case 'LINEORDER_INSERT': //case 'LINEORDER_UPDATE': @@ -152,8 +152,8 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers //case 'ORDER_SUPPLIER_VALIDATE': //case 'ORDER_SUPPLIER_DELETE': //case 'ORDER_SUPPLIER_APPROVE': - //case 'ORDER_SUPPLIER_CLASSIFY_BILLED': // TODO Replace with ORDER_SUPPLIER_MODIFY - //case 'ORDER_SUPPLIER_CLASSIFY_UNBILLED': // TODO Replace with ORDER_SUPPLIER_MODIFY + //case 'ORDER_SUPPLIER_CLASSIFY_BILLED': // TODO Replace with ORDER_SUPPLIER_BILLED + //case 'ORDER_SUPPLIER_CLASSIFY_UNBILLED': // TODO Replace with ORDER_SUPPLIER_UNBILLED //case 'ORDER_SUPPLIER_REFUSE': //case 'ORDER_SUPPLIER_CANCEL': //case 'ORDER_SUPPLIER_SENTBYMAIL': @@ -168,8 +168,8 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers //case 'PROPAL_MODIFY': //case 'PROPAL_VALIDATE': //case 'PROPAL_SENTBYMAIL': - //case 'PROPAL_CLASSIFY_BILLED': // TODO Replace it with PROPAL_MODIFY - //case 'PROPAL_CLASSIFY_UNBILLED': // TODO Replace it with PROPAL_MODIFY + //case 'PROPAL_CLASSIFY_BILLED': // TODO Replace it with PROPAL_BILLED + //case 'PROPAL_CLASSIFY_UNBILLED': // TODO Replace it with PROPAL_UNBILLED //case 'PROPAL_CLOSE_SIGNED': //case 'PROPAL_CLOSE_REFUSED': //case 'PROPAL_DELETE': @@ -245,8 +245,8 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers //case 'FICHINTER_CREATE': //case 'FICHINTER_MODIFY': //case 'FICHINTER_VALIDATE': - //case 'FICHINTER_CLASSIFY_BILLED': // TODO Replace it with FICHINTER_MODIFY - //case 'FICHINTER_CLASSIFY_UNBILLED': // TODO Replace it with FICHINTER_MODIFY + //case 'FICHINTER_CLASSIFY_BILLED': // TODO Replace it with FICHINTER_BILLED + //case 'FICHINTER_CLASSIFY_UNBILLED': // TODO Replace it with FICHINTER_UNBILLED //case 'FICHINTER_DELETE': //case 'LINEFICHINTER_CREATE': //case 'LINEFICHINTER_UPDATE': From 20018163e29a67ccdad87c92171a11d23d872539 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 15:13:43 +0100 Subject: [PATCH 701/714] Fix restore declaration to avoid to many uncompatibility problems. --- htdocs/core/triggers/dolibarrtriggers.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/triggers/dolibarrtriggers.class.php b/htdocs/core/triggers/dolibarrtriggers.class.php index e1eb9be0c0c..fd3004a9c9d 100644 --- a/htdocs/core/triggers/dolibarrtriggers.class.php +++ b/htdocs/core/triggers/dolibarrtriggers.class.php @@ -186,5 +186,5 @@ abstract class DolibarrTriggers * @param conf $conf Object conf * @return int if KO: <0 || if no trigger ran: 0 || if OK: >0 */ - abstract public function runTrigger(string $action, $object, User $user, Translate $langs, Conf $conf); + abstract public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf); } From f9346a8022c895900ad2a8784b17dce308a65aaf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 15:13:43 +0100 Subject: [PATCH 702/714] Fix restore declaration to avoid to many uncompatibility problems. --- htdocs/core/triggers/dolibarrtriggers.class.php | 2 +- htdocs/core/triggers/interface_20_all_Logevents.class.php | 2 +- .../triggers/interface_20_modWorkflow_WorkflowManager.class.php | 2 +- .../core/triggers/interface_50_modAgenda_ActionsAuto.class.php | 2 +- .../interface_50_modBlockedlog_ActionsBlockedLog.class.php | 2 +- ...nterface_50_modEventOrganization_EventOrganization.class.php | 2 +- htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php | 2 +- .../interface_50_modMailmanspip_Mailmanspipsynchro.class.php | 2 +- .../interface_50_modNotification_Notification.class.php | 2 +- .../core/triggers/interface_50_modTicket_TicketEmail.class.php | 2 +- htdocs/core/triggers/interface_80_modStripe_Stripe.class.php | 2 +- .../triggers/interface_90_modSociete_ContactRoles.class.php | 2 +- .../triggers/interface_95_modWebhook_WebhookTriggers.class.php | 2 +- .../triggers/interface_95_modZapier_ZapierTriggers.class.php | 2 +- .../interface_99_modMyModule_MyModuleTriggers.class.php | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/core/triggers/dolibarrtriggers.class.php b/htdocs/core/triggers/dolibarrtriggers.class.php index e1eb9be0c0c..fd3004a9c9d 100644 --- a/htdocs/core/triggers/dolibarrtriggers.class.php +++ b/htdocs/core/triggers/dolibarrtriggers.class.php @@ -186,5 +186,5 @@ abstract class DolibarrTriggers * @param conf $conf Object conf * @return int if KO: <0 || if no trigger ran: 0 || if OK: >0 */ - abstract public function runTrigger(string $action, $object, User $user, Translate $langs, Conf $conf); + abstract public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf); } diff --git a/htdocs/core/triggers/interface_20_all_Logevents.class.php b/htdocs/core/triggers/interface_20_all_Logevents.class.php index 47432eeb75c..adc63815e33 100644 --- a/htdocs/core/triggers/interface_20_all_Logevents.class.php +++ b/htdocs/core/triggers/interface_20_all_Logevents.class.php @@ -88,7 +88,7 @@ class InterfaceLogevents extends DolibarrTriggers * @return int if KO: <0, if no trigger ran: 0, if OK: >0 * @throws Exception dol_syslog can throw Exceptions */ - public function runTrigger(string $action, $object, User $user, Translate $langs, Conf $conf) + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { if (getDolGlobalString('MAIN_LOGEVENTS_DISABLE_ALL')) { return 0; // Log events is disabled (hidden features) diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 96da2886c32..1edea428b6f 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -62,7 +62,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers * @param conf $conf Object conf * @return int Return integer <0 if KO, 0 if no triggered ran, >0 if OK */ - public function runTrigger(string $action, $object, User $user, Translate $langs, Conf $conf) + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { if (empty($conf->workflow) || empty($conf->workflow->enabled)) { return 0; // Module not active, we do nothing diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 034a052ce0c..4d6a062e38b 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -77,7 +77,7 @@ class InterfaceActionsAuto extends DolibarrTriggers * @param conf $conf Object conf * @return int Return integer <0 if KO, 0 if no triggered ran, >0 if OK */ - public function runTrigger(string $action, $object, User $user, Translate $langs, Conf $conf) + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { if (!isModEnabled('agenda')) { return 0; // Module not active, we do nothing diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index 68cfccb49d5..a27ee6b7d66 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -56,7 +56,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers * @param conf $conf Object conf * @return int Return integer <0 if KO, 0 if no triggered ran, >0 if OK */ - public function runTrigger(string $action, $object, User $user, Translate $langs, Conf $conf) + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { if (empty($conf->blockedlog) || empty($conf->blockedlog->enabled)) { return 0; // Module not active, we do nothing diff --git a/htdocs/core/triggers/interface_50_modEventOrganization_EventOrganization.class.php b/htdocs/core/triggers/interface_50_modEventOrganization_EventOrganization.class.php index f54615a2aaf..445bbf4ac3c 100644 --- a/htdocs/core/triggers/interface_50_modEventOrganization_EventOrganization.class.php +++ b/htdocs/core/triggers/interface_50_modEventOrganization_EventOrganization.class.php @@ -69,7 +69,7 @@ class InterfaceEventOrganization extends DolibarrTriggers * @param conf $conf Object conf * @return int Return integer <0 if KO, 0 if no triggered ran, >0 if OK */ - public function runTrigger(string $action, $object, User $user, Translate $langs, Conf $conf) + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { if (empty($conf->eventorganization) || empty($conf->eventorganization->enabled)) { return 0; // Module not active, we do nothing diff --git a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php index 105739fa5de..1a92bca5b66 100644 --- a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php @@ -59,7 +59,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers * @param conf $conf Object conf * @return int Return integer <0 if KO, 0 if no triggered ran, >0 if OK */ - public function runTrigger(string $action, $object, User $user, Translate $langs, Conf $conf) + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { if (empty($conf->ldap) || empty($conf->ldap->enabled)) { return 0; // Module not active, we do nothing diff --git a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php index a73a0eb2eb4..5b746b971cb 100644 --- a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php @@ -57,7 +57,7 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers * @param conf $conf Object conf * @return int Return integer <0 if KO, 0 if no triggered ran, >0 if OK */ - public function runTrigger(string $action, $object, User $user, Translate $langs, Conf $conf) + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { if (empty($conf->mailmanspip) || empty($conf->mailmanspip->enabled)) { return 0; // Module not active, we do nothing diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index 602c3798c97..b9a009f7c0a 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -64,7 +64,7 @@ class InterfaceNotification extends DolibarrTriggers * @param conf $conf Object conf * @return int Return integer <0 if KO, 0 if no triggered ran, >0 if OK */ - public function runTrigger(string $action, $object, User $user, Translate $langs, Conf $conf) + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { global $hookmanager; diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index b37bd6ced34..08a24e1fc63 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -59,7 +59,7 @@ class InterfaceTicketEmail extends DolibarrTriggers * @param conf $conf Object conf * @return int Return integer <0 if KO, 0 if no triggered ran, >0 if OK */ - public function runTrigger(string $action, $object, User $user, Translate $langs, Conf $conf) + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { global $mysoc; diff --git a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php index 2d2b6db94c9..7178f29654c 100644 --- a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php +++ b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php @@ -64,7 +64,7 @@ class InterfaceStripe extends DolibarrTriggers * @param Conf $conf Object conf * @return int Return integer <0 if KO, 0 if no triggered ran, >0 if OK */ - public function runTrigger(string $action, $object, User $user, Translate $langs, Conf $conf) + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { // Put here code you want to execute when a Dolibarr business event occurs. // Data and type of action are stored into $object and $action diff --git a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php index 7c3047b03d3..6906157f6ef 100644 --- a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php +++ b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php @@ -65,7 +65,7 @@ class InterfaceContactRoles extends DolibarrTriggers * @param conf $conf Object conf * @return int Return integer <0 if KO, 0 if no triggered ran, >0 if OK */ - public function runTrigger(string $action, $object, User $user, Translate $langs, Conf $conf) + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { if ($action === 'PROPAL_CREATE' || $action === 'ORDER_CREATE' || $action === 'BILL_CREATE' || $action === 'ORDER_SUPPLIER_CREATE' || $action === 'BILL_SUPPLIER_CREATE' || $action === 'PROPOSAL_SUPPLIER_CREATE' diff --git a/htdocs/core/triggers/interface_95_modWebhook_WebhookTriggers.class.php b/htdocs/core/triggers/interface_95_modWebhook_WebhookTriggers.class.php index 70777a03ed4..c78c99fc304 100644 --- a/htdocs/core/triggers/interface_95_modWebhook_WebhookTriggers.class.php +++ b/htdocs/core/triggers/interface_95_modWebhook_WebhookTriggers.class.php @@ -65,7 +65,7 @@ class InterfaceWebhookTriggers extends DolibarrTriggers * @param Conf $conf Object conf * @return int Return integer <0 if KO, 0 if no triggered ran, >0 if OK */ - public function runTrigger(string $action, $object, User $user, Translate $langs, Conf $conf) + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { if (empty($conf->webhook) || empty($conf->webhook->enabled)) { return 0; // If module is not enabled, we do nothing diff --git a/htdocs/core/triggers/interface_95_modZapier_ZapierTriggers.class.php b/htdocs/core/triggers/interface_95_modZapier_ZapierTriggers.class.php index 701cfeec3fd..bfb4cf8ada3 100644 --- a/htdocs/core/triggers/interface_95_modZapier_ZapierTriggers.class.php +++ b/htdocs/core/triggers/interface_95_modZapier_ZapierTriggers.class.php @@ -58,7 +58,7 @@ class InterfaceZapierTriggers extends DolibarrTriggers * @param Conf $conf Object conf * @return int Return integer <0 if KO, 0 if no triggered ran, >0 if OK */ - public function runTrigger(string $action, $object, User $user, Translate $langs, Conf $conf) + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { if (empty($conf->zapier) || empty($conf->zapier->enabled)) { // Module not active, we do nothing diff --git a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php index 3ab08016799..32a980784e1 100644 --- a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php +++ b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php @@ -65,7 +65,7 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers * @param Conf $conf Object conf * @return int Return integer <0 if KO, 0 if no triggered ran, >0 if OK */ - public function runTrigger(string $action, $object, User $user, Translate $langs, Conf $conf) + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { if (!isModEnabled('mymodule')) { return 0; // If module is not enabled, we do nothing From 57181e64070233881536f8a8ee2f0c72852a9d81 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 15:28:19 +0100 Subject: [PATCH 703/714] Typo --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bb5abcf9f4c..9b0d6cfaab4 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -11765,7 +11765,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st * @param string $actionType 'default', 'danger', 'email', 'clone', 'cancel', 'delete', ... * @param string|array $url Url for link or array of subbutton description ('label'=>, 'url'=>, 'lang'=>, 'perm'=> ) * Example when an array is used: $arrayforbutaction = array( - * 10 => array('lang'=>'propal', 'enabled'=>isModEnabled("proposal"), 'perm'=>$user->hasRight('propal', 'creer'), 'label' => 'AddProp', 'url'=>'/comm/propal/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid), + * 10 => array('lang'=>'propal', 'enabled'=>isModEnabled("propal"), 'perm'=>$user->hasRight('propal', 'creer'), 'label' => 'AddProp', 'url'=>'/comm/propal/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid), * 20 => array('lang'=>'orders', 'enabled'=>isModEnabled("order"), 'perm'=>$user->hasRight('commande', 'creer'), 'label' => 'CreateOrder', 'url'=>'/commande/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid), * 30 => array('lang'=>'bills', 'enabled'=>isModEnabled("invoice"), 'perm'=>$user->hasRight('facture', 'creer'), 'label' => 'CreateBill', 'url'=>'/compta/facture/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid), * ); From 49bd37a72d37448602566dec1c206a792553f2d5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 16:02:33 +0100 Subject: [PATCH 704/714] Doc --- htdocs/admin/system/database-tables.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/system/database-tables.php b/htdocs/admin/system/database-tables.php index e122150571b..defb52235b7 100644 --- a/htdocs/admin/system/database-tables.php +++ b/htdocs/admin/system/database-tables.php @@ -168,7 +168,8 @@ if (!$base) { print '
'; print ''; print ''; From fcff03c66d68d0486a80abc0d032b2eff4f75bc9 Mon Sep 17 00:00:00 2001 From: mrozniecki Date: Mon, 18 Mar 2024 16:10:39 +0100 Subject: [PATCH 705/714] Add substitution for mail intro and signature on ticket mail --- htdocs/core/class/html.formticket.class.php | 8 ++++++-- htdocs/ticket/card.php | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 4fa8ee3eac6..471cffd2a84 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -1661,10 +1661,14 @@ class FormTicket $texttooltip .= '

'.$langs->trans("ForEmailMessageWillBeCompletedWith").'...'; } if (getDolGlobalString('TICKET_MESSAGE_MAIL_INTRO')) { - $texttooltip .= '
'.$langs->trans("TicketMessageMailIntro").'
'.getDolGlobalString('TICKET_MESSAGE_MAIL_INTRO'); + $mail_intro = make_substitutions(getDolGlobalString('TICKET_MESSAGE_MAIL_INTRO'), $this->substit); + print ''; + $texttooltip .= '
'.$langs->trans("TicketMessageMailIntro").'
'.$mail_intro; } if (getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE')) { - $texttooltip .= '

'.$langs->trans("TicketMessageMailFooter").'
'.getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE'); + $mail_signature = make_substitutions(getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE'), $this->substit); + print ''; + $texttooltip .= '

'.$langs->trans("TicketMessageMailFooter").'
'.$mail_signature; } print $form->textwithpicto('', $texttooltip, 1, 'help'); } diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 037ec5c57c4..db416fb7742 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -1536,6 +1536,7 @@ if ($action == 'create' || $action == 'presend') { $morehtmlright = ''; $help = ""; $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $arrayoffamiliestoexclude, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); $morehtmlright .= $form->textwithpicto(''.$langs->trans("TicketMessageSubstitutionReplacedByGenericValues").'', $help, 1, 'helpclickable', '', 0, 3, 'helpsubstitution'); print '
'; From 06ae1deb1b81147fb0f76acb9833ec1cb410d183 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 17:27:06 +0100 Subject: [PATCH 706/714] Fix better error message when using bad character_set_client --- htdocs/conf/conf.php.example | 7 +++---- htdocs/core/db/mysqli.class.php | 8 ++++++-- htdocs/website/index.php | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index d0ca5f7142e..4d8c4f8fadd 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -130,8 +130,8 @@ $dolibarr_main_db_user=''; // dolibarr_main_db_pass // ===================== // This parameter contains password used to read and write into Dolibarr database. -// If content is 'crypted:...', the password is encrypted/decrypted with dol_encode/dol_decode. -// If content is 'dolcrypt:...', the password is encrypted/decrypted with dolEncrypt/dolDecrypt. +// If content is 'crypted:...', the password is encrypted/decrypted with dol_encode/dol_decode. +// If content is 'dolcrypt:...', the password is encrypted/decrypted with dolEncrypt/dolDecrypt. // // Examples: // $dolibarr_main_db_pass='myadminpass'; @@ -160,6 +160,7 @@ $dolibarr_main_db_type=''; // Default value: depends on database driver // Examples: // dolibarr_main_db_character_set='utf8'; +// dolibarr_main_db_character_set='utf8mb4'; // $dolibarr_main_db_character_set='utf8'; @@ -455,5 +456,3 @@ $dolibarr_cron_allow_cli='0'; //############################## // External modules //############################## - - diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 8024bb4aa5b..ff63113e47b 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -125,11 +125,15 @@ class DoliDBMysqli extends DoliDB dol_syslog(get_class($this)."::DoliDBMysqli You should set the \$dolibarr_main_db_character_set and \$dolibarr_main_db_collation for the PHP to the one of the database ".$this->db->character_set_name(), LOG_WARNING); $this->db->set_charset($clientmustbe); // This set charset, but with a bad collation } catch (Exception $e) { - print 'Failed to force character set to '.$clientmustbe." according to setup to match the one of the server database.
\n"; + print 'Failed to force character_set_client to '.$clientmustbe." (according to setup) to match the one of the server database.
\n"; print $e->getMessage(); print "
\n"; if ($clientmustbe != 'utf8') { - print 'Edit conf/conf.php file to set a charset "utf8" instead of "'.$clientmustbe.'".'."\n"; + print 'Edit conf/conf.php file to set a charset "utf8"'; + if ($clientmustbe != 'utf8mb4') { + print ' or "utf8mb4"'; + } + print ' instead of "'.$clientmustbe.'".'."\n"; } exit; } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 2b622531dac..d64888743cb 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -683,7 +683,7 @@ if ($action == 'adddir' && $permtouploadfile) } */ -// Add site +// Add a website if ($action == 'addsite' && $usercanedit) { $db->begin(); From 13f7012d401525d80317d484bdca362e402af6c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 18:17:53 +0100 Subject: [PATCH 707/714] NEW Add maintenance tool to switch utf8 -> utf8mb4 --- htdocs/admin/system/database-tables.php | 42 +++++++---- htdocs/admin/system/dbtable.php | 94 +++++++++++++++++++++++-- htdocs/core/lib/functions.lib.php | 8 +-- 3 files changed, 120 insertions(+), 24 deletions(-) diff --git a/htdocs/admin/system/database-tables.php b/htdocs/admin/system/database-tables.php index defb52235b7..14121aebab8 100644 --- a/htdocs/admin/system/database-tables.php +++ b/htdocs/admin/system/database-tables.php @@ -39,6 +39,7 @@ if (!$user->admin) { accessforbidden(); } +$table = GETPOST('table', 'aZ09'); $action = GETPOST('action', 'aZ09'); @@ -46,16 +47,20 @@ $action = GETPOST('action', 'aZ09'); * Actions */ -if ($action == 'convert') { - $sql = "ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." ENGINE=INNODB"; +if ($action == 'convert') { // Convert engine into innodb + $sql = "ALTER TABLE ".$db->sanitize($table)." ENGINE=INNODB"; $db->query($sql); } if ($action == 'convertutf8') { - $sql = "ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." CHARACTER SET utf8 COLLATE utf8_unicode_ci"; + $sql = "ALTER TABLE ".$db->sanitize($table)." CHARACTER SET utf8 COLLATE utf8_unicode_ci"; + $db->query($sql); +} +if ($action == 'convertutf8mb4') { + $sql = "ALTER TABLE ".$db->sanitize($table)." CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"; $db->query($sql); } if ($action == 'convertdynamic') { - $sql = "ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." ROW_FORMAT=DYNAMIC;"; + $sql = "ALTER TABLE ".$db->sanitize($table)." ROW_FORMAT=DYNAMIC;"; $db->query($sql); } @@ -160,17 +165,24 @@ if (!$base) { print '
'.$langs->trans("Convert").' Dynamic'; } print ''; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; diff --git a/htdocs/admin/system/dbtable.php b/htdocs/admin/system/dbtable.php index c7e7c5baa5e..a47be52e386 100644 --- a/htdocs/admin/system/dbtable.php +++ b/htdocs/admin/system/dbtable.php @@ -33,7 +33,57 @@ if (!$user->admin) { accessforbidden(); } -$table = GETPOST('table', 'alpha'); +$table = GETPOST('table', 'aZ09'); +$field = GETPOST('field', 'aZ09'); +$action = GETPOST('action', 'aZ09'); + + +/* + * Actions + */ + +if ($action == 'convertutf8') { + $sql = "SHOW FULL COLUMNS IN ".$db->sanitize($table); + + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $row = $db->fetch_row($resql); + if ($row[0] == $field) { + $sql = 'ALTER TABLE '.$db->sanitize($table).' MODIFY '.$db->sanitize($row[0]).' '.$row[1].' CHARACTER SET utf8'; // We must not sanitize the $row[1] + $db->query($sql); + + $sql = 'ALTER TABLE '.$db->sanitize($table).' MODIFY '.$db->sanitize($row[0]).' '.$row[1].' COLLATE utf8_unicode_ci'; // We must not sanitize the $row[1] + $db->query($sql); + + break; + } + } + } +} +if ($action == 'convertutf8mb4') { + $sql = "SHOW FULL COLUMNS IN ".$db->sanitize($table); + + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $row = $db->fetch_row($resql); + if ($row[0] == $field) { + $sql = 'ALTER TABLE '.$db->sanitize($table).' MODIFY '.$db->sanitize($row[0]).' '.$row[1].' CHARACTER SET utf8mb4'; // We must not sanitize the $row[1] + $db->query($sql); + + $sql = 'ALTER TABLE '.$db->sanitize($table).' MODIFY '.$db->sanitize($row[0]).' '.$row[1].' COLLATE utf8mb4_unicode_ci'; // We must not sanitize the $row[1] + $db->query($sql); + + break; + } + } + } +} /* @@ -48,7 +98,7 @@ print load_fiche_titre($langs->trans("Table")." ".$table, '', 'title_setup'); // Define request to get table description $base = 0; if (preg_match('/mysql/i', $conf->db->type)) { - $sql = "SHOW TABLE STATUS LIKE '".$db->escape($table)."'"; + $sql = "SHOW TABLE STATUS LIKE '".$db->escape($db->escapeforlike($table))."'"; $base = 1; } elseif ($conf->db->type == 'pgsql') { $sql = "SELECT conname,contype FROM pg_constraint"; @@ -99,7 +149,7 @@ if (!$base) { print ''; // $sql = "DESCRIBE ".$table; - $sql = "SHOW FULL COLUMNS IN ".$db->escape($table); + $sql = "SHOW FULL COLUMNS IN ".$db->sanitize($table); $resql = $db->query($sql); if ($resql) { @@ -109,12 +159,46 @@ if (!$base) { $row = $db->fetch_row($resql); print ''; + // field print ""; + // type - print ""; + print ""; + // collation - print ""; + print ""; + // null print ""; // key diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9b0d6cfaab4..4a1beee4bcf 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5437,7 +5437,7 @@ function img_mime($file, $titlealt = '', $morecss = '') */ function img_search($titlealt = 'default', $other = '') { - global $conf, $langs; + global $langs; if ($titlealt == 'default') { $titlealt = $langs->trans('Search'); @@ -5460,7 +5460,7 @@ function img_search($titlealt = 'default', $other = '') */ function img_searchclear($titlealt = 'default', $other = '') { - global $conf, $langs; + global $langs; if ($titlealt == 'default') { $titlealt = $langs->trans('Search'); @@ -5682,7 +5682,7 @@ function dol_print_error($db = null, $error = '', $errors = null) */ function dol_print_error_email($prefixcode, $errormessage = '', $errormessages = array(), $morecss = 'error', $email = '') { - global $langs, $conf; + global $langs; if (empty($email)) { $email = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL'); @@ -5745,7 +5745,7 @@ function print_liste_field_titre($name, $file = "", $field = "", $begin = "", $m */ function getTitleFieldOfList($name, $thead = 0, $file = "", $field = "", $begin = "", $moreparam = "", $moreattrib = "", $sortfield = "", $sortorder = "", $prefix = "", $disablesortlink = 0, $tooltip = '', $forcenowrapcolumntitle = 0) { - global $conf, $langs, $form; + global $langs, $form; //print "$name, $file, $field, $begin, $options, $moreattrib, $sortfield, $sortorder
\n"; if ($moreattrib == 'class="right"') { From 62cf3ab098682dccfd78ad4aecdbcb5b1573764f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 19:27:52 +0100 Subject: [PATCH 708/714] Enhance error message --- htdocs/core/class/CMailFile.class.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 2ba41c28f43..11e25c2c741 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -275,8 +275,9 @@ class CMailFile // Search into the body for errors)); // Output errors set by findHtmlImagesInSrcData $this->error = 'ErrorInAddAttachementsImageBaseOnMedia'; return; } @@ -1900,8 +1901,6 @@ class CMailFile */ private function findHtmlImagesIsSrcData($images_dir) { - global $conf; - // Build the array of image extensions $extensions = array_keys($this->image_types); @@ -1927,7 +1926,7 @@ class CMailFile if (!empty($matches) && !empty($matches[1])) { if (empty($images_dir)) { // No temp directory provided, so we are not able to support convertion of data:image into physical images. - $this->error = 'NoTempDirProvidedInCMailConstructorSoCantConvertDataImgOnDisk'; + $this->errors[] = 'NoTempDirProvidedInCMailConstructorSoCantConvertDataImgOnDisk'; return -1; } @@ -1949,7 +1948,7 @@ class CMailFile dolChmod($destfiletmp); } else { $this->errors[] = "Failed to open file '".$destfiletmp."' for write"; - return -1; + return -2; } } From 04ae0f776d4d05b534e70331c9e1dec7157252b6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 20:02:08 +0100 Subject: [PATCH 709/714] FIX trackid and temp dir on payment confirmation of event registration --- htdocs/public/payment/paymentok.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index ca5db265610..62f9797d833 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -1378,7 +1378,10 @@ if ($ispaymentok) { $listofmimes = array(dol_mimetype($file)); } - $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, $listofpaths, $listofmimes, $listofnames, $cc, '', 0, $ishtml); + $trackid = 'inv'.$object->id; + $upload_dir_tmp = $conf->admin->dir_output.'/temp/'.uniqid('cmailfile'); + + $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, $listofpaths, $listofmimes, $listofnames, $cc, '', 0, $ishtml, '', '', $trackid, '', 'standard', '', $upload_dir_tmp); $result = $mailfile->sendfile(); if ($result) { From a0b7cb90d86c2f7a740654dd8a7576193929d899 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 20:02:08 +0100 Subject: [PATCH 710/714] FIX trackid and temp dir on payment confirmation of event registration --- htdocs/core/class/CMailFile.class.php | 6 ++++++ htdocs/public/payment/paymentok.php | 18 ++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 11e25c2c741..3539c62b6cf 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1901,9 +1901,15 @@ class CMailFile */ private function findHtmlImagesIsSrcData($images_dir) { + global $conf; + // Build the array of image extensions $extensions = array_keys($this->image_types); + if (empty($images_dir)) { + $images_dir = $conf->admin->dir_output.'/temp/'.uniqid('cmailfile'); + } + if ($images_dir && !dol_is_dir($images_dir)) { dol_mkdir($images_dir, DOL_DATA_ROOT); } diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index ca5db265610..3c710691bdd 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -1378,7 +1378,9 @@ if ($ispaymentok) { $listofmimes = array(dol_mimetype($file)); } - $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, $listofpaths, $listofmimes, $listofnames, $cc, '', 0, $ishtml); + $trackid = 'inv'.$object->id; + + $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, $listofpaths, $listofmimes, $listofnames, $cc, '', 0, $ishtml, '', '', $trackid, '', 'standard'); $result = $mailfile->sendfile(); if ($result) { @@ -1569,8 +1571,9 @@ if ($ispaymentok) { $urlback = $_SERVER["REQUEST_URI"]; $ishtml = dol_textishtml($texttosend); // May contain urls + $trackid = 'inv'.$invoice->id; - $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml); + $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml, '', '', $trackid, '', 'standard'); $result = $mailfile->sendfile(); if ($result) { @@ -1777,10 +1780,7 @@ if ($ispaymentok) { print $conf->global->$key; } - $sendemail = ''; - if (getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL')) { - $sendemail = $conf->global->ONLINE_PAYMENT_SENDEMAIL; - } + $sendemail = getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL'); $tmptag = dolExplodeIntoArray($fulltag, '.', '='); @@ -1860,9 +1860,10 @@ if ($ispaymentok) { $ishtml = dol_textishtml($content); // May contain urls + $trackid = ''; require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($topic, $sendto, $from, $content, array(), array(), array(), '', '', 0, $ishtml); + $mailfile = new CMailFile($topic, $sendto, $from, $content, array(), array(), array(), '', '', 0, $ishtml, '', '', $trackid, '', 'standard'); $result = $mailfile->sendfile(); if ($result) { @@ -1941,9 +1942,10 @@ if ($ispaymentok) { $ishtml = dol_textishtml($content); // May contain urls + $trackid = ''; require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($topic, $sendto, $from, $content, array(), array(), array(), '', '', 0, $ishtml); + $mailfile = new CMailFile($topic, $sendto, $from, $content, array(), array(), array(), '', '', 0, $ishtml, '', '', $trackid, '', 'standard'); $result = $mailfile->sendfile(); if ($result) { From 1a82c5e8ced5270313c6391787490fd891d1d9bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 20:38:51 +0100 Subject: [PATCH 711/714] Fix warnings --- htdocs/admin/mails_templates.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index ae1f8bf67d1..546427463da 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -681,7 +681,7 @@ if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu // Confirm deletion of record if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.((int) $rowid).'&code='.urlencode($code).'&id='.((int) $id), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.((int) $rowid).'&id='.((int) $id), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); } @@ -1101,7 +1101,7 @@ if ($num) { } print "\n"; - print ''; + print ''; print '\n"; - print ''; + print ''; print '
'; - print($salaryBonPl ? $salarytmp->getNomUrl(1) : $invoicetmp->getNomUrl(1)); + print $itemurl; print "'; print dol_escape_htmltag($invoicetmp->ref_supplier); print "'; - print($salaryBonPl ? $usertmp->getNomUrl(-1) : $thirdpartytmp->getNomUrl(1)); + print $partyurl; print "'.$obj->Auto_increment.''.$obj->Check_time.''.$obj->Collation; - if (isset($obj->Collation) && (in_array($obj->Collation, array("utf8mb4_general_ci", "utf8mb4_unicode_ci", "latin1_swedish_ci")))) { + // Accept utf8, utf8mb3_unicode_ci, utf8mb4_unicode_ci + if (isset($obj->Collation) && (in_array($obj->Collation, array("utf8mb4_general_ci", "latin1_swedish_ci")))) { print '
'.$langs->trans("Convert").' UTF8'; } print '
'.$obj->Rows.''.$obj->Avg_row_length.''.$obj->Data_length.''.$obj->Max_data_length.''.$obj->Index_length.''.$obj->Auto_increment.''.$obj->Check_time.''.$obj->Collation; - // Accept utf8, utf8mb3_unicode_ci, utf8mb4_unicode_ci - if (isset($obj->Collation) && (in_array($obj->Collation, array("utf8mb4_general_ci", "latin1_swedish_ci")))) { - print '
'.$langs->trans("Convert").' UTF8'; + print '
'.$obj->Rows.''.$obj->Avg_row_length.''.$obj->Data_length.''.$obj->Max_data_length.''.$obj->Index_length.''.$obj->Auto_increment.''.$obj->Check_time.''.$obj->Collation; + // Link to convert collation + if (isset($obj->Collation)) { + print '
'.$langs->trans("ConvertInto"); + if (!in_array($obj->Collation, array("utf8_unicode_ci"))) { + print ' utf8'; + } + if (!in_array($obj->Collation, array("utf8mb4_unicode_ci"))) { + print ' utf8mb4'; + } + print ''; } print '
".$row[0]."".$row[1].""; + $proptype = $row[1]; + $pictoType = ''; + $matches = array(); + if (preg_match('/^varchar/', $proptype, $matches)) { + $pictoType = 'varchar'; + } elseif (strpos($proptype, 'int') === 0 || strpos($proptype, 'tinyint') === 0 || strpos($proptype, 'bigint') === 0) { + $pictoType = 'int'; + } elseif (strpos($proptype, 'timestamp') === 0) { + $pictoType = 'datetime'; + } elseif (strpos($proptype, 'real') === 0) { + $pictoType = 'double'; + } + print(!empty($pictoType) ? getPictoForType($pictoType) : getPictoForType($proptype)).''.dol_escape_htmltag($proptype).''; + print "".$row[2]."".(empty($row[2]) ? ' ' : $row[2]); + + // Link to convert collation + if (isset($row[2])) { + print '
'.$langs->trans("ConvertInto"); + if (!in_array($row[2], array("utf8_unicode_ci"))) { + print ' utf8'; + } + if (!in_array($row[2], array("utf8mb4_unicode_ci"))) { + print ' utf8mb4'; + } + print ''; + } else { + print '
 '; + } + + print "
".$row[3]."
'; $fieldsforcontent = array('topic', 'email_from','joinfiles', 'content'); From ae41b07b705aad3f99fdc7eb997c0bbfd2ad35d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 20:51:47 +0100 Subject: [PATCH 712/714] Fix trans --- htdocs/langs/en_US/admin.lang | 3 ++- htdocs/langs/en_US/eventorganization.lang | 1 + htdocs/public/eventorganization/attendee_new.php | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index f20f46f5c03..ed6431ff1d6 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1666,7 +1666,7 @@ LDAPDescUsers=This page allows you to define LDAP attributes name in LDAP tree f LDAPDescGroups=This page allows you to define LDAP attributes name in LDAP tree for each data found on Dolibarr groups. LDAPDescMembers=This page allows you to define LDAP attributes name in LDAP tree for each data found on Dolibarr members module. LDAPDescMembersTypes=This page allows you to define LDAP attributes name in LDAP tree for each data found on Dolibarr members types. -LDAPDescValues=Example values are designed for OpenLDAP with following loaded schemas: core.schema, cosine.schema, inetorgperson.schema). If you use thoose values and OpenLDAP, modify your LDAP config file slapd.conf to have all thoose schemas loaded. +LDAPDescValues=Example values are designed for OpenLDAP with following loaded schemas: core.schema, cosine.schema, inetorgperson.schema). If you use those values and OpenLDAP, modify your LDAP config file slapd.conf to have all those schemas loaded. ForANonAnonymousAccess=For an authenticated access (for a write access for example) PerfDolibarr=Performance setup/optimizing report YouMayFindPerfAdviceHere=This page provides some checks or advice related to performance. @@ -2452,3 +2452,4 @@ VideoGeneration=Video generation AudioText=Audio - Text AIPromptForFeatures=AI custom prompts for features EnterAnIP=Enter an IP address +ConvertInto=Convert into diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 9d3b5c5fb08..e0e26dc460b 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -27,6 +27,7 @@ EventOrganizationMenuLeft = Organized events EventOrganizationConferenceOrBoothMenuLeft = Conference Or Booth PaymentEvent=Payment of event +EventFee=Event fee # # Admin page diff --git a/htdocs/public/eventorganization/attendee_new.php b/htdocs/public/eventorganization/attendee_new.php index 3d6db67046d..3eb22bceb3a 100644 --- a/htdocs/public/eventorganization/attendee_new.php +++ b/htdocs/public/eventorganization/attendee_new.php @@ -510,6 +510,8 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen // TODO Use default language of $thirdparty->default_lang to build $outputlang + $outputlangs->loadLangs(array("eventorganization")); + // Get product to use for invoice $productforinvoicerow = new Product($db); $productforinvoicerow->id = 0; @@ -629,7 +631,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang); // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members")); + $outputlangs->loadLangs(array("main", "members", "eventorganization")); // Get email content from template $arraydefaultmessage = null; From dfa9ed67d07b9af4a4f7cf3e3e23f15c5519f170 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 20:38:51 +0100 Subject: [PATCH 713/714] Fix warnings --- htdocs/admin/mails_templates.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index cabbe69c319..7a6d513c589 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -681,7 +681,7 @@ if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu // Confirm deletion of record if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.((int) $rowid).'&code='.urlencode($code).'&id='.((int) $id), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.((int) $rowid).'&id='.((int) $id), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); } @@ -1096,7 +1096,7 @@ if ($num) { } print "
'; $fieldsforcontent = array('topic', 'email_from','joinfiles', 'content'); From 08ed8f9aaffba580ba2519d4700a4f7bed55e096 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Mar 2024 20:51:47 +0100 Subject: [PATCH 714/714] Fix trans --- htdocs/langs/en_US/admin.lang | 5 +++-- htdocs/langs/en_US/eventorganization.lang | 1 + htdocs/public/eventorganization/attendee_new.php | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 931cb74aa11..2d89a39b03a 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1669,7 +1669,7 @@ LDAPDescUsers=This page allows you to define LDAP attributes name in LDAP tree f LDAPDescGroups=This page allows you to define LDAP attributes name in LDAP tree for each data found on Dolibarr groups. LDAPDescMembers=This page allows you to define LDAP attributes name in LDAP tree for each data found on Dolibarr members module. LDAPDescMembersTypes=This page allows you to define LDAP attributes name in LDAP tree for each data found on Dolibarr members types. -LDAPDescValues=Example values are designed for OpenLDAP with following loaded schemas: core.schema, cosine.schema, inetorgperson.schema). If you use thoose values and OpenLDAP, modify your LDAP config file slapd.conf to have all thoose schemas loaded. +LDAPDescValues=Example values are designed for OpenLDAP with following loaded schemas: core.schema, cosine.schema, inetorgperson.schema). If you use those values and OpenLDAP, modify your LDAP config file slapd.conf to have all those schemas loaded. ForANonAnonymousAccess=For an authenticated access (for a write access for example) PerfDolibarr=Performance setup/optimizing report YouMayFindPerfAdviceHere=This page provides some checks or advice related to performance. @@ -2442,4 +2442,5 @@ RecommendedForProduction=Recommended for Production RecommendedForDebug=Recommended for Debug ExportUseForce=Use the parameter -f ExportUseForceHelp=Force to continue the export even when an error is found (Backup may not be reliable) -EnterAnIP=Enter an IP address \ No newline at end of file +EnterAnIP=Enter an IP address +ConvertInto=Convert into diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 30c3f5d6b59..4dda951377a 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -27,6 +27,7 @@ EventOrganizationMenuLeft = Organized events EventOrganizationConferenceOrBoothMenuLeft = Conference Or Booth PaymentEvent=Payment of event +EventFee=Event fee # # Admin page diff --git a/htdocs/public/eventorganization/attendee_new.php b/htdocs/public/eventorganization/attendee_new.php index a2175e26ae3..154cac787c5 100644 --- a/htdocs/public/eventorganization/attendee_new.php +++ b/htdocs/public/eventorganization/attendee_new.php @@ -510,6 +510,8 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen // TODO Use default language of $thirdparty->default_lang to build $outputlang + $outputlangs->loadLangs(array("eventorganization")); + // Get product to use for invoice $productforinvoicerow = new Product($db); $productforinvoicerow->id = 0; @@ -629,7 +631,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang); // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members")); + $outputlangs->loadLangs(array("main", "members", "eventorganization")); // Get email content from template $arraydefaultmessage = null;