From 6b31c69c8b872ef8f5e554bb59ae200ec1febc2e Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 16 Jan 2025 18:22:46 +0100 Subject: [PATCH 1/6] Debug v21 --- htdocs/user/bank.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index edd8ff48472..61fadf541b6 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -629,12 +629,22 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac if ($action == 'editaccountancycodeusergeneral' && $user->hasRight('user', 'user', 'creer')) { print $formaccounting->formAccountingAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->accountancy_code_user_general, 'accountancycodeusergeneral', 0, 1, '', 1); } else { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch(0, $object->accountancy_code_user_general, 1); - print $accountingaccount->getNomUrl(0, 1, 1, '', 1); + if (!empty($object->accountancy_code_user_general) && $object->accountancy_code_user_general != '-1') { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(0, $object->accountancy_code_user_general, 1); + print $accountingaccount->getNomUrl(0, 1, 1, '', 1); + } } - $accountingAccountByDefault = " (" . $langs->trans("AccountingAccountByDefaultShort") . ": " . length_accountg(getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT')) . ")"; + print ''; + if (!empty($object->accountancy_code_user_general) && $object->accountancy_code_user_general != '-1') { + print ' ('; + } + $accountingAccountByDefault = $langs->trans("AccountingAccountByDefaultShort") . ": " . length_accountg(getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT')); print (getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') ? $accountingAccountByDefault : ''); + if (!empty($object->accountancy_code_user_general) && $object->accountancy_code_user_general != '-1') { + print ')'; + } + print ''; print ''; // Accountancy code From 4bf6511811c292de5920b2f82ecc54c958e4ede6 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 16 Jan 2025 22:03:51 +0100 Subject: [PATCH 2/6] Debug v21 - getCustomerAccount return duplicates. Misssing a key. --- htdocs/societe/class/societeaccount.class.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index add72341158..2a6447d6ca1 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -269,7 +269,6 @@ class SocieteAccount extends CommonObject */ public function createFromClone(User $user, $fromid) { - global $hookmanager, $langs; $error = 0; dol_syslog(__METHOD__, LOG_DEBUG); @@ -345,18 +344,25 @@ class SocieteAccount extends CommonObject * * @param int $id Id of third party * @param string $site Site (example: 'stripe', '...') - * @param int $status Status (0=test, 1=live) + * @param int $status Status (0=test, 1=live, -1=we don't mind) * @param string $site_account Value to use to identify with account to use on site when site can offer several accounts. For example: 'pk_live_123456' when using Stripe service. + * @param string $fk_website Id website * @return string Stripe customer ref 'cu_xxxxxxxxxxxxx' or '' * @see getThirdPartyID() */ - public function getCustomerAccount($id, $site, $status = 0, $site_account = '') + public function getCustomerAccount($id, $site, $status = 0, $site_account = '', $fk_website = 0) { $sql = "SELECT sa.key_account as key_account, sa.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_account as sa"; $sql .= " WHERE sa.fk_soc = ".((int) $id); $sql .= " AND sa.entity IN (".getEntity('societe').")"; - $sql .= " AND sa.site = '".$this->db->escape($site)."' AND sa.status = ".((int) $status); + $sql .= " AND sa.site = '".$this->db->escape($site)."'"; + if ($fk_website > 0) { + $sql .= " AND sa.fk_website = ".((int) $fk_website); + } + if ($status >= 0) { + $sql .= " AND sa.status = ".((int) $status); + } $sql .= " AND sa.key_account IS NOT NULL AND sa.key_account <> ''"; $sql .= " AND (sa.site_account = '' OR sa.site_account IS NULL OR sa.site_account = '".$this->db->escape($site_account)."')"; $sql .= " ORDER BY sa.site_account DESC, sa.rowid DESC"; // To get the entry with a site_account defined in priority @@ -442,7 +448,7 @@ class SocieteAccount extends CommonObject */ public function getTooltipContentArray($params) { - global $langs, $user; + global $langs; $langs->loadLangs(['companies, commercial', 'website']); @@ -467,7 +473,7 @@ class SocieteAccount extends CommonObject */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { - global $db, $conf, $langs; + global $conf, $langs; global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; From 0f02a26fe388e7adbaceb9d37b7c244b1bb73f82 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 16 Jan 2025 22:58:34 +0100 Subject: [PATCH 3/6] Trans --- htdocs/langs/en_US/website.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index b839978b0a9..6d48cde9934 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -304,6 +304,7 @@ lastUpdate=Last update contactSupport=How to contact support noProductToDisplay=Error, No product to display yourCompanyInformation=Your company information +yourBillingInformation=Your billing information emailAlreadyRegistered=This email is already registered. firstnameContainsLettersOnly=Firstname must contain letters and spaces only lastnameContainsLettersOnly=Lastname must contain letters and spaces only From c5421e457c561b120359616f1d5dafd7234cce16 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 16 Jan 2025 23:59:34 +0100 Subject: [PATCH 4/6] Fix typo --- htdocs/langs/en_US/website.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 6d48cde9934..1f4dea08683 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -361,6 +361,6 @@ LoginCheckout=Login & Proceed to checkout paymentSuccessProcessed=Your payment has been successfully processed. youWillBeRedirectedToOrderPage=You will be redirected to the order details page shortly. WebPortalSetupNotComplete=Web portal setup is not complete -DeleteWebsiteaccount=Delete website account +DeleteWebsiteAccount=Delete website account ConfirmDeleteWebsiteAccount=Are you sure you want to delete this account. ConfirmDeleteWebsiteAccount2=If this account was used to login on the public portal or any otherweb site powered by Dolibarr, the login may be no more possible. From e87853c17bee244d18bf01781e160206ed849ed4 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Fri, 17 Jan 2025 01:03:35 +0100 Subject: [PATCH 5/6] Doc --- htdocs/core/lib/images.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 6ff9a5087f6..c9b9a2fd99a 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -514,7 +514,7 @@ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) * @param string $extName Extension to differentiate thumb file name ('_small', '_mini') * @param int $quality Quality of compression (0=worst, 100=best) * @param string $outdir Directory where to store thumb - * @param int $targetformat New format of target (IMAGETYPE_GIF, IMAGETYPE_JPG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_WBMP ... or 0 to keep old format) + * @param int $targetformat New format of target (IMAGETYPE_GIF, IMAGETYPE_JPG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_WBMP ... or 0 to keep original format) * @return string|int<0,0> Full path of thumb or '' if it fails or 'Error...' if it fails, or 0 if it fails to detect the type of image */ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $quality = 50, $outdir = 'thumbs', $targetformat = 0) @@ -551,9 +551,9 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image - $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image - $imgWidth = $infoImg[0]; // Largeur de l'image - $imgHeight = $infoImg[1]; // Hauteur de l'image + $infoImg = getimagesize($filetoread); // Get information like size and real format of image. Warning real format may be png when extension is .jpg + $imgWidth = $infoImg[0]; // Width of image + $imgHeight = $infoImg[1]; // Height of image $ort = false; if (function_exists('exif_read_data')) { From d404ab6322a83222b7c9104f8612b8c5565d2fd9 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Fri, 17 Jan 2025 01:05:11 +0100 Subject: [PATCH 6/6] Doc --- htdocs/core/lib/images.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index c9b9a2fd99a..26ac9e8930f 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -506,7 +506,8 @@ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) /** * Create a thumbnail from an image file (Supported extensions are gif, jpg, png and bmp). - * If file is myfile.jpg, new file may be myfile_small.jpg + * If file is myfile.jpg, new file may be myfile_small.jpg. But extension may differs if original file has a format and an extension + * of another one, like a.jpg file when real format is png. * * @param string $file Path of source file to resize * @param int $maxWidth Maximum width of the thumbnail (-1=unchanged, 160 by default)