From 15cb20837ae175397b22553234aaed0b5f2e1a71 Mon Sep 17 00:00:00 2001 From: Saami PERDRIX - ATM Consulting Date: Wed, 6 Dec 2023 13:35:43 +0100 Subject: [PATCH 001/107] fix warning on email config --- dev/tools/rector/rector.php | 16 +++++----------- htdocs/admin/mails.php | 2 +- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/dev/tools/rector/rector.php b/dev/tools/rector/rector.php index 6b13c2fbf0b..0438318e8c9 100644 --- a/dev/tools/rector/rector.php +++ b/dev/tools/rector/rector.php @@ -7,7 +7,7 @@ use Rector\Core\ValueObject\PhpVersion; use Rector\Set\ValueObject\LevelSetList; return static function (RectorConfig $rectorConfig): void { - $rectorConfig->phpVersion(PhpVersion::PHP_71); + $rectorConfig->phpVersion(PhpVersion::PHP_82); //$rectorConfig->indent(' ', 4); // Traits seems not supported correctly by rector without declaring them as bootstrapFiles @@ -19,15 +19,9 @@ return static function (RectorConfig $rectorConfig): void { $rectorConfig->bootstrapFiles($arrayoftraitfiles); $rectorConfig->paths([ - __DIR__ . '/../../../htdocs/', - __DIR__ . '/../../../scripts/', - __DIR__ . '/../../../test/phpunit/', + __DIR__ . '/../../../htdocs/custom/multismtp', ]); $rectorConfig->skip([ - '**/includes/**', - '**/custom/**', - __DIR__ . '/../../../htdocs/custom/', - __DIR__ . '/../../../htdocs/install/doctemplates/*' ]); $rectorConfig->parallel(240); @@ -47,7 +41,7 @@ return static function (RectorConfig $rectorConfig): void { $rectorConfig->rule(Dolibarr\Rector\Renaming\EmptyGlobalToFunction::class); // Add all predefined rules to migrate to up to php 71 - // $rectorConfig->sets([ - // LevelSetList::UP_TO_PHP_71 - // ]); + /* $rectorConfig->sets([ + LevelSetList::UP_TO_PHP_71 + ]);*/ }; diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 828190b2cb4..13913616bf1 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -707,7 +707,7 @@ if ($action == 'edit') { // SMTPS PW if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') != "XOAUTH2") { - print ''.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW).''; + print ''.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./', '*', getDolGlobalString('MAIN_MAIL_SMTPS_PW')).''; } // SMTPS oauth service From 3bf1a8516c48e45c8c5b98b453ef61bceac960a7 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 6 Dec 2023 16:25:17 +0100 Subject: [PATCH 002/107] QUAL Fix php-cs-fixer configuration to not create 'public const' constants incompatible with 7.0 --- .php-cs-fixer.dist.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index dfe3fa53994..1bbd13d9022 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -41,6 +41,8 @@ return (new PhpCsFixer\Config()) // So we use target PHP70 for the moment. '@PHP70Migration' => true, //'@PHP71Migration' => true, + // Avoid adding public to const (incompatible with PHP 7.0): + 'visibility_required' => ['elements'=>['property', 'method']], //'strict_param' => true, //'array_syntax' => ['syntax' => 'short'], From 5fbd5c28b68bc0605db58df1e04a2a564ff33b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 7 Dec 2023 20:33:06 +0100 Subject: [PATCH 003/107] fix phpdoc --- htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index 11b0d8668af..f71ddb0ca60 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -43,8 +43,9 @@ class PrestaShopWebservice /** @var string PS version */ protected $version; - /** @var array compatible versions of PrestaShop Webservice */ + /** @var string compatible min version of PrestaShop Webservice */ const PSCOMPATIBLEVERSIONMIN = '1.4.0.0'; + /** @var string compatible max version of PrestaShop Webservice */ const PSCOMPATIBLEVERSIONMAX = '1.7.99.99'; From bd7e5abc5afb4756d0c016522184896c977e0545 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Dec 2023 11:16:57 +0100 Subject: [PATCH 004/107] Trans --- htdocs/langs/en_US/bills.lang | 2 +- htdocs/langs/en_US/hrm.lang | 2 +- htdocs/langs/en_US/products.lang | 2 +- htdocs/langs/en_US/receptions.lang | 2 +- htdocs/langs/en_US/sendings.lang | 2 +- htdocs/langs/en_US/stocks.lang | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index baba0dd75e2..d8ad2fbfece 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -185,7 +185,7 @@ SuppliersDraftInvoices=Vendor draft invoices Unpaid=Unpaid ErrorNoPaymentDefined=Error No payment defined ConfirmDeleteBill=Are you sure you want to delete this invoice? -ConfirmValidateBill=Are you sure you want to validate this invoice with reference %s? +ConfirmValidateBill=Are you sure you want to validate this invoice with the reference %s? ConfirmUnvalidateBill=Are you sure you want to change invoice %s to draft status? ConfirmClassifyPaidBill=Are you sure you want to change invoice %s to status paid? ConfirmCancelBill=Are you sure you want to cancel invoice %s? diff --git a/htdocs/langs/en_US/hrm.lang b/htdocs/langs/en_US/hrm.lang index 3dc2c041c06..4d99d0439ec 100644 --- a/htdocs/langs/en_US/hrm.lang +++ b/htdocs/langs/en_US/hrm.lang @@ -45,7 +45,7 @@ Eval=Evaluation Evals=Evaluations NewEval=New evaluation ValidateEvaluation=Validate evaluation -ConfirmValidateEvaluation=Are you sure you want to validate this evaluation with reference %s? +ConfirmValidateEvaluation=Are you sure you want to validate this evaluation with the reference %s? EvaluationCard=Evaluation card RequiredRank=Required rank for the job profile RequiredRankShort=Required rank diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 6d60b8f0fd1..dc7a05d3822 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -360,7 +360,7 @@ ProductAttributes=Variant attributes for products ProductAttributeName=Variant attribute %s ProductAttribute=Variant attribute ProductAttributeDeleteDialog=Are you sure you want to delete this attribute? All values will be deleted -ProductAttributeValueDeleteDialog=Are you sure you want to delete the value "%s" with reference "%s" of this attribute? +ProductAttributeValueDeleteDialog=Are you sure you want to delete the value "%s" with the reference "%s" of this attribute? ProductCombinationDeleteDialog=Are you sure want to delete the variant of the product "%s"? ProductCombinationAlreadyUsed=There was an error while deleting the variant. Please check it is not being used in any object ProductCombinations=Variants diff --git a/htdocs/langs/en_US/receptions.lang b/htdocs/langs/en_US/receptions.lang index cd5bc760585..bd135b22f13 100644 --- a/htdocs/langs/en_US/receptions.lang +++ b/htdocs/langs/en_US/receptions.lang @@ -34,7 +34,7 @@ StatusReceptionProcessedShort=Processed ReceptionSheet=Reception sheet ValidateReception=Validate reception ConfirmDeleteReception=Are you sure you want to delete this reception? -ConfirmValidateReception=Are you sure you want to validate this reception with reference %s? +ConfirmValidateReception=Are you sure you want to validate this reception with the reference %s? ConfirmCancelReception=Are you sure you want to cancel this reception? StatsOnReceptionsOnlyValidated=Statistics conducted on validated only receptions. Date used is date of validation of reception (planned delivery date is not always known). SendReceptionByEMail=Send reception by email diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index 73c2a942fc6..357a27462a3 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -39,7 +39,7 @@ StatusSendingValidatedShort=Validated StatusSendingProcessedShort=Processed SendingSheet=Shipment sheet ConfirmDeleteSending=Are you sure you want to delete this shipment? -ConfirmValidateSending=Are you sure you want to validate this shipment with reference %s? +ConfirmValidateSending=Are you sure you want to validate this shipment with the reference %s? ConfirmCancelSending=Are you sure you want to cancel this shipment? DocumentModelMerou=Merou A5 model WarningNoQtyLeftToSend=Warning, no products waiting to be shipped. diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index da42dcfd781..432c6f2c814 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -282,7 +282,7 @@ ModuleStockTransferName=Advanced Stock Transfer ModuleStockTransferDesc=Advanced management of Stock Transfer, with generation of transfer sheet StockTransferNew=New stock transfer StockTransferList=Stock transfers list -ConfirmValidateStockTransfer=Are you sure you want to validate this stocks transfer with reference %s ? +ConfirmValidateStockTransfer=Are you sure you want to validate this stocks transfer with the reference %s ? ConfirmDestock=Decrease of stocks with transfer %s ConfirmDestockCancel=Cancel decrease of stocks with transfer %s DestockAllProduct=Decrease of stocks From a3d405bdc8986c8357a2b0db5754d15cbbc04174 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Fri, 8 Dec 2023 12:41:36 +0100 Subject: [PATCH 005/107] FIx comm index page on contract --- htdocs/comm/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 27ac6154296..44a7565e9be 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -70,7 +70,7 @@ $now = dol_now(); //restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0); if (!$user->hasRight('propal', 'read') && !$user->hasRight('supplier_proposal', 'read') && !$user->hasRight('commande', 'read') && !$user->hasRight('fournisseur', 'commande', 'read') - && !$user->hasRight('supplier_order', 'read') && !$user->hasRight('fichinter', 'read')) { + && !$user->hasRight('supplier_order', 'read') && !$user->hasRight('fichinter', 'read') && !$user->hasRight('contrat', 'read')) { accessforbidden(); } From 8d7ab21ad673c2910b2b000f0eb9af043eeb5d2c Mon Sep 17 00:00:00 2001 From: Hystepik Date: Fri, 8 Dec 2023 14:23:34 +0100 Subject: [PATCH 006/107] Fix some php code smell --- htdocs/fourn/class/fournisseur.facture-rec.class.php | 2 +- htdocs/fourn/class/fournisseur.facture.class.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index 275fbb48d0a..cec0ab88d12 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -1106,7 +1106,6 @@ class FactureFournisseurRec extends CommonInvoice $txlocaltax1 = empty($txlocaltax1) ? 0 : price2num($txlocaltax1); $txlocaltax2 = empty($txlocaltax2) ? 0 : price2num($txlocaltax2); - $this->multicurrency_subprice = empty($this->multicurrency_subprice) ? 0 : $this->multicurrency_subprice; $this->multicurrency_total_ht = empty($this->multicurrency_total_ht) ? 0 : $this->multicurrency_total_ht; $this->multicurrency_total_tva = empty($this->multicurrency_total_tva) ? 0 : $this->multicurrency_total_tva; $this->multicurrency_total_ttc = empty($this->multicurrency_total_ttc) ? 0 : $this->multicurrency_total_ttc; @@ -1196,6 +1195,7 @@ class FactureFournisseurRec extends CommonInvoice return -1; } } + return 0; } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 26a73d35472..8b55b5d3455 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -168,6 +168,8 @@ class FactureFournisseur extends CommonInvoice */ public $datec; + public $datep; + /** * Date modification record (tms) * @@ -254,7 +256,7 @@ class FactureFournisseur extends CommonInvoice public $fk_facture_source; public $fac_rec; - + public $fk_fac_rec_source; public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), From dbf4a1e04136470232fe64324eff834433536e09 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Dec 2023 17:29:03 +0100 Subject: [PATCH 007/107] Debug ipn --- htdocs/public/stripe/ipn.php | 132 ++++++++++++++++++++--------------- 1 file changed, 76 insertions(+), 56 deletions(-) diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index c355c449a04..a3e73ebc36f 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -169,7 +169,7 @@ if (getDolGlobalString('MAIN_APPLICATION_TITLE')) { top_httphead(); -dol_syslog("***** Stripe IPN was called with event->type = ".$event->type); +dol_syslog("***** Stripe IPN was called with event->type=".$event->type." service=".$service); if ($event->type == 'payout.created') { @@ -321,7 +321,7 @@ if ($event->type == 'payout.created') { global $stripearrayofkeysbyenv; $error = 0; $object = $event->data->object; - $TRANSACTIONID = $object->id; + $TRANSACTIONID = $object->id; // Example pi_123456789... $ipaddress = $object->metadata->ipaddress; $now = dol_now(); $currencyCodeType = strtoupper($object->currency); @@ -338,7 +338,6 @@ if ($event->type == 'payout.created') { $sql = "SELECT pi.rowid, pi.fk_facture, pi.fk_prelevement_bons, pi.amount, pi.type, pi.traite"; $sql .= " FROM llx_prelevement_demande as pi"; $sql .= " WHERE pi.ext_payment_id = '".$db->escape($TRANSACTIONID)."'"; - //$sql .= " AND pi.type = 'ban' AND pi.traite = '1'"; $sql .= " AND pi.ext_payment_site = '".$db->escape($service)."'"; $result = $db->query($sql); @@ -374,9 +373,9 @@ if ($event->type == 'payout.created') { } } } else { - dol_syslog("Payment intent not found into database, so ignored."); - print "Payment intent not found into database, so ignored."; + dol_syslog("Payment intent ".$TRANSACTIONID." not found into database, so ignored."); http_response_code(200); + print "Payment intent ".$TRANSACTIONID." not found into database, so ignored."; return 1; } } else { @@ -524,7 +523,7 @@ if ($event->type == 'payout.created') { if ($db->num_rows($result)) { $obj = $db->fetch_object($result); $idbon = $obj->idbon; - dol_syslog('* Set prelevement to credite'); + dol_syslog('* Prelevement must be set to credited'); } else { dol_syslog('* Prelevement not found or already credited'); } @@ -577,7 +576,7 @@ if ($event->type == 'payout.created') { dol_syslog("The payment mode of this payment is ".$paymentTypeId." in Stripe and ".$paymentTypeIdInDolibarr." in Dolibarr. This case is not managed by the IPN"); } } else { - dol_syslog("Nothing to do in database"); + dol_syslog("Nothing to do in database because we don't know paymentTypeIdInDolibarr"); } } elseif ($event->type == 'payment_intent.payment_failed') { dol_syslog("A try to make a payment has failed"); @@ -588,64 +587,86 @@ if ($event->type == 'payout.created') { $paymentmethodstripeid = $object->payment_method; $customer_id = $object->customer; - $chargesdataarray = $object->charges->data; + $chargesdataarray = array(); + $objpayid = ''; + $objpaydesc = ''; + $objinvoiceid = 0; + $objerrcode = ''; + $objerrmessage = ''; + $objpaymentmodetype = ''; + if (property_exists($object, 'charges')) { // Old format + $chargesdataarray = $object->charges->data; + foreach ($chargesdataarray as $chargesdata) { + $objpayid = $chargesdata->id; + $objpaydesc = $chargesdata->description; + $objinvoiceid = 0; + if ($chargesdata->metadata->dol_type == 'facture') { + $objinvoiceid = $chargesdata->metadata->dol_id; + } + $objerrcode = $chargesdata->outcome->reason; + $objerrmessage = $chargesdata->outcome->seller_message; - foreach ($chargesdataarray as $chargesdata) { - $objpayid = $chargesdata->id; - $objpaydesc = $chargesdata->description; - $objinvoiceid = 0; - if ($chargesdata->metadata->dol_type == 'facture') { - $objinvoiceid = $chargesdata->metadata->dol_id; + $objpaymentmodetype = $chargesdata->payment_method_details->type; + break; } - $objerrcode = $chargesdata->outcome->reason; - $objerrmessage = $chargesdata->outcome->seller_message; + } + if (property_exists($object, 'last_payment_error')) { // New format 2023-10-16 + $objpayid = $object->latest_charge; + $objpaydesc = $object->description; + $objinvoiceid = 0; + if ($object->metadata->dol_type == 'facture') { + $objinvoiceid = $object->metadata->dol_id; + } + $objerrcode = $object->last_payment_error->code; + $objerrmessage = $object->last_payment_error->message; - $objpaymentmodetype = $chargesdata->payment_method_details->type; + $objpaymentmodetype = $object->last_payment_error->type; + } - // If this is a differed payment for SEPA, add a line into agenda events - if ($objpaymentmodetype == 'sepa_debit') { - $db->begin(); - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - $actioncomm = new ActionComm($db); + // If this is a differed payment for SEPA, add a line into agenda events + if ($objpaymentmodetype == 'sepa_debit') { + $db->begin(); - if ($objinvoiceid > 0) { - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $invoice = new Facture($db); - $invoice->fetch($objinvoiceid); + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + $actioncomm = new ActionComm($db); - $actioncomm->userownerid = 0; - $actioncomm->percentage = -1; + if ($objinvoiceid > 0) { + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $invoice = new Facture($db); + $invoice->fetch($objinvoiceid); - $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) - $actioncomm->code = 'AC_IPN'; + $actioncomm->userownerid = 0; + $actioncomm->percentage = -1; - $actioncomm->datep = $now; - $actioncomm->datef = $now; + $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) + $actioncomm->code = 'AC_IPN'; - $actioncomm->socid = $invoice->socid; - $actioncomm->fk_project = $invoice->fk_project; - $actioncomm->fk_element = $invoice->id; - $actioncomm->elementtype = 'invoice'; - $actioncomm->ip = getUserRemoteIP(); - } + $actioncomm->datep = $now; + $actioncomm->datef = $now; - $actioncomm->note_private = 'Error returned on payment id '.$objpayid.' after SEPA payment request '.$objpaydesc.'
Error code is: '.$objerrcode.'
Error message is: '.$objerrmessage; - $actioncomm->label = 'Payment error (SEPA Stripe)'; + $actioncomm->socid = $invoice->socid; + $actioncomm->fk_project = $invoice->fk_project; + $actioncomm->fk_element = $invoice->id; + $actioncomm->elementtype = 'invoice'; + $actioncomm->ip = getUserRemoteIP(); + } - $result = $actioncomm->create($user); - if ($result <= 0) { - dol_syslog($actioncomm->error, LOG_ERR); - $error++; - } + $actioncomm->note_private = 'Error returned on payment id '.$objpayid.' after SEPA payment request '.$objpaydesc.'
Error code is: '.$objerrcode.'
Error message is: '.$objerrmessage; + $actioncomm->label = 'Payment error (SEPA Stripe)'; - if (! $error) { - $db->commit(); - } else { - $db->rollback(); - http_response_code(500); - return -1; - } + $result = $actioncomm->create($user); + if ($result <= 0) { + dol_syslog($actioncomm->error, LOG_ERR); + $error++; + } + + if (! $error) { + $db->commit(); + } else { + $db->rollback(); + http_response_code(500); + return -1; } } } elseif ($event->type == 'checkout.session.completed') { // Called when making payment with new Checkout method ($conf->global->STRIPE_USE_NEW_CHECKOUT is on). @@ -732,12 +753,11 @@ if ($event->type == 'payout.created') { $db->query($sql); $db->commit(); } elseif ($event->type == 'charge.succeeded') { - // TODO: create fees - // TODO: Redirect to paymentok.php + // Deprecated. TODO: create fees and redirect to paymentok.php } elseif ($event->type == 'charge.failed') { - // TODO: Redirect to paymentko.php + // Deprecated. TODO: Redirect to paymentko.php } elseif (($event->type == 'source.chargeable') && ($event->data->object->type == 'three_d_secure') && ($event->data->object->three_d_secure->authenticated == true)) { - // This event is deprecated. + // Deprecated. } // End of page. Default return HTTP code will be 200 From c11a729a8723265b87a0274fbbca798383a8541e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Dec 2023 18:04:03 +0100 Subject: [PATCH 008/107] Debug v19 for for Stripe IPN API 2023-10-16 --- htdocs/public/stripe/ipn.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index a3e73ebc36f..c408f1c7f9f 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -617,12 +617,13 @@ if ($event->type == 'payout.created') { if ($object->metadata->dol_type == 'facture') { $objinvoiceid = $object->metadata->dol_id; } - $objerrcode = $object->last_payment_error->code; + $objerrcode = empty($object->last_payment_error->code) ? $object->last_payment_error->decline_code : $object->last_payment_error->code; $objerrmessage = $object->last_payment_error->message; - $objpaymentmodetype = $object->last_payment_error->type; + $objpaymentmodetype = $object->last_payment_error->payment_method->type; } + dol_syslog("objpaymentmodetype = ".$objpaymentmodetype); // If this is a differed payment for SEPA, add a line into agenda events if ($objpaymentmodetype == 'sepa_debit') { From 06c00f799cb70b0d78b335ee19cadd8df16429e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Dec 2023 18:10:14 +0100 Subject: [PATCH 009/107] Doc --- .../webhook_ipn_paymentintent_failed_sepa.txt | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 dev/examples/stripe/webhook_ipn_paymentintent_failed_sepa.txt diff --git a/dev/examples/stripe/webhook_ipn_paymentintent_failed_sepa.txt b/dev/examples/stripe/webhook_ipn_paymentintent_failed_sepa.txt new file mode 100644 index 00000000000..d85bedd9528 --- /dev/null +++ b/dev/examples/stripe/webhook_ipn_paymentintent_failed_sepa.txt @@ -0,0 +1,124 @@ +{ + "id": "evt_123456789", + "object": "event", + "api_version": "2023-10-16", + "created": 1702053463, + "data": { + "object": { + "id": "pi_123456789", + "object": "payment_intent", + "amount": 60, + "amount_capturable": 0, + "amount_details": { + "tip": { + } + }, + "amount_received": 0, + "application": null, + "application_fee_amount": null, + "automatic_payment_methods": null, + "canceled_at": null, + "cancellation_reason": null, + "capture_method": "automatic", + "client_secret": "pi_123456789_secret_123456789", + "confirmation_method": "automatic", + "created": 1702053448, + "currency": "eur", + "customer": "cus_123456789", + "description": "Stripe payment from makeStripeSepaRequest: DID=31262-INV=123-CUS=123 did=123 ref=FA2312-123", + "invoice": null, + "last_payment_error": { + "code": "", + "decline_code": "generic_decline", + "message": "The transaction can't be processed because your customer's account information is missing or incorrect. Collect a new mandate and ask your customer to provide their name and address exactly as it appears on their bank account. After this, you can attempt the transaction again.", + "payment_method": { + "id": "pm_123456789", + "object": "payment_method", + "billing_details": { + "address": { + "city": null, + "country": "FR", + "line1": null, + "line2": null, + "postal_code": null, + "state": null + }, + "email": "email@example.com", + "name": "Test example", + "phone": null + }, + "created": 1692688898, + "customer": "cus_123456789", + "livemode": false, + "metadata": { + "dol_version": "19.0.0-dev", + "dol_thirdparty_id": "123", + "ipaddress": "1.2.3.4", + "dol_id": "123", + "dol_type": "companypaymentmode", + "dol_entity": "1" + }, + "sepa_debit": { + "bank_code": "123", + "branch_code": "", + "country": "AT", + "fingerprint": "123456789", + "generated_from": { + "charge": null, + "setup_attempt": null + }, + "last4": "3202" + }, + "type": "sepa_debit" + }, + "type": "card_error" + }, + "latest_charge": "py_123456789", + "livemode": false, + "metadata": { + "dol_version": "19.0.0-beta", + "dol_thirdparty_id": "123", + "ipaddress": "1.2.3.4", + "dol_id": "123", + "dol_type": "facture", + "dol_entity": "1" + }, + "next_action": null, + "on_behalf_of": null, + "payment_method": null, + "payment_method_configuration_details": null, + "payment_method_options": { + "card": { + "installments": null, + "mandate_options": null, + "network": null, + "request_three_d_secure": "automatic" + }, + "sepa_debit": { + } + }, + "payment_method_types": [ + "card", + "sepa_debit" + ], + "processing": null, + "receipt_email": null, + "review": null, + "setup_future_usage": null, + "shipping": null, + "source": null, + "statement_descriptor": "DID=123-", + "statement_descriptor_suffix": "DID=123-", + "status": "requires_payment_method", + "transfer_data": null, + "transfer_group": null + } + }, + "livemode": false, + "pending_webhooks": 1, + "request": { + "id": null, + "idempotency_key": null + }, + "type": "payment_intent.payment_failed" +} From 33663f4ccfa7c9ee8d5a90bb0e905e52af6234c0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Dec 2023 18:32:38 +0100 Subject: [PATCH 010/107] Debug v19 --- htdocs/public/stripe/ipn.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index c408f1c7f9f..097ae2cef51 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -594,7 +594,7 @@ if ($event->type == 'payout.created') { $objerrcode = ''; $objerrmessage = ''; $objpaymentmodetype = ''; - if (property_exists($object, 'charges')) { // Old format + if (!empty($object->charges)) { // Old format $chargesdataarray = $object->charges->data; foreach ($chargesdataarray as $chargesdata) { $objpayid = $chargesdata->id; @@ -610,7 +610,8 @@ if ($event->type == 'payout.created') { break; } } - if (property_exists($object, 'last_payment_error')) { // New format 2023-10-16 + if (!empty($object->last_payment_error)) { // New format 2023-10-16 + // $object is probably an object of type Stripe\PaymentIntent $objpayid = $object->latest_charge; $objpaydesc = $object->description; $objinvoiceid = 0; @@ -623,7 +624,7 @@ if ($event->type == 'payout.created') { $objpaymentmodetype = $object->last_payment_error->payment_method->type; } - dol_syslog("objpaymentmodetype = ".$objpaymentmodetype); + dol_syslog("objpayid=".$objpayid." objpaymentmodetype = ".$objpaymentmodetype." objerrcode=".$objerrcode); // If this is a differed payment for SEPA, add a line into agenda events if ($objpaymentmodetype == 'sepa_debit') { From f5e2ccbe08721894b68dba9669af89d4ccda5523 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Dec 2023 18:32:38 +0100 Subject: [PATCH 011/107] Debug v19 --- htdocs/public/stripe/ipn.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index c408f1c7f9f..bee8b99ab0d 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -594,7 +594,7 @@ if ($event->type == 'payout.created') { $objerrcode = ''; $objerrmessage = ''; $objpaymentmodetype = ''; - if (property_exists($object, 'charges')) { // Old format + if (!empty($object->charges)) { // Old format $chargesdataarray = $object->charges->data; foreach ($chargesdataarray as $chargesdata) { $objpayid = $chargesdata->id; @@ -610,7 +610,8 @@ if ($event->type == 'payout.created') { break; } } - if (property_exists($object, 'last_payment_error')) { // New format 2023-10-16 + if (!empty($object->last_payment_error)) { // New format 2023-10-16 + // $object is probably an object of type Stripe\PaymentIntent $objpayid = $object->latest_charge; $objpaydesc = $object->description; $objinvoiceid = 0; @@ -623,7 +624,7 @@ if ($event->type == 'payout.created') { $objpaymentmodetype = $object->last_payment_error->payment_method->type; } - dol_syslog("objpaymentmodetype = ".$objpaymentmodetype); + dol_syslog("objpayid=".$objpayid." objpaymentmodetype=".$objpaymentmodetype." objerrcode=".$objerrcode); // If this is a differed payment for SEPA, add a line into agenda events if ($objpaymentmodetype == 'sepa_debit') { From 230371a6c9e524b4e05d0254141bdb0db3e0e23d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Dec 2023 19:08:42 +0100 Subject: [PATCH 012/107] Debug v19 --- htdocs/compta/paymentbybanktransfer/index.php | 30 ++++++++----------- .../class/bonprelevement.class.php | 2 -- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/htdocs/compta/paymentbybanktransfer/index.php b/htdocs/compta/paymentbybanktransfer/index.php index 9a83639b3dd..9ab0d0e0aeb 100644 --- a/htdocs/compta/paymentbybanktransfer/index.php +++ b/htdocs/compta/paymentbybanktransfer/index.php @@ -92,21 +92,23 @@ $totaltoshow = 0; if (isModEnabled('supplier_invoice')) { print ''.$langs->trans("NbOfInvoiceToPayByBankTransfer").''; print ''; - print ''; + $amounttoshow = $bprev->SommeAPrelever('bank-transfer'); + print ''; print $bprev->nbOfInvoiceToPay('bank-transfer'); print ''; print ''; - $totaltoshow += $bprev->SommeAPrelever('bank-transfer'); + $totaltoshow += $amounttoshow; } if (isModEnabled('salaries')) { print ''.$langs->trans("NbOfInvoiceToPayByBankTransferForSalaries").''; print ''; - print ''; + $amounttoshow = $bprev->SommeAPrelever('bank-transfer', 'salary'); + print ''; print $bprev->nbOfInvoiceToPay('bank-transfer', 'salary'); print ''; print ''; - $totaltoshow += $bprev->SommeAPrelever('bank-transfer', 'salary'); + $totaltoshow += $amounttoshow; } print ''.$langs->trans("Total").''; @@ -116,18 +118,15 @@ print '
'; /* - * Invoices waiting for withdraw + * Invoices waiting for credit transfer */ if (isModEnabled('supplier_invoice')) { $sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type, f.datef, f.date_lim_reglement,"; $sql .= " pfd.date_demande, pfd.amount,"; $sql .= " s.nom as name, s.email, s.rowid as socid, s.tva_intra, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,"; - $sql .= " ".MAIN_DB_PREFIX."societe as s"; - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } - $sql .= ", ".MAIN_DB_PREFIX."prelevement_demande as pfd"; + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; + $sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pfd"; $sql .= " WHERE s.rowid = f.fk_soc"; $sql .= " AND f.entity IN (".getEntity('supplier_invoice').")"; $sql .= " AND f.total_ttc > 0"; @@ -137,17 +136,10 @@ if (isModEnabled('supplier_invoice')) { $sql .= " AND pfd.traite = 0"; $sql .= " AND pfd.ext_payment_id IS NULL"; $sql .= " AND pfd.fk_facture_fourn = f.rowid"; - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } if ($socid) { $sql .= " AND f.fk_soc = ".((int) $socid); } - $sqlForSalary = "SELECT * FROM ".MAIN_DB_PREFIX."salary as s, ".MAIN_DB_PREFIX."prelevement_demande as pd"; - $sqlForSalary .= " WHERE s.rowid = pd.fk_salary AND s.paye = 0 AND pd.traite = 0"; - $sqlForSalary .= " AND s.entity IN (".getEntity('salary').")"; - $resql = $db->query($sql); if ($resql) { @@ -219,6 +211,10 @@ if (isModEnabled('supplier_invoice')) { } if (isModEnabled('salaries')) { + $sqlForSalary = "SELECT * FROM ".MAIN_DB_PREFIX."salary as s, ".MAIN_DB_PREFIX."prelevement_demande as pd"; + $sqlForSalary .= " WHERE s.rowid = pd.fk_salary AND s.paye = 0 AND pd.traite = 0"; + $sqlForSalary .= " AND s.entity IN (".getEntity('salary').")"; + $resql2 = $db->query($sqlForSalary); if ($resql2) { $numRow = $db->num_rows($resql2); diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 765431e15b6..adc65afba2a 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -749,8 +749,6 @@ class BonPrelevement extends CommonObject public function SommeAPrelever($mode = 'direct-debit', $type = '') { // phpcs:enable - global $conf; - $sql = "SELECT sum(pd.amount) as nb"; if ($type !== 'salary') { if ($mode != 'bank-transfer') { From 01a207a592871a98b912ded4113fe0be94b6e79d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Dec 2023 20:57:01 +0100 Subject: [PATCH 013/107] Debug v19 --- .../prelevement/class/bonprelevement.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index adc65afba2a..59f8fd95e6f 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1163,7 +1163,7 @@ class BonPrelevement extends CommonObject if (!$error) { $ref = substr($year, -2).$month; - // Get next free nuber for the ref of bon + // Get next free nunber for the ref of bon prelevement $sql = "SELECT substring(ref from char_length(ref) - 1)"; // To extract "YYMMXX" from "TYYMMXX" $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons"; $sql .= " WHERE ref LIKE '_".$this->db->escape($ref)."%'"; @@ -1228,6 +1228,8 @@ class BonPrelevement extends CommonObject } if (!$error) { + dol_syslog(__METHOD__." Now loop on each document to insert them in llx_prelevement_demande"); + // Add lines for the bon if (count($factures_prev) > 0) { foreach ($factures_prev as $fac) { // Add a link in database for each invoice ro salary @@ -1805,15 +1807,14 @@ class BonPrelevement extends CommonObject $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; $sql .= " ".MAIN_DB_PREFIX."salary as s,"; $sql .= " ".MAIN_DB_PREFIX."prelevement as p,"; - $sql .= " ".MAIN_DB_PREFIX."c_country as c,"; - $sql .= " ".MAIN_DB_PREFIX."user as u,"; + $sql .= " ".MAIN_DB_PREFIX."user as u"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON u.fk_country = c.rowid,"; $sql .= " ".MAIN_DB_PREFIX."user_rib as rib"; $sql .= " WHERE pl.fk_prelevement_bons=".((int) $this->id); $sql .= " AND pl.rowid = p.fk_prelevement_lignes"; $sql .= " AND p.fk_salary = s.rowid"; $sql .= " AND s.fk_user = u.rowid"; $sql .= " AND rib.fk_user = s.fk_user"; - $sql .= " AND rib.fk_country = c.rowid"; } else { $sql = "SELECT soc.rowid as socid, soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,"; $sql .= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,"; @@ -1823,14 +1824,13 @@ class BonPrelevement extends CommonObject $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; $sql .= " ".MAIN_DB_PREFIX."facture_fourn as f,"; $sql .= " ".MAIN_DB_PREFIX."prelevement as p,"; - $sql .= " ".MAIN_DB_PREFIX."societe as soc,"; - $sql .= " ".MAIN_DB_PREFIX."c_country as c,"; + $sql .= " ".MAIN_DB_PREFIX."societe as soc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON soc.fk_pays = c.rowid,"; $sql .= " ".MAIN_DB_PREFIX."societe_rib as rib"; $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $this->id); $sql .= " AND pl.rowid = p.fk_prelevement_lignes"; $sql .= " AND p.fk_facture_fourn = f.rowid"; $sql .= " AND f.fk_soc = soc.rowid"; - $sql .= " AND soc.fk_pays = c.rowid"; $sql .= " AND rib.fk_soc = f.fk_soc"; $sql .= " AND rib.default_rib = 1"; $sql .= " AND rib.type = 'ban'"; From d248840779ed69375a21038ced38f0646314d049 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Dec 2023 21:09:32 +0100 Subject: [PATCH 014/107] Debug v19 --- htdocs/compta/prelevement/class/bonprelevement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 59f8fd95e6f..ed02436dc97 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1799,7 +1799,7 @@ class BonPrelevement extends CommonObject * Section Creditor (sepa Crediteurs bloc lines) */ if (!empty($user_dest)) { - $sql = "SELECT u.rowid as userId, c.code as country_code, CONCAT(u.firstname,' ',u.lastname) as nom,"; + $sql = "SELECT u.rowid as userId, u.address, u.zip, u.town, c.code as country_code, CONCAT(u.firstname,' ',u.lastname) as nom,"; $sql .= " pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,"; $sql .= " s.ref as reffac, p.fk_salary as idfac,"; $sql .= " rib.rowid, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, '' as rum, '' as date_rum"; From 9d479c5df045f0764ecbdfa363b998653782d031 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Dec 2023 21:39:10 +0100 Subject: [PATCH 015/107] Debug v19 --- .../prelevement/class/bonprelevement.class.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index ed02436dc97..955d95c4aae 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -186,8 +186,6 @@ class BonPrelevement extends CommonObject */ public function __construct($db) { - global $conf, $langs; - $this->db = $db; $this->filename = ''; @@ -1852,8 +1850,12 @@ class BonPrelevement extends CommonObject $cachearraytotestduplicate[$obj->idfac] = $obj->rowid; $daterum = (!empty($obj->date_rum)) ? $this->db->jdate($obj->date_rum) : $this->db->jdate($obj->datec); + $refobj = $obj->reffac; + if (empty($refobj) && !empty($user_dest)) { // If ref of salary not defined, we force a value + $refobj = "SAL".$obj->idfac; + } - $fileCrediteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->reffac, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum, $type, $obj->fac_ref_supplier); + $fileCrediteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $refobj, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum, $type, $obj->fac_ref_supplier); $this->total = $this->total + $obj->somme; $i++; @@ -2069,6 +2071,7 @@ class BonPrelevement extends CommonObject fputs($this->file, "\n"); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write recipient (thirdparty concerned by request) @@ -2300,6 +2303,7 @@ class BonPrelevement extends CommonObject fputs($this->file, "\n"); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write sender of request (me). @@ -2621,8 +2625,6 @@ class BonPrelevement extends CommonObject public function load_board($user, $mode) { // phpcs:enable - global $conf, $langs; - if ($user->socid) { return -1; // protection pour eviter appel par utilisateur externe } From 453d5e5c260b284a499ed59679a78506de2c0d73 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Dec 2023 23:45:18 +0100 Subject: [PATCH 016/107] Fix #yogosha19443 --- htdocs/core/ajax/pingresult.php | 9 +++++---- htdocs/core/js/lib_notification.js.php | 2 +- htdocs/core/lib/security.lib.php | 13 +++++-------- htdocs/install/step2.php | 2 +- htdocs/main.inc.php | 10 +++++----- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/htdocs/core/ajax/pingresult.php b/htdocs/core/ajax/pingresult.php index 854188f7d6e..96700b261da 100644 --- a/htdocs/core/ajax/pingresult.php +++ b/htdocs/core/ajax/pingresult.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2019-2023 Laurent Destailleur * * 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 @@ -16,9 +16,10 @@ */ /** - * \file htdocs/core/ajax/pingresult.php - * \brief Page called after a ping was done in js to the official dolibarr ping service. - * This ajax URL is called with parameter 'firstpingok' or 'firstpingko' depending on the result of the ping. + * \file htdocs/core/ajax/pingresult.php + * \brief Page called after a ping was done in js to the official dolibarr ping service. + * This ajax URL is called with parameter 'firstpingok' or 'firstpingko' depending on the result of the ping. + * You can use &forceping=1 in parameters to force the ping if the ping was already sent. */ if (!defined('NOTOKENRENEWAL')) { diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php index d3403298691..2f8192a29fe 100644 --- a/htdocs/core/js/lib_notification.js.php +++ b/htdocs/core/js/lib_notification.js.php @@ -81,7 +81,7 @@ if ("Notification" in window) { if (Notification.permission !== "granted") { console.log("Ask Notification.permission"); Notification.requestPermission(function(result) { - console.log("result for requestPermission is "+result); + console.log("result for Notification.requestPermission is "+result); }); } diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 1fb7dbdbdbf..004bb6ea5d6 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -227,14 +227,13 @@ function dolDecrypt($chain, $key = '') * If constant MAIN_SECURITY_SALT is defined, we use it as a salt (used only if hashing algorightm is something else than 'password_hash'). * * @param string $chain String to hash - * @param string $type Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO else md5, '1':sha1, '2':sha1+md5, '3':md5, '4': for OpenLdap, '5':sha256, '6':password_hash). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. + * @param string $type Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO else md5, '1':sha1, '2':sha1+md5, '3':md5, '4': for OpenLdap, '5':sha256, '6':password_hash). + * Use 'md5' if hash is not needed for security purpose. For security need, prefer 'auto'. * @return string Hash of string * @see getRandomPassword(), dol_verifyHash() */ function dol_hash($chain, $type = '0') { - global $conf; - // No need to add salt for password_hash if (($type == '0' || $type == 'auto') && getDolGlobalString('MAIN_SECURITY_HASH_ALGO') && getDolGlobalString('MAIN_SECURITY_HASH_ALGO') == 'password_hash' && function_exists('password_hash')) { return password_hash($chain, PASSWORD_DEFAULT); @@ -249,7 +248,7 @@ function dol_hash($chain, $type = '0') return sha1($chain); } elseif ($type == '2' || $type == 'sha1md5') { return sha1(md5($chain)); - } elseif ($type == '3' || $type == 'md5') { + } elseif ($type == '3' || $type == 'md5') { // For hashing with no need of security return md5($chain); } elseif ($type == '4' || $type == 'openldap') { return dolGetLdapPasswordHash($chain, getDolGlobalString('LDAP_PASSWORD_HASH_TYPE', 'md5')); @@ -281,8 +280,6 @@ function dol_hash($chain, $type = '0') */ function dol_verifyHash($chain, $hash, $type = '0') { - global $conf; - if ($type == '0' && getDolGlobalString('MAIN_SECURITY_HASH_ALGO') && getDolGlobalString('MAIN_SECURITY_HASH_ALGO') == 'password_hash' && function_exists('password_verify')) { if (! empty($hash[0]) && $hash[0] == '$') { return password_verify($chain, $hash); @@ -365,7 +362,7 @@ function dolGetLdapPasswordHash($password, $type = 'md5') */ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid', $isdraft = 0, $mode = 0) { - global $db, $conf; + global $conf; global $hookmanager; // Define $objectid @@ -389,7 +386,7 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', $parentfortableentity = ''; - // Fix syntax of $features param + // Fix syntax of $features param to support non standard module names. $originalfeatures = $features; if ($features == 'agenda') { $tableandshare = 'actioncomm&societe'; diff --git a/htdocs/install/step2.php b/htdocs/install/step2.php index 5f78115113b..a90d6058e52 100644 --- a/htdocs/install/step2.php +++ b/htdocs/install/step2.php @@ -584,7 +584,7 @@ dolibarr_install_syslog("- step2: end"); $conf->file->instance_unique_id = (empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ? '' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id); // Unique id of instance -$hash_unique_id = md5('dolibarr'.$conf->file->instance_unique_id); +$hash_unique_id = dol_hash('dolibarr'.$conf->file->instance_unique_id, 'sha256'); // Note: if the global salt changes, this hash changes too so ping may be counted twice. We don't mind. It is for statistics purpose only. $out = ' '; $out .= ''; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 9a98c9fc776..35bb8176c22 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -3665,7 +3665,7 @@ if (!function_exists("llxFooter")) { $forceping = GETPOST('forceping', 'alpha'); if (($_SERVER["PHP_SELF"] == DOL_URL_ROOT.'/index.php') || $forceping) { //print ''; - $hash_unique_id = md5('dolibarr'.$conf->file->instance_unique_id); // Do not use dol_hash(), must not change if salt changes. + $hash_unique_id = dol_hash('dolibarr'.$conf->file->instance_unique_id, 'sha256'); // Note: if the global salt changes, this hash changes too so ping may be counted twice. We don't mind. It is for statistics purpose only. if (!getDolGlobalString('MAIN_FIRST_PING_OK_DATE') || (!empty($conf->file->instance_unique_id) && ($hash_unique_id != $conf->global->MAIN_FIRST_PING_OK_ID) && ($conf->global->MAIN_FIRST_PING_OK_ID != 'disabled')) @@ -3695,14 +3695,14 @@ if (!function_exists("llxFooter")) { ?> '; print ''; } + + // conciliate print ''; print ' '; print ''; + // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; } + print ''; } } @@ -1411,6 +1452,7 @@ if ($resql) { // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; if (in_array($obj->rowid, $arrayofselected)) { @@ -1814,9 +1856,14 @@ if ($resql) { print ''; } } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; if (in_array($objp->rowid, $arrayofselected)) { diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 955d95c4aae..32be42c7438 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -476,7 +476,7 @@ class BonPrelevement extends CommonObject $sql .= " SET fk_user_credit = ".$user->id; $sql .= ", statut = ".self::STATUS_CREDITED; $sql .= ", date_credit = '".$this->db->idate($date)."'"; - $sql .= " WHERE rowid=".((int) $this->id); + $sql .= " WHERE rowid = ".((int) $this->id); $sql .= " AND entity = ".((int) $conf->entity); $sql .= " AND statut = ".self::STATUS_TRANSFERED; @@ -497,6 +497,10 @@ class BonPrelevement extends CommonObject $amountsperthirdparty = array(); $facs = $this->getListInvoices(1); + if ($this->error) { + $error++; + } + //var_dump($facs);exit; // Loop on each invoice. $facs=array(0=>id, 1=>amount requested) $num = count($facs); @@ -594,9 +598,7 @@ class BonPrelevement extends CommonObject $error++; } - /* - * End of procedure - */ + // End of procedure if ($error == 0) { $this->date_credit = $date; $this->statut = self::STATUS_CREDITED; @@ -674,7 +676,7 @@ class BonPrelevement extends CommonObject * Get invoice list * * @param int $amounts If you want to get the amount of the order for each invoice - * @return array Id of invoices + * @return array Array(Id of invoices, Amount to pay) */ private function getListInvoices($amounts = 0) { @@ -682,6 +684,8 @@ class BonPrelevement extends CommonObject $arr = array(); + dol_syslog(get_class($this)."::getListInvoices"); + /* * Returns all invoices presented within same order */ @@ -694,18 +698,18 @@ class BonPrelevement extends CommonObject if ($amounts) { $sql .= ", SUM(pl.amount)"; } - $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; - $sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; - $sql .= " , ".MAIN_DB_PREFIX."prelevement as p"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as pb,"; + $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; + $sql .= " ".MAIN_DB_PREFIX."prelevement as p"; $sql .= " WHERE p.fk_prelevement_lignes = pl.rowid"; - $sql .= " AND pl.fk_prelevement_bons = p.rowid"; - $sql .= " AND p.rowid = ".((int) $this->id); - $sql .= " AND p.entity = ".((int) $conf->entity); + $sql .= " AND pl.fk_prelevement_bons = pb.rowid"; + $sql .= " AND pb.rowid = ".((int) $this->id); + $sql .= " AND pb.entity = ".((int) $conf->entity); if ($amounts) { if ($this->type == 'bank-transfer') { - $sql .= " GROUP BY fk_facture_fourn"; + $sql .= " GROUP BY p.fk_facture_fourn"; } else { - $sql .= " GROUP BY fk_facture"; + $sql .= " GROUP BY p.fk_facture"; } } @@ -730,7 +734,7 @@ class BonPrelevement extends CommonObject } $this->db->free($resql); } else { - dol_syslog(get_class($this)."::getListInvoices Erreur"); + $this->error = $this->db->lasterror(); } return $arr; diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index a1fd08bc7fc..19e3e3ab5ed 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -308,7 +308,6 @@ if ($resql) { print_liste_field_titre(($salaryBonPl ? "AmountSalary" : "AmountInvoice"), $_SERVER["PHP_SELF"], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("AmountRequested", $_SERVER["PHP_SELF"], "pl.amount", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", $param, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre(''); print "\n"; $totalinvoices = 0; @@ -376,8 +375,6 @@ if ($resql) { } print ""; - print ""; - print "\n"; $totalinvoices += $obj->total_ttc; @@ -403,7 +400,6 @@ if ($resql) { print price($totalamount_requested); print "\n"; print ' '; - print ' '; print "\n"; } diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php index 31b31fbb39b..cb6b18e10e5 100644 --- a/htdocs/compta/prelevement/line.php +++ b/htdocs/compta/prelevement/line.php @@ -108,10 +108,12 @@ if ($action == 'confirm_rejet' && $permissiontoadd) { if ($lipre->fetch($id) == 0) { $rej = new RejetPrelevement($db, $user, $type); - $rej->create($user, $id, GETPOST('motif', 'alpha'), $daterej, $lipre->bon_rowid, GETPOST('facturer', 'int')); + $result = $rej->create($user, $id, GETPOST('motif', 'alpha'), $daterej, $lipre->bon_rowid, GETPOST('facturer', 'int')); - header("Location: line.php?id=".urlencode($id).'&type='.urlencode($type)); - exit; + if ($result > 0) { + header("Location: line.php?id=".urlencode($id).'&type='.urlencode($type)); + exit; + } } } else { $action = "rejet"; @@ -202,30 +204,35 @@ if ($id) { dol_print_error($db); } + // Form to record a reject if ($action == 'rejet' && $user->hasRight('prelevement', 'bons', 'credit')) { $soc = new Societe($db); $soc->fetch($lipre->socid); $rej = new RejetPrelevement($db, $user, $type); - print '
'; + print ''; print ''; print ''; print ''; + + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; - print ''; + print ''; + print ''; + print ''; //Select yes/no print ''; - print ''; //Date print ''; - print ''; @@ -236,11 +243,15 @@ if ($id) { print ''; //Facturer - print ''; - print ''; + print ''; - print '
'.$langs->trans("WithdrawalRefused").'
'.$langs->trans("WithdrawalRefused").'
'.$langs->trans("WithdrawalRefusedConfirm").' '.$soc->name.' ?'; + print ''; print $form->selectyesno("confirm", 1, 0); print '
'.$langs->trans("RefusedData").''; + print ''; print $form->selectDate('', '', '', '', '', "confirm_rejet"); print '
'.$langs->trans("RefusedInvoicing").''; - print $form->selectarray("facturer", $rej->labelsofinvoicing, GETPOSTISSET('facturer') ? GETPOST('facturer', 'int') : ''); + print '
'; + print $form->textwithpicto($langs->trans("RefusedInvoicing"), $langs->trans("DirectDebitRefusedInvoicingDesc")); + print ''; + print $form->selectarray("facturer", $rej->labelsofinvoicing, GETPOSTISSET('facturer') ? GETPOST('facturer', 'int') : '', 0); print '

'; + + print ''; + print '
'; //Confirm Button print '
'; @@ -333,8 +344,12 @@ if ($id) { $i = 0; $urladd = "&id=".urlencode($id); + $title = $langs->trans("Bills"); + if ($type == 'bank-transfer') { + $title = $langs->trans("SupplierInvoices"); + } - print_barre_liste($langs->trans("Bills"), $page, "factures.php", $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); + print_barre_liste($title, $page, "factures.php", $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); print"\n\n"; print ''; diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index d8ad2fbfece..63c86001b28 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -250,12 +250,13 @@ RemainderToTake=Remaining amount to take RemainderToTakeMulticurrency=Remaining amount to take, original currency RemainderToPayBack=Remaining amount to refund RemainderToPayBackMulticurrency=Remaining amount to refund, original currency +NegativeIfExcessReceived=negative if excess received NegativeIfExcessRefunded=negative if excess refunded +NegativeIfExcessPaid=negative if excess paid Rest=Pending AmountExpected=Amount claimed ExcessReceived=Excess received ExcessReceivedMulticurrency=Excess received, original currency -NegativeIfExcessReceived=negative if excess received ExcessPaid=Excess paid ExcessPaidMulticurrency=Excess paid, original currency EscompteOffered=Discount offered (payment before term) From 100a65763340646d981ded0eb759310afd497519 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Dec 2023 20:28:28 +0100 Subject: [PATCH 024/107] Debug v19 - Support of bank payment rejection on SEPA. --- htdocs/compta/bank/bankentries_list.php | 2 +- .../class/rejetprelevement.class.php | 45 +++++++++++-------- htdocs/compta/prelevement/factures.php | 5 ++- htdocs/compta/prelevement/line.php | 2 +- htdocs/core/lib/prelevement.lib.php | 16 +++++-- htdocs/langs/en_US/withdrawals.lang | 5 ++- 6 files changed, 48 insertions(+), 27 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index ddcafa405dc..1d56ac2016d 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -1919,7 +1919,7 @@ if ($resql) { $colspan++; } } - print ''; + print ''; } print "
'.$langs->trans("NoRecordFound").'
'.$langs->trans("NoRecordFound").'
"; diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index 0dbe720d1d1..85b911a4cea 100644 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -97,27 +97,28 @@ class RejetPrelevement } /** - * Create + * Create a reject * * @param User $user User object * @param int $id Id * @param string $motif Motif - * @param int $date_rejet Date rejet + * @param int $date_rejet Date reject * @param int $bonid Bon id - * @param int $facturation Facturation - * @return void + * @param int $facturation 1=Bill the reject + * @return int Return >=0 if OK, <0 if KO */ public function create($user, $id, $motif, $date_rejet, $bonid, $facturation = 0) { - global $langs, $conf; + global $langs; $error = 0; $this->id = $id; $this->bon_id = $bonid; $now = dol_now(); - dol_syslog("RejetPrelevement::Create id $id"); - $bankaccount = ($this->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT); + dol_syslog("RejetPrelevement::Create id ".$id); + + $bankaccount = ($this->type == 'bank-transfer' ? getDolGlobalString('PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT') : getDolGlobalString('PRELEVEMENT_ID_BANKACCOUNT')); $facs = $this->getListInvoices(1); require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php'; @@ -172,30 +173,34 @@ class RejetPrelevement $fac->fetch($facs[$i][0]); - // Make a negative payment - //$pai = new Paiement($this->db); + $amountrejected = $facs[$i][1]; + // Make a negative payment + // Amount must be an array (id of invoice -> amount) $pai->amounts = array(); - /* - * We replace the comma with a point otherwise some - * PHP installs sends only the part integer negative - */ + //var_dump($this->type);exit; + + $pai->amounts[$facs[$i][0]] = price2num($amountrejected * -1); // The payment must be negative because it is a refund - $pai->amounts[$facs[$i][0]] = price2num($facs[$i][1] * ($this->type == 'bank-transfer' ? 1 : -1)); $pai->datepaye = $date_rejet; $pai->paiementid = 3; // type of payment: withdrawal - $pai->num_paiement = $fac->ref; - $pai->num_payment = $fac->ref; + $pai->num_paiement = $langs->trans('Rejection').' '.$fac->ref; + $pai->num_payment = $langs->trans('Rejection').' '.$fac->ref; $pai->id_prelevement = $this->bon_id; $pai->num_prelevement = $lipre->bon_ref; if ($pai->create($this->user) < 0) { - // we call with no_commit $error++; dol_syslog("RejetPrelevement::Create Error creation payment invoice ".$facs[$i][0]); } else { - $result = $pai->addPaymentToBank($user, 'payment', '(InvoiceRefused)', $bankaccount, '', ''); + // We record entry into bank + $mode = 'payment'; + if ($this->type == 'bank-transfer') { + $mode = 'payment_supplier'; + } + + $result = $pai->addPaymentToBank($user, $mode, '(InvoiceRefused)', $bankaccount, '', ''); if ($result < 0) { dol_syslog("RejetPrelevement::Create AddPaymentToBan Error"); $error++; @@ -220,9 +225,13 @@ class RejetPrelevement if ($error == 0) { dol_syslog("RejetPrelevement::Create Commit"); $this->db->commit(); + + return 1; } else { dol_syslog("RejetPrelevement::Create Rollback"); $this->db->rollback(); + + return -1; } } diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 19e3e3ab5ed..52fb559e8a9 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -96,6 +96,7 @@ llxHeader('', $langs->trans("WithdrawalsReceipts")); if ($id > 0 || $ref) { if ($object->fetch($id, $ref) >= 0) { $head = prelevement_prepare_head($object); + print dol_get_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); $linkback = ''.$langs->trans("BackToList").''; @@ -293,8 +294,9 @@ if ($resql) { print ''; $massactionbutton = ''; + $title = ($salaryBonPl ? $langs->trans("Salaries") : ($object->type == 'bank-transfer' ? $langs->trans("SupplierInvoices") : $langs->trans("Invoices"))); - print_barre_liste(($salaryBonPl ? $langs->trans("Salaries") : $langs->trans("Invoices")), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit); print"\n\n"; print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table @@ -339,7 +341,6 @@ if ($resql) { print ''; - print ''; print($salaryBonPl ? $salarytmp->getNomUrl(1) : $invoicetmp->getNomUrl(1)); print "\n"; diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php index cb6b18e10e5..2d21dd6a3a1 100644 --- a/htdocs/compta/prelevement/line.php +++ b/htdocs/compta/prelevement/line.php @@ -85,7 +85,7 @@ $error = 0; if ($action == 'confirm_rejet' && $permissiontoadd) { if (GETPOST("confirm") == 'yes') { if (GETPOST('remonth', 'int')) { - $daterej = mktime(2, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + $daterej = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); } if (empty($daterej)) { diff --git a/htdocs/core/lib/prelevement.lib.php b/htdocs/core/lib/prelevement.lib.php index a3f0de2c0f3..ce1b9c4e584 100644 --- a/htdocs/core/lib/prelevement.lib.php +++ b/htdocs/core/lib/prelevement.lib.php @@ -33,9 +33,11 @@ */ function prelevement_prepare_head(BonPrelevement $object) { - global $langs, $conf, $user; + global $langs, $conf; + $salary = $object->checkIfSalaryBonPrelevement(); - $langs->load("withdrawals"); + + $langs->loadLangs(array("bills", "withdrawals")); $h = 0; $head = array(); @@ -50,8 +52,16 @@ function prelevement_prepare_head(BonPrelevement $object) $head[$h][2] = 'prelevement'; $h++; + $titleoftab = $langs->trans("Bills"); + if ($object->type == 'bank-transfer') { + $titleoftab = $langs->trans("SupplierBills"); + } + if ($salary > 0) { + $titleoftab = $langs->trans("Salaries"); + } + $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/factures.php?id='.$object->id; - $head[$h][1] = ($salary <= 0 ? $langs->trans("Bills") : $langs->trans("Salaries")); + $head[$h][1] = $titleoftab; $head[$h][2] = 'invoices'; $h++; diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index fb4ff9a9e8b..d385b587459 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -66,8 +66,9 @@ WithdrawalRefusedConfirm=Are you sure you want to enter a withdrawal rejection f RefusedData=Date of rejection RefusedReason=Reason for rejection RefusedInvoicing=Billing the rejection -NoInvoiceRefused=Do not charge the rejection -InvoiceRefused=Invoice refused (Charge the rejection to customer) +NoInvoiceRefused=Do not charge the customer for the refusal +InvoiceRefused=Charge the customer for the refusal +DirectDebitRefusedInvoicingDesc=Set a flag to say this refusal must be charged to the customer StatusDebitCredit=Status debit/credit StatusWaiting=Waiting StatusTrans=Sent From d63aeeed9f6bcb9c13deb31a5c1a7e58ed503510 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Dec 2023 20:41:56 +0100 Subject: [PATCH 025/107] Debug v19 --- htdocs/compta/prelevement/rejets.php | 33 ++++++++++++++++++---------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/htdocs/compta/prelevement/rejets.php b/htdocs/compta/prelevement/rejets.php index baed8076f6b..30db9e40c50 100644 --- a/htdocs/compta/prelevement/rejets.php +++ b/htdocs/compta/prelevement/rejets.php @@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies')); @@ -83,14 +85,16 @@ if ($sortfield == "") { $rej = new RejetPrelevement($db, $user, $type); $line = new LignePrelevement($db); +$thirdpartystatic = new Societe($db); +$userstatic = new User($db); $hookmanager->initHooks(array('withdrawalsreceiptsrejectedlist')); // List of invoices -$sql = "SELECT pl.rowid, pr.motif, p.ref, pl.statut, p.rowid as bonId"; -$sql .= " , s.rowid as socid, s.nom as name, p.datec"; +$sql = "SELECT pl.rowid, pr.motif, p.ref, pl.statut, p.rowid as bonId,"; +$sql .= " s.rowid as socid, s.nom as name, p.datec"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr"; $sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; @@ -98,19 +102,20 @@ $sql .= " , ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE pr.fk_prelevement_lignes = pl.rowid"; $sql .= " AND pl.fk_prelevement_bons = p.rowid"; $sql .= " AND pl.fk_soc = s.rowid"; -$sql .= " AND p.entity = ".$conf->entity; +$sql .= " AND p.entity = ".((int) $conf->entity); if ($type == 'bank-transfer') { $sql .= " AND p.type = 'bank-transfer'"; } else { $sql .= " AND p.type = 'debit-order'"; } -if ($socid) { +if ($socid > 0) { $sql .= " AND s.rowid = ".((int) $socid); } +// Add list for salaries if ($type == 'bank-transfer') { $sql .= " UNION"; - $sql .= " SELECT pl.rowid, pr.motif, p.ref, pl.statut, p.rowid as bonId"; - $sql .= " ,u.rowid as socid, CONCAT(u.firstname,' ', u.lastname) as name, p.datec"; + $sql .= " SELECT pl.rowid, pr.motif, p.ref, pl.statut, p.rowid as bonId,"; + $sql .= " u.rowid as socid, CONCAT(u.firstname,' ', u.lastname) as name, p.datec"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr"; $sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; @@ -118,7 +123,7 @@ if ($type == 'bank-transfer') { $sql .= " WHERE pr.fk_prelevement_lignes = pl.rowid"; $sql .= " AND pl.fk_prelevement_bons = p.rowid"; $sql .= " AND pl.fk_user = u.rowid"; - $sql .= " AND p.entity = ".$conf->entity; + $sql .= " AND p.entity = ".((int) $conf->entity); $sql .= " AND p.type = 'bank-transfer'"; if ($socid) { $sql .= " AND s.rowid = ".((int) $socid); @@ -129,10 +134,10 @@ if ($type == 'bank-transfer') { } $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($limit + 1, $offset); + $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - $i = 0; $param = ''; @@ -147,7 +152,9 @@ if ($result) { $bon = new BonPrelevement($db); if ($num) { - while ($i < min($num, $limit)) { + $i = 0; + $maxlim = min($num, $limit); + while ($i < $maxlim) { $obj = $db->fetch_object($result); $bon->fetch($obj->bonId); @@ -157,10 +164,14 @@ if ($result) { print $line->LibStatut($obj->statut, 2).' '; print ''; print substr('000000'.$obj->rowid, -6).""; + if ($bon->checkIfSalaryBonPrelevement()) { - print ''.$obj->nom."\n"; + print ''.$obj->name."\n"; } else { - print ''.$obj->nom."\n"; + $thirdpartystatic->id = $obj->socid; + $thirdpartystatic->name = $obj->name; + + print ''.$thirdpartystatic->getNomUrl(1)."\n"; } print ''.$rej->motifs[$obj->motif].''; From 8227c155a00f4c0bc39c3a158ecda6f57af62eaf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Dec 2023 21:03:00 +0100 Subject: [PATCH 026/107] Fix MAIN_SHOW_TECHNICAL_ID --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 41e140e9231..a4331d183ed 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -243,7 +243,7 @@ $checkedprofid6 = 0; $checkprospectlevel = (in_array($contextpage, array('prospectlist')) ? 1 : 0); $checkstcomm = (in_array($contextpage, array('prospectlist')) ? 1 : 0); $arrayfields = array( - 's.rowid'=>array('label'=>"TechnicalID", 'position'=>1, 'checked'=>(getDolGlobalString('MAIN_SHOW_TECHNICAL_ID')), 'enabled'=>(getDolGlobalString('MAIN_SHOW_TECHNICAL_ID'))), + 's.rowid'=>array('label'=>"TechnicalID", 'position'=>1, 'checked'=>-1, 'enabled'=>1), 's.nom'=>array('label'=>"ThirdPartyName", 'position'=>2, 'checked'=>1), 's.name_alias'=>array('label'=>"AliasNameShort", 'position'=>3, 'checked'=>1), 's.barcode'=>array('label'=>"Gencod", 'position'=>5, 'checked'=>1, 'enabled'=>(isModEnabled('barcode'))), From 1c569578665a2e1cd751414216ee9e9c186aa3ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Dec 2023 21:15:32 +0100 Subject: [PATCH 027/107] Fix error on first launch of a cron job --- htdocs/cron/class/cronjob.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 7676e26d53a..5729d136869 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -738,6 +738,9 @@ class Cronjob extends CommonObject if (empty($this->email_alert)) { $this->email_alert = ''; } + if (empty($this->datenextrun)) { + $this->datenextrun = dol_now(); + } // Check parameters // Put here code to add a control on parameters values From f125899db27251dad3b9907010802959907ebc52 Mon Sep 17 00:00:00 2001 From: Jon Bendtsen Date: Sun, 10 Dec 2023 00:10:18 +0100 Subject: [PATCH 028/107] continuation of request made by eldy in https://github.com/Dolibarr/dolibarr/pull/25946 --- htdocs/admin/stock.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index bf686d3c93b..a784792ae02 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -776,7 +776,7 @@ if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_SUPPORTS_SERVICES'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_SUPPORTS_SERVICES", $arrval, $conf->global->STOCK_SUPPORTS_SERVICES); + print $form->selectarray("STOCK_SUPPORTS_SERVICES", $arrval, getDolGlobalString('STOCK_SUPPORTS_SERVICES')); } print "\n"; print "\n"; From 1add19cecc26a43fc849a1d1772bfece8053a119 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Dec 2023 13:51:14 +0100 Subject: [PATCH 029/107] Debug v19 --- htdocs/core/class/html.formactions.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 52e4e3fba31..7989f5a2502 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -296,7 +296,9 @@ class FormActions print ''; // Label - print ''.$actioncomm->getNomUrl(0).''; + print ''; + print $actioncomm->getNomUrl(0); + print ''; // Date print ''.dol_print_date($actioncomm->datep, 'dayhour', 'tzuserrel'); From 8bd8f4842587218070801ebd1ecd70339ab66ac3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Dec 2023 14:29:30 +0100 Subject: [PATCH 030/107] Doc --- SECURITY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 953059e625f..3bcf2e94508 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -92,8 +92,8 @@ Scope is the web application (backoffice) and the APIs. * Missing security-related HTTP headers which do not lead directly to a vulnerability * Reports from automated web vulnerability scanners (Acunetix, Vega, etc.) that have not been validated * Invalid or missing SPF (Sender Policy Framework) records (Incomplete or missing SPF/DKIM/DMARC) -* Reports on features flagged as "experimental" or "development" +* Reports on features flagged as "deprecated", "experimental" or "development" * Software version or private IP disclosure when logged-in user is admin * Stack traces or path disclosure when logged-in user is admin * Any vulnerabilities due to a configuration different than the one defined in chapter "Scope for qualified vulnerabilities". -* Brute force attacks on login page, password forgotten page or any public pages (/public/*) are not qualified if the fail2ban recommended fail2ban rules were not installed. +* Brute force attacks on login page, password forgotten page or any public pages (/public/*) are not qualified if the recommended fail2ban rules were not installed. From 2e3c9dc87ed3dfd97cb7650664f0381b8999564b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Dec 2023 14:34:43 +0100 Subject: [PATCH 031/107] Update doc --- SECURITY.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 3bcf2e94508..f004cea7c86 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -82,18 +82,17 @@ Scope is the web application (backoffice) and the APIs. ## Examples of vulnerabilities that are Non-qualified for reporting. * "Self" XSS -* SSL/TLS best practices -* Denial of Service attacks * Clickjacking/UI redressing -* Physical or social engineering attempts or issues that require physical access to a victim’s computer/device * Presence of autocomplete attribute on web forms -* Vulnerabilities affecting outdated browsers or platforms, or vulnerabilities inside browsers themself. * Logout and other instances of low-severity Cross-Site Request Forgery -* Missing security-related HTTP headers which do not lead directly to a vulnerability * Reports from automated web vulnerability scanners (Acunetix, Vega, etc.) that have not been validated -* Invalid or missing SPF (Sender Policy Framework) records (Incomplete or missing SPF/DKIM/DMARC) -* Reports on features flagged as "deprecated", "experimental" or "development" -* Software version or private IP disclosure when logged-in user is admin +* Reports on features on modules flagged as "deprecated", "experimental" or "development" if the module needs to be enabled for that (this is not the case on production). +* Software or libraries versions or private IP disclosure when logged-in user is admin * Stack traces or path disclosure when logged-in user is admin * Any vulnerabilities due to a configuration different than the one defined in chapter "Scope for qualified vulnerabilities". +* Vulnerabilities affecting outdated browsers or platforms, or vulnerabilities inside browsers themself. * Brute force attacks on login page, password forgotten page or any public pages (/public/*) are not qualified if the recommended fail2ban rules were not installed. +* SSL/TLS best practices +* Denial of Service attacks +* Invalid or missing SPF (Sender Policy Framework) records (Incomplete or missing SPF/DKIM/DMARC) +* Physical or social engineering attempts or issues that require physical access to a victim’s computer/device From 29dc12dd5882c8476b12b9091bb4396dd1cf83cf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Dec 2023 16:19:05 +0100 Subject: [PATCH 032/107] Option MAIN_DISALLOW_URL_INTO_DESCRIPTIONS accept 1 or 2 value. Value 1 should be ready to be on by default in a next version. Fix #yogosha18900 --- htdocs/admin/system/security.php | 4 +++- htdocs/core/class/doleditor.class.php | 2 +- htdocs/core/lib/functions.lib.php | 25 +++++++++++++++++--- test/phpunit/SecurityTest.php | 33 ++++++++++++++++++++++----- 4 files changed, 53 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 00d9a461048..e45d581c35f 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -713,7 +713,9 @@ print 'MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = '.(getDol print '   ('.$langs->trans("Recommended").": 1 - does not work on HTML5 with some old libxml libs)
"; print '
'; -print 'MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = '.getDolGlobalString('MAIN_DISALLOW_URL_INTO_DESCRIPTIONS', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': 1)')."
"; +// MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1, disallow url links except if on /medias +// MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 2, disallow all external urls link +print 'MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = '.getDolGlobalString('MAIN_DISALLOW_URL_INTO_DESCRIPTIONS', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': 1=only local links allowed or 2=no links at all)')."
"; print '
'; print 'MAIN_ALLOW_SVG_FILES_AS_EXTERNAL_LINKS = '.getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_EXTERNAL_LINKS', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)')."
"; diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 1125eb0cfcb..4a9d216bca2 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -171,7 +171,7 @@ class DolEditor if (!getDolGlobalString('FCKEDITOR_ENABLE_PDF')) { $pluginstodisable .= ',exportpdf'; } - if (getDolGlobalString('MAIN_DISALLOW_URL_INTO_DESCRIPTIONS')) { + if (getDolGlobalInt('MAIN_DISALLOW_URL_INTO_DESCRIPTIONS') == 2) { $this->uselocalbrowser = 0; // Can't use browser to navigate into files. Only links with " 0) { $out = 'ErrorHTMLLinksNotAllowed'; } + } elseif (getDolGlobalInt('MAIN_DISALLOW_URL_INTO_DESCRIPTIONS') == 1) { + $nblinks = 0; + // Loop on each url in src= and url( + $pattern = '/src=["\']?(http[^"\']+)|url\(["\']?(http[^\)]+)/'; + + $matches = array(); + if (preg_match_all($pattern, $out, $matches)) { + // URLs are into $matches[1] + $urls = $matches[1]; + + // Affiche les URLs + foreach ($urls as $url) { + $nblinks++; + echo "Found url = ".$url . "\n"; + } + if ($nblinks > 0) { + $out = 'ErrorHTMLExternalLinksNotAllowed'; + } + } } return $out; diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 45ca6fd0c0a..4615efe8c22 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -382,6 +382,7 @@ class SecurityTest extends PHPUnit\Framework\TestCase $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0; $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 0; $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0; + $conf->global->MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 0; $_COOKIE["id"]=111; $_POST["param0"]='A real string with aaa and " and \' and & inside content'; @@ -721,25 +722,45 @@ class SecurityTest extends PHPUnit\Framework\TestCase $conf->global->MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT = 3; - $_POST["pagecontentwithlinks"]=''; + $_POST["pagecontentwithlinks"]=''; $result=GETPOST("pagecontentwithlinks", 'restricthtml'); print __METHOD__." result=".$result."\n"; $this->assertEquals('ErrorTooManyLinksIntoHTMLString', $result, 'Test on limit on GETPOST fails'); // Test that img src="data:..." is excluded from the count of external links $conf->global->MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT = 3; - $_POST["pagecontentwithlinks"]=''; + $_POST["pagecontentwithlinks"]=''; $result=GETPOST("pagecontentwithlinks", 'restricthtml'); print __METHOD__." result=".$result."\n"; - $this->assertEquals('', $result, 'Test on limit on GETPOST fails'); + $this->assertEquals('', $result, 'Test on limit on GETPOST fails'); + + $conf->global->MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 2; // Test that no links is allowed - $conf->global->MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1; - $_POST["pagecontentwithlinks"]=''; + $_POST["pagecontentwithlinks"]=''; $result=GETPOST("pagecontentwithlinks", 'restricthtml'); print __METHOD__." result=".$result."\n"; - $this->assertEquals('ErrorHTMLLinksNotAllowed', $result, 'Test on limit on GETPOST fails'); + $this->assertEquals('ErrorHTMLLinksNotAllowed', $result, 'Test on limit on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 2 (no links allowed)'); + $conf->global->MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1; + + // Test that links on wrapper or local url are allowed + $_POST["pagecontentwithnowrapperlinks"]=''; + $result=GETPOST("pagecontentwithnowrapperlinks", 'restricthtml'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('', $result, 'Test on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1 (links on data or relative links ar allowed)'); + + // Test that links not on wrapper and not data are disallowed + $_POST["pagecontentwithnowrapperlinks"]=''; + $result=GETPOST("pagecontentwithnowrapperlinks", 'restricthtml'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('ErrorHTMLExternalLinksNotAllowed', $result, 'Test on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1 (no links to http allowed)'); + + // Test that links not on wrapper and not data are disallowed + $_POST["pagecontentwithnowrapperlinks"]=''; + $result=GETPOST("pagecontentwithnowrapperlinks", 'restricthtml'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('ErrorHTMLExternalLinksNotAllowed', $result, 'Test on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1 (no links to http allowed)'); return $result; } From 22f6e431557c5789f5cee668bb6c47c3a96a03ca Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Sun, 10 Dec 2023 19:22:28 +0100 Subject: [PATCH 033/107] Fix warehouse list --- htdocs/product/stock/class/entrepot.class.php | 4 ++-- htdocs/product/stock/list.php | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index c11ab685d69..837cdcdc981 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -132,8 +132,8 @@ class Entrepot extends CommonObject 'address' =>array('type'=>'varchar(255)', 'label'=>'Address', 'enabled'=>1, 'visible'=>-2, 'position'=>45, 'searchall'=>1), 'zip' =>array('type'=>'varchar(10)', 'label'=>'Zip', 'enabled'=>1, 'visible'=>-2, 'position'=>50, 'searchall'=>1), 'town' =>array('type'=>'varchar(50)', 'label'=>'Town', 'enabled'=>1, 'visible'=>-2, 'position'=>55, 'searchall'=>1), - 'fk_departement' =>array('type'=>'sellist:c_departements:label:rowid::active=1', 'label'=>'State', 'enabled'=>1, 'visible'=>0, 'position'=>60), - 'fk_pays' =>array('type'=>'sellist:c_country:label:rowid::active=1', 'label'=>'Country', 'enabled'=>1, 'visible'=>-2, 'position'=>65), + 'fk_departement' =>array('type'=>'integer', 'label'=>'State', 'enabled'=>1, 'visible'=>0, 'position'=>60), + 'fk_pays' =>array('type'=>'integer:Ccountry:core/class/ccountry.class.php', 'label'=>'Country', 'enabled'=>1, 'visible'=>-1, 'position'=>65), 'phone' =>array('type'=>'varchar(20)', 'label'=>'Phone', 'enabled'=>1, 'visible'=>-2, 'position'=>70, 'searchall'=>1), 'fax' =>array('type'=>'varchar(20)', 'label'=>'Fax', 'enabled'=>1, 'visible'=>-2, 'position'=>75, 'searchall'=>1), //'fk_user_author' =>array('type'=>'integer', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-2, 'position'=>82), diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index f9f1bac7ac9..a5fea4930f3 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -561,10 +561,10 @@ foreach ($object->fields as $key => $val) { print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1); } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { print '
'; - print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print $form->selectDate(isset($search[$key.'_dtstart']) ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); print '
'; print '
'; - print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print $form->selectDate(isset($search[$key.'_dtend']) ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); print '
'; } elseif ($key == 'lang') { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; @@ -647,16 +647,19 @@ foreach ($object->fields as $key => $val) { if (!empty($arrayfields["stockqty"]['checked'])) { print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stockqty", '', $param, '', $sortfield, $sortorder, 'right '); $totalarray['nbfield']++; + $totalarray['type'][$totalarray['nbfield']] = 'stock'; } if (!empty($arrayfields["estimatedvalue"]['checked'])) { print_liste_field_titre("EstimatedStockValue", $_SERVER["PHP_SELF"], "estimatedvalue", '', $param, '', $sortfield, $sortorder, 'right '); $totalarray['nbfield']++; + $totalarray['type'][$totalarray['nbfield']] = 'price'; } if (!empty($arrayfields["estimatedstockvaluesell"]['checked'])) { print_liste_field_titre("EstimatedStockValueSell", $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); $totalarray['nbfield']++; + $totalarray['type'][$totalarray['nbfield']] = 'price'; } // Extra fields From 6c8116fa7e1a69dc8385726461285be0407cb53a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Dec 2023 01:37:45 +0100 Subject: [PATCH 034/107] Show limit in nb of lines to explain error 500 in export of excel --- .../modules/export/export_excel2007.modules.php | 14 +++++++++++++- htdocs/core/modules/export/modules_export.php | 7 +++++++ htdocs/exports/export.php | 2 +- htdocs/langs/en_US/exports.lang | 1 + 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/export/export_excel2007.modules.php b/htdocs/core/modules/export/export_excel2007.modules.php index cdb6e9c208d..1c5aa0a29c2 100644 --- a/htdocs/core/modules/export/export_excel2007.modules.php +++ b/htdocs/core/modules/export/export_excel2007.modules.php @@ -77,7 +77,7 @@ class ExportExcel2007 extends ModeleExports */ public function __construct($db) { - global $conf, $langs; + global $langs; $this->db = $db; $this->id = 'excel2007'; // Same value then xxx in file name export_xxx.modules.php @@ -119,6 +119,18 @@ class ExportExcel2007 extends ModeleExports return $this->label; } + /** + * getDriverLabel + * + * @return string Return driver label + */ + public function getDriverLabelBis() + { + global $langs; + $langs->load("errors"); + return $langs->trans("NumberOfLinesLimited"); + } + /** * getDriverDesc * diff --git a/htdocs/core/modules/export/modules_export.php b/htdocs/core/modules/export/modules_export.php index c55fa7d2a61..82b8a36cb8c 100644 --- a/htdocs/core/modules/export/modules_export.php +++ b/htdocs/core/modules/export/modules_export.php @@ -84,6 +84,8 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac */ public function listOfAvailableExportFormat($db, $maxfilenamelength = 0) { + global $langs; + dol_syslog(get_class($this)."::listOfAvailableExportFormat"); $dir = DOL_DOCUMENT_ROOT."/core/modules/export/"; @@ -113,6 +115,11 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac $this->picto[$module->id] = $module->picto; // Driver properties $this->driverlabel[$module->id] = $module->getDriverLabel().(empty($module->disabled) ? '' : ' __(Disabled)__'); // '__(Disabled)__' is a key + if (method_exists($module, 'getDriverLabelBis')) { + if ($module->getDriverLabelBis()) { + $this->driverlabel[$module->id] .= ' ('.$module->getDriverLabelBis().')'; + } + } $this->driverdesc[$module->id] = $module->getDriverDesc(); $this->driverversion[$module->id] = $module->getDriverVersion(); // If use an external lib diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 262289dd226..48039b936e6 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -1074,7 +1074,7 @@ if ($step == 4 && $datatoexport) { } if ($step == 5 && $datatoexport) { - if (count($array_selected) < 1) { // This occurs when going back to page after sessecion expired + if (count($array_selected) < 1) { // This occurs when going back to page after session expired // Switch to step 2 header("Location: ".DOL_URL_ROOT.'/exports/export.php?step=2&datatoexport='.$datatoexport); exit; diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index af4c6f31b24..94ca852beca 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -145,3 +145,4 @@ SelectImportFieldsSource = Choose the source file fields you want to import and MandatoryTargetFieldsNotMapped=Some mandatory target fields are not mapped AllTargetMandatoryFieldsAreMapped=All target fields that need a mandatory value are mapped ResultOfSimulationNoError=Result of simulation: No error +NumberOfLinesLimited=Number of lines limited \ No newline at end of file From 2e445b2a6dd48bde95e789a203153a6c416bb038 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Dec 2023 09:13:10 +0100 Subject: [PATCH 035/107] Debug v19 --- htdocs/admin/syslog.php | 63 ++++++++++++------- .../core/modules/syslog/mod_syslog_file.php | 2 +- htdocs/langs/en_US/admin.lang | 4 +- 3 files changed, 44 insertions(+), 25 deletions(-) diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index dd37a06b4da..88d590ffc35 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -186,16 +186,20 @@ if (isModEnabled('multicompany') && $user->entity) { // Output mode + +print ''; + print load_fiche_titre($langs->trans("SyslogOutput"), '', ''); -// Mode -print ''; print ''; print ''; + +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; -print ''; -print ''; +print ''; +print ''; +print ''; print "\n"; foreach ($syslogModules as $moduleName) { @@ -209,9 +213,9 @@ foreach ($syslogModules as $moduleName) { print ''; - print ''; - print '
'.$langs->trans("Type").''.$langs->trans("Value").''.$langs->trans("Type").''.$langs->trans("Value").'
'; - print ' '; - print $module->getName(); + print ''; + print ' '; + print ''; if ($moduleName == 'mod_syslog_syslog') { if (!$module->isActive()) { $langs->load("errors"); @@ -235,22 +239,23 @@ foreach ($syslogModules as $moduleName) { $value = (isset($option['default']) ? $option['default'] : ''); } - print $option['name'].': '; + print ''.$option['name'].': '; if (!empty($option['example'])) { - print '
'.$langs->trans("Example").': '.$option['example']; + print '
'.$langs->trans("Example").': '.dol_escape_htmltag($option['example']); } if ($option['constant'] == 'SYSLOG_FILE' && preg_match('/^DOL_DATA_ROOT\/[^\/]*$/', $value)) { - $filelogparam = ' ('; + $filelogparam = '     '; $filelogparam .= $langs->trans('Download'); - $filelogparam .= ' '.basename($value).')'; + $filelogparam .= img_picto($langs->trans('Download').' '.basename($value), 'download', 'class="paddingleft"'); + $filelogparam .= ''; print $filelogparam; } } } print '
'; + print ''; if ($module->getInfo()) { print $form->textwithpicto('', $module->getInfo(), 1, 'help'); } @@ -262,42 +267,54 @@ foreach ($syslogModules as $moduleName) { } print "
\n"; +print "
\n"; + print "\n"; + print '
'."\n\n"; -print load_fiche_titre($langs->trans("SyslogLevel"), '', ''); // Level -print '
'; + +print ''; + +print load_fiche_titre($langs->trans("SyslogLevel"), '', ''); + print ''; print ''; + +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print ''; -print ''; +print ''; print "\n"; -print ''; -print ''; +print ''; if (!empty($conf->loghandlers['mod_syslog_file']) && isModEnabled('cron')) { - print ''; - print ''; + print ''; + print ''; } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("SyslogLevel").'
'.$langs->trans("SyslogLevel").''; + +print ajax_combobox("level"); print '
'.$langs->trans("SyslogFileNumberOfSaves").''; - print ' ('.$langs->trans('ConfigureCleaningCronjobToSetFrequencyOfSaves').')
'.$langs->trans("SyslogFileNumberOfSaves").''; + print '   ('.$langs->trans('ConfigureCleaningCronjobToSetFrequencyOfSaves').')
'; +print "
\n"; + print "
\n"; // End of page diff --git a/htdocs/core/modules/syslog/mod_syslog_file.php b/htdocs/core/modules/syslog/mod_syslog_file.php index 4acb3ec6a7e..c9385f44a6c 100644 --- a/htdocs/core/modules/syslog/mod_syslog_file.php +++ b/htdocs/core/modules/syslog/mod_syslog_file.php @@ -69,7 +69,7 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface 'name' => $langs->trans('SyslogFilename'), 'constant' => 'SYSLOG_FILE', 'default' => 'DOL_DATA_ROOT/dolibarr.log', - 'attr' => 'size="60"' + 'css' => 'minwidth300 maxwidth500' ) ); } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index ec0d628d8cf..ea93e78ba04 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2433,4 +2433,6 @@ ConfirmDeleteExtrafield=Do you confirm deletion of the field %s ? All data saved ExtraFieldsSupplierInvoicesRec=Complementary attributes (templates invoices) ExtraFieldsSupplierInvoicesLinesRec=Complementary attributes (invoice lines) ParametersForTestEnvironment=Parameters for test environment -TryToKeepOnly=Try to keep only %s \ No newline at end of file +TryToKeepOnly=Try to keep only %s +RecommendedForProduction=Recommended for Production +RecommendedForDebug=Recommended for Debug \ No newline at end of file From ee2543b516f7e37c1523bf97ab8e6f46fc09b6e2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Dec 2023 09:13:51 +0100 Subject: [PATCH 036/107] Clean code --- htdocs/contrat/class/contrat.class.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 08bb4caa932..8cbf96992c9 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -3413,7 +3413,7 @@ class ContratLigne extends CommonObjectLine */ public function update($user, $notrigger = 0) { - global $conf, $langs, $mysoc; + global $mysoc; $error = 0; @@ -3615,10 +3615,10 @@ class ContratLigne extends CommonObjectLine // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Mise a jour en base des champs total_xxx de ligne - * Used by migration process + * Update in database the fields total_xxx of lines + * Used by migration process * - * @return int Return integer <0 if KO, >0 if OK + * @return int Return integer <0 if KO, >0 if OK */ public function update_total() { @@ -3656,7 +3656,7 @@ class ContratLigne extends CommonObjectLine */ public function insert($notrigger = 0) { - global $conf, $user; + global $user; $error = 0; @@ -3753,8 +3753,6 @@ class ContratLigne extends CommonObjectLine public function active_line($user, $date, $date_end = '', $comment = '') { // phpcs:enable - global $langs, $conf; - $error = 0; $this->db->begin(); @@ -3813,9 +3811,6 @@ class ContratLigne extends CommonObjectLine public function close_line($user, $date_end_real, $comment = '', $notrigger = 0) { // phpcs:enable - global $langs, $conf; - - // Update object $this->date_cloture = $date_end_real; $this->date_end_real = $date_end_real; $this->user_closing_id = $user->id; From 9608f59485062764610ee1597868337f1e8481df Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Dec 2023 10:00:24 +0100 Subject: [PATCH 037/107] Debug v19 --- htdocs/admin/company.php | 29 ++++++++++++++++++--------- htdocs/core/class/html.form.class.php | 2 +- htdocs/theme/eldy/global.inc.php | 4 ++-- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 11590149cbb..e7ef3b764cb 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -41,6 +41,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $action = GETPOST('action', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'admincompany'; // To manage different context of search +$page_y = GETPOSTINT('page_y'); // Load translation files required by the page $langs->loadLangs(array('admin', 'companies', 'bills')); @@ -137,7 +138,8 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) dol_mkdir($dirforimage); } $result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']); - if ($result > 0) { + + if (is_numeric($result) && $result > 0) { $constant = "MAIN_INFO_SOCIETE_LOGO"; if ($varforimage == 'logo_squarred') { $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED"; @@ -267,7 +269,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) } if ($action != 'updateedit' && !$error) { - header("Location: ".$_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"].($page_y ? '?page_y='.$page_y : '')); exit; } } @@ -426,6 +428,7 @@ if (!empty($conf->use_javascript_ajax)) { print '
'; print ''; print ''; +print ''; print ''; print ''."\n"; @@ -518,6 +521,9 @@ if ($maxmin > 0) { print ''; print ''; if (!empty($mysoc->logo_small)) { + print ''; if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { print '
'; print ''; @@ -531,9 +537,6 @@ if (!empty($mysoc->logo_small)) { print ''; print '
'; } - print ''; } elseif (!empty($mysoc->logo)) { if (file_exists($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { print '
'; @@ -542,7 +545,7 @@ if (!empty($mysoc->logo_small)) { print ''; } else { print '
'; - print ''; + print ''; print '
'; } } @@ -560,6 +563,9 @@ if ($maxmin > 0) { print ''; print '
'; if (!empty($mysoc->logo_squarred_small)) { + print ''; if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_small)) { print '
'; print ''; @@ -573,7 +579,6 @@ if (!empty($mysoc->logo_squarred_small)) { print ''; print '
'; } - print ''; } elseif (!empty($mysoc->logo_squarred)) { if (file_exists($conf->mycompany->dir_output.'/logos/'.$mysoc->logo_squarred)) { print '
'; @@ -582,7 +587,7 @@ if (!empty($mysoc->logo_squarred_small)) { print ''; } else { print '
'; - print ''; + print ''; print '
'; } } @@ -596,8 +601,9 @@ print ''; print '
'.$langs->trans("CompanyInfo").'
'; +print $form->buttonsSaveCancel("Save", '', array(), false, 'reposition'); -print '
'; +print '

'; // IDs of the company (country-specific) @@ -765,6 +771,9 @@ print '
'; diff --git a/htdocs/install/check.php b/htdocs/install/check.php index a5f571fec0b..a84a6dd7b3e 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -131,7 +131,7 @@ if (!function_exists("session_id")) { if (!extension_loaded("mbstring")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "MBString")."
\n"; - // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) +// $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { print 'Ok '.$langs->trans("PHPSupport", "MBString")."
\n"; } @@ -140,7 +140,7 @@ if (!extension_loaded("mbstring")) { if (!extension_loaded("json")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "JSON")."
\n"; - // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) +// $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { print 'Ok '.$langs->trans("PHPSupport", "JSON")."
\n"; } @@ -149,7 +149,7 @@ if (!extension_loaded("json")) { if (!function_exists("imagecreate")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "GD")."
\n"; - // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) +// $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { print 'Ok '.$langs->trans("PHPSupport", "GD")."
\n"; } @@ -158,7 +158,7 @@ if (!function_exists("imagecreate")) { if (!function_exists("curl_init")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "Curl")."
\n"; - // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) +// $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { print 'Ok '.$langs->trans("PHPSupport", "Curl")."
\n"; } @@ -174,7 +174,7 @@ if (!function_exists("easter_date")) { if (!function_exists("simplexml_load_string")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "Xml")."
\n"; - // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) +// $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { print 'Ok '.$langs->trans("PHPSupport", "Xml")."
\n"; } @@ -183,7 +183,7 @@ if (!function_exists("simplexml_load_string")) { if (!function_exists("utf8_encode")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "UTF8")."
\n"; - // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) +// $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { print 'Ok '.$langs->trans("PHPSupport", "UTF8")."
\n"; } @@ -193,7 +193,7 @@ if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@loc if (!function_exists("locale_get_primary_language") || !function_exists("locale_get_region")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "Intl")."
\n"; - // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) + // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { print 'Ok '.$langs->trans("PHPSupport", "Intl")."
\n"; } @@ -203,7 +203,7 @@ if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@loc if (!function_exists("imap_open")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "IMAP")."
\n"; - // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) +// $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { print 'Ok '.$langs->trans("PHPSupport", "IMAP")."
\n"; } @@ -212,7 +212,7 @@ if (!function_exists("imap_open")) { if (!class_exists('ZipArchive')) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupport", "ZIP")."
\n"; - // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) +// $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { print 'Ok '.$langs->trans("PHPSupport", "ZIP")."
\n"; } diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index 5a2dcbc0c77..58d3d1d21f2 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -130,7 +130,7 @@ if (!empty($force_install_message)) { +} ?>"> @@ -244,11 +244,11 @@ if (!empty($force_install_noedit)) { id="main_force_https" name="main_force_https" + print ' checked'; + } ?> + print ' disabled'; + } ?> > @@ -388,8 +388,8 @@ if (!empty($force_install_noedit)) { @@ -407,8 +407,8 @@ if (!empty($force_install_noedit)) { name="db_host" value="" + print ' disabled'; + } ?> > @@ -502,7 +502,7 @@ if (!empty($force_install_noedit)) { ?>" + } ?> > @@ -552,8 +552,8 @@ if (!empty($force_install_noedit)) { class="needroot" value="" 0 && !empty($force_install_databaserootlogin)) { - print ' disabled'; - } ?> + print ' disabled'; + } ?> > '; - //} elseif ($key == 'propvalidate') { + //} elseif ($key == 'propvalidate') { // print ''; } elseif ($key == 'propvisible') { print ''; @@ -4933,18 +4933,18 @@ if ($module == 'initmodule') { }); '; - /*print '
'; - print '
'; - print '
'; - print ''.$langs->trans("or").''; - print '
'; - print '
'; - //print ' '; - print $langs->trans("InitStructureFromExistingTable"); - print ''; - print ''; - print '
'; - */ + /*print '
'; + print '
'; + print '
'; + print ''.$langs->trans("or").''; + print '
'; + print '
'; + //print ' '; + print $langs->trans("InitStructureFromExistingTable"); + print ''; + print ''; + print '
'; + */ } elseif ($tabdic == 'deletedictionary') { // Delete dic tab print ''; @@ -5394,7 +5394,7 @@ if ($module == 'initmodule') { }); '; - // display permissions for each object + // display permissions for each object } else { $fullpathoffile = dol_buildpath($file, 0); diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 4d9f5a2529d..c4b931c5b15 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1767,7 +1767,7 @@ class Mo extends CommonObject $productstatic->fetch($line->fk_product); $productstatic->load_virtual_stock(); $this->tpl['label'] .= $productstatic->getNomUrl(1); - //$this->tpl['label'].= ' - '.$productstatic->label; + //$this->tpl['label'].= ' - '.$productstatic->label; } else { // If origin MRP line is not a product, but another MRP // TODO diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index ec786f6ce6b..677da44ef65 100644 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -556,7 +556,7 @@ function hash_call($methodName, $nvpStr) $_SESSION['curl_error_no'] = curl_errno($ch); $_SESSION['curl_error_msg'] = curl_error($ch); - //Execute the Error handling module to display errors. + //Execute the Error handling module to display errors. } else { //closing the curl curl_close($ch); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index bbec24b64de..269a5298986 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2304,7 +2304,7 @@ class Product extends CommonObject $price_min = price2num($newminprice, 'MU'); $price_min_ttc = price2num($newminprice) * (1 + ($newvat / 100)); $price_min_ttc = price2num($price_min_ttc, 'MU'); - //print 'X'.$newminprice.'-'.$price_min; + //print 'X'.$newminprice.'-'.$price_min; } else { $price_min = 0; $price_min_ttc = 0; @@ -2688,7 +2688,7 @@ class Product extends CommonObject $this->multiprices_tva_tx[$i] = $result ? $result["tva_tx"].($result ? ' ('.$result['default_vat_code'].')' : '') : null; $this->multiprices_recuperableonly[$i] = $result ? $result["recuperableonly"] : null; - // Price by quantity + // Price by quantity /* $this->prices_by_qty[$i]=$result["price_by_qty"]; $this->prices_by_qty_id[$i]=$result["rowid"]; diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 255582e62c3..0ccfe522a77 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -199,7 +199,7 @@ class ProductCustomerPrice extends CommonObject $this->price_min = price2num($this->price_min, 'MU'); $this->price_min_ttc = price2num($this->price_min) * (1 + ($this->tva_tx / 100)); $this->price_min_ttc = price2num($this->price_min_ttc, 'MU'); - // print 'X'.$newminprice.'-'.$price_min; + // print 'X'.$newminprice.'-'.$price_min; } else { $this->price_min = 0; $this->price_min_ttc = 0; @@ -677,7 +677,7 @@ class ProductCustomerPrice extends CommonObject $this->price_min = price2num($this->price_min, 'MU'); $this->price_min_ttc = price2num($this->price_min) * (1 + ($this->tva_tx / 100)); $this->price_min_ttc = price2num($this->price_min_ttc, 'MU'); - // print 'X'.$newminprice.'-'.$price_min; + // print 'X'.$newminprice.'-'.$price_min; } else { $this->price_min = 0; $this->price_min_ttc = 0; diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 5a49139386b..f63fb0d5368 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -247,7 +247,7 @@ if ($action == 'createmovements' && $user->hasRight('stock', 'mouvement', 'creer $firstrecord = array_shift($arraybatchinfo); $dlc = $firstrecord['eatby']; $dluo = $firstrecord['sellby']; - //var_dump($batch); + //var_dump($batch); //var_dump($arraybatchinfo); //var_dump($firstrecord); //var_dump($dlc); diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index c5792768256..09fed415998 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -1356,15 +1356,15 @@ if (!$variants || getDolGlobalString('VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PA fetchByFkCombination($currcomb->id); - $iMax = count($productCombination2ValuePairs); + $iMax = count($productCombination2ValuePairs); - for ($i = 0; $i < $iMax; $i++) { - echo dol_htmlentities($productCombination2ValuePairs[$i]); + for ($i = 0; $i < $iMax; $i++) { + echo dol_htmlentities($productCombination2ValuePairs[$i]); - if ($i !== ($iMax - 1)) { - echo ', '; - } - } ?> + if ($i !== ($iMax - 1)) { + echo ', '; + } + } ?> diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index d347290c92c..5eb2d929b93 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -839,7 +839,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if ($usevirtualstock) { // If option to increase/decrease is not on an object validation, virtual stock may differs from physical stock. $stock = $prod->stock_theorique; - //TODO $stockwarehouse = $prod->stock_warehouse[$fk_entrepot]->; + //TODO $stockwarehouse = $prod->stock_warehouse[$fk_entrepot]->; } else { $stock = $prod->stock_reel; $stockwarehouse = $prod->stock_warehouse[$fk_entrepot]->real; @@ -891,12 +891,12 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $picto = ''; if ($ordered > 0) { $stockforcompare = ($usevirtualstock ? $stock : $stock + $ordered); - /*if ($stockforcompare >= $desiredstock) - { - $picto = img_picto('', 'help'); - } else { - $picto = img_picto('', 'help'); - }*/ + /*if ($stockforcompare >= $desiredstock) + { + $picto = img_picto('', 'help'); + } else { + $picto = img_picto('', 'help'); + }*/ } else { $picto = img_picto($langs->trans("NoPendingReceptionOnSupplierOrder"), 'help'); } diff --git a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php index d00755525c4..3cc38f65d28 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php @@ -476,7 +476,7 @@ class StockTransferLine extends CommonObjectLine $firstrecord = array_shift($arraybatchinfo); $dlc = $firstrecord['eatby']; $dluo = $firstrecord['sellby']; - //var_dump($batch); var_dump($arraybatchinfo); var_dump($firstrecord); var_dump($dlc); var_dump($dluo); exit; + //var_dump($batch); var_dump($arraybatchinfo); var_dump($firstrecord); var_dump($dlc); var_dump($dluo); exit; } else { $dlc = ''; $dluo = ''; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index f1c912f7ea0..c7b875427cd 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1117,7 +1117,7 @@ if ($action == 'create' && $user->hasRight('projet', 'creer')) { $filter = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; } $text = img_picto('', 'company', 'class="pictofixedwidth"'); - $text .= $form->select_company(!empty($object->thirdparty->id)?$object->thirdparty->id:"", 'socid', $filter, 'None', 1, 0, array(), 0, 'minwidth300'); + $text .= $form->select_company(!empty($object->thirdparty->id) ? $object->thirdparty->id : "", 'socid', $filter, 'None', 1, 0, array(), 0, 'minwidth300'); if (!getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') && empty($conf->dol_use_jmobile)) { $texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty"); print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1, 0, '', '', 2); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 372e3510fcf..620b1127e91 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -2494,7 +2494,7 @@ class Project extends CommonObject $return .= '
'; if ($this->public) { $return .= img_picto($langs->trans('Visibility').': '.$langs->trans('SharedProject'), 'world', 'class="paddingrightonly valignmiddle"'); - //print $langs->trans('SharedProject'); + //print $langs->trans('SharedProject'); } else { $return .= img_picto($langs->trans('Visibility').': '.$langs->trans('PrivateProject'), 'private', 'class="paddingrightonly valignmiddle"'); //print $langs->trans('PrivateProject'); diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index d91f9177aa3..93d913f3272 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -297,7 +297,7 @@ if (count($tasksarray) > 0) { if ($val->fk_parent != 0 && $task->hasChildren() > 0) { $tasks[$taskcursor]['task_is_group'] = 1; $tasks[$taskcursor]['task_css'] = 'ggroupblack'; - //$tasks[$taskcursor]['task_css'] = 'gtaskblue'; + //$tasks[$taskcursor]['task_css'] = 'gtaskblue'; } elseif ($task->hasChildren() > 0) { $tasks[$taskcursor]['task_is_group'] = 1; //$tasks[$taskcursor]['task_is_group'] = 0; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 1d5a8d85bd8..35302f28ad1 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -1773,7 +1773,7 @@ while ($i < $imaxinloop) { print ''; } elseif (isset($totalarray['totalvaluefield']) && $totalarray['totalvaluefield'] == $i) { print ''; - //} elseif ($totalarray['totalvaluebilledfield'] == $i) { print ''; + //} elseif ($totalarray['totalvaluebilledfield'] == $i) { print ''; } else { print ''; } diff --git a/htdocs/public/company/new.php b/htdocs/public/company/new.php index de5e4d4f179..c011847f9d2 100644 --- a/htdocs/public/company/new.php +++ b/htdocs/public/company/new.php @@ -244,7 +244,7 @@ if (empty($reshook) && $action == 'add') { $urlback = $backtopage; } elseif (getDolGlobalString('MEMBER_URL_REDIRECT_SUBSCRIPTION')) { $urlback = $conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION; - // TODO Make replacement of __AMOUNT__, etc... + // TODO Make replacement of __AMOUNT__, etc... } else { $urlback = $_SERVER["PHP_SELF"] . "?action=added&token=" . newToken(); } diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 2841a239015..a9b3aa0ae34 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -440,7 +440,7 @@ if (empty($reshook) && $action == 'add') { $urlback = $backtopage; } elseif (getDolGlobalString('MEMBER_URL_REDIRECT_SUBSCRIPTION')) { $urlback = $conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION; - // TODO Make replacement of __AMOUNT__, etc... + // TODO Make replacement of __AMOUNT__, etc... } else { $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken(); } diff --git a/htdocs/public/partnership/new.php b/htdocs/public/partnership/new.php index 73c2e3baa17..792bf93f4f7 100644 --- a/htdocs/public/partnership/new.php +++ b/htdocs/public/partnership/new.php @@ -423,7 +423,7 @@ if (empty($reshook) && $action == 'add') { $urlback = $backtopage; } elseif (getDolGlobalString('PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION')) { $urlback = $conf->global->PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION; - // TODO Make replacement of __AMOUNT__, etc... + // TODO Make replacement of __AMOUNT__, etc... } else { $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken(); } diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index b2dadb42058..e8b76c41645 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -382,7 +382,7 @@ if ($action == 'dopayment') { if (empty($PAYPAL_API_PRICE) || !is_numeric($PAYPAL_API_PRICE)) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")); $action = ''; - // } elseif (empty($EMAIL)) { $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail")); + // } elseif (empty($EMAIL)) { $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail")); // } elseif (! isValidEMail($EMAIL)) { $mesg=$langs->trans("ErrorBadEMail",$EMAIL); } elseif (!$origfulltag) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentCode")); @@ -2542,29 +2542,29 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme billing_details: { name: 'test' thirdparty) && !empty($object->thirdparty->email))) { - ?>, email: 'thirdparty->email); ?>' + ?>, email: 'thirdparty->email); ?>'thirdparty) && !empty($object->thirdparty->phone)) { - ?>, phone: 'thirdparty->phone); ?>' + ?>, phone: 'thirdparty->phone); ?>'thirdparty)) { - ?>, address: { + ?>, address: { city: 'thirdparty->town); ?>', thirdparty->country_code) { - ?>country: 'thirdparty->country_code); ?>', + ?>country: 'thirdparty->country_code); ?>', line1: 'thirdparty->address)); ?>', postal_code: 'thirdparty->zip); ?>' } + } ?> } }, save_payment_method: /* true when a customer was provided when creating payment intent. true ask to save the card */ + print 'true'; + } else { + print 'false'; + } ?> /* true when a customer was provided when creating payment intent. true ask to save the card */ }, } ).then(function(result) { @@ -2636,29 +2636,29 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme billing_details: { name: cardholderName.value thirdparty) && !empty($object->thirdparty->email))) { - ?>, email: 'thirdparty->email); ?>' + ?>, email: 'thirdparty->email); ?>'thirdparty) && !empty($object->thirdparty->phone)) { - ?>, phone: 'thirdparty->phone); ?>' + ?>, phone: 'thirdparty->phone); ?>'thirdparty)) { - ?>, address: { + ?>, address: { city: 'thirdparty->town); ?>', thirdparty->country_code) { - ?>country: 'thirdparty->country_code); ?>', + ?>country: 'thirdparty->country_code); ?>', line1: 'thirdparty->address)); ?>', postal_code: 'thirdparty->zip); ?>' } + } ?> } }, save_payment_method: /* true when a customer was provided when creating payment intent. true ask to save the card */ + print 'true'; + } else { + print 'false'; + } ?> /* true when a customer was provided when creating payment intent. true ask to save the card */ } ).then(function(result) { console.log(result); diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 1a548dd382f..e1bff57f33d 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -1867,7 +1867,7 @@ if ($ispaymentok) { $result = $mailfile->sendfile(); if ($result) { dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); - //dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0); + //dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0); } else { dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); //dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0); diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index 9b35ac796ac..81178c5b087 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -397,7 +397,7 @@ if (empty($reshook) && $action == 'add') { $urlback = $backtopage; } elseif (getDolGlobalString('PROJECT_URL_REDIRECT_LEAD')) { $urlback = $conf->global->PROJECT_URL_REDIRECT_LEAD; - // TODO Make replacement of __AMOUNT__, etc... + // TODO Make replacement of __AMOUNT__, etc... } else { $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken(); } diff --git a/htdocs/public/test/test_arrays.php b/htdocs/public/test/test_arrays.php index 3b0d17bbf98..6a32b5f4aff 100644 --- a/htdocs/public/test/test_arrays.php +++ b/htdocs/public/test/test_arrays.php @@ -89,7 +89,7 @@ if (empty($usedolheader)) { */ llxHeader('', '', '', '', 0, 0, $arrayjs, $arraycss); -} + } // CONTENT diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 5d408ebf796..0c486d20303 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -414,7 +414,7 @@ if (empty($reshook)) { $discountid = $discount->create($user); if ($discountid > 0) { $result = $objecttmp->insert_discount($discountid); - //$result=$discount->link_to_invoice($lineid,$id); + //$result=$discount->link_to_invoice($lineid,$id); } else { setEventMessages($discount->error, $discount->errors, 'errors'); $error++; diff --git a/htdocs/reception/tpl/linkedobjectblock.tpl.php b/htdocs/reception/tpl/linkedobjectblock.tpl.php index 51a9e3aedc1..d2832f687a9 100644 --- a/htdocs/reception/tpl/linkedobjectblock.tpl.php +++ b/htdocs/reception/tpl/linkedobjectblock.tpl.php @@ -51,8 +51,8 @@ foreach ($linkedObjectBlock as $key => $objectlink) { diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 5542bdd344d..8b1aeca2eb3 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -452,7 +452,7 @@ if ($action == "update_extras" && $permissiontoadd) { if (GETPOSTISSET($attributekeylong.'day') && GETPOSTISSET($attributekeylong.'month') && GETPOSTISSET($attributekeylong.'year')) { // This is properties of a date $object->array_options['options_'.$attributekey] = dol_mktime(GETPOST($attributekeylong.'hour', 'int'), GETPOST($attributekeylong.'min', 'int'), GETPOST($attributekeylong.'sec', 'int'), GETPOST($attributekeylong.'month', 'int'), GETPOST($attributekeylong.'day', 'int'), GETPOST($attributekeylong.'year', 'int')); - //var_dump(dol_print_date($object->array_options['options_'.$attributekey]));exit; + //var_dump(dol_print_date($object->array_options['options_'.$attributekey]));exit; } else { $object->array_options['options_'.$attributekey] = GETPOST($attributekeylong, 'alpha'); } diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 301dbe6dd59..3095e18f2b1 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -391,7 +391,7 @@ foreach ($dirsociete as $dirroot) { dol_syslog($e->getMessage(), LOG_ERR); } - $modCodeTiers = new $file; + $modCodeTiers = new $file(); // Show modules according to features level if ($modCodeTiers->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { @@ -477,7 +477,7 @@ foreach ($dirsociete as $dirroot) { dol_syslog($e->getMessage(), LOG_ERR); } - $modCodeCompta = new $file; + $modCodeCompta = new $file(); $arrayofmodules[$file] = $modCodeCompta; } @@ -593,9 +593,9 @@ foreach ($dirsociete as $dirroot) { print "'; print ''; @@ -1469,12 +1470,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio // Phone / Fax print ''; - print 'browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning', 'class="pictofixedwidth"').' '; + print 'browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning', 'class="pictofixedwidth"').' '; if ($conf->browser->layout == 'phone') { print ''; } print ''; - print 'browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning_fax', 'class="pictofixedwidth"').' '; + print 'browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning_fax', 'class="pictofixedwidth"').' '; // Email / Web print ''; @@ -1525,10 +1526,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio } // Prof ids - $i = 1; $j = 0; $NBCOLS = ($conf->browser->layout == 'phone' ? 1 : 2); + $i = 1; + $j = 0; + $NBCOLS = ($conf->browser->layout == 'phone' ? 1 : 2); while ($i <= 6) { $idprof = $langs->transcountry('ProfId'.$i, $object->country_code); - if ($idprof != '-') { + if ($idprof != '-') { $key = 'idprof'.$i; if (($j % $NBCOLS) == 0) { @@ -1554,7 +1557,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio // Vat is used print ''; print ''; if ($conf->browser->layout == 'phone') { print ''; @@ -1566,7 +1569,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio if (!getDolGlobalString('MAIN_DISABLEVATCHECK') && isInEEC($object)) { $s .= ' '; - if (!empty($conf->use_javascript_ajax)) { + if (!empty($conf->use_javascript_ajax)) { $widthpopup = 600; if (!empty($conf->dol_use_jmobile)) { $widthpopup = 350; @@ -1623,7 +1626,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio } // Type - Workforce/Staff - print ''; // Zip / Town - print 'browser->layout == 'phone' ? ' colspan="3"': '').'>'; + print 'browser->layout == 'phone' ? ' colspan="3"' : '').'>'; print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100'); print ''; if ($conf->browser->layout == 'phone') { print ''; } - print 'browser->layout == 'phone' ? ' colspan="3"': '').'>'; + print 'browser->layout == 'phone' ? ' colspan="3"' : '').'>'; print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); print $form->widgetForTranslation("town", $object, $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent'); print ''; @@ -2200,23 +2203,23 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio // Phone / Fax print ''; - print 'browser->layout == 'phone' ? ' colspan="3"': '').'>'.img_picto('', 'object_phoning', 'class="pictofixedwidth"').' '; + print 'browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning', 'class="pictofixedwidth"').' '; if ($conf->browser->layout == 'phone') { print ''; } print ''; - print 'browser->layout == 'phone' ? ' colspan="3"': '').'>'.img_picto('', 'object_phoning_fax', 'class="pictofixedwidth"').' '; + print 'browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning_fax', 'class="pictofixedwidth"').' '; print ''; // Web print ''; - print ''; + print ''; // EMail print ''; print ''; // Unsubscribe @@ -2290,7 +2293,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio // VAT is used print ''; // Local Taxes @@ -2376,7 +2379,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''; // Type - Workforce/Staff - print ''; - print ''; + print ''; print ''; @@ -2686,7 +2689,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio } // Prof ids - $i = 1; $j = 0; + $i = 1; + $j = 0; while ($i <= 6) { $idprof = $langs->transcountry('ProfId'.$i, $object->country_code); if ($idprof != '-') { @@ -3119,7 +3123,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio if (empty($user->socid)) { $langs->load("mails"); $title = ''; - if (empty($object->email) && !$at_least_one_email_contact) { $title = $langs->trans('NoEMail'); } + if (empty($object->email) && !$at_least_one_email_contact) { + $title = $langs->trans('NoEMail'); + } print dolGetButtonAction($title, $langs->trans('SendMail'), 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', 'btn-send-mail', !empty($object->email) || $at_least_one_email_contact); } diff --git a/htdocs/societe/checkvat/checkVatPopup.php b/htdocs/societe/checkvat/checkVatPopup.php index 93a4668cf7c..008d63e8a2d 100644 --- a/htdocs/societe/checkvat/checkVatPopup.php +++ b/htdocs/societe/checkvat/checkVatPopup.php @@ -21,7 +21,9 @@ * \brief Popup screen to validate VAT */ -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +if (! defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); +} // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) require "../../main.inc.php"; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -116,7 +118,7 @@ if (!$vatNumber) { } print $langs->trans("VATIntraSyntaxIsValid").': '.$langs->trans("No").' (Might be a non europeen VAT)
'; print $langs->trans("ValueIsValid").': '.$langs->trans("No").' (Might be a non europeen VAT)
'; - //$messagetoshow=$soapclient->response; + //$messagetoshow=$soapclient->response; } else { // Syntaxe ok if ($result['requestDate']) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 341c3e4124e..b394021caa2 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -896,7 +896,7 @@ class Societe extends CommonObject if (empty($this->status)) { $this->status = 0; } - $this->name = $this->name ?trim($this->name) : trim($this->nom); + $this->name = $this->name ? trim($this->name) : trim($this->nom); $this->setUpperOrLowerCase(); $this->nom = $this->name; // For backward compatibility if (empty($this->client)) { @@ -1205,8 +1205,11 @@ class Societe extends CommonObject $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL', 'TVA_INTRA', 'ACCOUNTANCY_CODE_CUSTOMER', 'ACCOUNTANCY_CODE_SUPPLIER'); foreach ($array_to_check as $key) { $keymin = strtolower($key); - if ($key == 'ACCOUNTANCY_CODE_CUSTOMER') $keymin = 'code_compta'; - elseif ($key == 'ACCOUNTANCY_CODE_SUPPLIER') $keymin = 'code_compta_fournisseur'; + if ($key == 'ACCOUNTANCY_CODE_CUSTOMER') { + $keymin = 'code_compta'; + } elseif ($key == 'ACCOUNTANCY_CODE_SUPPLIER') { + $keymin = 'code_compta_fournisseur'; + } $i = (int) preg_replace('/[^0-9]/', '', $key); $vallabel = $this->$keymin; @@ -1246,7 +1249,8 @@ class Societe extends CommonObject if (!$error && $vallabel && getDolGlobalString('SOCIETE_EMAIL_UNIQUE')) { if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) { $langs->load("errors"); - $error++; $this->errors[] = $langs->trans('Email')." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel).' ('.$langs->trans("ForbiddenBySetupRules").')'; + $error++; + $this->errors[] = $langs->trans('Email')." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel).' ('.$langs->trans("ForbiddenBySetupRules").')'; } } } elseif ($key == 'TVA_INTRA') { @@ -1254,7 +1258,8 @@ class Societe extends CommonObject if ($vallabel && getDolGlobalString('SOCIETE_VAT_INTRA_UNIQUE')) { if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) { $langs->load("errors"); - $error++; $this->errors[] = $langs->trans('VATIntra')." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel).' ('.$langs->trans("ForbiddenBySetupRules").')'; + $error++; + $this->errors[] = $langs->trans('VATIntra')." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel).' ('.$langs->trans("ForbiddenBySetupRules").')'; } } } elseif ($key == 'ACCOUNTANCY_CODE_CUSTOMER' && !empty($this->client)) { @@ -1335,9 +1340,9 @@ class Societe extends CommonObject $this->nom = $this->name; // For backward compatibility $this->name_alias = trim($this->name_alias); $this->ref_ext = trim($this->ref_ext); - $this->address = $this->address ?trim($this->address) : trim($this->address); - $this->zip = $this->zip ?trim($this->zip) : trim($this->zip); - $this->town = $this->town ?trim($this->town) : trim($this->town); + $this->address = $this->address ? trim($this->address) : trim($this->address); + $this->zip = $this->zip ? trim($this->zip) : trim($this->zip); + $this->town = $this->town ? trim($this->town) : trim($this->town); $this->state_id = trim($this->state_id); $this->country_id = ($this->country_id > 0) ? $this->country_id : 0; $this->phone = trim($this->phone); @@ -1347,15 +1352,15 @@ class Societe extends CommonObject $this->fax = preg_replace("/\s/", "", $this->fax); $this->fax = preg_replace("/\./", "", $this->fax); $this->email = trim($this->email); - $this->url = $this->url ?clean_url($this->url, 0) : ''; + $this->url = $this->url ? clean_url($this->url, 0) : ''; $this->note_private = trim($this->note_private); $this->note_public = trim($this->note_public); $this->idprof1 = trim($this->idprof1); $this->idprof2 = trim($this->idprof2); $this->idprof3 = trim($this->idprof3); $this->idprof4 = trim($this->idprof4); - $this->idprof5 = (!empty($this->idprof5) ?trim($this->idprof5) : ''); - $this->idprof6 = (!empty($this->idprof6) ?trim($this->idprof6) : ''); + $this->idprof5 = (!empty($this->idprof5) ? trim($this->idprof5) : ''); + $this->idprof6 = (!empty($this->idprof6) ? trim($this->idprof6) : ''); $this->prefix_comm = trim($this->prefix_comm); $this->outstanding_limit = price2num($this->outstanding_limit); $this->order_min_amount = price2num($this->order_min_amount); @@ -1442,7 +1447,7 @@ class Societe extends CommonObject } //Web services - $this->webservices_url = $this->webservices_url ?clean_url($this->webservices_url, 0) : ''; + $this->webservices_url = $this->webservices_url ? clean_url($this->webservices_url, 0) : ''; $this->webservices_key = trim($this->webservices_key); $this->accountancy_code_buy = trim($this->accountancy_code_buy); @@ -2929,7 +2934,7 @@ class Societe extends CommonObject $label = $langs->trans("ShowCompany"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"'); + $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"'); $linkclose .= $dataparams.' class="'.$classfortooltip.' refurl valignmiddle"'; $target_value = array('_self', '_blank', '_parent', '_top'); if (in_array($target, $target_value)) { @@ -3121,10 +3126,12 @@ class Societe extends CommonObject if ($resql) { $nump = $this->db->num_rows($resql); if ($nump) { - $sepa = "("; $sepb = ")"; + $sepa = "("; + $sepb = ")"; if ($mode == 'email') { //$sepa="<"; $sepb=">"; - $sepa = "<"; $sepb = ">"; + $sepa = "<"; + $sepb = ">"; } $i = 0; while ($i < $nump) { @@ -3795,7 +3802,7 @@ class Societe extends CommonObject break; } - //Verify duplicate entries + //Verify duplicate entries $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."societe WHERE ".$field." = '".$this->db->escape($value)."' AND entity IN (".getEntity('societe').")"; if ($socid) { $sql .= " AND rowid <> ".$socid; @@ -4346,7 +4353,7 @@ class Societe extends CommonObject if ($member->morphy == 'mor') { if (empty($socname)) { - $socname = $member->company? $member->company : $member->societe; + $socname = $member->company ? $member->company : $member->societe; } if (!empty($fullname) && empty($socalias)) { $socalias = $fullname; @@ -4477,7 +4484,8 @@ class Societe extends CommonObject //TODO This could be replicated for region but function `getRegion` didn't exist, so I didn't added it. // We define state_id, state_code and state - $state_id = 0; $state_code = $state_label = ''; + $state_id = 0; + $state_code = $state_label = ''; if (getDolGlobalString('MAIN_INFO_SOCIETE_STATE')) { $tmp = explode(':', $conf->global->MAIN_INFO_SOCIETE_STATE); $state_id = $tmp[0]; @@ -4683,7 +4691,7 @@ class Societe extends CommonObject $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); - return (($obj->nb > 0) ?true:false); + return (($obj->nb > 0) ? true : false); } else { $this->error = $this->db->lasterror(); return false; diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index e070f07740b..c4efe6be306 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -464,7 +464,7 @@ class SocieteAccount extends CommonObject $label = $langs->trans("WebsiteAccount"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"'); + $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"'); $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 8cd00ac9cde..9aceb69b6b5 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; $langs->loadLangs(array("companies", "bills", "orders", "suppliers", "propal", "interventions", "contracts", "products")); -$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thirdpartylist'; +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'thirdpartylist'; // Security check $socid = GETPOST('socid', 'int'); @@ -52,7 +52,7 @@ if ($socid > 0) { } // Sort & Order fields -$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -591,26 +591,26 @@ if ($sql_select) { if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) { $discount = new DiscountAbsolute($db); $discount->fetch($objp->fk_remise_except); - echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0)); + echo($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0)); } if ($objp->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) { $discount = new DiscountAbsolute($db); $discount->fetch($objp->fk_remise_except); - echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0)); + echo($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0)); } elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) { $discount = new DiscountAbsolute($db); $discount->fetch($objp->fk_remise_except); - echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0)); + echo($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0)); } elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) { $discount = new DiscountAbsolute($db); $discount->fetch($objp->fk_remise_except); - echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0)); + echo($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0)); // Add date of deposit if (getDolGlobalString('INVOICE_ADD_DEPOSIT_DATE')) { echo ' ('.dol_print_date($discount->datec).')'; } } else { - echo ($txt ? ' - ' : '').dol_htmlentitiesbr($objp->description); + echo($txt ? ' - ' : '').dol_htmlentitiesbr($objp->description); } } } else { diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php index 2fb0808a36a..612336ea797 100644 --- a/htdocs/societe/contact.php +++ b/htdocs/societe/contact.php @@ -68,7 +68,7 @@ $action = (GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'); $cancel = GETPOST('cancel', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $confirm = GETPOST('confirm'); -$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); +$socid = GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'); if ($user->socid) { $socid = $user->socid; diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index 20666856940..836c8e83294 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -127,7 +127,7 @@ print dol_get_fiche_head($head, 'document', $langs->trans("ThirdParty"), -1, 'co // Build file list -$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); +$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); $totalsize = 0; foreach ($filearray as $key => $file) { $totalsize += $file['size']; diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index 9f7bc20008d..cd0573b6457 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -125,16 +125,20 @@ if ($result) { while ($objp = $db->fetch_object($result)) { $found = 0; if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTS_STATS') && ($objp->client == 2 || $objp->client == 3)) { - $found = 1; $third['prospect']++; + $found = 1; + $third['prospect']++; } if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS') && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS_STATS') && ($objp->client == 1 || $objp->client == 3)) { - $found = 1; $third['customer']++; + $found = 1; + $third['customer']++; } 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'))) && !getDolGlobalString('SOCIETE_DISABLE_SUPPLIERS_STATS') && $objp->fournisseur) { - $found = 1; $third['supplier']++; + $found = 1; + $third['supplier']++; } if (isModEnabled('societe') && $objp->client == 0 && $objp->fournisseur == 0) { - $found = 1; $third['other']++; + $found = 1; + $third['other']++; } if ($found) { $total++; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index a4331d183ed..cda63c586d6 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -131,7 +131,7 @@ $place = GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : '0'; // $place is $diroutputmassaction = $conf->societe->dir_output.'/temp/massgeneration/'.$user->id; // Load variable for pagination -$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -152,28 +152,32 @@ $pagenext = $page + 1; if ($type == 'c') { if (empty($contextpage) || $contextpage == 'thirdpartylist') { $contextpage = 'customerlist'; - } if ($search_type == '') { + } + if ($search_type == '') { $search_type = '1,3'; } } if ($type == 'p') { if (empty($contextpage) || $contextpage == 'thirdpartylist') { $contextpage = 'prospectlist'; - } if ($search_type == '') { + } + if ($search_type == '') { $search_type = '2,3'; } } if ($type == 't') { if (empty($contextpage) || $contextpage == 'poslist') { $contextpage = 'poslist'; - } if ($search_type == '') { + } + if ($search_type == '') { $search_type = '1,2,3'; } } if ($type == 'f') { if (empty($contextpage) || $contextpage == 'thirdpartylist') { $contextpage = 'supplierlist'; - } if ($search_type == '') { + } + if ($search_type == '') { $search_type = '4'; } } @@ -326,8 +330,7 @@ if ($action == "change") { // Change customer for TakePOS } $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".((int) $idcustomer)." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; - $resql = $db->query($sql); - ?> + $resql = $db->query($sql); ?> '; - /*print '
'; - print '
'; - print '
'; - print ''.$langs->trans("or").''; - print '
'; - print '
'; - //print ' '; - print $langs->trans("InitStructureFromExistingTable"); - print ''; - print ''; - print '
'; - */ + /*print '
'; + print '
'; + print '
'; + print ''.$langs->trans("or").''; + print '
'; + print '
'; + //print ' '; + print $langs->trans("InitStructureFromExistingTable"); + print ''; + print ''; + print '
'; + */ } elseif ($tabdic == 'deletedictionary') { // Delete dic tab print ''; @@ -5394,7 +5394,7 @@ if ($module == 'initmodule') { }); '; - // display permissions for each object + // display permissions for each object } else { $fullpathoffile = dol_buildpath($file, 0); diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index c4b931c5b15..4d9f5a2529d 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1767,7 +1767,7 @@ class Mo extends CommonObject $productstatic->fetch($line->fk_product); $productstatic->load_virtual_stock(); $this->tpl['label'] .= $productstatic->getNomUrl(1); - //$this->tpl['label'].= ' - '.$productstatic->label; + //$this->tpl['label'].= ' - '.$productstatic->label; } else { // If origin MRP line is not a product, but another MRP // TODO diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index 677da44ef65..ec786f6ce6b 100644 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -556,7 +556,7 @@ function hash_call($methodName, $nvpStr) $_SESSION['curl_error_no'] = curl_errno($ch); $_SESSION['curl_error_msg'] = curl_error($ch); - //Execute the Error handling module to display errors. + //Execute the Error handling module to display errors. } else { //closing the curl curl_close($ch); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 269a5298986..bbec24b64de 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2304,7 +2304,7 @@ class Product extends CommonObject $price_min = price2num($newminprice, 'MU'); $price_min_ttc = price2num($newminprice) * (1 + ($newvat / 100)); $price_min_ttc = price2num($price_min_ttc, 'MU'); - //print 'X'.$newminprice.'-'.$price_min; + //print 'X'.$newminprice.'-'.$price_min; } else { $price_min = 0; $price_min_ttc = 0; @@ -2688,7 +2688,7 @@ class Product extends CommonObject $this->multiprices_tva_tx[$i] = $result ? $result["tva_tx"].($result ? ' ('.$result['default_vat_code'].')' : '') : null; $this->multiprices_recuperableonly[$i] = $result ? $result["recuperableonly"] : null; - // Price by quantity + // Price by quantity /* $this->prices_by_qty[$i]=$result["price_by_qty"]; $this->prices_by_qty_id[$i]=$result["rowid"]; diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 0ccfe522a77..255582e62c3 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -199,7 +199,7 @@ class ProductCustomerPrice extends CommonObject $this->price_min = price2num($this->price_min, 'MU'); $this->price_min_ttc = price2num($this->price_min) * (1 + ($this->tva_tx / 100)); $this->price_min_ttc = price2num($this->price_min_ttc, 'MU'); - // print 'X'.$newminprice.'-'.$price_min; + // print 'X'.$newminprice.'-'.$price_min; } else { $this->price_min = 0; $this->price_min_ttc = 0; @@ -677,7 +677,7 @@ class ProductCustomerPrice extends CommonObject $this->price_min = price2num($this->price_min, 'MU'); $this->price_min_ttc = price2num($this->price_min) * (1 + ($this->tva_tx / 100)); $this->price_min_ttc = price2num($this->price_min_ttc, 'MU'); - // print 'X'.$newminprice.'-'.$price_min; + // print 'X'.$newminprice.'-'.$price_min; } else { $this->price_min = 0; $this->price_min_ttc = 0; diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index f63fb0d5368..5a49139386b 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -247,7 +247,7 @@ if ($action == 'createmovements' && $user->hasRight('stock', 'mouvement', 'creer $firstrecord = array_shift($arraybatchinfo); $dlc = $firstrecord['eatby']; $dluo = $firstrecord['sellby']; - //var_dump($batch); + //var_dump($batch); //var_dump($arraybatchinfo); //var_dump($firstrecord); //var_dump($dlc); diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 09fed415998..c5792768256 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -1356,15 +1356,15 @@ if (!$variants || getDolGlobalString('VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PA fetchByFkCombination($currcomb->id); - $iMax = count($productCombination2ValuePairs); + $iMax = count($productCombination2ValuePairs); - for ($i = 0; $i < $iMax; $i++) { - echo dol_htmlentities($productCombination2ValuePairs[$i]); + for ($i = 0; $i < $iMax; $i++) { + echo dol_htmlentities($productCombination2ValuePairs[$i]); - if ($i !== ($iMax - 1)) { - echo ', '; - } - } ?> + if ($i !== ($iMax - 1)) { + echo ', '; + } + } ?> diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 5eb2d929b93..d347290c92c 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -839,7 +839,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if ($usevirtualstock) { // If option to increase/decrease is not on an object validation, virtual stock may differs from physical stock. $stock = $prod->stock_theorique; - //TODO $stockwarehouse = $prod->stock_warehouse[$fk_entrepot]->; + //TODO $stockwarehouse = $prod->stock_warehouse[$fk_entrepot]->; } else { $stock = $prod->stock_reel; $stockwarehouse = $prod->stock_warehouse[$fk_entrepot]->real; @@ -891,12 +891,12 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $picto = ''; if ($ordered > 0) { $stockforcompare = ($usevirtualstock ? $stock : $stock + $ordered); - /*if ($stockforcompare >= $desiredstock) - { - $picto = img_picto('', 'help'); - } else { - $picto = img_picto('', 'help'); - }*/ + /*if ($stockforcompare >= $desiredstock) + { + $picto = img_picto('', 'help'); + } else { + $picto = img_picto('', 'help'); + }*/ } else { $picto = img_picto($langs->trans("NoPendingReceptionOnSupplierOrder"), 'help'); } diff --git a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php index 3cc38f65d28..d00755525c4 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php @@ -476,7 +476,7 @@ class StockTransferLine extends CommonObjectLine $firstrecord = array_shift($arraybatchinfo); $dlc = $firstrecord['eatby']; $dluo = $firstrecord['sellby']; - //var_dump($batch); var_dump($arraybatchinfo); var_dump($firstrecord); var_dump($dlc); var_dump($dluo); exit; + //var_dump($batch); var_dump($arraybatchinfo); var_dump($firstrecord); var_dump($dlc); var_dump($dluo); exit; } else { $dlc = ''; $dluo = ''; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 620b1127e91..372e3510fcf 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -2494,7 +2494,7 @@ class Project extends CommonObject $return .= '
'; if ($this->public) { $return .= img_picto($langs->trans('Visibility').': '.$langs->trans('SharedProject'), 'world', 'class="paddingrightonly valignmiddle"'); - //print $langs->trans('SharedProject'); + //print $langs->trans('SharedProject'); } else { $return .= img_picto($langs->trans('Visibility').': '.$langs->trans('PrivateProject'), 'private', 'class="paddingrightonly valignmiddle"'); //print $langs->trans('PrivateProject'); diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 93d913f3272..d91f9177aa3 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -297,7 +297,7 @@ if (count($tasksarray) > 0) { if ($val->fk_parent != 0 && $task->hasChildren() > 0) { $tasks[$taskcursor]['task_is_group'] = 1; $tasks[$taskcursor]['task_css'] = 'ggroupblack'; - //$tasks[$taskcursor]['task_css'] = 'gtaskblue'; + //$tasks[$taskcursor]['task_css'] = 'gtaskblue'; } elseif ($task->hasChildren() > 0) { $tasks[$taskcursor]['task_is_group'] = 1; //$tasks[$taskcursor]['task_is_group'] = 0; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 35302f28ad1..1d5a8d85bd8 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -1773,7 +1773,7 @@ while ($i < $imaxinloop) { print ''; } elseif (isset($totalarray['totalvaluefield']) && $totalarray['totalvaluefield'] == $i) { print ''; - //} elseif ($totalarray['totalvaluebilledfield'] == $i) { print ''; + //} elseif ($totalarray['totalvaluebilledfield'] == $i) { print ''; } else { print ''; } diff --git a/htdocs/public/company/new.php b/htdocs/public/company/new.php index c011847f9d2..de5e4d4f179 100644 --- a/htdocs/public/company/new.php +++ b/htdocs/public/company/new.php @@ -244,7 +244,7 @@ if (empty($reshook) && $action == 'add') { $urlback = $backtopage; } elseif (getDolGlobalString('MEMBER_URL_REDIRECT_SUBSCRIPTION')) { $urlback = $conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION; - // TODO Make replacement of __AMOUNT__, etc... + // TODO Make replacement of __AMOUNT__, etc... } else { $urlback = $_SERVER["PHP_SELF"] . "?action=added&token=" . newToken(); } diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index a9b3aa0ae34..2841a239015 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -440,7 +440,7 @@ if (empty($reshook) && $action == 'add') { $urlback = $backtopage; } elseif (getDolGlobalString('MEMBER_URL_REDIRECT_SUBSCRIPTION')) { $urlback = $conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION; - // TODO Make replacement of __AMOUNT__, etc... + // TODO Make replacement of __AMOUNT__, etc... } else { $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken(); } diff --git a/htdocs/public/partnership/new.php b/htdocs/public/partnership/new.php index 792bf93f4f7..73c2e3baa17 100644 --- a/htdocs/public/partnership/new.php +++ b/htdocs/public/partnership/new.php @@ -423,7 +423,7 @@ if (empty($reshook) && $action == 'add') { $urlback = $backtopage; } elseif (getDolGlobalString('PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION')) { $urlback = $conf->global->PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION; - // TODO Make replacement of __AMOUNT__, etc... + // TODO Make replacement of __AMOUNT__, etc... } else { $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken(); } diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index e8b76c41645..b2dadb42058 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -382,7 +382,7 @@ if ($action == 'dopayment') { if (empty($PAYPAL_API_PRICE) || !is_numeric($PAYPAL_API_PRICE)) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")); $action = ''; - // } elseif (empty($EMAIL)) { $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail")); + // } elseif (empty($EMAIL)) { $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail")); // } elseif (! isValidEMail($EMAIL)) { $mesg=$langs->trans("ErrorBadEMail",$EMAIL); } elseif (!$origfulltag) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentCode")); @@ -2542,29 +2542,29 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme billing_details: { name: 'test' thirdparty) && !empty($object->thirdparty->email))) { - ?>, email: 'thirdparty->email); ?>' + ?>, email: 'thirdparty->email); ?>'thirdparty) && !empty($object->thirdparty->phone)) { - ?>, phone: 'thirdparty->phone); ?>' + ?>, phone: 'thirdparty->phone); ?>'thirdparty)) { - ?>, address: { + ?>, address: { city: 'thirdparty->town); ?>', thirdparty->country_code) { - ?>country: 'thirdparty->country_code); ?>', + ?>country: 'thirdparty->country_code); ?>', line1: 'thirdparty->address)); ?>', postal_code: 'thirdparty->zip); ?>' } + } ?> } }, save_payment_method: /* true when a customer was provided when creating payment intent. true ask to save the card */ + print 'true'; + } else { + print 'false'; + } ?> /* true when a customer was provided when creating payment intent. true ask to save the card */ }, } ).then(function(result) { @@ -2636,29 +2636,29 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme billing_details: { name: cardholderName.value thirdparty) && !empty($object->thirdparty->email))) { - ?>, email: 'thirdparty->email); ?>' + ?>, email: 'thirdparty->email); ?>'thirdparty) && !empty($object->thirdparty->phone)) { - ?>, phone: 'thirdparty->phone); ?>' + ?>, phone: 'thirdparty->phone); ?>'thirdparty)) { - ?>, address: { + ?>, address: { city: 'thirdparty->town); ?>', thirdparty->country_code) { - ?>country: 'thirdparty->country_code); ?>', + ?>country: 'thirdparty->country_code); ?>', line1: 'thirdparty->address)); ?>', postal_code: 'thirdparty->zip); ?>' } + } ?> } }, save_payment_method: /* true when a customer was provided when creating payment intent. true ask to save the card */ + print 'true'; + } else { + print 'false'; + } ?> /* true when a customer was provided when creating payment intent. true ask to save the card */ } ).then(function(result) { console.log(result); diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index e1bff57f33d..1a548dd382f 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -1867,7 +1867,7 @@ if ($ispaymentok) { $result = $mailfile->sendfile(); if ($result) { dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); - //dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0); + //dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0); } else { dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); //dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0); diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index 81178c5b087..9b35ac796ac 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -397,7 +397,7 @@ if (empty($reshook) && $action == 'add') { $urlback = $backtopage; } elseif (getDolGlobalString('PROJECT_URL_REDIRECT_LEAD')) { $urlback = $conf->global->PROJECT_URL_REDIRECT_LEAD; - // TODO Make replacement of __AMOUNT__, etc... + // TODO Make replacement of __AMOUNT__, etc... } else { $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken(); } diff --git a/htdocs/public/test/test_arrays.php b/htdocs/public/test/test_arrays.php index 6a32b5f4aff..3b0d17bbf98 100644 --- a/htdocs/public/test/test_arrays.php +++ b/htdocs/public/test/test_arrays.php @@ -89,7 +89,7 @@ if (empty($usedolheader)) { */ llxHeader('', '', '', '', 0, 0, $arrayjs, $arraycss); - } +} // CONTENT diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 0c486d20303..5d408ebf796 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -414,7 +414,7 @@ if (empty($reshook)) { $discountid = $discount->create($user); if ($discountid > 0) { $result = $objecttmp->insert_discount($discountid); - //$result=$discount->link_to_invoice($lineid,$id); + //$result=$discount->link_to_invoice($lineid,$id); } else { setEventMessages($discount->error, $discount->errors, 'errors'); $error++; diff --git a/htdocs/reception/tpl/linkedobjectblock.tpl.php b/htdocs/reception/tpl/linkedobjectblock.tpl.php index d2832f687a9..51a9e3aedc1 100644 --- a/htdocs/reception/tpl/linkedobjectblock.tpl.php +++ b/htdocs/reception/tpl/linkedobjectblock.tpl.php @@ -51,8 +51,8 @@ foreach ($linkedObjectBlock as $key => $objectlink) { diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 8b1aeca2eb3..5542bdd344d 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -452,7 +452,7 @@ if ($action == "update_extras" && $permissiontoadd) { if (GETPOSTISSET($attributekeylong.'day') && GETPOSTISSET($attributekeylong.'month') && GETPOSTISSET($attributekeylong.'year')) { // This is properties of a date $object->array_options['options_'.$attributekey] = dol_mktime(GETPOST($attributekeylong.'hour', 'int'), GETPOST($attributekeylong.'min', 'int'), GETPOST($attributekeylong.'sec', 'int'), GETPOST($attributekeylong.'month', 'int'), GETPOST($attributekeylong.'day', 'int'), GETPOST($attributekeylong.'year', 'int')); - //var_dump(dol_print_date($object->array_options['options_'.$attributekey]));exit; + //var_dump(dol_print_date($object->array_options['options_'.$attributekey]));exit; } else { $object->array_options['options_'.$attributekey] = GETPOST($attributekeylong, 'alpha'); } diff --git a/htdocs/societe/checkvat/checkVatPopup.php b/htdocs/societe/checkvat/checkVatPopup.php index 008d63e8a2d..dd38649b545 100644 --- a/htdocs/societe/checkvat/checkVatPopup.php +++ b/htdocs/societe/checkvat/checkVatPopup.php @@ -118,7 +118,7 @@ if (!$vatNumber) { } print $langs->trans("VATIntraSyntaxIsValid").': '.$langs->trans("No").' (Might be a non europeen VAT)
'; print $langs->trans("ValueIsValid").': '.$langs->trans("No").' (Might be a non europeen VAT)
'; - //$messagetoshow=$soapclient->response; + //$messagetoshow=$soapclient->response; } else { // Syntaxe ok if ($result['requestDate']) { diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index cda63c586d6..57e4657148e 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -555,7 +555,7 @@ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id"; // We'll need this table joined to the select in order to filter by sale if ($search_sale == -2) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; -//elseif ($search_sale || (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + //elseif ($search_sale || (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } elseif (!empty($search_sale) && $search_sale != '-1' || (!$user->hasRight('societe', 'client', 'voir') && !$socid)) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 89145d30087..ffa6f523208 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -707,7 +707,7 @@ if (empty($reshook)) { if (empty($newsup)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = '".$db->escape($tmpservice)."' AND entity = ".$conf->entity; - // TODO Add site and site_account on oauth_token table + // TODO Add site and site_account on oauth_token table //$sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE site = 'stripe' AND (site_account IS NULL or site_account = '".$db->escape($site_account)."') AND fk_soc = ".((int) $object->id)." AND service = '".$db->escape($service)."' AND entity = ".$conf->entity; } else { try { diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index d39e6b9a91d..0d6f2db0d43 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -755,57 +755,57 @@ if ($action == 'create' || $action == 'presend') { $formticket->withcancel = 1; $formticket->showForm(1, 'create', 0, null, $action); -/*} elseif ($action == 'edit' && $user->rights->ticket->write && $object->status < Ticket::STATUS_CLOSED) { -$formticket = new FormTicket($db); + /*} elseif ($action == 'edit' && $user->rights->ticket->write && $object->status < Ticket::STATUS_CLOSED) { + $formticket = new FormTicket($db); -$head = ticket_prepare_head($object); + $head = ticket_prepare_head($object); -print ''; -print ''; -print ''; -print ''; + print ''; + print ''; + print ''; + print ''; -print dol_get_fiche_head($head, 'card', $langs->trans('Ticket'), 0, 'ticket'); + print dol_get_fiche_head($head, 'card', $langs->trans('Ticket'), 0, 'ticket'); -print '
'; -print '
@@ -189,7 +189,7 @@ if (!empty($force_install_noedit)) { value="" + } ?> > " > trans("CheckToForceHttps"); ?> @@ -275,8 +275,8 @@ if (!empty($force_install_noedit)) { name="db_name" value="" + print ' disabled'; + } ?> > trans("DatabaseName"); ?> trans("ServerAddressDescription"); ?> @@ -424,8 +424,8 @@ if (!empty($force_install_noedit)) { id="db_port" value="" + print ' disabled'; + } ?> > trans("ServerPortDescription"); ?> @@ -441,8 +441,8 @@ if (!empty($force_install_noedit)) { name="db_prefix" value="" + print ' disabled'; + } ?> > trans("DatabasePrefixDescription"); ?> trans("AdminPassword"); ?> trans("DatabaseRootLoginDescription"); ?> @@ -593,7 +593,7 @@ if (!empty($force_install_noedit)) { ?>" 0 && !empty($force_install_databaserootpass)) { print ' disabled'; /* May be removed by javascript*/ - } ?> + } ?> > trans("KeepEmptyIfNoPassword"); ?> diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index 4ce9551d246..43ce0075f73 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -645,7 +645,7 @@ if (!$error && $db->connected && $action == "set") { $check2 = $newdb->getDefaultCollationDatabase(); dolibarr_install_syslog('step1: new database is using charset='.$check1.' collation='.$check2); - // If values differs, we save conf file again + // If values differs, we save conf file again //if ($check1 != $dolibarr_main_db_character_set) dolibarr_install_syslog('step1: value for character_set is not the one asked for database creation', LOG_WARNING); //if ($check2 != $dolibarr_main_db_collation) dolibarr_install_syslog('step1: value for collation is not the one asked for database creation', LOG_WARNING); } else { diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index f96d7b8719e..471ea718a41 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -3310,7 +3310,7 @@ function migrate_actioncomm_element($db, $langs, $conf) if ($resql) { $db->commit(); - // DDL commands must not be inside a transaction + // DDL commands must not be inside a transaction // We will drop at next version because a migrate should be runnable several times if it fails. //$sqlDrop = "ALTER TABLE ".MAIN_DB_PREFIX."actioncomm DROP COLUMN ".$field; //$db->query($sqlDrop); diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 03171f5be86..12f81cf60e4 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -3137,7 +3137,7 @@ if (is_array($listofmodules) && count($listofmodules) > 0) { $urlpage = $page; if ($i++) { $linktoenabledisable .= ' '.img_picto(ucfirst($page), "setup").''; - // print ''.ucfirst($page).' '; + // print ''.ucfirst($page).' '; } else { if (preg_match('/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) { $urltouse = dol_buildpath('/'.$regs[2].'/admin/'.$regs[1], 1); @@ -3913,7 +3913,7 @@ if ($module == 'initmodule') { */ print ''; print ''.$attribute.''.$attribute.'
getLibStatut(2, 0) ?> getLibStatut(2, 1) ?>'; if ($obj->public) { print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"'); - //print $langs->trans('SharedProject'); + //print $langs->trans('SharedProject'); } else { print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"'); //print $langs->trans('PrivateProject'); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 48e941aae91..a273b7bd381 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -2816,7 +2816,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print '' . convertSecondToTime($totalarray['totalduration'], 'allhourmin') . '' . price($totalarray['totalvalue']) . ''.price($totalarray['totalvaluebilled']).''.price($totalarray['totalvaluebilled']).'
trans("Reception"); ?> global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { - print ' + print ' getNomUrl(1); ?> ref_supplier); ?>\n"; //if ($conf->global->COMPANY_ADDON_PDF != "$name") //{ - print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; + print 'scandir.'&label='.urlencode($module->name).'">'; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; //} //else //{ @@ -695,9 +695,9 @@ foreach ($profid as $key => $val) { $idprof_mandatory = 'SOCIETE_'.$key.'_MANDATORY'; $idprof_invoice_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY'; - $verif = (empty($conf->global->$idprof_unique) ?false:true); - $mandatory = (empty($conf->global->$idprof_mandatory) ?false:true); - $invoice_mandatory = (empty($conf->global->$idprof_invoice_mandatory) ?false:true); + $verif = (empty($conf->global->$idprof_unique) ? false : true); + $mandatory = (empty($conf->global->$idprof_mandatory) ? false : true); + $invoice_mandatory = (empty($conf->global->$idprof_invoice_mandatory) ? false : true); if ($verif) { print ''; diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index a32782fab17..41d5460566e 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; // Load translation files required by the page $langs->loadLangs(array('agenda', 'bills', 'companies', 'orders', 'propal')); -$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thirdpartyagenda'; +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'thirdpartyagenda'; if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); @@ -46,13 +46,13 @@ if (GETPOST('actioncode', 'array')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); + $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); -$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -210,9 +210,9 @@ if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $cachekey = 'count_events_thirdparty_'.$object->id; $nbEvent = dol_getcache($cachekey); - $titlelist = $langs->trans("ActionsOnCompany").(is_numeric($nbEvent) ? '('.$nbEvent.')': ''); + $titlelist = $langs->trans("ActionsOnCompany").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); if (!empty($conf->dol_optimize_smallscreen)) { - $titlelist = $langs->trans("Actions").(is_numeric($nbEvent) ? '('.$nbEvent.')': ''); + $titlelist = $langs->trans("Actions").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); } print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0); diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index f625b94bed7..19cee63dcb1 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -106,7 +106,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) { $id = (!empty($match[0]) ? $match[0] : ''); // Take first key found into GET array with matching $htmlname123 // When used from jQuery, the search term is added as GET param "term". - $searchkey = (($id && GETPOST($id, 'alpha')) ? GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ?GETPOST($htmlname, 'alpha') : '')); + $searchkey = (($id && GETPOST($id, 'alpha')) ? GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ? GETPOST($htmlname, 'alpha') : '')); if (!$searchkey) { return; } diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index b9119174058..b129fde860e 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -203,7 +203,7 @@ abstract class ActionsCardCommon break; } } - $modCodeFournisseur = new $module; + $modCodeFournisseur = new $module(); $this->tpl['auto_suppliercode'] = $modCodeFournisseur->code_auto; // We verified if the tag prefix is used if ($modCodeFournisseur->code_auto) { diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b280efc4536..cb3ca2527ac 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -110,7 +110,7 @@ if (!empty($backtopagejsfields)) { $dol_openinpopup = $tmpbacktopagejsfields[0]; } -$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); +$socid = GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'); if ($user->socid) { $socid = $user->socid; } @@ -347,8 +347,8 @@ if (empty($reshook)) { $object->idprof5 = trim(GETPOST('idprof5', 'alphanohtml')); $object->idprof6 = trim(GETPOST('idprof6', 'alphanohtml')); $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml'); - $object->code_client = GETPOSTISSET('customer_code') ?GETPOST('customer_code', 'alpha') : GETPOST('code_client', 'alpha'); - $object->code_fournisseur = GETPOSTISSET('supplier_code') ?GETPOST('supplier_code', 'alpha') : GETPOST('code_fournisseur', 'alpha'); + $object->code_client = GETPOSTISSET('customer_code') ? GETPOST('customer_code', 'alpha') : GETPOST('code_client', 'alpha'); + $object->code_fournisseur = GETPOSTISSET('supplier_code') ? GETPOST('supplier_code', 'alpha') : GETPOST('code_fournisseur', 'alpha'); $object->capital = GETPOST('capital', 'alphanohtml'); $object->barcode = GETPOST('barcode', 'alphanohtml'); @@ -413,7 +413,7 @@ if (empty($reshook)) { // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { - $error++; + $error++; } // Fill array 'array_languages' with data from add form @@ -446,7 +446,8 @@ if (empty($reshook)) { } if (!isValidUrl($object->webservices_url)) { $langs->load("errors"); - $error++; $errors[] = $langs->trans("ErrorBadUrl", $object->webservices_url); + $error++; + $errors[] = $langs->trans("ErrorBadUrl", $object->webservices_url); } } @@ -837,7 +838,7 @@ if (empty($reshook)) { // Actions to build doc $id = $socid; - $upload_dir = !empty($conf->societe->multidir_output[$object->entity])?$conf->societe->multidir_output[$object->entity]:$conf->societe->dir_output; + $upload_dir = !empty($conf->societe->multidir_output[$object->entity]) ? $conf->societe->multidir_output[$object->entity] : $conf->societe->dir_output; $permissiontoadd = $user->hasRight('societe', 'creer'); include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } @@ -915,7 +916,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio break; } } - $modCodeClient = new $module; + $modCodeClient = new $module(); // Load object modCodeFournisseur $module = (getDolGlobalString('SOCIETE_CODECLIENT_ADDON') ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard'); if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') { @@ -928,7 +929,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio break; } } - $modCodeFournisseur = new $module; + $modCodeFournisseur = new $module(); // Define if customer/prospect or supplier status is set or not if (GETPOST("type", 'aZ') != 'f') { @@ -962,7 +963,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $object->firstname = GETPOST('firstname', 'alphanohtml'); $object->particulier = $private; $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml'); - $object->client = GETPOST('client', 'int') ?GETPOST('client', 'int') : $object->client; + $object->client = GETPOST('client', 'int') ? GETPOST('client', 'int') : $object->client; if (empty($duplicate_code_error)) { $object->code_client = GETPOST('customer_code', 'alpha'); @@ -1037,11 +1038,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio } } - $object->logo = (isset($_FILES['photo']) ?dol_sanitizeFileName($_FILES['photo']['name']) : ''); + $object->logo = (isset($_FILES['photo']) ? dol_sanitizeFileName($_FILES['photo']['name']) : ''); // Company logo management $dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos"; - $file_OK = (isset($_FILES['photo']) ?is_uploaded_file($_FILES['photo']['tmp_name']) : false); + $file_OK = (isset($_FILES['photo']) ? is_uploaded_file($_FILES['photo']['tmp_name']) : false); if ($file_OK) { if (image_format_supported($_FILES['photo']['name'])) { dol_mkdir($dir); @@ -1061,7 +1062,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio } // We set country_id, country_code and country for the selected country - $object->country_id = GETPOST('country_id') ?GETPOST('country_id') : $mysoc->country_id; + $object->country_id = GETPOST('country_id') ? GETPOST('country_id') : $mysoc->country_id; if ($object->country_id) { $tmparray = getCountry($object->country_id, 'all'); $object->country_code = $tmparray['code']; @@ -1346,7 +1347,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio // Prospect/Customer print '
'.$form->editfieldkey('ProspectCustomer', 'customerprospect', '', $object, 0, 'string', '', 1).''; - $selected = (GETPOSTISSET('client') ?GETPOST('client', 'int') : $object->client); + $selected = (GETPOSTISSET('client') ? GETPOST('client', 'int') : $object->client); print $formcompany->selectProspectCustomerType($selected); print '
'.$form->editfieldkey('Phone', 'phone', '', $object, 0).'
'.$form->editfieldkey('Fax', 'fax', '', $object, 0).'
'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', !getDolGlobalString('SOCIETE_EMAIL_MANDATORY') ? '' : $conf->global->SOCIETE_EMAIL_MANDATORY).'
'.$form->editfieldkey('VATIsUsed', 'assujtva_value', '', $object, 0).''; - print ''; // Assujeti par defaut en creation + print ''; // Assujeti par defaut en creation print '
'.$form->editfieldkey('ThirdPartyType', 'typent_id', '', $object, 0).'browser->layout == 'phone' || getDolGlobalString('SOCIETE_DISABLE_WORKFORCE')) ? ' colspan="3"' : '').'>'."\n"; + print '
'.$form->editfieldkey('ThirdPartyType', 'typent_id', '', $object, 0).'browser->layout == 'phone' || getDolGlobalString('SOCIETE_DISABLE_WORKFORCE')) ? ' colspan="3"' : '').'>'."\n"; $sortparam = (!getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 1, 0, 0, '', 0, 0, 0, $sortparam, '', 1); if ($user->admin) { @@ -1844,7 +1847,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $object->address = GETPOST('address', 'alphanohtml'); $object->zip = GETPOST('zipcode', 'alphanohtml'); $object->town = GETPOST('town', 'alphanohtml'); - $object->country_id = GETPOST('country_id') ?GETPOST('country_id', 'int') : $mysoc->country_id; + $object->country_id = GETPOST('country_id') ? GETPOST('country_id', 'int') : $mysoc->country_id; $object->state_id = GETPOST('state_id', 'int'); $object->parent = GETPOST('parent_company_id', 'int'); @@ -2165,13 +2168,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print '
'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).'
'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).'
'.$form->editfieldkey('Town', 'town', '', $object, 0).''.$form->editfieldkey('Town', 'town', '', $object, 0).'
'.$form->editfieldkey('Phone', 'phone', GETPOST('phone', 'alpha'), $object, 0).'
'.$form->editfieldkey('Fax', 'fax', GETPOST('fax', 'alpha'), $object, 0).'
'.$form->editfieldkey('Web', 'url', GETPOST('url', 'alpha'), $object, 0).''.img_picto('', 'globe', 'class="pictofixedwidth"').'
'.img_picto('', 'globe', 'class="pictofixedwidth"').'
'.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (getDolGlobalString('SOCIETE_EMAIL_MANDATORY'))).''; print img_picto('', 'object_email', 'class="pictofixedwidth"'); - print ''; + print ''; print '
'.$form->editfieldkey('VATIsUsed', 'assujtva_value', '', $object, 0).''; - print 'tva_assuj ? 'checked="checked"': '') . ' value="1">'; + print 'tva_assuj ? 'checked="checked"' : '') . ' value="1">'; print '
'.$form->editfieldkey('ThirdPartyType', 'typent_id', '', $object, 0).'browser->layout == 'phone' || getDolGlobalString('SOCIETE_DISABLE_WORKFORCE')) ? ' colspan="3"' : '').'>'; + print '
'.$form->editfieldkey('ThirdPartyType', 'typent_id', '', $object, 0).'browser->layout == 'phone' || getDolGlobalString('SOCIETE_DISABLE_WORKFORCE')) ? ' colspan="3"' : '').'>'; print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 1, 0, 0, '', 0, 0, 0, (!getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1); if ($user->admin) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); @@ -2422,7 +2425,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio // Incoterms if (isModEnabled('incoterm')) { print '
'.$form->editfieldkey('IncotermLabel', 'incoterm_id', '', $object, 0).''.$form->editfieldkey('IncotermLabel', 'incoterm_id', '', $object, 0).''; print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); print '
getLibStatut(2, 0) ?> getLibStatut(2, 1) ?>'; if ($obj->public) { print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"'); - //print $langs->trans('SharedProject'); + //print $langs->trans('SharedProject'); } else { print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"'); //print $langs->trans('PrivateProject'); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index a273b7bd381..48e941aae91 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -2816,7 +2816,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print '' . convertSecondToTime($totalarray['totalduration'], 'allhourmin') . '' . price($totalarray['totalvalue']) . ''.price($totalarray['totalvaluebilled']).''.price($totalarray['totalvaluebilled']).'
trans("Reception"); ?> global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { - print ' + print ' getNomUrl(1); ?> ref_supplier); ?>
'; + print '
'; + print '
'; -// Type -print ''; + // Type + print ''; -// Severity -print ''; + // Severity + print ''; -// Group -print ''; + // Group + print ''; -// Subject -print ''; + // Subject + print ''; -// Other attributes -$parameters = array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); -$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; -if (empty($reshook)) { -print $object->showOptionals($extrafields, 'edit'); -} + // Other attributes + $parameters = array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (empty($reshook)) { + print $object->showOptionals($extrafields, 'edit'); + } -print '
'; -$formticket->selectTypesTickets((GETPOSTISSET('type_code') ? GETPOST('type_code') : $object->type_code), 'type_code', '', '2'); -print '
'; + $formticket->selectTypesTickets((GETPOSTISSET('type_code') ? GETPOST('type_code') : $object->type_code), 'type_code', '', '2'); + print '
'; -$formticket->selectSeveritiesTickets((GETPOSTISSET('severity_code') ? GETPOST('severity_code') : $object->severity_code), 'severity_code', '', '2'); -print '
'; + $formticket->selectSeveritiesTickets((GETPOSTISSET('severity_code') ? GETPOST('severity_code') : $object->severity_code), 'severity_code', '', '2'); + print '
'; -$formticket->selectGroupTickets((GETPOSTISSET('category_code') ? GETPOST('category_code') : $object->category_code), 'category_code', '', '2'); -print '
'; + $formticket->selectGroupTickets((GETPOSTISSET('category_code') ? GETPOST('category_code') : $object->category_code), 'category_code', '', '2'); + print '
'; -print ''; -print '
'; + print ''; + print '
'; -print ''; + print ''; + print ''; -print dol_get_fiche_end(); + print dol_get_fiche_end(); -print $form->buttonsSaveCancel(); + print $form->buttonsSaveCancel(); -print ''; */ + print ''; */ } elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'abandon' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'categories' || $action == 'reopen' || $action== 'edit_contrat' || $action == 'editsubject' || $action == 'edit_extras' || $action == 'update_extras' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink') { if ($res > 0) { diff --git a/htdocs/ticket/tpl/linkedobjectblock.tpl.php b/htdocs/ticket/tpl/linkedobjectblock.tpl.php index 359a20fb0d6..e4ccd67308c 100644 --- a/htdocs/ticket/tpl/linkedobjectblock.tpl.php +++ b/htdocs/ticket/tpl/linkedobjectblock.tpl.php @@ -47,8 +47,8 @@ foreach ($linkedObjectBlock as $key => $objectlink) { trans("Ticket"); ?> global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { - print ' + print ' getNomUrl(1); ?> ref_client; ?> diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 092e7752da5..05826f80dbc 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2321,7 +2321,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''.$form->editfieldkey('Employee', 'employee', '', $object, 0).''; if ($caneditfield) { print 'employee ? ' checked="checked"' : '').'>'; - //print $form->selectyesno("employee", $object->employee, 1); + //print $form->selectyesno("employee", $object->employee, 1); } else { print 'employee ? ' checked="checked"' : '').'>'; /*if ($object->employee) { diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index c35390a4953..e7913c9750c 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -518,7 +518,7 @@ if (!empty($id) || !empty($ref)) { $listofvariantselected .= '
    ' . implode(' ', $toprint) . '
'; } $listofvariantselected .= ''; - //print dol_get_fiche_end(); + //print dol_get_fiche_end(); } else { $title = $langs->trans('EditProductCombination'); } @@ -654,12 +654,12 @@ if (!empty($id) || !empty($ref)) { trans("GoOnMenuToCreateVairants", $langs->transnoentities("Product"), $langs->transnoentities("VariantAttributes")); - print $form->textwithpicto('', $htmltext); - /* - print '    
id).'">'; - print $langs->trans("Create"); - print ''; - */ ?> + print $form->textwithpicto('', $htmltext); + /* + print '     id).'">'; + print $langs->trans("Create"); + print ''; + */ ?> @@ -778,7 +778,7 @@ if (!empty($id) || !empty($ref)) {
value="trans('Create') : $langs->trans("Save") ?>" class="button button-save"> + } ?> value="trans('Create') : $langs->trans("Save") ?>" class="button button-save">   " class="button button-cancel">
diff --git a/htdocs/variants/tpl/productattributevalueline_create.tpl.php b/htdocs/variants/tpl/productattributevalueline_create.tpl.php index afa6e34acef..7eeee0636cd 100644 --- a/htdocs/variants/tpl/productattributevalueline_create.tpl.php +++ b/htdocs/variants/tpl/productattributevalueline_create.tpl.php @@ -53,8 +53,8 @@ $nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines); ?> trans('Ref') . ': '; - } ?> + echo $langs->trans('Ref') . ': '; + } ?> " autofocus> trans("ErrorFileDoesNotExists",$original_file)); - exit; - } + // This test if file exists should be useless. We keep it to find bug more easily + if (! file_exists($original_file_osencoded)) + { + dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file)); + exit; + } - //include_once $original_file_osencoded; - */ + //include_once $original_file_osencoded; + */ /*print '';*/ From 72006c6b763112357eba1714701ae57fadde407a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Dec 2023 14:23:18 +0100 Subject: [PATCH 077/107] Work on rector to fix warnings --- .../rector/src/Renaming/GlobalToFunction.php | 18 ++++++++++----- htdocs/adherents/admin/member.php | 16 +++++++------- htdocs/adherents/admin/website.php | 16 +++++++------- htdocs/adherents/cartes/carte.php | 22 +++++++++---------- htdocs/adherents/stats/byproperties.php | 2 +- htdocs/adherents/stats/geo.php | 2 +- 6 files changed, 41 insertions(+), 35 deletions(-) diff --git a/dev/tools/rector/src/Renaming/GlobalToFunction.php b/dev/tools/rector/src/Renaming/GlobalToFunction.php index 7ca0588db83..03b797c81b1 100644 --- a/dev/tools/rector/src/Renaming/GlobalToFunction.php +++ b/dev/tools/rector/src/Renaming/GlobalToFunction.php @@ -101,11 +101,14 @@ class GlobalToFunction extends AbstractRector if ($node instanceof FuncCall) { $tmpfunctionname = $this->getName($node); - if (in_array($tmpfunctionname, array('dol_escape_htmltag'))) { - $nbofparam = count($node->getArgs()); - if ($nbofparam == 1) { - $args = $node->getArgs(); - foreach ($args as $arg) { // only 1 element in this array + if (in_array($tmpfunctionname, array('dol_escape_htmltag', 'make_substitutions', 'min', 'max'))) { + $args = $node->getArgs(); + $nbofparam = count($args); + + if ($nbofparam >= 1) { + $tmpargs = $args; + foreach ($args as $key => $arg) { // only 1 element in this array + //var_dump($key); //var_dump($arg->value);exit; if ($this->isGlobalVar($arg->value)) { $constName = $this->getConstName($arg->value); @@ -113,7 +116,10 @@ class GlobalToFunction extends AbstractRector return; } $a = new FuncCall(new Name('getDolGlobalString'), [new Arg($constName)]); - return new FuncCall(new Name($tmpfunctionname), [new Arg($a)]); + $tmpargs[$key] = new Arg($a); + + $r = new FuncCall(new Name($tmpfunctionname), $tmpargs); + return $r; } } } diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index 06cd83397c4..06416f19039 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -353,12 +353,12 @@ print "\n"; print ''; print $langs->trans("MemberSubscriptionStartAfter"); print ''; -print ''; +print ''; print "\n"; // Mail required for members print ''.$langs->trans("AdherentMailRequired").''; -print $form->selectyesno('ADHERENT_MAIL_REQUIRED', (getDolGlobalString('ADHERENT_MAIL_REQUIRED') ? $conf->global->ADHERENT_MAIL_REQUIRED : 0), 1); +print $form->selectyesno('ADHERENT_MAIL_REQUIRED', getDolGlobalInt('ADHERENT_MAIL_REQUIRED'), 1); print "\n"; // Login/Pass required for members @@ -370,24 +370,24 @@ print "\n"; // Send mail information is on by default print ''.$langs->trans("MemberSendInformationByMailByDefault").''; -print $form->selectyesno('ADHERENT_DEFAULT_SENDINFOBYMAIL', (getDolGlobalString('ADHERENT_DEFAULT_SENDINFOBYMAIL') ? $conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL : 0), 1); +print $form->selectyesno('ADHERENT_DEFAULT_SENDINFOBYMAIL', getDolGlobalInt('ADHERENT_DEFAULT_SENDINFOBYMAIL', 0), 1); print "\n"; // Create an external user login for each new member subscription validated print ''.$langs->trans("MemberCreateAnExternalUserForSubscriptionValidated").''; -print $form->selectyesno('ADHERENT_CREATE_EXTERNAL_USER_LOGIN', (getDolGlobalString('ADHERENT_CREATE_EXTERNAL_USER_LOGIN') ? $conf->global->ADHERENT_CREATE_EXTERNAL_USER_LOGIN : 0), 1); +print $form->selectyesno('ADHERENT_CREATE_EXTERNAL_USER_LOGIN', getDolGlobalInt('ADHERENT_CREATE_EXTERNAL_USER_LOGIN', 0), 1); print "\n"; // Create an external user login for each new member subscription validated -$linkofpubliclist = DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.((isModEnabled('multicompany')) ? '?entity='.$conf->entity : ''); +$linkofpubliclist = DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.((isModEnabled('multicompany')) ? '?entity='.((int) $conf->entity) : ''); print ''.$langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist).''; -print $form->selectyesno('MEMBER_PUBLIC_ENABLED', (getDolGlobalString('MEMBER_PUBLIC_ENABLED') ? $conf->global->MEMBER_PUBLIC_ENABLED : 0), 1); +print $form->selectyesno('MEMBER_PUBLIC_ENABLED', getDolGlobalInt('MEMBER_PUBLIC_ENABLED', 0), 1); print "\n"; // Allow members to change type on renewal forms /* To test during next beta print ''.$langs->trans("MemberAllowchangeOfType").''; -print $form->selectyesno('MEMBER_ALLOW_CHANGE_OF_TYPE', (!empty($conf->global->MEMBER_ALLOW_CHANGE_OF_TYPE) ? 0 : 1), 1); +print $form->selectyesno('MEMBER_ALLOW_CHANGE_OF_TYPE', (getDolGlobalInt('MEMBER_ALLOW_CHANGE_OF_TYPE') ? 0 : 1), 1); print "\n"; */ @@ -416,7 +416,7 @@ if (isModEnabled('facture')) { print ''.$langs->trans("VATToUseForSubscriptions").''; if (isModEnabled("banque")) { print ''; - print $form->selectarray('ADHERENT_VAT_FOR_SUBSCRIPTIONS', array('0'=>$langs->trans("NoVatOnSubscription"), 'defaultforfoundationcountry'=>$langs->trans("Default")), (!getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') ? '0' : $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS), 0); + print $form->selectarray('ADHERENT_VAT_FOR_SUBSCRIPTIONS', array('0'=>$langs->trans("NoVatOnSubscription"), 'defaultforfoundationcountry'=>$langs->trans("Default")), getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS', '0'), 0); print ''; } else { print ''; diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index 4a9ba7ee1c7..8ac296f9449 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -215,7 +215,7 @@ if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) { print ''; $listofval = array(); $listofval += $adht->liste_array(1); - $forcetype = !getDolGlobalString('MEMBER_NEWFORM_FORCETYPE') ? -1 : $conf->global->MEMBER_NEWFORM_FORCETYPE; + $forcetype = getDolGlobalInt('MEMBER_NEWFORM_FORCETYPE', -1); print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval) > 1 ? 1 : 0); print "\n"; @@ -225,7 +225,7 @@ if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) { print ''; print $langs->trans("ForceMemberNature"); print ''; - $forcenature = !getDolGlobalString('MEMBER_NEWFORM_FORCEMORPHY') ? 0 : $conf->global->MEMBER_NEWFORM_FORCEMORPHY; + $forcenature = getDolGlobalInt('MEMBER_NEWFORM_FORCEMORPHY', 0); print $form->selectarray("MEMBER_NEWFORM_FORCEMORPHY", $morphys, $forcenature, 1); print "\n"; @@ -233,25 +233,25 @@ if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) { print ''; print $langs->trans("DefaultAmount"); print ''; - print ''; + print ''; print "\n"; // Min amount print ''; print $langs->trans("MinimumAmount"); print ''; - print ''; + print ''; print "\n"; // SHow counter of validated members publicly print ''; print $langs->trans("MemberCountersArePublic"); print ''; - print $form->selectyesno("MEMBER_COUNTERS_ARE_PUBLIC", (getDolGlobalString('MEMBER_COUNTERS_ARE_PUBLIC') ? $conf->global->MEMBER_COUNTERS_ARE_PUBLIC : 0), 1); + print $form->selectyesno("MEMBER_COUNTERS_ARE_PUBLIC", getDolGlobalInt('MEMBER_COUNTERS_ARE_PUBLIC'), 1); print "\n"; // Show the table of all available membership types. If not, show a form (as the default was for Dolibarr <=16.0) - $skiptable = (getDolGlobalString('MEMBER_SKIP_TABLE') ? $conf->global->MEMBER_SKIP_TABLE : 0); + $skiptable = getDolGlobalInt('MEMBER_SKIP_TABLE'); print ''; print $langs->trans("MembersShowMembershipTypesTable"); print ''; @@ -259,7 +259,7 @@ if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) { print "\n"; // Show "vote allowed" setting for membership types - $hidevoteallowed = (getDolGlobalString('MEMBER_HIDE_VOTE_ALLOWED') ? $conf->global->MEMBER_HIDE_VOTE_ALLOWED : 0); + $hidevoteallowed = getDolGlobalInt('MEMBER_HIDE_VOTE_ALLOWED'); print ''; print $langs->trans("MembersShowVotesAllowed"); print ''; @@ -282,7 +282,7 @@ if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) { if (isModEnabled('stripe')) { $listofval['stripe'] = 'Stripe'; } - print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, (getDolGlobalString('MEMBER_NEWFORM_PAYONLINE') ? $conf->global->MEMBER_NEWFORM_PAYONLINE : ''), 0); + print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, getDolGlobalString('MEMBER_NEWFORM_PAYONLINE'), 0); print "\n"; print ''; diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index fcfe87209c0..c47e745c8b8 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -150,10 +150,10 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { // For business cards if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') { - $textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); - $textheader = make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); - $textfooter = make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); - $textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); + $textleft = make_substitutions(getDolGlobalString('ADHERENT_CARD_TEXT'), $substitutionarray); + $textheader = make_substitutions(getDolGlobalString('ADHERENT_CARD_HEADER_TEXT'), $substitutionarray); + $textfooter = make_substitutions(getDolGlobalString('ADHERENT_CARD_FOOTER_TEXT'), $substitutionarray); + $textright = make_substitutions(getDolGlobalString('ADHERENT_CARD_TEXT_RIGHT'), $substitutionarray); if (is_numeric($foruserid) || $foruserlogin) { $nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY']; // $_Avery_Labels is defined into an include @@ -190,7 +190,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { if (!getDolGlobalString('ADHERENT_ETIQUETTE_TEXT')) { $conf->global->ADHERENT_ETIQUETTE_TEXT = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__"; } - $textleft = make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray); + $textleft = make_substitutions(getDolGlobalString('ADHERENT_ETIQUETTE_TEXT'), $substitutionarray); $textheader = ''; $textfooter = ''; $textright = ''; @@ -275,7 +275,7 @@ dol_htmloutput_errors($mesg); print '
'; -print img_picto('', 'card').' '.$langs->trans("DocForAllMembersCards", (getDolGlobalString('ADHERENT_CARD_TYPE') ? $conf->global->ADHERENT_CARD_TYPE : $langs->transnoentitiesnoconv("None"))).' '; +print img_picto('', 'card').' '.$langs->trans("DocForAllMembersCards", getDolGlobalString('ADHERENT_CARD_TYPE', $langs->transnoentitiesnoconv("None"))).' '; print '
'; print ''; print ''; @@ -288,13 +288,13 @@ foreach (array_keys($_Avery_Labels) as $codecards) { $arrayoflabels[$codecards] = $_Avery_Labels[$codecards]['name']; } asort($arrayoflabels); -print $form->selectarray('modelcard', $arrayoflabels, (GETPOST('modelcard') ? GETPOST('modelcard') : (!getDolGlobalString('ADHERENT_CARD_TYPE') ? '' : $conf->global->ADHERENT_CARD_TYPE)), 1, 0, 0, '', 0, 0, 0, '', '', 1); +print $form->selectarray('modelcard', $arrayoflabels, (GETPOST('modelcard') ? GETPOST('modelcard') : getDolGlobalString('ADHERENT_CARD_TYPE')), 1, 0, 0, '', 0, 0, 0, '', '', 1); print '
'; print '
'; print '

'; -print img_picto('', 'card').' '.$langs->trans("DocForOneMemberCards", (getDolGlobalString('ADHERENT_CARD_TYPE') ? $conf->global->ADHERENT_CARD_TYPE : $langs->transnoentitiesnoconv("None"))).' '; +print img_picto('', 'card').' '.$langs->trans("DocForOneMemberCards", getDolGlobalString('ADHERENT_CARD_TYPE', $langs->transnoentitiesnoconv("None"))).' '; print '
'; print ''; print ''; @@ -306,14 +306,14 @@ foreach (array_keys($_Avery_Labels) as $codecards) { $arrayoflabels[$codecards] = $_Avery_Labels[$codecards]['name']; } asort($arrayoflabels); -print $form->selectarray('model', $arrayoflabels, (GETPOST('model') ? GETPOST('model') : (!getDolGlobalString('ADHERENT_CARD_TYPE') ? '' : $conf->global->ADHERENT_CARD_TYPE)), 1, 0, 0, '', 0, 0, 0, '', '', 1); +print $form->selectarray('model', $arrayoflabels, (GETPOST('model') ? GETPOST('model') : getDolGlobalString('ADHERENT_CARD_TYPE')), 1, 0, 0, '', 0, 0, 0, '', '', 1); print '
'.$langs->trans("Login").': '; print '
'; print '
'; print '

'; -print img_picto('', 'card').' '.$langs->trans("DocForLabels", (!getDolGlobalString('ADHERENT_ETIQUETTE_TYPE') ? '' : $conf->global->ADHERENT_ETIQUETTE_TYPE)).' '; +print img_picto('', 'card').' '.$langs->trans("DocForLabels", getDolGlobalString('ADHERENT_ETIQUETTE_TYPE')).' '; print '
'; print ''; print ''; @@ -325,7 +325,7 @@ foreach (array_keys($_Avery_Labels) as $codecards) { $arrayoflabels[$codecards] = $_Avery_Labels[$codecards]['name']; } asort($arrayoflabels); -print $form->selectarray('modellabel', $arrayoflabels, (GETPOST('modellabel') ? GETPOST('modellabel') : (!getDolGlobalString('ADHERENT_ETIQUETTE_TYPE') ? '' : $conf->global->ADHERENT_ETIQUETTE_TYPE)), 1, 0, 0, '', 0, 0, 0, '', '', 1); +print $form->selectarray('modellabel', $arrayoflabels, (GETPOST('modellabel') ? GETPOST('modellabel') : getDolGlobalString('ADHERENT_ETIQUETTE_TYPE')), 1, 0, 0, '', 0, 0, 0, '', '', 1); print '
'; print '
'; diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index 351b7092dd8..d2cd86f7de0 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -41,7 +41,7 @@ if ($user->socid > 0) { $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); $year = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); -$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS))); +$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS')))); $endyear = $year; // Load translation files required by the page diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index 4dc2f756df1..fd64e315ff1 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -43,7 +43,7 @@ if ($user->socid > 0) { $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); $year = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); -$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS))); +$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS')))); $endyear = $year; // Load translation files required by the page From fc1411f9a46de5942adef6bdaf9586c46cc0b8d6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Dec 2023 14:59:22 +0100 Subject: [PATCH 078/107] Work on rector to fix warnings --- .../rector/src/Renaming/GlobalToFunction.php | 28 ++++++++++++++++--- htdocs/adherents/admin/member.php | 2 +- htdocs/adherents/class/adherent.class.php | 17 ++++++----- .../adherents/class/adherent_type.class.php | 2 +- 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/dev/tools/rector/src/Renaming/GlobalToFunction.php b/dev/tools/rector/src/Renaming/GlobalToFunction.php index 03b797c81b1..b498160c895 100644 --- a/dev/tools/rector/src/Renaming/GlobalToFunction.php +++ b/dev/tools/rector/src/Renaming/GlobalToFunction.php @@ -25,6 +25,7 @@ use PhpParser\Node\Expr\BinaryOp\Greater; use PhpParser\Node\Expr\BinaryOp\GreaterOrEqual; use PhpParser\Node\Expr\BinaryOp\Smaller; use PhpParser\Node\Expr\BinaryOp\SmallerOrEqual; +use PhpParser\Node\Expr\BinaryOp\NotIdentical; /** * Class with Rector custom rule to fix code @@ -70,7 +71,7 @@ class GlobalToFunction extends AbstractRector */ public function getNodeTypes(): array { - return [FuncCall::class, Equal::class, Greater::class, GreaterOrEqual::class, Smaller::class, SmallerOrEqual::class, BooleanAnd::class, Concat::class, ArrayDimFetch::class]; + return [FuncCall::class, Equal::class, Greater::class, GreaterOrEqual::class, Smaller::class, SmallerOrEqual::class, NotIdentical::class, BooleanAnd::class, Concat::class, ArrayDimFetch::class]; } /** @@ -101,7 +102,7 @@ class GlobalToFunction extends AbstractRector if ($node instanceof FuncCall) { $tmpfunctionname = $this->getName($node); - if (in_array($tmpfunctionname, array('dol_escape_htmltag', 'make_substitutions', 'min', 'max'))) { + if (in_array($tmpfunctionname, array('dol_escape_htmltag', 'make_substitutions', 'min', 'max', 'explode'))) { $args = $node->getArgs(); $nbofparam = count($args); @@ -126,6 +127,7 @@ class GlobalToFunction extends AbstractRector } return $node; } + if ($node instanceof Concat) { if ($this->isGlobalVar($node->left)) { $constName = $this->getConstName($node->left); @@ -154,6 +156,7 @@ class GlobalToFunction extends AbstractRector } return new Concat($leftConcat, $rightConcat); } + if ($node instanceof BooleanAnd) { $nodes = $this->resolveTwoNodeMatch($node); if (!isset($nodes)) { @@ -164,6 +167,9 @@ class GlobalToFunction extends AbstractRector $node = $nodes->getFirstExpr(); } + // Now process all comparison like: + // $conf->global->... Operator Value + $typeofcomparison = ''; if ($node instanceof Equal) { $typeofcomparison = 'Equal'; @@ -180,6 +186,10 @@ class GlobalToFunction extends AbstractRector if ($node instanceof SmallerOrEqual) { $typeofcomparison = 'SmallerOrEqual'; } + if ($node instanceof NotIdentical) { + $typeofcomparison = 'NotIdentical'; + //var_dump($node->left); + } if (empty($typeofcomparison)) { return; } @@ -189,7 +199,8 @@ class GlobalToFunction extends AbstractRector } // Test the type after the comparison conf->global->xxx to know the name of function - switch ($node->right->getType()) { + $typeright = $node->right->getType(); + switch ($typeright) { case 'Scalar_LNumber': $funcName = 'getDolGlobalInt'; break; @@ -250,6 +261,15 @@ class GlobalToFunction extends AbstractRector $node->right ); } + if ($typeofcomparison == 'NotIdentical') { + return new NotIdentical( + new FuncCall( + new Name($funcName), + [new Arg($constName)] + ), + $node->right + ); + } } /** @@ -262,7 +282,7 @@ class GlobalToFunction extends AbstractRector { return $this->binaryOpManipulator->matchFirstAndSecondConditionNode( $booleanAnd, - // $conf->global == $value + // Function to check if we are in the case $conf->global->... == $value function (Node $node): bool { if (!$node instanceof Equal) { return \false; diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index 06416f19039..b78cd367c9d 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -428,7 +428,7 @@ if (isModEnabled('facture')) { if (isModEnabled("product") || isModEnabled("service")) { print ''.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").''; print ''; - $selected = (!getDolGlobalString('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') ? '' : $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); + $selected = getDolGlobalString('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS'); print img_picto('', 'product', 'class="pictofixedwidth"'); $form->select_produits($selected, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', '', 0); print ''; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 294e0c4689d..51af75d9591 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1151,7 +1151,6 @@ class Adherent extends CommonObject // Mise a jour $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; $sql .= " SET pass_crypted = '".$this->db->escape($password_crypted)."'"; - //if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) if ($isencrypted) { $sql .= ", pass = null"; } else { @@ -1921,7 +1920,7 @@ class Adherent extends CommonObject $outputlangs->setDefaultLang($newlang); } // Generate PDF (whatever is option MAIN_DISABLE_PDF_AUTOUPDATE) so we can include it into email - //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + //if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) $invoice->generateDocument($invoice->model_pdf, $outputlangs); } @@ -2727,7 +2726,7 @@ class Adherent extends CommonObject $keymodified = false; // Object classes - $info["objectclass"] = explode(',', $conf->global->LDAP_MEMBER_OBJECT_CLASS); + $info["objectclass"] = explode(',', getDolGlobalString('LDAP_MEMBER_OBJECT_CLASS')); $this->fullname = $this->getFullName($langs); @@ -2752,7 +2751,7 @@ class Adherent extends CommonObject $info[getDolGlobalString($constname)] = $this->$varname; // Check if it is the LDAP key and if its value has been changed - if (getDolGlobalString('LDAP_KEY_MEMBERS') && $conf->global->LDAP_KEY_MEMBERS == getDolGlobalString($constname)) { + if (getDolGlobalString('LDAP_KEY_MEMBERS') && getDolGlobalString('LDAP_KEY_MEMBERS') == getDolGlobalString($constname)) { if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) { $keymodified = true; // For check if LDAP key has been modified } @@ -2821,15 +2820,15 @@ class Adherent extends CommonObject if (getDolGlobalString('LDAP_MEMBER_FIELD_PASSWORD_CRYPTED')) { $info[getDolGlobalString('LDAP_MEMBER_FIELD_PASSWORD_CRYPTED')] = dol_hash($this->pass, 'openldap'); // Create OpenLDAP password (see LDAP_PASSWORD_HASH_TYPE) } - } elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !== '3') { + } elseif (getDolGlobalString('LDAP_SERVER_PROTOCOLVERSION') !== '3') { // Set LDAP password if possible // If ldap key is modified and LDAPv3 we use ldap_rename function for avoid lose encrypt password - if (getDolGlobalString('DATABASE_PWD_ENCRYPTED')) { - // Just for the default MD5 ! - if (!getDolGlobalString('MAIN_SECURITY_HASH_ALGO')) { + if (getDolGlobalString('DATABASE_PWD_ENCRYPTED')) { // This should be on on default installation + // Just for the case we use old md5 encryption (deprecated, no more used, kept for compatibility) + if (!getDolGlobalString('MAIN_SECURITY_HASH_ALGO') || getDolGlobalString('MAIN_SECURITY_HASH_ALGO') == 'md5') { if ($this->pass_indatabase_crypted && getDolGlobalString('LDAP_MEMBER_FIELD_PASSWORD_CRYPTED')) { // Create OpenLDAP MD5 password from Dolibarr MD5 password - // Note: This suppose that "pass_indatabase_crypted" is a md5 (guaranted by the previous test if "(empty($conf->global->MAIN_SECURITY_HASH_ALGO))" + // Note: This suppose that "pass_indatabase_crypted" is a md5 (this should not happen anymore)" $info[getDolGlobalString('LDAP_MEMBER_FIELD_PASSWORD_CRYPTED')] = dolGetLdapPasswordHash($this->pass_indatabase_crypted, 'md5frommd5'); } } diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index c75ec565b35..2ecd0a80978 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -868,7 +868,7 @@ class AdherentType extends CommonObject $info = array(); // Object classes - $info["objectclass"] = explode(',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS); + $info["objectclass"] = explode(',', getDolGlobalString('LDAP_MEMBER_TYPE_OBJECT_CLASS')); if (empty($this->note_public) && !empty($this->note)) { // For backward compatibility $this->note_public = $this->note; From 8f7d258a8370e4e3356a4c9799cb45640a88a4e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Dec 2023 14:59:22 +0100 Subject: [PATCH 079/107] Work on rector to fix warnings --- .../rector/src/Renaming/GlobalToFunction.php | 43 ++++++++++++++++--- htdocs/adherents/admin/member.php | 2 +- htdocs/adherents/class/adherent.class.php | 17 ++++---- .../adherents/class/adherent_type.class.php | 4 +- htdocs/adherents/subscription.php | 4 +- 5 files changed, 51 insertions(+), 19 deletions(-) diff --git a/dev/tools/rector/src/Renaming/GlobalToFunction.php b/dev/tools/rector/src/Renaming/GlobalToFunction.php index 03b797c81b1..656a7d4ff59 100644 --- a/dev/tools/rector/src/Renaming/GlobalToFunction.php +++ b/dev/tools/rector/src/Renaming/GlobalToFunction.php @@ -21,10 +21,12 @@ use Rector\Php71\ValueObject\TwoNodeMatch; use Symplify\RuleDocGenerator\Exception\PoorDocumentationException; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use PhpParser\Node\Expr\BinaryOp\NotEqual; use PhpParser\Node\Expr\BinaryOp\Greater; use PhpParser\Node\Expr\BinaryOp\GreaterOrEqual; use PhpParser\Node\Expr\BinaryOp\Smaller; use PhpParser\Node\Expr\BinaryOp\SmallerOrEqual; +use PhpParser\Node\Expr\BinaryOp\NotIdentical; /** * Class with Rector custom rule to fix code @@ -55,7 +57,7 @@ class GlobalToFunction extends AbstractRector public function getRuleDefinition(): RuleDefinition { return new RuleDefinition( - 'Change $conf->global to getDolGlobal', + 'Change $conf->global to getDolGlobal in context (1) conf->global Operator Value or (2) function(conf->global...)', [new CodeSample( '$conf->global->CONSTANT', 'getDolGlobalInt(\'CONSTANT\')' @@ -70,7 +72,7 @@ class GlobalToFunction extends AbstractRector */ public function getNodeTypes(): array { - return [FuncCall::class, Equal::class, Greater::class, GreaterOrEqual::class, Smaller::class, SmallerOrEqual::class, BooleanAnd::class, Concat::class, ArrayDimFetch::class]; + return [FuncCall::class, Equal::class, NotEqual::class, Greater::class, GreaterOrEqual::class, Smaller::class, SmallerOrEqual::class, NotIdentical::class, BooleanAnd::class, Concat::class, ArrayDimFetch::class]; } /** @@ -101,7 +103,7 @@ class GlobalToFunction extends AbstractRector if ($node instanceof FuncCall) { $tmpfunctionname = $this->getName($node); - if (in_array($tmpfunctionname, array('dol_escape_htmltag', 'make_substitutions', 'min', 'max'))) { + if (in_array($tmpfunctionname, array('dol_escape_htmltag', 'make_substitutions', 'min', 'max', 'explode'))) { $args = $node->getArgs(); $nbofparam = count($args); @@ -126,6 +128,7 @@ class GlobalToFunction extends AbstractRector } return $node; } + if ($node instanceof Concat) { if ($this->isGlobalVar($node->left)) { $constName = $this->getConstName($node->left); @@ -154,6 +157,7 @@ class GlobalToFunction extends AbstractRector } return new Concat($leftConcat, $rightConcat); } + if ($node instanceof BooleanAnd) { $nodes = $this->resolveTwoNodeMatch($node); if (!isset($nodes)) { @@ -164,10 +168,16 @@ class GlobalToFunction extends AbstractRector $node = $nodes->getFirstExpr(); } + // Now process all comparison like: + // $conf->global->... Operator Value + $typeofcomparison = ''; if ($node instanceof Equal) { $typeofcomparison = 'Equal'; } + if ($node instanceof NotEqual) { + $typeofcomparison = 'NotEqual'; + } if ($node instanceof Greater) { $typeofcomparison = 'Greater'; } @@ -180,6 +190,10 @@ class GlobalToFunction extends AbstractRector if ($node instanceof SmallerOrEqual) { $typeofcomparison = 'SmallerOrEqual'; } + if ($node instanceof NotIdentical) { + $typeofcomparison = 'NotIdentical'; + //var_dump($node->left); + } if (empty($typeofcomparison)) { return; } @@ -189,7 +203,8 @@ class GlobalToFunction extends AbstractRector } // Test the type after the comparison conf->global->xxx to know the name of function - switch ($node->right->getType()) { + $typeright = $node->right->getType(); + switch ($typeright) { case 'Scalar_LNumber': $funcName = 'getDolGlobalInt'; break; @@ -214,6 +229,15 @@ class GlobalToFunction extends AbstractRector $node->right ); } + if ($typeofcomparison == 'NotEqual') { + return new NotEqual( + new FuncCall( + new Name($funcName), + [new Arg($constName)] + ), + $node->right + ); + } if ($typeofcomparison == 'Greater') { return new Greater( new FuncCall( @@ -250,6 +274,15 @@ class GlobalToFunction extends AbstractRector $node->right ); } + if ($typeofcomparison == 'NotIdentical') { + return new NotIdentical( + new FuncCall( + new Name($funcName), + [new Arg($constName)] + ), + $node->right + ); + } } /** @@ -262,7 +295,7 @@ class GlobalToFunction extends AbstractRector { return $this->binaryOpManipulator->matchFirstAndSecondConditionNode( $booleanAnd, - // $conf->global == $value + // Function to check if we are in the case $conf->global->... == $value function (Node $node): bool { if (!$node instanceof Equal) { return \false; diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index 06416f19039..b78cd367c9d 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -428,7 +428,7 @@ if (isModEnabled('facture')) { if (isModEnabled("product") || isModEnabled("service")) { print ''.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").''; print ''; - $selected = (!getDolGlobalString('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') ? '' : $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); + $selected = getDolGlobalString('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS'); print img_picto('', 'product', 'class="pictofixedwidth"'); $form->select_produits($selected, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', '', 0); print ''; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 294e0c4689d..51af75d9591 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1151,7 +1151,6 @@ class Adherent extends CommonObject // Mise a jour $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; $sql .= " SET pass_crypted = '".$this->db->escape($password_crypted)."'"; - //if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) if ($isencrypted) { $sql .= ", pass = null"; } else { @@ -1921,7 +1920,7 @@ class Adherent extends CommonObject $outputlangs->setDefaultLang($newlang); } // Generate PDF (whatever is option MAIN_DISABLE_PDF_AUTOUPDATE) so we can include it into email - //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + //if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) $invoice->generateDocument($invoice->model_pdf, $outputlangs); } @@ -2727,7 +2726,7 @@ class Adherent extends CommonObject $keymodified = false; // Object classes - $info["objectclass"] = explode(',', $conf->global->LDAP_MEMBER_OBJECT_CLASS); + $info["objectclass"] = explode(',', getDolGlobalString('LDAP_MEMBER_OBJECT_CLASS')); $this->fullname = $this->getFullName($langs); @@ -2752,7 +2751,7 @@ class Adherent extends CommonObject $info[getDolGlobalString($constname)] = $this->$varname; // Check if it is the LDAP key and if its value has been changed - if (getDolGlobalString('LDAP_KEY_MEMBERS') && $conf->global->LDAP_KEY_MEMBERS == getDolGlobalString($constname)) { + if (getDolGlobalString('LDAP_KEY_MEMBERS') && getDolGlobalString('LDAP_KEY_MEMBERS') == getDolGlobalString($constname)) { if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) { $keymodified = true; // For check if LDAP key has been modified } @@ -2821,15 +2820,15 @@ class Adherent extends CommonObject if (getDolGlobalString('LDAP_MEMBER_FIELD_PASSWORD_CRYPTED')) { $info[getDolGlobalString('LDAP_MEMBER_FIELD_PASSWORD_CRYPTED')] = dol_hash($this->pass, 'openldap'); // Create OpenLDAP password (see LDAP_PASSWORD_HASH_TYPE) } - } elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !== '3') { + } elseif (getDolGlobalString('LDAP_SERVER_PROTOCOLVERSION') !== '3') { // Set LDAP password if possible // If ldap key is modified and LDAPv3 we use ldap_rename function for avoid lose encrypt password - if (getDolGlobalString('DATABASE_PWD_ENCRYPTED')) { - // Just for the default MD5 ! - if (!getDolGlobalString('MAIN_SECURITY_HASH_ALGO')) { + if (getDolGlobalString('DATABASE_PWD_ENCRYPTED')) { // This should be on on default installation + // Just for the case we use old md5 encryption (deprecated, no more used, kept for compatibility) + if (!getDolGlobalString('MAIN_SECURITY_HASH_ALGO') || getDolGlobalString('MAIN_SECURITY_HASH_ALGO') == 'md5') { if ($this->pass_indatabase_crypted && getDolGlobalString('LDAP_MEMBER_FIELD_PASSWORD_CRYPTED')) { // Create OpenLDAP MD5 password from Dolibarr MD5 password - // Note: This suppose that "pass_indatabase_crypted" is a md5 (guaranted by the previous test if "(empty($conf->global->MAIN_SECURITY_HASH_ALGO))" + // Note: This suppose that "pass_indatabase_crypted" is a md5 (this should not happen anymore)" $info[getDolGlobalString('LDAP_MEMBER_FIELD_PASSWORD_CRYPTED')] = dolGetLdapPasswordHash($this->pass_indatabase_crypted, 'md5frommd5'); } } diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index c75ec565b35..4832a4242e7 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -844,7 +844,7 @@ class AdherentType extends CommonObject $dn = getDolGlobalString('LDAP_KEY_MEMBERS_TYPES') . "=".$info[getDolGlobalString('LDAP_KEY_MEMBERS_TYPES')]."," . getDolGlobalString('LDAP_MEMBER_TYPE_DN'); } if ($mode == 1) { - $dn = $conf->global->LDAP_MEMBER_TYPE_DN; + $dn = getDolGlobalString('LDAP_MEMBER_TYPE_DN'); } if ($mode == 2) { $dn = getDolGlobalString('LDAP_KEY_MEMBERS_TYPES') . "=".$info[getDolGlobalString('LDAP_KEY_MEMBERS_TYPES')]; @@ -868,7 +868,7 @@ class AdherentType extends CommonObject $info = array(); // Object classes - $info["objectclass"] = explode(',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS); + $info["objectclass"] = explode(',', getDolGlobalString('LDAP_MEMBER_TYPE_OBJECT_CLASS')); if (empty($this->note_public) && !empty($this->note)) { // For backward compatibility $this->note_public = $this->note; diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 182957bc97d..511553b9e88 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -1056,7 +1056,7 @@ if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->h print $langs->trans("CreateDolibarrThirdParty"); print ')'; } - if (!getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') { + if (!getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') || getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') != 'defaultforfoundationcountry') { print '. '.$langs->trans("NoVatOnSubscription", 0).''; } if (getDolGlobalString('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && (isModEnabled('product') || isModEnabled('service'))) { @@ -1086,7 +1086,7 @@ if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->h print $langs->trans("CreateDolibarrThirdParty"); print ')'; } - if (!getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') { + if (!getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') || getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') != 'defaultforfoundationcountry') { print '. '.$langs->trans("NoVatOnSubscription", 0).''; } if (getDolGlobalString('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && (isModEnabled('product')|| isModEnabled('service'))) { From d3b0032fb7514b57677a5e72d4750323e50c00a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Dec 2023 16:35:47 +0100 Subject: [PATCH 080/107] Fix date --- htdocs/fourn/facture/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 90446c20584..93b72fbd900 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -3328,9 +3328,9 @@ if ($action == 'create') { // Date print ''; - print $form->editfieldkey("DateInvoice", 'datef', $object->datep, $object, $form_permission, 'datepicker'); + print $form->editfieldkey("DateInvoice", 'datef', $object->date, $object, $form_permission, 'datepicker'); print ''; - print $form->editfieldval("Date", 'datef', $object->datep, $object, $form_permission, 'datepicker'); + print $form->editfieldval("Date", 'datef', $object->date, $object, $form_permission, 'datepicker'); print ''; // Default terms of the settlement From a0f097c0a8bd9637602f2347f91cfab416295718 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 13 Dec 2023 16:44:12 +0100 Subject: [PATCH 081/107] add constant MAIN_IGNORE_CONTACTS_ON_CLONING --- htdocs/comm/propal/class/propal.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 7ff7de223bf..c34c0db113b 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1512,7 +1512,7 @@ class Propal extends CommonObject $error++; } - if (!$error) { + if (!$error && !getDolGlobalInt('MAIN_IGNORE_CONTACTS_ON_CLONING')) { // copy internal contacts if ($object->copy_linked_contact($this, 'internal') < 0) { $error++; From a65631c3554b988310b022ed1ca5c9a8c9760163 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 13 Dec 2023 16:49:55 +0100 Subject: [PATCH 082/107] add constant PROPAL_DISABLE_AUTOUPDATE_ON_CLOSE --- htdocs/comm/propal/class/propal.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 7ff7de223bf..67e3153f7ea 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2720,7 +2720,7 @@ class Propal extends CommonObject } } - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { + if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE') && !getDolGlobalInt('PROPAL_DISABLE_AUTOUPDATE_ON_CLOSE')) { // Define output language $outputlangs = $langs; if (getDolGlobalInt('MAIN_MULTILANGS')) { From 003c758f704600d04320bf2e96abece8eb0214a4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Dec 2023 18:10:42 +0100 Subject: [PATCH 083/107] FIX Bad format of date when updating an extrafield field date --- htdocs/core/class/commonobject.class.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index cdcb8f51121..8352d83c84a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6918,15 +6918,11 @@ abstract class CommonObject case 'datetime': if (empty($this->array_options["options_".$key])) { $this->array_options["options_".$key] = null; - } else { - $this->array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key]); } break; case 'datetimegmt': if (empty($this->array_options["options_".$key])) { $this->array_options["options_".$key] = null; - } else { - $this->array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key], 'gmt'); } break; case 'boolean': @@ -7051,7 +7047,7 @@ abstract class CommonObject */ public function updateExtraLanguages($key, $trigger = null, $userused = null) { - global $conf, $langs, $user; + global $user; if (empty($userused)) { $userused = $user; From 23b62d928c44131a19aed092c8278c06ae379f35 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Dec 2023 18:45:00 +0100 Subject: [PATCH 084/107] Debug v19 --- htdocs/core/class/commonobject.class.php | 55 ++++++++++++++++++------ 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8352d83c84a..520e004a751 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6820,15 +6820,23 @@ abstract class CommonObject } } + // $new_array_options will be used for direct update, so must contains formated data for the UPDATE. + $new_array_options = $this->array_options; + //dol_syslog("attributeLabel=".$attributeLabel, LOG_DEBUG); //dol_syslog("attributeType=".$attributeType, LOG_DEBUG); if (!empty($attrfieldcomputed)) { if (getDolGlobalString('MAIN_STORE_COMPUTED_EXTRAFIELDS')) { $value = dol_eval($attrfieldcomputed, 1, 0, '2'); dol_syslog($langs->trans("Extrafieldcomputed")." sur ".$attributeLabel."(".$value.")", LOG_DEBUG); - $this->array_options["options_".$key] = $value; + + $new_array_options["options_".$key] = $value; + + $this->array_options["options_".$key] = $new_array_options["options_".$key]; } else { - $this->array_options["options_".$key] = null; + $new_array_options["options_".$key] = null; + + $this->array_options["options_".$key] = $new_array_options["options_".$key]; } } @@ -6838,7 +6846,9 @@ abstract class CommonObject $this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel); return -1; } elseif ($value === '') { - $this->array_options["options_".$key] = null; + $new_array_options["options_".$key] = null; + + $this->array_options["options_".$key] = $new_array_options["options_".$key]; } break; case 'double': @@ -6851,19 +6861,24 @@ abstract class CommonObject $value = null; } //dol_syslog("double value"." sur ".$attributeLabel."(".$value." is '".$attributeType."')", LOG_DEBUG); - $this->array_options["options_".$key] = $value; + $new_array_options["options_".$key] = $value; + + $this->array_options["options_".$key] = $new_array_options["options_".$key]; break; /*case 'select': // Not required, we chosed value='0' for undefined values if ($value=='-1') { - $this->array_options[$key] = null; + $new_array_options["options_".$key] = $value; + + $this->array_options["options_".$key] = $new_array_options["options_".$key]; } break;*/ case 'price': - $this->array_options["options_".$key] = price2num($this->array_options["options_".$key]); + $new_array_options["options_".$key] = price2num($this->array_options["options_".$key]); + + $this->array_options["options_".$key] = $new_array_options["options_".$key]; break; case 'password': - $new_array_options = array(); $algo = ''; if ($this->array_options["options_".$key] != '' && is_array($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])) { // If there is an encryption choice, we use it to crypt data before insert @@ -6917,22 +6932,34 @@ abstract class CommonObject case 'date': case 'datetime': if (empty($this->array_options["options_".$key])) { - $this->array_options["options_".$key] = null; + $new_array_options["options_".$key] = null; + + $this->array_options["options_".$key] = $new_array_options["options_".$key]; + } else { + $new_array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key]); } break; case 'datetimegmt': if (empty($this->array_options["options_".$key])) { - $this->array_options["options_".$key] = null; + $new_array_options["options_".$key] = null; + + $this->array_options["options_".$key] = $new_array_options["options_".$key]; + } else { + $new_array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key], 'gmt'); } break; case 'boolean': if (empty($this->array_options["options_".$key])) { - $this->array_options["options_".$key] = null; + $new_array_options["options_".$key] = null; + + $this->array_options["options_".$key] = $new_array_options["options_".$key]; } break; case 'link': if ($this->array_options["options_".$key] === '') { - $this->array_options["options_".$key] = null; + $new_array_options["options_".$key] = null; + + $this->array_options["options_".$key] = $new_array_options["options_".$key]; } break; /* @@ -6991,12 +7018,12 @@ abstract class CommonObject } } - //var_dump('linealreadyfound='.$linealreadyfound.' sql='.$sql); + //var_dump('linealreadyfound='.$linealreadyfound.' sql='.$sql); exit; if ($linealreadyfound) { if ($this->array_options["options_".$key] === null) { $sql = "UPDATE ".$this->db->prefix().$this->table_element."_extrafields SET ".$key." = null"; } else { - $sql = "UPDATE ".$this->db->prefix().$this->table_element."_extrafields SET ".$key." = '".$this->db->escape($this->array_options["options_".$key])."'"; + $sql = "UPDATE ".$this->db->prefix().$this->table_element."_extrafields SET ".$key." = '".$this->db->escape($new_array_options["options_".$key])."'"; } $sql .= " WHERE fk_object = ".((int) $this->id); @@ -7047,7 +7074,7 @@ abstract class CommonObject */ public function updateExtraLanguages($key, $trigger = null, $userused = null) { - global $user; + global $conf, $langs, $user; if (empty($userused)) { $userused = $user; From fe99114fc10dcc2a478ab2a46549f3f2585ea8b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Dec 2023 19:42:23 +0100 Subject: [PATCH 085/107] Debug v19 --- htdocs/compta/bank/line.php | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index cda42de38d3..449866b5e74 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -258,25 +258,38 @@ if ($user->hasRight('banque', 'consolidate') && ($action == 'num_releve' || $act } $sql .= " WHERE rowid = ".((int) $rowid); - dol_syslog("line.php", LOG_DEBUG); + $updatePathFile = true; + $update_dir = true; + + dol_syslog("line.php update bank line to set the new bank receipt nuber", LOG_DEBUG); + $result = $db->query($sql); + + // We must not rename the directory of the bank receipt when we change 1 line of bank receipt. Other lines may share the same old ref. + // Renaming can be done when we rename globaly a bank receipt but not when changing 1 line from one receipt into another one. + /* if ($result) { - $oldfilepath = dol_sanitizePathName("bank/".((int) $id)."/statement/".$oldNum_rel); - $filepath = dol_sanitizePathName("bank/".((int) $id)."/statement/".$num_rel); + if ($oldNum_rel) { + if ($num_rel) { + $oldfilepath = dol_sanitizePathName("bank/".((int) $id)."/statement/".$oldNum_rel); + $filepath = dol_sanitizePathName("bank/".((int) $id)."/statement/".$num_rel); - $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_files"; - $sql .= " SET filepath = '".$db->escape($filepath)."'"; - $sql .= " WHERE filepath = '".$db->escape($oldfilepath)."'"; - $updatePathFile = $db->query($sql); + $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_files"; + $sql .= " SET filepath = '".$db->escape($filepath)."'"; + $sql .= " WHERE filepath = '".$db->escape($oldfilepath)."'"; + $updatePathFile = $db->query($sql); - $srcdir = dol_sanitizePathName(DOL_DATA_ROOT."/bank/".((int) $id)."/statement/".$oldNum_rel); - $destdir = dol_sanitizePathName(DOL_DATA_ROOT."/bank/".((int) $id)."/statement/".$num_rel); + $srcdir = dol_sanitizePathName(DOL_DATA_ROOT."/bank/".((int) $id)."/statement/".$oldNum_rel); + $destdir = dol_sanitizePathName(DOL_DATA_ROOT."/bank/".((int) $id)."/statement/".$num_rel); - $update_dir = true; - if (dol_is_dir($srcdir)) { - $update_dir = dol_move_dir($srcdir, $destdir, 1); + if (dol_is_dir($srcdir)) { + $update_dir = dol_move_dir($srcdir, $destdir, 1); + } + } } } + */ + if ($result && $updatePathFile && $update_dir) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); $db->commit(); From 0a2e28435e5b233d246f518870c8057db606eb39 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Dec 2023 20:33:36 +0100 Subject: [PATCH 086/107] Debug v19 --- htdocs/compta/prelevement/card.php | 31 ++++++++++++++----- .../class/bonprelevement.class.php | 7 +++-- htdocs/core/class/commonobject.class.php | 3 ++ 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index a5e7c3fc17c..ad5e99713e9 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -149,7 +149,7 @@ if (empty($reshook)) { } // Set direct debit order to credited, create payment and close invoices - if ($action == 'infocredit' && $permissiontocreditdebit) { + if ($action == 'setinfocredit' && $permissiontocreditdebit) { $dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); if (($object->type != 'bank-transfer' && $object->statut == BonPrelevement::STATUS_CREDITED) || ($object->type == 'bank-transfer' && $object->statut == BonPrelevement::STATUS_DEBITED)) { @@ -164,6 +164,14 @@ if (empty($reshook)) { } } + if ($action == 'reopen' && $permissiontocreditdebit) { + $savtype = $object->type; + $res = $object->setStatut(BonPrelevement::STATUS_TRANSFERED); + if ($res <= 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + if ($action == 'confirm_delete' && $permissiontodelete) { $savtype = $object->type; $res = $object->delete($user); @@ -386,11 +394,11 @@ if ($id > 0 || $ref) { print '
'; } - if (!empty($object->date_trans) && empty($object->date_credit) && (($user->hasRight('prelevement', 'bons', 'credit') && $object->type != 'bank-transfer') || ($user->hasRight('paymentbybanktransfer', 'debit') && $object->type == 'bank-transfer')) && $action == 'setcredited') { + if ($object->status == BonPrelevement::STATUS_TRANSFERED && (($user->hasRight('prelevement', 'bons', 'credit') && $object->type != 'bank-transfer') || ($user->hasRight('paymentbybanktransfer', 'debit') && $object->type == 'bank-transfer')) && $action == 'setcredited') { $btnLabel = ($object->type == 'bank-transfer') ? $langs->trans("ClassDebited") : $langs->trans("ClassCredited"); print '
'; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -417,7 +425,8 @@ if ($id > 0 || $ref) { print dolGetButtonAction($langs->trans("SetToStatusSent"), '', 'default', 'card.php?action=settransmitted&token='.newToken().'&id='.$object->id, '', $user->hasRight('prelevement', 'bons', 'send')); } } - if (!empty($object->date_trans) && empty($object->date_credit)) { + + if ($object->status == BonPrelevement::STATUS_TRANSFERED) { if ($object->type == 'bank-transfer') { print dolGetButtonAction($langs->trans("ClassDebited"), '', 'default', 'card.php?action=setcredited&token='.newToken().'&id='.$object->id, '', $user->hasRight('paymentbybanktransfer', 'debit')); } else { @@ -425,6 +434,16 @@ if ($id > 0 || $ref) { } } + if (getDolGlobalString('BANK_CAN_REOPEN_DIRECT_DEBIT_OR_CREDIT_TRANSFER')) { + if ($object->status == BonPrelevement::STATUS_DEBITED || $object->status == BonPrelevement::STATUS_CREDITED) { + if ($object->type == 'bank-transfer') { + print dolGetButtonAction($langs->trans("ReOpen"), '', 'default', 'card.php?action=reopen&token='.newToken().'&id='.$object->id, '', $user->hasRight('paymentbybanktransfer', 'debit')); + } else { + print dolGetButtonAction($langs->trans("ReOpen"), '', 'default', 'card.php?action=reopen&token='.newToken().'&id='.$object->id, '', $user->hasRight('prelevement', 'bons', 'credit')); + } + } + } + if ($object->type == 'bank-transfer') { print dolGetButtonAction($langs->trans("Delete"), '', 'delete', 'card.php?action=delete&token='.newToken().'&id='.$object->id, '', $user->hasRight('paymentbybanktransfer', 'create')); } else { @@ -437,9 +456,7 @@ if ($id > 0 || $ref) { $ligne = new LignePrelevement($db); - /* - * Lines into withdraw request - */ + // Lines into withdraw request if ($salaryBonPl) { $sql = "SELECT pl.rowid, pl.statut, pl.amount,pl.fk_user"; $sql .=" FROM llx_prelevement as p, llx_prelevement_lignes as pl, llx_salary as s"; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 3488d1ada43..b2ab3b897cf 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -602,6 +602,7 @@ class BonPrelevement extends CommonObject if ($error == 0) { $this->date_credit = $date; $this->statut = self::STATUS_CREDITED; + $this->status = self::STATUS_CREDITED; $this->db->commit(); return 0; @@ -639,7 +640,7 @@ class BonPrelevement extends CommonObject $sql .= " , statut = ".self::STATUS_TRANSFERED; $sql .= " WHERE rowid = ".((int) $this->id); $sql .= " AND entity = ".((int) $conf->entity); - $sql .= " AND statut = 0"; + $sql .= " AND statut = ".self::STATUS_DRAFT; if ($this->db->query($sql)) { $this->method_trans = $method; @@ -655,8 +656,10 @@ class BonPrelevement extends CommonObject if ($error == 0) { $this->date_trans = $date; - $this->statut = 1; + $this->statut = self::STATUS_TRANSFERED; + $this->status = self::STATUS_TRANSFERED; $this->user_trans = $user->id; + $this->db->commit(); return 0; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 520e004a751..b15a1da96c3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4535,6 +4535,9 @@ abstract class CommonObject if ($elementTable == 'commande_fournisseur_dispatch') { $fieldstatus = "status"; } + if ($elementTable == 'prelevement_bons') { + $fieldstatus = "statut"; + } if (isset($this->fields) && is_array($this->fields) && array_key_exists('status', $this->fields)) { $fieldstatus = 'status'; } From 1b7edbb44f132985192b75931075294cd323123c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Dec 2023 21:57:56 +0100 Subject: [PATCH 087/107] Fix warnings --- htdocs/accountancy/journal/sellsjournal.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 5ca5c164007..911f13c0ba9 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -464,7 +464,7 @@ if ($action == 'writebookkeeping' && !$error) { // Warranty if (!$errorforline) { - if (is_iterable($tabwarranty[$key])) { + if (is_array($tabwarranty[$key])) { foreach ($tabwarranty[$key] as $k => $mt) { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; @@ -706,7 +706,7 @@ if ($action == 'writebookkeeping' && !$error) { // Revenue stamp if (!$errorforline) { - if (is_iterable($tabrevenuestamp[$key])) { + if (is_array($tabrevenuestamp[$key])) { foreach ($tabrevenuestamp[$key] as $k => $mt) { if ($mt) { $accountingaccount->fetch(null, $k, true); // TODO Use a cache for label @@ -1144,7 +1144,7 @@ if (empty($action) || $action == 'view') { } // Warranty - if (is_iterable($tabwarranty[$key])) { + if (is_array($tabwarranty[$key])) { foreach ($tabwarranty[$key] as $k => $mt) { print ''; print ""; @@ -1292,7 +1292,7 @@ if (empty($action) || $action == 'view') { } // Revenue stamp - if (is_iterable($tabrevenuestamp[$key])) { + if (is_array($tabrevenuestamp[$key])) { foreach ($tabrevenuestamp[$key] as $k => $mt) { print ''; print ""; From ac3253723459c12a0f04fc1413c65891957c5650 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Dec 2023 22:04:39 +0100 Subject: [PATCH 088/107] Fix filter lost on page to transfer in accountancy --- htdocs/accountancy/journal/bankjournal.php | 8 +++++++- htdocs/accountancy/journal/expensereportsjournal.php | 8 +++++++- htdocs/accountancy/journal/purchasesjournal.php | 8 +++++++- htdocs/accountancy/journal/sellsjournal.php | 8 +++++++- htdocs/accountancy/journal/variousjournal.php | 8 +++++++- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index ccf5b4df7b7..5d80232d51d 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -104,10 +104,16 @@ $error = 0; $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); -if (empty($date_startmonth) || empty($date_endmonth)) { +if (empty($date_startmonth)) { // Period by default on transfer $dates = getDefaultDatesForTransfer(); $date_start = $dates['date_start']; + $pastmonthyear = $dates['pastmonthyear']; + $pastmonth = $dates['pastmonth']; +} +if (empty($date_endmonth)) { + // Period by default on transfer + $dates = getDefaultDatesForTransfer(); $date_end = $dates['date_end']; $pastmonthyear = $dates['pastmonthyear']; $pastmonth = $dates['pastmonth']; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 39fa8d8e050..fb86cdc3505 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -90,10 +90,16 @@ $journal_label = $accountingjournalstatic->label; $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); -if (empty($date_startmonth) || empty($date_endmonth)) { +if (empty($date_startmonth)) { // Period by default on transfer $dates = getDefaultDatesForTransfer(); $date_start = $dates['date_start']; + $pastmonthyear = $dates['pastmonthyear']; + $pastmonth = $dates['pastmonth']; +} +if (empty($date_endmonth)) { + // Period by default on transfer + $dates = getDefaultDatesForTransfer(); $date_end = $dates['date_end']; $pastmonthyear = $dates['pastmonthyear']; $pastmonth = $dates['pastmonth']; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index ed03d708b79..8439ff5ec99 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -92,10 +92,16 @@ $journal_label = $accountingjournalstatic->label; $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); -if (empty($date_startmonth) || empty($date_endmonth)) { +if (empty($date_startmonth)) { // Period by default on transfer $dates = getDefaultDatesForTransfer(); $date_start = $dates['date_start']; + $pastmonthyear = $dates['pastmonthyear']; + $pastmonth = $dates['pastmonth']; +} +if (empty($date_endmonth)) { + // Period by default on transfer + $dates = getDefaultDatesForTransfer(); $date_end = $dates['date_end']; $pastmonthyear = $dates['pastmonthyear']; $pastmonth = $dates['pastmonth']; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 911f13c0ba9..b91a7393572 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -94,10 +94,16 @@ $journal_label = $accountingjournalstatic->label; $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); -if (empty($date_startmonth) || empty($date_endmonth)) { +if (empty($date_startmonth)) { // Period by default on transfer $dates = getDefaultDatesForTransfer(); $date_start = $dates['date_start']; + $pastmonthyear = $dates['pastmonthyear']; + $pastmonth = $dates['pastmonth']; +} +if (empty($date_endmonth)) { + // Period by default on transfer + $dates = getDefaultDatesForTransfer(); $date_end = $dates['date_end']; $pastmonthyear = $dates['pastmonthyear']; $pastmonth = $dates['pastmonth']; diff --git a/htdocs/accountancy/journal/variousjournal.php b/htdocs/accountancy/journal/variousjournal.php index 7d496cee5a0..0906f7c4754 100644 --- a/htdocs/accountancy/journal/variousjournal.php +++ b/htdocs/accountancy/journal/variousjournal.php @@ -61,10 +61,16 @@ $parameters = array(); $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); -if (empty($date_startmonth) || empty($date_endmonth)) { +if (empty($date_startmonth)) { // Period by default on transfer $dates = getDefaultDatesForTransfer(); $date_start = $dates['date_start']; + $pastmonthyear = $dates['pastmonthyear']; + $pastmonth = $dates['pastmonth']; +} +if (empty($date_endmonth)) { + // Period by default on transfer + $dates = getDefaultDatesForTransfer(); $date_end = $dates['date_end']; $pastmonthyear = $dates['pastmonthyear']; $pastmonth = $dates['pastmonth']; From 1fb9c7bec8b36a5f2cae43d3682485e152bf90ae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Dec 2023 22:09:39 +0100 Subject: [PATCH 089/107] Log --- htdocs/accountancy/class/bookkeeping.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 8759890a020..ffda82c2174 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -367,7 +367,7 @@ class BookKeeping extends CommonObject $this->piece_num = $objnum->piece_num; } - dol_syslog(get_class($this).":: create this->piece_num=".$this->piece_num, LOG_DEBUG); + dol_syslog(get_class($this)."::create this->piece_num=".$this->piece_num, LOG_DEBUG); if (empty($this->piece_num)) { $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; $sqlnum .= " FROM ".MAIN_DB_PREFIX.$this->table_element; From 3a7379531fa8ebb514623055a2e2ab171b02b5ec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Dec 2023 00:23:25 +0100 Subject: [PATCH 090/107] Fix trans --- htdocs/compta/facture/list.php | 35 ++-------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index e3e7a952a6c..7c459dde04a 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -214,7 +214,7 @@ $arrayfields = array( 'f.subtype'=>array('label'=>"InvoiceSubtype", 'checked'=>0, 'position'=>17), 'f.date_lim_reglement'=>array('label'=>"DateDue", 'checked'=>1, 'position'=>25), 'f.date_closing'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>30), - 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>40), + 'p.ref'=>array('label'=>"ProjectRef", 'langs'=>'project', 'checked'=>1, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>40), 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>41), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>50), 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1, 'position'=>51), @@ -910,38 +910,6 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -// We disable this. It create a bug when searching with sall and sorting on status. Also it create performance troubles. -/* -if (!$sall) { - $sql .= ' GROUP BY f.rowid, f.ref, ref_client, f.fk_soc, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total_ht, f.total_tva, f.total_ttc,'; - $sql .= ' f.localtax1, f.localtax2,'; - $sql .= ' f.datef, f.date_valid, f.date_lim_reglement, f.module_source, f.pos_source,'; - $sql .= ' f.paye, f.fk_statut, f.close_code,'; - $sql .= ' f.datec, f.tms, f.date_closing,'; - $sql .= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,'; - $sql .= ' f.fk_user_author, f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht,'; - $sql .= ' f.multicurrency_total_tva, f.multicurrency_total_ttc,'; - $sql .= ' s.rowid, s.nom, s.name_alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,'; - $sql .= ' typent.code,'; - $sql .= ' state.code_departement, state.nom,'; - $sql .= ' country.code,'; - $sql .= " p.rowid, p.ref, p.title,"; - $sql .= " u.login, u.lastname, u.firstname, u.email, u.statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender"; - if ($search_categ_cus && $search_categ_cus != -1) { - $sql .= ", cc.fk_categorie, cc.fk_soc"; - } - // Add fields from extrafields - if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); - } - } - // Add GroupBy from hooks - $parameters = array('all' => !empty($all) ? $all : 0, 'fieldstosearchall' => $fieldstosearchall); - $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook - $sql .= $hookmanager->resPrint; -} else { -*/ if ($sall) { $sql .= natural_search(array_keys($fieldstosearchall), $sall); } @@ -1708,6 +1676,7 @@ if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { $totalarray['nbfield']++; } if (!empty($arrayfields['p.ref']['checked'])) { + $langs->trans("projects"); print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder); $totalarray['nbfield']++; } From a976620d625384dbbcf4909b9a6ce9dd1cd85fbd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Dec 2023 00:25:46 +0100 Subject: [PATCH 091/107] Fix load language --- htdocs/compta/facture/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 7c459dde04a..d58a1cf15d4 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -214,7 +214,7 @@ $arrayfields = array( 'f.subtype'=>array('label'=>"InvoiceSubtype", 'checked'=>0, 'position'=>17), 'f.date_lim_reglement'=>array('label'=>"DateDue", 'checked'=>1, 'position'=>25), 'f.date_closing'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>30), - 'p.ref'=>array('label'=>"ProjectRef", 'langs'=>'project', 'checked'=>1, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>40), + 'p.ref'=>array('label'=>"ProjectRef", 'langs'=>'projects', 'checked'=>1, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>40), 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>41), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>50), 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1, 'position'=>51), @@ -1676,7 +1676,7 @@ if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { $totalarray['nbfield']++; } if (!empty($arrayfields['p.ref']['checked'])) { - $langs->trans("projects"); + $langs->load("projects"); print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder); $totalarray['nbfield']++; } From b266c26781ece7c13e2871a72d13bfda0d701e2f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Dec 2023 00:29:57 +0100 Subject: [PATCH 092/107] Debug css v19 --- htdocs/core/get_menudiv.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/core/get_menudiv.php b/htdocs/core/get_menudiv.php index bcc89ae3f9c..f7ed538c274 100644 --- a/htdocs/core/get_menudiv.php +++ b/htdocs/core/get_menudiv.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2023 Laurent Destailleur * * This file is a modified version of datepicker.php from phpBSM to fix some * bugs, to add new features and to dramatically increase speed. @@ -140,6 +140,12 @@ print ' li.lilevel2 a { padding-left: 60px !important; } + li.lilevel3 a { + padding-left: 90px !important; + } + li.lilevel4 a { + padding-left: 120px !important; + } a.alilevel0, span.spanlilevel0 { background-image: url(\''.DOL_URL_ROOT.'/theme/'.urlencode($conf->theme).'/img/next.png\') !important; From c58cc0bbc49971b9da8dfbdafac89987a11a6f48 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Dec 2023 00:35:14 +0100 Subject: [PATCH 093/107] Debug look and feel --- htdocs/blockedlog/admin/blockedlog_list.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index 70611f174e9..9874be8bebe 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -442,7 +442,6 @@ print ''; // User print ''; // Actions code @@ -570,7 +569,7 @@ if (is_array($blocks)) { print ''; // User - print ''; @@ -580,7 +579,7 @@ if (is_array($blocks)) { // Ref print ''; // Link to source object @@ -596,7 +595,7 @@ if (is_array($blocks)) { print ''; // Fingerprint - print ''; - $coldisplay = $coldisplay + 3; + $colspan = 3; + if (isModEnabled('asset') && $object->element == 'invoice_supplier') { + $colspan++; + } + print ''; + $coldisplay = $coldisplay + $colspan; } if ($action == 'selectlines') { ?> diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 93b72fbd900..c9092bf5f0c 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2751,6 +2751,7 @@ if ($action == 'create') { // Intracomm report if (isModEnabled('intracommreport')) { $langs->loadLangs(array("intracommreport")); + print ''."\n"; print ''; @@ -3500,6 +3501,7 @@ if ($action == 'create') { // Intracomm report if (isModEnabled('intracommreport')) { $langs->loadLangs(array("intracommreport")); + print ''."\n"; print '
'.$langs->trans("NotifyCredit").'
'; print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); - print ''.dol_print_date($block->date_creation, 'dayhour').''; + print ''; //print $block->getUser() print dol_escape_htmltag($block->user_fullname); print ''; - print $block->ref_object; + print dol_escape_htmltag($block->ref_object); print ''.img_info($langs->trans('ShowDetails')).''; + print ''; $texttoshow = $langs->trans("Fingerprint").' - '.$langs->trans("Saved").':
'.$block->signature; $texttoshow .= '

'.$langs->trans("Fingerprint").' - Recalculated sha256(previoushash * data):
'.$checkdetail[$block->id]['calculatedsignature']; $texttoshow .= '
'.$langs->trans("PreviousHash").'='.$checkdetail[$block->id]['previoushash'].''; From 2a48d3497d6216860989b9754148f4b9fccda6c4 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 14 Dec 2023 09:36:08 +0100 Subject: [PATCH 094/107] better fix --- htdocs/fourn/class/fournisseur.facture.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 3cb37ac3617..05f91cdb6af 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -201,7 +201,6 @@ class FactureFournisseur extends CommonInvoice // Warning: Do not set default value into property defintion. it must stay null. // For example to avoid to have substition done when object is generic and not yet defined. - public $amount_ht; public $localtax1; public $localtax2; public $total_ht; @@ -3083,7 +3082,6 @@ class FactureFournisseur extends CommonInvoice } } - $this->amount_ht = $xnbp * 100; $this->total_ht = $xnbp * 100; $this->total_tva = $xnbp * 19.6; $this->total_ttc = $xnbp * 119.6; From d5722ee4b2c48b92549356edacda9c65cd44d27f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Dec 2023 13:50:29 +0100 Subject: [PATCH 095/107] Fix payment SEPA for salary --- htdocs/compta/prelevement/card.php | 19 +++-- .../class/bonprelevement.class.php | 71 ++++++++++++------- 2 files changed, 60 insertions(+), 30 deletions(-) diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index ad5e99713e9..396dc4c6cc0 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -156,7 +156,7 @@ if (empty($reshook)) { $error = 1; setEventMessages('WithdrawalCantBeCreditedTwice', array(), 'errors'); } else { - $error = $object->set_infocredit($user, $dt); + $error = $object->set_infocredit($user, $dt, ($salaryBonPl ? 'salary' : '')); } if ($error) { @@ -458,11 +458,18 @@ if ($id > 0 || $ref) { // Lines into withdraw request if ($salaryBonPl) { - $sql = "SELECT pl.rowid, pl.statut, pl.amount,pl.fk_user"; - $sql .=" FROM llx_prelevement as p, llx_prelevement_lignes as pl, llx_salary as s"; - $sql .= " WHERE pl.rowid = p.fk_prelevement_lignes"; - $sql .= " AND p.fk_salary = s.rowid"; - $sql .= " AND pl.fk_prelevement_bons = ".((int) $id); + $sql = "SELECT pl.rowid, pl.statut, pl.amount, pl.fk_user"; + $sql .= " u.rowid as socid, u.login as name"; + $sql .=" FROM llx_prelevement_lignes as pl"; + $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as pb"; + $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $id); + $sql .= " AND pl.fk_prelevement_bons = pb.rowid"; + $sql .= " AND pb.entity = ".((int) $conf->entity); // No sharing of entity here + $sql .= " AND pl.fk_user = u.rowid"; + if ($socid) { + $sql .= " AND u.rowid = ".((int) $socid); + } + $sql .= $db->order($sortfield, $sortorder); } else { $sql = "SELECT pl.rowid, pl.statut, pl.amount,"; $sql .= " s.rowid as socid, s.nom as name"; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index b2ab3b897cf..7bd53e14dfd 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -35,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; +require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/userbankaccount.class.php'; @@ -449,13 +450,14 @@ class BonPrelevement extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set direct debit or credit transfer order to "paid" status. - * Then create the payment for each invoice of the prelemevement_bon. + * Then create the payment for each invoice or salary of the prelemevement_bon. * * @param User $user Id of user * @param int $date date of action + * @param string $type 'salary' for type=salary * @return int >0 if OK, <0 if KO */ - public function set_infocredit($user, $date) + public function set_infocredit($user, $date, $type = '') { // phpcs:enable global $conf, $langs; @@ -473,7 +475,7 @@ class BonPrelevement extends CommonObject $this->db->begin(); $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_bons"; - $sql .= " SET fk_user_credit = ".$user->id; + $sql .= " SET fk_user_credit = ".((int) $user->id); $sql .= ", statut = ".self::STATUS_CREDITED; $sql .= ", date_credit = '".$this->db->idate($date)."'"; $sql .= " WHERE rowid = ".((int) $this->id); @@ -496,17 +498,22 @@ class BonPrelevement extends CommonObject $amounts = array(); $amountsperthirdparty = array(); - $facs = $this->getListInvoices(1); + $facs = $this->getListInvoices(1, $type); if ($this->error) { $error++; } //var_dump($facs);exit; - // Loop on each invoice. $facs=array(0=>id, 1=>amount requested) + // Loop on each invoice or salary. + // $facs=array(0=>id, 1=>amount requested) $num = count($facs); for ($i = 0; $i < $num; $i++) { if ($this->type == 'bank-transfer') { - $fac = new FactureFournisseur($this->db); + if ($type == 'salary') { + $fac = new Salary($this->db); + } else { + $fac = new FactureFournisseur($this->db); + } } else { $fac = new Facture($this->db); } @@ -517,8 +524,14 @@ class BonPrelevement extends CommonObject $amountsperthirdparty[$fac->socid][$fac->id] = $facs[$i][1]; $totalpaid = $fac->getSommePaiement(); - $totalcreditnotes = $fac->getSumCreditNotesUsed(); - $totaldeposits = $fac->getSumDepositsUsed(); + $totalcreditnotes = 0; + if (method_exists($fac, 'getSumCreditNotesUsed')) { + $totalcreditnotes = $fac->getSumCreditNotesUsed(); + } + $totaldeposits = 0; + if (method_exists($fac, 'getSumDepositsUsed')) { + $totaldeposits = $fac->getSumDepositsUsed(); + } $alreadypayed = $totalpaid + $totalcreditnotes + $totaldeposits; // @TODO Move this after creation of payment @@ -532,10 +545,14 @@ class BonPrelevement extends CommonObject } //var_dump($amountsperthirdparty);exit; - // Make one payment per customer + // Make one payment per customer or employee foreach ($amountsperthirdparty as $thirdpartyid => $cursoramounts) { if ($this->type == 'bank-transfer') { - $paiement = new PaiementFourn($this->db); + if ($type == 'salary') { + $paiement = new PaymentSalary($this->db); + } else { + $paiement = new PaiementFourn($this->db); + } } else { $paiement = new Paiement($this->db); } @@ -561,9 +578,15 @@ class BonPrelevement extends CommonObject dol_syslog(get_class($this)."::set_infocredit AddPayment Error ".$this->error); } else { if ($this->type == 'bank-transfer') { - $modeforaddpayment = 'payment_supplier'; - $labelforaddpayment = '(SupplierInvoicePayment)'; - $addbankurl = 'credit-transfer'; + if ($type == 'salary') { + $modeforaddpayment = 'payment_salary'; + $labelforaddpayment = '(SalaryPayment)'; + $addbankurl = 'credit-transfer'; + } else { + $modeforaddpayment = 'payment_supplier'; + $labelforaddpayment = '(SupplierInvoicePayment)'; + $addbankurl = 'credit-transfer'; + } } else { $modeforaddpayment = 'payment'; $labelforaddpayment = '(CustomerInvoicePayment)'; @@ -600,7 +623,7 @@ class BonPrelevement extends CommonObject // End of procedure if ($error == 0) { - $this->date_credit = $date; + $this->date_credit = $date; // date credit or debit $this->statut = self::STATUS_CREDITED; $this->status = self::STATUS_CREDITED; @@ -619,9 +642,9 @@ class BonPrelevement extends CommonObject /** * Set withdrawal to transmited status * - * @param User $user id of user - * @param int $date date of action - * @param string $method method of transmision to bank (0=Internet, 1=Api...) + * @param User $user Id of user + * @param int $date Date of action + * @param string $method Method of transmision to bank (0=Internet, 1=Api...) * @return int >0 if OK, <0 if KO */ public function set_infotrans($user, $date, $method) @@ -632,6 +655,7 @@ class BonPrelevement extends CommonObject $error = 0; dol_syslog(get_class($this)."::set_infotrans Start", LOG_INFO); + if ($this->db->begin()) { $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons "; $sql .= " SET fk_user_trans = ".$user->id; @@ -676,12 +700,13 @@ class BonPrelevement extends CommonObject } /** - * Get invoice list + * Get invoice or salary list * * @param int $amounts If you want to get the amount of the order for each invoice - * @return array Array(Id of invoices, Amount to pay) + * @param string $type 'salary' for type=salary + * @return array Array(Id of invoices/salary, Amount to pay) */ - private function getListInvoices($amounts = 0) + private function getListInvoices($amounts = 0, $type = '') { global $conf; @@ -689,9 +714,7 @@ class BonPrelevement extends CommonObject dol_syslog(get_class($this)."::getListInvoices"); - /* - * Returns all invoices presented within same order - */ + // Returns all invoices presented within same order $sql = "SELECT "; if ($this->type == 'bank-transfer') { $sql .= " p.fk_facture_fourn"; @@ -820,7 +843,7 @@ class BonPrelevement extends CommonObject * Get number of invoices to pay * * @param string $type 'direct-debit' or 'bank-transfer' - * @param int $forsalary 0= for facture & facture_supplier, 1=for salary + * @param int $forsalary 0= for facture & facture_supplier, 1=for salary * @return int Return integer Date: Thu, 14 Dec 2023 14:01:28 +0100 Subject: [PATCH 096/107] Fix add tms field to help debug v19 and sepa payment pbs --- htdocs/install/mysql/migration/18.0.0-19.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_prelevement_lignes.sql | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/18.0.0-19.0.0.sql b/htdocs/install/mysql/migration/18.0.0-19.0.0.sql index 2461ed733cb..4a6f4c0325c 100644 --- a/htdocs/install/mysql/migration/18.0.0-19.0.0.sql +++ b/htdocs/install/mysql/migration/18.0.0-19.0.0.sql @@ -201,3 +201,5 @@ ALTER TABLE llx_commande_fournisseur_dispatch ADD COLUMN element_type varchar(50 ALTER TABLE llx_expensereport DROP INDEX idx_expensereport_fk_refuse, ADD INDEX idx_expensereport_fk_refuse(fk_user_refuse); INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (1,'66','Société publique locale'); + +ALTER TABLE llx_prelevement_lignes ADD COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; diff --git a/htdocs/install/mysql/tables/llx_prelevement_lignes.sql b/htdocs/install/mysql/tables/llx_prelevement_lignes.sql index be55cab9638..f3de4f8f780 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_lignes.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_lignes.sql @@ -32,5 +32,6 @@ create table llx_prelevement_lignes number varchar(255), cle_rib varchar(5), - note text + note text, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP )ENGINE=innodb; From 33dd878f9eaf58f8b0d55d09152ffcf7f4dbbf91 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Dec 2023 14:48:22 +0100 Subject: [PATCH 097/107] Fix payment SEPA for salary --- .../class/bonprelevement.class.php | 38 +++++++------------ htdocs/core/class/commoninvoice.class.php | 10 +++-- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 7bd53e14dfd..16ed1987ef8 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -216,7 +216,7 @@ class BonPrelevement extends CommonObject /** * Add invoice to withdrawal * - * @param int $invoice_id id invoice to add + * @param int $invoice_id ID of invoice to add or ID of salary to add * @param int $client_id id invoice customer * @param string $client_nom customer name * @param int $amount amount of invoice @@ -225,7 +225,7 @@ class BonPrelevement extends CommonObject * @param string $number bank account number * @param string $number_key number key of account number * @param string $type 'debit-order' or 'bank-transfer' - * @param string $sourcetype 'salary' for invoice of salary + * @param string $sourcetype 'salary' for salary, '' for invoices * @return int >0 if OK, <0 if KO */ public function AddFacture($invoice_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key, $type = 'debit-order', $sourcetype = '') @@ -234,7 +234,7 @@ class BonPrelevement extends CommonObject $result = 0; $line_id = 0; - // Add lines + // Add lines into prelevement_lignes $result = $this->addline($line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key, $sourcetype); @@ -244,7 +244,7 @@ class BonPrelevement extends CommonObject if ($type != 'bank-transfer') { $sql .= "fk_facture"; } else { - if (!empty($sourcetype)) { + if ($sourcetype == 'salary') { $sql .= "fk_salary"; } else { $sql .= "fk_facture_fourn"; @@ -279,21 +279,21 @@ class BonPrelevement extends CommonObject /** * Add line to withdrawal * - * @param int $line_id id line to add - * @param int $client_id id invoice customer + * @param int $line_id ID of line added (returned parameter) + * @param int $client_id ID of thirdparty for invoices, ID of user for salaries * @param string $client_nom customer name * @param int $amount amount of invoice * @param string $code_banque code of bank withdrawal * @param string $code_guichet code of bank's office * @param string $number bank account number * @param string $number_key number key of account number - * @param string $sourcetype check if is salary invoice + * @param string $sourcetype 'salary' for salary, '' for invoices * @return int >0 if OK, <0 if KO */ public function addline(&$line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key, $sourcetype = '') { $result = -1; - $concat = 0; + $concat = 0; // ??? what is this for. Seems not used. if ($concat == 1) { /* @@ -302,10 +302,10 @@ class BonPrelevement extends CommonObject $sql = "SELECT rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes"; $sql .= " WHERE fk_prelevement_bons = ".((int) $this->id); - if (empty($sourcetype)) { - $sql .= " AND fk_soc =".((int) $client_id); + if ($sourcetype == 'salary') { + $sql .= " AND fk_soc = ".((int) $client_id); } else { - $sql .= " AND fk_user =".((int) $client_id); + $sql .= " AND fk_user = ".((int) $client_id); } $sql .= " AND code_banque = '".$this->db->escape($code_banque)."'"; $sql .= " AND code_guichet = '".$this->db->escape($code_guichet)."'"; @@ -330,17 +330,17 @@ class BonPrelevement extends CommonObject $sql .= ", code_guichet"; $sql .= ", number"; $sql .= ", cle_rib"; - $sql .= (!empty($sourcetype) ? ", fk_user" : ""); + $sql .= ($sourcetype == 'salary' ? ", fk_user" : ""); $sql .= ") VALUES ("; $sql .= $this->id; - $sql .= ", ".(empty($sourcetype) ? ((int) $client_id) : 0); + $sql .= ", ".(($sourcetype != 'salary') ? ((int) $client_id) : "NULL"); $sql .= ", '".$this->db->escape($client_nom)."'"; $sql .= ", ".((float) price2num($amount)); $sql .= ", '".$this->db->escape($code_banque)."'"; $sql .= ", '".$this->db->escape($code_guichet)."'"; $sql .= ", '".$this->db->escape($number)."'"; $sql .= ", '".$this->db->escape($number_key)."'"; - $sql .= (!empty($sourcetype) ? ", ". ((int) $client_id) : ''); + $sql .= (($sourcetype == 'salary') ? ", ". ((int) $client_id) : ''); $sql .= ")"; if ($this->db->query($sql)) { $line_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_lignes"); @@ -1261,15 +1261,6 @@ class BonPrelevement extends CommonObject // Add lines for the bon if (count($factures_prev) > 0) { foreach ($factures_prev as $fac) { // Add a link in database for each invoice ro salary - // Fetch invoice - /* - $result = $fact->fetch($fac[0]); - if ($result < 0) { - $this->error = 'ERRORBONPRELEVEMENT Failed to load invoice with id '.$fac[0]; - break; - } - */ - /* * Add standing order. This add record into llx_prelevement_lignes and llx_prelevement * @@ -1287,7 +1278,6 @@ class BonPrelevement extends CommonObject * $fac[11] : IBAN * $fac[12] : frstrcur */ - $ri = $this->AddFacture($fac[0], $fac[2], $fac[8], $fac[7], $fac[3], $fac[4], $fac[5], $fac[6], $type, $sourcetype); if ($ri <> 0) { diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 1047e0f884f..83f38d2a70f 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -1139,14 +1139,18 @@ abstract class CommonInvoice extends CommonObject } // Load the pending payment request to process (with rowid=$did) - $sql = "SELECT rowid, date_demande, amount, fk_facture, fk_facture_fourn, fk_prelevement_bons"; + $sql = "SELECT rowid, date_demande, amount, fk_facture, fk_facture_fourn, fk_salary, fk_prelevement_bons"; $sql .= " FROM ".$this->db->prefix()."prelevement_demande"; $sql .= " WHERE rowid = ".((int) $did); if ($type != 'bank-transfer' && $type != 'credit-transfer') { - $sql .= " AND fk_facture = ".((int) $this->id); // Add a protection to not pay another invoice than current one + $sql .= " AND fk_facture = ".((int) $this->id); // Add a protection to not pay another invoice than current one } if ($type != 'direct-debit') { - $sql .= " AND fk_facture_fourn = ".((int) $this->id); // Add a protection to not pay another invoice than current one + if ($$sourcetype == 'salary') { + $sql .= " AND fk_salary = ".((int) $this->id); // Add a protection to not pay another salary than current one + } else { + $sql .= " AND fk_facture_fourn = ".((int) $this->id); // Add a protection to not pay another invoice than current one + } } $sql .= " AND traite = 0"; // To not process payment request that were already converted into a direct debit or credit transfer order (Note: fk_prelevement_bons is also empty when traite = 0) From 14ba1138c4511a6eab2f301e06f588184b074c16 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Dec 2023 14:48:22 +0100 Subject: [PATCH 098/107] Fix payment SEPA for salary --- .../class/bonprelevement.class.php | 38 +++++++------------ htdocs/core/class/commoninvoice.class.php | 10 +++-- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 7bd53e14dfd..011d965f278 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -216,7 +216,7 @@ class BonPrelevement extends CommonObject /** * Add invoice to withdrawal * - * @param int $invoice_id id invoice to add + * @param int $invoice_id ID of invoice to add or ID of salary to add * @param int $client_id id invoice customer * @param string $client_nom customer name * @param int $amount amount of invoice @@ -225,7 +225,7 @@ class BonPrelevement extends CommonObject * @param string $number bank account number * @param string $number_key number key of account number * @param string $type 'debit-order' or 'bank-transfer' - * @param string $sourcetype 'salary' for invoice of salary + * @param string $sourcetype 'salary' for salary, '' for invoices * @return int >0 if OK, <0 if KO */ public function AddFacture($invoice_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key, $type = 'debit-order', $sourcetype = '') @@ -234,7 +234,7 @@ class BonPrelevement extends CommonObject $result = 0; $line_id = 0; - // Add lines + // Add lines into prelevement_lignes $result = $this->addline($line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key, $sourcetype); @@ -244,7 +244,7 @@ class BonPrelevement extends CommonObject if ($type != 'bank-transfer') { $sql .= "fk_facture"; } else { - if (!empty($sourcetype)) { + if ($sourcetype == 'salary') { $sql .= "fk_salary"; } else { $sql .= "fk_facture_fourn"; @@ -279,21 +279,21 @@ class BonPrelevement extends CommonObject /** * Add line to withdrawal * - * @param int $line_id id line to add - * @param int $client_id id invoice customer + * @param int $line_id ID of line added (returned parameter) + * @param int $client_id ID of thirdparty for invoices, ID of user for salaries * @param string $client_nom customer name * @param int $amount amount of invoice * @param string $code_banque code of bank withdrawal * @param string $code_guichet code of bank's office * @param string $number bank account number * @param string $number_key number key of account number - * @param string $sourcetype check if is salary invoice + * @param string $sourcetype 'salary' for salary, '' for invoices * @return int >0 if OK, <0 if KO */ public function addline(&$line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key, $sourcetype = '') { $result = -1; - $concat = 0; + $concat = 0; // ??? what is this for. Seems not used. if ($concat == 1) { /* @@ -302,10 +302,10 @@ class BonPrelevement extends CommonObject $sql = "SELECT rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes"; $sql .= " WHERE fk_prelevement_bons = ".((int) $this->id); - if (empty($sourcetype)) { - $sql .= " AND fk_soc =".((int) $client_id); + if ($sourcetype == 'salary') { + $sql .= " AND fk_soc = ".((int) $client_id); } else { - $sql .= " AND fk_user =".((int) $client_id); + $sql .= " AND fk_user = ".((int) $client_id); } $sql .= " AND code_banque = '".$this->db->escape($code_banque)."'"; $sql .= " AND code_guichet = '".$this->db->escape($code_guichet)."'"; @@ -330,17 +330,17 @@ class BonPrelevement extends CommonObject $sql .= ", code_guichet"; $sql .= ", number"; $sql .= ", cle_rib"; - $sql .= (!empty($sourcetype) ? ", fk_user" : ""); + $sql .= ($sourcetype == 'salary' ? ", fk_user" : ""); $sql .= ") VALUES ("; $sql .= $this->id; - $sql .= ", ".(empty($sourcetype) ? ((int) $client_id) : 0); + $sql .= ", ".(($sourcetype != 'salary') ? ((int) $client_id) : "0"); // fk_soc can't be null $sql .= ", '".$this->db->escape($client_nom)."'"; $sql .= ", ".((float) price2num($amount)); $sql .= ", '".$this->db->escape($code_banque)."'"; $sql .= ", '".$this->db->escape($code_guichet)."'"; $sql .= ", '".$this->db->escape($number)."'"; $sql .= ", '".$this->db->escape($number_key)."'"; - $sql .= (!empty($sourcetype) ? ", ". ((int) $client_id) : ''); + $sql .= (($sourcetype == 'salary') ? ", ". ((int) $client_id) : ''); $sql .= ")"; if ($this->db->query($sql)) { $line_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_lignes"); @@ -1261,15 +1261,6 @@ class BonPrelevement extends CommonObject // Add lines for the bon if (count($factures_prev) > 0) { foreach ($factures_prev as $fac) { // Add a link in database for each invoice ro salary - // Fetch invoice - /* - $result = $fact->fetch($fac[0]); - if ($result < 0) { - $this->error = 'ERRORBONPRELEVEMENT Failed to load invoice with id '.$fac[0]; - break; - } - */ - /* * Add standing order. This add record into llx_prelevement_lignes and llx_prelevement * @@ -1287,7 +1278,6 @@ class BonPrelevement extends CommonObject * $fac[11] : IBAN * $fac[12] : frstrcur */ - $ri = $this->AddFacture($fac[0], $fac[2], $fac[8], $fac[7], $fac[3], $fac[4], $fac[5], $fac[6], $type, $sourcetype); if ($ri <> 0) { diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 1047e0f884f..83f38d2a70f 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -1139,14 +1139,18 @@ abstract class CommonInvoice extends CommonObject } // Load the pending payment request to process (with rowid=$did) - $sql = "SELECT rowid, date_demande, amount, fk_facture, fk_facture_fourn, fk_prelevement_bons"; + $sql = "SELECT rowid, date_demande, amount, fk_facture, fk_facture_fourn, fk_salary, fk_prelevement_bons"; $sql .= " FROM ".$this->db->prefix()."prelevement_demande"; $sql .= " WHERE rowid = ".((int) $did); if ($type != 'bank-transfer' && $type != 'credit-transfer') { - $sql .= " AND fk_facture = ".((int) $this->id); // Add a protection to not pay another invoice than current one + $sql .= " AND fk_facture = ".((int) $this->id); // Add a protection to not pay another invoice than current one } if ($type != 'direct-debit') { - $sql .= " AND fk_facture_fourn = ".((int) $this->id); // Add a protection to not pay another invoice than current one + if ($$sourcetype == 'salary') { + $sql .= " AND fk_salary = ".((int) $this->id); // Add a protection to not pay another salary than current one + } else { + $sql .= " AND fk_facture_fourn = ".((int) $this->id); // Add a protection to not pay another invoice than current one + } } $sql .= " AND traite = 0"; // To not process payment request that were already converted into a direct debit or credit transfer order (Note: fk_prelevement_bons is also empty when traite = 0) From 6ca736e8a5490905901f7d4bd823e95fd32bebbc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Dec 2023 15:16:11 +0100 Subject: [PATCH 099/107] Debug v19 --- htdocs/core/tpl/objectline_view.tpl.php | 8 ++++++-- htdocs/fourn/facture/card.php | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 25a6fac0b16..ef78b72ce1c 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -497,8 +497,12 @@ if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlin $coldisplay++; } } else { - print '
'.$langs->trans('IntracommReportTransportMode').''; $form->selectTransportMode(GETPOSTISSET('transport_mode_id') ? GETPOST('transport_mode_id') : $transport_mode_id, 'transport_mode_id'); print '
'; print ''; print '\n"; if ($object->type == 'bank-transfer' && !$salaryBonPl) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b15a1da96c3..4cb9b708f6c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -678,6 +678,11 @@ abstract class CommonObject * @var float Amount already paid (used to show correct status) */ public $alreadypaid; + /** + * @var float Amount already paid (used to show correct status) + * @deprecated Duplicate of $alreadypaid + */ + public $totalpaid; /** * @var array Array with label of status diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 1bedbe21fdf..47275863ce6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2517,7 +2517,13 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi } else { $morehtmlstatus .= ''.$object->getLibStatut(6, 1).''; } - } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan', 'tva', 'salary'))) { + } elseif (in_array($object->element, array('salary'))) { + $tmptxt = $object->getLibStatut(6, $object->alreadypaid); + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) { + $tmptxt = $object->getLibStatut(5, $object->alreadypaid); + } + $morehtmlstatus .= $tmptxt; + } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan', 'tva'))) { // TODO Move this to use ->alreadypaid $tmptxt = $object->getLibStatut(6, $object->totalpaid); if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) { $tmptxt = $object->getLibStatut(5, $object->totalpaid); diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 5542bdd344d..4ec7883c40a 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -877,7 +877,7 @@ if ($id > 0) { $morehtmlref .= ''; $totalpaid = $object->getSommePaiement(); - $object->totalpaid = $totalpaid; + $object->alreadypaid = $totalpaid; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index 1189fc31fdc..2c0e779e024 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -268,6 +268,7 @@ class Salary extends CommonObject $this->dateep = $this->db->jdate($obj->dateep); $this->note = $obj->note; $this->paye = $obj->paye; + $this->status = $obj->paye; $this->fk_bank = $obj->fk_bank; $this->fk_user_author = $obj->fk_user_author; $this->fk_user_modif = $obj->fk_user_modif; @@ -479,19 +480,29 @@ class Salary extends CommonObject /** * getTooltipContentArray - * @param array $params params to construct tooltip data + * + * @param array $params params to construct tooltip data * @since v18 * @return array */ public function getTooltipContentArray($params) { - global $conf, $langs, $user; + global $langs; $langs->loadLangs(['salaries']); + // Complete datas + if (!empty($params['fromajaxtooltip']) && !isset($this->alreadypaid)) { + // Load the alreadypaid field + $this->alreadypaid = $this->getSommePaiement(0); + } + $datas = []; - $option = $params['option'] ?? ''; + $datas['picto'] = ''.$langs->trans("Salary").''; + if (isset($this->status) && isset($this->alreadypaid)) { + $datas['picto'] .= ' '.$this->getLibStatut(5, $this->alreadypaid); + } $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; return $datas; @@ -509,9 +520,7 @@ class Salary extends CommonObject */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { - global $db, $conf, $langs, $hookmanager; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; + global $conf, $langs, $hookmanager; if (!empty($conf->dol_no_mouse_hover)) { $notooltip = 1; diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index 4bb0d118839..64b82b4e8f2 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -646,6 +646,8 @@ while ($i < $imaxinloop) { $salstatic->ref = $obj->rowid; $salstatic->label = $obj->label; $salstatic->paye = $obj->paye; + $salstatic->status = $obj->paye; + $salstatic->alreadypaid = $obj->alreadypayed; $salstatic->datesp = $obj->datesp; $salstatic->dateep = $obj->dateep; $salstatic->amount = $obj->amount; @@ -774,7 +776,7 @@ while ($i < $imaxinloop) { } $totalarray['val']['totalttcfield'] += $obj->amount; - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } From 03c05b4fd8d4b70d2f569fe423b0b1ba6a36986d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Dec 2023 18:05:46 +0100 Subject: [PATCH 103/107] Debug v19 --- .../class/bonprelevement.class.php | 57 ++++++++++++---- htdocs/core/class/commonobject.class.php | 6 +- htdocs/salaries/class/paymentsalary.class.php | 68 +++++++++---------- 3 files changed, 79 insertions(+), 52 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 173785efa8d..6ec256df84f 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -502,10 +502,9 @@ class BonPrelevement extends CommonObject if ($this->error) { $error++; } - //var_dump($facs);exit; // Loop on each invoice or salary. - // $facs=array(0=>id, 1=>amount requested) + // $facs should be array(0=>id, 1=>amount requested) $num = count($facs); for ($i = 0; $i < $num; $i++) { if ($this->type == 'bank-transfer') { @@ -521,7 +520,15 @@ class BonPrelevement extends CommonObject $result = $fac->fetch($facs[$i][0]); $amounts[$fac->id] = $facs[$i][1]; - $amountsperthirdparty[$fac->socid][$fac->id] = $facs[$i][1]; + if ($this->type == 'bank-transfer') { + if ($type == 'salary') { + $amountsperthirdparty[$fac->fk_user][$fac->id] = $facs[$i][1]; + } else { + $amountsperthirdparty[$fac->socid][$fac->id] = $facs[$i][1]; + } + } else { + $amountsperthirdparty[$fac->socid][$fac->id] = $facs[$i][1]; + } $totalpaid = $fac->getSommePaiement(); $totalcreditnotes = 0; @@ -534,8 +541,13 @@ class BonPrelevement extends CommonObject } $alreadypayed = $totalpaid + $totalcreditnotes + $totaldeposits; - // @TODO Move this after creation of payment - if (price2num($alreadypayed + $facs[$i][1], 'MT') == $fac->total_ttc) { + // Set the main document to pay with status Paid. + // @TODO Move this after creation of payments done after + $amountofdocument = $fac->total_ttc; + if ($type == 'salary') { + $amountofdocument = $fac->amount; + } + if (price2num($alreadypayed + $facs[$i][1], 'MT') == price2num($amountofdocument, 'MT')) { $result = $fac->setPaid($user); if ($result < 0) { $this->error = $fac->error; @@ -543,7 +555,6 @@ class BonPrelevement extends CommonObject } } } - //var_dump($amountsperthirdparty);exit; // Make one payment per customer or employee foreach ($amountsperthirdparty as $thirdpartyid => $cursoramounts) { @@ -560,8 +571,16 @@ class BonPrelevement extends CommonObject $paiement->amounts = $cursoramounts; // Array with detail of dispatching of payments for each invoice if ($this->type == 'bank-transfer') { - $paiement->paiementid = 2; - $paiement->paiementcode = 'VIR'; + if ($type == 'salary') { + $paiement->datep = $date; + + $paiement->paiementid = 2; + $paiement->fk_typepayment = 2; + $paiement->paiementcode = 'VIR'; + } else { + $paiement->paiementid = 2; + $paiement->paiementcode = 'VIR'; + } } else { $paiement->paiementid = 3; $paiement->paiementcode = 'PRE'; @@ -570,8 +589,9 @@ class BonPrelevement extends CommonObject $paiement->num_payment = $this->ref; // Set ref of direct debit note $paiement->id_prelevement = $this->id; - $paiement_id = $paiement->create($user); // This use ->paiementid, that is ID of payment mode - if ($paiement_id < 0) { + $result = $paiement->create($user); // This use ->paiementid, that is ID of payment mode + + if ($result < 0) { $error++; $this->error = $paiement->error; $this->errors = $paiement->errors; @@ -594,6 +614,7 @@ class BonPrelevement extends CommonObject } $result = $paiement->addPaymentToBank($user, $modeforaddpayment, $labelforaddpayment, $fk_bank_account, '', '', 0, '', $addbankurl); + if ($result < 0) { $error++; $this->error = $paiement->error; @@ -700,9 +721,9 @@ class BonPrelevement extends CommonObject } /** - * Get invoice or salary list + * Get invoice or salary list (with amount or not) * - * @param int $amounts If you want to get the amount of the order for each invoice + * @param int $amounts If you want to get the amount of the order for each invoice or salary * @param string $type 'salary' for type=salary * @return array Array(Id of invoices/salary, Amount to pay) */ @@ -717,7 +738,11 @@ class BonPrelevement extends CommonObject // Returns all invoices presented within same order $sql = "SELECT "; if ($this->type == 'bank-transfer') { - $sql .= " p.fk_facture_fourn"; + if ($type == 'salary') { + $sql .= " p.fk_salary"; + } else { + $sql .= " p.fk_facture_fourn"; + } } else { $sql .= " p.fk_facture"; } @@ -733,7 +758,11 @@ class BonPrelevement extends CommonObject $sql .= " AND pb.entity = ".((int) $conf->entity); if ($amounts) { if ($this->type == 'bank-transfer') { - $sql .= " GROUP BY p.fk_facture_fourn"; + if ($type == 'salary') { + $sql .= " GROUP BY p.fk_salary"; + } else { + $sql .= " GROUP BY p.fk_facture_fourn"; + } } else { $sql .= " GROUP BY p.fk_facture"; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4cb9b708f6c..ef31fb50485 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -675,12 +675,12 @@ abstract class CommonObject public $sendtoid; /** - * @var float Amount already paid (used to show correct status) + * @var float Amount already paid from getSommePaiement() (used to show correct status) + * @deprecated Duplicate of $totalpaid */ public $alreadypaid; /** - * @var float Amount already paid (used to show correct status) - * @deprecated Duplicate of $alreadypaid + * @var float Amount already paid from getSommePaiement() (used to show correct status) */ public $totalpaid; diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php index fb9a2ed3b49..d1c6b185181 100644 --- a/htdocs/salaries/class/paymentsalary.class.php +++ b/htdocs/salaries/class/paymentsalary.class.php @@ -233,45 +233,43 @@ class PaymentSalary extends CommonObject $this->db->begin(); if ($totalamount != 0) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (entity, fk_salary, datec, datep, amount,"; - $sql .= " fk_typepayment, num_payment, note, fk_user_author, fk_bank)"; - $sql .= " VALUES (".((int) $conf->entity).", ".((int) $this->fk_salary).", '".$this->db->idate($now)."',"; - $sql .= " '".$this->db->idate($this->datep)."',"; - $sql .= " ".price2num($totalamount).","; - $sql .= " ".((int) $this->fk_typepayment).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".((int) $user->id).","; - $sql .= " 0)"; + // Insert array of amounts + foreach ($this->amounts as $key => $amount) { + $salary_id = $key; + $amount = price2num($amount); + if (is_numeric($amount) && !empty($amount)) { + // We can have n payments for 1 salary but we can't have 1 payments for n salaries (for invoices link is n-n, not for salaries). + $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (entity, fk_salary, datec, datep, amount,"; + $sql .= " fk_typepayment, num_payment, note, fk_user_author, fk_bank)"; + $sql .= " VALUES (".((int) $conf->entity).", ".((int) $salary_id).", '".$this->db->idate($now)."',"; + $sql .= " '".$this->db->idate($this->datep)."',"; + $sql .= " ".price2num($amount).","; + $sql .= " ".((int) $this->fk_typepayment).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".((int) $user->id).","; + $sql .= " 0)"; - $resql = $this->db->query($sql); - if ($resql) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); + $resql = $this->db->query($sql); + if ($resql) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); + } - // Insere tableau des montants / factures - foreach ($this->amounts as $key => $amount) { - $contribid = $key; - if (is_numeric($amount) && $amount <> 0) { - $amount = price2num($amount); - - // If we want to closed payed invoices - if ($closepaidcontrib) { - $tmpsalary = new Salary($this->db); - $tmpsalary->fetch($contribid); - $paiement = $tmpsalary->getSommePaiement(); - //$creditnotes=$tmpsalary->getSumCreditNotesUsed(); - $creditnotes = 0; - //$deposits=$tmpsalary->getSumDepositsUsed(); - $deposits = 0; - $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT'); - $remaintopay = price2num($tmpsalary->amount - $paiement - $creditnotes - $deposits, 'MT'); - if ($remaintopay == 0) { - $result = $tmpsalary->setPaid($user); - } else { - dol_syslog("Remain to pay for salary id=".$contribid." not null. We do nothing."); - } + // If we want to closed payed invoices + if ($closepaidcontrib) { + $tmpsalary = new Salary($this->db); + $tmpsalary->fetch($salary_id); + $paiement = $tmpsalary->getSommePaiement(); + //$creditnotes=$tmpsalary->getSumCreditNotesUsed(); + $creditnotes = 0; + //$deposits=$tmpsalary->getSumDepositsUsed(); + $deposits = 0; + $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT'); + $remaintopay = price2num($tmpsalary->amount - $paiement - $creditnotes - $deposits, 'MT'); + if ($remaintopay == 0) { + $result = $tmpsalary->setPaid($user); + } else { + dol_syslog("Remain to pay for salary id=".$salary_id." not null. We do nothing."); } } } - } else { - $error++; } } @@ -284,7 +282,7 @@ class PaymentSalary extends CommonObject $this->amount = $totalamount; $this->total = $totalamount; // deprecated $this->db->commit(); - return $this->id; + return $this->id; // id of the last payment inserted } else { $this->error = $this->db->error(); $this->db->rollback(); From 3487b76052521032f0240db4a7e04b6a48b8682c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Dec 2023 10:28:16 +0100 Subject: [PATCH 104/107] Fix phpcs --- dev/tools/apstats.php | 26 ++++++++++++++------- htdocs/salaries/class/salary.class.php | 32 +++++++++++++++++++------- phpstan.neon | 2 +- 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/dev/tools/apstats.php b/dev/tools/apstats.php index e15c8b5ace2..f49623ff91f 100755 --- a/dev/tools/apstats.php +++ b/dev/tools/apstats.php @@ -38,6 +38,8 @@ error_reporting(E_ALL & ~E_DEPRECATED); define('PRODUCT', "apstats"); define('VERSION', "1.0"); +$phpstanlevel = 2; + print '***** '.constant('PRODUCT').' - '.constant('VERSION').' *****'."\n"; if (empty($argv[1])) { @@ -71,6 +73,7 @@ while ($i < $argc) { $i++; } +$timestart = time(); // Count lines of code of Dolibarr itself /* @@ -102,7 +105,7 @@ exec($commandcheck, $output_arrdep, $resexecdep); // Get technical debt -$commandcheck = ($dirphpstan ? $dirphpstan.'/' : '').'phpstan -v analyze -a build/phpstan/bootstrap.php --memory-limit 5G --error-format=github'; +$commandcheck = ($dirphpstan ? $dirphpstan.'/' : '').'phpstan --level='.$phpstanlevel.' -v analyze -a build/phpstan/bootstrap.php --memory-limit 5G --error-format=github'; print 'Execute PHPStan to get the technical debt: '.$commandcheck."\n"; $output_arrtd = array(); $resexectd = 0; @@ -169,6 +172,8 @@ foreach (array('proj', 'dep') as $source) { } } +$timeend = time(); + /* * View @@ -293,7 +298,7 @@ $html .= ''."\n"; $html .= '
'."\n"; $html .= '

Advanced Project Statistics

'."\n"; $currentDate = date("Y-m-d H:i:s"); // Format: Year-Month-Day Hour:Minute:Second -$html .= 'Generated on '.$currentDate.''."\n"; +$html .= 'Generated on '.$currentDate.' in '.($timeend - $timestart).' seconds'."\n"; $html .= '
'."\n"; $html .= '
'."\n"; @@ -372,19 +377,24 @@ $html .= ''.formatNumber($arraycocomo['proj']['people'] * $arraycocomo['proj' $html .= ' monthes people
'; $html .= '
'."\n"; -$html .= '
'."\n"; -$html .= '

Technical debt ('.count($output_arrtd).')


'."\n"; -$html .= '
'."\n"; -$html .= '
'; print $langs->trans('IntracommReportTransportMode'); From 68d89d442110063224fd21e71061a778db65647d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Dec 2023 15:29:20 +0100 Subject: [PATCH 100/107] Fix pgsql install --- htdocs/install/pgsql/functions/functions.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/pgsql/functions/functions.sql b/htdocs/install/pgsql/functions/functions.sql index 6727d486d35..dacec28bd89 100644 --- a/htdocs/install/pgsql/functions/functions.sql +++ b/htdocs/install/pgsql/functions/functions.sql @@ -105,6 +105,7 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_cronjob FOR EACH ROW CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_ecm_directories FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_ecm_files FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_element_resources FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_element_time FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_emailcollector_emailcollector FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_emailcollector_emailcollectoraction FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_emailcollector_emailcollectorfilter FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); @@ -140,6 +141,7 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_payment_donation FOR CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_payment_expensereport FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_payment_loan FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_payment_salary FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_prelevement_lignes FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_printing FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_product FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_product_batch FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); @@ -153,7 +155,6 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_projet FOR EACH ROW CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_projet_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_projet_task FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_projet_task_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_element_time FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_propal FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_propal_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_propal_merge_pdf_product FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); From 20a934d7248a5f6c878700573ac0ee35d7120e36 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Dec 2023 15:32:23 +0100 Subject: [PATCH 101/107] Fix sql error --- htdocs/compta/prelevement/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 396dc4c6cc0..04b59c959ce 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -458,10 +458,11 @@ if ($id > 0 || $ref) { // Lines into withdraw request if ($salaryBonPl) { - $sql = "SELECT pl.rowid, pl.statut, pl.amount, pl.fk_user"; + $sql = "SELECT pl.rowid, pl.statut, pl.amount, pl.fk_user,"; $sql .= " u.rowid as socid, u.login as name"; $sql .=" FROM llx_prelevement_lignes as pl"; $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as pb"; + $sql .= ", ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $id); $sql .= " AND pl.fk_prelevement_bons = pb.rowid"; $sql .= " AND pb.entity = ".((int) $conf->entity); // No sharing of entity here From 80576444f7da5daecd364ea838afdc6d3ab91966 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Dec 2023 16:00:05 +0100 Subject: [PATCH 102/107] Debug v19 --- htdocs/compta/prelevement/factures.php | 2 +- htdocs/core/class/commonobject.class.php | 5 +++++ htdocs/core/lib/functions.lib.php | 8 +++++++- htdocs/salaries/card.php | 2 +- htdocs/salaries/class/salary.class.php | 21 +++++++++++++++------ htdocs/salaries/list.php | 4 +++- 6 files changed, 32 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 52fb559e8a9..f1d9c22cc19 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -342,7 +342,7 @@ if ($resql) { print '
'; - print($salaryBonPl ? $salarytmp->getNomUrl(1) : $invoicetmp->getNomUrl(1)); + print ($salaryBonPl ? $salarytmp->getNomUrl(1) : $invoicetmp->getNomUrl(1)); print "'.$salstatic->LibStatut($obj->paye, 5, $obj->alreadypayed).''.$salstatic->getLibStatut(5, $obj->alreadypayed).'
'."\n"; -$html .= ''."\n"; +$tmp = ''; +$nblines = 0; foreach ($output_arrtd as $line) { $reg = array(); //print $line."\n"; preg_match('/^::error file=(.*),line=(\d+),col=(\d+)::(.*)$/', $line, $reg); if (!empty($reg[1])) { - $html .= ''."\n"; + $tmp .= ''."\n"; + $nblines++; } } + +$html .= '
'."\n"; +$html .= '

Technical debt - PHPStan level '.$phpstanlevel.' ('.$nblines.')


'."\n"; +$html .= '
'."\n"; +$html .= '
FileLineType
'.$reg[1].''.$reg[2].''.$reg[4].'
'.$reg[1].''.$reg[2].''.$reg[4].'
'."\n"; +$html .= ''."\n"; +$html .= $tmp; $html .= '
FileLineType
'; $html .= ''; $html .= ''."\n"; diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index 2c0e779e024..f6cebf0c07f 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -597,31 +597,47 @@ class Salary extends CommonObject /** * Return amount of payments already done * - * @return int Amount of payment already done, <0 if KO + * @param int $multicurrency Return multicurrency_amount instead of amount. -1=Return both. + * @return float|int|array Amount of payment already done, <0 and set ->error if KO */ - public function getSommePaiement() + public function getSommePaiement($multicurrency = 0) { $table = 'payment_salary'; $field = 'fk_salary'; $sql = "SELECT sum(amount) as amount"; + //sum(multicurrency_amount) as multicurrency_amount // Not yet supported $sql .= " FROM ".MAIN_DB_PREFIX.$table; $sql .= " WHERE ".$field." = ".((int) $this->id); dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); + $resql = $this->db->query($sql); if ($resql) { - $amount = 0; - $obj = $this->db->fetch_object($resql); - if ($obj) { - $amount = $obj->amount ? $obj->amount : 0; - } $this->db->free($resql); - return $amount; + + if ($obj) { + if ($multicurrency < 0) { + //$this->sumpayed = $obj->amount; + //$this->sumpayed_multicurrency = $obj->multicurrency_amount; + //return array('alreadypaid'=>(float) $obj->amount, 'alreadypaid_multicurrency'=>(float) $obj->multicurrency_amount); + return array(); // Not yet supported + } elseif ($multicurrency) { + //$this->sumpayed_multicurrency = $obj->multicurrency_amount; + //return (float) $obj->multicurrency_amount; + return -1; // Not yet supported + } else { + //$this->sumpayed = $obj->amount; + return (float) $obj->amount; + } + } else { + return 0; + } } else { + $this->error = $this->db->lasterror(); return -1; } } diff --git a/phpstan.neon b/phpstan.neon index 9b2515e4ea9..29d78e29db3 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,6 @@ parameters: customRulesetUsed: true - level: 1 + level: 2 fileExtensions: - php paths: From dc134cddbad2f1f7e3bf3c88dcdf47c8684dd7d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Dec 2023 10:46:49 +0100 Subject: [PATCH 105/107] FIX Remove useless code line that make phpstan hang with not enough memory --- htdocs/core/db/DoliDB.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index d4034d9f9f4..081976ebc2b 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -29,8 +29,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/db/Database.interface.php'; */ abstract class DoliDB implements Database { - /** @var string Force subclass to implement VERSIONMIN */ - const VERSIONMIN=self::VERSIONMIN; /** @var bool|resource|mysqli|SQLite3|PgSql\Connection Database handler */ public $db; /** @var string Database type */ From dae7bb5e8043ce83d69b3fb375411ae5e71039b0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Dec 2023 11:02:50 +0100 Subject: [PATCH 106/107] Fix phpstan --- htdocs/core/db/DoliDB.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 081976ebc2b..206bac677a4 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -116,10 +116,10 @@ abstract class DoliDB implements Database * * @param string $subject string tested * @param string $pattern SQL pattern to match - * @param string $sqlstring whether or not the string being tested is an SQL expression + * @param int $sqlstring whether or not the string being tested is an SQL expression * @return string SQL string */ - public function regexpsql($subject, $pattern, $sqlstring = false) + public function regexpsql($subject, $pattern, $sqlstring = 0) { if ($sqlstring) { return "(". $subject ." REGEXP '" . $pattern . "')"; @@ -158,7 +158,7 @@ abstract class DoliDB implements Database * * @param string $stringtosanitize String to escape * @param int $allowsimplequote 1=Allow simple quotes in string. When string is used as a list of SQL string ('aa', 'bb', ...) - * @param string $allowsequals 1=Allow equals sign + * @param int $allowsequals 1=Allow equals sign * @return string String escaped */ public function sanitize($stringtosanitize, $allowsimplequote = 0, $allowsequals = 0) From 957c483890da28c1864483b7217b6d619df321be Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Dec 2023 11:18:04 +0100 Subject: [PATCH 107/107] Swith phpstan level to 2 --- dev/tools/apstats.php | 6 +++--- phpstan.neon | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dev/tools/apstats.php b/dev/tools/apstats.php index f49623ff91f..cad08090550 100755 --- a/dev/tools/apstats.php +++ b/dev/tools/apstats.php @@ -229,7 +229,7 @@ th,td { .nowrap { white-space: nowrap; } -.opacity { +.opacitymedium { opacity: 0.5; } .centpercent { @@ -298,7 +298,7 @@ $html .= ''."\n"; $html .= '
'."\n"; $html .= '

Advanced Project Statistics

'."\n"; $currentDate = date("Y-m-d H:i:s"); // Format: Year-Month-Day Hour:Minute:Second -$html .= 'Generated on '.$currentDate.' in '.($timeend - $timestart).' seconds'."\n"; +$html .= 'Generated on '.$currentDate.' in '.($timeend - $timestart).' seconds'."\n"; $html .= '
'."\n"; $html .= '
'."\n"; @@ -390,7 +390,7 @@ foreach ($output_arrtd as $line) { } $html .= '
'."\n"; -$html .= '

Technical debt - PHPStan level '.$phpstanlevel.' ('.$nblines.')


'."\n"; +$html .= '

Technical debt (PHPStan level '.$phpstanlevel.' => '.$nblines.' warnings)


'."\n"; $html .= '
'."\n"; $html .= ''."\n"; $html .= ''."\n"; diff --git a/phpstan.neon b/phpstan.neon index 29d78e29db3..a898f05f524 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -8,7 +8,7 @@ parameters: - scripts excludePaths: analyseAndScan: - - htdocs/custom + - htdocs/custom/* - htdocs/dev/* - htdocs/doc/* - htdocs/documents/*
FileLineType