delais.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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. *
  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. /**
  22. * \file htdocs/admin/delais.php
  23. * \brief Page to setup late delays
  24. */
  25. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  27. // Load translation files required by the page
  28. $langs->load("admin");
  29. if (! $user->admin) accessforbidden();
  30. $action=GETPOST('action','alpha');
  31. $modules=array(
  32. 'agenda' => array(
  33. array(
  34. 'code' => 'MAIN_DELAY_ACTIONS_TODO',
  35. 'img' => 'action'
  36. )
  37. ),
  38. 'projet' => array(
  39. array(
  40. 'code' => 'MAIN_DELAY_PROJECT_TO_CLOSE',
  41. 'img' => 'project'
  42. ),
  43. array(
  44. 'code' => 'MAIN_DELAY_TASKS_TODO',
  45. 'img' => 'task'
  46. )
  47. ),
  48. 'propal' => array(
  49. array(
  50. 'code' => 'MAIN_DELAY_PROPALS_TO_CLOSE',
  51. 'img' => 'propal'
  52. ),
  53. array(
  54. 'code' => 'MAIN_DELAY_PROPALS_TO_BILL',
  55. 'img' => 'propal'
  56. )
  57. ),
  58. 'commande' => array(
  59. array(
  60. 'code' => 'MAIN_DELAY_ORDERS_TO_PROCESS',
  61. 'img' => 'order'
  62. )
  63. ),
  64. 'facture' => array(
  65. array(
  66. 'code' => 'MAIN_DELAY_CUSTOMER_BILLS_UNPAYED',
  67. 'img' => 'bill'
  68. )
  69. ),
  70. 'fournisseur' => array(
  71. array(
  72. 'code' => 'MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS',
  73. 'img' => 'order'
  74. ),
  75. array(
  76. 'code' => 'MAIN_DELAY_SUPPLIER_BILLS_TO_PAY',
  77. 'img' => 'bill'
  78. )
  79. ),
  80. 'service' => array(
  81. array(
  82. 'code' => 'MAIN_DELAY_NOT_ACTIVATED_SERVICES',
  83. 'img' => 'service'
  84. ),
  85. array(
  86. 'code' => 'MAIN_DELAY_RUNNING_SERVICES',
  87. 'img' => 'service'
  88. )
  89. ),
  90. 'banque' => array(
  91. array(
  92. 'code' => 'MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE',
  93. 'img' => 'account'
  94. ),
  95. array(
  96. 'code' => 'MAIN_DELAY_CHEQUES_TO_DEPOSIT',
  97. 'img' => 'account'
  98. )
  99. ),
  100. 'adherent' => array(
  101. array(
  102. 'code' => 'MAIN_DELAY_MEMBERS',
  103. 'img' => 'user'
  104. )
  105. ),
  106. 'expensereport' => array(
  107. array(
  108. 'code' => 'MAIN_DELAY_EXPENSEREPORTS',
  109. 'img' => 'trip'
  110. ),
  111. /* TODO Enable this
  112. array(
  113. 'code' => 'MAIN_DELAY_EXPENSEREPORTS_TO_PAY',
  114. 'img' => 'trip'
  115. )*/
  116. ),
  117. );
  118. $labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly"));
  119. /*
  120. * Actions
  121. */
  122. if ($action == 'update')
  123. {
  124. foreach($modules as $module => $delays)
  125. {
  126. if (! empty($conf->$module->enabled))
  127. {
  128. foreach($delays as $delay)
  129. {
  130. if (GETPOST($delay['code']) != '')
  131. {
  132. dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity);
  133. }
  134. }
  135. }
  136. }
  137. dolibarr_set_const($db, "MAIN_DISABLE_METEO",$_POST["MAIN_DISABLE_METEO"],'chaine',0,'',$conf->entity);
  138. dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE",GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"),'chaine',0,'',$conf->entity);
  139. // For update value with percentage
  140. $plus='';
  141. if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE';
  142. // Update values
  143. for($i=0; $i<4; $i++) {
  144. 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);
  145. }
  146. }
  147. /*
  148. * View
  149. */
  150. $form = new Form($db);
  151. llxHeader();
  152. print load_fiche_titre($langs->trans("DelaysOfToleranceBeforeWarning"),'','title_setup');
  153. print $langs->transnoentities("DelaysOfToleranceDesc",img_warning());
  154. print " ".$langs->trans("OnlyActiveElementsAreShown",DOL_URL_ROOT.'/admin/modules.php')."<br>\n";
  155. print "<br>\n";
  156. $countrynotdefined='<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
  157. if ($action == 'edit')
  158. {
  159. print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="form_index">';
  160. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  161. print '<input type="hidden" name="action" value="update">';
  162. print '<table class="noborder" width="100%">';
  163. print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
  164. foreach($modules as $module => $delays)
  165. {
  166. if (! empty($conf->$module->enabled))
  167. {
  168. foreach($delays as $delay)
  169. {
  170. $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0);
  171. print '<tr class="oddeven">';
  172. print '<td width="20px">'.img_object('',$delay['img']).'</td>';
  173. print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td><td>';
  174. print '<input class="right maxwidth75" type="number" name="'.$delay['code'].'" value="'.$value.'"> '.$langs->trans("days").'</td></tr>';
  175. }
  176. }
  177. }
  178. print '</table>';
  179. print '<br>';
  180. // Show if meteo is enabled
  181. print '<table class="noborder" width="100%">';
  182. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
  183. print '<tr class="oddeven">';
  184. print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
  185. print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO)?0:$conf->global->MAIN_DISABLE_METEO));
  186. print '</td></tr>';
  187. print '</table>';
  188. }
  189. else
  190. {
  191. /*
  192. * Affichage des parametres
  193. */
  194. print '<table class="noborder" width="100%">';
  195. print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
  196. foreach($modules as $module => $delays)
  197. {
  198. if (! empty($conf->$module->enabled))
  199. {
  200. foreach($delays as $delay)
  201. {
  202. $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0);
  203. print '<tr class="oddeven">';
  204. print '<td width="20px">'.img_object('',$delay['img']).'</td>';
  205. print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td>';
  206. print '<td class="right">'.$value.' '.$langs->trans("days").'</td></tr>';
  207. }
  208. }
  209. }
  210. print '</table>';
  211. print '<br>';
  212. // Show if meteo is enabled
  213. print '<table class="noborder" width="100%">';
  214. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
  215. print '<tr class="oddeven">';
  216. print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
  217. print $labelmeteo[$conf->global->MAIN_DISABLE_METEO];
  218. print '</td></tr>';
  219. print '</table>';
  220. }
  221. print '<br>';
  222. // Show logo for weather
  223. print $langs->trans("DescWeather").'<br>';
  224. if($action == 'edit') {
  225. $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->trans('MeteoPercentageMod'));
  226. $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->trans('MeteoStdMod'));
  227. if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std;
  228. else $str_mode_enabled = $str_mode_percentage;
  229. print '<a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>';
  230. print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.$conf->global->MAIN_USE_METEO_WITH_PERCENTAGE.'" />';
  231. print '<br><br>';
  232. } else {
  233. if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled');
  234. else print $langs->trans('MeteoPercentageModEnabled');
  235. print '<br><br>';
  236. }
  237. $offset=0;
  238. $cursor=10; // By default
  239. //if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
  240. //if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP;
  241. $level0=$offset; if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level0=$conf->global->MAIN_METEO_LEVEL0;
  242. $level1=$offset+1*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1;
  243. $level2=$offset+2*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2;
  244. $level3=$offset+3*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3;
  245. $text=''; $options='class="valignmiddle" height="60px"';
  246. if ($action == 'edit') {
  247. print '<div id="standard" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>';
  248. print '<div>';
  249. print '<div class="inline-block" style="padding-right: 20px">';
  250. print img_weather($text,'weather-clear.png', $options);
  251. print '= <input type="text" size="2" name="MAIN_METEO_LEVEL0" value="'.$level0.'"/></td>';
  252. print '</div><div class="inline-block" style="padding-right: 20px">';
  253. print img_weather($text,'weather-few-clouds.png',$options);
  254. print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL1" value="'.$level1.'"/></td>';
  255. print '</div><div class="inline-block" style="padding-right: 20px">';
  256. print img_weather($text,'weather-clouds.png',$options);
  257. print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL2" value="'.$level2.'"/></td>';
  258. print '</div><div class="inline-block" style="padding-right: 20px">';
  259. print img_weather($text,'weather-many-clouds.png',$options);
  260. print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL3" value="'.$level3.'"/></td>';
  261. print '</div>';
  262. print '</div>';
  263. print '</div>';
  264. print '<div id="percentage" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>';
  265. print '<div>';
  266. print '<div class="inline-block" style="padding-right: 20px">';
  267. print img_weather($text,'weather-clear.png',$options);
  268. print '= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL0" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'"/>&nbsp;%</td>';
  269. print '</div><div class="inline-block" style="padding-right: 20px">';
  270. print img_weather($text,'weather-few-clouds.png',$options);
  271. print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL1" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'"/>&nbsp;%</td>';
  272. print '</div><div class="inline-block" style="padding-right: 20px">';
  273. print img_weather($text,'weather-clouds.png',$options);
  274. print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL2" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'"/>&nbsp;%</td>';
  275. print '</div><div class="inline-block" style="padding-right: 20px">';
  276. print img_weather($text,'weather-many-clouds.png',$options);
  277. print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL3" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'"/>&nbsp;%</td>';
  278. print '</div>';
  279. print '</div>';
  280. print '</div>';
  281. ?>
  282. <script type="text/javascript">
  283. $(document).ready(function() {
  284. $("#change_mode").click(function() {
  285. var use_percent = $("#MAIN_USE_METEO_WITH_PERCENTAGE");
  286. var str_mode_std = "<?php print $str_mode_std; ?>";
  287. var str_mode_percentage = "<?php print $str_mode_percentage; ?>";
  288. if(use_percent.val() == 1) {
  289. use_percent.val(0);
  290. $("#standard").show();
  291. $("#percentage").hide();
  292. $(this).html(str_mode_std);
  293. } else {
  294. use_percent.val(1);
  295. $("#standard").hide();
  296. $("#percentage").show();
  297. $(this).html(str_mode_percentage);
  298. }
  299. });
  300. });
  301. </script>
  302. <?php
  303. } else {
  304. if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
  305. print '<div>';
  306. print '<div class="inline-block" style="padding-right: 20px">';
  307. print img_weather($text,'weather-clear.png',$options);
  308. print '= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'&nbsp;%</td>';
  309. print '</div><div class="inline-block" style="padding-right: 20px">';
  310. print img_weather($text,'weather-few-clouds.png',$options);
  311. print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'&nbsp;%</td>';
  312. print '</div><div class="inline-block" style="padding-right: 20px">';
  313. print img_weather($text,'weather-clouds.png',$options);
  314. print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'&nbsp;%</td>';
  315. print '</div><div class="inline-block" style="padding-right: 20px">';
  316. print img_weather($text,'weather-many-clouds.png',$options);
  317. print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>';
  318. print '</div><div class="inline-block" style="padding-right: 20px">';
  319. print img_weather($text,'weather-storm.png',$options);
  320. print '&gt; '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>';
  321. print '</div>';
  322. print '</div>';
  323. } else {
  324. print '<div>';
  325. print '<div class="inline-block" style="padding-right: 20px">';
  326. print img_weather($text,'weather-clear.png',$options);
  327. print '= '.$level0;
  328. print '</div><div class="inline-block" style="padding-right: 20px">';
  329. print img_weather($text,'weather-few-clouds.png',$options);
  330. print '&lt;= '.$level1;
  331. print '</div><div class="inline-block" style="padding-right: 20px">';
  332. print img_weather($text,'weather-clouds.png',$options);
  333. print '&lt;= '.$level2;
  334. print '</div><div class="inline-block" style="padding-right: 20px">';
  335. print img_weather($text,'weather-many-clouds.png',$options);
  336. print '&lt;= '.$level3;
  337. print '</div><div class="inline-block" style="padding-right: 20px">';
  338. print img_weather($text,'weather-storm.png',$options);
  339. print '&gt; '.$level3;
  340. print '</div>';
  341. print '</div>';
  342. }
  343. }
  344. print '</div>';
  345. if($action == 'edit') {
  346. print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
  347. print '<br></form>';
  348. } else {
  349. // Boutons d'action
  350. print '<br><div class="tabsAction">';
  351. print '<a class="butAction" href="delais.php?action=edit">'.$langs->trans("Modify").'</a></div>';
  352. }
  353. // End of page
  354. llxFooter();
  355. $db->close();