PageRenderTime 166ms CodeModel.GetById 61ms app.highlight 43ms RepoModel.GetById 57ms app.codeStats 1ms

/htdocs/admin/pdf.php

https://bitbucket.org/speedealing/speedealing
PHP | 410 lines | 293 code | 66 blank | 51 comment | 47 complexity | 5fdbeab7f1569ccf895cb6e2ee5a1a01 MD5 | raw 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@capnetworks.com>
  5 * Copyright (C) 2012	   Juanjo Menent		<jmenent@2byte.es>
  6 *
  7 * This program is free software; you can redistribute it and/or modify
  8 * it under the terms of the GNU General Public License as published by
  9 * the Free Software Foundation; either version 3 of the License, or
 10 * (at your option) any later version.
 11 *
 12 * This program is distributed in the hope that it will be useful,
 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15 * GNU General Public License for more details.
 16 *
 17 * You should have received a copy of the GNU General Public License
 18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 19 */
 20
 21/**
 22 *       \file       htdocs/admin/pdf.php
 23 *       \brief      Page to setup PDF options
 24 */
 25
 26require '../main.inc.php';
 27require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
 28require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 29require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
 30require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
 31require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
 32
 33$langs->load("admin");
 34$langs->load("languages");
 35$langs->load("other");
 36
 37$langs->load("companies");
 38$langs->load("products");
 39$langs->load("members");
 40
 41if (! $user->admin) accessforbidden();
 42
 43$action = GETPOST('action','alpha');
 44
 45/*
 46 * Actions
 47 */
 48
 49if ($action == 'update')
 50{
 51	dolibarr_set_const($db, "MAIN_PDF_FORMAT",    $_POST["MAIN_PDF_FORMAT"],'chaine',0,'',$conf->entity);
 52
 53	dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS",    $_POST["MAIN_PROFID1_IN_ADDRESS"],'chaine',0,'',$conf->entity);
 54    dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS",    $_POST["MAIN_PROFID2_IN_ADDRESS"],'chaine',0,'',$conf->entity);
 55	dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS",    $_POST["MAIN_PROFID3_IN_ADDRESS"],'chaine',0,'',$conf->entity);
 56	dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS",    $_POST["MAIN_PROFID4_IN_ADDRESS"],'chaine',0,'',$conf->entity);
 57	dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT",    $_POST["MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"],'chaine',0,'',$conf->entity);
 58	
 59	if ($conf->global->MAIN_FEATURES_LEVEL > 1)
 60	{
 61		dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"],'chaine',0,'',$conf->entity);
 62		dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC",    $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DESC"],'chaine',0,'',$conf->entity);
 63		dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF",     $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_REF"],'chaine',0,'',$conf->entity);
 64	}
 65	
 66	header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
 67	exit;
 68}
 69
 70
 71/*
 72 * View
 73 */
 74
 75$wikihelp='EN:First_setup|FR:Premiers_param&eacute;trages|ES:Primeras_configuraciones';
 76llxHeader('',$langs->trans("Setup"),$wikihelp);
 77
 78$form=new Form($db);
 79$formother=new FormOther($db);
 80$formadmin=new FormAdmin($db);
 81
 82print_fiche_titre($langs->trans("PDF"),'','setup');
 83
 84print $langs->trans("PDFDesc")."<br>\n";
 85print "<br>\n";
 86
 87$noCountryCode = (empty($mysoc->country_code) ? true : false);
 88
 89if ($action == 'edit')	// Edit
 90{
 91    print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
 92    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 93    print '<input type="hidden" name="action" value="update">';
 94
 95    clearstatcache();
 96
 97
 98    // Misc options
 99    print_fiche_titre($langs->trans("DictionnaryPaperFormat"),'','').'<br>';
100	$var=true;
101    print '<table summary="more" class="noborder" width="100%">';
102    print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
103
104    $selected=$conf->global->MAIN_PDF_FORMAT;
105    if (empty($selected)) $selected=dol_getDefaultFormat();
106
107    // Show pdf format
108    $var=!$var;
109    print '<tr '.$bc[$var].'><td>'.$langs->trans("DictionnaryPaperFormat").'</td><td>';
110    print $formadmin->select_paper_format($selected,'MAIN_PDF_FORMAT');
111    print '</td></tr>';
112
113	print '</table>';
114
115	print '<br>';
116
117
118    // Addresses
119    print_fiche_titre($langs->trans("PDFAddressForging"),'','').'<br>';
120	$var=true;
121    print '<table summary="more" class="noborder" width="100%">';
122    print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
123
124    // Show prof id 1 in address into pdf
125    $var=!$var;
126    if (! $noCountryCode)
127    {
128    	$pid1=$langs->transcountry("ProfId1",$mysoc->country_code);
129    	if ($pid1 == '-') $pid1=false;
130    }
131    else
132    {
133    	$pid1 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
134    }
135    if ($pid1)
136    {
137    	print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid1.'</td><td>';
138    	print $form->selectyesno('MAIN_PROFID1_IN_ADDRESS',isset($conf->global->MAIN_PROFID1_IN_ADDRESS)?$conf->global->MAIN_PROFID1_IN_ADDRESS:0,1,$noCountryCode);
139    	print '</td></tr>';
140    }
141
142    // Show prof id 2 in address into pdf
143    $var=!$var;
144    if (! $noCountryCode)
145    {
146    	$pid2=$langs->transcountry("ProfId2",$mysoc->country_code);
147    	if ($pid2 == '-') $pid2=false;
148    }
149    else
150    {
151    	$pid2 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
152    }
153    if ($pid2)
154    {
155    	print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid2.'</td><td>';
156    	print $form->selectyesno('MAIN_PROFID2_IN_ADDRESS',isset($conf->global->MAIN_PROFID2_IN_ADDRESS)?$conf->global->MAIN_PROFID2_IN_ADDRESS:0,1,$noCountryCode);
157    	print '</td></tr>';
158    }
159
160    // Show prof id 3 in address into pdf
161    $var=!$var;
162    if (! $noCountryCode)
163    {
164    	$pid3=$langs->transcountry("ProfId3",$mysoc->country_code);
165    	if ($pid3 == '-') $pid3=false;
166    }
167    else
168    {
169    	$pid3 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
170    }
171    if ($pid3)
172    {
173    	print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid3.'</td><td>';
174    	print $form->selectyesno('MAIN_PROFID3_IN_ADDRESS',isset($conf->global->MAIN_PROFID3_IN_ADDRESS)?$conf->global->MAIN_PROFID3_IN_ADDRESS:0,1,$noCountryCode);
175    	print '</td></tr>';
176    }
177
178    // Show prof id 4 in address into pdf
179    $var=!$var;
180    if (! $noCountryCode)
181    {
182    	$pid4=$langs->transcountry("ProfId4",$mysoc->country_code);
183    	if ($pid4 == '-') $pid4=false;
184    }
185    else
186    {
187    	$pid4 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
188    }
189    if ($pid4)
190    {
191    	print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid4.'</td><td>';
192    	print $form->selectyesno('MAIN_PROFID4_IN_ADDRESS',isset($conf->global->MAIN_PROFID4_IN_ADDRESS)?$conf->global->MAIN_PROFID4_IN_ADDRESS:0,1,$noCountryCode);
193    	print '</td></tr>';
194    }
195
196	print '</table>';
197
198    print '<br>';
199
200    // Other
201    print_fiche_titre($langs->trans("Other"),'','').'<br>';
202	$var=true;
203    print '<table summary="more" class="noborder" width="100%">';
204    print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
205
206    // Hide any PDF informations
207    $var=!$var;
208    print '<tr '.$bc[$var].'><td>'.$langs->trans("HideAnyVATInformationOnPDF").'</td><td>';
209	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);
210    print '</td></tr>';
211    
212    if ($conf->global->MAIN_FEATURES_LEVEL > 1)
213    {
214    	//Desc
215    	$var=!$var;
216    	print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDescOnPDF").'</td><td>';
217    	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);
218    	print '</td></tr>';
219    	
220    	//Ref
221    	$var=!$var;
222    	print '<tr '.$bc[$var].'><td>'.$langs->trans("HideRefOnPDF").'</td><td>';
223    	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);
224    	print '</td></tr>';
225    	
226    	//Details
227    	$var=!$var;
228    	print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDetailsOnPDF").'</td><td>';
229    	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);
230    	print '</td></tr>';
231    }
232
233	print '</table>';
234
235    print '<br><center>';
236    print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
237    print '</center>';
238
239    print '</form>';
240    print '<br>';
241}
242else	// Show
243{
244    $var=true;
245
246    // Misc options
247    print_fiche_titre($langs->trans("DictionnaryPaperFormat"),'','').'<br>';
248	$var=true;
249    print '<table summary="more" class="noborder" width="100%">';
250    print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
251
252    // Show pdf format
253    $var=!$var;
254    print '<tr '.$bc[$var].'><td>'.$langs->trans("DictionnaryPaperFormat").'</td><td>';
255
256    $pdfformatlabel='';
257    if (empty($conf->global->MAIN_PDF_FORMAT))
258    {
259        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
260        $pdfformatlabel=dol_getDefaultFormat();
261    }
262    else $pdfformatlabel=$conf->global->MAIN_PDF_FORMAT;
263    if (! empty($pdfformatlabel))
264    {
265    	$sql="SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format";
266        $sql.=" WHERE code LIKE '%".$db->escape($pdfformatlabel)."%'";
267
268        $resql=$db->query($sql);
269        if ($resql)
270        {
271            $obj=$db->fetch_object($resql);
272            $paperKey = $langs->trans('PaperFormat'.$obj->code);
273            $unitKey = $langs->trans('SizeUnit'.$obj->unit);
274            $pdfformatlabel = ($paperKey == 'PaperFormat'.$obj->code ? $obj->label : $paperKey).' - '.round($obj->width).'x'.round($obj->height).' '.($unitKey == 'SizeUnit'.$obj->unit ? $obj->unit : $unitKey);
275        }
276    }
277    print $pdfformatlabel;
278    print '</td></tr>';
279
280	print '</table>';
281
282	print '<br>';
283
284	print_fiche_titre($langs->trans("PDFAddressForging"),'','').'<br>';
285    print '<table class="noborder" width="100%">';
286    print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
287
288    // Show prof id 1 in address into pdf
289    $var=!$var;
290    if (! $noCountryCode)
291    {
292    	$pid1=$langs->transcountry("ProfId1",$mysoc->country_code);
293    	if ($pid1 == '-') $pid1=false;
294    }
295    else
296    {
297    	$pid1 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
298    }
299    if ($pid1)
300    {
301    	print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid1.'</td><td>';
302    	print yn($conf->global->MAIN_PROFID1_IN_ADDRESS,1);
303    	print '</td></tr>';
304    }
305
306    // Show prof id 2 in address into pdf
307    $var=!$var;
308    if (! $noCountryCode)
309    {
310    	$pid2=$langs->transcountry("ProfId2",$mysoc->country_code);
311    	if ($pid2 == '-') $pid2=false;
312    }
313    else
314    {
315    	$pid2 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
316    }
317    if ($pid2)
318    {
319    	print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid2.'</td><td>';
320    	print yn($conf->global->MAIN_PROFID2_IN_ADDRESS,1);
321    	print '</td></tr>';
322    }
323
324    // Show prof id 3 in address into pdf
325    $var=!$var;
326    if (! $noCountryCode)
327    {
328    	$pid3=$langs->transcountry("ProfId3",$mysoc->country_code);
329    	if ($pid3 == '-') $pid3=false;
330    }
331    else
332    {
333    	$pid3 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
334    }
335    if ($pid3)
336    {
337    	print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid3.'</td><td>';
338    	print yn($conf->global->MAIN_PROFID3_IN_ADDRESS,1);
339    	print '</td></tr>';
340    }
341
342    // Show prof id 4 in address into pdf
343    $var=!$var;
344    if (! $noCountryCode)
345    {
346    	$pid4=$langs->transcountry("ProfId4",$mysoc->country_code);
347    	if ($pid4 == '-') $pid4=false;
348    }
349    else
350    {
351    	$pid4 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
352    }
353    if ($pid4)
354    {
355    	print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid4.'</td><td>';
356    	print yn($conf->global->MAIN_PROFID4_IN_ADDRESS,1);
357    	print '</td></tr>';
358    }
359
360    print '</table>'."\n";
361
362    print '<br>';
363
364    // Other
365    print_fiche_titre($langs->trans("Other"),'','').'<br>';
366	$var=true;
367    print '<table summary="more" class="noborder" width="100%">';
368    print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
369
370    // Hide any PDF informations
371    $var=!$var;
372    print '<tr '.$bc[$var].'><td>'.$langs->trans("HideAnyVATInformationOnPDF").'</td><td>';
373    print yn($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT,1);
374    print '</td></tr>';
375       
376    if ($conf->global->MAIN_FEATURES_LEVEL > 1)
377    {
378    	//Desc
379    	$var=!$var;
380    	print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDescOnPDF").'</td><td>';
381    	print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC,1);
382    	print '</td></tr>';
383    	 
384    	//Ref
385    	$var=!$var;
386    	print '<tr '.$bc[$var].'><td>'.$langs->trans("HideRefOnPDF").'</td><td>';
387    	print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF,1);
388    	print '</td></tr>';
389    	 
390    	//Details
391    	$var=!$var;
392    	print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDetailsOnPDF").'</td><td>';
393    	print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS,1);
394    	print '</td></tr>';
395    }
396
397	print '</table>';
398
399
400    print '<div class="tabsAction">';
401    print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
402    print '</div>';
403	print '<br>';
404}
405
406
407$db->close();
408
409llxFooter();
410?>