dolibarr 21.0.0-alpha
invoice_situation.php
Go to the documentation of this file.
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 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
31// Load Dolibarr environment
32require '../main.inc.php';
33
34// Libraries
35require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
39
40// Load translation files required by the page
41$langs->loadLangs(array('admin', 'errors', 'other', 'bills'));
42
43// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
44$hookmanager->initHooks(array('situationinvoicesetup', 'globalsetup'));
45
46// Access control
47if (!$user->admin) {
49}
50
51$action = GETPOST('action', 'aZ09');
52$backtopage = GETPOST('backtopage', 'alpha');
53
54$value = GETPOST('value', 'alpha');
55$label = GETPOST('label', 'alpha');
56$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
57
58$scandir = GETPOST('scan_dir', 'alpha');
59$type = 'invoice';
60
61$form = new Form($db);
62$formSetup = new FormSetup($db);
63
64
65// Setup conf MYMODULE_MYPARAM4 : example of quick define write style
66$formSetup->newItem('INVOICE_USE_SITUATION')
67 ->setAsYesNo()
68 ->nameText = $langs->trans('UseSituationInvoices');
69
70$item = $formSetup->newItem('INVOICE_USE_SITUATION_CREDIT_NOTE')
71 ->setAsYesNo()
72 ->nameText = $langs->trans('UseSituationInvoicesCreditNote');
73
74//$item = $formSetup->newItem('INVOICE_USE_RETAINED_WARRANTY')
75// ->setAsYesNo()
76// ->nameText = $langs->trans('RetainedWarranty');
77
78
79$item = $formSetup->newItem('INVOICE_USE_RETAINED_WARRANTY');
80$item->nameText = $langs->trans('AllowedInvoiceForRetainedWarranty');
81
82$arrayAvailableType = array(
83 Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation"),
84 Facture::TYPE_STANDARD.'+'.Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation").' + '.$langs->trans("InvoiceStandard"),
85);
86
87if ($action == 'edit') {
88 $item->fieldInputOverride = $form->selectarray('INVOICE_USE_RETAINED_WARRANTY', $arrayAvailableType, $conf->global->INVOICE_USE_RETAINED_WARRANTY, 1);
89} else {
90 $item->fieldOutputOverride = isset($arrayAvailableType[getDolGlobalString('INVOICE_USE_RETAINED_WARRANTY')]) ? $arrayAvailableType[getDolGlobalString('INVOICE_USE_RETAINED_WARRANTY')] : '';
91}
92
93//$item = $formSetup->newItem('INVOICE_RETAINED_WARRANTY_LIMITED_TO_SITUATION')->setAsYesNo();
94//$item->nameText = $langs->trans('RetainedWarrantyOnlyForSituation');
95
96$formSetup->newItem('INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION')
97 ->setAsYesNo()
98 ->nameText = $langs->trans('RetainedWarrantyOnlyForSituationFinal');
99
100
101$item = $formSetup->newItem('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT');
102$item->nameText = $langs->trans('RetainedWarrantyDefaultPercent');
103$item->fieldAttr = array(
104 'type' => 'number',
105 'step' => '0.01',
106 'min' => 0,
107 'max' => 100
108);
109
110
111// Conditions paiements
112$item = $formSetup->newItem('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID');
113$item->nameText = $langs->trans('PaymentConditionsShortRetainedWarranty');
114$form->load_cache_conditions_paiements();
115if (getDolGlobalString('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID') && isset($form->cache_conditions_paiements[getDolGlobalString('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID')]['label'])) {
116 $item->fieldOutputOverride = $form->cache_conditions_paiements[getDolGlobalString('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID')]['label'];
117}
118$item->fieldInputOverride = $form->getSelectConditionsPaiements($conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID, 'INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID', -1, 1);
119
120
121/*
122 * Actions
123 */
124
125include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
126
127
128
129/*
130 * View
131 */
132
133$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
134
135$help_url = 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura';
136
137llxHeader("", $langs->trans("BillsSetup"), $help_url, '', 0, 0, '', '', '', 'mod-admin page-invoice_situation');
138
139
140$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
141print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup');
142
144print dol_get_fiche_head($head, 'situation', $langs->trans("InvoiceSituation"), -1, 'invoice');
145
146
147print '<span class="opacitymedium">'.$langs->trans("InvoiceFirstSituationDesc").'</span><br><br>';
148
149
150/*
151 * Numbering module
152 */
153
154if ($action == 'edit') {
155 print $formSetup->generateOutput(true);
156} else {
157 print $formSetup->generateOutput();
158}
159
160if (count($formSetup->items) > 0) {
161 if ($action != 'edit') {
162 print '<div class="tabsAction">';
163 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
164 print '</div>';
165 }
166} else {
167 print '<br>'.$langs->trans("NothingToSetup");
168}
169
170
171print dol_get_fiche_end();
172
173// End of page
174llxFooter();
175$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
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.
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
invoice_admin_prepare_head()
Return array head with list of tabs to view object information.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.