PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/admin/pdf.php

https://bitbucket.org/speedealing/speedealing
PHP | 410 lines | 293 code | 66 blank | 51 comment | 47 complexity | 5fdbeab7f1569ccf895cb6e2ee5a1a01 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  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. * \file htdocs/admin/pdf.php
  22. * \brief Page to setup PDF options
  23. */
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.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. $langs->load("admin");
  31. $langs->load("languages");
  32. $langs->load("other");
  33. $langs->load("companies");
  34. $langs->load("products");
  35. $langs->load("members");
  36. if (! $user->admin) accessforbidden();
  37. $action = GETPOST('action','alpha');
  38. /*
  39. * Actions
  40. */
  41. if ($action == 'update')
  42. {
  43. dolibarr_set_const($db, "MAIN_PDF_FORMAT", $_POST["MAIN_PDF_FORMAT"],'chaine',0,'',$conf->entity);
  44. dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", $_POST["MAIN_PROFID1_IN_ADDRESS"],'chaine',0,'',$conf->entity);
  45. dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", $_POST["MAIN_PROFID2_IN_ADDRESS"],'chaine',0,'',$conf->entity);
  46. dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS", $_POST["MAIN_PROFID3_IN_ADDRESS"],'chaine',0,'',$conf->entity);
  47. dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", $_POST["MAIN_PROFID4_IN_ADDRESS"],'chaine',0,'',$conf->entity);
  48. dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", $_POST["MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"],'chaine',0,'',$conf->entity);
  49. if ($conf->global->MAIN_FEATURES_LEVEL > 1)
  50. {
  51. dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"],'chaine',0,'',$conf->entity);
  52. dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DESC"],'chaine',0,'',$conf->entity);
  53. dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_REF"],'chaine',0,'',$conf->entity);
  54. }
  55. header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
  56. exit;
  57. }
  58. /*
  59. * View
  60. */
  61. $wikihelp='EN:First_setup|FR:Premiers_param&eacute;trages|ES:Primeras_configuraciones';
  62. llxHeader('',$langs->trans("Setup"),$wikihelp);
  63. $form=new Form($db);
  64. $formother=new FormOther($db);
  65. $formadmin=new FormAdmin($db);
  66. print_fiche_titre($langs->trans("PDF"),'','setup');
  67. print $langs->trans("PDFDesc")."<br>\n";
  68. print "<br>\n";
  69. $noCountryCode = (empty($mysoc->country_code) ? true : false);
  70. if ($action == 'edit') // Edit
  71. {
  72. print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
  73. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  74. print '<input type="hidden" name="action" value="update">';
  75. clearstatcache();
  76. // Misc options
  77. print_fiche_titre($langs->trans("DictionnaryPaperFormat"),'','').'<br>';
  78. $var=true;
  79. print '<table summary="more" class="noborder" width="100%">';
  80. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
  81. $selected=$conf->global->MAIN_PDF_FORMAT;
  82. if (empty($selected)) $selected=dol_getDefaultFormat();
  83. // Show pdf format
  84. $var=!$var;
  85. print '<tr '.$bc[$var].'><td>'.$langs->trans("DictionnaryPaperFormat").'</td><td>';
  86. print $formadmin->select_paper_format($selected,'MAIN_PDF_FORMAT');
  87. print '</td></tr>';
  88. print '</table>';
  89. print '<br>';
  90. // Addresses
  91. print_fiche_titre($langs->trans("PDFAddressForging"),'','').'<br>';
  92. $var=true;
  93. print '<table summary="more" class="noborder" width="100%">';
  94. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
  95. // Show prof id 1 in address into pdf
  96. $var=!$var;
  97. if (! $noCountryCode)
  98. {
  99. $pid1=$langs->transcountry("ProfId1",$mysoc->country_code);
  100. if ($pid1 == '-') $pid1=false;
  101. }
  102. else
  103. {
  104. $pid1 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
  105. }
  106. if ($pid1)
  107. {
  108. print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid1.'</td><td>';
  109. print $form->selectyesno('MAIN_PROFID1_IN_ADDRESS',isset($conf->global->MAIN_PROFID1_IN_ADDRESS)?$conf->global->MAIN_PROFID1_IN_ADDRESS:0,1,$noCountryCode);
  110. print '</td></tr>';
  111. }
  112. // Show prof id 2 in address into pdf
  113. $var=!$var;
  114. if (! $noCountryCode)
  115. {
  116. $pid2=$langs->transcountry("ProfId2",$mysoc->country_code);
  117. if ($pid2 == '-') $pid2=false;
  118. }
  119. else
  120. {
  121. $pid2 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
  122. }
  123. if ($pid2)
  124. {
  125. print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid2.'</td><td>';
  126. print $form->selectyesno('MAIN_PROFID2_IN_ADDRESS',isset($conf->global->MAIN_PROFID2_IN_ADDRESS)?$conf->global->MAIN_PROFID2_IN_ADDRESS:0,1,$noCountryCode);
  127. print '</td></tr>';
  128. }
  129. // Show prof id 3 in address into pdf
  130. $var=!$var;
  131. if (! $noCountryCode)
  132. {
  133. $pid3=$langs->transcountry("ProfId3",$mysoc->country_code);
  134. if ($pid3 == '-') $pid3=false;
  135. }
  136. else
  137. {
  138. $pid3 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
  139. }
  140. if ($pid3)
  141. {
  142. print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid3.'</td><td>';
  143. print $form->selectyesno('MAIN_PROFID3_IN_ADDRESS',isset($conf->global->MAIN_PROFID3_IN_ADDRESS)?$conf->global->MAIN_PROFID3_IN_ADDRESS:0,1,$noCountryCode);
  144. print '</td></tr>';
  145. }
  146. // Show prof id 4 in address into pdf
  147. $var=!$var;
  148. if (! $noCountryCode)
  149. {
  150. $pid4=$langs->transcountry("ProfId4",$mysoc->country_code);
  151. if ($pid4 == '-') $pid4=false;
  152. }
  153. else
  154. {
  155. $pid4 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
  156. }
  157. if ($pid4)
  158. {
  159. print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid4.'</td><td>';
  160. print $form->selectyesno('MAIN_PROFID4_IN_ADDRESS',isset($conf->global->MAIN_PROFID4_IN_ADDRESS)?$conf->global->MAIN_PROFID4_IN_ADDRESS:0,1,$noCountryCode);
  161. print '</td></tr>';
  162. }
  163. print '</table>';
  164. print '<br>';
  165. // Other
  166. print_fiche_titre($langs->trans("Other"),'','').'<br>';
  167. $var=true;
  168. print '<table summary="more" class="noborder" width="100%">';
  169. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
  170. // Hide any PDF informations
  171. $var=!$var;
  172. print '<tr '.$bc[$var].'><td>'.$langs->trans("HideAnyVATInformationOnPDF").'</td><td>';
  173. 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);
  174. print '</td></tr>';
  175. if ($conf->global->MAIN_FEATURES_LEVEL > 1)
  176. {
  177. //Desc
  178. $var=!$var;
  179. print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDescOnPDF").'</td><td>';
  180. 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);
  181. print '</td></tr>';
  182. //Ref
  183. $var=!$var;
  184. print '<tr '.$bc[$var].'><td>'.$langs->trans("HideRefOnPDF").'</td><td>';
  185. 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);
  186. print '</td></tr>';
  187. //Details
  188. $var=!$var;
  189. print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDetailsOnPDF").'</td><td>';
  190. 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);
  191. print '</td></tr>';
  192. }
  193. print '</table>';
  194. print '<br><center>';
  195. print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
  196. print '</center>';
  197. print '</form>';
  198. print '<br>';
  199. }
  200. else // Show
  201. {
  202. $var=true;
  203. // Misc options
  204. print_fiche_titre($langs->trans("DictionnaryPaperFormat"),'','').'<br>';
  205. $var=true;
  206. print '<table summary="more" class="noborder" width="100%">';
  207. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
  208. // Show pdf format
  209. $var=!$var;
  210. print '<tr '.$bc[$var].'><td>'.$langs->trans("DictionnaryPaperFormat").'</td><td>';
  211. $pdfformatlabel='';
  212. if (empty($conf->global->MAIN_PDF_FORMAT))
  213. {
  214. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  215. $pdfformatlabel=dol_getDefaultFormat();
  216. }
  217. else $pdfformatlabel=$conf->global->MAIN_PDF_FORMAT;
  218. if (! empty($pdfformatlabel))
  219. {
  220. $sql="SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format";
  221. $sql.=" WHERE code LIKE '%".$db->escape($pdfformatlabel)."%'";
  222. $resql=$db->query($sql);
  223. if ($resql)
  224. {
  225. $obj=$db->fetch_object($resql);
  226. $paperKey = $langs->trans('PaperFormat'.$obj->code);
  227. $unitKey = $langs->trans('SizeUnit'.$obj->unit);
  228. $pdfformatlabel = ($paperKey == 'PaperFormat'.$obj->code ? $obj->label : $paperKey).' - '.round($obj->width).'x'.round($obj->height).' '.($unitKey == 'SizeUnit'.$obj->unit ? $obj->unit : $unitKey);
  229. }
  230. }
  231. print $pdfformatlabel;
  232. print '</td></tr>';
  233. print '</table>';
  234. print '<br>';
  235. print_fiche_titre($langs->trans("PDFAddressForging"),'','').'<br>';
  236. print '<table class="noborder" width="100%">';
  237. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
  238. // Show prof id 1 in address into pdf
  239. $var=!$var;
  240. if (! $noCountryCode)
  241. {
  242. $pid1=$langs->transcountry("ProfId1",$mysoc->country_code);
  243. if ($pid1 == '-') $pid1=false;
  244. }
  245. else
  246. {
  247. $pid1 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
  248. }
  249. if ($pid1)
  250. {
  251. print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid1.'</td><td>';
  252. print yn($conf->global->MAIN_PROFID1_IN_ADDRESS,1);
  253. print '</td></tr>';
  254. }
  255. // Show prof id 2 in address into pdf
  256. $var=!$var;
  257. if (! $noCountryCode)
  258. {
  259. $pid2=$langs->transcountry("ProfId2",$mysoc->country_code);
  260. if ($pid2 == '-') $pid2=false;
  261. }
  262. else
  263. {
  264. $pid2 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
  265. }
  266. if ($pid2)
  267. {
  268. print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid2.'</td><td>';
  269. print yn($conf->global->MAIN_PROFID2_IN_ADDRESS,1);
  270. print '</td></tr>';
  271. }
  272. // Show prof id 3 in address into pdf
  273. $var=!$var;
  274. if (! $noCountryCode)
  275. {
  276. $pid3=$langs->transcountry("ProfId3",$mysoc->country_code);
  277. if ($pid3 == '-') $pid3=false;
  278. }
  279. else
  280. {
  281. $pid3 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
  282. }
  283. if ($pid3)
  284. {
  285. print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid3.'</td><td>';
  286. print yn($conf->global->MAIN_PROFID3_IN_ADDRESS,1);
  287. print '</td></tr>';
  288. }
  289. // Show prof id 4 in address into pdf
  290. $var=!$var;
  291. if (! $noCountryCode)
  292. {
  293. $pid4=$langs->transcountry("ProfId4",$mysoc->country_code);
  294. if ($pid4 == '-') $pid4=false;
  295. }
  296. else
  297. {
  298. $pid4 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
  299. }
  300. if ($pid4)
  301. {
  302. print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid4.'</td><td>';
  303. print yn($conf->global->MAIN_PROFID4_IN_ADDRESS,1);
  304. print '</td></tr>';
  305. }
  306. print '</table>'."\n";
  307. print '<br>';
  308. // Other
  309. print_fiche_titre($langs->trans("Other"),'','').'<br>';
  310. $var=true;
  311. print '<table summary="more" class="noborder" width="100%">';
  312. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
  313. // Hide any PDF informations
  314. $var=!$var;
  315. print '<tr '.$bc[$var].'><td>'.$langs->trans("HideAnyVATInformationOnPDF").'</td><td>';
  316. print yn($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT,1);
  317. print '</td></tr>';
  318. if ($conf->global->MAIN_FEATURES_LEVEL > 1)
  319. {
  320. //Desc
  321. $var=!$var;
  322. print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDescOnPDF").'</td><td>';
  323. print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC,1);
  324. print '</td></tr>';
  325. //Ref
  326. $var=!$var;
  327. print '<tr '.$bc[$var].'><td>'.$langs->trans("HideRefOnPDF").'</td><td>';
  328. print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF,1);
  329. print '</td></tr>';
  330. //Details
  331. $var=!$var;
  332. print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDetailsOnPDF").'</td><td>';
  333. print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS,1);
  334. print '</td></tr>';
  335. }
  336. print '</table>';
  337. print '<div class="tabsAction">';
  338. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
  339. print '</div>';
  340. print '<br>';
  341. }
  342. $db->close();
  343. llxFooter();
  344. ?>