From 55736301463838ffeb6abcfc7adcd39b3e1f58b6 Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Sun, 13 Nov 2022 21:26:58 +0100 Subject: [PATCH 01/11] FIX - php 8 warning --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 39d833de6cc..e1cca63c224 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1180,7 +1180,7 @@ class pdf_crabe extends ModelePDFFactures // Decret n°2099-1299 2022-10-07 // French mention : "Option pour le paiement de la taxe d'après les débits" if ($this->emetteur->country_code == 'FR') { - if ($conf->global->TAX_MODE == 1) { + if (isset($conf->global->TAX_MODE) && $conf->global->TAX_MODE == 1) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->writeHTMLCell(80, 5, '', '', $outputlangs->transnoentities("MentionVATDebitOptionIsOn"), 0, 1); From 7ba582ee66277420ac78859a16d39365fb5eb2f6 Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Sun, 13 Nov 2022 23:18:44 +0100 Subject: [PATCH 02/11] Add shipping address --- .../modules/facture/doc/pdf_crabe.modules.php | 49 +++++++++++++++++-- htdocs/langs/en_US/bills.lang | 1 + 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index e1cca63c224..8d68664b48f 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -579,7 +579,8 @@ class pdf_crabe extends ModelePDFFactures $pdf->useTemplate($tplidx); } if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + $top_shift = $this->_pagehead($pdf, $object, 0, $outputlangs); + $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10); } $pdf->setPage($pageposbefore + 1); @@ -622,7 +623,8 @@ class pdf_crabe extends ModelePDFFactures $pdf->useTemplate($tplidx); } if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + $top_shift = $this->_pagehead($pdf, $object, 0, $outputlangs); + $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10); } $pdf->setPage($pageposafter + 1); } @@ -798,7 +800,8 @@ class pdf_crabe extends ModelePDFFactures $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + $top_shift = $this->_pagehead($pdf, $object, 0, $outputlangs); + $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10); } if (!empty($tplidx)) { $pdf->useTemplate($tplidx); @@ -818,7 +821,8 @@ class pdf_crabe extends ModelePDFFactures } $pagenb++; if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + $top_shift = $this->_pagehead($pdf, $object, 0, $outputlangs); + $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10); } } } @@ -2056,6 +2060,43 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection); + + // Show shipping address + if (getDolGlobalInt('DOC_SHOW_SHIPPING_ADDRESS')) { + $idaddressshipping = $object->getIdContact('external', 'SHIPPING'); + + if (!empty($idaddressshipping)) { + $contactshipping = $object->fetch_Contact($idaddressshipping[0]); + $object->fetch_thirdparty($object->contact->fk_soc); + $carac_client_name_shipping=pdfBuildThirdpartyName($object->contact, $outputlangs); + $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, $usecontact, 'target', $object); + } else { + $carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs); + $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object);; + } + if (!empty($carac_client_shipping) && (isset($object->contact->socid) && $object->contact->socid != $object->socid)) { + $posy += $hautcadre; + + // Show shipping frame + $pdf->SetXY($posx + 2, $posy - 5); + $pdf->SetFont('', '', $default_font_size - 2); + $pdf->MultiCell($widthrecbox, '', $langs->trans('ShippingTo'), 0, 'L', 0); + $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + + // Show shipping name + $pdf->SetXY($posx + 2, $posy + 3); + $pdf->SetFont('', 'B', $default_font_size); + $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping, '', 'L'); + + $posy = $pdf->getY(); + + // Show shipping information + $pdf->SetXY($posx+2, $posy); + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping, '', 'L'); + $top_shift += $hautcadre; + } + } } $pdf->SetTextColor(0, 0, 0); diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 2551f92af53..d7c29a82399 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -162,6 +162,7 @@ ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved=This part or ano ErrorInvoiceIsNotLastOfSameType=Error: The date of invoice %s is %s. It must be posterior or equal to last date for same type invoices (%s). Please change the invoice date. BillFrom=From BillTo=To +ShippingTo=Shipping to ActionsOnBill=Actions on invoice RecurringInvoiceTemplate=Template / Recurring invoice NoQualifiedRecurringInvoiceTemplateFound=No recurring template invoice qualified for generation. From b272877fe20ca1149bebdf731c0ae2a560e926d7 Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Fri, 18 Nov 2022 16:20:52 +0100 Subject: [PATCH 03/11] Sponge and FIx and optimise --- htdocs/admin/facture.php | 2 +- htdocs/admin/pdf_other.php | 22 ++++--- .../modules/facture/doc/pdf_crabe.modules.php | 40 +++++++----- .../facture/doc/pdf_sponge.modules.php | 65 +++++++++++++++++-- .../modules/facture/mod_facture_mercure.php | 22 +++++-- htdocs/langs/en_US/admin.lang | 2 + htdocs/langs/en_US/bills.lang | 3 +- 7 files changed, 119 insertions(+), 37 deletions(-) diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index d2e1ec4ea25..2dd2f242a05 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -754,7 +754,7 @@ print ''; print ''; print $langs->trans("ForceInvoiceDate"); print ''; -print $form->selectyesno("forcedate", $conf->global->FAC_FORCE_DATE_VALIDATION, 1); +print $form->selectyesno("forcedate", getDolGlobalInt('FAC_FORCE_DATE_VALIDATION')?$conf->global->FAC_FORCE_DATE_VALIDATION:0, 1); print ''; print ''; print "\n"; diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php index f2f9f83f67c..3a10bd8f2e8 100644 --- a/htdocs/admin/pdf_other.php +++ b/htdocs/admin/pdf_other.php @@ -69,6 +69,10 @@ if ($action == 'update') { dolibarr_set_const($db, "INVOICE_ADD_SWISS_QR_CODE", GETPOST("INVOICE_ADD_SWISS_QR_CODE", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, "INVOICE_ADD_ZATCA_QR_CODE", $conf->entity); } + if (GETPOSTISSET('DOC_SHOW_SHIPPING_ADDRESS')) { + dolibarr_set_const($db, "DOC_SHOW_SHIPPING_ADDRESS", GETPOST("DOC_SHOW_SHIPPING_ADDRESS", 'int'), 'chaine', 0, '', $conf->entity); + dolibarr_del_const($db, "DOC_SHOW_SHIPPING_ADDRESS", $conf->entity); + } setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -155,16 +159,16 @@ if (isModEnabled('facture')) { } print ''; - /* - print ''.$langs->trans("MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING'); - } else { + print ''; + print $form->textwithpicto($langs->trans("INVOICE_SHOW_SHIPPING_ADDRESS"), $langs->trans("INVOICE_SHOW_SHIPPING_ADDRESSMore")); + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('INVOICE_SHOW_SHIPPING_ADDRESS'); + } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING", $arrval, $conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING); - } - print ''; - */ + print $form->selectarray("INVOICE_SHOW_SHIPPING_ADDRESS", $arrval, $conf->global->INVOICE_SHOW_SHIPPING_ADDRESS); + } + print ''; print ''; print ''; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 8d68664b48f..fc08f9814d0 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -947,7 +947,8 @@ class pdf_crabe extends ModelePDFFactures $pdf->useTemplate($tplidx); } if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + $top_shift = $this->_pagehead($pdf, $object, 0, $outputlangs); + $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10); } $pdf->setPage($current_page); $this->_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top + $y - 3, $tab3_width, $tab3_height); @@ -1009,7 +1010,8 @@ class pdf_crabe extends ModelePDFFactures $pdf->useTemplate($tplidx); } if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + $top_shift = $this->_pagehead($pdf, $object, 0, $outputlangs); + $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10); } $pdf->setPage($current_page); $this->_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top + $y - 3, $tab3_width, $tab3_height); @@ -2028,6 +2030,25 @@ class pdf_crabe extends ModelePDFFactures $mode = 'target'; $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object); + $titelrecipient = $outputlangs->transnoentities("BillTo"); + + if (getDolGlobalInt('INVOICE_SHOW_SHIPPING_ADDRESS') || $this->emetteur->country_code == 'FR') { + $idaddressshipping = $object->getIdContact('external', 'SHIPPING'); + + if (!empty($idaddressshipping)) { + $contactshipping = $object->fetch_Contact($idaddressshipping[0]); + $object->fetch_thirdparty($object->contact->fk_soc); + $carac_client_name_shipping=pdfBuildThirdpartyName($object->contact, $outputlangs); + $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, $usecontact, 'target', $object); + } else { + $carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs); + $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object);; + } + if ((isset($object->contact->socid) && $object->contact->socid == $object->socid) || !isset($object->contact->socid)) { + $titelrecipient = $outputlangs->transnoentities("BillShippTo"); + } + } + // Show recipient $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; if ($this->page_largeur < 210) { @@ -2045,7 +2066,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); - $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection); + $pdf->MultiCell($widthrecbox - 2, 5, $titelrecipient, 0, $ltrdirection); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); } @@ -2062,18 +2083,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection); // Show shipping address - if (getDolGlobalInt('DOC_SHOW_SHIPPING_ADDRESS')) { - $idaddressshipping = $object->getIdContact('external', 'SHIPPING'); - - if (!empty($idaddressshipping)) { - $contactshipping = $object->fetch_Contact($idaddressshipping[0]); - $object->fetch_thirdparty($object->contact->fk_soc); - $carac_client_name_shipping=pdfBuildThirdpartyName($object->contact, $outputlangs); - $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, $usecontact, 'target', $object); - } else { - $carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs); - $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object);; - } + if (getDolGlobalInt('INVOICE_SHOW_SHIPPING_ADDRESS') || $this->emetteur->country_code == 'FR') { if (!empty($carac_client_shipping) && (isset($object->contact->socid) && $object->contact->socid != $object->socid)) { $posy += $hautcadre; diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index e11cd90bc43..3f001f1c5d2 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -448,7 +448,9 @@ class pdf_sponge extends ModelePDFFactures $pagenb++; // Output header (logo, ref and address blocks). This is first call for first page. - $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis); + $pagehead = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis); + $top_shift = $pagehead['top_shift']; + $shipp_shift = $pagehead['shipp_shift']; $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); @@ -456,7 +458,7 @@ class pdf_sponge extends ModelePDFFactures // $pdf->GetY() here can't be used. It is bottom of the second addresse box but first one may be higher // $this->tab_top is y where we must continue content (90 = 42 + 48: 42 is height of logo and ref, 48 is address blocks) - $this->tab_top = 90 + $top_shift; // top_shift is an addition for linked objects or addons (0 in most cases) + $this->tab_top = 90 + $top_shift + $shipp_shift; // top_shift is an addition for linked objects or addons (0 in most cases) $this->tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10); // You can add more thing under header here, if you increase $extra_under_address_shift too. @@ -1290,7 +1292,7 @@ class pdf_sponge extends ModelePDFFactures // Decret n°2099-1299 2022-10-07 // French mention : "Option pour le paiement de la taxe d'après les débits" if ($this->emetteur->country_code == 'FR') { - if ($conf->global->TAX_MODE == 1) { + if (isset($conf->global->TAX_MODE) && $conf->global->TAX_MODE == 1) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->writeHTMLCell(80, 5, '', '', $outputlangs->transnoentities("MentionVATDebitOptionIsOn"), 0, 1); @@ -2222,6 +2224,7 @@ class pdf_sponge extends ModelePDFFactures $posy += 1; $top_shift = 0; + $shipp_shift = 0; // Show list of linked objects $current_y = $pdf->getY(); $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size); @@ -2244,7 +2247,6 @@ class pdf_sponge extends ModelePDFFactures $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; - // Show sender frame if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) { $pdf->SetTextColor(0, 0, 0); @@ -2290,6 +2292,25 @@ class pdf_sponge extends ModelePDFFactures $mode = 'target'; $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object); + $titelrecipient = $outputlangs->transnoentities("BillTo"); + + if (getDolGlobalInt('INVOICE_SHOW_SHIPPING_ADDRESS') || $this->emetteur->country_code == 'FR') { + $idaddressshipping = $object->getIdContact('external', 'SHIPPING'); + + if (!empty($idaddressshipping)) { + $contactshipping = $object->fetch_Contact($idaddressshipping[0]); + $object->fetch_thirdparty($object->contact->fk_soc); + $carac_client_name_shipping=pdfBuildThirdpartyName($object->contact, $outputlangs); + $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, $usecontact, 'target', $object); + } else { + $carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs); + $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object);; + } + if ((isset($object->contact->socid) && $object->contact->socid == $object->socid) || !isset($object->contact->socid)) { + $titelrecipient = $outputlangs->transnoentities("BillShippTo"); + } + } + // Show recipient $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; if ($this->page_largeur < 210) { @@ -2307,7 +2328,7 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); - $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection); + $pdf->MultiCell($widthrecbox - 2, 5, $titelrecipient, 0, $ltrdirection); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); } @@ -2322,10 +2343,42 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection); + + // Show shipping address + if (getDolGlobalInt('INVOICE_SHOW_SHIPPING_ADDRESS') || $this->emetteur->country_code == 'FR') { + if (!empty($carac_client_shipping) && (isset($object->contact->socid) && $object->contact->socid != $object->socid)) { + $posy += $hautcadre; + + // Show shipping frame + $pdf->SetXY($posx + 2, $posy - 5); + $pdf->SetFont('', '', $default_font_size - 2); + $pdf->MultiCell($widthrecbox, '', $langs->trans('ShippingTo'), 0, 'L', 0); + $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + + // Show shipping name + $pdf->SetXY($posx + 2, $posy + 3); + $pdf->SetFont('', 'B', $default_font_size); + $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping, '', 'L'); + + $posy = $pdf->getY(); + + // Show shipping information + $pdf->SetXY($posx+2, $posy); + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping, '', 'L'); + $shipp_shift += $hautcadre; + } + } } $pdf->SetTextColor(0, 0, 0); - return $top_shift; + + // $pagehead = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis); + // $top_shift = $pagehead->top_shift; + // $shipp_shift = $pagehead->shipp_shift; + + $pagehead = array('top_shift' => $top_shift, 'shipp_shift' => $shipp_shift); + return $pagehead; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index 7a572615a21..7692568feff 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -143,16 +143,28 @@ class mod_facture_mercure extends ModeleNumRefFactures // Get Mask value $mask = ''; if (is_object($invoice) && $invoice->type == 1) { - $mask = $conf->global->FACTURE_MERCURE_MASK_REPLACEMENT; + if (isset($conf->global->FACTURE_MERCURE_MASK_REPLACEMENT)) { + $mask = $conf->global->FACTURE_MERCURE_MASK_REPLACEMENT; + } if (!$mask) { - $mask = $conf->global->FACTURE_MERCURE_MASK_INVOICE; + if (isset($conf->global->FACTURE_MERCURE_MASK_INVOICE)) { + $mask = $conf->global->FACTURE_MERCURE_MASK_INVOICE; + } } } elseif (is_object($invoice) && $invoice->type == 2) { - $mask = $conf->global->FACTURE_MERCURE_MASK_CREDIT; + if (isset($conf->global->FACTURE_MERCURE_MASK_CREDIT)) { + $mask = $conf->global->FACTURE_MERCURE_MASK_CREDIT; + } } elseif (is_object($invoice) && $invoice->type == 3) { - $mask = $conf->global->FACTURE_MERCURE_MASK_DEPOSIT; + if (isset($conf->global->FACTURE_MERCURE_MASK_DEPOSIT)) { + $mask = $conf->global->FACTURE_MERCURE_MASK_DEPOSIT; + } } else { - $mask = $conf->global->FACTURE_MERCURE_MASK_INVOICE; + if (isset($conf->global->FACTURE_MERCURE_MASK_INVOICE)) { + $mask = $conf->global->FACTURE_MERCURE_MASK_INVOICE; + } else { + $mask = ''; + } } if (!$mask) { $this->error = 'NotConfigured'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 2cd9d55aefb..adec92ba029 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2299,6 +2299,8 @@ IconOnly=Icon only - Text on tooltip only INVOICE_ADD_ZATCA_QR_CODE=Show the ZATCA QR code on invoices INVOICE_ADD_ZATCA_QR_CODEMore=Some Arabic countries need this QR Code on their invoices INVOICE_ADD_SWISS_QR_CODE=Show the swiss QR-Bill code on invoices +INVOICE_SHOW_SHIPPING_ADDRESS=Show shipping address +INVOICE_SHOW_SHIPPING_ADDRESSMore=Compulsory mention for France UrlSocialNetworksDesc=Url link of social network. Use {socialid} for the variable part that contains the social network ID. IfThisCategoryIsChildOfAnother=If this category is a child of another one DarkThemeMode=Dark theme mode diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index d7c29a82399..b631fada41b 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -161,7 +161,8 @@ ErrorCantCancelIfReplacementInvoiceNotValidated=Error, can't cancel an invoice t ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved=This part or another is already used so discount series cannot be removed. ErrorInvoiceIsNotLastOfSameType=Error: The date of invoice %s is %s. It must be posterior or equal to last date for same type invoices (%s). Please change the invoice date. BillFrom=From -BillTo=To +BillTo=Address to +BillShippTo=Address and shipping to ShippingTo=Shipping to ActionsOnBill=Actions on invoice RecurringInvoiceTemplate=Template / Recurring invoice From d25cc6e83277ac3198e0e83f6ebb4e01b889a0ab Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Fri, 18 Nov 2022 16:28:21 +0100 Subject: [PATCH 04/11] Clean --- .../modules/facture/doc/pdf_crabe.modules.php | 32 +++++++------------ .../facture/doc/pdf_sponge.modules.php | 32 +++++++------------ htdocs/langs/en_US/bills.lang | 3 +- 3 files changed, 25 insertions(+), 42 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index fc08f9814d0..74c8f2e6ae7 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -2030,25 +2030,6 @@ class pdf_crabe extends ModelePDFFactures $mode = 'target'; $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object); - $titelrecipient = $outputlangs->transnoentities("BillTo"); - - if (getDolGlobalInt('INVOICE_SHOW_SHIPPING_ADDRESS') || $this->emetteur->country_code == 'FR') { - $idaddressshipping = $object->getIdContact('external', 'SHIPPING'); - - if (!empty($idaddressshipping)) { - $contactshipping = $object->fetch_Contact($idaddressshipping[0]); - $object->fetch_thirdparty($object->contact->fk_soc); - $carac_client_name_shipping=pdfBuildThirdpartyName($object->contact, $outputlangs); - $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, $usecontact, 'target', $object); - } else { - $carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs); - $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object);; - } - if ((isset($object->contact->socid) && $object->contact->socid == $object->socid) || !isset($object->contact->socid)) { - $titelrecipient = $outputlangs->transnoentities("BillShippTo"); - } - } - // Show recipient $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; if ($this->page_largeur < 210) { @@ -2066,7 +2047,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); - $pdf->MultiCell($widthrecbox - 2, 5, $titelrecipient, 0, $ltrdirection); + $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); } @@ -2084,6 +2065,17 @@ class pdf_crabe extends ModelePDFFactures // Show shipping address if (getDolGlobalInt('INVOICE_SHOW_SHIPPING_ADDRESS') || $this->emetteur->country_code == 'FR') { + $idaddressshipping = $object->getIdContact('external', 'SHIPPING'); + + if (!empty($idaddressshipping)) { + $contactshipping = $object->fetch_Contact($idaddressshipping[0]); + $object->fetch_thirdparty($object->contact->fk_soc); + $carac_client_name_shipping=pdfBuildThirdpartyName($object->contact, $outputlangs); + $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, $usecontact, 'target', $object); + } else { + $carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs); + $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object);; + } if (!empty($carac_client_shipping) && (isset($object->contact->socid) && $object->contact->socid != $object->socid)) { $posy += $hautcadre; diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 3f001f1c5d2..868ee71343f 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -2292,25 +2292,6 @@ class pdf_sponge extends ModelePDFFactures $mode = 'target'; $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object); - $titelrecipient = $outputlangs->transnoentities("BillTo"); - - if (getDolGlobalInt('INVOICE_SHOW_SHIPPING_ADDRESS') || $this->emetteur->country_code == 'FR') { - $idaddressshipping = $object->getIdContact('external', 'SHIPPING'); - - if (!empty($idaddressshipping)) { - $contactshipping = $object->fetch_Contact($idaddressshipping[0]); - $object->fetch_thirdparty($object->contact->fk_soc); - $carac_client_name_shipping=pdfBuildThirdpartyName($object->contact, $outputlangs); - $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, $usecontact, 'target', $object); - } else { - $carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs); - $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object);; - } - if ((isset($object->contact->socid) && $object->contact->socid == $object->socid) || !isset($object->contact->socid)) { - $titelrecipient = $outputlangs->transnoentities("BillShippTo"); - } - } - // Show recipient $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; if ($this->page_largeur < 210) { @@ -2328,7 +2309,7 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posx + 2, $posy - 5); - $pdf->MultiCell($widthrecbox - 2, 5, $titelrecipient, 0, $ltrdirection); + $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); } @@ -2346,6 +2327,17 @@ class pdf_sponge extends ModelePDFFactures // Show shipping address if (getDolGlobalInt('INVOICE_SHOW_SHIPPING_ADDRESS') || $this->emetteur->country_code == 'FR') { + $idaddressshipping = $object->getIdContact('external', 'SHIPPING'); + + if (!empty($idaddressshipping)) { + $contactshipping = $object->fetch_Contact($idaddressshipping[0]); + $object->fetch_thirdparty($object->contact->fk_soc); + $carac_client_name_shipping=pdfBuildThirdpartyName($object->contact, $outputlangs); + $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, $usecontact, 'target', $object); + } else { + $carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs); + $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object);; + } if (!empty($carac_client_shipping) && (isset($object->contact->socid) && $object->contact->socid != $object->socid)) { $posy += $hautcadre; diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index b631fada41b..d7c29a82399 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -161,8 +161,7 @@ ErrorCantCancelIfReplacementInvoiceNotValidated=Error, can't cancel an invoice t ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved=This part or another is already used so discount series cannot be removed. ErrorInvoiceIsNotLastOfSameType=Error: The date of invoice %s is %s. It must be posterior or equal to last date for same type invoices (%s). Please change the invoice date. BillFrom=From -BillTo=Address to -BillShippTo=Address and shipping to +BillTo=To ShippingTo=Shipping to ActionsOnBill=Actions on invoice RecurringInvoiceTemplate=Template / Recurring invoice From 4ea20e6511681e445441d94edcfe086e2cc5bc65 Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Fri, 18 Nov 2022 17:06:11 +0100 Subject: [PATCH 05/11] Clean code --- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 868ee71343f..d90d1189e2a 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -2365,10 +2365,6 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetTextColor(0, 0, 0); - // $pagehead = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis); - // $top_shift = $pagehead->top_shift; - // $shipp_shift = $pagehead->shipp_shift; - $pagehead = array('top_shift' => $top_shift, 'shipp_shift' => $shipp_shift); return $pagehead; } From a9b14b7b2da825614dc18e3c13a56be8d2725267 Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Mon, 21 Nov 2022 09:29:30 +0100 Subject: [PATCH 06/11] Copy --- htdocs/admin/facture.php | 1 + htdocs/admin/pdf_other.php | 2 +- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 1 + .../core/modules/facture/doc/pdf_sponge.modules.php | 1 + htdocs/core/modules/facture/mod_facture_mercure.php | 11 ++++++----- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 2dd2f242a05..5feb2e9bc0b 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -6,6 +6,7 @@ * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2012-2013 Juanjo Menent * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> + * Copyright (C) 2022 Anthony Berton * * 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 diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php index 3a10bd8f2e8..f6515e9c40c 100644 --- a/htdocs/admin/pdf_other.php +++ b/htdocs/admin/pdf_other.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2012-2107 Juanjo Menent * Copyright (C) 2019 Ferran Marcet - * Copyright (C) 2021 Anthony Berton + * Copyright (C) 2021-2022 Anthony Berton * * 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 diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 74c8f2e6ae7..601189d507a 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -9,6 +9,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2017-2018 Ferran Marcet * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2022 Anthony Berton * * 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 diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index d90d1189e2a..d4ee9da122d 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -9,6 +9,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2018 Frédéric France + * Copyright (C) 2022 Anthony Berton * * 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 diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index 7692568feff..321741ea8a0 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -1,9 +1,10 @@ - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2007 Regis Houssin - * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2013 Juanjo Menent +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005-2007 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand (Resultic) + * Copyright (C) 2013 uanjo Menent + * Copyright (C) 2022 Anthony Berton * * 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 From 8d35258370b652ad41ab09437c355974adaaba3f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Nov 2022 22:02:47 +0100 Subject: [PATCH 07/11] Update facture.php --- htdocs/admin/facture.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 5feb2e9bc0b..cb7ec476d21 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -755,7 +755,7 @@ print ''; print ''; print $langs->trans("ForceInvoiceDate"); print ''; -print $form->selectyesno("forcedate", getDolGlobalInt('FAC_FORCE_DATE_VALIDATION')?$conf->global->FAC_FORCE_DATE_VALIDATION:0, 1); +print $form->selectyesno("forcedate", getDolGlobalInt('FAC_FORCE_DATE_VALIDATION',0), 1); print ''; print ''; print "\n"; From 8f9dea244d1d05eec9dbaa7a8ba1b6aeeed0e2ed Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 22 Nov 2022 21:08:41 +0000 Subject: [PATCH 08/11] Fixing style errors. --- htdocs/admin/facture.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index cb7ec476d21..10746c794be 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -755,7 +755,7 @@ print ''; print ''; print $langs->trans("ForceInvoiceDate"); print ''; -print $form->selectyesno("forcedate", getDolGlobalInt('FAC_FORCE_DATE_VALIDATION',0), 1); +print $form->selectyesno("forcedate", getDolGlobalInt('FAC_FORCE_DATE_VALIDATION', 0), 1); print ''; print ''; print "\n"; From ff5609273b67650bad88fffc72d4eae743d30b9a Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Wed, 23 Nov 2022 00:29:49 +0100 Subject: [PATCH 09/11] Update pdf_other.php --- htdocs/admin/pdf_other.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php index f6515e9c40c..e5c76a36269 100644 --- a/htdocs/admin/pdf_other.php +++ b/htdocs/admin/pdf_other.php @@ -69,9 +69,9 @@ if ($action == 'update') { dolibarr_set_const($db, "INVOICE_ADD_SWISS_QR_CODE", GETPOST("INVOICE_ADD_SWISS_QR_CODE", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, "INVOICE_ADD_ZATCA_QR_CODE", $conf->entity); } - if (GETPOSTISSET('DOC_SHOW_SHIPPING_ADDRESS')) { - dolibarr_set_const($db, "DOC_SHOW_SHIPPING_ADDRESS", GETPOST("DOC_SHOW_SHIPPING_ADDRESS", 'int'), 'chaine', 0, '', $conf->entity); - dolibarr_del_const($db, "DOC_SHOW_SHIPPING_ADDRESS", $conf->entity); + if (GETPOSTISSET('INVOICE_SHOW_SHIPPING_ADDRESS')) { + dolibarr_set_const($db, "INVOICE_SHOW_SHIPPING_ADDRESS", GETPOST("INVOICE_SHOW_SHIPPING_ADDRESS", 'int'), 'chaine', 0, '', $conf->entity); + dolibarr_del_const($db, "INVOICE_SHOW_SHIPPING_ADDRESS", $conf->entity); } setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); From 84a977afe220340a4433a930570e88485adfccfa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Nov 2022 16:13:59 +0100 Subject: [PATCH 10/11] Update pdf_crabe.modules.php --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 601189d507a..654f804b0d8 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -2065,7 +2065,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection); // Show shipping address - if (getDolGlobalInt('INVOICE_SHOW_SHIPPING_ADDRESS') || $this->emetteur->country_code == 'FR') { + if (getDolGlobalInt('INVOICE_SHOW_SHIPPING_ADDRESS')) { $idaddressshipping = $object->getIdContact('external', 'SHIPPING'); if (!empty($idaddressshipping)) { From 9c786a1b50c89bb509473261b842b8c3c5b8d9a1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Nov 2022 16:15:32 +0100 Subject: [PATCH 11/11] Update pdf_sponge.modules.php --- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index d4ee9da122d..c3a4318a218 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -2327,7 +2327,7 @@ class pdf_sponge extends ModelePDFFactures $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection); // Show shipping address - if (getDolGlobalInt('INVOICE_SHOW_SHIPPING_ADDRESS') || $this->emetteur->country_code == 'FR') { + if (getDolGlobalInt('INVOICE_SHOW_SHIPPING_ADDRESS')) { $idaddressshipping = $object->getIdContact('external', 'SHIPPING'); if (!empty($idaddressshipping)) {