Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW - Shipping address to invoice #22832

Merged
merged 16 commits into from Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion htdocs/admin/facture.php
Expand Up @@ -6,6 +6,7 @@
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2012-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
*
* 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
Expand Down Expand Up @@ -754,7 +755,7 @@
print '<tr class="oddeven"><td>';
print $langs->trans("ForceInvoiceDate");
print '</td><td width="60" class="center">';
print $form->selectyesno("forcedate", $conf->global->FAC_FORCE_DATE_VALIDATION, 1);
print $form->selectyesno("forcedate", getDolGlobalInt('FAC_FORCE_DATE_VALIDATION', 0), 1);
print '</td><td class="right">';
print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'" />';
print "</td></tr>\n";
Expand Down
24 changes: 14 additions & 10 deletions htdocs/admin/pdf_other.php
Expand Up @@ -4,7 +4,7 @@
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2012-2107 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2019 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2021 Anthony Berton <bertonanthony@gmail.com>
* Copyright (C) 2021-2022 Anthony Berton <bertonanthony@gmail.com>
*
* 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
Expand Down Expand Up @@ -69,6 +69,10 @@
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');

Expand Down Expand Up @@ -155,16 +159,16 @@
}
print '</td></tr>';

/*
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING").'</td><td>';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING');
} else {
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans("INVOICE_SHOW_SHIPPING_ADDRESS"), $langs->trans("INVOICE_SHOW_SHIPPING_ADDRESSMore"));
print '</td><td>';
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 '</td></tr>';
*/
print $form->selectarray("INVOICE_SHOW_SHIPPING_ADDRESS", $arrval, $conf->global->INVOICE_SHOW_SHIPPING_ADDRESS);
}
print '</td></tr>';

print '</table>';
print '</div>';
Expand Down
58 changes: 51 additions & 7 deletions htdocs/core/modules/facture/doc/pdf_crabe.modules.php
Expand Up @@ -9,6 +9,7 @@
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2017-2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
*
* 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
Expand Down Expand Up @@ -579,7 +580,8 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
$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);

Expand Down Expand Up @@ -622,7 +624,8 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
$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);
}
Expand Down Expand Up @@ -798,7 +801,8 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
$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);
Expand All @@ -818,7 +822,8 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
}
$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);
}
}
}
Expand Down Expand Up @@ -943,7 +948,8 @@ protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs, $hei
$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);
Expand Down Expand Up @@ -1005,7 +1011,8 @@ protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs, $hei
$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);
Expand Down Expand Up @@ -1180,7 +1187,7 @@ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlan
// 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);

Expand Down Expand Up @@ -2056,6 +2063,43 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output
$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);
Expand Down
52 changes: 47 additions & 5 deletions htdocs/core/modules/facture/doc/pdf_sponge.modules.php
Expand Up @@ -9,6 +9,7 @@
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
*
* 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
Expand Down Expand Up @@ -448,15 +449,17 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
$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);

// $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.
Expand Down Expand Up @@ -1290,7 +1293,7 @@ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlan
// 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);

Expand Down Expand Up @@ -2222,6 +2225,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output
$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);
Expand All @@ -2244,7 +2248,6 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output
$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);
Expand Down Expand Up @@ -2322,10 +2325,49 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output
$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
Expand Down
33 changes: 23 additions & 10 deletions htdocs/core/modules/facture/mod_facture_mercure.php
@@ -1,9 +1,10 @@
<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2013 uanjo Menent <jmenent@2byte.es>
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
*
* 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
Expand Down Expand Up @@ -143,16 +144,28 @@ public function getNextValue($objsoc, $invoice, $mode = 'next')
// 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';
Expand Down
2 changes: 2 additions & 0 deletions htdocs/langs/en_US/admin.lang
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions htdocs/langs/en_US/bills.lang
Expand Up @@ -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.
Expand Down