facture_situation.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <?php
  2. /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
  5. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  6. * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
  7. * Copyright (C) 2012-2013 Juanjo Menent <jmenent@2byte.es>
  8. * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  22. */
  23. /**
  24. * \file htdocs/admin/facture.php
  25. * \ingroup facture
  26. * \brief Page to setup invoice module
  27. */
  28. require '../main.inc.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  33. // Load translation files required by the page
  34. $langs->loadLangs(array('admin', 'errors', 'other', 'bills'));
  35. if (!$user->admin) accessforbidden();
  36. $action = GETPOST('action', 'alpha');
  37. $value = GETPOST('value', 'alpha');
  38. $label = GETPOST('label', 'alpha');
  39. $scandir = GETPOST('scan_dir', 'alpha');
  40. $type = 'invoice';
  41. /*
  42. * Actions
  43. */
  44. include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  45. /*
  46. * View
  47. */
  48. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  49. llxHeader(
  50. "", $langs->trans("BillsSetup"),
  51. 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura'
  52. );
  53. $form = new Form($db);
  54. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  55. print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup');
  56. $head = invoice_admin_prepare_head();
  57. dol_fiche_head($head, 'situation', $langs->trans("InvoiceSituation"), -1, 'invoice');
  58. print '<span class="opacitymedium">'.$langs->trans("InvoiceFirstSituationDesc").'</span><br><br>';
  59. /*
  60. * Numbering module
  61. */
  62. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
  63. print '<input type="hidden" name="token" value="'.newToken().'">';
  64. print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  65. print '<table class="noborder centpercent">';
  66. print '<tr class="liste_titre">';
  67. print '<td>'.$langs->trans("Parameter").'</td>';
  68. print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
  69. print '<td width="80">&nbsp;</td>';
  70. print "</tr>\n";
  71. _printOnOff('INVOICE_USE_SITUATION', $langs->trans('UseSituationInvoices'));
  72. _printOnOff('INVOICE_USE_SITUATION_CREDIT_NOTE', $langs->trans('UseSituationInvoicesCreditNote'));
  73. _printOnOff('INVOICE_USE_SITUATION_RETAINED_WARRANTY', $langs->trans('Retainedwarranty'));
  74. $metas = array(
  75. 'type' => 'number',
  76. 'step' => '0.01',
  77. 'min' => 0,
  78. 'max' => 100
  79. );
  80. _printInputFormPart('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT', $langs->trans('RetainedwarrantyDefaultPercent'), '', $metas);
  81. // Conditions paiements
  82. $inputCount = empty($inputCount) ? 1 : ($inputCount + 1);
  83. print '<tr class="oddeven">';
  84. print '<td>'.$langs->trans('PaymentConditionsShortRetainedWarranty').'</td>';
  85. print '<td class="center" width="20">&nbsp;</td>';
  86. print '<td class="right" width="300">';
  87. print '<input type="hidden" name="param'.$inputCount.'" value="INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID">';
  88. $form->select_conditions_paiements($conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID, 'value'.$inputCount, -1, 1);
  89. print '</td></tr>';
  90. print '</table>';
  91. print '</div>';
  92. print '<br>';
  93. _updateBtn();
  94. print '</form>';
  95. dol_fiche_end();
  96. // End of page
  97. llxFooter();
  98. $db->close();
  99. /**
  100. * Print an update button
  101. *
  102. * @return void
  103. */
  104. function _updateBtn()
  105. {
  106. global $langs;
  107. print '<div class="center">';
  108. print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
  109. print '</div>';
  110. }
  111. /**
  112. * Print a On/Off button
  113. *
  114. * @param string $confkey the conf key
  115. * @param bool $title Title of conf
  116. * @param string $desc Description
  117. *
  118. * @return void
  119. */
  120. function _printOnOff($confkey, $title = false, $desc = '')
  121. {
  122. global $langs;
  123. print '<tr class="oddeven">';
  124. print '<td>'.($title ? $title : $langs->trans($confkey));
  125. if (!empty($desc)) {
  126. print '<br><small>'.$langs->trans($desc).'</small>';
  127. }
  128. print '</td>';
  129. print '<td class="center" width="20">&nbsp;</td>';
  130. print '<td class="right" width="300">';
  131. print ajax_constantonoff($confkey);
  132. print '</td></tr>';
  133. }
  134. /**
  135. * Print a form part
  136. *
  137. * @param string $confkey the conf key
  138. * @param bool $title Title of conf
  139. * @param string $desc Description of
  140. * @param array $metas html meta
  141. * @param string $type type of input textarea or input
  142. * @param bool $help help description
  143. *
  144. * @return void
  145. */
  146. function _printInputFormPart($confkey, $title = false, $desc = '', $metas = array(), $type = 'input', $help = false)
  147. {
  148. global $langs, $conf, $db, $inputCount;
  149. $inputCount = empty($inputCount) ? 1 : ($inputCount + 1);
  150. $form = new Form($db);
  151. $defaultMetas = array(
  152. 'name' => 'value'.$inputCount
  153. );
  154. if ($type != 'textarea') {
  155. $defaultMetas['type'] = 'text';
  156. $defaultMetas['value'] = $conf->global->{$confkey};
  157. }
  158. $metas = array_merge($defaultMetas, $metas);
  159. $metascompil = '';
  160. foreach ($metas as $key => $values) {
  161. $metascompil .= ' '.$key.'="'.$values.'" ';
  162. }
  163. print '<tr class="oddeven">';
  164. print '<td>';
  165. if (!empty($help)) {
  166. print $form->textwithtooltip(($title ? $title : $langs->trans($confkey)), $langs->trans($help), 2, 1, img_help(1, ''));
  167. } else {
  168. print $title ? $title : $langs->trans($confkey);
  169. }
  170. if (!empty($desc)) {
  171. print '<br><small>'.$langs->trans($desc).'</small>';
  172. }
  173. print '</td>';
  174. print '<td class="center" width="20">&nbsp;</td>';
  175. print '<td class="right" width="300">';
  176. print '<input type="hidden" name="param'.$inputCount.'" value="'.$confkey.'">';
  177. print '<input type="hidden" name="action" value="setModuleOptions">';
  178. if ($type == 'textarea') {
  179. print '<textarea '.$metascompil.' >'.dol_htmlentities($conf->global->{$confkey}).'</textarea>';
  180. } else {
  181. print '<input '.$metascompil.' />';
  182. }
  183. print '</td></tr>';
  184. }