From bfc5f01e1ea364c068f4e9e1f912173e0c3861f6 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Wed, 30 Aug 2017 14:36:00 +0200 Subject: [PATCH 1/4] NEW Add detail of all tax rates into pdf column tax sale. -Can be hidden by pdf setup page -For know if localtax is applied into line we have to read totaltax line --- htdocs/admin/pdf.php | 76 ++++++++++++++++++++++++- htdocs/core/lib/pdf.lib.php | 12 ++-- htdocs/core/tpl/objectline_view.tpl.php | 5 +- htdocs/langs/en_US/admin.lang | 6 +- 4 files changed, 87 insertions(+), 12 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 6698be8b01f..f366d8a5ce3 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2005 Rodolphe Quiedeville * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2011 Regis Houssin - * Copyright (C) 2012-2105 Juanjo Menent + * Copyright (C) 2012-2107 Juanjo Menent * * 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 @@ -74,7 +74,11 @@ if ($action == 'update') dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_REF"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", $_POST["MAIN_PDF_USE_ISO_LOCATION"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"],'chaine',0,'',$conf->entity); - + + + dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_SECOND_TAX", $_POST["MAIN_PDF_MAIN_HIDE_SECOND_TAX"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_THIRD_TAX", $_POST["_MAIN_PDF_MAIN_HIDE_THIRD_TAX"],'chaine',0,'',$conf->entity); + header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); exit; } @@ -249,6 +253,40 @@ if ($action == 'edit') // Edit print '
'; + // Localtaxes + if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) + { + $locales =''; + $text=''; + + if ($mysoc->useLocalTax(1)) + { + $locales = $langs->transcountry("LT1",$mysoc->country_code); + $text ='' . $langs->trans("HideLocalTaxOnPDF",$langs->transcountry("LT1",$mysoc->country_code)) . ''; + $text.= $form->selectyesno('MAIN_PDF_MAIN_HIDE_SECOND_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX : 0, 1); + $text .= ''; + } + + if ($mysoc->useLocalTax(2)) + { + $locales.=($locales?' & ':'').$langs->transcountry("LT2",$mysoc->country_code); + + $text.= '' . $langs->trans("HideLocalTaxOnPDF",$langs->transcountry("LT2",$mysoc->country_code)) . ''; + $text.= $form->selectyesno('MAIN_PDF_MAIN_HIDE_THIRD_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX : 0, 1); + $text.= ''; + } + + print load_fiche_titre($langs->trans("PDFLocaltax",$locales),'',''); + $var=true; + print ''; + print ''; + print $text; + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print '
'; + + } + // Other print load_fiche_titre($langs->trans("Other"),'','').'
'; $var=true; @@ -444,6 +482,40 @@ else // Show print '
'; + // Localtaxes + if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) + { + $locales =''; + $text=''; + + if ($mysoc->useLocalTax(1)) + { + $locales = $langs->transcountry("LT1",$mysoc->country_code); + $text ='' . $langs->trans("HideLocalTaxOnPDF",$langs->transcountry("LT1",$mysoc->country_code)) . ''; + $text .= yn($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX,1); + $text .= ''; + } + + if ($mysoc->useLocalTax(2)) + { + $locales.=($locales?' & ':'').$langs->transcountry("LT2",$mysoc->country_code); + + $text.= '' . $langs->trans("HideLocalTaxOnPDF",$langs->transcountry("LT2",$mysoc->country_code)) . ''; + $text.= yn($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX,1); + $text.= ''; + } + + print load_fiche_titre($langs->trans("PDFLocaltax",$locales),'',''); + $var=true; + print ''; + print ''; + print $text; + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print '
'; + + } + // Other print load_fiche_titre($langs->trans("Other"),'',''); $var=true; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 77f295bd813..8a445625022 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1,9 +1,9 @@ +/* Copyright (C) 2006-2017 Laurent Destailleur * Copyright (C) 2006 Rodolphe Quiedeville * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2010-2012 Regis Houssin - * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2010-2017 Juanjo Menent * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2012-2015 Raphaël Doursenaud @@ -1492,18 +1492,18 @@ function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0) $tmpresult=''; $tmpresult.=vatrate($object->lines[$i]->tva_tx, 1, $object->lines[$i]->info_bits, 1); - if (empty($conf->PDF_MAIN_HIDE_SECOND_TAX)) + if (empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) { - if ($object->lines[$i]->localtax1_tx != 0) + if ($object->lines[$i]->total_localtax1 != 0) { if (preg_replace('/[\s0%]/','',$tmpresult)) $tmpresult.='/'; else $tmpresult=''; $tmpresult.=vatrate(abs($object->lines[$i]->localtax1_tx),1); } } - if (empty($conf->PDF_MAIN_HIDE_THIRD_TAX)) + if (empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) { - if ($object->lines[$i]->localtax2_tx != 0) + if ($object->lines[$i]->total_localtax2 != 0) { if (preg_replace('/[\s0%]/','',$tmpresult)) $tmpresult.='/'; else $tmpresult=''; diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 5cfe2459247..7176e4a028d 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -5,6 +5,7 @@ * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2013 Florian Henry + * Copyright (C) 2017 Juanjo Menent * * 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 @@ -145,8 +146,8 @@ if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax=0; //var_dump($line); $positiverates=''; if (price2num($line->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($line->tva_tx); - if (price2num($line->localtax1_tx)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx); - if (price2num($line->localtax2_tx)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx); + if (price2num($line->total_localtax1)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx); + if (price2num($line->total_localtax2_tx)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx); if (empty($positiverates)) $positiverates='0'; echo vatrate($positiverates.($line->vat_src_code?' ('.$line->vat_src_code.')':''), '%', $line->info_bits); //echo vatrate($line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), '%', $line->info_bits); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 2e3ccdd965e..4ef46f4d2fc 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -356,6 +356,8 @@ PDF=PDF PDFDesc=You can set each global options related to the PDF generation PDFAddressForging=Rules to forge address boxes HideAnyVATInformationOnPDF=Hide all information related to VAT on generated PDF +PDFLocaltax=Rules for %s +HideLocalTaxOnPDF=Hide %s into pdf column tax sale HideDescOnPDF=Hide products description on generated PDF HideRefOnPDF=Hide products ref. on generated PDF HideDetailsOnPDF=Hide product lines details on generated PDF @@ -1638,11 +1640,11 @@ BackgroundTableLineEvenColor=Background color for even table lines MinimumNoticePeriod=Minimum notice period (Your leave request must be done before this delay) NbAddedAutomatically=Number of days added to counters of users (automatically) each month EnterAnyCode=This field contains a reference to identify line. Enter any value of your choice, but without special characters. -UnicodeCurrency=Enter here between braces, list of byte number that represent the currency symbol. For exemple: for $, enter [36] - for brazil real R$ [82,36] - for €, enter [8364] +UnicodeCurrency=Enter here between braces, list of byte number that represent the currency symbol. For exemple: for $, enter [36] - for brazil real R$ [82,36] - for ?, enter [8364] ColorFormat=The RGB color is in HEX format, eg: FF0000 PositionIntoComboList=Position of line into combo lists SellTaxRate=Sale tax rate -RecuperableOnly=Yes for VAT "Non Perçue Récupérable" dedicated for some state in France. Keep value to "No" in all other cases. +RecuperableOnly=Yes for VAT "Non Per?ue R?cup?rable" dedicated for some state in France. Keep value to "No" in all other cases. UrlTrackingDesc=If the provider or transport service offer a page or web site to check status of your shipping, you can enter it here. You can use the key {TRACKID} into URL parameters so the system will replace it with value of tracking number user entered into shipment card. OpportunityPercent=When you create an opportunity, you will defined an estimated amount of project/lead. According to status of opportunity, this amount may be multiplicated by this rate to evaluate global amount all your opportunities may generate. Value is percent (between 0 and 100). TemplateForElement=This template record is dedicated to which element From a3085cb44a95afd7453f12e33362158ad5c27dca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Aug 2017 16:43:57 +0200 Subject: [PATCH 2/4] Update objectline_view.tpl.php --- htdocs/core/tpl/objectline_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 7176e4a028d..f968fdcbfc7 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -147,7 +147,7 @@ if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax=0; $positiverates=''; if (price2num($line->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($line->tva_tx); if (price2num($line->total_localtax1)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx); - if (price2num($line->total_localtax2_tx)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx); + if (price2num($line->total_localtax2)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx); if (empty($positiverates)) $positiverates='0'; echo vatrate($positiverates.($line->vat_src_code?' ('.$line->vat_src_code.')':''), '%', $line->info_bits); //echo vatrate($line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), '%', $line->info_bits); From 2c4e8cbb4a9cc12b5c829560978c04a766423ccd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Aug 2017 16:45:53 +0200 Subject: [PATCH 3/4] Update admin.lang --- htdocs/langs/en_US/admin.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 4ef46f4d2fc..75b904dfa2d 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1640,11 +1640,11 @@ BackgroundTableLineEvenColor=Background color for even table lines MinimumNoticePeriod=Minimum notice period (Your leave request must be done before this delay) NbAddedAutomatically=Number of days added to counters of users (automatically) each month EnterAnyCode=This field contains a reference to identify line. Enter any value of your choice, but without special characters. -UnicodeCurrency=Enter here between braces, list of byte number that represent the currency symbol. For exemple: for $, enter [36] - for brazil real R$ [82,36] - for ?, enter [8364] +UnicodeCurrency=Enter here between braces, list of byte number that represent the currency symbol. For exemple: for $, enter [36] - for brazil real R$ [82,36] - for €, enter [8364] ColorFormat=The RGB color is in HEX format, eg: FF0000 PositionIntoComboList=Position of line into combo lists SellTaxRate=Sale tax rate -RecuperableOnly=Yes for VAT "Non Per?ue R?cup?rable" dedicated for some state in France. Keep value to "No" in all other cases. +RecuperableOnly=Yes for VAT "Not Perceived but Recoverable" dedicated for some state in France. Keep value to "No" in all other cases. UrlTrackingDesc=If the provider or transport service offer a page or web site to check status of your shipping, you can enter it here. You can use the key {TRACKID} into URL parameters so the system will replace it with value of tracking number user entered into shipment card. OpportunityPercent=When you create an opportunity, you will defined an estimated amount of project/lead. According to status of opportunity, this amount may be multiplicated by this rate to evaluate global amount all your opportunities may generate. Value is percent (between 0 and 100). TemplateForElement=This template record is dedicated to which element From 3e4a7ba97cde90c818666b37f4a01042c0a0e314 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Aug 2017 16:46:50 +0200 Subject: [PATCH 4/4] Update admin.lang --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 75b904dfa2d..dfd6e90929a 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -357,7 +357,7 @@ PDFDesc=You can set each global options related to the PDF generation PDFAddressForging=Rules to forge address boxes HideAnyVATInformationOnPDF=Hide all information related to VAT on generated PDF PDFLocaltax=Rules for %s -HideLocalTaxOnPDF=Hide %s into pdf column tax sale +HideLocalTaxOnPDF=Hide %s rate into pdf column tax sale HideDescOnPDF=Hide products description on generated PDF HideRefOnPDF=Hide products ref. on generated PDF HideDetailsOnPDF=Hide product lines details on generated PDF