dolibarr 25.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 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 */
25
32// Load Dolibarr environment
33require '../main.inc.php';
41// Libraries
42require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
44require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
45require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
46
47// Load translation files required by the page
48$langs->loadLangs(array('admin', 'errors', 'other', 'bills'));
49
50// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
51$hookmanager->initHooks(array('situationinvoicesetup', 'globalsetup'));
52
53// Access control
54if (!$user->admin) {
56}
57
58$action = GETPOST('action', 'aZ09');
59$backtopage = GETPOST('backtopage', 'alpha');
60
61$value = GETPOST('value', 'alpha');
62$label = GETPOST('label', 'alpha');
63$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
64
65$scandir = GETPOST('scan_dir', 'alpha');
66$type = 'invoice';
67
68$form = new Form($db);
69$formSetup = new FormSetup($db);
70
71
72// INVOICE_USE_SITUATION is a 3-state flag (0=off, 1=cumulative/legacy, 2=progressive), see admin/invoice.php.
73// A yes/no toggle can only write 0 or 1 and deletes the const when turned off (ajax_constantonoff calls
74// dolibarr_del_const): mode 2 could not be selected and was silently dropped. Use a 3-value select, which
75// writes the literal value via dolibarr_set_const and never deletes the const.
76$item = $formSetup->newItem('INVOICE_USE_SITUATION');
77$item->setAsSelect(array(
78 0 => $langs->trans('Disabled'),
79 1 => $langs->trans('SituationInvoiceModeCumulative'),
80 2 => $langs->trans('SituationInvoiceModeProgressive'),
81));
82$situationModeHelp = $langs->trans('SituationInvoiceModeHelp')
83 .'<br><b>'.$langs->trans('SituationInvoiceModeWarning').'</b>';
84$item->nameText = $langs->trans('SituationInvoiceMode').info_admin($situationModeHelp, 0, 0, 'warning', 'clearboth');
85
86$item = $formSetup->newItem('INVOICE_USE_SITUATION_CREDIT_NOTE')
87 ->setAsYesNo()
88 ->nameText = $langs->trans('UseSituationInvoicesCreditNote');
89
90//$item = $formSetup->newItem('INVOICE_USE_RETAINED_WARRANTY')
91// ->setAsYesNo()
92// ->nameText = $langs->trans('RetainedWarranty');
93
94
95$item = $formSetup->newItem('INVOICE_USE_RETAINED_WARRANTY');
96$item->nameText = $langs->trans('AllowedInvoiceForRetainedWarranty');
97$arrayAvailableType = array(
98 Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation"),
99 Facture::TYPE_STANDARD.'+'.Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation").' + '.$langs->trans("InvoiceStandard"),
100);
101$item->setAsSelect($arrayAvailableType);
102
103//$item = $formSetup->newItem('INVOICE_RETAINED_WARRANTY_LIMITED_TO_SITUATION')->setAsYesNo();
104//$item->nameText = $langs->trans('RetainedWarrantyOnlyForSituation');
105
106$formSetup->newItem('INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION')
107 ->setAsYesNo()
108 ->nameText = $langs->trans('RetainedWarrantyOnlyForSituationFinal');
109
110
111$item = $formSetup->newItem('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT');
112$item->nameText = $langs->trans('RetainedWarrantyDefaultPercent');
113$item->fieldAttr = array(
114 'type' => 'number',
115 'step' => '0.01',
116 'min' => 0,
117 'max' => 100,
118 'class' => 'width75 right',
119);
120
121
122// Conditions paiements
123$item = $formSetup->newItem('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID');
124$item->nameText = $langs->trans('PaymentConditionsShortRetainedWarranty');
125$form->load_cache_conditions_paiements();
126if (getDolGlobalString('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID') && isset($form->cache_conditions_paiements[getDolGlobalString('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID')]['label'])) {
127 $item->fieldOutputOverride = $form->cache_conditions_paiements[getDolGlobalString('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID')]['label'];
128}
129$item->fieldInputOverride = $form->getSelectConditionsPaiements(getDolGlobalInt("INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID"), 'INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID', -1, 1);
130
131
132/*
133 * Actions
134 */
135
136include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
137
138
139
140/*
141 * View
142 */
143
144$action = 'edit';
145
146$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
147
148$help_url = 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura';
149
150llxHeader("", $langs->trans("BillsSetup"), $help_url, '', 0, 0, '', '', '', 'mod-admin page-invoice_situation');
151
152
153$linkback = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/admin/modules.php', ['restore_lastsearch_values' => 1]).'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
154
155print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup');
156
158print dol_get_fiche_head($head, 'situation', $langs->trans("InvoiceSituation"), -1, 'bill');
159
160
161print '<span class="opacitymedium">'.$langs->trans("InvoiceFirstSituationDesc").'</span><br><br>';
162
163print $formSetup->generateOutput(true);
164
165print dol_get_fiche_end();
166
167// End of page
168llxFooter();
169$db->close();
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.