dolibarr  16.0.5
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 
32 // Libraries
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
37 
38 // Load translation files required by the page
39 $langs->loadLangs(array('admin', 'errors', 'other', 'bills'));
40 
41 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
42 $hookmanager->initHooks(array('situationinvoicesetup', 'globalsetup'));
43 
44 // Access control
45 if (!$user->admin) {
47 }
48 
49 $action = GETPOST('action', 'aZ09');
50 $backtopage = GETPOST('backtopage', 'alpha');
51 
52 $value = GETPOST('value', 'alpha');
53 $label = GETPOST('label', 'alpha');
54 $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
55 
56 $scandir = GETPOST('scan_dir', 'alpha');
57 $type = 'invoice';
58 
59 $form = new Form($db);
60 $formSetup = new FormSetup($db);
61 
62 
63 // Setup conf MYMODULE_MYPARAM4 : exemple of quick define write style
64 $formSetup->newItem('INVOICE_USE_SITUATION')
65  ->setAsYesNo()
66  ->nameText = $langs->trans('UseSituationInvoices');
67 
68 $item = $formSetup->newItem('INVOICE_USE_SITUATION_CREDIT_NOTE')
69  ->setAsYesNo()
70  ->nameText = $langs->trans('UseSituationInvoicesCreditNote');
71 
72 //$item = $formSetup->newItem('INVOICE_USE_RETAINED_WARRANTY')
73 // ->setAsYesNo()
74 // ->nameText = $langs->trans('Retainedwarranty');
75 
76 
77 $item = $formSetup->newItem('INVOICE_USE_RETAINED_WARRANTY');
78 $item->nameText = $langs->trans('AllowedInvoiceForRetainedWarranty');
79 
80 $arrayAvailableType = array(
81  Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation"),
82  Facture::TYPE_STANDARD.'+'.Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation").' + '.$langs->trans("InvoiceStandard"),
83 );
84 
85 if ($action == 'edit') {
86  $item->fieldInputOverride = $form->selectarray('INVOICE_USE_RETAINED_WARRANTY', $arrayAvailableType, $conf->global->INVOICE_USE_RETAINED_WARRANTY, 1);
87 } else {
88  $item->fieldOutputOverride= isset($arrayAvailableType[$conf->global->INVOICE_USE_RETAINED_WARRANTY])?$arrayAvailableType[$conf->global->INVOICE_USE_RETAINED_WARRANTY]:'';
89 }
90 
91 //$item = $formSetup->newItem('INVOICE_RETAINED_WARRANTY_LIMITED_TO_SITUATION')->setAsYesNo();
92 //$item->nameText = $langs->trans('RetainedwarrantyOnlyForSituation');
93 
94 $formSetup->newItem('INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION')
95  ->setAsYesNo()
96  ->nameText = $langs->trans('RetainedwarrantyOnlyForSituationFinal');
97 
98 
99 $item = $formSetup->newItem('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT');
100 $item->nameText = $langs->trans('RetainedwarrantyDefaultPercent');
101 $item->fieldAttr = array(
102  'type' => 'number',
103  'step' => '0.01',
104  'min' => 0,
105  'max' => 100
106 );
107 
108 
109 // Conditions paiements
110 $item = $formSetup->newItem('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID');
111 $item->nameText = $langs->trans('PaymentConditionsShortRetainedWarranty');
112 $form->load_cache_conditions_paiements();
113 if (!empty($conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID) && isset($form->cache_conditions_paiements[$conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID]['label'])) {
114  $item->fieldOutputOverride = $form->cache_conditions_paiements[$conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID]['label'];
115 }
116 $item->fieldInputOverride = $form->getSelectConditionsPaiements($conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID, 'INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID', -1, 1);
117 
118 
119 /*
120  * Actions
121  */
122 
123 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
124 
125 
126 
127 /*
128  * View
129  */
130 
131 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
132 
133 llxHeader(
134  "",
135  $langs->trans("BillsSetup"),
136  'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura'
137 );
138 
139 
140 
141 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
142 print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup');
143 
145 print dol_get_fiche_head($head, 'situation', $langs->trans("InvoiceSituation"), -1, 'invoice');
146 
147 
148 print '<span class="opacitymedium">'.$langs->trans("InvoiceFirstSituationDesc").'</span><br><br>';
149 
150 
151 /*
152  * Numbering module
153  */
154 
155 if ($action == 'edit') {
156  print $formSetup->generateOutput(true);
157 } else {
158  print $formSetup->generateOutput();
159 }
160 
161 if (count($formSetup->items) > 0) {
162  if ($action != 'edit') {
163  print '<div class="tabsAction">';
164  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
165  print '</div>';
166  }
167 } else {
168  print '<br>'.$langs->trans("NothingToSetup");
169 }
170 
171 
172 print dol_get_fiche_end();
173 
174 // End of page
175 llxFooter();
176 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
invoice_admin_prepare_head
invoice_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: invoice.lib.php:136
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FormSetup
This class help you create setup render.
Definition: html.formsetup.class.php:22
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
Facture\TYPE_STANDARD
const TYPE_STANDARD
Standard invoice.
Definition: facture.class.php:382
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
accessforbidden
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 ...
Definition: security.lib.php:933
Facture\TYPE_SITUATION
const TYPE_SITUATION
Situation invoice.
Definition: facture.class.php:407
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59