From 6388ddeb6f7bd3f2eafe2c2788ee7926c5809816 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Thu, 27 Jul 2023 17:55:34 +0200 Subject: [PATCH 01/14] Fix column display (#25490) --- htdocs/projet/tasks.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 54146704708..c0bf6b2c086 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -962,7 +962,9 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third } // progress resume not searchable - print ''; + if (!empty($arrayfields['t.progress_summary']['checked'])) { + print ''; + } if ($object->usage_bill_time) { if (!empty($arrayfields['t.tobill']['checked'])) { From e4cc07324b6e3c2942440a9ae925adb4c2e78233 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 28 Jul 2023 14:24:16 +0200 Subject: [PATCH 02/14] Fix php syntax (#25508) --- htdocs/product/class/api_products.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index ac666824f0e..e95db77d0cc 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -676,9 +676,9 @@ class Products extends DolibarrApi require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; $prodcustprice = new Productcustomerprice($this->db); $filter = array(); - $filter['t.fk_product'] .= $id; + $filter['t.fk_product'] = $id; if ($thirdparty_id) { - $filter['t.fk_soc'] .= $thirdparty_id; + $filter['t.fk_soc'] = $thirdparty_id; } $result = $prodcustprice->fetchAll('', '', 0, 0, $filter); } From 5997ae4bb7f5178c10418472cd1377ce809253e9 Mon Sep 17 00:00:00 2001 From: atm-lena <52402938+atm-lena@users.noreply.github.com> Date: Fri, 28 Jul 2023 14:41:01 +0200 Subject: [PATCH 03/14] FIX Fatal Error PHP 8 : division by 0 (#25384) * FIX Fatal Error PHP 8 : division by 0 * Update objectline_view.tpl.php --------- Co-authored-by: atm-lena Co-authored-by: Laurent Destailleur --- htdocs/bom/tpl/objectline_view.tpl.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index b921e23d64d..a512e13aea5 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -332,8 +332,11 @@ if ($resql) { $resql_supplier_price = $object->db->query($sql_supplier_price); if ($resql_supplier_price) { $obj = $object->db->fetch_object($resql_supplier_price); - $line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty * $line->qty; - + if (!empty($obj->qty) && !empty($sub_bom_line->qty) && !empty($line->qty)) { + $line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty * $line->qty; + } else { + $line_cost = $obj->min_price; + } print ''.price2num($line_cost, 'MT').''; $total_cost+= $line_cost; } From 617d89c183fe78cae8e8e08db8c65a0d1ca58ba7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Jul 2023 15:48:16 +0200 Subject: [PATCH 04/14] Fix phpcs --- htdocs/bom/tpl/objectline_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index a512e13aea5..cd7828ef680 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -332,7 +332,7 @@ if ($resql) { $resql_supplier_price = $object->db->query($sql_supplier_price); if ($resql_supplier_price) { $obj = $object->db->fetch_object($resql_supplier_price); - if (!empty($obj->qty) && !empty($sub_bom_line->qty) && !empty($line->qty)) { + if (!empty($obj->qty) && !empty($sub_bom_line->qty) && !empty($line->qty)) { $line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty * $line->qty; } else { $line_cost = $obj->min_price; From db15f04ab05efb95970f55676d0fe097abbe36ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Jul 2023 14:00:22 +0200 Subject: [PATCH 05/14] FIX fatal error on Stripe setup page and security when terminal not used --- htdocs/stripe/admin/stripe.php | 59 ++++++++++++++++++++-------------- htdocs/stripe/ajax/ajax.php | 16 +++++++-- htdocs/takepos/pay.php | 31 +++++++++++------- 3 files changed, 68 insertions(+), 38 deletions(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 1c5a507b619..4c4fa48f759 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -394,35 +394,44 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code $service = 'StripeLive'; $servicestatus = 1; } - global $stripearrayofkeysbyenv; - $site_account = $stripearrayofkeysbyenv[$servicestatus]['secret_key']; - if (!empty($site_account)) { - \Stripe\Stripe::setApiKey($site_account); - } - if (isModEnabled('stripe') && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { - $service = 'StripeTest'; - $servicestatus = '0'; - dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); - } else { - $service = 'StripeLive'; - $servicestatus = '1'; - } - $stripe = new Stripe($db); - if (!empty($site_account)) { - // If $site_account not defined, then key not set and no way to call API Location - $stripeacc = $stripe->getStripeAccount($service); - if ($stripeacc) { - $locations = \Stripe\Terminal\Location::all('', array("stripe_account" => $stripeacc)); + + try { + global $stripearrayofkeysbyenv; + $site_account = $stripearrayofkeysbyenv[$servicestatus]['secret_key']; + if (!empty($site_account)) { + \Stripe\Stripe::setApiKey($site_account); + } + if (isModEnabled('stripe') && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { + $service = 'StripeTest'; + $servicestatus = '0'; + dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); } else { - $locations = \Stripe\Terminal\Location::all(); + $service = 'StripeLive'; + $servicestatus = '1'; + } + $stripe = new Stripe($db); + if (!empty($site_account)) { + // If $site_account not defined, then key not set and no way to call API Location + $stripeacc = $stripe->getStripeAccount($service); + if ($stripeacc) { + $locations = \Stripe\Terminal\Location::all('', array("stripe_account" => $stripeacc)); + } else { + $locations = \Stripe\Terminal\Location::all(); + } + } + } catch (Exception $e) { + print $e->getMessage().'
'; + } + + // Define the array $location + $location = array(); + $location[""] = $langs->trans("NotDefined"); + if (!empty($locations)) { + foreach ($locations as $tmplocation) { + $location[$tmplocation->id] = $tmplocation->display_name; } } - $location = array(); - $location[""] = $langs->trans("NotDefined"); - foreach ($locations as $tmplocation) { - $location[$tmplocation->id] = $tmplocation->display_name; - } print $form->selectarray("STRIPE_LOCATION", $location, getDolGlobalString('STRIPE_LOCATION')); print ''; } diff --git a/htdocs/stripe/ajax/ajax.php b/htdocs/stripe/ajax/ajax.php index 5fa4da88ae7..664e21303dd 100644 --- a/htdocs/stripe/ajax/ajax.php +++ b/htdocs/stripe/ajax/ajax.php @@ -18,6 +18,11 @@ /** * \file htdocs/stripe/ajax/ajax.php * \brief Ajax action for Stipe ie: Terminal + * + * Calling with + * action=getConnexionToken return a token of Stripe terminal + * action=createPaymentIntent generates a payment intent + * action=capturePaymentIntent generates a payment */ if (!defined('NOTOKENRENEWAL')) { @@ -49,7 +54,12 @@ $servicestatus = GETPOST('servicestatus', 'int'); $amount = GETPOST('amount', 'int'); if (empty($user->rights->takepos->run)) { - accessforbidden(); + accessforbidden('Not allowed to use TakePOS'); +} + +$usestripeterminals = getDolGlobalString('STRIPE_LOCATION'); +if (! $usestripeterminals) { + accessforbidden('Feature to use Stripe terminals not enabled'); } @@ -68,7 +78,9 @@ if ($action == 'getConnexionToken') { // The ConnectionToken's secret lets you connect to any Stripe Terminal reader // and take payments with your Stripe account. $array = array(); - if (isset($location) && !empty($location)) $array['location'] = $location; + if (isset($location) && !empty($location)) { + $array['location'] = $location; + } if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage $connectionToken = \Stripe\Terminal\ConnectionToken::create($array); } else { diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 0f2a54ced68..fdc2a4f319d 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -96,28 +96,34 @@ if (isModEnabled('stripe')) { $stripeacc = $stripe->getStripeAccount($service); // Get Stripe OAuth connect account (no remote access to Stripe here) $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus, $site_account); // Get remote Stripe customer 'cus_...' (no remote access to Stripe here) $keyforstripeterminalbank = "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".$_SESSION["takeposterminal"]; - ?> + + $usestripeterminals = getDolGlobalString('STRIPE_LOCATION'); + + if ($usestripeterminals) { + ?> -global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning', 1); From 36e91da160ca242a6c2f0500aa885941b01310ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Jul 2023 14:30:47 +0200 Subject: [PATCH 06/14] FIX Try to fix the date of invoice on TakePOS on eastern timezone --- htdocs/takepos/invoice.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 9ed8a41d2bd..1f5f4383e2b 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -465,9 +465,10 @@ if (empty($reshook)) { $invoice->fetch($placeid); } + // If we add a line and no invoice yet, we create the invoice if (($action == "addline" || $action == "freezone") && $placeid == 0) { $invoice->socid = getDolGlobalString($constforcompanyid); - $invoice->date = dol_now(); + $invoice->date = dol_now('tzuserrel'); // We use the local date, only the day will be saved. $invoice->module_source = 'takepos'; $invoice->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; $invoice->entity = !empty($_SESSION["takeposinvoiceentity"]) ? $_SESSION["takeposinvoiceentity"] : $conf->entity; @@ -476,6 +477,7 @@ if (empty($reshook)) { $langs->load('errors'); dol_htmloutput_errors($langs->trans("ErrorModuleSetupNotComplete", "TakePos"), null, 1); } else { + // Create invoice $placeid = $invoice->create($user); if ($placeid < 0) { dol_htmloutput_errors($invoice->error, $invoice->errors, 1); From a72fac7c3dfc25516f94a0c32bacc5891bb6ea52 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Jul 2023 15:20:16 +0200 Subject: [PATCH 07/14] FIX pn in language selection on target for emailing --- htdocs/core/modules/mailings/contacts1.modules.php | 12 +++++++----- .../core/modules/mailings/thirdparties.modules.php | 14 ++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 13436761c3b..772c9900573 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -219,7 +219,8 @@ class mailing_contacts1 extends MailingTargets if ($level == $obj->code) { $level = $langs->trans($obj->label); } - $s .= ''; + $labeltoshow = $langs->trans("ThirdPartyProspects").' ('.$langs->trans("ProspectLevelShort").'='.$level.')'; + $s .= ''; $i++; } } else { @@ -311,7 +312,7 @@ class mailing_contacts1 extends MailingTargets require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($this->db); $s .= img_picto($langs->trans("DefaultLang"), 'language', 'class="pictofixedwidth"'); - $s .= $formadmin->select_language($langs->getDefaultLang(1), 'filter_lang', 0, null, $langs->trans("DefaultLang"), 0, 0, '', 0, 0, 0, null, 1); + $s .= $formadmin->select_language(GETPOST('filter_lang', 'aZ09'), 'filter_lang', 0, null, $langs->trans("DefaultLang"), 0, 0, '', 0, 0, 0, null, 1); } return $s; @@ -412,7 +413,7 @@ class mailing_contacts1 extends MailingTargets } // Filter on language - if (!empty($filter_lang)) { + if (!empty($filter_lang) && $filter_lang != '-1') { $sql .= " AND sp.default_lang LIKE '".$this->db->escape($filter_lang)."%'"; } @@ -442,8 +443,9 @@ class mailing_contacts1 extends MailingTargets } $sql .= " ORDER BY sp.email"; - // print "wwwwwwx".$sql; - // Stocke destinataires dans cibles + //print "wwwwwwx".$sql; + + // Store recipients in target tables $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index bc9a763ab1f..e678dab33ed 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -126,11 +126,11 @@ class mailing_thirdparties extends MailingTargets $addDescription .= $langs->trans("Disabled"); } } - if (GETPOST('default_lang', 'alpha')) { + if (GETPOST('default_lang', 'alpha') && GETPOST('default_lang', 'alpha') != '-1') { $addFilter .= " AND s.default_lang LIKE '".$this->db->escape(GETPOST('default_lang', 'alpha'))."%'"; $addDescription = $langs->trans('DefaultLang')."="; } - if (GETPOST('filter_lang_thirdparties', 'alpha')) { + if (GETPOST('filter_lang_thirdparties', 'alpha') && GETPOST('filter_lang_thirdparties', 'alpha') != '-1') { $addFilter .= " AND s.default_lang LIKE '".$this->db->escape(GETPOST('filter_lang_thirdparties', 'alpha'))."%'"; $addDescription = $langs->trans('DefaultLang')."="; } @@ -280,7 +280,7 @@ class mailing_thirdparties extends MailingTargets $langs->load("companies"); // filter - $s = ''; // Show categories $sql = "SELECT rowid, label, type, visible"; @@ -316,10 +316,12 @@ class mailing_thirdparties extends MailingTargets if ($obj->type == 2) { $type = $langs->trans("Customer"); } - $s .= ''; $i++; } @@ -370,7 +372,7 @@ class mailing_thirdparties extends MailingTargets $formadmin = new FormAdmin($this->db); $s .= img_picto($langs->trans("DefaultLang"), 'language', 'class="pictofixedwidth"'); //$s .= ''.$langs->trans("DefaultLang").': '; - $s .= $formadmin->select_language($langs->getDefaultLang(1), 'filter_lang_thirdparties', 0, null, $langs->trans("DefaultLang"), 0, 0, '', 0, 0, 0, null, 1); + $s .= $formadmin->select_language(GETPOST('filter_lang_thirdparties', 'aZ09'), 'filter_lang_thirdparties', 0, null, $langs->trans("DefaultLang"), 0, 0, '', 0, 0, 0, null, 1); } return $s; From 22bed76e401efd1419597a3bcaf6214f5f85ea52 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Jul 2023 18:32:44 +0200 Subject: [PATCH 08/14] Fix warning --- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index d282d29d262..85576e467ec 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1502,8 +1502,10 @@ class pdf_azur extends ModelePDFPropales $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); + $w = 100; + $posy = $this->marge_haute; - $posx = $this->page_largeur - $this->marge_droite - 100; + $posx = $this->page_largeur - $this->marge_droite - $w; $pdf->SetXY($this->marge_gauche, $posy); From 01e65bbad1f19d73ce9d24b5c95f0b6c37406f67 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Jul 2023 18:42:05 +0200 Subject: [PATCH 09/14] Fix warning --- htdocs/core/lib/signature.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/signature.lib.php b/htdocs/core/lib/signature.lib.php index e88d8dd3635..49a250963a1 100644 --- a/htdocs/core/lib/signature.lib.php +++ b/htdocs/core/lib/signature.lib.php @@ -90,7 +90,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1) if ($mode == 1) { $out .= "hash('".$securekeyseed."' + '".$type."' + proposal_ref)"; } else { - $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(!isModEnabled('multicompany') ? '' : $object->entity), '0'); + $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? (is_null($object) ? '' : $object->entity) : ''), '0'); } /* if ($mode == 1) { From 6b0630561eff50ac663848a08c86e63ba270f439 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Jul 2023 18:47:40 +0200 Subject: [PATCH 10/14] Fix warnings --- htdocs/core/lib/signature.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/signature.lib.php b/htdocs/core/lib/signature.lib.php index 49a250963a1..1e18d570703 100644 --- a/htdocs/core/lib/signature.lib.php +++ b/htdocs/core/lib/signature.lib.php @@ -129,7 +129,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1) if ($mode == 1) { $out .= "hash('".$securekeyseed."' + '".$type."' + contract_ref)"; } else { - $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(!isModEnabled('multicompany') ? '' : $object->entity), '0'); + $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? (is_null($object) ? '' : $object->entity) : ''), '0'); } } elseif ($type == 'fichinter') { $securekeyseed = isset($conf->global->FICHINTER_ONLINE_SIGNATURE_SECURITY_TOKEN) ? $conf->global->FICHINTER_ONLINE_SIGNATURE_SECURITY_TOKEN : ''; @@ -144,13 +144,13 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1) if ($mode == 1) { $out .= "hash('".$securekeyseed."' + '".$type."' + fichinter_ref)"; } else { - $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(!isModEnabled('multicompany') ? '' : $object->entity), '0'); + $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? (is_null($object) ? '' : $object->entity) : ''), '0'); } } // For multicompany if (!empty($out) && isModEnabled('multicompany')) { - $out .= "&entity=".$object->entity; // Check the entity because we may have the same reference in several entities + $out .= "&entity=".(is_null($object) ? '' : $object->entity); // Check the entity because we may have the same reference in several entities } return $out; From 9b0901383e6a96ca9101e05df8bcb31d151278af Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Jul 2023 18:52:31 +0200 Subject: [PATCH 11/14] Fix warning --- htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index fce233a5667..5bd2749122a 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -390,6 +390,7 @@ class pdf_cyan extends ModelePDFPropales $tab_top = 90 + $top_shift; $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10); + $nexY = $tab_top; // Incoterm $height_incoterms = 0; From 9fd651ee5ca8ccb4b531232ff002346eba040bd2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Jul 2023 19:26:07 +0200 Subject: [PATCH 12/14] FIX warnings --- .../core/class/commondocgenerator.class.php | 12 +++---- .../asset/doc/pdf_standard_asset.modules.php | 12 +++++-- .../commande/doc/pdf_einstein.modules.php | 12 +++++-- .../commande/doc/pdf_eratosthene.modules.php | 12 +++++-- .../doc/doc_generic_invoice_odt.modules.php | 31 ++++++++++--------- .../facture/doc/pdf_sponge.modules.php | 12 +++++-- .../product/doc/pdf_standard.modules.php | 18 ++++++++--- .../modules/propale/doc/pdf_cyan.modules.php | 12 +++++-- .../doc/pdf_eagle_proforma.modules.php | 18 ++++++++--- .../supplier_order/doc/pdf_cornas.modules.php | 12 +++++-- .../doc/pdf_muscadet.modules.php | 12 +++++-- .../doc/pdf_aurore.modules.php | 12 +++++-- htdocs/includes/odtphp/Segment.php | 4 +-- .../doc/pdf_standard_myobject.modules.php | 12 +++++-- 14 files changed, 142 insertions(+), 49 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 7e85071e453..76e104be4ea 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -272,7 +272,7 @@ abstract class CommonDocGenerator 'mycompany_idprof5'=>$mysoc->idprof5, 'mycompany_idprof6'=>$mysoc->idprof6, 'mycompany_vatnumber'=>$mysoc->tva_intra, - 'mycompany_object'=>$mysoc->object, + 'mycompany_socialobject'=>$mysoc->socialobject, 'mycompany_note_private'=>$mysoc->note_private, //'mycompany_note_public'=>$mysoc->note_public, // Only private not exists for "mysoc" but both for thirdparties ); @@ -516,11 +516,11 @@ abstract class CommonDocGenerator $array_key.'_incoterms' => (method_exists($object, 'display_incoterms') ? $object->display_incoterms() : ''), - $array_key.'_bank_iban'=>$bank_account->iban, - $array_key.'_bank_bic'=>$bank_account->bic, - $array_key.'_bank_label'=>$bank_account->label, - $array_key.'_bank_number'=>$bank_account->number, - $array_key.'_bank_proprio'=>$bank_account->proprio, + $array_key.'_bank_iban' => (!empty($bank_account) ? $bank_account->iban : ''), + $array_key.'_bank_bic' => (!empty($bank_account) ? $bank_account->bic : ''), + $array_key.'_bank_label' => (!empty($bank_account) ? $bank_account->label : ''), + $array_key.'_bank_number' => (!empty($bank_account) ? $bank_account->number : ''), + $array_key.'_bank_proprio' => (!empty($bank_account) ? $bank_account->proprio : ''), $array_key.'_total_ht_locale'=>price($object->total_ht, 0, $outputlangs), $array_key.'_total_vat_locale'=>(!empty($object->total_vat) ?price($object->total_vat, 0, $outputlangs) : price($object->total_tva, 0, $outputlangs)), diff --git a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php index 75fb8025e42..56057582d11 100644 --- a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php +++ b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php @@ -706,10 +706,18 @@ class pdf_standard_asset extends ModelePDFAsset // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) { - $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) { + $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne; + } else { + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + } } if ($localtax2_type && $localtax2ligne != 0) { - $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) { + $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne; + } else { + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + } } if (($object->lines[$i]->info_bits & 0x01) == 0x01) { diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 9f8008dda11..3f1a62c1b2b 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -566,10 +566,18 @@ class pdf_einstein extends ModelePDFCommandes // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) { - $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) { + $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne; + } else { + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + } } if ($localtax2_type && $localtax2ligne != 0) { - $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) { + $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne; + } else { + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + } } if (($object->lines[$i]->info_bits & 0x01) == 0x01) { diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 458cc39dd27..f6f9cf79bfa 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -784,10 +784,18 @@ class pdf_eratosthene extends ModelePDFCommandes // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) { - $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) { + $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne; + } else { + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + } } if ($localtax2_type && $localtax2ligne != 0) { - $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) { + $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne; + } else { + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + } } if (($object->lines[$i]->info_bits & 0x01) == 0x01) { 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 9e203e8d5ce..ba273ef270c 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 @@ -330,12 +330,13 @@ class doc_generic_invoice_odt extends ModelePDFFactures $object->fetchObjectLinked('', '', '', ''); //print_r($object->linkedObjects['propal']); exit; - $array_propal_object = $object->linkedObjects['propal']; - if (isset($array_propal_object) && is_array($array_propal_object) && count($array_propal_object) > 0) { - $tmparrayofvalue = array_values($array_propal_object); - $propal_object = $tmparrayofvalue[0]; - } else { - $propal_object = null; + $propal_object = null; + if (!empty($object->linkedObjects['propal'])) { + $array_propal_object = $object->linkedObjects['propal']; + if (isset($array_propal_object) && is_array($array_propal_object) && count($array_propal_object) > 0) { + $tmparrayofvalue = array_values($array_propal_object); + $propal_object = $tmparrayofvalue[0]; + } } // Make substitution @@ -411,15 +412,15 @@ class doc_generic_invoice_odt extends ModelePDFFactures // TODO Search all tags {object_...:xxxx} into template then loop on this found tags to analyze them and the the corresponding // property of object and use the xxxx to know how to format it. // Before that, we hard code this substitution as if we have found them into the template. - $tmparray['object_PREVIOUS_MONTH'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%m'); - $tmparray['object_MONTH'] = dol_print_date($this->date, '%m'); - $tmparray['object_NEXT_MONTH'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%m'); - $tmparray['object_PREVIOUS_MONTH_TEXT'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%B'); - $tmparray['object_MONTH_TEXT'] = dol_print_date($this->date, '%B'); - $tmparray['object_NEXT_MONTH_TEXT'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%B'); - $tmparray['object_PREVIOUS_YEAR'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'y'), '%Y'); - $tmparray['object_YEAR'] = dol_print_date($this->date, '%Y'); - $tmparray['object_NEXT_YEAR'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'); + $tmparray['object_PREVIOUS_MONTH'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%m'); + $tmparray['object_MONTH'] = dol_print_date($object->date, '%m'); + $tmparray['object_NEXT_MONTH'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%m'); + $tmparray['object_PREVIOUS_MONTH_TEXT'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%B'); + $tmparray['object_MONTH_TEXT'] = dol_print_date($object->date, '%B'); + $tmparray['object_NEXT_MONTH_TEXT'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%B'); + $tmparray['object_PREVIOUS_YEAR'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'y'), '%Y'); + $tmparray['object_YEAR'] = dol_print_date($object->date, '%Y'); + $tmparray['object_NEXT_YEAR'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'y'), '%Y'); // Call the ODTSubstitution hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index fbf1907ec7d..b219888596c 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -950,10 +950,18 @@ class pdf_sponge extends ModelePDFFactures // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) { - $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) { + $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne; + } else { + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + } } if ($localtax2_type && $localtax2ligne != 0) { - $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) { + $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne; + } else { + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + } } if (($object->lines[$i]->info_bits & 0x01) == 0x01) { diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index afcb9503997..3cd29891550 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -481,10 +481,20 @@ class pdf_standard extends ModelePDFProduct } // retrieve global local tax - if ($localtax1_type && $localtax1ligne != 0) - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; - if ($localtax2_type && $localtax2ligne != 0) - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; + if ($localtax1_type && $localtax1ligne != 0) { + if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) { + $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne; + } else { + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + } + } + if ($localtax2_type && $localtax2ligne != 0) { + if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) { + $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne; + } else { + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + } + } if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 5bd2749122a..153a0460d84 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -795,10 +795,18 @@ class pdf_cyan extends ModelePDFPropales // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) { - $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) { + $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne; + } else { + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + } } if ($localtax2_type && $localtax2ligne != 0) { - $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) { + $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne; + } else { + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + } } if (($object->lines[$i]->info_bits & 0x01) == 0x01) { diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php index 69c1ed27a51..83f0cb802e9 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php @@ -704,10 +704,20 @@ class pdf_eagle_proforma extends ModelePDFCommandes } // retrieve global local tax - if ($localtax1_type && $localtax1ligne != 0) - $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; - if ($localtax2_type && $localtax2ligne != 0) - $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + if ($localtax1_type && $localtax1ligne != 0) { + if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) { + $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne; + } else { + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + } + } + if ($localtax2_type && $localtax2ligne != 0) { + if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) { + $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne; + } else { + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + } + } if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*'; if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0; diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index cf94376b285..d787a1d8dfe 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -723,10 +723,18 @@ class pdf_cornas extends ModelePDFSuppliersOrders // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) { - $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) { + $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne; + } else { + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + } } if ($localtax2_type && $localtax2ligne != 0) { - $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) { + $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne; + } else { + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + } } if (($object->lines[$i]->info_bits & 0x01) == 0x01) { diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 1206d91a794..1b90c123e99 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -603,10 +603,18 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) { - $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) { + $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne; + } else { + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + } } if ($localtax2_type && $localtax2ligne != 0) { - $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) { + $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne; + } else { + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + } } if (($object->lines[$i]->info_bits & 0x01) == 0x01) { diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 046c72cd06b..84c13dc0ee6 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -589,10 +589,18 @@ class pdf_aurore extends ModelePDFSupplierProposal // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) { - $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) { + $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne; + } else { + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + } } if ($localtax2_type && $localtax2ligne != 0) { - $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) { + $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne; + } else { + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + } } if (($object->lines[$i]->info_bits & 0x01) == 0x01) { diff --git a/htdocs/includes/odtphp/Segment.php b/htdocs/includes/odtphp/Segment.php index b57983321a3..928cefcd1bf 100644 --- a/htdocs/includes/odtphp/Segment.php +++ b/htdocs/includes/odtphp/Segment.php @@ -180,8 +180,8 @@ class Segment implements IteratorAggregate, Countable '/__CURRENTMONTH__/u','/__CURRENTMONTHLONG__/u', '/__NEXTMONTH__/u','/__NEXTMONTHLONG__/u', '/__CURRENTYEAR__/u','/__NEXTYEAR__/u' ); - $values=array( $hoy['mday'], $langs->transnoentitiesnoconv($hoy['weekday']), - $hoy['mon'], $langs->transnoentitiesnoconv($hoy['month']), + $values=array( $hoy['mday'], $langs->transnoentitiesnoconv($hoy['wday']), + $hoy['mon'], monthArray($langs)[$hoy['mon']], $nextMonth, monthArray($langs)[$nextMonth], $hoy['year'], $hoy['year']+1 ); diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index d3c717bcd3c..5dca1a952b1 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -672,10 +672,18 @@ class pdf_standard_myobject extends ModelePDFMyObject // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) { - $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) { + $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne; + } else { + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; + } } if ($localtax2_type && $localtax2ligne != 0) { - $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) { + $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne; + } else { + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; + } } if (($object->lines[$i]->info_bits & 0x01) == 0x01) { From 964e71cacb02d96a4f980f301152856b67f6d655 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Jul 2023 19:46:56 +0200 Subject: [PATCH 13/14] Add utility tool to fix corrupted generated files --- scripts/doc/regenerate_docs.php | 161 ++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100755 scripts/doc/regenerate_docs.php diff --git a/scripts/doc/regenerate_docs.php b/scripts/doc/regenerate_docs.php new file mode 100755 index 00000000000..b0a3ee17cf2 --- /dev/null +++ b/scripts/doc/regenerate_docs.php @@ -0,0 +1,161 @@ +#!/usr/bin/env php + + * Copyright (C) 2015 Jean Heimburger + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file scripts/doc/regenerate_docs.php + * \ingroup scripts + * \brief Regenerated main documents into documents directory + */ + +if (!defined('NOSESSION')) { + define('NOSESSION', '1'); +} + +$sapi_type = php_sapi_name(); +$script_file = basename(__FILE__); +$path = __DIR__.'/'; + +// Test if batch mode +if (substr($sapi_type, 0, 3) == 'cgi') { + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; + exit(-1); +} + +@set_time_limit(0); // No timeout for this script +define('EVEN_IF_ONLY_LOGIN_ALLOWED', 1); // Set this define to 0 if you want to lock your script when dolibarr setup is "locked to admin user only". + +// Include and load Dolibarr environment variables +require_once $path."../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/images.lib.php"; +// After this $db, $mysoc, $langs, $conf and $hookmanager are defined (Opened $db handler to database will be closed at end of file). +// $user is created but empty. + +// $langs->setDefaultLang('en_US'); // To change default language of $langs +$langs->load("main"); // To load language file for default language + +// Global variables +$version = DOL_VERSION; +$error = 0; +$forcecommit = 0; + +print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." - dir=".DOL_DATA_ROOT." *****\n"; +dol_syslog($script_file." launched with arg ".join(',', $argv)); + +if (empty($argv[1])) { + print "Usage: $script_file subdirtoscan (test|confirm)\n"; + print "Example: $script_file propale test\n"; + exit(-1); +} + +print '--- start'."\n"; + +$dir = DOL_DATA_ROOT; +$subdir = $argv[1]; +if (empty($dir) || empty($subdir)) { + dol_print_error('', 'dir not defined'); + exit(1); +} +if (!dol_is_dir($dir.'/'.$subdir)) { + print 'Directory '.$dir.'/'.$subdir.' not found.'."\n"; + exit(2); +} + +print 'Scan directory '.$dir.'/'.$subdir."\n"; + +$filearray = dol_dir_list($dir.'/'.$subdir, "directories", 0, '', 'temp$'); + +$nbok = $nbko = 0; + +$tmpobject = null; +if ($subdir == 'propale' || $subdir == 'proposal') { + if (isModEnabled('propal')) { + require_once DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"; + $tmpobject = new Propal($db); + } else { + print 'Error, module not enabled'."\n"; + } +} else if ($subdir == 'commande' || $subdir == 'order') { + if (isModEnabled('commande')) { + require_once DOL_DOCUMENT_ROOT."/commande/class/commande.class.php"; + $tmpobject = new Commande($db); + } else { + print 'Error, module not enabled'."\n"; + } +} else if ($subdir == 'facture' || $subdir == 'invoice') { + if (isModEnabled('facture')) { + require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"; + $tmpobject = new Facture($db); + } else { + print 'Error, module not enabled'."\n"; + } +} else { + print 'Dir '.$subdir.' not yet supported'."\n"; +} + +if ($tmpobject) { + foreach ($filearray as $keyf => $valf) { + $ref = basename($valf['name']); + print 'Process document for dir = '.$subdir.', ref '.$ref."\n"; + + $ret1 = $tmpobject->fetch(0, $ref); + $ret2 = $tmpobject->fetch_thirdparty(); + + if ($ret1 > 0) { + //$tmpobject->build + //$tmpobject->setDocModel($user, GETPOST('model', 'alpha')); + $outputlangs = $langs; + $newlang = ''; + + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + + $hidedetails = 0; + $hidedesc = 0; + $hideref = 0; + $moreparams = null; + + $result = 0; + if (!empty($argv[2]) && $argv[2] == 'confirm') { + $result = $tmpobject->generateDocument($tmpobject->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + } + if ($result < 0) { + $nbko++; + } if ($result == 0) { + print 'File for ref '.$tmpobject->ref.' returned 0 during regeneration with template '.$tmpobject->model_pdf."\n"; + $nbok++; + } else { + print 'File for ref '.$tmpobject->ref.' regenerated with template '.$tmpobject->model_pdf."\n"; + $nbok++; + } + } else { + $nbko++; + } + } +} + +print $nbok." objects processed\n"; +print $nbko." objects with errors\n"; + +$db->close(); // Close $db database opened handler + +exit($error); From 8db331103dc070f68e86ee66d23e5869f0cd4496 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jul 2023 02:42:18 +0200 Subject: [PATCH 14/14] Fix phpcss --- scripts/doc/regenerate_docs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/doc/regenerate_docs.php b/scripts/doc/regenerate_docs.php index b0a3ee17cf2..e76cc615298 100755 --- a/scripts/doc/regenerate_docs.php +++ b/scripts/doc/regenerate_docs.php @@ -92,14 +92,14 @@ if ($subdir == 'propale' || $subdir == 'proposal') { } else { print 'Error, module not enabled'."\n"; } -} else if ($subdir == 'commande' || $subdir == 'order') { +} elseif ($subdir == 'commande' || $subdir == 'order') { if (isModEnabled('commande')) { require_once DOL_DOCUMENT_ROOT."/commande/class/commande.class.php"; $tmpobject = new Commande($db); } else { print 'Error, module not enabled'."\n"; } -} else if ($subdir == 'facture' || $subdir == 'invoice') { +} elseif ($subdir == 'facture' || $subdir == 'invoice') { if (isModEnabled('facture')) { require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"; $tmpobject = new Facture($db);