dolibarr  13.0.2
pdf.php
Go to the documentation of this file.
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 
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
33 require_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 
38 if (!$user->admin) accessforbidden();
39 
40 $action = GETPOST('action', 'aZ09');
41 $cancel = GETPOST('cancel', 'alpha');
42 
43 
44 /*
45  * Actions
46  */
47 
48 if ($cancel) {
49  $action = '';
50 }
51 
52 if ($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&eacute;trages|ES:Primeras_configuraciones';
98 llxHeader('', $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');
114 if (class_exists('FPDF') && !class_exists('TCPDF'))
115 {
116  if ($i) $s .= ' + ';
117  $s .= 'FPDF';
118  $s .= ' ('.@constant('FPDF_PATH').')';
119  $i++;
120 }
121 if (class_exists('TCPDF'))
122 {
123  if ($i) $s .= ' + ';
124  $s .= 'TCPDF';
125  $s .= ' ('.@constant('TCPDF_PATH').')';
126  $i++;
127 }
128 if (class_exists('FPDI'))
129 {
130  if ($i) $s .= ' + ';
131  $s .= 'FPDI';
132  $s .= ' ('.@constant('FPDI_PATH').')';
133  $i++;
134 }
135 if (class_exists('TCPDI'))
136 {
137  if ($i) $s .= ' + ';
138  $s .= 'TCPDI';
139  $s .= ' ('.@constant('TCPDI_PATH').')';
140  $i++;
141 }
142 
143 print load_fiche_titre($langs->trans("PDF"), '', 'title_setup');
144 
145 print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("PDFDesc"), $s)."</span><br>\n";
146 print "<br>\n";
147 
148 $noCountryCode = (empty($mysoc->country_code) ? true : false);
149 
150 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
151 print '<input type="hidden" name="token" value="'.newToken().'">';
152 print '<input type="hidden" name="action" value="update">';
153 
154 clearstatcache();
155 
156 
157 // Misc options
158 print load_fiche_titre($langs->trans("DictionaryPaperFormat"), '', '');
159 
160 print '<div class="div-table-responsive-no-min">';
161 print '<table summary="more" class="noborder centpercent">';
162 print '<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;
165 if (empty($selected)) $selected = dol_getDefaultFormat();
166 
167 // Show pdf format
168 
169 print '<tr class="oddeven"><td>'.$langs->trans("DictionaryPaperFormat").'</td><td>';
170 print $formadmin->select_paper_format($selected, 'MAIN_PDF_FORMAT');
171 print '</td></tr>';
172 
173 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_LEFT").'</td><td>';
174 print '<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).'">';
175 print '</td></tr>';
176 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_RIGHT").'</td><td>';
177 print '<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).'">';
178 print '</td></tr>';
179 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_TOP").'</td><td>';
180 print '<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).'">';
181 print '</td></tr>';
182 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_MARGIN_BOTTOM").'</td><td>';
183 print '<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).'">';
184 print '</td></tr>';
185 
186 print '</table>';
187 print '</div>';
188 
189 print '<br>';
190 
191 
192 // Addresses
193 print load_fiche_titre($langs->trans("PDFAddressForging"), '', '');
194 
195 print '<div class="div-table-responsive-no-min">';
196 print '<table summary="more" class="noborder centpercent">';
197 print '<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 
201 print '<tr class="oddeven"><td>'.$langs->trans("ShowVATIntaInAddress").'</td><td>';
202 print $form->selectyesno('MAIN_TVAINTRA_NOT_IN_ADDRESS', (!empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) ? $conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS : 0, 1);
203 print '</td></tr>';
204 
205 // Show prof id in address into pdf
206 for ($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 
224 print '</table>';
225 print '</div>';
226 
227 
228 print '<br>';
229 
230 
231 // Localtaxes
232 $locales = '';
233 $text = '';
234 if ($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");
255 if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2))
256 {
257  $title .= ' - '.$langs->trans("PDFLocaltax", $locales);
258 }
259 
260 print load_fiche_titre($title, '', '');
261 
262 print '<table summary="more" class="noborder centpercent">';
263 print '<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 
267 print '<tr class="oddeven"><td>'.$langs->trans("HideAnyVATInformationOnPDF").'</td><td>';
268 print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT : 0, 1);
269 print '</td></tr>';
270 
271 // Locataxes
272 print $text;
273 
274 print '</table>';
275 print '<br>';
276 
277 
278 // Other
279 print load_fiche_titre($langs->trans("Other"), '', '');
280 
281 print '<div class="div-table-responsive-no-min">';
282 print '<table summary="more" class="noborder centpercent">';
283 print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
284 
285 // Height of logo
286 
287 print '<tr class="oddeven"><td>'.$langs->trans("MAIN_DOCUMENTS_LOGO_HEIGHT").'</td><td>';
288 print '<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).'">';
289 print '</td></tr>';
290 
291 //Desc
292 
293 print '<tr class="oddeven"><td>'.$langs->trans("HideDescOnPDF").'</td><td>';
294 print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DESC', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC : 0, 1);
295 print '</td></tr>';
296 
297 //Ref
298 
299 print '<tr class="oddeven"><td>'.$langs->trans("HideRefOnPDF").'</td><td>';
300 print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_REF', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF : 0, 1);
301 print '</td></tr>';
302 
303 //Details
304 
305 print '<tr class="oddeven"><td>'.$langs->trans("HideDetailsOnPDF").'</td><td>';
306 print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS : 0, 1);
307 print '</td></tr>';
308 
309 //Invert sender and recipient
310 
311 print '<tr class="oddeven"><td>'.$langs->trans("SwapSenderAndRecipientOnPDF").'</td><td>';
312 print $form->selectyesno('MAIN_INVERT_SENDER_RECIPIENT', (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) ? $conf->global->MAIN_INVERT_SENDER_RECIPIENT : 0, 1);
313 print '</td></tr>';
314 
315 // Place customer adress to the ISO location
316 
317 print '<tr class="oddeven"><td>'.$langs->trans("PlaceCustomerAddressToIsoLocation").'</td><td>';
318 print $form->selectyesno('MAIN_PDF_USE_ISO_LOCATION', (!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION)) ? $conf->global->MAIN_PDF_USE_ISO_LOCATION : 0, 1);
319 print '</td></tr>';
320 
321 
322 print '<tr class="oddeven"><td>'.$langs->trans("ShowDetailsInPDFPageFoot").'</td><td>';
323 print $form->selectarray('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', $arraydetailsforpdffoot, $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS);
324 print '</td></tr>';
325 
326 print '<tr class="oddeven"><td>'.$langs->trans("PDF_USE_ALSO_LANGUAGE_CODE").'</td><td>';
327 //if (! empty($conf->global->MAIN_MULTILANGS))
328 //{
329 print $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 //}
333 print '</td></tr>';
334 
335 // SHOW_SUBPRODUCT_REF_IN_PDF - Option to show the detail of product ref for kits.
336 print '<tr class="oddeven"><td>'.$langs->trans("SHOW_SUBPRODUCT_REF_IN_PDF", $langs->transnoentitiesnoconv("AssociatedProductsAbility"), $langs->transnoentitiesnoconv("Products")).'</td><td>';
337 print $form->selectyesno('SHOW_SUBPRODUCT_REF_IN_PDF', (!empty($conf->global->SHOW_SUBPRODUCT_REF_IN_PDF)) ? $conf->global->SHOW_SUBPRODUCT_REF_IN_PDF : 0, 1);
338 print '</td></tr>';
339 
340 print '</table>';
341 print '</div>';
342 
343 print '<br><div class="center">';
344 print '<input class="button button-save" type="submit" name="save" value="'.$langs->trans("Save").'">';
345 print '</div>';
346 
347 print '</form>';
348 
349 
350 // End of page
351 llxFooter();
352 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dolibarr_set_const($db, $name, $value, $type= 'chaine', $visible=0, $note= '', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:575
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
Class to generate html code for admin pages.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $wikihelp
View.
Definition: agenda.php:120
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
Classe permettant la generation de composants html autre Only common components are here...
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_getDefaultFormat(Translate $outputlangs=null)
Try to guess default paper format according to language into $langs.
print $_SERVER["PHP_SELF"]
Edit parameters.
pdf_getInstance($format= '', $metric= 'mm', $pagetype= 'P')
Return a PDF instance object.
Definition: pdf.lib.php:88
print
Draft customers invoices.
Definition: index.php:89
llxFooter()
Empty footer.
Definition: wrapper.php:59