diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index 4e98d2d655e..02bff396fb4 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -6576,12 +6576,6 @@ parameters: count: 1 path: ../../../htdocs/compta/sociales/card.php - - - message: '#^Variable \$resteapayer might not be defined\.$#' - identifier: variable.undefined - count: 3 - path: ../../../htdocs/compta/sociales/card.php - - message: '#^Negated boolean expression is always true\.$#' identifier: booleanNot.alwaysTrue @@ -16170,12 +16164,6 @@ parameters: count: 2 path: ../../../htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php - - - message: '#^Variable \$old_MAIN_MAIL_AUTOCOPY_TO might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php - - message: '#^Call to function method_exists\(\) with Contact and ''getContactRoles'' will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -19593,13 +19581,7 @@ parameters: - message: '#^Variable \$begin might not be defined\.$#' identifier: variable.undefined - count: 5 - path: ../../../htdocs/fourn/contact.php - - - - message: '#^Variable \$contactname might not be defined\.$#' - identifier: variable.undefined - count: 1 + count: 3 path: ../../../htdocs/fourn/contact.php - @@ -19608,12 +19590,6 @@ parameters: count: 4 path: ../../../htdocs/fourn/contact.php - - - message: '#^Variable \$stcomm might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../../htdocs/fourn/contact.php - - message: '#^If condition is always false\.$#' identifier: if.alwaysFalse @@ -22290,12 +22266,6 @@ parameters: count: 2 path: ../../../htdocs/loan/class/loanschedule.class.php - - - message: '#^Negated boolean expression is always true\.$#' - identifier: booleanNot.alwaysTrue - count: 1 - path: ../../../htdocs/loan/class/paymentloan.class.php - - message: '#^Property PaymentLoan\:\:\$amount_capital \(float\|int\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -31926,12 +31896,6 @@ parameters: count: 1 path: ../../../htdocs/variants/class/ProductCombination.class.php - - - message: '#^Negated boolean expression is always false\.$#' - identifier: booleanNot.alwaysFalse - count: 1 - path: ../../../htdocs/variants/class/ProductCombination.class.php - - message: '#^Property ProductCombination\:\:\$variation_price_percentage type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -32628,21 +32592,9 @@ parameters: count: 4 path: ../../../htdocs/website/index.php - - - message: '#^Comparison operation "\>\=" between 1 and 0 is always true\.$#' - identifier: greaterOrEqual.alwaysTrue - count: 1 - path: ../../../htdocs/website/samples/wrapper.php - - message: '#^If condition is always false\.$#' identifier: if.alwaysFalse - count: 3 - path: ../../../htdocs/website/samples/wrapper.php - - - - message: '#^If condition is always true\.$#' - identifier: if.alwaysTrue count: 1 path: ../../../htdocs/website/samples/wrapper.php diff --git a/dev/initdata/generate-invoice.php b/dev/initdata/generate-invoice.php index 3f4a701b0c4..2cd9ecbcae5 100755 --- a/dev/initdata/generate-invoice.php +++ b/dev/initdata/generate-invoice.php @@ -150,7 +150,7 @@ while ($i < GEN_NUMBER_FACTURE && $result >= 0) { $fuser = new User($db); $fuser->fetch(mt_rand(1, 2)); - $fuser->getRights(); + $fuser->loadRights(); $result=$object->create($fuser); if ($result >= 0) { diff --git a/dev/initdata/generate-order.php b/dev/initdata/generate-order.php index fc110907ce5..c08675468c1 100755 --- a/dev/initdata/generate-order.php +++ b/dev/initdata/generate-order.php @@ -180,7 +180,7 @@ for ($s = 0; $s < GEN_NUMBER_COMMANDE; $s++) { $fuser = new User($db); $fuser->fetch($listofuserid[mt_rand(0, 2)]); - $fuser->getRights(); + $fuser->loadRights(); $db->begin(); diff --git a/dev/initdata/generate-proposal.php b/dev/initdata/generate-proposal.php index 59298a44e69..7d7f5f59161 100755 --- a/dev/initdata/generate-proposal.php +++ b/dev/initdata/generate-proposal.php @@ -171,7 +171,7 @@ while ($i < GEN_NUMBER_PROPAL && $result >= 0) { $fuser = new User($db); $fuser->fetch(mt_rand(1, 2)); - $fuser->getRights(); + $fuser->loadRights(); $object->contactid = $contids[$socids[$socid]][0]; $object->socid = $socids[$socid]; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index bc7e0c14462..ddc70d21c85 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -763,6 +763,11 @@ class Adherent extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + $nbrowsaffected = 0; $error = 0; diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 6a65bc99ced..db18500629c 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2017 Regis Houssin * Copyright (C) 2020 Thibault FOUCART * Copyright (C) 2020-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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 @@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; class Members extends DolibarrApi { /** - * @var string[] $FIELDS Mandatory fields, checked when create and update object + * @var string[] Mandatory fields, checked when create and update object */ public static $FIELDS = array( 'morphy', @@ -159,7 +159,7 @@ class Members extends DolibarrApi throw new RestException(404, 'member not found'); } } else { - throw new RestException(404, 'This account have many thirdparties attached or does not exist.'); + throw new RestException(404, 'This account have many thirdparties attached or does not exist.'); } if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) { @@ -355,7 +355,9 @@ class Members extends DolibarrApi /** * Create member object * - * @param array $request_data Request data + * @param array $request_data Request data + * @phan-param ?array $request_data + * @phpstan-param ?array $request_data * @return int ID of member * * @throws RestException 403 Access denied diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 32e9e105fa2..36c10eb7429 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2025 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 @@ -28,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; class MembersTypes extends DolibarrApi { /** - * @var array $FIELDS Mandatory fields, checked when create and update object + * @var string[] Mandatory fields, checked when create and update object */ public static $FIELDS = array( 'label', @@ -39,7 +40,7 @@ class MembersTypes extends DolibarrApi */ public function __construct() { - global $db, $conf; + global $db; $this->db = $db; } @@ -84,13 +85,13 @@ class MembersTypes extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.libelle:like:'SO-%') and (t.subscription:=:'1')" * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names * @return array Array of member type objects + * @phan-return AdherentType[] + * @phpstan-return AdherentType[] * * @throws RestException */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '') { - global $db, $conf; - $obj_ret = array(); if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { @@ -143,7 +144,9 @@ class MembersTypes extends DolibarrApi /** * Create member type object * - * @param array $request_data Request data + * @param array $request_data Request data + * @phan-param ?array $request_data + * @phpstan-param ?array $request_data * @return int ID of member type */ public function post($request_data = null) @@ -151,8 +154,8 @@ class MembersTypes extends DolibarrApi if (!DolibarrApiAccess::$user->hasRight('adherent', 'configurer')) { throw new RestException(401); } - // Check mandatory fields - $result = $this->_validate($request_data); + // Check mandatory fields. Throw exception on error. + $this->_validate($request_data); $membertype = new AdherentType($this->db); foreach ($request_data as $field => $value) { @@ -175,7 +178,9 @@ class MembersTypes extends DolibarrApi * * @param int $id ID of member type to update * @param array $request_data Datas - * @return int + * @phan-param ?array $request_data + * @phpstan-param ?array $request_data + * @return Object */ public function put($id, $request_data = null) { @@ -227,6 +232,8 @@ class MembersTypes extends DolibarrApi * * @param int $id member type ID * @return array + * @phan-return array + * @phpstan-return array */ public function delete($id) { @@ -261,8 +268,8 @@ class MembersTypes extends DolibarrApi /** * Validate fields before creating an object * - * @param array|null $data Data to validate - * @return array + * @param ?array $data Data to validate + * @return array * * @throws RestException */ @@ -282,8 +289,8 @@ class MembersTypes extends DolibarrApi /** * Clean sensible object datas * - * @param Object $object Object to clean - * @return Object Object with cleaned properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index d3d0c3c2ddf..45a30fdef82 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -760,6 +760,11 @@ class Account extends CommonObject $this->status = $this->clos; } + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + // Load the library to validate/check a BAN account require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; @@ -900,6 +905,11 @@ class Account extends CommonObject { global $langs, $conf; + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + $error = 0; $this->db->begin(); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index bb5431eb32b..ebede310b25 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4743,19 +4743,21 @@ if ($action == 'create') { print ' '.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1, '', 32)).''; } - $facidavoir = $object->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) { + // Retrieve credit note ids + $object->getListIdAvoirFromInvoice(); + + if (!empty($object->creditnote_ids)) { print ' '.$langs->transnoentities("InvoiceHasAvoir"); $i = 0; - foreach ($facidavoir as $id) { + foreach ($object->creditnote_ids as $invoiceid) { if ($i == 0) { print ' '; } else { print ','; } - $facavoir = new Facture($db); - $facavoir->fetch($id); - print $facavoir->getNomUrl(1, '', 32); + $creditnote = new Facture($db); + $creditnote->fetch($invoiceid); + print $creditnote->getNomUrl(1, '', 32); } print ''; } diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 1476eb8e764..d58000dd683 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -149,6 +149,9 @@ class Invoices extends DolibarrApi throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + // Retrieve credit note ids + $this->invoice->getListIdAvoirFromInvoice(); + // Add external contacts ids if ($contact_list > -1) { $tmparray = $this->invoice->liste_contact(-1, 'external', $contact_list); @@ -268,6 +271,9 @@ class Invoices extends DolibarrApi $invoice_static->totaldeposits = $invoice_static->getSumDepositsUsed(); $invoice_static->remaintopay = price2num($invoice_static->total_ttc - $invoice_static->totalpaid - $invoice_static->totalcreditnotes - $invoice_static->totaldeposits, 'MT'); + // Retrieve credit note ids + $invoice_static->getListIdAvoirFromInvoice(); + // Add external contacts ids $tmparray = $invoice_static->liste_contact(-1, 'external', 1); if (is_array($tmparray)) { diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 50a513a994f..fd22234a7a9 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -439,17 +439,19 @@ if ($object->id > 0) { print ' '.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).''; } - $facidavoir = $object->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) { + // Retrieve credit note ids + $object->getListIdAvoirFromInvoice(); + + if (!empty($object->creditnote_ids)) { $invoicecredits = array(); - foreach ($facidavoir as $facid) { + foreach ($object->creditnote_ids as $invoiceid) { if ($type == 'bank-transfer') { - $facavoir = new FactureFournisseur($db); + $creditnote = new FactureFournisseur($db); } else { - $facavoir = new Facture($db); + $creditnote = new Facture($db); } - $facavoir->fetch($facid); - $invoicecredits[] = $facavoir->getNomUrl(1); + $creditnote->fetch($invoiceid); + $invoicecredits[] = $creditnote->getNomUrl(1); } print ' '.$langs->transnoentities("InvoiceHasAvoir"); print ' '. (count($invoicecredits) ? ' ' : '') . implode(',', $invoicecredits); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index e2961594ea4..e785fc0a520 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -607,6 +607,11 @@ class Contact extends CommonObject { global $conf; + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + $error = 0; $this->id = $id; diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index 22a1d2d84d2..81be08a78b8 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -1,6 +1,7 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW + * Copyright (C) 2025 Charlene Benke * * 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 @@ -46,28 +47,29 @@ class Ccountry extends CommonDict public $code_iso; /** - * @var array|string,position:int,notnull?:int,visible:int<-5,5>|string,alwayseditable?:int<0,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,4>,disabled?:int<0,1>,arrayofkeyval?:array,autofocusoncreate?:int<0,1>,comment?:string,copytoclipboard?:int<1,2>,validate?:int<0,1>,showonheader?:int<0,1>}> + * @var string */ - public $fields = array( - 'label' => array('type' => 'varchar(250)', 'label' => 'Label', 'enabled' => 1, 'visible' => 1, 'position' => 15, 'notnull' => -1, 'showoncombobox' => 1) - ); + public $ecc; /** * @var int */ public $favorite; - /** - * @var int - */ - public $eec; - /** * @var string */ public $numeric_code; + /** + * @var array|string,position:int,notnull?:int,visible:int<-5,5>|string,alwayseditable?:int<0,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,4>,disabled?:int<0,1>,arrayofkeyval?:array,autofocusoncreate?:int<0,1>,comment?:string,copytoclipboard?:int<1,2>,validate?:int<0,1>,showonheader?:int<0,1>}> + */ + public $fields = array( + 'label' => array('type' => 'varchar(250)', 'label' => 'Label', 'enabled' => 1, 'visible' => 1, 'position' => 15, 'notnull' => -1, 'showoncombobox' => 1) + ); + + /** * Constructor * @@ -190,9 +192,9 @@ class Ccountry extends CommonDict $this->code = $obj->code; $this->code_iso = $obj->code_iso; $this->label = $obj->label; + $this->ecc = $obj->ecc; $this->active = $obj->active; $this->favorite = $obj->favorite; - $this->eec = $obj->eec; $this->numeric_code = $obj->numeric_code; } diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 321533eb28d..13561f2de64 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -162,6 +162,11 @@ abstract class CommonInvoice extends CommonObject */ public $nbofopendirectdebitorcredittransfer; + /** + * @var int[] return of getListIdAvoirFromInvoice() + */ + public $creditnote_ids; + /** * @var int */ @@ -450,6 +455,9 @@ abstract class CommonInvoice extends CommonObject } else { dol_print_error($this->db); } + + $this->creditnote_ids = $idarray; + return $idarray; } diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index 40cd8f49827..d518d284c8e 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2014-2016 Jean-François Ferry * 2016 Christophe Battarel * Copyright (C) 2023 Benjamin Falière - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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 @@ -178,6 +178,7 @@ class InterfaceTicketEmail extends DolibarrTriggers if (!getDolGlobalString('TICKET_DISABLE_ALL_MAILS')) { // Send email to assigned user $sendto = $userstat->email; + $old_MAIN_MAIL_AUTOCOPY_TO = null; if (!getDolGlobalString('TICKET_DISABLE_MAIL_AUTOCOPY_TO')) { $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; @@ -206,6 +207,7 @@ class InterfaceTicketEmail extends DolibarrTriggers if (!getDolGlobalString('TICKET_DISABLE_ALL_MAILS')) { // Send email to assigned user $sendto = $userstat->email; + $old_MAIN_MAIL_AUTOCOPY_TO = null; if (!getDolGlobalString('TICKET_DISABLE_MAIL_AUTOCOPY_TO')) { $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index ae52a4705fa..76c286cbcb4 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -1,9 +1,9 @@ - * Copyright (C) 2016 Laurent Destailleur - * Copyright (C) 2023 Joachim Kueter - * Copyright (C) 2024 MDW - * Copyright (C) 2024 Frédéric France +/* Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2023 Joachim Kueter + * 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 @@ -82,6 +82,9 @@ class SupplierInvoices extends DolibarrApi throw new RestException(404, 'Supplier invoice not found'); } + // Retrieve credit note ids + $this->invoice->getListIdAvoirFromInvoice(); + $this->invoice->fetchObjectLinked(); return $this->_cleanObjectDatas($this->invoice); } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 39d971bba99..ab1ce229e1f 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -3339,13 +3339,15 @@ if ($action == 'create') { } } - $facidavoir = $object->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) { + // Retrieve credit note ids + $object->getListIdAvoirFromInvoice(); + + if (!empty($object->creditnote_ids)) { $invoicecredits = array(); - foreach ($facidavoir as $id) { - $facavoir = new FactureFournisseur($db); - $facavoir->fetch($id); - $invoicecredits[] = $facavoir->getNomUrl(1); + foreach ($object->creditnote_ids as $invoiceid) { + $creditnote = new FactureFournisseur($db); + $creditnote->fetch($invoiceid); + $invoicecredits[] = $creditnote->getNomUrl(1); } print ' '.$langs->transnoentities("InvoiceHasAvoir") . (count($invoicecredits) ? ' ' : '') . implode(',', $invoicecredits); print ''; diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index d15646059f3..5fd19773108 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -211,13 +211,15 @@ if ($id > 0 || !empty($ref)) { print ' '.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)); } - $facidavoir = $object->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) { + // Retrieve credit note ids + $object->getListIdAvoirFromInvoice(); + + if (!empty($object->creditnote_ids)) { $invoicecredits = array(); - foreach ($facidavoir as $facid) { - $facavoir = new FactureFournisseur($db); - $facavoir->fetch($facid); - $invoicecredits[] = $facavoir->getNomUrl(1); + foreach ($object->creditnote_ids as $invoiceid) { + $creditnote = new FactureFournisseur($db); + $creditnote->fetch($invoiceid); + $invoicecredits[] = $creditnote->getNomUrl(1); } print ' '.$langs->transnoentities("InvoiceHasAvoir") . (count($invoicecredits) ? ' ' : '') . implode(',', $invoicecredits); } diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index ddbf73ccf39..75d961308b0 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -187,13 +187,15 @@ if ($object->id > 0) { print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; } - $facidavoir = $object->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) { + // Retrieve credit note ids + $object->getListIdAvoirFromInvoice(); + + if (!empty($object->creditnote_ids)) { $invoicecredits = array(); - foreach ($facidavoir as $facid) { - $facavoir = new FactureFournisseur($db); - $facavoir->fetch($facid); - $invoicecredits[] = $facavoir->getNomUrl(1); + foreach ($object->creditnote_ids as $invoiceid) { + $creditnote = new FactureFournisseur($db); + $creditnote->fetch($invoiceid); + $invoicecredits[] = $creditnote->getNomUrl(1); } print ' ('.$langs->transnoentities("InvoiceHasAvoir") . (count($invoicecredits) ? ' ' : '') . implode(',', $invoicecredits) . ')'; } diff --git a/htdocs/fourn/facture/note.php b/htdocs/fourn/facture/note.php index 0f9d53b18d3..001797dc5a6 100644 --- a/htdocs/fourn/facture/note.php +++ b/htdocs/fourn/facture/note.php @@ -169,13 +169,15 @@ if ($object->id > 0) { print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; } - $facidavoir = $object->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) { + // Retrieve credit note ids + $object->getListIdAvoirFromInvoice(); + + if (!empty($object->creditnote_ids)) { $invoicecredits = array(); - foreach ($facidavoir as $facid) { - $facavoir = new FactureFournisseur($db); - $facavoir->fetch($facid); - $invoicecredits[] = $facavoir->getNomUrl(1); + foreach ($object->creditnote_ids as $invoiceid) { + $creditnote = new FactureFournisseur($db); + $creditnote->fetch($invoiceid); + $invoicecredits[] = $creditnote->getNomUrl(1); } print ' ('.$langs->transnoentities("InvoiceHasAvoir") . implode(',', $invoicecredits) . ')'; } diff --git a/htdocs/install/mysql/data/llx_accounting_journal.sql b/htdocs/install/mysql/data/llx_accounting_journal.sql new file mode 100644 index 00000000000..fd5e634d66f --- /dev/null +++ b/htdocs/install/mysql/data/llx_accounting_journal.sql @@ -0,0 +1,57 @@ +-- Copyright (C) 2001-2004 Rodolphe Quiedeville +-- Copyright (C) 2003 Jean-Louis Bergamo +-- Copyright (C) 2004-2009 Laurent Destailleur +-- Copyright (C) 2004 Benoit Mortier +-- Copyright (C) 2004 Guillaume Delecourt +-- Copyright (C) 2005-2025 Regis Houssin +-- Copyright (C) 2007 Patrick Raguin +-- Copyright (C) 2011-2022 Alexandre Spangaro +-- Copyright (C) 2015-2017 Juanjo Menent +-- Copyright (C) 2018 Abbes bahfir +-- Copyright (C) 2020 Udo Tamm +-- Copyright (C) 2023 Nick Fragoulis +-- Copyright (C) 2023 Santiago Payà +-- +-- +-------------------------------------------------------------------------------------- +-- License +-- ####### +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-------------------------------------------------------------------------------------- + +-- Comment +-- ####### +-- (EN) +-- Do not place a comment at the end of the line, this file is parsed at the end of the line. +-- from the install and all '--' are removed. +-- +-- (FR) +-- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors +-- de l'install et tous les sigles '--' sont supprimés. +-- +-------------------------------------------------------------------------------------- +-- PCG = Plan Comptable Général (FR) - General Accounting Plan (EN) +-------------------------------------------------------------------------------------- + + +-- Accounting Journals + +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('VT', 'ACCOUNTING_SELL_JOURNAL', 2, 1, __ENTITY__); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('AC', 'ACCOUNTING_PURCHASE_JOURNAL', 3, 1, __ENTITY__); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('BQ', 'FinanceJournal', 4, 1, __ENTITY__); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('OD', 'ACCOUNTING_MISCELLANEOUS_JOURNAL', 1, 1, __ENTITY__); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('AN', 'ACCOUNTING_HAS_NEW_JOURNAL', 9, 1, __ENTITY__); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('ER', 'ExpenseReportsJournal', 5, 1, __ENTITY__); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('INV', 'InventoryJournal', 8, 1, __ENTITY__); diff --git a/htdocs/install/mysql/data/llx_accounting_abc.sql b/htdocs/install/mysql/data/llx_accounting_system.sql similarity index 91% rename from htdocs/install/mysql/data/llx_accounting_abc.sql rename to htdocs/install/mysql/data/llx_accounting_system.sql index d748aa7f4fa..2def811073e 100644 --- a/htdocs/install/mysql/data/llx_accounting_abc.sql +++ b/htdocs/install/mysql/data/llx_accounting_system.sql @@ -3,7 +3,7 @@ -- Copyright (C) 2004-2009 Laurent Destailleur -- Copyright (C) 2004 Benoit Mortier -- Copyright (C) 2004 Guillaume Delecourt --- Copyright (C) 2005-2009 Regis Houssin +-- Copyright (C) 2005-2025 Regis Houssin -- Copyright (C) 2007 Patrick Raguin -- Copyright (C) 2011-2022 Alexandre Spangaro -- Copyright (C) 2015-2017 Juanjo Menent @@ -46,17 +46,6 @@ -------------------------------------------------------------------------------------- --- Accounting Journals - -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('VT', 'ACCOUNTING_SELL_JOURNAL', 2, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('AC', 'ACCOUNTING_PURCHASE_JOURNAL', 3, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('BQ', 'FinanceJournal', 4, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('OD', 'ACCOUNTING_MISCELLANEOUS_JOURNAL', 1, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('AN', 'ACCOUNTING_HAS_NEW_JOURNAL', 9, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('ER', 'ExpenseReportsJournal', 5, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('INV', 'InventoryJournal', 8, 1, 1); - - -- Accounting Charts / Plans (Templates) for Countries -- Description of chart of account FR PCG25-DEV diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index fa3cc2b2d4e..7c72797d446 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1423,6 +1423,10 @@ class Product extends CommonObject if (empty($this->country_id)) { $this->country_id = 0; } + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } if (empty($this->state_id)) { $this->state_id = 0; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 3ca48bbd39d..76ddc84ecfb 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -255,6 +255,10 @@ class Entrepot extends CommonObject $this->error = "ErrorFieldRequired"; return 0; } + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } $now = dol_now(); @@ -325,6 +329,11 @@ class Entrepot extends CommonObject */ public function update($id, $user, $notrigger = 0) { + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + $error = 0; if (empty($id)) { diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 0eb947f56a6..4fc99beac08 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1658,7 +1658,8 @@ if ($action == 'create' && $user->hasRight('projet', 'creer')) { // Validate if ($object->status == Project::STATUS_DRAFT && $user->hasRight('projet', 'creer')) { if ($userWrite > 0) { - print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=validate&token='.newToken().'&id='.$object->id, ''); + //print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=validate&token='.newToken().'&id='.$object->id, ''); + print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=confirm_validate&confirm=yes&token='.newToken().'&id='.$object->id, ''); } else { print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('Validate'), 'default', $_SERVER['PHP_SELF']. '#', '', false); } @@ -1667,7 +1668,8 @@ if ($action == 'create' && $user->hasRight('projet', 'creer')) { // Close if ($object->status == Project::STATUS_VALIDATED && $user->hasRight('projet', 'creer')) { if ($userWrite > 0) { - print dolGetButtonAction('', $langs->trans('Close'), 'default', $_SERVER["PHP_SELF"].'?action=close&token='.newToken().'&id='.$object->id, ''); + //print dolGetButtonAction('', $langs->trans('Close'), 'default', $_SERVER["PHP_SELF"].'?action=close&token='.newToken().'&id='.$object->id, ''); + print dolGetButtonAction('', $langs->trans('Close'), 'default', $_SERVER["PHP_SELF"].'?action=confirm_close&confirm=yes&token='.newToken().'&id='.$object->id, ''); } else { print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('Close'), 'default', $_SERVER['PHP_SELF']. '#', '', false); } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 18f07046905..8ced8b891c4 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1012,11 +1012,6 @@ class Societe extends CommonObject $this->fk_multicurrency = 0; } - if (empty($this->country_id) && !empty($this->country_code)) { - $country_id = getCountry($this->country_code, '3'); - $this->country_id = is_int($country_id) ? $country_id : 0; - } - dol_syslog(get_class($this)."::create ".$this->name); $now = dol_now(); @@ -1446,6 +1441,11 @@ class Societe extends CommonObject $this->country_id = dol_getIdFromCode($this->db, $this->country_code, 'c_country', 'code', 'rowid'); } + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + $error = 0; dol_syslog(get_class($this)."::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 1ea16d01c17..549bbb4454d 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2096,6 +2096,11 @@ class User extends CommonObject { global $conf, $langs; + if (empty($this->country_id) && !empty($this->country_code)) { + $country_id = getCountry($this->country_code, '3'); + $this->country_id = is_int($country_id) ? $country_id : 0; + } + $nbrowsaffected = 0; $error = 0; diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index db82c86747a..6b6524028fb 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2016 Marcos García * Copyright (C) 2018 Juanjo Menent * Copyright (C) 2022 Open-Dsi - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -884,11 +884,7 @@ class ProductCombination $productCombinationLevel->fk_price_level = $i; $productCombinationLevel->variation_price = $price_impact[$i]; - if (is_array($price_var_percent)) { - $productCombinationLevel->variation_price_percentage = (bool) $price_var_percent[$i] ; - } else { - $productCombinationLevel->variation_price_percentage = $price_var_percent; - } + $productCombinationLevel->variation_price_percentage = (bool) $price_var_percent[$i] ; $newcomb->combination_price_levels[$i] = $productCombinationLevel; } diff --git a/test/phpunit/SupplierProposalTest.php b/test/phpunit/SupplierProposalTest.php index 437857d8381..213938f4a38 100644 --- a/test/phpunit/SupplierProposalTest.php +++ b/test/phpunit/SupplierProposalTest.php @@ -88,7 +88,7 @@ class SupplierProposalTest extends CommonClassTest // Set permission not set by default sql sample $user->addrights(0, 'supplier_proposal'); - $user->getrights('supplier_proposal', 1); + $user->loadRights('supplier_proposal', 1); } /** @@ -183,7 +183,7 @@ class SupplierProposalTest extends CommonClassTest $result = $user->addrights(0, 'supplier_proposal'); $this->assertLessThan($result, 0); - $result = $user->getrights('supplier_proposal', 1); + $result = $user->loadRights('supplier_proposal', 1); //$this->assertLessThan($result, 0); $result = $localobject->valid($user);