dolibarr 20.0.2
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 *
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 : example 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$arrayAvailableType = array(
81 Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation"),
82 Facture::TYPE_STANDARD.'+'.Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation").' + '.$langs->trans("InvoiceStandard"),
83);
84$item->setAsSelect($arrayAvailableType);
85
86//$item = $formSetup->newItem('INVOICE_RETAINED_WARRANTY_LIMITED_TO_SITUATION')->setAsYesNo();
87//$item->nameText = $langs->trans('RetainedWarrantyOnlyForSituation');
88
89$formSetup->newItem('INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION')
90 ->setAsYesNo()
91 ->nameText = $langs->trans('RetainedWarrantyOnlyForSituationFinal');
92
93
94$item = $formSetup->newItem('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT');
95$item->nameText = $langs->trans('RetainedWarrantyDefaultPercent');
96$item->fieldAttr = array(
97 'type' => 'number',
98 'step' => '0.01',
99 'min' => 0,
100 'max' => 100
101);
102
103
104// Conditions paiements
105$item = $formSetup->newItem('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID');
106$item->nameText = $langs->trans('PaymentConditionsShortRetainedWarranty');
107$form->load_cache_conditions_paiements();
108if (getDolGlobalString('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID') && isset($form->cache_conditions_paiements[getDolGlobalString('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID')]['label'])) {
109 $item->fieldOutputOverride = $form->cache_conditions_paiements[getDolGlobalString('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID')]['label'];
110}
111$item->fieldInputOverride = $form->getSelectConditionsPaiements($conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID, 'INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID', -1, 1);
112
113
114/*
115 * Actions
116 */
117
118include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
119
120
121
122/*
123 * View
124 */
125
126$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
127
128$help_yrl = 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura';
129
130llxHeader("", $langs->trans("BillsSetup"), $help_url, '', 0, 0, '', '', '', 'mod-admin page-invoice_situation');
131
132
133$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
134print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup');
135
137print dol_get_fiche_head($head, 'situation', $langs->trans("InvoiceSituation"), -1, 'invoice');
138
139
140print '<span class="opacitymedium">'.$langs->trans("InvoiceFirstSituationDesc").'</span><br><br>';
141
142
143/*
144 * Numbering module
145 */
146
147if ($action == 'edit') {
148 print $formSetup->generateOutput(true);
149} else {
150 print $formSetup->generateOutput();
151}
152
153if (count($formSetup->items) > 0) {
154 if ($action != 'edit') {
155 print '<div class="tabsAction">';
156 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
157 print '</div>';
158 }
159} else {
160 print '<br>'.$langs->trans("NothingToSetup");
161}
162
163
164print dol_get_fiche_end();
165
166// End of page
167llxFooter();
168$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:55
llxFooter()
Empty footer.
Definition wrapper.php:69
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($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 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.