dolibarr 19.0.4
delais.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
7 * Copyright (C) 2022 Frédéric France <frederic.france@netlogic.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
28// Load Dolibarr environment
29require '../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31
32// Load translation files required by the page
33$langs->load("admin");
34
35if (!$user->admin) {
37}
38
39$action = GETPOST('action', 'aZ09');
40if (empty($action)) {
41 $action = 'edit';
42}
43
44// Define list of managed delays
45$modules = array(
46 'agenda' => array(
47 array(
48 'code' => 'MAIN_DELAY_ACTIONS_TODO',
49 'img' => 'action'
50 )
51 ),
52 'projet' => array(
53 array(
54 'code' => 'MAIN_DELAY_PROJECT_TO_CLOSE',
55 'img' => 'project'
56 ),
57 array(
58 'code' => 'MAIN_DELAY_TASKS_TODO',
59 'img' => 'projecttask'
60 )
61 ),
62 'propal' => array(
63 array(
64 'code' => 'MAIN_DELAY_PROPALS_TO_CLOSE',
65 'img' => 'propal'
66 ),
67 array(
68 'code' => 'MAIN_DELAY_PROPALS_TO_BILL',
69 'img' => 'propal'
70 )
71 ),
72 'commande' => array(
73 array(
74 'code' => 'MAIN_DELAY_ORDERS_TO_PROCESS',
75 'img' => 'order'
76 )
77 ),
78 'facture' => array(
79 array(
80 'code' => 'MAIN_DELAY_CUSTOMER_BILLS_UNPAYED',
81 'img' => 'bill'
82 )
83 ),
84 'fournisseur' => array(
85 array(
86 'code' => 'MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS',
87 'img' => 'order'
88 ),
89 array(
90 'code' => 'MAIN_DELAY_SUPPLIER_BILLS_TO_PAY',
91 'img' => 'bill'
92 )
93 ),
94 'service' => array(
95 array(
96 'code' => 'MAIN_DELAY_NOT_ACTIVATED_SERVICES',
97 'img' => 'service'
98 ),
99 array(
100 'code' => 'MAIN_DELAY_RUNNING_SERVICES',
101 'img' => 'service'
102 )
103 ),
104 'banque' => array(
105 array(
106 'code' => 'MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE',
107 'img' => 'account'
108 ),
109 array(
110 'code' => 'MAIN_DELAY_CHEQUES_TO_DEPOSIT',
111 'img' => 'account'
112 )
113 ),
114 'adherent' => array(
115 array(
116 'code' => 'MAIN_DELAY_MEMBERS',
117 'img' => 'user'
118 )
119 ),
120 'expensereport' => array(
121 array(
122 'code' => 'MAIN_DELAY_EXPENSEREPORTS',
123 'img' => 'trip'
124 ),
125 /* TODO Enable this
126 array(
127 'code' => 'MAIN_DELAY_EXPENSEREPORTS_TO_PAY',
128 'img' => 'trip'
129 )*/
130 ),
131 'holiday' => array(
132 array(
133 'code' => 'MAIN_DELAY_HOLIDAYS',
134 'img' => 'holiday'
135 ),
136 ),
137);
138
139$labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly"));
140
141if (!isset($conf->global->MAIN_DELAY_MEMBERS)) {
142 $conf->global->MAIN_DELAY_MEMBERS = 0; // Must be same value than into conf.class.php
143}
144if (!isset($conf->global->MAIN_DELAY_ACTIONS_TODO)) {
145 $conf->global->MAIN_DELAY_ACTIONS_TODO = 7; // Must be same value than into conf.class.php
146}
147if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
148 $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
149}
150if (!isset($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)) {
151 $conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS = 7;
152}
153if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
154 $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
155}
156if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
157 $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
158}
159if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
160 $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
161}
162
163
164
165/*
166 * Actions
167 */
168
169if ($action == 'update') {
170 foreach ($modules as $module => $delays) {
171 if (isModEnabled($module)) {
172 foreach ($delays as $delay) {
173 if (GETPOST($delay['code']) != '') {
174 dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity);
175 }
176 }
177 }
178 }
179
180 dolibarr_set_const($db, "MAIN_DISABLE_METEO", GETPOST("MAIN_DISABLE_METEO"), 'chaine', 0, '', $conf->entity);
181 dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity);
182
183 // For update value with percentage
184 $plus = '';
185 if (getDolGlobalString('MAIN_USE_METEO_WITH_PERCENTAGE')) {
186 $plus = '_PERCENTAGE';
187 }
188 // Update values
189 for ($i = 0; $i < 4; $i++) {
190 if (GETPOSTISSET('MAIN_METEO'.$plus.'_LEVEL'.$i)) {
191 dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity);
192 }
193 }
194
195 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
196
197 $action = 'edit';
198}
199
200
201/*
202 * View
203 */
204
205$form = new Form($db);
206
207llxHeader();
208
209print load_fiche_titre($langs->trans("DelaysOfToleranceBeforeWarning"), '', 'title_setup');
210
211print '<span class="opacitymedium">'.$langs->transnoentities("DelaysOfToleranceDesc", img_warning('default', '', 'pictowarning nopaddingleft'));
212print " ".$langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php')."</span><br>\n";
213print "<br>\n";
214
215if ($action == 'edit') {
216 print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="form_index">';
217 print '<input type="hidden" name="token" value="'.newToken().'">';
218 print '<input type="hidden" name="action" value="update">';
219
220 print '<table class="noborder centpercent">';
221 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td>';
222 print '<td class="right">'.$langs->trans("LateWarningAfter").'</td></tr>';
223
224 foreach ($modules as $module => $delays) {
225 if (isModEnabled($module)) {
226 foreach ($delays as $delay) {
227 $value = getDolGlobalInt($delay['code']);
228 print '<tr class="oddeven">';
229 print '<td width="20px">' . img_object('', $delay['img']) . '</td>';
230 print '<td>' . $langs->trans('Delays_' . $delay['code']) . '</td><td class="nowraponall right">';
231 print '<input class="right maxwidth75" type="number" name="' . $delay['code'] . '" value="' . $value . '"> ' . $langs->trans("days") . '</td></tr>';
232 }
233 }
234 }
235
236 print '</table>';
237
238 print '<br>';
239
240 // Show if meteo is enabled
241 print '<table class="noborder centpercent">';
242 print '<tr class="liste_titre"><td>'.$langs->trans("Option").'</td><td class="right">'.$langs->trans("Value").'</td></tr>';
243
244 print '<tr class="oddeven">';
245 print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="right">';
246 print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (!getDolGlobalString('MAIN_DISABLE_METEO') ? 0 : $conf->global->MAIN_DISABLE_METEO));
247 print '</td></tr>';
248
249 print '</table>';
250} else {
251 /*
252 * Show parameters
253 */
254
255 print '<table class="noborder centpercent">';
256 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="right">'.$langs->trans("Value").'</td></tr>';
257
258 foreach ($modules as $module => $delays) {
259 if (isModEnabled($module)) {
260 foreach ($delays as $delay) {
261 $value = getDolGlobalInt($delay['code']);
262 print '<tr class="oddeven">';
263 print '<td width="20px">' . img_object('', $delay['img']) . '</td>';
264 print '<td>' . $langs->trans('Delays_' . $delay['code']) . '</td>';
265 print '<td class="right">' . $value . ' ' . $langs->trans("days") . '</td></tr>';
266 }
267 }
268 }
269
270 print '</table>';
271
272 print '<br>';
273
274 // Show if meteo is enabled
275 print '<table class="noborder centpercent">';
276 print '<tr class="liste_titre"><td>'.$langs->trans("Option").'</td><td class="right">'.$langs->trans("Value").'</td></tr>';
277
278 print '<tr class="oddeven">';
279 print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
280 print $labelmeteo[getDolGlobalString('MAIN_DISABLE_METEO')];
281 print '</td></tr>';
282
283 print '</table>';
284}
285
286print '<br>';
287
288
289if (!getDolGlobalString('MAIN_DISABLE_METEO') || getDolGlobalInt('MAIN_DISABLE_METEO') != 1) {
290 // Show logo for weather
291 print '<span class="opacitymedium">'.$langs->trans("DescWeather").'</span> ';
292
293 if ($action == 'edit') {
294 $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod'));
295 $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod'));
296 if (!getDolGlobalString('MAIN_USE_METEO_WITH_PERCENTAGE')) {
297 $str_mode_enabled = $str_mode_std;
298 } else {
299 $str_mode_enabled = $str_mode_percentage;
300 }
301 print '<br><a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>';
302 print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.(getDolGlobalString('MAIN_USE_METEO_WITH_PERCENTAGE') ? $conf->global->MAIN_USE_METEO_WITH_PERCENTAGE : '').'" />';
303
304 print '<br><br>';
305 } else {
306 if (!getDolGlobalString('MAIN_USE_METEO_WITH_PERCENTAGE')) {
307 print $langs->trans('MeteoStdModEnabled');
308 } else {
309 print $langs->trans('MeteoPercentageModEnabled');
310 }
311 print '<br><br>';
312 }
313
314 $offset = 0;
315 $cursor = 10; // By default
316 //if (!empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
317 //if (!empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP;
318 $level0 = $offset;
319 if (getDolGlobalString('MAIN_METEO_LEVEL0')) {
320 $level0 = $conf->global->MAIN_METEO_LEVEL0;
321 }
322 $level1 = $offset + $cursor;
323 if (getDolGlobalString('MAIN_METEO_LEVEL1')) {
324 $level1 = $conf->global->MAIN_METEO_LEVEL1;
325 }
326 $level2 = $offset + 2 * $cursor;
327 if (getDolGlobalString('MAIN_METEO_LEVEL2')) {
328 $level2 = $conf->global->MAIN_METEO_LEVEL2;
329 }
330 $level3 = $offset + 3 * $cursor;
331 if (getDolGlobalString('MAIN_METEO_LEVEL3')) {
332 $level3 = $conf->global->MAIN_METEO_LEVEL3;
333 }
334 $text = '';
335 $options = 'class="valignmiddle" height="60px"';
336
337
338 if ($action == 'edit') {
339 print '<div id="standard" '.(!getDolGlobalString('MAIN_USE_METEO_WITH_PERCENTAGE') ? '' : 'style="display:none;"').'>';
340
341 print '<div>';
342 print '<div class="inline-block" style="padding-right: 20px">';
343 print img_weather($text, 0, $options);
344 print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL0" value="'.$level0.'"/></td>';
345 print '</div><div class="inline-block" style="padding-right: 20px">';
346 print img_weather($text, 1, $options);
347 print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL1" value="'.$level1.'"/></td>';
348 print '</div><div class="inline-block" style="padding-right: 20px">';
349 print img_weather($text, 2, $options);
350 print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL2" value="'.$level2.'"/></td>';
351 print '</div><div class="inline-block" style="padding-right: 20px">';
352 print img_weather($text, 3, $options);
353 print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL3" value="'.$level3.'"/></td>';
354 print '</div>';
355 print '</div>';
356
357 print '</div>';
358
359 print '<div id="percentage" '.(!getDolGlobalString('MAIN_USE_METEO_WITH_PERCENTAGE') ? 'style="display:none;"' : '').'>';
360
361 print '<div>';
362 print '<div class="inline-block" style="padding-right: 20px">';
363 print img_weather($text, 0, $options);
364 print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL0" value="'.getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL0').'"/>&nbsp;%</td>';
365 print '</div><div class="inline-block" style="padding-right: 20px">';
366 print img_weather($text, 1, $options);
367 print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL1" value="'.getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL1').'"/>&nbsp;%</td>';
368 print '</div><div class="inline-block" style="padding-right: 20px">';
369 print img_weather($text, 2, $options);
370 print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL2" value="'.getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL2').'"/>&nbsp;%</td>';
371 print '</div><div class="inline-block" style="padding-right: 20px">';
372 print img_weather($text, 3, $options);
373 print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL3" value="'.getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL3').'"/>&nbsp;%</td>';
374 print '</div>';
375 print '</div>';
376
377 print '</div>'; ?>
378
379 <script type="text/javascript">
380
381 $(document).ready(function() {
382
383 $("#change_mode").click(function() {
384 var use_percent = $("#MAIN_USE_METEO_WITH_PERCENTAGE");
385 var str_mode_std = "<?php print $str_mode_std; ?>";
386 var str_mode_percentage = "<?php print $str_mode_percentage; ?>";
387
388 if(use_percent.val() == 1) {
389 use_percent.val(0);
390 $("#standard").show();
391 $("#percentage").hide();
392 $(this).html(str_mode_std);
393 } else {
394 use_percent.val(1);
395 $("#standard").hide();
396 $("#percentage").show();
397 $(this).html(str_mode_percentage);
398 }
399 });
400
401 });
402
403 </script>
404
405 <?php
406 } else {
407 if (getDolGlobalString('MAIN_USE_METEO_WITH_PERCENTAGE')) {
408 print '<div>';
409 print '<div class="inline-block" style="padding-right: 20px">';
410 print img_weather($text, 0, $options);
411 print ' &lt;= ' . getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL0').'&nbsp;%</td>';
412 print '</div><div class="inline-block" style="padding-right: 20px">';
413 print img_weather($text, 1, $options);
414 print ' &lt;= ' . getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL1').'&nbsp;%</td>';
415 print '</div><div class="inline-block" style="padding-right: 20px">';
416 print img_weather($text, 2, $options);
417 print ' &lt;= ' . getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL2').'&nbsp;%</td>';
418 print '</div><div class="inline-block" style="padding-right: 20px">';
419 print img_weather($text, 3, $options);
420 print ' &lt;= ' . getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL3').'&nbsp;%</td>';
421 print '</div><div class="inline-block" style="padding-right: 20px">';
422 print img_weather($text, 4, $options);
423 print ' &gt; ' . getDolGlobalString('MAIN_METEO_PERCENTAGE_LEVEL3').'&nbsp;%</td>';
424 print '</div>';
425 print '</div>';
426 } else {
427 print '<div>';
428 print '<div class="inline-block" style="padding-right: 20px">';
429 print img_weather($text, 0, $options);
430 print ' &lt;= '.$level0;
431 print '</div><div class="inline-block" style="padding-right: 20px">';
432 print img_weather($text, 1, $options);
433 print ' &lt;= '.$level1;
434 print '</div><div class="inline-block" style="padding-right: 20px">';
435 print img_weather($text, 2, $options);
436 print ' &lt;= '.$level2;
437 print '</div><div class="inline-block" style="padding-right: 20px">';
438 print img_weather($text, 3, $options);
439 print ' &lt;= '.$level3;
440 print '</div><div class="inline-block" style="padding-right: 20px">';
441 print img_weather($text, 4, $options);
442 print ' &gt; '.$level3;
443 print '</div>';
444 print '</div>';
445 }
446 }
447}
448
449
450if ($action == 'edit') {
451 print $form->buttonsSaveCancel("Save", '');
452 print '</form>';
453} else {
454 print '<br><br><div class="tabsAction">';
455 print '<a class="butAction reposition" href="delais.php?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
456 print '</div>';
457}
458
459// End of page
460llxFooter();
461$db->close();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
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
Class to manage generation of HTML components Only common components must be here.
img_weather($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $morecss='')
Show weather picto.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:121
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.