From f6bc48e6d7a40e3dd983997b0eae6b5f6c28a264 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 28 Nov 2019 22:13:11 +0100 Subject: [PATCH 01/12] FIX minimal stripe update for compatibility cf https://stripe.com/guides/important-update-for-connect --- htdocs/stripe/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/config.php b/htdocs/stripe/config.php index 17ca74b7955..3eb7feae0d5 100644 --- a/htdocs/stripe/config.php +++ b/htdocs/stripe/config.php @@ -55,4 +55,4 @@ else \Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']); \Stripe\Stripe::setAppInfo("Dolibarr Stripe", DOL_VERSION, "https://www.dolibarr.org"); // add dolibarr version -\Stripe\Stripe::setApiVersion("2019-05-16"); // force version API +\Stripe\Stripe::setApiVersion("2019-09-09"); // force version API From b9c0f961c9d890330c2027e7566f440fe2cc0c02 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 28 Nov 2019 22:17:49 +0100 Subject: [PATCH 02/12] Update stripe.class.php --- htdocs/stripe/class/stripe.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 626f5533da4..d1b661841db 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -393,7 +393,7 @@ class Stripe extends CommonObject "currency" => $currency_code, "payment_method_types" => array("card"), "description" => $description, - "statement_descriptor" => dol_trunc($tag, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + "statement_descriptor_suffix" => dol_trunc($tag, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) //"save_payment_method" => true, "metadata" => $metadata ); @@ -683,7 +683,7 @@ class Stripe extends CommonObject $charge = \Stripe\Charge::create(array( "amount" => "$stripeamount", "currency" => "$currency", - "statement_descriptor" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + "statement_descriptor_suffix" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) "description" => "Stripe payment: ".$description, "capture" => $capture, "metadata" => $metadata, @@ -693,7 +693,7 @@ class Stripe extends CommonObject $paymentarray = array( "amount" => "$stripeamount", "currency" => "$currency", - "statement_descriptor" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + "statement_descriptor_suffix" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) "description" => "Stripe payment: ".$description, "capture" => $capture, "metadata" => $metadata, @@ -721,7 +721,7 @@ class Stripe extends CommonObject $paymentarray = array( "amount" => "$stripeamount", "currency" => "$currency", - "statement_descriptor" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + "statement_descriptor_suffix" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) "description" => "Stripe payment: ".$description, "capture" => $capture, "metadata" => $metadata, From 16d08bd9031f6e50cde860a8a11018dd0bd9872a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 28 Nov 2019 22:19:52 +0100 Subject: [PATCH 03/12] Update newpayment.php --- htdocs/public/payment/newpayment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index dbceb483f97..a3667af0c6a 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -495,7 +495,7 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled)) 'metadata' => $metadata, 'customer' => $customer->id, 'source' => $card, - 'statement_descriptor' => dol_trunc($FULLTAG, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + 'statement_descriptor_suffix' => dol_trunc($FULLTAG, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) ), array("idempotency_key" => "$FULLTAG", "stripe_account" => "$stripeacc")); // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) if (empty($charge)) From 753439efee7b0f21f8f023778b11263afa02afc4 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 28 Nov 2019 23:23:08 +0100 Subject: [PATCH 04/12] Update stripe.php --- htdocs/stripe/admin/stripe.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index c3c008a5874..4444dd4c540 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -161,7 +161,7 @@ print ''; dol_fiche_head($head, 'stripeaccount', '', -1); -$stripearrayofwebhookevents=array('payout.created','payout.paid','charge.pending','charge.refunded','charge.succeeded','charge.failed','payment_intent.succeeded','payment_intent.payment_failed','payment_method.attached','payment_method.updated','payment_method.card_automatically_updated','payment_method.detached','source.chargeable','customer.deleted'); +$stripearrayofwebhookevents=array('account.updated','payout.created','payout.paid','charge.pending','charge.refunded','charge.succeeded','charge.failed','payment_intent.succeeded','payment_intent.payment_failed','payment_method.attached','payment_method.updated','payment_method.card_automatically_updated','payment_method.detached','source.chargeable','customer.deleted'); print $langs->trans("StripeDesc")."
\n"; From 4bd4719aa660984a4d381f1cd5725d80d0e16566 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 1 Dec 2019 10:03:29 +0000 Subject: [PATCH 05/12] Fixing style errors. --- htdocs/stripe/class/stripe.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index ef902b6164c..48127874e12 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -969,10 +969,10 @@ class Stripe extends CommonObject if (!in_array($currency, $arrayzerounitcurrency)) $stripefee = round($fee * 100); else $stripefee = round($fee); - $paymentarray = array( + $paymentarray = array( "amount" => "$stripeamount", "currency" => "$currency", - "statement_descriptor_suffix" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + "statement_descriptor_suffix" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) "description" => "Stripe payment: ".$description, "capture" => $capture, "metadata" => $metadata, From 33a4888341cfe22abd18373aeca318a59d40e760 Mon Sep 17 00:00:00 2001 From: Norbert Penel Date: Wed, 29 Jan 2020 14:25:23 +0100 Subject: [PATCH 06/12] Protocol is not anymore used in url Since https expension, people do not specify protocol, so browsers propage the protocol used in parent page --- htdocs/main.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index a6de7819237..041fda15ea9 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1345,7 +1345,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr { foreach ($arrayofcss as $cssfile) { - if (preg_match('/^http/i', $cssfile)) + if (preg_match('/^(http|\/\/)/i', $cssfile)) { $urltofile = $cssfile; } @@ -1497,7 +1497,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr print ''."\n"; foreach ($arrayofjs as $jsfile) { - if (preg_match('/^http/i', $jsfile)) + if (preg_match('/^(http|\/\/)/i', $jsfile)) { print ''."\n"; } From 300abfd5e20c312c683d42dc175b4b4dcf3ea599 Mon Sep 17 00:00:00 2001 From: Michael Jeanmotte Date: Wed, 29 Jan 2020 14:44:50 +0100 Subject: [PATCH 07/12] Fetch thirdparty to be sure thirdparty is accessible through an API call when we use ODT template --- .../modules/facture/doc/doc_generic_invoice_odt.modules.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index ef05b9b2df9..aac525ffb55 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -303,6 +303,9 @@ class doc_generic_invoice_odt extends ModelePDFFactures $result = $object->fetch_contact($arrayidcontact[0]); } + // Fetch thirdparty to be sure thirdparty is accessible through an API call when we use ODT template + $object->fetch_thirdparty(); + // Recipient name $contactobject = null; if (!empty($usecontact)) { From a300cb9067dbb5a0e285bf8ae76e0c18721bd418 Mon Sep 17 00:00:00 2001 From: Michael Jeanmotte Date: Wed, 29 Jan 2020 15:12:14 +0100 Subject: [PATCH 08/12] Revert "Fetch thirdparty to be sure thirdparty is accessible through an API call when we use ODT template" This reverts commit 300abfd5 --- .../modules/facture/doc/doc_generic_invoice_odt.modules.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index aac525ffb55..ef05b9b2df9 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -303,9 +303,6 @@ class doc_generic_invoice_odt extends ModelePDFFactures $result = $object->fetch_contact($arrayidcontact[0]); } - // Fetch thirdparty to be sure thirdparty is accessible through an API call when we use ODT template - $object->fetch_thirdparty(); - // Recipient name $contactobject = null; if (!empty($usecontact)) { From 481e7126bf7bb58137f934919f78682e7ba578a2 Mon Sep 17 00:00:00 2001 From: Michael Jeanmotte Date: Wed, 29 Jan 2020 15:13:40 +0100 Subject: [PATCH 09/12] Revert "Fetch thirdparty to be sure thirdparty is accessible through an API call when we use ODT template" This reverts commit 300abfd5 --- .../modules/facture/doc/doc_generic_invoice_odt.modules.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index aac525ffb55..ef05b9b2df9 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -303,9 +303,6 @@ class doc_generic_invoice_odt extends ModelePDFFactures $result = $object->fetch_contact($arrayidcontact[0]); } - // Fetch thirdparty to be sure thirdparty is accessible through an API call when we use ODT template - $object->fetch_thirdparty(); - // Recipient name $contactobject = null; if (!empty($usecontact)) { From 9c160d5181a77f751f645bfe903e9f613fd8784c Mon Sep 17 00:00:00 2001 From: Michael Jeanmotte Date: Wed, 29 Jan 2020 15:17:12 +0100 Subject: [PATCH 10/12] Feature Request: Dolibarr API - [GET] /bankaccounts/{id}/lines : add sqlfilters #11259 --- .../compta/bank/class/api_bankaccounts.class.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 57aa50f1568..2ecb59861d9 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -411,8 +411,9 @@ class BankAccounts extends DolibarrApi * @throws RestException * * @url GET {id}/lines + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')" */ - public function getLines($id) + public function getLines($id, $sqlfilters = '') { $list = array(); @@ -428,6 +429,18 @@ class BankAccounts extends DolibarrApi $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."bank "; $sql .= " WHERE fk_account = ".$id; + + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + $sql .= " ORDER BY rowid"; $result = $this->db->query($sql); From dcc8b4b65ea0a6ef30f366123ed62bb0d8c77462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 29 Jan 2020 15:35:46 +0100 Subject: [PATCH 11/12] Update extrafields.class.php --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index ef5f5d4e74c..10b3ca071cc 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1465,7 +1465,7 @@ class ExtraFields } // We have to join on extrafield table - if (strpos($InfoFieldList[4], 'extra') !== false) { + if (strpos($InfoFieldList[4], 'extra.') !== false) { $sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra'; $sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4]; } else { From 9874169311720b36b5093c3a465f0c67df491238 Mon Sep 17 00:00:00 2001 From: kadogo Date: Wed, 29 Jan 2020 17:05:39 +0100 Subject: [PATCH 12/12] NEW enable put for agendaevents api --- htdocs/comm/action/class/api_agendaevents.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 0d3c5de514d..6299b72b28b 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -229,7 +229,6 @@ class AgendaEvents extends DolibarrApi * * @return int */ - /* public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { @@ -257,12 +256,11 @@ class AgendaEvents extends DolibarrApi $this->actioncomm->$field = $value; } - if ($this->actioncomm->update($id, DolibarrApiAccess::$user,1,'','','update')) + if ($this->actioncomm->update(DolibarrApiAccess::$user, 1) > 0) return $this->get($id); return false; } - */ /** * Delete Agenda Event