facture_situation.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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) {
  36. accessforbidden();
  37. }
  38. $action = GETPOST('action', 'aZ09');
  39. $value = GETPOST('value', 'alpha');
  40. $label = GETPOST('label', 'alpha');
  41. $scandir = GETPOST('scan_dir', 'alpha');
  42. $type = 'invoice';
  43. /*
  44. * Actions
  45. */
  46. include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  47. /*
  48. * View
  49. */
  50. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  51. llxHeader(
  52. "",
  53. $langs->trans("BillsSetup"),
  54. 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura'
  55. );
  56. $form = new Form($db);
  57. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  58. print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup');
  59. $head = invoice_admin_prepare_head();
  60. print dol_get_fiche_head($head, 'situation', $langs->trans("InvoiceSituation"), -1, 'invoice');
  61. print '<span class="opacitymedium">'.$langs->trans("InvoiceFirstSituationDesc").'</span><br><br>';
  62. /*
  63. * Numbering module
  64. */
  65. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
  66. print '<input type="hidden" name="token" value="'.newToken().'">';
  67. 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
  68. print '<table class="noborder centpercent">';
  69. print '<tr class="liste_titre">';
  70. print '<td>'.$langs->trans("Parameter").'</td>';
  71. print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
  72. print '<td width="80">&nbsp;</td>';
  73. print "</tr>\n";
  74. _printOnOff('INVOICE_USE_SITUATION', $langs->trans('UseSituationInvoices'));
  75. _printOnOff('INVOICE_USE_SITUATION_CREDIT_NOTE', $langs->trans('UseSituationInvoicesCreditNote'));
  76. //_printOnOff('INVOICE_USE_RETAINED_WARRANTY', $langs->trans('Retainedwarranty'));
  77. $confkey = 'INVOICE_USE_RETAINED_WARRANTY';
  78. $arrayAvailableType = array(
  79. Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation"),
  80. Facture::TYPE_STANDARD.'+'.Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation").' + '.$langs->trans("InvoiceStandard"),
  81. );
  82. $selected = $conf->global->$confkey;
  83. $curentInput = (empty($inputCount) ? 1 : ($inputCount + 1));
  84. $formSelectInvoiceType = $form->selectarray('value'.$curentInput, $arrayAvailableType, $selected, 1);
  85. _printInputFormPart($confkey, $langs->trans('AllowedInvoiceForRetainedWarranty'), '', array(), $formSelectInvoiceType);
  86. //_printOnOff('INVOICE_RETAINED_WARRANTY_LIMITED_TO_SITUATION', $langs->trans('RetainedwarrantyOnlyForSituation'));
  87. _printOnOff('INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION', $langs->trans('RetainedwarrantyOnlyForSituationFinal'));
  88. $metas = array(
  89. 'type' => 'number',
  90. 'step' => '0.01',
  91. 'min' => 0,
  92. 'max' => 100
  93. );
  94. _printInputFormPart('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT', $langs->trans('RetainedwarrantyDefaultPercent'), '', $metas);
  95. // Conditions paiements
  96. $inputCount = empty($inputCount) ? 1 : ($inputCount + 1);
  97. print '<tr class="oddeven">';
  98. print '<td>'.$langs->trans('PaymentConditionsShortRetainedWarranty').'</td>';
  99. print '<td class="center" width="20">&nbsp;</td>';
  100. print '<td class="right" width="300">';
  101. print '<input type="hidden" name="param'.$inputCount.'" value="INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID">';
  102. $form->select_conditions_paiements($conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID, 'value'.$inputCount, -1, 1);
  103. print '</td></tr>';
  104. print '</table>';
  105. print '</div>';
  106. print '<br>';
  107. _updateBtn();
  108. print '</form>';
  109. print dol_get_fiche_end();
  110. // End of page
  111. llxFooter();
  112. $db->close();
  113. /**
  114. * Print an update button
  115. *
  116. * @return void
  117. */
  118. function _updateBtn()
  119. {
  120. global $langs;
  121. print '<div class="center">';
  122. print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'">';
  123. print '</div>';
  124. }
  125. /**
  126. * Print a On/Off button
  127. *
  128. * @param string $confkey the conf key
  129. * @param bool $title Title of conf
  130. * @param string $desc Description
  131. *
  132. * @return void
  133. */
  134. function _printOnOff($confkey, $title = false, $desc = '')
  135. {
  136. global $langs;
  137. print '<tr class="oddeven">';
  138. print '<td>'.($title ? $title : $langs->trans($confkey));
  139. if (!empty($desc)) {
  140. print '<br><small>'.$langs->trans($desc).'</small>';
  141. }
  142. print '</td>';
  143. print '<td class="center" width="20">&nbsp;</td>';
  144. print '<td class="right" width="300">';
  145. print ajax_constantonoff($confkey);
  146. print '</td></tr>';
  147. }
  148. /**
  149. * Print a form part
  150. *
  151. * @param string $confkey the conf key
  152. * @param bool $title Title of conf
  153. * @param string $desc Description of
  154. * @param array $metas html meta
  155. * @param string $type type of input textarea or input
  156. * @param bool $help help description
  157. *
  158. * @return void
  159. */
  160. function _printInputFormPart($confkey, $title = false, $desc = '', $metas = array(), $type = 'input', $help = false)
  161. {
  162. global $langs, $conf, $db, $inputCount;
  163. $inputCount = empty($inputCount) ? 1 : ($inputCount + 1);
  164. $form = new Form($db);
  165. $defaultMetas = array(
  166. 'name' => 'value'.$inputCount
  167. );
  168. if ($type != 'textarea') {
  169. $defaultMetas['type'] = 'text';
  170. $defaultMetas['value'] = $conf->global->{$confkey};
  171. }
  172. $metas = array_merge($defaultMetas, $metas);
  173. $metascompil = '';
  174. foreach ($metas as $key => $values) {
  175. $metascompil .= ' '.$key.'="'.$values.'" ';
  176. }
  177. print '<tr class="oddeven">';
  178. print '<td>';
  179. if (!empty($help)) {
  180. print $form->textwithtooltip(($title ? $title : $langs->trans($confkey)), $langs->trans($help), 2, 1, img_help(1, ''));
  181. } else {
  182. print $title ? $title : $langs->trans($confkey);
  183. }
  184. if (!empty($desc)) {
  185. print '<br><small>'.$langs->trans($desc).'</small>';
  186. }
  187. print '</td>';
  188. print '<td class="center" width="20">&nbsp;</td>';
  189. print '<td class="right" width="300">';
  190. print '<input type="hidden" name="param'.$inputCount.'" value="'.$confkey.'">';
  191. print '<input type="hidden" name="action" value="setModuleOptions">';
  192. if ($type == 'textarea') {
  193. print '<textarea '.$metascompil.' >'.dol_htmlentities($conf->global->{$confkey}).'</textarea>';
  194. } elseif ($type == 'input') {
  195. print '<input '.$metascompil.' />';
  196. } else {
  197. // custom
  198. print $type;
  199. }
  200. print '</td></tr>';
  201. }