From a0d9419be5cb766db6b8d3f9f47ba1322d1196e1 Mon Sep 17 00:00:00 2001 From: Sylvain Legrand Date: Thu, 30 Mar 2023 19:06:47 +0200 Subject: [PATCH 01/16] Improve multicurrency payments --- htdocs/compta/paiement.php | 5 +++++ htdocs/compta/paiement/class/paiement.class.php | 11 ++++++++--- htdocs/fourn/class/paiementfourn.class.php | 9 +++++++-- htdocs/fourn/facture/paiement.php | 5 +++++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index f2cd1fe18f9..0efb7bf4d61 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -9,6 +9,7 @@ * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2023 Sylvain Legrand * * 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 @@ -223,6 +224,7 @@ if (empty($reshook)) { } $multicurrency_code = array(); + $multicurrency_tx = array(); // Clean parameters amount if payment is for a credit note foreach ($amounts as $key => $value) { // How payment is dispatched @@ -233,6 +235,7 @@ if (empty($reshook)) { $amounts[$key] = - abs($newvalue); } $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; + $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx; } foreach ($multicurrency_amounts as $key => $value) { // How payment is dispatched @@ -243,6 +246,7 @@ if (empty($reshook)) { $multicurrency_amounts[$key] = - abs($newvalue); } $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; + $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx; } if (isModEnabled("banque")) { @@ -259,6 +263,7 @@ if (empty($reshook)) { $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching + $paiement->multicurrency_tx = $multicurrency_tx; // Array with all currency tx of payments dispatching $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); $paiement->num_payment = GETPOST('num_paiement', 'alpha'); $paiement->note_private = GETPOST('comment', 'alpha'); diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index f573ec5be56..78909e95d9d 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -12,6 +12,7 @@ * Copyright (C) 2020 Andreu Bisquerra Gaya * Copyright (C) 2021 OpenDsi * Copyright (C) 2023 Joachim Kueter + * Copyright (C) 2023 Sylvain Legrand * * 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 @@ -76,6 +77,7 @@ class Paiement extends CommonObject public $multicurrency_amount; // Total amount of payment (in the currency of the bank account) public $amounts = array(); // array: invoice ID => amount for that invoice (in the main currency) public $multicurrency_amounts = array(); // array: invoice ID => amount for that invoice (in the invoice's currency) + public $multicurrency_tx = array(); // array: invoice ID => currency tx for that invoice public $multicurrency_code = array(); // array: invoice ID => currency code for that invoice public $pos_change = 0; // Excess received in TakePOS cash payment @@ -262,6 +264,7 @@ class Paiement extends CommonObject } $currencyofpayment = ''; + $currencytxofpayment = ''; foreach ($amounts as $key => $value) { // How payment is dispatch if (empty($value)) { @@ -282,6 +285,9 @@ class Paiement extends CommonObject $this->error = 'ErrorYouTryToPayInvoicesWithDifferentCurrenciesInSamePayment'; return -1; } + if (empty($currencytxofpayment)) { + $currencytxofpayment = isset($this->multicurrency_tx[$key]) ? $this->multicurrency_tx[$key] : ""; + } $totalamount_converted += $value_converted; $amounts_to_update[$key] = price2num($value_converted, 'MT'); @@ -351,9 +357,8 @@ class Paiement extends CommonObject $facid = $key; if (is_numeric($amount) && $amount <> 0) { $amount = price2num($amount); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount)"; - // TODO Add multicurrency_code and multicurrency_tx - $sql .= " VALUES (".((int) $facid).", ".((int) $this->id).", ".((float) $amount).", ".((float) $this->multicurrency_amounts[$key]).")"; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount, multicurrency_code, multicurrency_tx)'; + $sql .= ' VALUES ('.((int) $facid).', '.((int) $this->id).', "'.((float) $amount).'", "'.((float) $this->multicurrency_amounts[$key]).'", '.($this->multicurrency_code ? '"'.$this->db->escape($currencyofpayment).'"' : 'NULL').', '.(!empty($this->multicurrency_tx) ? (double) $currencytxofpayment : 1).')'; dol_syslog(get_class($this).'::create Amount line '.$key.' insert paiement_facture', LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index e3b7be2c42a..168a9c98821 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -8,6 +8,7 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018 Frédéric France * Copyright (C) 2023 Joachim Kueter + * Copyright (C) 2023 Sylvain Legrand * * 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 @@ -186,6 +187,7 @@ class PaiementFourn extends Paiement } $currencyofpayment = ''; + $currencytxofpayment = ''; foreach ($amounts as $key => $value) { if (empty($value)) { @@ -207,6 +209,9 @@ class PaiementFourn extends Paiement $this->error = 'ErrorYouTryToPayInvoicesWithDifferentCurrenciesInSamePayment'; return -1; } + if (empty($currencytxofpayment)) { + $currencytxofpayment = $this->multicurrency_tx[$key]; + } $totalamount_converted += $value_converted; $amounts_to_update[$key] = price2num($value_converted, 'MT'); @@ -264,8 +269,8 @@ class PaiementFourn extends Paiement $facid = $key; if (is_numeric($amount) && $amount <> 0) { $amount = price2num($amount); - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn_facturefourn (fk_facturefourn, fk_paiementfourn, amount, multicurrency_amount)'; - $sql .= " VALUES (".((int) $facid).", ".((int) $this->id).", ".((float) $amount).', '.((float) $this->multicurrency_amounts[$key]).')'; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn_facturefourn (fk_facturefourn, fk_paiementfourn, amount, multicurrency_amount, multicurrency_code, multicurrency_tx)'; + $sql .= " VALUES (".((int) $facid).", ".((int) $this->id).", ".((float) $amount).', '.((float) $this->multicurrency_amounts[$key]).', '.($currencyofpayment ? '"'.$this->db->escape($currencyofpayment).'"' : 'NULL').', '.(!empty($currencytxofpayment) ? (double) $currencytxofpayment : 1).')'; $resql = $this->db->query($sql); if ($resql) { $invoice = new FactureFournisseur($this->db); diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index bad8d19bd28..5e1665d6c2b 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -12,6 +12,7 @@ * Copyright (C) 2018-2020 Frédéric France * Copyright (C) 2021 Charlene Benke * Copyright (C) 2022 Udo Tamm + * Copyright (C) 2023 Sylvain Legrand * * 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 @@ -270,6 +271,7 @@ if (empty($reshook)) { $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $multicurrency_code = array(); + $multicurrency_tx = array(); // Clean parameters amount if payment is for a credit note foreach ($amounts as $key => $value) { // How payment is dispatched @@ -280,6 +282,7 @@ if (empty($reshook)) { $amounts[$key] = - abs($newvalue); } $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; + $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx; } foreach ($multicurrency_amounts as $key => $value) { // How payment is dispatched @@ -290,6 +293,7 @@ if (empty($reshook)) { $multicurrency_amounts[$key] = - abs($newvalue); } $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; + $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx; } //var_dump($amounts); @@ -310,6 +314,7 @@ if (empty($reshook)) { $paiement->amounts = $amounts; // Array of amounts $paiement->multicurrency_amounts = $multicurrency_amounts; $paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching + $paiement->multicurrency_tx = $multicurrency_tx; // Array with all currency tx of payments dispatching $paiement->paiementid = GETPOST('paiementid', 'int'); $paiement->num_payment = GETPOST('num_paiement', 'alphanohtml'); $paiement->note_private = GETPOST('comment', 'alpha'); From 3c57992074460bcc7776f7cc2a185323a1eda32f Mon Sep 17 00:00:00 2001 From: Sylvain Legrand Date: Thu, 30 Mar 2023 20:59:27 +0200 Subject: [PATCH 02/16] Update paiement.class.php --- htdocs/compta/paiement/class/paiement.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 78909e95d9d..ec33f6368d4 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -357,8 +357,8 @@ class Paiement extends CommonObject $facid = $key; if (is_numeric($amount) && $amount <> 0) { $amount = price2num($amount); - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount, multicurrency_code, multicurrency_tx)'; - $sql .= ' VALUES ('.((int) $facid).', '.((int) $this->id).', "'.((float) $amount).'", "'.((float) $this->multicurrency_amounts[$key]).'", '.($this->multicurrency_code ? '"'.$this->db->escape($currencyofpayment).'"' : 'NULL').', '.(!empty($this->multicurrency_tx) ? (double) $currencytxofpayment : 1).')'; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount, multicurrency_code, multicurrency_tx)"; + $sql .= " VALUES (".((int) $facid).", ".((int) $this->id).", ".((float) $amount).", ".((float) $this->multicurrency_amounts[$key]).", ".($this->multicurrency_code ? $this->db->escape($currencyofpayment) : 'NULL').", ".(!empty($this->multicurrency_tx) ? (double) $currencytxofpayment : 1).")"; dol_syslog(get_class($this).'::create Amount line '.$key.' insert paiement_facture', LOG_DEBUG); $resql = $this->db->query($sql); From 40d476d2c9d2c174a8646cee12d58ac918d12ca8 Mon Sep 17 00:00:00 2001 From: Maximilien Rozniecki Date: Thu, 27 Apr 2023 11:02:22 +0200 Subject: [PATCH 03/16] first commit --- htdocs/contact/class/contact.class.php | 4 ++-- htdocs/core/lib/functions.lib.php | 14 ++++++++++++++ htdocs/ticket/class/actions_ticket.class.php | 8 ++++++++ htdocs/ticket/class/ticket.class.php | 8 +++++++- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 23fcf2d8c0a..5b76d43ab1d 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1535,7 +1535,7 @@ class Contact extends CommonObject $linkend = ''; } - $result .= $linkstart; + $result .= (($option == 'nolink') ? '' : $linkstart); if ($withpicto) { if ($withpicto < 0) { $result .= ''.Form::showphoto('contact', $this, 0, 0, 0, 'userphoto'.($withpicto == -3 ? 'small' : ''), 'mini', 0, 1).''; @@ -1546,7 +1546,7 @@ class Contact extends CommonObject if ($withpicto != 2 && $withpicto != -2) { $result .= ''.($maxlen ? dol_trunc($this->getFullName($langs), $maxlen) : $this->getFullName($langs)).''; } - $result .= $linkend; + $result .= (($option == 'nolink') ? '' : $linkend); global $action; $hookmanager->initHooks(array('contactdao')); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bedb62c1162..62f552b7b80 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12077,6 +12077,7 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n $sql .= " a.percent as percent, 'action' as type,"; $sql .= " a.fk_element, a.elementtype,"; $sql .= " a.fk_contact,"; + $sql .= " a.email_from as msg_from,"; $sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; $sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; if (is_object($filterobj) && get_class($filterobj) == 'Societe') { @@ -12276,6 +12277,7 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n 'userfirstname'=>$obj->user_firstname, 'userlastname'=>$obj->user_lastname, 'userphoto'=>$obj->user_photo, + 'msg_from'=>$obj->msg_from, 'contact_id'=>$obj->fk_contact, 'socpeopleassigned' => $contactaction->socpeopleassigned, @@ -12339,6 +12341,7 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n $userstatic = new User($db); $contactstatic = new Contact($db); $userGetNomUrlCache = array(); + $contactGetNomUrlCache = array(); $out .= '
'; $out .= '
'; @@ -12501,6 +12504,17 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n } $out .= $userGetNomUrlCache[$histo[$key]['userid']]; } + else if (!empty($histo[$key]['msg_from']) && $actionstatic->code == 'TICKET_MSG') { + if (!isset($contactGetNomUrlCache[$histo[$key]['msg_from']])) { + if ($contactstatic->fetch(0,null,'',$histo[$key]['msg_from']) > 0) { + $contactGetNomUrlCache[$histo[$key]['msg_from']] = $contactstatic->getNomUrl(-1, '', 16); + } + else { + $contactGetNomUrlCache[$histo[$key]['msg_from']] = $histo[$key]['msg_from']; + } + } + $out .= $contactGetNomUrlCache[$histo[$key]['msg_from']]; + } $out .= '
'; // Title diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 29a013f1eb9..fb426d74e09 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -306,6 +306,14 @@ class ActionsTicket if ($res) { print $userstat->getNomUrl(0); } + } else if (isset($arraymsgs['fk_contact_author'])) { + $contactstat = new Contact($this->db); + $res = $contactstat->fetch(0, null, '', $arraymsgs['fk_contact_author']); + if ($res) { + print $contactstat->getNomUrl(0, 'nolink'); + } else { + print $arraymsgs['fk_contact_author']; + } } else { print $langs->trans('Customer'); } diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 92baa55ea89..9ca4e3a3309 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1700,6 +1700,9 @@ class Ticket extends CommonObject if ($send_email) { $actioncomm->code .= '_SENTBYMAIL'; } + if ((empty($user->id) || $user->id == 0) && isset($_SESSION['email_customer'])) { + $actioncomm->email_from = $_SESSION['email_customer']; + } $actioncomm->socid = $this->socid; $actioncomm->label = $this->subject; $actioncomm->note_private = $this->message; @@ -1753,7 +1756,7 @@ class Ticket extends CommonObject // Cache already loaded - $sql = "SELECT id as rowid, fk_user_author, datec, label, note as message, code"; + $sql = "SELECT id as rowid, fk_user_author, email_from, datec, label, note as message, code"; $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm"; $sql .= " WHERE fk_element = ".(int) $this->id; $sql .= " AND elementtype = 'ticket'"; @@ -1768,6 +1771,9 @@ class Ticket extends CommonObject $obj = $this->db->fetch_object($resql); $this->cache_msgs_ticket[$i]['id'] = $obj->rowid; $this->cache_msgs_ticket[$i]['fk_user_author'] = $obj->fk_user_author; + if ($obj->code == 'TICKET_MSG' && empty($obj->fk_user_author)) { + $this->cache_msgs_ticket[$i]['fk_contact_author'] = $obj->email_from; + } $this->cache_msgs_ticket[$i]['datec'] = $this->db->jdate($obj->datec); $this->cache_msgs_ticket[$i]['subject'] = $obj->label; $this->cache_msgs_ticket[$i]['message'] = $obj->message; From df817dba7de74d562c7096781242343aced3b564 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Sat, 15 Apr 2023 18:01:42 +0200 Subject: [PATCH 04/16] ContactTest: assertStringContainsString instead of assertContains PHPUnit >= 9 adds assertStringContainsString, which ought to replace assertContains, and PHPUnit >= 9 removed[^1] support for calling assertContains on strings. [^1]: https://github.com/sebastianbergmann/phpunit/issues/3426 --- test/phpunit/ContactTest.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/phpunit/ContactTest.php b/test/phpunit/ContactTest.php index c28db01d579..7701f67bd08 100644 --- a/test/phpunit/ContactTest.php +++ b/test/phpunit/ContactTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -296,7 +297,7 @@ class ContactTest extends PHPUnit\Framework\TestCase $result=$localobject->getFullAddress(1); print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertContains("New address\nNew zip New town\nBelgium", $result); + $this->assertStringContainsString("New address\nNew zip New town\nBelgium", $result); $localobject->info($localobject->id); print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; @@ -357,7 +358,7 @@ class ContactTest extends PHPUnit\Framework\TestCase $localobjectadd->town='New town'; $result=$localobjectadd->getFullAddress(1); print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; - $this->assertContains("New address\nNew zip New town\nFrance", $result); + $this->assertStringContainsString("New address\nNew zip New town\nFrance", $result); // Belgium unset($localobjectadd->country_code); @@ -368,7 +369,7 @@ class ContactTest extends PHPUnit\Framework\TestCase $localobjectadd->town='New town'; $result=$localobjectadd->getFullAddress(1); print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; - $this->assertContains("New address\nNew zip New town\nBelgium", $result); + $this->assertStringContainsString("New address\nNew zip New town\nBelgium", $result); // Switzerland unset($localobjectadd->country_code); @@ -379,7 +380,7 @@ class ContactTest extends PHPUnit\Framework\TestCase $localobjectadd->town='New town'; $result=$localobjectadd->getFullAddress(1); print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; - $this->assertContains("New address\nNew zip New town\nSwitzerland", $result); + $this->assertStringContainsString("New address\nNew zip New town\nSwitzerland", $result); // USA unset($localobjectadd->country_code); @@ -390,7 +391,7 @@ class ContactTest extends PHPUnit\Framework\TestCase $localobjectadd->town='New town'; $result=$localobjectadd->getFullAddress(1); print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; - $this->assertContains("New address\nNew town, New zip\nUnited States", $result); + $this->assertStringContainsString("New address\nNew town, New zip\nUnited States", $result); return $localobjectadd->id; } From e9dcac67f02cf28a8ac4769e07bcd19c434a8db9 Mon Sep 17 00:00:00 2001 From: Maximilien Rozniecki Date: Fri, 28 Apr 2023 17:35:06 +0200 Subject: [PATCH 05/16] Stickler --- htdocs/core/lib/functions.lib.php | 7 +++---- htdocs/ticket/class/actions_ticket.class.php | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 62f552b7b80..1663b80ae70 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12504,12 +12504,11 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n } $out .= $userGetNomUrlCache[$histo[$key]['userid']]; } - else if (!empty($histo[$key]['msg_from']) && $actionstatic->code == 'TICKET_MSG') { + elseif (!empty($histo[$key]['msg_from']) && $actionstatic->code == 'TICKET_MSG') { if (!isset($contactGetNomUrlCache[$histo[$key]['msg_from']])) { - if ($contactstatic->fetch(0,null,'',$histo[$key]['msg_from']) > 0) { + if ($contactstatic->fetch(0, null, '', $histo[$key]['msg_from']) > 0) { $contactGetNomUrlCache[$histo[$key]['msg_from']] = $contactstatic->getNomUrl(-1, '', 16); - } - else { + } else { $contactGetNomUrlCache[$histo[$key]['msg_from']] = $histo[$key]['msg_from']; } } diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index fb426d74e09..c566bf54329 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -306,7 +306,7 @@ class ActionsTicket if ($res) { print $userstat->getNomUrl(0); } - } else if (isset($arraymsgs['fk_contact_author'])) { + } elseif (isset($arraymsgs['fk_contact_author'])) { $contactstat = new Contact($this->db); $res = $contactstat->fetch(0, null, '', $arraymsgs['fk_contact_author']); if ($res) { From 3c5b385444fe22765fb9dc2c55db8040936ddcbf Mon Sep 17 00:00:00 2001 From: Timo Scheuer Date: Wed, 17 May 2023 13:04:08 +0200 Subject: [PATCH 06/16] fixed access to propal array --- .../modules/facture/doc/doc_generic_invoice_odt.modules.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 14f71fa4f99..3d0e0b5e2aa 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -336,8 +336,9 @@ class doc_generic_invoice_odt extends ModelePDFFactures $object->fetchObjectLinked('', '', '', ''); //print_r($object->linkedObjects['propal']); exit; - if (isset($object->linkedObjects['propal'][0])) { - $propal_object = $object->linkedObjects['propal'][0]; + $propal_object = $object->linkedObjects['propal']; + if (isset($propal_object) && sizeof($propal_object)>0) { + $propal_object = array_values($object->linkedObjects['propal'])[0]; } else { $propal_object = null; } From 8db4d42ff2a089429fcdcfcc230ba87b2d402a02 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 17 May 2023 15:33:04 +0200 Subject: [PATCH 07/16] Update doc_generic_invoice_odt.modules.php --- .../facture/doc/doc_generic_invoice_odt.modules.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 3d0e0b5e2aa..cc9bc723635 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -336,9 +336,10 @@ class doc_generic_invoice_odt extends ModelePDFFactures $object->fetchObjectLinked('', '', '', ''); //print_r($object->linkedObjects['propal']); exit; - $propal_object = $object->linkedObjects['propal']; - if (isset($propal_object) && sizeof($propal_object)>0) { - $propal_object = array_values($object->linkedObjects['propal'])[0]; + $array_propal_object = $object->linkedObjects['propal']; + if (isset($array_propal_object) && is_array($array_propal_object) && count($array_propal_object) > 0) { + $tmparrayofvalue = array_values($array_propal_object); + $propal_object = $tmparrayofvalue[0]; } else { $propal_object = null; } From 4a25a6de21b0a7375c84bc6036bd74b677bf140c Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 17 May 2023 17:42:18 +0200 Subject: [PATCH 08/16] add constant to manage discounts with tax --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index c1c5b8aeccd..ea49a5c663d 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -598,7 +598,7 @@ if (empty($reshook)) { $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); - $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') ? 'HT' : 'TTC', $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0); + $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', getDolGlobalInt('TAKEPOS_DISCOUNT_TTC') ? ($number >= 0 ? 'HT' : 'TTC') : (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') ? 'HT' : 'TTC'), $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0); $invoice->fetch($placeid); } From 14d8eac70617e9a8e107ddc8f975ce77fa3614fc Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 17 May 2023 19:57:20 +0200 Subject: [PATCH 09/16] New attributes on invoice customer card --- htdocs/compta/facture/card.php | 128 ++++++++++++++++++--------------- 1 file changed, 70 insertions(+), 58 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 897c534bfba..77ecc4e4a05 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4788,6 +4788,7 @@ if ($action == 'create') { print ''."\n"; print '
'."\n"; + print ''; $sign = 1; @@ -4795,44 +4796,61 @@ if ($action == 'create') { $sign = -1; // We invert sign for output } - if (isModEnabled('multicurrency') && ($object->multicurrency_code != $conf->currency)) { + print ''; + // Amount HT + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT - print ''; - print ''; - print ''; - - // Multicurrency Amount VAT - print ''; - print ''; - print ''; - - // Multicurrency Amount TTC - print ''; - print ''; - print ''; + print ''; } + print ''; - // Amount - print ''; - print ''; - - // Vat - print ''; + print ''; + // Amount VAT + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + // Multicurrency Amount VAT + print ''; + } print ''; // Amount Local Taxes - if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) { // Localtax1 - print ''; - print ''; - } - if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) { // Localtax2 - print ''; - print ''; + if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) { + print ''; + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + print ''; + } + print ''; + + if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) { + print ''; + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + print ''; + } + print ''; + } } - // Revenue stamp - if ($selleruserevenustamp) { // Test company use revenue stamp - print ''; + // Amount TTC + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + // Multicurrency Amount TTC + print ''; + } + print ''; + + print '
' . $langs->trans('AmountHT') . '' . price($sign * $object->total_ht, '', $langs, 0, -1, -1, $conf->currency) . '
'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''.price($sign * $object->multicurrency_total_ht, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''.price($sign * $object->multicurrency_total_tva, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''.price($sign * $object->multicurrency_total_ttc, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
' . price($sign * $object->multicurrency_total_ht, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'.$langs->trans('AmountHT').''.price($sign * $object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'
'.$langs->trans('AmountVAT').''.price($sign * $object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'
' . $langs->trans('AmountVAT') . '' . price($sign * $object->total_tva, '', $langs, 0, -1, -1, $conf->currency) . '' . price($sign * $object->multicurrency_total_tva, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($sign * $object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'
'.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($sign * $object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($sign * $object->total_localtax1, '', $langs, 0, -1, -1, $conf->currency) . '' . price($sign * $object->total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($sign * $object->total_localtax2, '', $langs, 0, -1, -1, $conf->currency) . '' . price($sign * $object->total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'; + print '
' . $langs->trans('AmountTTC') . '' . price($sign * $object->total_ttc, '', $langs, 0, -1, -1, $conf->currency) . '' . price($sign * $object->total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'; + + // Ajouter la première condition + if ($selleruserevenustamp) { print ''; @@ -4852,43 +4870,37 @@ if ($action == 'create') { print ' '; print ''; print " "; + } + $('#revenuestamp_val').val(revenue); + $('#revenuestamp_span').html(revenue); + } + "; } else { - print price($object->revenuestamp, 1, '', 1, - 1, - 1, $conf->currency); + print price($object->revenuestamp, 1, '', 1, -1, -1, $conf->currency); } print ''; } - // Total with tax - print ''; - - print '
'; print $langs->trans('RevenueStamp'); print '
'.$langs->trans('AmountTTC').''.price($sign * $object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'
'; - - $nbrows = 8; $nbcols = 3; if (isModEnabled('project')) { From 954636159d5a0ef95115eeee78530ba8b06ac671 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Wed, 17 May 2023 23:05:25 +0200 Subject: [PATCH 10/16] FIX #24796 PHP 8 Warning missing PROJECT_USE_SEARCH_TO_SELECT const --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 210fcb202e8..58b4c5937f7 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7770,7 +7770,7 @@ class Form if (!$forcecombo) { include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $out .= ajax_combobox($htmlname, $events, $conf->global->PROJECT_USE_SEARCH_TO_SELECT); + $out .= ajax_combobox($htmlname, $events, !empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT) ? $conf->global->PROJECT_USE_SEARCH_TO_SELECT : '' ); } $out .= ''; From e5cfd4851eeda6ebeac0c852ccd2cfd9f388dec5 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Thu, 18 May 2023 11:21:36 +0200 Subject: [PATCH 12/16] FIX PHP 8 Warning in box_membres_by_tags.php --- htdocs/core/boxes/box_members_by_tags.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_members_by_tags.php b/htdocs/core/boxes/box_members_by_tags.php index 861e15d262b..468fc2d52a0 100644 --- a/htdocs/core/boxes/box_members_by_tags.php +++ b/htdocs/core/boxes/box_members_by_tags.php @@ -149,7 +149,7 @@ class box_members_by_tags extends ModeleBoxes ); $line++; foreach ($sumMembers as $key => $data) { - $adhtag = new Categorie($db); + $adhtag = new Categorie($this->db); $adhtag->id = $key; if ($key=='total') { From 726ca61776fcbed54a63ac606db296458631dcc2 Mon Sep 17 00:00:00 2001 From: Maximilien Rozniecki Date: Fri, 19 May 2023 11:36:53 +0200 Subject: [PATCH 13/16] Fix "html" type extrafields now accept some html balises with the flag "htmlrestricted" inside the "GETPOST" --- htdocs/core/class/extrafields.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 5c44e140be9..b110f0a4a16 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2306,6 +2306,11 @@ class ExtraFields $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); $value_key = $value_arr; } + } elseif (in_array($key_type, array('html'))) { + if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) { + continue; // Value was not provided, we should not set it. + } + $value_key = dol_htmlcleanlastbr(GETPOST($keysuffix."options_".$key.$keyprefix, 'restricthtml')); } else { if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) { continue; // Value was not provided, we should not set it. From 0f93845380afcc288a84c33a1daee4d7619351da Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 19 May 2023 16:32:31 +0200 Subject: [PATCH 14/16] NEW : TakePOS - add constant to forbid credit note --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 6f5e829ca47..f00eec79e80 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1684,7 +1684,7 @@ if ($placeid > 0) { print ''; -if (($action == "valid" || $action == "history") && $invoice->type != Facture::TYPE_CREDIT_NOTE) { +if (($action == "valid" || $action == "history") && $invoice->type != Facture::TYPE_CREDIT_NOTE && empty($conf->global->TAKEPOS_NO_CREDITNOTE)) { print ''; } From 6a181b114b4c8372466729b0160cacce2f8d357a Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 19 May 2023 17:27:07 +0200 Subject: [PATCH 15/16] fix syntax --- htdocs/takepos/index.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 7e1c648d460..a2846f63ddf 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -1089,7 +1089,11 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {