From 00a6a07d5a685dd4aebf3dd27cf90b7a1760648a Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Tue, 14 Feb 2023 10:31:55 +0100 Subject: [PATCH 1/8] FIX - Shipping address fetch-thirdparty --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 7 ++++--- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 30a61fbb1d3..c3a8fcce500 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -2135,9 +2135,10 @@ class pdf_crabe extends ModelePDFFactures if (!empty($idaddressshipping)) { $contactshipping = $object->fetch_Contact($idaddressshipping[0]); - $object->fetch_thirdparty($object->contact->fk_soc); + $companystatic = new Societe($this->db); + $companystatic->fetch($object->contact->fk_soc); $carac_client_name_shipping=pdfBuildThirdpartyName($object->contact, $outputlangs); - $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, $usecontact, 'target', $object); + $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $companystatic, $object->contact, $usecontact, 'target', $object); } else { $carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs); $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object);; @@ -2148,7 +2149,7 @@ class pdf_crabe extends ModelePDFFactures // Show shipping frame $pdf->SetXY($posx + 2, $posy - 5); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->MultiCell($widthrecbox, '', $langs->trans('ShippingTo'), 0, 'L', 0); + $pdf->MultiCell($widthrecbox, '', $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); // Show shipping name diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 1d106f6f024..9aa96e147ab 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -2384,9 +2384,10 @@ class pdf_sponge extends ModelePDFFactures if (!empty($idaddressshipping)) { $contactshipping = $object->fetch_Contact($idaddressshipping[0]); - $object->fetch_thirdparty($object->contact->fk_soc); + $companystatic = new Societe($this->db); + $companystatic->fetch($object->contact->fk_soc); $carac_client_name_shipping=pdfBuildThirdpartyName($object->contact, $outputlangs); - $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, $usecontact, 'target', $object); + $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $companystatic, $object->contact, $usecontact, 'target', $object); } else { $carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs); $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object); @@ -2397,7 +2398,7 @@ class pdf_sponge extends ModelePDFFactures // Show shipping frame $pdf->SetXY($posx + 2, $posy - 5); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->MultiCell($widthrecbox, '', $langs->trans('ShippingTo'), 0, 'L', 0); + $pdf->MultiCell($widthrecbox, '', $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); // Show shipping name From 4ed5f231be4e443a30bc4c7dd94a2dccc8fa09aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 15 Feb 2023 22:13:23 +0100 Subject: [PATCH 2/8] fix sql actioncomm index is id not rowid --- htdocs/eventorganization/conferenceorbooth_list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 4d8ea00c421..1f31690052f 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -1,6 +1,7 @@ * Copyright (C) 2021 Florian Henry + * Copyright (C) 2023 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 @@ -531,7 +532,7 @@ $sqlfields = $sql; // $sql fields to remove for count total $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.id = ef.fk_object)"; } $sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_actioncomm as cact ON cact.id=t.fk_action AND cact.module LIKE '%@eventorganization'"; // Add table from hooks From b3bdfc342d9f15bebef0995897895f958d2f2420 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Feb 2023 12:20:39 +0100 Subject: [PATCH 3/8] Debug v17. Missing style amount and bank link --- htdocs/loan/card.php | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index a45577b6608..1fd571a9a91 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -1,4 +1,6 @@ * Copyright (C) 2015 Frederic France * Copyright (C) 2017 Laurent Destailleur @@ -37,6 +39,7 @@ if (isModEnabled('accounting')) { } require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array("compta", "bills", "loan")); @@ -632,12 +635,14 @@ if ($id > 0) { /* * Payments */ - $sql = "SELECT p.rowid, p.num_payment, datep as dp,"; + $sql = "SELECT p.rowid, p.num_payment, p.datep as dp,"; $sql .= " p.amount_capital, p.amount_insurance, p.amount_interest,"; + $sql .= " b.fk_account,"; $sql .= " c.libelle as paiement_type"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as p"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; - $sql .= ", ".MAIN_DB_PREFIX."loan as l"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank = b.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id,"; + $sql .= " ".MAIN_DB_PREFIX."loan as l"; $sql .= " WHERE p.fk_loan = ".((int) $id); $sql .= " AND p.fk_loan = l.rowid"; $sql .= " AND l.entity IN ( ".getEntity('loan').")"; @@ -658,11 +663,14 @@ if ($id > 0) { print ''.$langs->trans("RefPayment").''; print ''.$langs->trans("Date").''; print ''.$langs->trans("Type").''; + print ''.$langs->trans("BankAccount").''; print ''.$langs->trans("Insurance").''; print ''.$langs->trans("Interest").''; print ''.$langs->trans("LoanCapital").''; print ''; + $conf->cache['bankaccount'] = array(); + while ($i < $num) { $objp = $db->fetch_object($resql); @@ -670,9 +678,19 @@ if ($id > 0) { print ''.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.''; print ''.dol_print_date($db->jdate($objp->dp), 'day')."\n"; print "".$objp->paiement_type.' '.$objp->num_payment."\n"; - print ''.price($objp->amount_insurance, 0, $outputlangs, 1, -1, -1, $conf->currency)."\n"; - print ''.price($objp->amount_interest, 0, $outputlangs, 1, -1, -1, $conf->currency)."\n"; - print ''.price($objp->amount_capital, 0, $outputlangs, 1, -1, -1, $conf->currency)."\n"; + print ""; + if (!empty($conf->cache['bankaccount'][$objp->fk_account])) { + $tmpbank = $conf->cache['bankaccount'][$objp->fk_account]; + } else { + $tmpbank = new Account($db); + $tmpbank->fetch($objp->fk_account); + $conf->cache['bankaccount'][$objp->fk_account] = $tmpbank; + } + print $tmpbank->getNomUrl(1); + print "\n"; + print ''.price($objp->amount_insurance, 0, $outputlangs, 1, -1, -1, $conf->currency)."\n"; + print ''.price($objp->amount_interest, 0, $outputlangs, 1, -1, -1, $conf->currency)."\n"; + print ''.price($objp->amount_capital, 0, $outputlangs, 1, -1, -1, $conf->currency)."\n"; print ""; $total_capital += $objp->amount_capital; $i++; @@ -681,12 +699,12 @@ if ($id > 0) { $totalpaid = $total_capital; if ($object->paid == 0 || $object->paid == 2) { - print ''.$langs->trans("AlreadyPaid").' :'.price($totalpaid, 0, $langs, 0, -1, -1, $conf->currency).''; - print ''.$langs->trans("AmountExpected").' :'.price($object->capital, 0, $outputlangs, 1, -1, -1, $conf->currency).''; + print ''.$langs->trans("AlreadyPaid").' :'.price($totalpaid, 0, $langs, 0, -1, -1, $conf->currency).''; + print ''.$langs->trans("AmountExpected").' :'.price($object->capital, 0, $outputlangs, 1, -1, -1, $conf->currency).''; $staytopay = $object->capital - $totalpaid; - print ''.$langs->trans("RemainderToPay").' :'; + print ''.$langs->trans("RemainderToPay").' :'; print ''; print price($staytopay, 0, $langs, 0, -1, -1, $conf->currency); print ''; From 6925d416ba04936c9cfd37d998dceac2e92cdd97 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Feb 2023 18:44:00 +0100 Subject: [PATCH 4/8] Doc --- htdocs/fourn/class/fournisseur.product.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index fa1706a523a..9b9646480b7 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -674,6 +674,7 @@ class ProductFournisseur extends Product * @param int $offset Offset * @param int $socid Filter on a third party id * @return array Array of ProductFournisseur with new properties to define supplier price + * @see find_min_price_product_fournisseur() */ public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0, $socid = 0) { @@ -784,6 +785,7 @@ class ProductFournisseur extends Product * @param int $qty Minimum quantity * @param int $socid get min price for specific supplier * @return int <0 if KO, 0=Not found of no product id provided, >0 if OK + * @see list_product_fournisseur_price() */ public function find_min_price_product_fournisseur($prodid, $qty = 0, $socid = 0) { From 3c3d2213700e6c3f8dfecb2961fa30e6cd8e9694 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Feb 2023 21:23:00 +0100 Subject: [PATCH 5/8] FIX #23914 search_all --- htdocs/fichinter/list.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 5a44e9069cd..ebff3305365 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -65,7 +65,7 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_projet_ref = GETPOST('search_projet_ref', 'alpha'); $search_contrat_ref = GETPOST('search_contrat_ref', 'alpha'); $search_status = GETPOST('search_status', 'alpha'); -$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $optioncss = GETPOST('optioncss', 'alpha'); $socid = GETPOST('socid', 'int'); @@ -310,8 +310,8 @@ if (empty($user->rights->societe->client->voir) && empty($socid)) { if ($socid) { $sql .= " AND s.rowid = ".((int) $socid); } -if ($sall) { - $sql .= natural_search(array_keys($fieldstosearchall), $sall); +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -320,7 +320,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; // Add GroupBy from hooks -$parameters = array('search_all' => $sall, 'fieldstosearchall' => $fieldstosearchall); +$parameters = array('search_all' => $search_all, 'fieldstosearchall' => $fieldstosearchall); $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; @@ -395,8 +395,8 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } -if ($sall) { - $param .= "&sall=".urlencode($sall); +if ($search_all) { + $param .= "&search_all=".urlencode($search_all); } if ($socid) { $param .= "&socid=".urlencode($socid); @@ -470,11 +470,11 @@ $objecttmp = new Fichinter($db); $trackid = 'int'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($sall) { +if ($search_all) { foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); } - print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; } $moreforfilter = ''; From b021721b10d4e0253884ede3b322b0cf005da79f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Feb 2023 22:01:05 +0100 Subject: [PATCH 6/8] Fix reload of page --- htdocs/fourn/commande/card.php | 8 ++++---- htdocs/fourn/facture/card.php | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 3bdf969c24c..842352475ad 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1700,14 +1700,14 @@ if ($action == 'create') { } else { print img_picto('', 'company').$form->select_company((empty($socid) ? '' : $socid), 'socid', '(s.fournisseur=1 AND s.status=1)', 'SelectThirdParty', 1, 0, null, 0, 'minwidth175 maxwidth500 widthcentpercentminusxx'); // reload page to retrieve customer informations - if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { + if (empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE_DISABLED)) { print ''; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 246f65c19f9..15e959b9736 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2099,13 +2099,14 @@ if ($action == 'create') { } else { print img_picto('', 'company').$form->select_company(empty($societe->id) ? 0 : $societe->id, 'socid', '(s.fournisseur = 1 AND s.status = 1)', 'SelectThirdParty', 1, 0, null, 0, 'minwidth175 widthcentpercentminusxx maxwidth500'); // reload page to retrieve supplier informations - if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { + if (empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE_DISABLED)) { print ''; @@ -2168,10 +2169,9 @@ if ($action == 'create') { $(document).ready(function() { $("#fac_rec").change(function() { console.log("We have changed the template invoice - Reload page"); - var fac_rec = $(this).val(); - var socid = $(\'#socid\').val(); - // For template invoice change, we must reuse data of template, not input already done, so we call a GET with action=create, not a POST submit. - window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid+"&fac_rec="+fac_rec; + // reload page + $("input[name=action]").val("create"); + $("form[name=add]").submit(); }); }); '; From f8c3b9ff5b21be4880f2cdb12e800f3c6fa5efd4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Feb 2023 22:11:41 +0100 Subject: [PATCH 7/8] Fix trans of "d" --- htdocs/core/lib/date.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 03223a7b65a..28d9da85f61 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -285,7 +285,7 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l if ($sDay > 1) { $dayTranslate = $langs->trans("Days"); } - $sTime .= $sDay.' '.strtolower(dol_substr($dayTranslate, 0, 1)).'. '; + $sTime .= $sDay.' '.$langs->trans("d").' '; } if ($format == 'all') { From a18b5a31e5653f4561082dec7d45298bc591b5a7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Feb 2023 16:00:57 +0100 Subject: [PATCH 8/8] Fix phpunit --- test/phpunit/DateLibTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/phpunit/DateLibTest.php b/test/phpunit/DateLibTest.php index 6f50e5b3085..eef029d26d1 100644 --- a/test/phpunit/DateLibTest.php +++ b/test/phpunit/DateLibTest.php @@ -344,7 +344,7 @@ class DateLibTest extends PHPUnit\Framework\TestCase $result=convertSecondToTime(86400, 'all', 86400); print __METHOD__." result=".$result."\n"; - $this->assertSame('1 '.strtolower(dol_substr($langs->trans("Day"), 0, 1).'.'), $result); + $this->assertSame('1 '.$langs->trans("d"), $result); return $result; }