dolibarr  7.0.0-beta
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@capnetworks.com>
6  * Copyright (C) 2016 RaphaĆ«l Doursenaud <rdoursenaud@gpcsolutions.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29 
30 $langs->load("admin");
31 
32 if (! $user->admin) accessforbidden();
33 
34 $action=GETPOST('action','alpha');
35 
36 $modules=array(
37  'agenda' => array(
38  array(
39  'code' => 'MAIN_DELAY_ACTIONS_TODO',
40  'img' => 'action'
41  )
42  ),
43  'projet' => array(
44  array(
45  'code' => 'MAIN_DELAY_PROJECT_TO_CLOSE',
46  'img' => 'project'
47  ),
48  array(
49  'code' => 'MAIN_DELAY_TASKS_TODO',
50  'img' => 'task'
51  )
52  ),
53  'propal' => array(
54  array(
55  'code' => 'MAIN_DELAY_PROPALS_TO_CLOSE',
56  'img' => 'propal'
57  ),
58  array(
59  'code' => 'MAIN_DELAY_PROPALS_TO_BILL',
60  'img' => 'propal'
61  )
62  ),
63  'commande' => array(
64  array(
65  'code' => 'MAIN_DELAY_ORDERS_TO_PROCESS',
66  'img' => 'order'
67  )
68  ),
69  'facture' => array(
70  array(
71  'code' => 'MAIN_DELAY_CUSTOMER_BILLS_UNPAYED',
72  'img' => 'bill'
73  )
74  ),
75  'fournisseur' => array(
76  array(
77  'code' => 'MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS',
78  'img' => 'order'
79  ),
80  array(
81  'code' => 'MAIN_DELAY_SUPPLIER_BILLS_TO_PAY',
82  'img' => 'bill'
83  )
84  ),
85  'service' => array(
86  array(
87  'code' => 'MAIN_DELAY_NOT_ACTIVATED_SERVICES',
88  'img' => 'service'
89  ),
90  array(
91  'code' => 'MAIN_DELAY_RUNNING_SERVICES',
92  'img' => 'service'
93  )
94  ),
95  'banque' => array(
96  array(
97  'code' => 'MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE',
98  'img' => 'account'
99  ),
100  array(
101  'code' => 'MAIN_DELAY_CHEQUES_TO_DEPOSIT',
102  'img' => 'account'
103  )
104  ),
105  'adherent' => array(
106  array(
107  'code' => 'MAIN_DELAY_MEMBERS',
108  'img' => 'user'
109  )
110  ),
111  'expensereport' => array(
112  array(
113  'code' => 'MAIN_DELAY_EXPENSEREPORTS',
114  'img' => 'trip'
115  ),
116  /* TODO Enable this
117  array(
118  'code' => 'MAIN_DELAY_EXPENSEREPORTS_TO_PAY',
119  'img' => 'trip'
120  )*/
121  ),
122 );
123 
124 if ($action == 'update')
125 {
126  foreach($modules as $module => $delays)
127  {
128  if (! empty($conf->$module->enabled))
129  {
130  foreach($delays as $delay)
131  {
132  if (GETPOST($delay['code']) != '')
133  {
134  dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity);
135  }
136  }
137  }
138  }
139 
140  dolibarr_set_const($db, "MAIN_DISABLE_METEO",$_POST["MAIN_DISABLE_METEO"],'chaine',0,'',$conf->entity);
141  dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE",GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"),'chaine',0,'',$conf->entity);
142 
143  // For update value with percentage
144  $plus='';
145  if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE';
146  // Update values
147  for($i=0;$i<4;$i++) {
148  if(isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'),'chaine',0,'',$conf->entity);
149  }
150 
151 }
152 
153 
154 /*
155  * View
156  */
157 
158 $form = new Form($db);
159 
160 llxHeader();
161 
162 print load_fiche_titre($langs->trans("DelaysOfToleranceBeforeWarning"),'','title_setup');
163 
164 print $langs->transnoentities("DelaysOfToleranceDesc",img_warning());
165 print " ".$langs->trans("OnlyActiveElementsAreShown",DOL_URL_ROOT.'/admin/modules.php')."<br>\n";
166 print "<br>\n";
167 
168 $countrynotdefined='<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
169 
170 if ($action == 'edit')
171 {
172  print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="form_index">';
173  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
174  print '<input type="hidden" name="action" value="update">';
175  $var=true;
176 
177  print '<table class="noborder" width="100%">';
178  print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
179 
180  foreach($modules as $module => $delays)
181  {
182  if (! empty($conf->$module->enabled))
183  {
184  foreach($delays as $delay)
185  {
186 
187  $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0);
188  print '<tr class="oddeven">';
189  print '<td width="20px">'.img_object('',$delay['img']).'</td>';
190  print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td><td>';
191  print '<input class="right maxwidth75" type="number" name="'.$delay['code'].'" value="'.$value.'"> '.$langs->trans("days").'</td></tr>';
192  }
193  }
194  }
195 
196  print '</table>';
197 
198  print '<br>';
199 
200  // Show if meteo is enabled
201  print '<table class="noborder" width="100%">';
202  print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
203 
204  $var=false;
205  print '<tr class="oddeven">';
206  print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">' .$form->selectyesno('MAIN_DISABLE_METEO',(empty($conf->global->MAIN_DISABLE_METEO)?0:1),1) . '</td></tr>';
207 
208  print '</table>';
209 }
210 else
211 {
212  /*
213  * Affichage des parametres
214  */
215 
216  print '<table class="noborder" width="100%">';
217  print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
218  $var=true;
219 
220  foreach($modules as $module => $delays)
221  {
222  if (! empty($conf->$module->enabled))
223  {
224  foreach($delays as $delay)
225  {
226 
227  $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0);
228  print '<tr class="oddeven">';
229  print '<td width="20px">'.img_object('',$delay['img']).'</td>';
230  print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td>';
231  print '<td class="right">'.$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" width="100%">';
242  print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
243 
244  $var=false;
245  print '<tr class="oddeven">';
246  print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">' . yn($conf->global->MAIN_DISABLE_METEO) . '</td></tr>';
247 
248  print '</table>';
249 
250 }
251 
252 print '<br>';
253 
254 // Show logo for weather
255 print $langs->trans("DescWeather").'<br>';
256 
257 if($action == 'edit') {
258 
259  $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->trans('MeteoPercentageMod'));
260  $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->trans('MeteoStdMod'));
261  if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std;
262  else $str_mode_enabled = $str_mode_percentage;
263  print '<a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>';
264  print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.$conf->global->MAIN_USE_METEO_WITH_PERCENTAGE.'" />';
265 
266  print '<br><br>';
267 
268 } else {
269  if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled');
270  else print $langs->trans('MeteoPercentageModEnabled');
271  print '<br><br>';
272 }
273 
274 $offset=0;
275 $cursor=10; // By default
276 //if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
277 //if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP;
278 $level0=$offset; if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level0=$conf->global->MAIN_METEO_LEVEL0;
279 $level1=$offset+1*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1;
280 $level2=$offset+2*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2;
281 $level3=$offset+3*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3;
282 $text=''; $options='class="valignmiddle" height="60px"';
283 
284 
285 if ($action == 'edit') {
286 
287 
288  print '<div id="standard" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>';
289 
290  print '<div>';
291  print '<div class="inline-block" style="padding-right: 20px">';
292  print img_weather($text,'weather-clear.png', $options);
293  print '= <input type="text" size="2" name="MAIN_METEO_LEVEL0" value="'.$level0.'"/></td>';
294  print '</div><div class="inline-block" style="padding-right: 20px">';
295  print img_weather($text,'weather-few-clouds.png',$options);
296  print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL1" value="'.$level1.'"/></td>';
297  print '</div><div class="inline-block" style="padding-right: 20px">';
298  print img_weather($text,'weather-clouds.png',$options);
299  print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL2" value="'.$level2.'"/></td>';
300  print '</div><div class="inline-block" style="padding-right: 20px">';
301  print img_weather($text,'weather-many-clouds.png',$options);
302  print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL3" value="'.$level3.'"/></td>';
303  print '</div>';
304  print '</div>';
305 
306  print '</div>';
307 
308  print '<div id="percentage" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>';
309 
310  print '<div>';
311  print '<div class="inline-block" style="padding-right: 20px">';
312  print img_weather($text,'weather-clear.png',$options);
313  print '= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL0" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'"/>&nbsp;%</td>';
314  print '</div><div class="inline-block" style="padding-right: 20px">';
315  print img_weather($text,'weather-few-clouds.png',$options);
316  print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL1" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'"/>&nbsp;%</td>';
317  print '</div><div class="inline-block" style="padding-right: 20px">';
318  print img_weather($text,'weather-clouds.png',$options);
319  print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL2" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'"/>&nbsp;%</td>';
320  print '</div><div class="inline-block" style="padding-right: 20px">';
321  print img_weather($text,'weather-many-clouds.png',$options);
322  print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL3" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'"/>&nbsp;%</td>';
323  print '</div>';
324  print '</div>';
325 
326  print '</div>';
327 
328  ?>
329 
330  <script type="text/javascript">
331 
332  $(document).ready(function() {
333 
334  $("#change_mode").click(function() {
335  var use_percent = $("#MAIN_USE_METEO_WITH_PERCENTAGE");
336  var str_mode_std = "<?php print $str_mode_std; ?>";
337  var str_mode_percentage = "<?php print $str_mode_percentage; ?>";
338 
339  if(use_percent.val() == 1) {
340  use_percent.val(0);
341  $("#standard").show();
342  $("#percentage").hide();
343  $(this).html(str_mode_std);
344  } else {
345  use_percent.val(1);
346  $("#standard").hide();
347  $("#percentage").show();
348  $(this).html(str_mode_percentage);
349  }
350  });
351 
352  });
353 
354  </script>
355 
356  <?php
357 
358 } else {
359 
360  if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
361 
362  print '<div>';
363  print '<div class="inline-block" style="padding-right: 20px">';
364  print img_weather($text,'weather-clear.png',$options);
365  print '= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'&nbsp;%</td>';
366  print '</div><div class="inline-block" style="padding-right: 20px">';
367  print img_weather($text,'weather-few-clouds.png',$options);
368  print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'&nbsp;%</td>';
369  print '</div><div class="inline-block" style="padding-right: 20px">';
370  print img_weather($text,'weather-clouds.png',$options);
371  print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'&nbsp;%</td>';
372  print '</div><div class="inline-block" style="padding-right: 20px">';
373  print img_weather($text,'weather-many-clouds.png',$options);
374  print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>';
375  print '</div><div class="inline-block" style="padding-right: 20px">';
376  print img_weather($text,'weather-storm.png',$options);
377  print '&gt; '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>';
378  print '</div>';
379  print '</div>';
380 
381  } else {
382 
383  print '<div>';
384  print '<div class="inline-block" style="padding-right: 20px">';
385  print img_weather($text,'weather-clear.png',$options);
386  print '= '.$level0;
387  print '</div><div class="inline-block" style="padding-right: 20px">';
388  print img_weather($text,'weather-few-clouds.png',$options);
389  print '&lt;= '.$level1;
390  print '</div><div class="inline-block" style="padding-right: 20px">';
391  print img_weather($text,'weather-clouds.png',$options);
392  print '&lt;= '.$level2;
393  print '</div><div class="inline-block" style="padding-right: 20px">';
394  print img_weather($text,'weather-many-clouds.png',$options);
395  print '&lt;= '.$level3;
396  print '</div><div class="inline-block" style="padding-right: 20px">';
397  print img_weather($text,'weather-storm.png',$options);
398  print '&gt; '.$level3;
399  print '</div>';
400  print '</div>';
401 
402  }
403 }
404 
405 print '</div>';
406 
407 if($action == 'edit') {
408 
409  print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
410  print '<br></form>';
411 
412 } else {
413 
414  // Boutons d'action
415  print '<br><div class="tabsAction">';
416  print '<a class="butAction" href="delais.php?action=edit">'.$langs->trans("Modify").'</a></div>';
417 
418 }
419 
420 llxFooter();
421 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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).
Definition: admin.lib.php:485
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
img_warning($titlealt= 'default', $moreatt= '')
Show warning logo.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_weather($titlealt, $picto, $moreatt= '', $pictoisfullpath=0)
Show weather picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
print
Draft customers invoices.
Definition: index.php:91
type
Definition: viewcat.php:283