From 54f7a2f7eef6561751d7b48624b47cf100eb4d0f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Jul 2023 21:40:05 +0200 Subject: [PATCH 01/10] Fix css --- htdocs/user/card.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 04efa858041..971aed07006 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1075,7 +1075,7 @@ if ($action == 'create' || $action == 'adduserldap') { // We do not use a field password but a field text to show new password to use. $valuetoshow .= ($valuetoshow ? ' + '.$langs->trans("DolibarrPassword") : '').''; if (!empty($conf->use_javascript_ajax)) { - $valuetoshow .= ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_password" class="linkobject"'); + $valuetoshow .= img_picto($langs->trans('Generate'), 'refresh', 'id="generate_password" class="linkobject paddingleft"'); } } } @@ -1097,9 +1097,9 @@ if ($action == 'create' || $action == 'adduserldap') { //$generated_password = getRandomPassword(false); print ''.$langs->trans("ApiKey").''; print ''; - print ''; + print ''; if (!empty($conf->use_javascript_ajax)) { - print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"'); + print img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject paddingleft"'); } print ''; } else { @@ -2449,7 +2449,7 @@ if ($action == 'create' || $action == 'adduserldap') { if ($caneditpassword) { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''; if (!empty($conf->use_javascript_ajax)) { - $valuetoshow .= ' '.img_picto((getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? $langs->trans('NoPasswordGenerationRuleConfigured') : $langs->trans('Generate')), 'refresh', 'id="generate_password" class="'.(getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? ' opacitymedium' : ' linkobject').'"'); + $valuetoshow .= img_picto((getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? $langs->trans('NoPasswordGenerationRuleConfigured') : $langs->trans('Generate')), 'refresh', 'id="generate_password" class="paddingleft'.(getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? ' opacitymedium' : ' linkobject').'"'); } } else { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').preg_replace('/./i', '*', $object->pass); @@ -2472,9 +2472,9 @@ if ($action == 'create' || $action == 'adduserldap') { print ''.$langs->trans("ApiKey").''; print ''; if ($caneditpassword || $user->hasRight("api", "apikey", "generate")) { - print ''; + print ''; if (!empty($conf->use_javascript_ajax)) { - print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"'); + print img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject paddingleft"'); } } print ''; From bfdd082e55cc9caf5ade6dd9274b849f77cd6d58 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2023 14:43:08 +0200 Subject: [PATCH 02/10] FIX IPN for SEPA payment --- htdocs/public/stripe/ipn.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index eb9671ed956..3a6e1b1c0bb 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -388,7 +388,7 @@ if ($event->type == 'payout.created') { $paiement->ext_payment_site = $service; $ispaymentdone = 0; - $sql = "SELECT p.id FROM llx_paiement as p"; + $sql = "SELECT p.rowid FROM llx_paiement as p"; $sql .= " WHERE p.ext_payment_id = '".$db->escape($paiement->ext_payment_id)."'"; $sql .= " AND p.ext_payment_site = '".$db->escape($paiement->ext_payment_site)."'"; $result = $db->query($sql); @@ -398,7 +398,9 @@ if ($event->type == 'payout.created') { dol_syslog('* Payment for ext_payment_id '.$paiement->ext_payment_id.' already done. We do not recreate the payment'); } } + $db->begin(); + if (!$error && !$ispaymentdone) { dol_syslog('* Record payment for invoice id ' . $invoice_id . '. It includes closing of invoice and regenerating document'); @@ -408,15 +410,19 @@ if ($event->type == 'payout.created') { $postactionmessages[] = $paiement->error . ($paiement->error ? ' ' : '') . join("
\n", $paiement->errors); $ispostactionok = -1; $error++; + + dol_syslog("Failed to create the payment for invoice id " . $invoice_id); } else { $postactionmessages[] = 'Payment created'; - } - dol_syslog("The payment has been created for invoice id " . $invoice_id); + dol_syslog("The payment has been created for invoice id " . $invoice_id); + } } + if (!$error && isModEnabled('banque')) { + // Search again the payment to see if it is already linked to a bank payment record (We should always find the payement now we have created before). $ispaymentdone = 0; - $sql = "SELECT p.id, p.fk_bank FROM llx_paiement as p"; + $sql = "SELECT p.rowid, p.fk_bank FROM llx_paiement as p"; $sql .= " WHERE p.ext_payment_id = '".$db->escape($paiement->ext_payment_id)."'"; $sql .= " AND p.ext_payment_site = '".$db->escape($paiement->ext_payment_site)."'"; $sql .= " AND p.fk_bank <> 0"; @@ -425,13 +431,14 @@ if ($event->type == 'payout.created') { if ($db->num_rows($result)) { $ispaymentdone = 1; $obj = $db->fetch_object($result); - dol_syslog('* Payment already linked to bank record '.$obj->fk_bank.' . We do not recrate the link'); + dol_syslog('* Payment already linked to bank record '.$obj->fk_bank.' . We do not recreate the link'); } } if (!$ispaymentdone) { dol_syslog('* Add payment to bank'); // The bank used is the one defined into Stripe setup + $paymentmethod = 'stripe'; $bankaccountid = getDolGlobalInt("STRIPE_BANK_ACCOUNT_FOR_PAYMENTS"); if ($bankaccountid > 0) { From d64c51e860d6446bbd2fd779ea702d6788ff7049 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2023 14:59:40 +0200 Subject: [PATCH 03/10] Debug v18 --- htdocs/compta/facture/invoicetemplate_list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 56ef08d1f1e..c2955777e4b 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -626,13 +626,13 @@ if (!empty($arrayfields['f.total_ttc']['checked'])) { } if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { // Payment term - print ''; + print ''; print $form->getSelectConditionsPaiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100'); print ""; } if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { // Payment mode - print ''; + print ''; print $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100', 1); print ''; } From 3b6f8b50822a7f25a5de7fc094c458864185a848 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2023 17:09:00 +0200 Subject: [PATCH 04/10] Fix phpcs --- .../modules/mrp/doc/pdf_vinci.modules.php | 58 +++++++++---------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index 362faa4cd8e..1f047598d24 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -1168,40 +1168,38 @@ class pdf_vinci extends ModelePDFMo } // product info - $prodToMake = new Product($this->db); - $resProdToMake = $prodToMake->fetch($object->fk_product); + $prodToMake = new Product($this->db); + $resProdToMake = $prodToMake->fetch($object->fk_product); - if ($resProdToMake > 0) - { - // ref - $posy += 7; - $pdf->SetFont('', 'B', $default_font_size + 1); - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $prodToMake->ref, '', 'R'); + if ($resProdToMake > 0) { + // ref + $posy += 7; + $pdf->SetFont('', 'B', $default_font_size + 1); + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $prodToMake->ref, '', 'R'); - // description - $posy += 5; - $pdf->SetFont('', 'B', $default_font_size + 3); - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, html_entity_decode($prodToMake->description), '', 'R'); - $posy = $pdf->GetY() - 5; + // description + $posy += 5; + $pdf->SetFont('', 'B', $default_font_size + 3); + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, html_entity_decode($prodToMake->description), '', 'R'); + $posy = $pdf->GetY() - 5; - // dimensions - $array = array_filter(array($prodToMake->length, $prodToMake->width, $prodToMake->height)); - $dim = implode("x", $array); - if (!empty($dim)) { - $posy += 5; - $pdf->SetFont('', 'B', $default_font_size + 3); - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $dim, '', 'R'); - } + // dimensions + $array = array_filter(array($prodToMake->length, $prodToMake->width, $prodToMake->height)); + $dim = implode("x", $array); + if (!empty($dim)) { + $posy += 5; + $pdf->SetFont('', 'B', $default_font_size + 3); + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $dim, '', 'R'); + } + } - } - - $posy += 5; + $posy += 5; $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); From 07fbb2da9da98d3f28b7e15f4f23a5d7d8267532 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Jul 2023 19:40:40 +0200 Subject: [PATCH 05/10] Doc --- htdocs/langs/zh_CN/README.md | 2 ++ htdocs/langs/zh_HK/README.md | 2 ++ htdocs/langs/zh_TW/README.md | 2 ++ 3 files changed, 6 insertions(+) create mode 100644 htdocs/langs/zh_CN/README.md create mode 100644 htdocs/langs/zh_HK/README.md create mode 100644 htdocs/langs/zh_TW/README.md diff --git a/htdocs/langs/zh_CN/README.md b/htdocs/langs/zh_CN/README.md new file mode 100644 index 00000000000..7ee58e0311a --- /dev/null +++ b/htdocs/langs/zh_CN/README.md @@ -0,0 +1,2 @@ +Language code for ZH language in China. +This is the simplified chinese. diff --git a/htdocs/langs/zh_HK/README.md b/htdocs/langs/zh_HK/README.md new file mode 100644 index 00000000000..28350b77f38 --- /dev/null +++ b/htdocs/langs/zh_HK/README.md @@ -0,0 +1,2 @@ +Language code for ZH language in Hong Kong. +This is the traditionnal chinese. diff --git a/htdocs/langs/zh_TW/README.md b/htdocs/langs/zh_TW/README.md new file mode 100644 index 00000000000..46675a6d946 --- /dev/null +++ b/htdocs/langs/zh_TW/README.md @@ -0,0 +1,2 @@ +Language code for ZH language in Taiwan. +This is the traditionnal chinese. From 9552346a477d7ef0da127fb94c2ed1ff283f843f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2023 13:29:00 +0200 Subject: [PATCH 06/10] FIX generating substitution array was corrupting the array_option --- .../core/class/commondocgenerator.class.php | 81 ++++++++++--------- .../societe/doc/doc_generic_odt.modules.php | 4 +- 2 files changed, 45 insertions(+), 40 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index ad9a09d5013..0affc1f5feb 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -448,6 +448,7 @@ abstract class CommonDocGenerator // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value + * Note that vars into substitutions array are formatted. * * @param Object $object Main object to use as data source * @param Translate $outputlangs Lang object to use for output @@ -498,14 +499,15 @@ abstract class CommonDocGenerator $array_key.'_hour'=>dol_print_date($date, 'hour'), $array_key.'_date'=>dol_print_date($date, 'day'), $array_key.'_date_rfc'=>dol_print_date($date, 'dayrfc'), - $array_key.'_date_limit'=>(!empty($object->date_lim_reglement) ?dol_print_date($object->date_lim_reglement, 'day') : ''), - $array_key.'_date_end'=>(!empty($object->fin_validite) ?dol_print_date($object->fin_validite, 'day') : ''), + $array_key.'_date_limit'=>(!empty($object->date_lim_reglement) ? dol_print_date($object->date_lim_reglement, 'day') : ''), + $array_key.'_date_limit_rfc'=>(!empty($object->date_lim_reglement) ? dol_print_date($object->date_lim_reglement, 'dayrfc') : ''), + $array_key.'_date_end'=>(!empty($object->fin_validite) ? dol_print_date($object->fin_validite, 'day') : ''), $array_key.'_date_creation'=>dol_print_date($object->date_creation, 'day'), - $array_key.'_date_modification'=>(!empty($object->date_modification) ?dol_print_date($object->date_modification, 'day') : ''), - $array_key.'_date_validation'=>(!empty($object->date_validation) ?dol_print_date($object->date_validation, 'dayhour') : ''), - $array_key.'_date_approve'=>(!empty($object->date_approve) ?dol_print_date($object->date_approve, 'day') : ''), - $array_key.'_date_delivery_planed'=>(!empty($object->delivery_date) ?dol_print_date($object->delivery_date, 'day') : ''), - $array_key.'_date_close'=>(!empty($object->date_cloture) ?dol_print_date($object->date_cloture, 'dayhour') : ''), + $array_key.'_date_modification'=>(!empty($object->date_modification) ? dol_print_date($object->date_modification, 'day') : ''), + $array_key.'_date_validation'=>(!empty($object->date_validation) ? dol_print_date($object->date_validation, 'dayhour') : ''), + $array_key.'_date_approve'=>(!empty($object->date_approve) ? dol_print_date($object->date_approve, 'day') : ''), + $array_key.'_date_delivery_planed'=>(!empty($object->delivery_date) ? dol_print_date($object->delivery_date, 'day') : ''), + $array_key.'_date_close'=>(!empty($object->date_cloture) ? dol_print_date($object->date_cloture, 'dayhour') : ''), $array_key.'_payment_mode_code'=>$object->mode_reglement_code, $array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) : $object->mode_reglement), @@ -641,6 +643,7 @@ abstract class CommonDocGenerator // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value + * Note that vars into substitutions array are formatted. * * @param Object $line Object line * @param Translate $outputlangs Lang object to use for output @@ -650,8 +653,6 @@ abstract class CommonDocGenerator public function get_substitutionarray_lines($line, $outputlangs, $linenumber = 0) { // phpcs:enable - global $conf; - $resarray = array( 'line_pos' => $linenumber, 'line_fulldesc'=>doc_getlinedesc($line, $outputlangs), @@ -765,6 +766,7 @@ abstract class CommonDocGenerator // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value + * Note that vars into substitutions array are formatted. * * @param Expedition $object Main object to use as data source * @param Translate $outputlangs Lang object to use for output @@ -831,6 +833,7 @@ abstract class CommonDocGenerator // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value + * Note that vars into substitutions array are formatted. * * @param ExpeditionLigne $line Object line * @param Translate $outputlangs Lang object to use for output @@ -839,7 +842,6 @@ abstract class CommonDocGenerator public function get_substitutionarray_shipment_lines($line, $outputlangs) { // phpcs:enable - global $conf; dol_include_once('/core/lib/product.lib.php'); $resarray = array( @@ -930,6 +932,7 @@ abstract class CommonDocGenerator // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fill array with couple extrafield key => extrafield value + * Note that vars into substitutions array are formatted. * * @param Object $object Object with extrafields (must have $object->array_options filled) * @param array $array_to_fill Substitution array @@ -945,49 +948,51 @@ abstract class CommonDocGenerator if (is_array($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) { + $formatedarrayoption = $object->array_options; + if ($extrafields->attributes[$object->table_element]['type'][$key] == 'price') { - $object->array_options['options_'.$key] = price2num($object->array_options['options_'.$key]); - $object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency); + $formatedarrayoption['options_'.$key] = price2num($formatedarrayoption['options_'.$key]); + $formatedarrayoption['options_'.$key.'_currency'] = price($formatedarrayoption['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency); //Add value to store price with currency - $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $formatedarrayoption['options_'.$key.'_currency'])); } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'select') { - $valueofselectkey = $object->array_options['options_'.$key]; + $valueofselectkey = $formatedarrayoption['options_'.$key]; if (array_key_exists($valueofselectkey, $extrafields->attributes[$object->table_element]['param'][$key]['options'])) { - $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$valueofselectkey]; + $formatedarrayoption['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$valueofselectkey]; } else { - $object->array_options['options_'.$key] = ''; + $formatedarrayoption['options_'.$key] = ''; } } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { - $valArray = explode(',', $object->array_options['options_'.$key]); + $valArray = explode(',', $formatedarrayoption['options_'.$key]); $output = array(); foreach ($extrafields->attributes[$object->table_element]['param'][$key]['options'] as $keyopt => $valopt) { if (in_array($keyopt, $valArray)) { $output[] = $valopt; } } - $object->array_options['options_'.$key] = implode(', ', $output); + $formatedarrayoption['options_'.$key] = implode(', ', $output); } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'date') { - if (strlen($object->array_options['options_'.$key]) > 0) { - $date = $object->array_options['options_'.$key]; - $object->array_options['options_'.$key] = dol_print_date($date, 'day'); // using company output language - $object->array_options['options_'.$key.'_locale'] = dol_print_date($date, 'day', 'tzserver', $outputlangs); // using output language format - $object->array_options['options_'.$key.'_rfc'] = dol_print_date($date, 'dayrfc'); // international format + if (strlen($formatedarrayoption['options_'.$key]) > 0) { + $date = $formatedarrayoption['options_'.$key]; + $formatedarrayoption['options_'.$key] = dol_print_date($date, 'day'); // using company output language + $formatedarrayoption['options_'.$key.'_locale'] = dol_print_date($date, 'day', 'tzserver', $outputlangs); // using output language format + $formatedarrayoption['options_'.$key.'_rfc'] = dol_print_date($date, 'dayrfc'); // international format } else { - $object->array_options['options_'.$key] = ''; - $object->array_options['options_'.$key.'_locale'] = ''; - $object->array_options['options_'.$key.'_rfc'] = ''; + $formatedarrayoption['options_'.$key] = ''; + $formatedarrayoption['options_'.$key.'_locale'] = ''; + $formatedarrayoption['options_'.$key.'_rfc'] = ''; } - $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); - $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $formatedarrayoption['options_'.$key.'_locale'])); + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $formatedarrayoption['options_'.$key.'_rfc'])); } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'datetime') { - $datetime = $object->array_options['options_'.$key]; - $object->array_options['options_'.$key] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhour') : ''); // using company output language - $object->array_options['options_'.$key.'_locale'] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhour', 'tzserver', $outputlangs) : ''); // using output language format - $object->array_options['options_'.$key.'_rfc'] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhourrfc') : ''); // international format - $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); - $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); + $datetime = $formatedarrayoption['options_'.$key]; + $formatedarrayoption['options_'.$key] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($formatedarrayoption['options_'.$key], 'dayhour') : ''); // using company output language + $formatedarrayoption['options_'.$key.'_locale'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($formatedarrayoption['options_'.$key], 'dayhour', 'tzserver', $outputlangs) : ''); // using output language format + $formatedarrayoption['options_'.$key.'_rfc'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($formatedarrayoption['options_'.$key], 'dayhourrfc') : ''); // international format + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $formatedarrayoption['options_'.$key.'_locale'])); + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $formatedarrayoption['options_'.$key.'_rfc'])); } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'link') { - $id = $object->array_options['options_'.$key]; + $id = $formatedarrayoption['options_'.$key]; if ($id != "") { $param = $extrafields->attributes[$object->table_element]['param'][$key]; $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath' @@ -1000,14 +1005,14 @@ abstract class CommonDocGenerator $tmpobject = new $classname($this->db); $tmpobject->fetch($id); // completely replace the id with the linked object name - $object->array_options['options_'.$key] = $tmpobject->name; + $formatedarrayoption['options_'.$key] = $tmpobject->name; } } } } - if (array_key_exists('options_'.$key, $object->array_options)) { - $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); + if (array_key_exists('options_'.$key, $formatedarrayoption)) { + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $formatedarrayoption['options_'.$key])); } else { $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => '')); } diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 985fe9dfd60..78a4e57d5c5 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -49,7 +49,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; // Load translation files required by the page $langs->loadLangs(array("main", "companies")); @@ -203,6 +203,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc { // phpcs:enable global $user, $langs, $conf, $mysoc, $hookmanager; + global $action; if (empty($srctemplatepath)) { dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); @@ -215,7 +216,6 @@ class doc_generic_odt extends ModeleThirdPartyDoc $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); - global $action; if (!is_object($outputlangs)) { $outputlangs = $langs; From 5375b169cdcd80a1c12f0c45a443658c612a4ca9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2023 13:45:35 +0200 Subject: [PATCH 07/10] FIX generating substitution array was corrupting the array_option --- htdocs/core/class/commondocgenerator.class.php | 6 +++--- htdocs/core/modules/societe/doc/doc_generic_odt.modules.php | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 0affc1f5feb..7e85071e453 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -986,9 +986,9 @@ abstract class CommonDocGenerator $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $formatedarrayoption['options_'.$key.'_rfc'])); } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'datetime') { $datetime = $formatedarrayoption['options_'.$key]; - $formatedarrayoption['options_'.$key] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($formatedarrayoption['options_'.$key], 'dayhour') : ''); // using company output language - $formatedarrayoption['options_'.$key.'_locale'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($formatedarrayoption['options_'.$key], 'dayhour', 'tzserver', $outputlangs) : ''); // using output language format - $formatedarrayoption['options_'.$key.'_rfc'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($formatedarrayoption['options_'.$key], 'dayhourrfc') : ''); // international format + $formatedarrayoption['options_'.$key] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhour') : ''); // using company output language + $formatedarrayoption['options_'.$key.'_locale'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhour', 'tzserver', $outputlangs) : ''); // using output language format + $formatedarrayoption['options_'.$key.'_rfc'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhourrfc') : ''); // international format $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $formatedarrayoption['options_'.$key.'_locale'])); $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $formatedarrayoption['options_'.$key.'_rfc'])); } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'link') { diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 78a4e57d5c5..b67cdd61056 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -357,6 +357,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc $array_other = $this->get_substitutionarray_other($outputlangs); $tmparray = array_merge($array_user, $array_soc, $array_thirdparty, $array_other); + complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook From ce6b2d06dbee176c031eb63e1899345e272c3405 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2023 14:14:04 +0200 Subject: [PATCH 08/10] FIX #25223 --- htdocs/don/document.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/don/document.php b/htdocs/don/document.php index 030ca5cb085..c04d6e4a760 100644 --- a/htdocs/don/document.php +++ b/htdocs/don/document.php @@ -77,7 +77,10 @@ if (!$sortfield) { $object = new Don($db); $object->fetch($id, $ref); -$upload_dir = $conf->don->dir_output.'/'.get_exdir($filename, 0, 0, 0, $object, 'donation').'/'.dol_sanitizeFileName($object->ref); +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->don->multidir_output[$object->entity ? $object->entity : $conf->entity]."/".get_exdir(0, 0, 0, 1, $object); +} + $modulepart = 'don'; $permissiontoadd = $user->rights->don->creer; // Used by the include of actions_dellink.inc.php From 1e443e060c05b4ed0709cf4483d954fa0fed774c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jul 2023 16:17:06 +0200 Subject: [PATCH 09/10] Debug v18 --- htdocs/core/class/html.form.class.php | 13 ++++++++----- htdocs/core/js/lib_head.js.php | 2 +- htdocs/core/lib/ajax.lib.php | 8 ++++++-- htdocs/core/lib/functions.lib.php | 8 ++++++-- htdocs/projet/tasks/time.php | 12 +++++++----- htdocs/workstation/class/workstation.class.php | 4 +++- 6 files changed, 31 insertions(+), 16 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 39a0d9754e0..cd75f7c803d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1591,9 +1591,9 @@ class Form if (empty($outputmode)) { if (in_array($obj->rowid, $selected)) { - $out .= ''; + $out .= ''; } else { - $out .= ''; + $out .= ''; } } else { array_push($outarray, array('key' => $obj->rowid, 'value' => $label, 'label' => $label, 'labelhtml' => $labelhtml)); @@ -8612,9 +8612,10 @@ class Form $out .= ' selected'; } if (!empty($tmplabelhtml)) { - $out .= ' data-html="' . dol_escape_htmltag($tmplabelhtml) . '"'; + $out .= ' data-html="' . dol_escape_htmltag($tmplabelhtml, 0, 0, '', 0, 1) . '"'; } else { - $out .= ' data-html="' . dol_escape_htmltag(($tmppicto ? img_picto('', $tmppicto, 'class="pictofixedwidth" style="color: #' . $tmpcolor . '"') : '') . $newval) . '"'; + $tmplabelhtml = ($tmppicto ? img_picto('', $tmppicto, 'class="pictofixedwidth" style="color: #' . $tmpcolor . '"') : '') . $newval; + $out .= ' data-html="' . dol_escape_htmltag($tmplabelhtml, 0, 0, '', 0, 1) . '"'; } $out .= '>'; $out .= dol_htmlentitiesbr($newval); @@ -8631,7 +8632,9 @@ class Form if ($addjscombo == 1) { $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ? constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT; $out .= 'function formatResult(record, container) {' . "\n"; - $out .= ' if ($(record.element).attr("data-html") != undefined) return htmlEntityDecodeJs($(record.element).attr("data-html")); // If property html set, we decode html entities and use this' . "\n"; + // If property html set, we decode html entities and use this. + // Note that HTML content must have been sanitized from js with dol_escape_htmltag(xxx, 0, 0, '', 0, 1) when building the select option. + $out .= ' if ($(record.element).attr("data-html") != undefined) { return htmlEntityDecodeJs($(record.element).attr("data-html")); }'."\n"; $out .= ' return record.text;'; $out .= '}' . "\n"; $out .= 'function formatSelection(record) {' . "\n"; diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 1c29ffc2597..37c0bfc6744 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -464,7 +464,7 @@ function urlencode(s) { /* * ================================================================= - * Purpose: Clean string to have it url encoded + * Purpose: Clean string to get a HTML coded string. * Input: s * Author: Laurent Destailleur * Licence: GPL diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 3a95809e6d4..34ca110dd1e 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -506,11 +506,15 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete = templateResult: function (data, container) { /* Format visible output into combo list */ /* Code to add class of origin OPTION propagated to the new select2
  • tag */ if (data.element) { $(container).addClass($(data.element).attr("class")); } - //console.log($(data.element).attr("data-html")); + //console.log("data html is "+$(data.element).attr("data-html")); if (data.id == '.((int) $idforemptyvalue).' && $(data.element).attr("data-html") == undefined) { return \' \'; } - if ($(data.element).attr("data-html") != undefined) return htmlEntityDecodeJs($(data.element).attr("data-html")); // If property html set, we decode html entities and use this + if ($(data.element).attr("data-html") != undefined) { + /* If property html set, we decode html entities and use this. */ + /* Note that HTML content must have been sanitized from js with dol_escape_htmltag(xxx, 0, 0, \'\', 0, 1) when building the select option. */ + return htmlEntityDecodeJs($(data.element).attr("data-html")); + } return data.text; }, templateSelection: function (selection) { /* Format visible output of selected value */ diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e273f17b154..5b47c3d31b6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1594,14 +1594,18 @@ function dol_escape_json($stringtoescape) * @param int $keepn 1=Preserve \r\n strings (otherwise, replace them with escaped value). Set to 1 when escaping for a