diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index 2f82b16e1ad..c5e60e0bdba 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -52,7 +52,12 @@ $langs->loadLangs(array("interventions", "admin", "compta", "bills")); // Security check $id = (GETPOST('fichinterid', 'int') ?GETPOST('fichinterid', 'int') : GETPOST('id', 'int')); +$ref = GETPOST('ref', 'alpha'); +$date_next_execution = GETPOST('date_next_execution', 'alpha'); $action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); +$socid = GETPOST('socid', 'int'); if ($user->socid) { $socid = $user->socid; } @@ -62,12 +67,19 @@ if ($action == "create" || $action == "add") { } $result = restrictedArea($user, 'ficheinter', $id, $objecttype); -if ($page == -1) { +// Load variable for pagination +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; } - -$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + $sortorder = GETPOST('sortorder', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -102,6 +114,17 @@ $arrayfields = array( * Actions */ +if ($cancel) { + /*var_dump($cancel);var_dump($backtopage);var_dump($backtopageforcancel);exit;*/ + if (!empty($backtopageforcancel)) { + header("Location: ".$backtopageforcancel); + exit; + } elseif (!empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } + $action = ''; +} // Create predefined intervention if ($action == 'add') { @@ -130,6 +153,8 @@ if ($action == 'add') { setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Date")), null, 'errors'); $action = "create"; $error++; + }else { + $date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear); } if ($nb_gen_max === '') { setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("MaxPeriodNumber")), null, 'errors'); @@ -151,7 +176,6 @@ if ($action == 'add') { $object->nb_gen_max = $nb_gen_max; $object->auto_validate = GETPOST('auto_validate', 'int'); - $date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear); $object->date_when = $date_next_execution; if ($object->create($user) > 0) { @@ -268,6 +292,7 @@ if ($action == 'create') { print '