From 7dd95914e801bfa8d3eff13eb4d728b277d3348d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 May 2025 00:02:59 +0200 Subject: [PATCH 1/4] Clean code --- htdocs/core/class/html.form.class.php | 27 +++++++++++++++++---- htdocs/core/lib/functions.lib.php | 29 +++++++++++++++++------ htdocs/core/tpl/objectline_create.tpl.php | 8 +++---- htdocs/main.inc.php | 3 ++- htdocs/societe/card.php | 6 +++-- 5 files changed, 55 insertions(+), 18 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5414bf897d9..fa9900f93b0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -9498,6 +9498,8 @@ class Form } } + $out .= ''; + // We need a hidden field because when using the multiselect, if we unselect all, there is no // variable submitted at all, so no way to make a difference between variable not submitted and variable // submitted to nothing. @@ -9544,21 +9546,35 @@ class Form } $out .= '' . "\n"; + // Add js code to add the edit button and go back + if (getDolGlobalString('CATEGORY_EDIT_IN_POPUP_NOT_IN_MENU')) { + $jsonclose = 'doJsCodeAfterPopupClose'.$htmlname.'()'; + $s = dolButtonToOpenUrlInDialogPopup($htmlname, $langs->transnoentitiesnoconv("Tags"), img_picto('', 'add', 'class="editfielda"'), '/categories/categorie_list.php?type='.Categorie::TYPE_CUSTOMER, '', '', '', $jsonclose); + $out .= $s; + $out .=''; + } + + $out .= ''; + // Add code for jquery to use multiselect if (!empty($conf->use_javascript_ajax) && getDolGlobalString('MAIN_USE_JQUERY_MULTISELECT') || defined('REQUIRE_JQUERY_MULTISELECT')) { $out .= "\n" . ''; $out .= "\n" . ''; - } - $out .= ''; // Add code for jquery to use multiselect @@ -9576,11 +9566,7 @@ class Form $out .= '}' . "\n"; $out .= 'function formatSelection(record) {' . "\n"; - if ($elemtype == 'category') { - $out .= 'return \' \'+record.text+\'\';'; - } else { - $out .= 'return record.text;'; - } + $out .= ' return record.text;'; $out .= '}' . "\n"; // Load the select2 enhancer @@ -9591,7 +9577,7 @@ class Form $out .= ' placeholder: { id: \'-1\', - text: \'' . dol_escape_js($placeholder) . '\' + text: \''.dol_escape_js($placeholder).'\' },'; } $out .= ' dir: \'ltr\', @@ -9599,7 +9585,7 @@ class Form dropdownCssClass: \'' . dol_escape_js($morecss) . '\', /* Line to add class on the new '; + $colspan = 0; + if ($conf->browser->layout == 'phone') { + $colspan = 3; + } + + print ''.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).''; print ''; } - print ''; if ((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) { print '
'; $tmpcode = $object->code_client ?? ''; if (empty($tmpcode) && !empty($modCodeClient->code_auto)) { @@ -2421,7 +2426,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print '
'.$form->editfieldkey('SupplierCode', 'supplier_code', '', $object, 0).''; + print ''.$form->editfieldkey('SupplierCode', 'supplier_code', '', $object, 0).'
"; // Supplier From 186c1bd036f528262f29aacb6359b1e3f2a7b1ee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 May 2025 01:48:05 +0200 Subject: [PATCH 3/4] NEW Add a delay to be sure that any Stripe action from webhooks are executed after interactive actions --- htdocs/public/stripe/ipn.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index 6e92987b054..097fa6f595a 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -165,7 +165,6 @@ if (isModEnabled('multicompany') && !empty($conf->stripeconnect->enabled) && is_ $ret = $mc->switchEntity($key); } -// list of action $stripe = new Stripe($db); // Subject @@ -180,6 +179,10 @@ dol_syslog("***** Stripe IPN was called with event->type=".$event->type." servic dol_syslog("***** Stripe IPN was called with event->type=".$event->type." service=".$service, LOG_DEBUG, 0, '_payment'); +// Add a delay to be sure that any Stripe action from webhooks are executed after interactive actions +sleep(2); + + if ($event->type == 'payout.created' && getDolGlobalString('STRIPE_AUTO_RECORD_PAYOUT')) { // When a payout is created by Stripe to transfer money to your account dol_syslog("object = ".var_export($event->data, true)); From 6c39a9657ccae98fd36a657022ac3f8a2366d60a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 May 2025 02:30:30 +0200 Subject: [PATCH 4/4] NEW Show country flag in list of chart of account --- htdocs/accountancy/admin/account.php | 7 +++++-- htdocs/core/class/html.form.class.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 65e1e82b9c5..8b1a3c7fbd6 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -452,6 +452,7 @@ if ($resql) { $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country = c.rowid AND c.active = 1"; $sql .= " WHERE a.active = 1"; + $sql .= " ORDER BY c.code, a.pcg_version"; dol_syslog("accountancy/admin/account.php sql=".$sql); @@ -463,9 +464,11 @@ if ($resql) { while ($i < $numbis) { $obj = $db->fetch_object($resqlchart); if ($obj) { - print ''; + print '>'.$labeltoshow.''; } $i++; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index adb80239a7b..7f14ae81e59 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -940,7 +940,7 @@ class Form public function select_country($selected = '', $htmlname = 'country_id', $htmloption = '', $maxlength = 0, $morecss = 'minwidth300', $usecodeaskey = '', $showempty = 1, $disablefavorites = 0, $addspecialentries = 0, $exclude_country_code = array(), $hideflags = 0, $forcecombo = 0) { // phpcs:enable - global $conf, $langs, $mysoc; + global $langs, $mysoc; $langs->load("dict");
'; @@ -2753,7 +2758,31 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $arrayselected[] = $cat->id; } print img_picto('', 'category', 'class="pictofixedwidth"'); - print $form->multiselectarray('custcats', $cate_arbo, $arrayselected, 0, 0, 'minwidth100 widthcentpercentminusxx', 0, 0); + $htmlname = 'custcats'; + print $form->multiselectarray($htmlname, $cate_arbo, $arrayselected, 0, 0, 'minwidth100 widthcentpercentminusxx', 0, 0); + + if (getDolGlobalString('CATEGORY_EDIT_IN_POPUP_NOT_IN_MENU')) { + // Add html code to add the edit button and go back + $jsonclose = 'doJsCodeAfterPopupClose'.$htmlname.'()'; + $s = dolButtonToOpenUrlInDialogPopup($htmlname, $langs->transnoentitiesnoconv("Tags"), img_picto('', 'add', 'class="editfielda"'), '/categories/categorie_list.php?type='.Categorie::TYPE_CUSTOMER, '', '', '', $jsonclose); + print $s; + // Add js code to add the edit button and go back + print ''; + } + print "