delais.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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 <https://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. array(
  106. 'code' => 'MAIN_DELAY_MEMBERS_SHIFT',
  107. 'img' => 'user'
  108. )
  109. ),
  110. 'expensereport' => array(
  111. array(
  112. 'code' => 'MAIN_DELAY_EXPENSEREPORTS',
  113. 'img' => 'trip'
  114. ),
  115. /* TODO Enable this
  116. array(
  117. 'code' => 'MAIN_DELAY_EXPENSEREPORTS_TO_PAY',
  118. 'img' => 'trip'
  119. )*/
  120. ),
  121. 'holiday' => array(
  122. array(
  123. 'code' => 'MAIN_DELAY_HOLIDAYS',
  124. 'img' => 'holiday'
  125. ),
  126. ),
  127. );
  128. $labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly"));
  129. if (!isset($conf->global->MAIN_DELAY_PROJECT_TO_CLOSE)) {
  130. $conf->global->MAIN_DELAY_PROJECT_TO_CLOSE = 7; // Must be same value than into conf.class.php
  131. }
  132. if (!isset($conf->global->MAIN_DELAY_TASKS_TODO)) {
  133. $conf->global->MAIN_DELAY_TASKS_TODO = 7; // Must be same value than into conf.class.php
  134. }
  135. if (!isset($conf->global->MAIN_DELAY_MEMBERS)) {
  136. $conf->global->MAIN_DELAY_MEMBERS = 0; // Must be same value than into conf.class.php
  137. }
  138. if (!isset($conf->global->MAIN_DELAY_ACTIONS_TODO)) {
  139. $conf->global->MAIN_DELAY_ACTIONS_TODO = 7; // Must be same value than into conf.class.php
  140. }
  141. if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
  142. $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
  143. }
  144. if (!isset($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)) {
  145. $conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS = 7;
  146. }
  147. if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
  148. $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
  149. }
  150. if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
  151. $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
  152. }
  153. if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
  154. $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
  155. }
  156. /*
  157. * Actions
  158. */
  159. if ($action == 'update')
  160. {
  161. foreach ($modules as $module => $delays)
  162. {
  163. if (!empty($conf->$module->enabled))
  164. {
  165. foreach ($delays as $delay)
  166. {
  167. if (GETPOST($delay['code']) != '')
  168. {
  169. dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity);
  170. }
  171. }
  172. }
  173. }
  174. dolibarr_set_const($db, "MAIN_DISABLE_METEO", $_POST["MAIN_DISABLE_METEO"], 'chaine', 0, '', $conf->entity);
  175. dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity);
  176. // For update value with percentage
  177. $plus = '';
  178. if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE';
  179. // Update values
  180. for ($i = 0; $i < 4; $i++) {
  181. 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);
  182. }
  183. }
  184. /*
  185. * View
  186. */
  187. $form = new Form($db);
  188. llxHeader();
  189. print load_fiche_titre($langs->trans("DelaysOfToleranceBeforeWarning"), '', 'title_setup');
  190. print '<span class="opacitymedium">'.$langs->transnoentities("DelaysOfToleranceDesc", img_warning('default', '', 'pictowarning nopaddingleft'));
  191. print " ".$langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php')."</span><br>\n";
  192. print "<br>\n";
  193. if ($action == 'edit')
  194. {
  195. print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="form_index">';
  196. print '<input type="hidden" name="token" value="'.newToken().'">';
  197. print '<input type="hidden" name="action" value="update">';
  198. print '<table class="noborder centpercent">';
  199. print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
  200. foreach ($modules as $module => $delays)
  201. {
  202. if (!empty($conf->$module->enabled))
  203. {
  204. foreach ($delays as $delay)
  205. {
  206. $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0);
  207. print '<tr class="oddeven">';
  208. print '<td width="20px">'.img_object('', $delay['img']).'</td>';
  209. print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td><td>';
  210. print '<input class="right maxwidth75" type="number" name="'.$delay['code'].'" value="'.$value.'"> '.$langs->trans("days").'</td></tr>';
  211. }
  212. }
  213. }
  214. print '</table>';
  215. print '<br>';
  216. // Show if meteo is enabled
  217. print '<table class="noborder centpercent">';
  218. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
  219. print '<tr class="oddeven">';
  220. print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
  221. print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO) ? 0 : $conf->global->MAIN_DISABLE_METEO));
  222. print '</td></tr>';
  223. print '</table>';
  224. }
  225. else
  226. {
  227. /*
  228. * Show parameters
  229. */
  230. print '<table class="noborder centpercent">';
  231. print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
  232. foreach ($modules as $module => $delays)
  233. {
  234. if (!empty($conf->$module->enabled))
  235. {
  236. foreach ($delays as $delay)
  237. {
  238. $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0);
  239. print '<tr class="oddeven">';
  240. print '<td width="20px">'.img_object('', $delay['img']).'</td>';
  241. print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td>';
  242. print '<td class="right">'.$value.' '.$langs->trans("days").'</td></tr>';
  243. }
  244. }
  245. }
  246. print '</table>';
  247. print '<br>';
  248. // Show if meteo is enabled
  249. print '<table class="noborder centpercent">';
  250. print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
  251. print '<tr class="oddeven">';
  252. print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
  253. print $labelmeteo[$conf->global->MAIN_DISABLE_METEO];
  254. print '</td></tr>';
  255. print '</table>';
  256. }
  257. print '<br>';
  258. // Show logo for weather
  259. print '<span class="opacitymedium">'.$langs->trans("DescWeather").'</span> ';
  260. if ($action == 'edit') {
  261. $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod'));
  262. $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod'));
  263. if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std;
  264. else $str_mode_enabled = $str_mode_percentage;
  265. print '<a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>';
  266. print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.$conf->global->MAIN_USE_METEO_WITH_PERCENTAGE.'" />';
  267. print '<br><br>';
  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. $offset = 0;
  274. $cursor = 10; // By default
  275. //if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
  276. //if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP;
  277. $level0 = $offset; if (!empty($conf->global->MAIN_METEO_LEVEL0)) $level0 = $conf->global->MAIN_METEO_LEVEL0;
  278. $level1 = $offset + 1 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL1)) $level1 = $conf->global->MAIN_METEO_LEVEL1;
  279. $level2 = $offset + 2 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL2)) $level2 = $conf->global->MAIN_METEO_LEVEL2;
  280. $level3 = $offset + 3 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL3)) $level3 = $conf->global->MAIN_METEO_LEVEL3;
  281. $text = ''; $options = 'class="valignmiddle" height="60px"';
  282. if ($action == 'edit') {
  283. print '<div id="standard" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>';
  284. print '<div>';
  285. print '<div class="inline-block" style="padding-right: 20px">';
  286. print img_weather($text, 0, $options);
  287. print '= <input type="text" size="2" name="MAIN_METEO_LEVEL0" value="'.$level0.'"/></td>';
  288. print '</div><div class="inline-block" style="padding-right: 20px">';
  289. print img_weather($text, 1, $options);
  290. print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL1" value="'.$level1.'"/></td>';
  291. print '</div><div class="inline-block" style="padding-right: 20px">';
  292. print img_weather($text, 2, $options);
  293. print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL2" value="'.$level2.'"/></td>';
  294. print '</div><div class="inline-block" style="padding-right: 20px">';
  295. print img_weather($text, 3, $options);
  296. print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL3" value="'.$level3.'"/></td>';
  297. print '</div>';
  298. print '</div>';
  299. print '</div>';
  300. print '<div id="percentage" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>';
  301. print '<div>';
  302. print '<div class="inline-block" style="padding-right: 20px">';
  303. print img_weather($text, 0, $options);
  304. print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL0" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'"/>&nbsp;%</td>';
  305. print '</div><div class="inline-block" style="padding-right: 20px">';
  306. print img_weather($text, 1, $options);
  307. print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL1" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'"/>&nbsp;%</td>';
  308. print '</div><div class="inline-block" style="padding-right: 20px">';
  309. print img_weather($text, 2, $options);
  310. print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL2" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'"/>&nbsp;%</td>';
  311. print '</div><div class="inline-block" style="padding-right: 20px">';
  312. print img_weather($text, 3, $options);
  313. print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL3" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'"/>&nbsp;%</td>';
  314. print '</div>';
  315. print '</div>';
  316. print '</div>';
  317. ?>
  318. <script type="text/javascript">
  319. $(document).ready(function() {
  320. $("#change_mode").click(function() {
  321. var use_percent = $("#MAIN_USE_METEO_WITH_PERCENTAGE");
  322. var str_mode_std = "<?php print $str_mode_std; ?>";
  323. var str_mode_percentage = "<?php print $str_mode_percentage; ?>";
  324. if(use_percent.val() == 1) {
  325. use_percent.val(0);
  326. $("#standard").show();
  327. $("#percentage").hide();
  328. $(this).html(str_mode_std);
  329. } else {
  330. use_percent.val(1);
  331. $("#standard").hide();
  332. $("#percentage").show();
  333. $(this).html(str_mode_percentage);
  334. }
  335. });
  336. });
  337. </script>
  338. <?php
  339. } else {
  340. if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
  341. print '<div>';
  342. print '<div class="inline-block" style="padding-right: 20px">';
  343. print img_weather($text, 0, $options);
  344. print '= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'&nbsp;%</td>';
  345. print '</div><div class="inline-block" style="padding-right: 20px">';
  346. print img_weather($text, 1, $options);
  347. print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'&nbsp;%</td>';
  348. print '</div><div class="inline-block" style="padding-right: 20px">';
  349. print img_weather($text, 2, $options);
  350. print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'&nbsp;%</td>';
  351. print '</div><div class="inline-block" style="padding-right: 20px">';
  352. print img_weather($text, 3, $options);
  353. print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>';
  354. print '</div><div class="inline-block" style="padding-right: 20px">';
  355. print img_weather($text, 4, $options);
  356. print '&gt; '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>';
  357. print '</div>';
  358. print '</div>';
  359. } else {
  360. print '<div>';
  361. print '<div class="inline-block" style="padding-right: 20px">';
  362. print img_weather($text, 0, $options);
  363. print '= '.$level0;
  364. print '</div><div class="inline-block" style="padding-right: 20px">';
  365. print img_weather($text, 1, $options);
  366. print '&lt;= '.$level1;
  367. print '</div><div class="inline-block" style="padding-right: 20px">';
  368. print img_weather($text, 2, $options);
  369. print '&lt;= '.$level2;
  370. print '</div><div class="inline-block" style="padding-right: 20px">';
  371. print img_weather($text, 3, $options);
  372. print '&lt;= '.$level3;
  373. print '</div><div class="inline-block" style="padding-right: 20px">';
  374. print img_weather($text, 4, $options);
  375. print '&gt; '.$level3;
  376. print '</div>';
  377. print '</div>';
  378. }
  379. }
  380. print '</div>';
  381. if ($action == 'edit') {
  382. print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
  383. print '<br></form>';
  384. } else {
  385. print '<br><div class="tabsAction">';
  386. print '<a class="butAction" href="delais.php?action=edit">'.$langs->trans("Modify").'</a></div>';
  387. }
  388. // End of page
  389. llxFooter();
  390. $db->close();