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