1<?php 2/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> 4 * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com> 5 * Copyright (C) 2012-2107 Juanjo Menent <jmenent@2byte.es> 6 * Copyright (C) 2019 Ferran Marcet <fmarcet@2byte.es> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program. If not, see <https://www.gnu.org/licenses/>. 20 */ 21 22/** 23 * \file htdocs/admin/pdf.php 24 * \brief Page to setup PDF options 25 */ 26 27require '../main.inc.php'; 28require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; 29require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; 30require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; 31require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; 32require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; 33require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; 34 35// Load translation files required by the page 36$langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members', 'stocks')); 37 38if (!$user->admin) accessforbidden(); 39 40$action = GETPOST('action', 'aZ09'); 41$cancel = GETPOST('cancel', 'alpha'); 42 43 44/* 45 * Actions 46 */ 47 48if ($cancel) { 49 $action = ''; 50} 51 52if ($action == 'update') 53{ 54 dolibarr_set_const($db, "MAIN_PDF_FORMAT", GETPOST("MAIN_PDF_FORMAT"), 'chaine', 0, '', $conf->entity); 55 56 dolibarr_set_const($db, "MAIN_PDF_MARGIN_LEFT", GETPOST("MAIN_PDF_MARGIN_LEFT"), 'chaine', 0, '', $conf->entity); 57 dolibarr_set_const($db, "MAIN_PDF_MARGIN_RIGHT", GETPOST("MAIN_PDF_MARGIN_TOP"), 'chaine', 0, '', $conf->entity); 58 dolibarr_set_const($db, "MAIN_PDF_MARGIN_BOTTOM", GETPOST("MAIN_PDF_MARGIN_BOTTOM"), 'chaine', 0, '', $conf->entity); 59 60 dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", GETPOST("MAIN_PROFID1_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); 61 dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", GETPOST("MAIN_PROFID2_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); 62 dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS", GETPOST("MAIN_PROFID3_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); 63 dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", GETPOST("MAIN_PROFID4_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); 64 dolibarr_set_const($db, "MAIN_PROFID5_IN_ADDRESS", GETPOST("MAIN_PROFID5_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); 65 dolibarr_set_const($db, "MAIN_PROFID6_IN_ADDRESS", GETPOST("MAIN_PROFID6_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); 66 67 dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", GETPOST("MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"), 'chaine', 0, '', $conf->entity); 68 69 dolibarr_set_const($db, "MAIN_TVAINTRA_NOT_IN_ADDRESS", GETPOST("MAIN_TVAINTRA_NOT_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); 70 dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"), 'chaine', 0, '', $conf->entity); 71 dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_DESC"), 'chaine', 0, '', $conf->entity); 72 dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_REF"), 'chaine', 0, '', $conf->entity); 73 74 dolibarr_set_const($db, "MAIN_DOCUMENTS_LOGO_HEIGHT", GETPOST("MAIN_DOCUMENTS_LOGO_HEIGHT", 'int'), 'chaine', 0, '', $conf->entity); 75 dolibarr_set_const($db, "MAIN_INVERT_SENDER_RECIPIENT", GETPOST("MAIN_INVERT_SENDER_RECIPIENT"), 'chaine', 0, '', $conf->entity); 76 dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", GETPOST("MAIN_PDF_USE_ISO_LOCATION"), 'chaine', 0, '', $conf->entity); 77 dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", GETPOST("MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"), 'chaine', 0, '', $conf->entity); 78 79 dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_SECOND_TAX", GETPOST("MAIN_PDF_MAIN_HIDE_SECOND_TAX"), 'chaine', 0, '', $conf->entity); 80 dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_THIRD_TAX", GETPOST("MAIN_PDF_MAIN_HIDE_THIRD_TAX"), 'chaine', 0, '', $conf->entity); 81 82 dolibarr_set_const($db, "PDF_USE_ALSO_LANGUAGE_CODE", GETPOST('PDF_USE_ALSO_LANGUAGE_CODE', 'alpha'), 'chaine', 0, '', $conf->entity); 83 dolibarr_set_const($db, "SHOW_SUBPRODUCT_REF_IN_PDF", GETPOST('SHOW_SUBPRODUCT_REF_IN_PDF', 'alpha'), 'chaine', 0, '', $conf->entity); 84 85 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); 86 87 header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); 88 exit; 89} 90 91 92 93/* 94 * View 95 */ 96 97$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; 98llxHeader('', $langs->trans("Setup"), $wikihelp); 99 100$form = new Form($db); 101$formother = new FormOther($db); 102$formadmin = new FormAdmin($db); 103 104$arraydetailsforpdffoot = array( 105 0 => $langs->transnoentitiesnoconv('NoDetails'), 106 1 => $langs->transnoentitiesnoconv('DisplayCompanyInfo'), 107 2 => $langs->transnoentitiesnoconv('DisplayCompanyManagers'), 108 3 => $langs->transnoentitiesnoconv('DisplayCompanyInfoAndManagers') 109); 110 111$s = $langs->trans("LibraryToBuildPDF")."<br>"; 112$i = 0; 113$pdf = pdf_getInstance('A4'); 114if (class_exists('FPDF') && !class_exists('TCPDF')) 115{ 116 if ($i) $s .= ' + '; 117 $s .= 'FPDF'; 118 $s .= ' ('.@constant('FPDF_PATH').')'; 119 $i++; 120} 121if (class_exists('TCPDF')) 122{ 123 if ($i) $s .= ' + '; 124 $s .= 'TCPDF'; 125 $s .= ' ('.@constant('TCPDF_PATH').')'; 126 $i++; 127} 128if (class_exists('FPDI')) 129{ 130 if ($i) $s .= ' + '; 131 $s .= 'FPDI'; 132 $s .= ' ('.@constant('FPDI_PATH').')'; 133 $i++; 134} 135if (class_exists('TCPDI')) 136{ 137 if ($i) $s .= ' + '; 138 $s .= 'TCPDI'; 139 $s .= ' ('.@constant('TCPDI_PATH').')'; 140 $i++; 141} 142 143print load_fiche_titre($langs->trans("PDF"), '', 'title_setup'); 144 145print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("PDFDesc"), $s)."</span><br>\n"; 146print "<br>\n"; 147 148$noCountryCode = (empty($mysoc->country_code) ? true : false); 149 150print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">'; 151print '<input type="hidden" name="token" value="'.newToken().'">'; 152print '<input type="hidden" name="action" value="update">'; 153 154clearstatcache(); 155 156 157// Misc options 158print load_fiche_titre($langs->trans("DictionaryPaperFormat"), '', ''); 159 160print '<div class="div-table-responsive-no-min">'; 161print '<table summary="more" class="noborder centpercent">'; 162print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>'; 163 164$selected = $conf->global->MAIN_PDF_FORMAT; 165if (empty($selected)) $selected = dol_getDefaultFormat(); 166 167// Show pdf format 168 169print '<tr class="oddeven"><td>'.$langs->trans("DictionaryPaperFormat").'</td><td>'; 170print $formadmin->select_paper_format($selected, 'MAIN_PDF_FORMAT'); 171print '</td></tr>'; 172 173print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_LEFT").'</td><td>'; 174print '<input type="text" class="maxwidth50" name="MAIN_PDF_MARGIN_LEFT" value="'.(empty($conf->global->MAIN_PDF_MARGIN_LEFT) ? 10 : $conf->global->MAIN_PDF_MARGIN_LEFT).'">'; 175print '</td></tr>'; 176print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_RIGHT").'</td><td>'; 177print '<input type="text" class="maxwidth50" name="MAIN_PDF_MARGIN_RIGHT" value="'.(empty($conf->global->MAIN_PDF_MARGIN_RIGHT) ? 10 : $conf->global->MAIN_PDF_MARGIN_RIGHT).'">'; 178print '</td></tr>'; 179print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_TOP").'</td><td>'; 180print '<input type="text" class="maxwidth50" name="MAIN_PDF_MARGIN_TOP" value="'.(empty($conf->global->MAIN_PDF_MARGIN_TOP) ? 10 : $conf->global->MAIN_PDF_MARGIN_TOP).'">'; 181print '</td></tr>'; 182print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_BOTTOM").'</td><td>'; 183print '<input type="text" class="maxwidth50" name="MAIN_PDF_MARGIN_BOTTOM" value="'.(empty($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? 10 : $conf->global->MAIN_PDF_MARGIN_BOTTOM).'">'; 184print '</td></tr>'; 185 186print '</table>'; 187print '</div>'; 188 189print '<br>'; 190 191 192// Addresses 193print load_fiche_titre($langs->trans("PDFAddressForging"), '', ''); 194 195print '<div class="div-table-responsive-no-min">'; 196print '<table summary="more" class="noborder centpercent">'; 197print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>'; 198 199// Hide VAT Intra on address 200 201print '<tr class="oddeven"><td>'.$langs->trans("ShowVATIntaInAddress").'</td><td>'; 202print $form->selectyesno('MAIN_TVAINTRA_NOT_IN_ADDRESS', (!empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) ? $conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS : 0, 1); 203print '</td></tr>'; 204 205// Show prof id in address into pdf 206for ($i = 1; $i <= 6; $i++) 207{ 208 if (!$noCountryCode) 209 { 210 $pid = $langs->transcountry("ProfId".$i, $mysoc->country_code); 211 if ($pid == '-') $pid = false; 212 } else { 213 $pid = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; 214 } 215 if ($pid) 216 { 217 print '<tr class="oddeven"><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid.'</td><td>'; 218 $keyforconstant = 'MAIN_PROFID'.$i.'_IN_ADDRESS'; 219 print $form->selectyesno($keyforconstant, isset($conf->global->$keyforconstant) ? $conf->global->$keyforconstant : 0, 1, $noCountryCode); 220 print '</td></tr>'; 221 } 222} 223 224print '</table>'; 225print '</div>'; 226 227 228print '<br>'; 229 230 231// Localtaxes 232$locales = ''; 233$text = ''; 234if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) 235{ 236 if ($mysoc->useLocalTax(1)) 237 { 238 $locales = $langs->transcountry("LT1", $mysoc->country_code); 239 $text = '<tr class="oddeven"><td>'.$langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT1", $mysoc->country_code)).'</td><td>'; 240 $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); 241 $text .= '</td></tr>'; 242 } 243 244 if ($mysoc->useLocalTax(2)) 245 { 246 $locales .= ($locales ? ' & ' : '').$langs->transcountry("LT2", $mysoc->country_code); 247 248 $text .= '<tr class="oddeven"><td>'.$langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT2", $mysoc->country_code)).'</td><td>'; 249 $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); 250 $text .= '</td></tr>'; 251 } 252} 253 254$title = $langs->trans("PDFRulesForSalesTax"); 255if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) 256{ 257 $title .= ' - '.$langs->trans("PDFLocaltax", $locales); 258} 259 260print load_fiche_titre($title, '', ''); 261 262print '<table summary="more" class="noborder centpercent">'; 263print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>'; 264 265// Hide any information on Sale tax / VAT 266 267print '<tr class="oddeven"><td>'.$langs->trans("HideAnyVATInformationOnPDF").'</td><td>'; 268print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT : 0, 1); 269print '</td></tr>'; 270 271// Locataxes 272print $text; 273 274print '</table>'; 275print '<br>'; 276 277 278// Other 279print load_fiche_titre($langs->trans("Other"), '', ''); 280 281print '<div class="div-table-responsive-no-min">'; 282print '<table summary="more" class="noborder centpercent">'; 283print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>'; 284 285// Height of logo 286 287print '<tr class="oddeven"><td>'.$langs->trans("MAIN_DOCUMENTS_LOGO_HEIGHT").'</td><td>'; 288print '<input type="text" class="maxwidth50" name="MAIN_DOCUMENTS_LOGO_HEIGHT" value="'.(!empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT) ? $conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT : 20).'">'; 289print '</td></tr>'; 290 291//Desc 292 293print '<tr class="oddeven"><td>'.$langs->trans("HideDescOnPDF").'</td><td>'; 294print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DESC', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC : 0, 1); 295print '</td></tr>'; 296 297//Ref 298 299print '<tr class="oddeven"><td>'.$langs->trans("HideRefOnPDF").'</td><td>'; 300print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_REF', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF : 0, 1); 301print '</td></tr>'; 302 303//Details 304 305print '<tr class="oddeven"><td>'.$langs->trans("HideDetailsOnPDF").'</td><td>'; 306print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS : 0, 1); 307print '</td></tr>'; 308 309//Invert sender and recipient 310 311print '<tr class="oddeven"><td>'.$langs->trans("SwapSenderAndRecipientOnPDF").'</td><td>'; 312print $form->selectyesno('MAIN_INVERT_SENDER_RECIPIENT', (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) ? $conf->global->MAIN_INVERT_SENDER_RECIPIENT : 0, 1); 313print '</td></tr>'; 314 315// Place customer adress to the ISO location 316 317print '<tr class="oddeven"><td>'.$langs->trans("PlaceCustomerAddressToIsoLocation").'</td><td>'; 318print $form->selectyesno('MAIN_PDF_USE_ISO_LOCATION', (!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION)) ? $conf->global->MAIN_PDF_USE_ISO_LOCATION : 0, 1); 319print '</td></tr>'; 320 321 322print '<tr class="oddeven"><td>'.$langs->trans("ShowDetailsInPDFPageFoot").'</td><td>'; 323print $form->selectarray('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', $arraydetailsforpdffoot, $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS); 324print '</td></tr>'; 325 326print '<tr class="oddeven"><td>'.$langs->trans("PDF_USE_ALSO_LANGUAGE_CODE").'</td><td>'; 327//if (! empty($conf->global->MAIN_MULTILANGS)) 328//{ 329print $formadmin->select_language(GETPOSTISSET('PDF_USE_ALSO_LANGUAGE_CODE') ? GETPOST('PDF_USE_ALSO_LANGUAGE_CODE') : $conf->global->PDF_USE_ALSO_LANGUAGE_CODE, 'PDF_USE_ALSO_LANGUAGE_CODE', 0, null, 1); 330//} else { 331// print '<span class="opacitymedium">'.$langs->trans("MultiLangNotEnabled").'</span>'; 332//} 333print '</td></tr>'; 334 335// SHOW_SUBPRODUCT_REF_IN_PDF - Option to show the detail of product ref for kits. 336print '<tr class="oddeven"><td>'.$langs->trans("SHOW_SUBPRODUCT_REF_IN_PDF", $langs->transnoentitiesnoconv("AssociatedProductsAbility"), $langs->transnoentitiesnoconv("Products")).'</td><td>'; 337print $form->selectyesno('SHOW_SUBPRODUCT_REF_IN_PDF', (!empty($conf->global->SHOW_SUBPRODUCT_REF_IN_PDF)) ? $conf->global->SHOW_SUBPRODUCT_REF_IN_PDF : 0, 1); 338print '</td></tr>'; 339 340print '</table>'; 341print '</div>'; 342 343print '<br><div class="center">'; 344print '<input class="button button-save" type="submit" name="save" value="'.$langs->trans("Save").'">'; 345print '</div>'; 346 347print '</form>'; 348 349 350// End of page 351llxFooter(); 352$db->close(); 353