From cf0213e3e1a349c01dc895d829337d8feca4f3aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 17 Sep 2022 09:11:09 +0200 Subject: [PATCH 01/11] update php-iban lib to v4.1.1 --- COPYRIGHT | 6 ++-- htdocs/includes/php-iban/README.md | 14 ++++---- htdocs/includes/php-iban/php-iban.php | 46 +++++++++++++-------------- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/COPYRIGHT b/COPYRIGHT index 8c8a1f56355..46e2f093900 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -13,7 +13,7 @@ The Dolibarr images resources (available in the doc directory) is distributed un The name Dolibarr is a trademark initially registered by Laurent Destailleur and ceased to the Dolibarr foundation. You can use the name Dolibarr -for your own need as long as you follow the rules defined on the page https://wiki.dolibarr.org/index.php/Rules_to_use_the_brand_name_%22Dolibarr%22 +for your own need as long as you follow the rules defined on the page https://wiki.dolibarr.org/index.php/Rules_to_use_the_brand_name_%22Dolibarr%22 The use of the name DoliStore is also restricted to the same rules defined on https://wiki.dolibarr.org/index.php/Rules_to_use_the_brand_name_%22Dolibarr%22 @@ -31,11 +31,11 @@ Mobiledetect 2.8.39 MIT License Yes NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package) PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency ParseDown 1.6 MIT License Yes Markdown parser -PCLZip 2.8.4 LGPL-3+ Yes Library to zip/unzip files +PCLZip 2.8.4 LGPL-3+ Yes Library to zip/unzip files PHPDebugBar 1.15.1 MIT License Yes Used only by the module "debugbar" for developers PHP-Imap 2.7.2 MIT License Yes Library to use IMAP with OAuth PHPSpreadSheet 1.8.2 LGPL-2.1+ Yes Read/Write XLS files, read ODS files -php-iban 4.1 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP +php-iban 4.1.1 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP PHPoAuthLib 0.8.2 MIT License Yes Library to provide oauth1 and oauth2 to different service PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests PSR/Logs 1.0 MIT License Yes Library for logs (used by DebugBar) diff --git a/htdocs/includes/php-iban/README.md b/htdocs/includes/php-iban/README.md index 78b5c121c30..238b8ea7678 100644 --- a/htdocs/includes/php-iban/README.md +++ b/htdocs/includes/php-iban/README.md @@ -9,10 +9,6 @@ php-iban All parts of an IBAN can be retrieved, including country code, checksum, BBAN, financial institution or bank code, account number, and where a fixed-length national system is in use, also branch/sort code. Legacy national checksums may also be retrieved, validated and correctly set, where available, whether they apply to the account number portion, bank and branch identifiers, part or all of the above. IBAN country codes can be converted in to ISO3166-1 alpha-2 and IANA formats, the parent IBAN country acting as registrar for dependent territories may be queried, the official national currency (ISO4217 alpha code format), central bank name and central bank URL may also be queried to ease integration. IBANs may be converted between human and machine representation. IBANs may be obfuscated for presentation to humans in special circumstances such as relative identification. A database of example/test IBANs from different countries is included. Finally, highly accurate suggestions for originally intended input can be made when an incorrect IBAN is detected and is due to mistranscription error. -Tested on PHP versions: ![PHP 5.2](https://img.shields.io/badge/version-PHP%205.2%2B-lightgrey.svg) ![PHP 5.3](https://img.shields.io/badge/version-PHP%205.3%2B-lightgrey.svg) ![PHP 5.4](https://img.shields.io/badge/version-PHP%205.4%2B-lightgrey.svg) ![PHP 5.5](https://img.shields.io/badge/version-PHP%205.5%2B-lightgrey.svg) ![PHP 5.6](https://img.shields.io/badge/version-PHP%205.6%2B-lightgrey.svg) ![PHP 7.0](https://img.shields.io/badge/version-PHP%207.0%2B-lightgrey.svg) ![PHP 7.4](https://img.shields.io/badge/version-PHP%207.4%2B-lightgrey.svg) - -Test on HHVM versions: ![HHVM 3.3](https://img.shields.io/badge/version-HHVM%203.3%2B-lightgrey.svg) ![HHVM 3.6](https://img.shields.io/badge/version-HHVM%203.6%2B-lightgrey.svg) ![HHVM 3.9](https://img.shields.io/badge/version-HHVM%203.9%2B-lightgrey.svg) ![HHVM 3.12](https://img.shields.io/badge/version-HHVM%203.12%2B-lightgrey.svg) ![HHVM 3.15](https://img.shields.io/badge/version-HHVM%203.15%2B-lightgrey.svg) ![HHVM 3.18](https://img.shields.io/badge/version-HHVM%203.18%2B-lightgrey.svg) - The parser was built using regular expressions to adapt the contents of the _official_ IBAN registry available from SWIFT then manually modified for special cases such as [errors and omissions in SWIFT's official specifications](https://raw.githubusercontent.com/globalcitizen/php-iban/master/docs/COMEDY-OF-ERRORS). Various deficiencies in the initial adaptation have since been rectified, and the current version should be a fairly correct and reliable implementation. @@ -256,14 +252,14 @@ The following table compares __php-iban__ to other PHP projects offering IBAN-re | Project | Lic. | Proc | OO | Began | Latest | Star | Watch | Fork | Installs | Home culture | Deps | | ---------------------------------------------------------- | ---- | ---- | --- | ------ | ------ | ---- | ----- | ---- | -------- | ------------ | ------- | -| __php-iban__ | LGPL | ✔ | ✔ | 2009 | 4.1.0 | 344 | 26 | 76 | ~2M* | Global* | *none* | +| __php-iban__ | LGPL | ✔ | ✔ | 2009 | 4.1.1 | 414 | 28 | 98 | ~3.5M* | Global* | *none* | | [Iban](https://github.com/jschaedl/Iban) | MIT | ✘ | ✔ | 2013 | 1.3.0 | 50 | 9 | 19 | 178.39k | German | lots | | [IsoCodes](https://github.com/ronanguilloux/IsoCodes) | GPL3 | ✘ | ✔ | 2012 | 2.1.1 | 466 | 22 | 54 | 145k | French | lots | | [SepaUtil's](https://github.com/AbcAeffchen/SepaUtilities) | GPL3 | ✘ | ✔ | 2014 | 1.2.3 | 8 | 4 | 3 | 25k | German | phpunit | | [Symfony](https://github.com/symfony/symfony) | MIT | ✘ | ✔ | 2013 | 3.3.6 | 15k | 1214 | 5.6k | 23M+ | French | lots | Notes: - * Original download records for __php-iban__ releases were hosted on Google Code and are now lost. Prior to establishing a release process on Github, we just expected that people would download the code... so we're really not sure how many installs exist, but this is a fair guess (~11k + composer installs + a little bit now and then). + * Original download records for __php-iban__ releases were hosted on Google Code and are now lost. Prior to establishing a release process on Github, we just expected that people would download the code... so we're really not sure how many installs exist, but this is a fair guess (now over 3M composer installs + all prior google code and Github installs). * __php-iban__ also powers: * [adm-gravity-iban](https://github.com/InternativeNL/adm-gravity-iban) * [Azzana consulting's XML Solver for ISO20022](http://www.azzana-consulting.com/xmlsolver/) @@ -324,6 +320,12 @@ Your Help Wanted * If you are willing to spend some time searching, we could do with some more test IBANs for most countries, especially smaller ones... +News: August 2022 +----------------- + +__[Version 4.1.1](https://github.com/globalcitizen/php-iban/releases/tag/v4.1.1)__ has been released. + * Long-standing bug affecting Belgian pre-IBAN national checksum verification fixed - thanks to [Arne Peirs](https://github.com/Olympic1) for a [very well documented pull request](https://github.com/globalcitizen/php-iban/pull/119). + News: July 2021 --------------- diff --git a/htdocs/includes/php-iban/php-iban.php b/htdocs/includes/php-iban/php-iban.php index 902cc1e2669..effc0cbf6a8 100644 --- a/htdocs/includes/php-iban/php-iban.php +++ b/htdocs/includes/php-iban/php-iban.php @@ -29,7 +29,7 @@ function verify_iban($iban,$machine_format_only=false) { # Check regex if(preg_match($regex,$iban)) { # Regex passed, check checksum - if(!iban_verify_checksum($iban)) { + if(!iban_verify_checksum($iban)) { return false; } } @@ -56,9 +56,9 @@ function iban_to_machine_format($iban) { # Convert an IBAN to human format. To do this, we # simply insert spaces right now, as per the ECBS -# (European Committee for Banking Standards) +# (European Committee for Banking Standards) # recommendations available at: -# http://www.europeanpaymentscouncil.eu/knowledge_bank_download.cfm?file=ECBS%20standard%20implementation%20guidelines%20SIG203V3.2.pdf +# http://www.europeanpaymentscouncil.eu/knowledge_bank_download.cfm?file=ECBS%20standard%20implementation%20guidelines%20SIG203V3.2.pdf function iban_to_human_format($iban) { # Remove all spaces $iban = str_replace(' ','',$iban); @@ -71,15 +71,15 @@ function iban_to_human_format($iban) { # asterisk, except for the final four characters, and then # return in human format, ie. # HU69107000246667654851100005 -> HU** **** **** **** **** **** 0005 -# +# # We avoid the checksum as it may be used to infer the rest # of the IBAN in cases where the country has few valid banks # and branches, or other information about the account such # as bank, branch, or date issued is known (where a sequential # issuance scheme is in use). -# -# Note that output of this function should be presented with -# other information to a user, such as the date last used or +# +# Note that output of this function should be presented with +# other information to a user, such as the date last used or # the date added to their account, in order to better facilitate # unambiguous relative identification. function iban_to_obfuscated_format($iban) { @@ -439,10 +439,10 @@ function iban_country_get_is_eu_member($iban_country) { # - turkish TL/TK thing # - norway NO gets dropped due to mis-identification with "No." for number (ie. if no country code try prepending NO) function iban_mistranscription_suggestions($incorrect_iban) { - + # remove funky characters $incorrect_iban = iban_to_machine_format($incorrect_iban); - + # abort on ridiculous length input (but be liberal) $length = strlen($incorrect_iban); if($length<5 || $length>34) { return array('(supplied iban length insane)'); } @@ -663,7 +663,7 @@ function _iban_nationalchecksum_set($iban,$nationalchecksum) { return $fixed_iban; } -# Currently unused but may be useful for Norway. +# Currently unused but may be useful for Norway. # ISO7064 MOD11-2 # Adapted from https://gist.github.com/andreCatita/5714353 by Andrew Catita function _iso7064_mod112_catita($input) { @@ -678,7 +678,7 @@ function _iso7064_mod112_catita($input) { return $result; } -# Currently unused but may be useful for Norway. +# Currently unused but may be useful for Norway. # ISO 7064:1983.MOD 11-2 # by goseaside@sina.com function _iso7064_mod112_goseaside($vString) { @@ -688,10 +688,10 @@ function _iso7064_mod112_goseaside($vString) { $i_size = strlen($vString); $bModify = '?' == substr($vString, -1); $i_size1 = $bModify ? $i_size : $i_size + 1; - for ($i = 1; $i <= $i_size; $i++) { + for ($i = 1; $i <= $i_size; $i++) { $i1 = $vString[$i - 1] * 1; $w1 = $wi[($i_size1 - $i) % 10]; - $sigma += ($i1 * $w1) % 11; + $sigma += ($i1 * $w1) % 11; } if($bModify) return str_replace('?', $hash_map[($sigma % 11)], $vString); else return $hash_map[($sigma % 11)]; @@ -714,13 +714,13 @@ function _iso7064_mod97_10($str) { } # Implement the national checksum for a Belgium (BE) IBAN -# (Credit: @gaetan-be) +# (Credit: @gaetan-be, fixed by @Olympic1) function _iban_nationalchecksum_implementation_be($iban,$mode) { if($mode != 'set' && $mode != 'find' && $mode != 'verify') { return ''; } # blank value on return to distinguish from correct execution $nationalchecksum = iban_get_nationalchecksum_part($iban); - $account = iban_get_account_part($iban); - $account_less_checksum = substr($account,strlen($account)-2); - $expected_nationalchecksum = $account_less_checksum % 97; + $bban = iban_get_bban_part($iban); + $bban_less_checksum = substr($bban, 0, -strlen($nationalchecksum)); + $expected_nationalchecksum = $bban_less_checksum % 97; if($mode=='find') { return $expected_nationalchecksum; } @@ -776,8 +776,8 @@ function _iban_nationalchecksum_implementation_es($iban,$mode) { function _iban_nationalchecksum_implementation_fr_letters2numbers_helper($bban) { $allNumbers = ""; $conversion = array( - "A" => 1, "B" => 2, "C" => 3, "D" => 4, "E" => 5, "F" => 6, "G" => 7, "H" => 8, "I" => 9, - "J" => 1, "K" => 2, "L" => 3, "M" => 4, "N" => 5, "O" => 6, "P" => 7, "Q" => 8, "R" => 9, + "A" => 1, "B" => 2, "C" => 3, "D" => 4, "E" => 5, "F" => 6, "G" => 7, "H" => 8, "I" => 9, + "J" => 1, "K" => 2, "L" => 3, "M" => 4, "N" => 5, "O" => 6, "P" => 7, "Q" => 8, "R" => 9, "S" => 2, "T" => 3, "U" => 4, "V" => 5, "W" => 6, "X" => 7, "Y" => 8, "Z" => 9 ); for ($i=0; $i < strlen($bban); $i++) { @@ -852,7 +852,7 @@ function _iban_nationalchecksum_implementation_mc($iban,$mode) { } # Implement the national checksum for a France (FR) IBAN -# (Credit: @gaetan-be, http://www.credit-card.be/BankAccount/ValidationRules.htm#FR_Validation and +# (Credit: @gaetan-be, http://www.credit-card.be/BankAccount/ValidationRules.htm#FR_Validation and # https://docs.oracle.com/cd/E18727_01/doc.121/e13483/T359831T498954.htm) function _iban_nationalchecksum_implementation_fr($iban,$mode) { if($mode != 'set' && $mode != 'find' && $mode != 'verify') { return ''; } # blank value on return to distinguish from correct execution @@ -1100,7 +1100,7 @@ function _iban_nationalchecksum_implementation_pt($iban,$mode) { } # Implement the national checksum for an Serbia (RS) IBAN -# (NOTE: Reverse engineered, including bank 'Narodna banka Srbije' (908) exception. For two +# (NOTE: Reverse engineered, including bank 'Narodna banka Srbije' (908) exception. For two # separately published and legitimate looking IBANs from that bank, there appears to # be a +97 offset on the checksum, so we simply ignore all checksums for this bank.) function _iban_nationalchecksum_implementation_rs($iban,$mode) { @@ -1118,7 +1118,7 @@ function _iban_nationalchecksum_implementation_rs($iban,$mode) { function _iban_nationalchecksum_implementation_si($iban,$mode) { $bank = iban_get_bank_part($iban); # Bank of Slovenia does not use the legacy checksum scheme. - # Accounts in this namespace appear to be the central bank + # Accounts in this namespace appear to be the central bank # accounts for licensed local banks. if($bank == '01') { return ''; @@ -1277,7 +1277,7 @@ function _iban_nationalchecksum_implementation_sm($iban,$mode) { # Italian (and San Marino's) checksum # (Credit: Translated by Francesco Zanoni from http://community.visual-basic.it/lucianob/archive/2004/12/26/2464.aspx) -# (Source: European Commettee of Banking Standards' Register of European Account Numbers (TR201 V3.23 — FEBRUARY 2007), +# (Source: European Commettee of Banking Standards' Register of European Account Numbers (TR201 V3.23 — FEBRUARY 2007), # available at URL http://www.cnb.cz/cs/platebni_styk/iban/download/TR201.pdf) function _italian($input) { From 0269d3dbed1d30207927bc02eca2a8d8326f5a3d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Sep 2022 13:34:29 +0200 Subject: [PATCH 02/11] Reduc delay --- htdocs/core/login/functions_dolibarr.php | 2 +- htdocs/core/login/functions_ldap.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/login/functions_dolibarr.php b/htdocs/core/login/functions_dolibarr.php index 610072aa35a..990390235a7 100644 --- a/htdocs/core/login/functions_dolibarr.php +++ b/htdocs/core/login/functions_dolibarr.php @@ -124,7 +124,7 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes if ($passok) { $login = $obj->login; } else { - sleep(2); // Anti brut force protection + sleep(1); // Anti brut force protection dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO bad password for '".$usertotest."', cryptType=".$cryptType, LOG_NOTICE); // Load translation files required by the page diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php index e9785ce82a8..3f217573b18 100644 --- a/htdocs/core/login/functions_ldap.php +++ b/htdocs/core/login/functions_ldap.php @@ -267,7 +267,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) $ldap->ldapErrorText = ldap_error($ldap->connection); dol_syslog("functions_ldap::check_user_password_ldap ".$ldap->ldapErrorCode." ".$ldap->ldapErrorText); } - sleep(2); // Anti brut force protection + sleep(1); // Anti brut force protection // Load translation files required by the page $langs->loadLangs(array('main', 'other', 'errors')); From 1a663b5105025d9bc256c4171292dfa7e4f7dd8c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Sep 2022 13:41:07 +0200 Subject: [PATCH 03/11] Fix page to setup OAUTH --- htdocs/admin/oauth.php | 149 +++++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 73 deletions(-) diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index 772055f0809..a671888ec56 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -100,7 +100,7 @@ $form = new Form($db); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup'); -print '
'; +print ''; print ''; print ''; @@ -137,15 +137,8 @@ print '
'; print '
'; print '
'; +print dol_get_fiche_end(); -print '
'; -print ''; -print ''; - -print '
'; -print ''; - -$i = 0; //var_dump($list); foreach ($conf->global as $key => $val) { @@ -155,83 +148,93 @@ foreach ($conf->global as $key => $val) { } } -// $list is defined into oauth.lib.php to the list of supporter OAuth providers. -foreach ($listinsetup as $key) { - $supported = 0; - $keyforsupportedoauth2array = $key[0]; // May be OAUTH_GOOGLE_NAME or OAUTH_GOOGLE_xxx_NAME - $keyforsupportedoauth2array = preg_replace('/^OAUTH_/', '', $keyforsupportedoauth2array); - $keyforsupportedoauth2array = preg_replace('/_NAME$/', '', $keyforsupportedoauth2array); - if (preg_match('/^.*-/', $keyforsupportedoauth2array)) { - $keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array); - } else { - $keyforprovider = ''; - } - $keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array); - $keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME'; - if (in_array($keyforsupportedoauth2array, array_keys($supportedoauth2array))) { - $supported = 1; - } - if (!$supported) { - continue; // show only supported - } +if (count($listinsetup) > 0) { + print ''; + print ''; + print ''; - $i++; + print '
'; + print '
'; - print ''; - // Api Name - $label = $langs->trans($keyforsupportedoauth2array); - print ''; - print ''; - print ''; + $i = 0; - if ($supported) { - $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'].'_oauthcallback.php'; + // $list is defined into oauth.lib.php to the list of supporter OAuth providers. + foreach ($listinsetup as $key) { + $supported = 0; + $keyforsupportedoauth2array = $key[0]; // May be OAUTH_GOOGLE_NAME or OAUTH_GOOGLE_xxx_NAME + $keyforsupportedoauth2array = preg_replace('/^OAUTH_/', '', $keyforsupportedoauth2array); + $keyforsupportedoauth2array = preg_replace('/_NAME$/', '', $keyforsupportedoauth2array); + if (preg_match('/^.*-/', $keyforsupportedoauth2array)) { + $keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array); + } else { + $keyforprovider = ''; + } + $keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array); + $keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME'; + + if (in_array($keyforsupportedoauth2array, array_keys($supportedoauth2array))) { + $supported = 1; + } + if (!$supported) { + continue; // show only supported + } + + $i++; + + print ''; + // Api Name + $label = $langs->trans($keyforsupportedoauth2array); + print ''; + print ''; + print ''; + + if ($supported) { + $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'].'_oauthcallback.php'; + print ''; + print ''; + print ''; + } else { + print ''; + print ''; + print ''; + print ''; + } + + // Api Id print ''; - print ''; - print ''; + print ''; - } else { + + // Api Secret print ''; - print ''; - print ''; + print ''; + print ''; } - // Api Id - print ''; - print ''; - print ''; + print '
'; - print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"'); - print $label; - if ($keyforprovider) { - print ' ('.$keyforprovider.')'; - } else { - print ' ('.$langs->trans("NoName").')'; - } - print ''; - if (!empty($supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials'])) { - print $langs->trans("OAUTH_URL_FOR_CREDENTIAL", $supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials']); - } - print '
'; + print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"'); + print $label; + if ($keyforprovider) { + print ' ('.$keyforprovider.')'; + } else { + print ' ('.$langs->trans("NoName").')'; + } + print ''; + if (!empty($supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials'])) { + print $langs->trans("OAUTH_URL_FOR_CREDENTIAL", $supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials']); + } + print '
'.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; + print '
'.$langs->trans("UseTheFollowingUrlAsRedirectURI").''.$langs->trans("FeatureNotYetSupported").'
'.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; + print ''; print '
'.$langs->trans("UseTheFollowingUrlAsRedirectURI").''.$langs->trans("FeatureNotYetSupported").''; print '
'; - print '
'."\n"; + print '
'; - // Api Secret - print ''; - print ''; - print ''; - print ''; + print $form->buttonsSaveCancel("Modify", ''); + + print '
'; } -print ''."\n"; -print ''; - -print dol_get_fiche_end(); - -print $form->buttonsSaveCancel("Modify", ''); - -print ''; - // End of page llxFooter(); $db->close(); From c2a4b78ee857b1b009f0623f07f0d98cc58d9090 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Sep 2022 13:49:39 +0200 Subject: [PATCH 04/11] Fix control char of a label --- htdocs/admin/oauth.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index a671888ec56..ec6af9bc4f6 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -36,7 +36,7 @@ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domai //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current // Load translation files required by the page -$langs->loadLangs(array('admin', 'oauth')); +$langs->loadLangs(array('admin', 'oauth', 'modulebuilder')); // Security check if (!$user->admin) { @@ -130,7 +130,7 @@ foreach ($list as $key) { } print ''; print ajax_combobox('provider'); -print ' '; +print ' '; print ' '; print ''; From 9ba2b41aee142316c2f4947ae30981e8f4e8029e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Sep 2022 00:31:11 +0200 Subject: [PATCH 05/11] FIX filter lost when sorting on productMargin --- htdocs/margin/productMargins.php | 47 ++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index ac006c042aa..a47ec246aaf 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -74,17 +74,18 @@ if (!$sortfield) { $startdate = $enddate = ''; -if (!empty($_POST['startdatemonth'])) { - $startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']); +if (GETPOST('startdatemonth')) { + $startdate = dol_mktime(0, 0, 0, GETPOST('startdatemonth', 'int'), GETPOST('startdateday', 'int'), GETPOST('startdateyear', 'int')); } -if (!empty($_POST['enddatemonth'])) { - $enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']); +if (GETPOST('enddatemonth')) { + $enddate = dol_mktime(23, 59, 59, GETPOST('enddatemonth', 'int'), GETPOST('enddateday', 'int'), GETPOST('enddateyear')); } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Product($db); $hookmanager->initHooks(array('marginproductlist')); + /* * View */ @@ -224,13 +225,31 @@ $sql .= $db->order($sortfield, $sortorder); // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); +$param = '&id='.((int) $id); +if (GETPOST('startdatemonth', 'int')) { + $param .= '&startdateyear='.GETPOST('startdateyear', 'int'); + $param .= '&startdatemonth='.GETPOST('startdatemonth', 'int'); + $param .= '&startdateday='.GETPOST('startdateday', 'int'); +} +if (GETPOST('enddatemonth', 'int')) { + $param .= '&enddateyear='.GETPOST('enddateyear', 'int'); + $param .= '&enddatemonth='.GETPOST('enddatemonth', 'int'); + $param .= '&enddateday='.GETPOST('enddateday', 'int'); +} +$listofcateg = GETPOST('categories', 'array:int'); +if (is_array($listofcateg)) { + foreach ($listofcateg as $val) { + $param .= '&categories[]='.$val; + } +} + dol_syslog('margin::productMargins.php', LOG_DEBUG); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); print '
'; - print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "&id=".$id, $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); + print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); //var_dump($conf->global->MARGIN_TYPE); if ($conf->global->MARGIN_TYPE == "1") { @@ -247,20 +266,20 @@ if ($result) { print ''; if ($id > 0) { - print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", "&id=".$id, '', $sortfield, $sortorder); - print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&id=".$id, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $param, '', $sortfield, $sortorder, 'center '); } else { - print_liste_field_titre("ProductService", $_SERVER["PHP_SELF"], "p.ref", "", "&id=".$id, '', $sortfield, $sortorder); + print_liste_field_titre("ProductService", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); } - print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "product_qty", "", "&id=".$id, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", "&id=".$id, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", "&id=".$id, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&id=".$id, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "product_qty", "", $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, '', $sortfield, $sortorder, 'right '); if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { - print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&id=".$id, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); } if (!empty($conf->global->DISPLAY_MARK_RATES)) { - print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&id=".$id, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); } print "\n"; From d452d225b6f1cf1d9eca7b6ee6bd0926e14570af Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Sep 2022 09:24:19 +0200 Subject: [PATCH 06/11] FIX support of array parameters in "add to bookmark" feature. --- htdocs/bookmarks/bookmarks.lib.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 54bd7a41282..26d834fb5d9 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -42,8 +42,12 @@ function printDropdownBookmarksList() if (!empty($_SERVER["QUERY_STRING"])) { if (is_array($_GET)) { foreach ($_GET as $key => $val) { - if ($val != '') { - $url_param[$key]=http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val))); + if (is_array($val)) { + foreach ($val as $tmpsubval) { + $url_param[] = http_build_query(array(dol_escape_htmltag($key).'[]' => dol_escape_htmltag($tmpsubval))); + } + } elseif ($val != '') { + $url_param[$key] = http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val))); } } } @@ -61,10 +65,11 @@ function printDropdownBookmarksList() if ((preg_match('/^search_/', $key) || in_array($key, $authorized_var)) && $val != '' && !array_key_exists($key, $url_param)) { - $url_param[$key]=http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val))); + $url_param[$key] = http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val))); } } } + $url .= ($tmpurl ? '?'.$tmpurl : ''); if (!empty($url_param)) { $url .= '&'.implode('&', $url_param); From e56362a5debb1c162668d4fb69711dcb9e31973e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Sep 2022 09:37:57 +0200 Subject: [PATCH 07/11] FIX filters lost when sorting on customerMargins --- htdocs/margin/customerMargins.php | 54 ++++++++++++++++++++++--------- htdocs/margin/productMargins.php | 3 +- 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 290a94908c0..e5f21b5095f 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -43,8 +43,6 @@ $result = restrictedArea($user, 'societe', '', ''); $result = restrictedArea($user, 'margins'); -$mesg = ''; - // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -64,18 +62,18 @@ if (!$sortorder) { } $startdate = $enddate = ''; - -if (!empty($_POST['startdatemonth'])) { - $startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']); +if (GETPOST('startdatemonth')) { + $startdate = dol_mktime(0, 0, 0, GETPOST('startdatemonth', 'int'), GETPOST('startdateday', 'int'), GETPOST('startdateyear', 'int')); } -if (!empty($_POST['enddatemonth'])) { - $enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']); +if (GETPOST('enddatemonth')) { + $enddate = dol_mktime(23, 59, 59, GETPOST('enddatemonth', 'int'), GETPOST('enddateday', 'int'), GETPOST('enddateyear')); } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Societe($db); $hookmanager->initHooks(array('margincustomerlist')); + /* * View */ @@ -188,7 +186,7 @@ print ''; // Total Margin print ''; // Margin Rate @@ -271,6 +269,30 @@ $sql .= $db->order($sortfield, $sortorder); // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); +$param = '&socid='.((int) $socid); +if (GETPOST('startdatemonth', 'int')) { + $param .= '&startdateyear='.GETPOST('startdateyear', 'int'); + $param .= '&startdatemonth='.GETPOST('startdatemonth', 'int'); + $param .= '&startdateday='.GETPOST('startdateday', 'int'); +} +if (GETPOST('enddatemonth', 'int')) { + $param .= '&enddateyear='.GETPOST('enddateyear', 'int'); + $param .= '&enddatemonth='.GETPOST('enddatemonth', 'int'); + $param .= '&enddateday='.GETPOST('enddateday', 'int'); +} +$listofproducts = GETPOST('products', 'array:int'); +if (is_array($listofproducts)) { + foreach ($listofproducts as $val) { + $param .= '&products[]='.$val; + } +} +$listofcateg = GETPOST('categories', 'array:int'); +if (is_array($listofcateg)) { + foreach ($listofcateg as $val) { + $param .= '&categories[]='.$val; + } +} + dol_syslog('margin::customerMargins.php', LOG_DEBUG); $result = $db->query($sql); if ($result) { @@ -293,19 +315,19 @@ if ($result) { print ''; if (!empty($client)) { - print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", "&socid=".$socid, '', $sortfield, $sortorder); - print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&socid=".$socid, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $param, 'align="center"', $sortfield, $sortorder); } else { - print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "s.nom", "", "&socid=".$socid, '', $sortfield, $sortorder); + print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); } - print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, 'align="right"', $sortfield, $sortorder); if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { - print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder); } if (!empty($conf->global->DISPLAY_MARK_RATES)) { - print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder); } print "\n"; diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index a47ec246aaf..48e0d50cd4c 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -73,7 +73,6 @@ if (!$sortfield) { } $startdate = $enddate = ''; - if (GETPOST('startdatemonth')) { $startdate = dol_mktime(0, 0, 0, GETPOST('startdatemonth', 'int'), GETPOST('startdateday', 'int'), GETPOST('startdateyear', 'int')); } @@ -150,7 +149,7 @@ print '
'.$langs->trans("TotalMargin").''; -print ''; // set by jquery (see below) +print ' '.$langs->getCurrencySymbol($conf->currency).''; // set by jquery (see below) print '
'; // Total Margin print ''; // Margin Rate From 39863897b776eeeb343596f81e86fc2dcf81c66f Mon Sep 17 00:00:00 2001 From: rsanjoseo Date: Sun, 18 Sep 2022 11:30:41 +0200 Subject: [PATCH 08/11] Add a new tab with php errors and warnings to the debug bar --- .../class/DataCollector/DolPhpCollector.php | 168 ++++++++++++++++++ htdocs/debugbar/class/DebugBar.php | 2 + 2 files changed, 170 insertions(+) create mode 100644 htdocs/debugbar/class/DataCollector/DolPhpCollector.php diff --git a/htdocs/debugbar/class/DataCollector/DolPhpCollector.php b/htdocs/debugbar/class/DataCollector/DolPhpCollector.php new file mode 100644 index 00000000000..3d6536bd258 --- /dev/null +++ b/htdocs/debugbar/class/DataCollector/DolPhpCollector.php @@ -0,0 +1,168 @@ +name = $name; + set_error_handler([$this, 'errorHandler'], E_ALL); + } + + /** + * Called by the DebugBar when data needs to be collected. + * + * @return array Collected data. + */ + public function collect() + { + $messages = $this->getMessages(); + return [ + 'count' => count($messages), + 'messages' => $messages, + ]; + } + + /** + * Returns a list of messages ordered by their timestamp. + * + * @return array A list of messages ordered by time. + */ + public function getMessages() + { + $messages = $this->messages; + + usort($messages, function ($itemA, $itemB) { + if ($itemA['time'] === $itemB['time']) { + return 0; + } + return $itemA['time'] < $itemB['time'] ? -1 : 1; + }); + + return $messages; + } + + /** + * Returns a hash where keys are control names and their values an array of options as defined in + * {@see DebugBar\JavascriptRenderer::addControl()} + * + * @return array Needed details to render the widget. + */ + public function getWidgets() + { + $name = $this->getName(); + return [ + $name => [ + 'icon' => 'list', + 'widget' => 'PhpDebugBar.Widgets.MessagesWidget', + 'map' => "$name.messages", + 'default' => '[]', + ], + "$name:badge" => [ + 'map' => "$name.count", + 'default' => 'null', + ], + ]; + } + + /** + * Returns the unique name of the collector. + * + * @return string The widget name. + */ + public function getName() + { + return $this->name; + } + + /** + * Exception error handler. Called from constructor with set_error_handler to add all details. + * + * @param int $severity Error type. + * @param string $message Message of error. + * @param string $fileName File where error is generated. + * @param int $line Line number where error is generated. + * + * @return void + */ + public function errorHandler($severity, $message, $fileName, $line) + { + for ($i = 0; $i < 15; $i++) { + if ($type = $severity & (2 ** $i)) { + $label = $this->friendlyErrorType($type); + $this->messages[] = [ + 'message' => $message . ' (' . $fileName . ':' . $line . ')', + 'message_html' => null, + 'is_string' => true, + 'label' => $label, + 'time' => microtime(true), + ]; + } + } + } + + /** + * Return error name from error code. + * + * @info http://php.net/manual/es/errorfunc.constants.php + * + * @param int $type Error code. + * + * @return string Error name. + */ + private function friendlyErrorType($type) + { + $errors = [ + E_ERROR => 'ERROR', + E_WARNING => 'WARNING', + E_PARSE => 'PARSE', + E_NOTICE => 'NOTICE', + E_CORE_ERROR => 'CORE_ERROR', + E_CORE_WARNING => 'CORE_WARNING', + E_COMPILE_ERROR => 'COMPILE_ERROR', + E_COMPILE_WARNING => 'COMPILE_WARNING', + E_USER_ERROR => 'USER_ERROR', + E_USER_WARNING => 'USER_WARNING', + E_USER_NOTICE => 'USER_NOTICE', + E_STRICT => 'STRICT', + E_RECOVERABLE_ERROR => 'RECOVERABLE_ERROR', + E_DEPRECATED => 'DEPRECATED', + E_USER_DEPRECATED => 'USER_DEPRECATED', + ]; + + $result = ''; + if (isset($errors[$type])) { + $result = $errors[$type]; + } + + return $result; + } +} diff --git a/htdocs/debugbar/class/DebugBar.php b/htdocs/debugbar/class/DebugBar.php index af824a64392..b2ec0f17bf0 100644 --- a/htdocs/debugbar/class/DebugBar.php +++ b/htdocs/debugbar/class/DebugBar.php @@ -10,6 +10,7 @@ dol_include_once('/debugbar/class/DataCollector/DolRequestDataCollector.php'); dol_include_once('/debugbar/class/DataCollector/DolConfigCollector.php'); dol_include_once('/debugbar/class/DataCollector/DolTimeDataCollector.php'); dol_include_once('/debugbar/class/DataCollector/DolMemoryCollector.php'); +dol_include_once('/debugbar/class/DataCollector/DolPhpCollector.php'); dol_include_once('/debugbar/class/DataCollector/DolExceptionsCollector.php'); dol_include_once('/debugbar/class/DataCollector/DolQueryCollector.php'); dol_include_once('/debugbar/class/DataCollector/DolibarrCollector.php'); @@ -36,6 +37,7 @@ class DolibarrDebugBar extends DebugBar $this->addCollector(new DolRequestDataCollector()); //$this->addCollector(new DolConfigCollector()); // Disabled for security purpose $this->addCollector(new DolTimeDataCollector()); + $this->addCollector(new PhpCollector()); $this->addCollector(new DolMemoryCollector()); //$this->addCollector(new DolExceptionsCollector()); $this->addCollector(new DolQueryCollector()); From 76ecf1d35a4f4da10fb9166c4763c434c675f43a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 19 Sep 2022 08:54:45 +0200 Subject: [PATCH 09/11] NEW Bank - Add salaries & vat in tab planned entries --- htdocs/compta/bank/treso.php | 50 +++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 0d76b40a3e2..14e07d1ea14 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -4,6 +4,7 @@ * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2015 Marcos García + * Copyright (C) 2022 Alexandre Spangaro * * 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 @@ -28,13 +29,16 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; +require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page -$langs->loadLangs(array('banks', 'categories', 'bills', 'companies')); +$langs->loadLangs(array('banks', 'bills', 'categories', 'companies', 'salaries')); // Security check if (GETPOSTISSET("account") || GETPOSTISSET("ref")) { @@ -58,9 +62,12 @@ $hookmanager->initHooks(array('banktreso', 'globalcard')); * View */ $societestatic = new Societe($db); +$userstatic = new User($db); $facturestatic = new Facture($db); $facturefournstatic = new FactureFournisseur($db); $socialcontribstatic = new ChargeSociales($db); +$salarystatic = new Salary($db); +$vatstatic = new TVA($db); $form = new Form($db); @@ -133,6 +140,27 @@ if (GETPOST("account") || GETPOST("ref")) { $sql .= " ORDER BY dlr ASC"; $sqls[] = $sql; + // Salaries + $sql = " SELECT 'salary' as family, sa.rowid as objid, sa.label as ref, (-1*sa.amount) as total_ttc, sa.dateep as dlr,"; + $sql .= " s.rowid as socid, CONCAT(s.firstname, ' ', s.lastname) as name, 0 as fournisseur"; + $sql .= " FROM ".MAIN_DB_PREFIX."salary as sa"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as s ON sa.fk_user = s.rowid"; + $sql .= " WHERE sa.entity = ".$conf->entity; + $sql .= " AND sa.paye = 0"; // Not paid + $sql .= " AND (sa.fk_account IN (0, ".$object->id.") OR sa.fk_account IS NULL)"; // Id bank account of salary + $sql .= " ORDER BY dlr ASC"; + $sqls[] = $sql; + + // VAT + $sql = " SELECT 'vat' as family, t.rowid as objid, t.label as ref, (-1*t.amount) as total_ttc, t.datev as dlr,"; + $sql .= " 0 as socid, 'noname' as name, 0 as fournisseur"; + $sql .= " FROM ".MAIN_DB_PREFIX."tva as t"; + $sql .= " WHERE t.entity = ".$conf->entity; + $sql .= " AND t.paye = 0"; // Not paid + $sql .= " AND (t.fk_account IN (-1, 0, ".$object->id.") OR t.fk_account IS NULL)"; // Id bank account of vat + $sql .= " ORDER BY dlr ASC"; + $sqls[] = $sql; + // others sql $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreSQL', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -266,6 +294,26 @@ if (GETPOST("account") || GETPOST("ref")) { $totalpayment = -1 * $socialcontribstatic->getSommePaiement(); // Payment already done } + if ($tmpobj->family == 'salary') { + $salarystatic->ref = $tmpobj->ref; + $salarystatic->id = $tmpobj->objid; + $salarystatic->label = $langs->trans("SalaryPayment"); + $ref = $salarystatic->getNomUrl(1, ''); + + $userstatic->id = $tmpobj->socid; + $userstatic->name = $tmpobj->name; + $refcomp = $userstatic->getNomUrl(1); + + $totalpayment = -1 * $salarystatic->getSommePaiement(); // Payment already done + } + if ($tmpobj->family == 'vat') { + $vatstatic->ref = $tmpobj->ref; + $vatstatic->id = $tmpobj->objid; + $vatstatic->type = $tmpobj->type; + $ref = $vatstatic->getNomUrl(1, ''); + + $totalpayment = -1 * $vatstatic->getSommePaiement(); // Payment already done + } $parameters = array('obj' => $tmpobj, 'ref' => $ref, 'refcomp' => $refcomp, 'totalpayment' => $totalpayment); $reshook = $hookmanager->executeHooks('moreFamily', $parameters, $tmpobject, $action); // Note that $action and $tmpobject may have been modified by hook From cc99ba0114cda42448fcc3a0780494e675882118 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Sep 2022 12:00:43 +0200 Subject: [PATCH 10/11] FIX extrafields with value '0' was '' --- htdocs/core/tpl/extrafields_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 3db65e198c5..baf13f77c67 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -101,7 +101,7 @@ if (empty($reshook) && isset($extrafields->attributes[$object->table_element]['l if ($action == 'edit_extras') { $value = (GETPOSTISSET("options_".$tmpkeyextra) ? GETPOST("options_".$tmpkeyextra) : $object->array_options["options_".$tmpkeyextra]); } else { - $value = (!empty($object->array_options["options_".$tmpkeyextra]) ? $object->array_options["options_".$tmpkeyextra] : ''); + $value = (isset($object->array_options["options_".$tmpkeyextra]) ? $object->array_options["options_".$tmpkeyextra] : ''); //var_dump($tmpkeyextra.' - '.$value); } From 89080112520233c3c3df0ef241c884c45d159348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Cendrier?= Date: Mon, 19 Sep 2022 16:54:12 +0200 Subject: [PATCH 11/11] this should be cleaned when we click on the eraser --- htdocs/expedition/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index dc9a5c04b6e..db5182d0a4d 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1408,7 +1408,7 @@ if ($action == 'create') { $deliverableQty = GETPOST($inputName, 'int'); } - print ''; + print ''; print ''; } else { if (!empty($conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS)) {
'.$langs->trans("TotalMargin").''; -print ''; // set by jquery (see below) +print ' '.$langs->getCurrencySymbol($conf->currency).''; // set by jquery (see below) print '