PageRenderTime 49ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/admin/pdf.php

https://github.com/asterix14/dolibarr
PHP | 269 lines | 168 code | 57 blank | 44 comment | 26 complexity | 1deae443d840e72d3e3c736981095502 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/admin/pdf.php
  21. * \brief Page to setup PDF options
  22. */
  23. require("../main.inc.php");
  24. require_once(DOL_DOCUMENT_ROOT."/core/lib/usergroups.lib.php");
  25. require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
  26. require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
  27. require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
  28. require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php");
  29. $langs->load("admin");
  30. $langs->load("languages");
  31. $langs->load("other");
  32. $langs->load("companies");
  33. $langs->load("products");
  34. $langs->load("members");
  35. if (!$user->admin)
  36. accessforbidden();
  37. /*
  38. * Actions
  39. */
  40. if (isset($_POST["action"]) && $_POST["action"] == 'update')
  41. {
  42. dolibarr_set_const($db, "MAIN_PDF_FORMAT", $_POST["MAIN_PDF_FORMAT"],'chaine',0,'',$conf->entity);
  43. dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", $_POST["MAIN_PROFID1_IN_ADDRESS"],'chaine',0,'',$conf->entity);
  44. dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", $_POST["MAIN_PROFID2_IN_ADDRESS"],'chaine',0,'',$conf->entity);
  45. dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS", $_POST["MAIN_PROFID3_IN_ADDRESS"],'chaine',0,'',$conf->entity);
  46. dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", $_POST["MAIN_PROFID4_IN_ADDRESS"],'chaine',0,'',$conf->entity);
  47. dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", $_POST["MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"],'chaine',0,'',$conf->entity);
  48. Header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
  49. exit;
  50. }
  51. /*
  52. * View
  53. */
  54. $wikihelp='EN:First_setup|FR:Premiers_param&eacute;trages|ES:Primeras_configuraciones';
  55. llxHeader('',$langs->trans("Setup"),$wikihelp);
  56. $form=new Form($db);
  57. $formother=new FormOther($db);
  58. $formadmin=new FormAdmin($db);
  59. print_fiche_titre($langs->trans("PDF"),'','setup');
  60. print $langs->trans("PDFDesc")."<br>\n";
  61. print "<br>\n";
  62. if (isset($_GET["action"]) && $_GET["action"] == 'edit') // Edit
  63. {
  64. print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
  65. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  66. print '<input type="hidden" name="action" value="update">';
  67. clearstatcache();
  68. // Misc options
  69. print_fiche_titre($langs->trans("DictionnaryPaperFormat"),'','').'<br>';
  70. $var=true;
  71. print '<table summary="more" class="noborder" width="100%">';
  72. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
  73. $selected=$conf->global->MAIN_PDF_FORMAT;
  74. if (empty($selected)) $selected=dol_getDefaultFormat();
  75. // Show pdf format
  76. $var=!$var;
  77. print '<tr '.$bc[$var].'><td>'.$langs->trans("DictionnaryPaperFormat").'</td><td>';
  78. print $formadmin->select_paper_format($selected,'MAIN_PDF_FORMAT');
  79. print '</td></tr>';
  80. print '</table>';
  81. print '<br>';
  82. // Addresses
  83. print_fiche_titre($langs->trans("PDFAddressForging"),'','').'<br>';
  84. $var=true;
  85. print '<table summary="more" class="noborder" width="100%">';
  86. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
  87. // Show prof id 1 in address into pdf
  88. $var=!$var;
  89. $pid1=$langs->transcountry("ProfId1",$mysoc->pays_code);
  90. if ($pid1 == '-') $pid1=$langs->transcountry("ProfId1");
  91. print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid1.'</td><td>';
  92. print $form->selectyesno('MAIN_PROFID1_IN_ADDRESS',isset($conf->global->MAIN_PROFID1_IN_ADDRESS)?$conf->global->MAIN_PROFID1_IN_ADDRESS:0,1);
  93. print '</td></tr>';
  94. // Show prof id 2 in address into pdf
  95. $var=!$var;
  96. $pid2=$langs->transcountry("ProfId2",$mysoc->pays_code);
  97. if ($pid2 == '-') $pid2=$langs->transcountry("ProfId2");
  98. print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid2.'</td><td>';
  99. print $form->selectyesno('MAIN_PROFID2_IN_ADDRESS',isset($conf->global->MAIN_PROFID2_IN_ADDRESS)?$conf->global->MAIN_PROFID2_IN_ADDRESS:0,1);
  100. print '</td></tr>';
  101. // Show prof id 3 in address into pdf
  102. $var=!$var;
  103. $pid3=$langs->transcountry("ProfId3",$mysoc->pays_code);
  104. if ($pid3 == '-') $pid3=$langs->transcountry("ProfId3");
  105. print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid3.'</td><td>';
  106. print $form->selectyesno('MAIN_PROFID3_IN_ADDRESS',isset($conf->global->MAIN_PROFID3_IN_ADDRESS)?$conf->global->MAIN_PROFID3_IN_ADDRESS:0,1);
  107. print '</td></tr>';
  108. // Show prof id 4 in address into pdf
  109. $var=!$var;
  110. $pid4=$langs->transcountry("ProfId4",$mysoc->pays_code);
  111. if ($pid4 == '-') $pid4=$langs->transcountry("ProfId4");
  112. print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid4.'</td><td>';
  113. print $form->selectyesno('MAIN_PROFID4_IN_ADDRESS',isset($conf->global->MAIN_PROFID4_IN_ADDRESS)?$conf->global->MAIN_PROFID4_IN_ADDRESS:0,1);
  114. print '</td></tr>';
  115. print '</table>';
  116. print '<br>';
  117. // Other
  118. print_fiche_titre($langs->trans("Other"),'','').'<br>';
  119. $var=true;
  120. print '<table summary="more" class="noborder" width="100%">';
  121. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
  122. // Hide any PDF informations
  123. $var=!$var;
  124. print '<tr '.$bc[$var].'><td>'.$langs->trans("HideAnyVATInformationOnPDF").'</td><td>';
  125. 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);
  126. print '</td></tr>';
  127. print '</table>';
  128. print '<br><center>';
  129. print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
  130. print '</center>';
  131. print '</form>';
  132. print '<br>';
  133. }
  134. else // Show
  135. {
  136. $var=true;
  137. // Misc options
  138. print_fiche_titre($langs->trans("DictionnaryPaperFormat"),'','').'<br>';
  139. $var=true;
  140. print '<table summary="more" class="noborder" width="100%">';
  141. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
  142. // Show pdf format
  143. $var=!$var;
  144. print '<tr '.$bc[$var].'><td>'.$langs->trans("DictionnaryPaperFormat").'</td><td>';
  145. $pdfformatlabel=$conf->global->MAIN_PDF_FORMAT;
  146. if (! empty($conf->global->MAIN_PDF_FORMAT))
  147. {
  148. $sql="SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format";
  149. $sql.=" WHERE code LIKE '%".$conf->global->MAIN_PDF_FORMAT."%'";
  150. $resql=$db->query($sql);
  151. if ($resql)
  152. {
  153. $obj=$db->fetch_object($resql);
  154. $pdfformatlabel=$obj->label.' - '.round($obj->width).'x'.round($obj->height).' '.$obj->unit;
  155. }
  156. }
  157. print $pdfformatlabel;
  158. print '</td></tr>';
  159. print '</table>';
  160. print '<br>';
  161. print_fiche_titre($langs->trans("PDFAddressForging"),'','').'<br>';
  162. print '<table class="noborder" width="100%">';
  163. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
  164. // Show prof id 1 in address into pdf
  165. $var=!$var;
  166. $pid1=$langs->transcountry("ProfId1",$mysoc->pays_code);
  167. if ($pid1 == '-') $pid1=$langs->transcountry("ProfId1");
  168. print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid1.'</td><td>';
  169. print yn($conf->global->MAIN_PROFID1_IN_ADDRESS,1);
  170. print '</td></tr>';
  171. // Show prof id 2 in address into pdf
  172. $var=!$var;
  173. $pid2=$langs->transcountry("ProfId2",$mysoc->pays_code);
  174. if ($pid2 == '-') $pid2=$langs->transcountry("ProfId2");
  175. print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid2.'</td><td>';
  176. print yn($conf->global->MAIN_PROFID2_IN_ADDRESS,1);
  177. print '</td></tr>';
  178. // Show prof id 3 in address into pdf
  179. $var=!$var;
  180. $pid3=$langs->transcountry("ProfId3",$mysoc->pays_code);
  181. if ($pid3 == '-') $pid3=$langs->transcountry("ProfId3");
  182. print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid3.'</td><td>';
  183. print yn($conf->global->MAIN_PROFID3_IN_ADDRESS,1);
  184. print '</td></tr>';
  185. // Show prof id 4 in address into pdf
  186. $var=!$var;
  187. $pid4=$langs->transcountry("ProfId4",$mysoc->pays_code);
  188. if ($pid4 == '-') $pid4=$langs->transcountry("ProfId4");
  189. print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid4.'</td><td>';
  190. print yn($conf->global->MAIN_PROFID4_IN_ADDRESS,1);
  191. print '</td></tr>';
  192. print '</table>'."\n";
  193. print '<br>';
  194. // Other
  195. print_fiche_titre($langs->trans("Other"),'','').'<br>';
  196. $var=true;
  197. print '<table summary="more" class="noborder" width="100%">';
  198. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
  199. // Hide any PDF informations
  200. $var=!$var;
  201. print '<tr '.$bc[$var].'><td>'.$langs->trans("HideAnyVATInformationOnPDF").'</td><td>';
  202. print yn($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT,1);
  203. print '</td></tr>';
  204. print '</table>';
  205. print '<div class="tabsAction">';
  206. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
  207. print '</div>';
  208. print '<br>';
  209. }
  210. $db->close();
  211. llxFooter();
  212. ?>