From 8e6fdb50b70db026ac3831ab411f0b6cf97cb010 Mon Sep 17 00:00:00 2001 From: xabitrigo <7525839+xabitrigo@users.noreply.github.com> Date: Sun, 3 Dec 2023 02:13:30 +0100 Subject: [PATCH 01/41] CLOSE #26942 REST API GET /bankaccounts/{id}/lines/{line_id}/links --- .../bank/class/api_bankaccounts.class.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index cd6ebd9c3bf..9ca88363266 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -566,4 +566,37 @@ class BankAccounts extends DolibarrApi } return $result; } + + /** + * Get the list of links for a line of the account. + * + * @param int $id ID of account + * @param int $line_id ID of account line + * @return array Array of links + * + * @throws RestException + * + * @url GET {id}/lines/{line_id}/links + * + */ + public function getLinks($id, $line_id) + { + $list = array(); + + if (!DolibarrApiAccess::$user->rights->banque->lire) { + throw new RestException(401); + } + + $account = new Account($this->db); + $result = $account->fetch($id); + if (!$result) { + throw new RestException(404, 'account not found'); + } + $links = $account->get_url($line_id); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) + foreach ($links as &$link) { + unset($link[0], $link[1], $link[2], $link[3]); // Remove the numeric keys + } + + return $links; + } } From 01fc1432ca8305a546e0be51a1246091f6ca26ef Mon Sep 17 00:00:00 2001 From: xabitrigo <7525839+xabitrigo@users.noreply.github.com> Date: Sun, 3 Dec 2023 02:23:38 +0100 Subject: [PATCH 02/41] Fix #26942 phpcs code style --- htdocs/compta/bank/class/api_bankaccounts.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 9ca88363266..432731bb7a3 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -577,7 +577,7 @@ class BankAccounts extends DolibarrApi * @throws RestException * * @url GET {id}/lines/{line_id}/links - * + * */ public function getLinks($id, $line_id) { @@ -594,7 +594,7 @@ class BankAccounts extends DolibarrApi } $links = $account->get_url($line_id); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) foreach ($links as &$link) { - unset($link[0], $link[1], $link[2], $link[3]); // Remove the numeric keys + unset($link[0], $link[1], $link[2], $link[3]); // Remove the numeric keys } return $links; From fa47d02cd54984c1cd4428333cea3dc273e78c95 Mon Sep 17 00:00:00 2001 From: pascal Date: Sun, 3 Dec 2023 21:00:19 +0100 Subject: [PATCH 03/41] fix 26871 --- htdocs/contrat/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 58c037e8adb..c452e082d0b 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -768,7 +768,6 @@ if (empty($reshook)) { $remise_percent = price2num(GETPOST('elremise_percent'), 2); if ($remise_percent > 0) { $remise = round(($price_ht * $remise_percent / 100), 2); - $price_ht = ($price_ht - $remise); } $objectline->fk_product = GETPOST('idprod', 'int'); From bd7e5abc5afb4756d0c016522184896c977e0545 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Dec 2023 11:16:57 +0100 Subject: [PATCH 04/41] 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 8d7ab21ad673c2910b2b000f0eb9af043eeb5d2c Mon Sep 17 00:00:00 2001 From: Hystepik Date: Fri, 8 Dec 2023 14:23:34 +0100 Subject: [PATCH 05/41] 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 06/41] 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 07/41] 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 08/41] 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 09/41] 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 10/41] 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 11/41] 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 12/41] 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 13/41] 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 14/41] 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 15/41] 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 23/41] 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 24/41] 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 25/41] 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 26/41] 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 27/41] 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 28/41] 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 29/41] 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 30/41] 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 31/41] 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 6c8116fa7e1a69dc8385726461285be0407cb53a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Dec 2023 01:37:45 +0100 Subject: [PATCH 32/41] 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 33/41] 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 34/41] 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 35/41] 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 '