dolibarr  13.0.2
facture_situation.php
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 
30 require '../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
35 
36 // Load translation files required by the page
37 $langs->loadLangs(array('admin', 'errors', 'other', 'bills'));
38 
39 if (!$user->admin) accessforbidden();
40 
41 $action = GETPOST('action', 'aZ09');
42 $value = GETPOST('value', 'alpha');
43 $label = GETPOST('label', 'alpha');
44 $scandir = GETPOST('scan_dir', 'alpha');
45 $type = 'invoice';
46 
47 
48 /*
49  * Actions
50  */
51 
52 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
53 
54 
55 
56 /*
57  * View
58  */
59 
60 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
61 
62 llxHeader(
63  "", $langs->trans("BillsSetup"),
64  'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura'
65 );
66 
67 $form = new Form($db);
68 
69 
70 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
71 print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup');
72 
74 print dol_get_fiche_head($head, 'situation', $langs->trans("InvoiceSituation"), -1, 'invoice');
75 
76 
77 print '<span class="opacitymedium">'.$langs->trans("InvoiceFirstSituationDesc").'</span><br><br>';
78 
79 
80 /*
81  * Numbering module
82  */
83 
84 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
85 print '<input type="hidden" name="token" value="'.newToken().'">';
86 
87 
88 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
89 print '<table class="noborder centpercent">';
90 
91 print '<tr class="liste_titre">';
92 print '<td>'.$langs->trans("Parameter").'</td>';
93 print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
94 print '<td width="80">&nbsp;</td>';
95 print "</tr>\n";
96 
97 _printOnOff('INVOICE_USE_SITUATION', $langs->trans('UseSituationInvoices'));
98 _printOnOff('INVOICE_USE_SITUATION_CREDIT_NOTE', $langs->trans('UseSituationInvoicesCreditNote'));
99 //_printOnOff('INVOICE_USE_RETAINED_WARRANTY', $langs->trans('Retainedwarranty'));
100 
101 $confkey = 'INVOICE_USE_RETAINED_WARRANTY';
102 
103 $arrayAvailableType = array(
104  Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation"),
105  Facture::TYPE_STANDARD.'+'.Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation").' + '.$langs->trans("InvoiceStandard"),
106 );
107 $selected = $conf->global->$confkey;
108 $curentInput = (empty($inputCount) ? 1 : ($inputCount + 1));
109 $formSelectInvoiceType = $form->selectarray('value'.$curentInput, $arrayAvailableType, $selected, 1);
110 _printInputFormPart($confkey, $langs->trans('AllowedInvoiceForRetainedWarranty'), '', array(), $formSelectInvoiceType);
111 
112 //_printOnOff('INVOICE_RETAINED_WARRANTY_LIMITED_TO_SITUATION', $langs->trans('RetainedwarrantyOnlyForSituation'));
113 _printOnOff('INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION', $langs->trans('RetainedwarrantyOnlyForSituationFinal'));
114 
115 $metas = array(
116  'type' => 'number',
117  'step' => '0.01',
118  'min' => 0,
119  'max' => 100
120 );
121 _printInputFormPart('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT', $langs->trans('RetainedwarrantyDefaultPercent'), '', $metas);
122 
123 // Conditions paiements
124 $inputCount = empty($inputCount) ? 1 : ($inputCount + 1);
125 print '<tr class="oddeven">';
126 print '<td>'.$langs->trans('PaymentConditionsShortRetainedWarranty').'</td>';
127 print '<td class="center" width="20">&nbsp;</td>';
128 print '<td class="right" width="300">';
129 print '<input type="hidden" name="param'.$inputCount.'" value="INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID">';
130 $form->select_conditions_paiements($conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID, 'value'.$inputCount, -1, 1);
131 print '</td></tr>';
132 
133 
134 print '</table>';
135 print '</div>';
136 
137 print '<br>';
138 
139 _updateBtn();
140 
141 print '</form>';
142 
144 
145 // End of page
146 llxFooter();
147 $db->close();
148 
154 function _updateBtn()
155 {
156  global $langs;
157  print '<div class="center">';
158  print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'">';
159  print '</div>';
160 }
161 
171 function _printOnOff($confkey, $title = false, $desc = '')
172 {
173  global $langs;
174 
175  print '<tr class="oddeven">';
176  print '<td>'.($title ? $title : $langs->trans($confkey));
177  if (!empty($desc)) {
178  print '<br><small>'.$langs->trans($desc).'</small>';
179  }
180  print '</td>';
181  print '<td class="center" width="20">&nbsp;</td>';
182  print '<td class="right" width="300">';
183  print ajax_constantonoff($confkey);
184  print '</td></tr>';
185 }
186 
187 
200 function _printInputFormPart($confkey, $title = false, $desc = '', $metas = array(), $type = 'input', $help = false)
201 {
202  global $langs, $conf, $db, $inputCount;
203 
204  $inputCount = empty($inputCount) ? 1 : ($inputCount + 1);
205  $form = new Form($db);
206 
207  $defaultMetas = array(
208  'name' => 'value'.$inputCount
209  );
210 
211  if ($type != 'textarea') {
212  $defaultMetas['type'] = 'text';
213  $defaultMetas['value'] = $conf->global->{$confkey};
214  }
215 
216 
217  $metas = array_merge($defaultMetas, $metas);
218  $metascompil = '';
219  foreach ($metas as $key => $values) {
220  $metascompil .= ' '.$key.'="'.$values.'" ';
221  }
222 
223  print '<tr class="oddeven">';
224  print '<td>';
225 
226  if (!empty($help)) {
227  print $form->textwithtooltip(($title ? $title : $langs->trans($confkey)), $langs->trans($help), 2, 1, img_help(1, ''));
228  } else {
229  print $title ? $title : $langs->trans($confkey);
230  }
231 
232  if (!empty($desc)) {
233  print '<br><small>'.$langs->trans($desc).'</small>';
234  }
235 
236  print '</td>';
237  print '<td class="center" width="20">&nbsp;</td>';
238  print '<td class="right" width="300">';
239  print '<input type="hidden" name="param'.$inputCount.'" value="'.$confkey.'">';
240 
241  print '<input type="hidden" name="action" value="setModuleOptions">';
242  if ($type == 'textarea') {
243  print '<textarea '.$metascompil.' >'.dol_htmlentities($conf->global->{$confkey}).'</textarea>';
244  } elseif ($type == 'input') {
245  print '<input '.$metascompil.' />';
246  } else {
247  // custom
248  print $type;
249  }
250  print '</td></tr>';
251 }
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
const TYPE_STANDARD
Standard invoice.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor &quot;?&quot;.
dol_htmlentities($string, $flags=null, $encoding= 'UTF-8', $double_encode=false)
Replace htmlentities functions.
invoice_admin_prepare_head()
Return array head with list of tabs to view object informations.
const TYPE_SITUATION
Situation invoice.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0)
On/off button for constant.
Definition: ajax.lib.php:503
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
dol_get_fiche_end($notab=0)
Return tab footer of a card.
llxFooter()
Empty footer.
Definition: wrapper.php:59