diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index d2e1ec4ea25..10746c794be 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 @@ -754,7 +755,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', 0), 1); print ''; print ''; print "\n"; diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php index f2f9f83f67c..e5c76a36269 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 @@ -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('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'); @@ -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 39d833de6cc..654f804b0d8 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 @@ -579,7 +580,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 +624,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 +801,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 +822,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); } } } @@ -943,7 +948,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); @@ -1005,7 +1011,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); @@ -1180,7 +1187,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); @@ -2056,6 +2063,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('INVOICE_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/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index e11cd90bc43..c3a4318a218 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 @@ -448,7 +449,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 +459,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 +1293,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 +2225,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 +2248,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); @@ -2322,10 +2325,49 @@ 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')) { + $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'); + $shipp_shift += $hautcadre; + } + } } $pdf->SetTextColor(0, 0, 0); - return $top_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..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 @@ -143,16 +144,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 3f12a36283f..4a55dc2cffc 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 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.