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 24/** 25 * \file htdocs/admin/facture.php 26 * \ingroup facture 27 * \brief Page to setup invoice module 28 */ 29 30require '../main.inc.php'; 31require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; 32require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; 33require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; 34require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; 35 36// Load translation files required by the page 37$langs->loadLangs(array('admin', 'errors', 'other', 'bills')); 38 39if (!$user->admin) accessforbidden(); 40 41$action = GETPOST('action', 'aZ09'); 42$value = GETPOST('value', 'alpha'); 43$label = GETPOST('label', 'alpha'); 44$scandir = GETPOST('scan_dir', 'alpha'); 45$type = 'invoice'; 46 47 48/* 49 * Actions 50 */ 51 52include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; 53 54 55 56/* 57 * View 58 */ 59 60$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); 61 62llxHeader( 63 "", $langs->trans("BillsSetup"), 64 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura' 65); 66 67$form = new Form($db); 68 69 70$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; 71print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup'); 72 73$head = invoice_admin_prepare_head(); 74print dol_get_fiche_head($head, 'situation', $langs->trans("InvoiceSituation"), -1, 'invoice'); 75 76 77print '<span class="opacitymedium">'.$langs->trans("InvoiceFirstSituationDesc").'</span><br><br>'; 78 79 80/* 81 * Numbering module 82 */ 83 84print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">'; 85print '<input type="hidden" name="token" value="'.newToken().'">'; 86 87 88print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table 89print '<table class="noborder centpercent">'; 90 91print '<tr class="liste_titre">'; 92print '<td>'.$langs->trans("Parameter").'</td>'; 93print '<td align="center" width="60">'.$langs->trans("Value").'</td>'; 94print '<td width="80"> </td>'; 95print "</tr>\n"; 96 97_printOnOff('INVOICE_USE_SITUATION', $langs->trans('UseSituationInvoices')); 98_printOnOff('INVOICE_USE_SITUATION_CREDIT_NOTE', $langs->trans('UseSituationInvoicesCreditNote')); 99//_printOnOff('INVOICE_USE_RETAINED_WARRANTY', $langs->trans('Retainedwarranty')); 100 101$confkey = 'INVOICE_USE_RETAINED_WARRANTY'; 102 103$arrayAvailableType = array( 104 Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation"), 105 Facture::TYPE_STANDARD.'+'.Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation").' + '.$langs->trans("InvoiceStandard"), 106); 107$selected = $conf->global->$confkey; 108$curentInput = (empty($inputCount) ? 1 : ($inputCount + 1)); 109$formSelectInvoiceType = $form->selectarray('value'.$curentInput, $arrayAvailableType, $selected, 1); 110_printInputFormPart($confkey, $langs->trans('AllowedInvoiceForRetainedWarranty'), '', array(), $formSelectInvoiceType); 111 112//_printOnOff('INVOICE_RETAINED_WARRANTY_LIMITED_TO_SITUATION', $langs->trans('RetainedwarrantyOnlyForSituation')); 113_printOnOff('INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION', $langs->trans('RetainedwarrantyOnlyForSituationFinal')); 114 115$metas = array( 116 'type' => 'number', 117 'step' => '0.01', 118 'min' => 0, 119 'max' => 100 120); 121_printInputFormPart('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT', $langs->trans('RetainedwarrantyDefaultPercent'), '', $metas); 122 123// Conditions paiements 124$inputCount = empty($inputCount) ? 1 : ($inputCount + 1); 125print '<tr class="oddeven">'; 126print '<td>'.$langs->trans('PaymentConditionsShortRetainedWarranty').'</td>'; 127print '<td class="center" width="20"> </td>'; 128print '<td class="right" width="300">'; 129print '<input type="hidden" name="param'.$inputCount.'" value="INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID">'; 130$form->select_conditions_paiements($conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID, 'value'.$inputCount, -1, 1); 131print '</td></tr>'; 132 133 134print '</table>'; 135print '</div>'; 136 137print '<br>'; 138 139_updateBtn(); 140 141print '</form>'; 142 143print dol_get_fiche_end(); 144 145// End of page 146llxFooter(); 147$db->close(); 148 149/** 150 * Print an update button 151 * 152 * @return void 153 */ 154function _updateBtn() 155{ 156 global $langs; 157 print '<div class="center">'; 158 print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'">'; 159 print '</div>'; 160} 161 162/** 163 * Print a On/Off button 164 * 165 * @param string $confkey the conf key 166 * @param bool $title Title of conf 167 * @param string $desc Description 168 * 169 * @return void 170 */ 171function _printOnOff($confkey, $title = false, $desc = '') 172{ 173 global $langs; 174 175 print '<tr class="oddeven">'; 176 print '<td>'.($title ? $title : $langs->trans($confkey)); 177 if (!empty($desc)) { 178 print '<br><small>'.$langs->trans($desc).'</small>'; 179 } 180 print '</td>'; 181 print '<td class="center" width="20"> </td>'; 182 print '<td class="right" width="300">'; 183 print ajax_constantonoff($confkey); 184 print '</td></tr>'; 185} 186 187 188/** 189 * Print a form part 190 * 191 * @param string $confkey the conf key 192 * @param bool $title Title of conf 193 * @param string $desc Description of 194 * @param array $metas html meta 195 * @param string $type type of input textarea or input 196 * @param bool $help help description 197 * 198 * @return void 199 */ 200function _printInputFormPart($confkey, $title = false, $desc = '', $metas = array(), $type = 'input', $help = false) 201{ 202 global $langs, $conf, $db, $inputCount; 203 204 $inputCount = empty($inputCount) ? 1 : ($inputCount + 1); 205 $form = new Form($db); 206 207 $defaultMetas = array( 208 'name' => 'value'.$inputCount 209 ); 210 211 if ($type != 'textarea') { 212 $defaultMetas['type'] = 'text'; 213 $defaultMetas['value'] = $conf->global->{$confkey}; 214 } 215 216 217 $metas = array_merge($defaultMetas, $metas); 218 $metascompil = ''; 219 foreach ($metas as $key => $values) { 220 $metascompil .= ' '.$key.'="'.$values.'" '; 221 } 222 223 print '<tr class="oddeven">'; 224 print '<td>'; 225 226 if (!empty($help)) { 227 print $form->textwithtooltip(($title ? $title : $langs->trans($confkey)), $langs->trans($help), 2, 1, img_help(1, '')); 228 } else { 229 print $title ? $title : $langs->trans($confkey); 230 } 231 232 if (!empty($desc)) { 233 print '<br><small>'.$langs->trans($desc).'</small>'; 234 } 235 236 print '</td>'; 237 print '<td class="center" width="20"> </td>'; 238 print '<td class="right" width="300">'; 239 print '<input type="hidden" name="param'.$inputCount.'" value="'.$confkey.'">'; 240 241 print '<input type="hidden" name="action" value="setModuleOptions">'; 242 if ($type == 'textarea') { 243 print '<textarea '.$metascompil.' >'.dol_htmlentities($conf->global->{$confkey}).'</textarea>'; 244 } elseif ($type == 'input') { 245 print '<input '.$metascompil.' />'; 246 } else { 247 // custom 248 print $type; 249 } 250 print '</td></tr>'; 251} 252