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 '
'; print ''; print ''; + print ''; print ''; print dol_get_fiche_head(); @@ -332,7 +357,7 @@ if ($action == 'create') { if (isModEnabled('contrat')) { $formcontract = new FormContract($db); print "".$langs->trans("Contract").""; - $contractid = GETPOST('contractid') ?GETPOST('contractid') : $object->fk_contract; + $contractid = GETPOST('contractid') ? GETPOST('contractid') : (!empty($object->fk_contract) ? $object->fk_contract : 0) ; $numcontract = $formcontract->select_contract($object->thirdparty->id, $contractid, 'contracttid'); print ""; } @@ -357,7 +382,7 @@ if ($action == 'create') { // First date of execution for cron print "".$langs->trans('NextDateToExecution').""; - if ($date_next_execution != "") { + if (empty($date_next_execution)) { $date_next_execution = (GETPOST('remonth') ? dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')) : -1); } print $form->selectDate($date_next_execution, '', 1, 1, '', "add", 1, 1); @@ -763,22 +788,22 @@ if ($action == 'create') { } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity = ".$conf->entity; - if ($socid) { + if (!empty($socid)) { $sql .= " AND s.rowid = ".((int) $socid); } if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } - if ($search_ref) { + if (!empty($search_ref)) { $sql .= natural_search('f.titre', $search_ref); } - if ($search_societe) { + if (!empty($search_societe)) { $sql .= natural_search('s.nom', $search_societe); } - if ($search_frequency == '1') { + if (!empty($search_frequency) && $search_frequency == '1') { $sql .= ' AND f.frequency > 0'; } - if ($search_frequency == '0') { + if (!empty($search_frequency) && $search_frequency == '0') { $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)'; } diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 89205de02d5..aff1076eda5 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1642,7 +1642,7 @@ if ($action == 'create') { // Create intervention model if ($conf->global->MAIN_FEATURES_LEVEL >= 1 && $object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer && (count($object->lines) > 0)) { print '
'; - print ''.$langs->trans("ChangeIntoRepeatableIntervention").''; + print ''.$langs->trans("ChangeIntoRepeatableIntervention").''; print '
'; } diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index 96ef9e97314..6f9beb5d051 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -234,7 +234,7 @@ class FichinterRec extends Fichinter 0, $fichintsrc->lines[$i]->product_type, $fichintsrc->lines[$i]->special_code, - $fichintsrc->lines[$i]->label, + !empty($fichintsrc->lines[$i]->label) ? $fichintsrc->lines[$i]->label : "", $fichintsrc->lines[$i]->fk_unit ); @@ -304,10 +304,10 @@ class FichinterRec extends Fichinter $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->user_author = $obj->fk_user_author; - $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; // deprecated - $this->rang = $obj->rang; - $this->special_code = $obj->special_code; + $this->model_pdf = !empty($obj->model_pdf) ? $obj->model_pdf : ""; + $this->modelpdf = !empty($obj->model_pdf) ? $obj->model_pdf : ""; // deprecated + $this->rang = !empty($obj->rang) ? $obj->rang : ""; + $this->special_code = !empty($obj->special_code) ? $obj->special_code : ""; $this->frequency = $obj->frequency; $this->unit_frequency = $obj->unit_frequency; $this->date_when = $this->db->jdate($obj->date_when); @@ -384,9 +384,9 @@ class FichinterRec extends Fichinter $line->subprice = $objp->subprice; $line->tva_tx = $objp->tva_tx; $line->remise_percent = $objp->remise_percent; - $line->fk_remise_except = $objp->fk_remise_except; + $line->fk_remise_except = !empty($objp->fk_remise_except) ? $objp->fk_remise_except : ""; $line->fk_product = $objp->fk_product; - $line->info_bits = $objp->info_bits; + $line->info_bits = !empty($objp->info_bits) ? $objp->info_bits : ""; $line->total_ht = $objp->total_ht; $line->total_tva = $objp->total_tva; $line->total_ttc = $objp->total_ttc; diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index 162afb68077..59c3ba83ee1 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -288,11 +288,11 @@ foreach ($data as $val) { print ''; print ' 0 ? '&userid='.$userid : '').'">'.$year.''; print ''.$val['nb'].''; - print ''.round($val['nb_diff']).''; + print ''.(isset($val['nb_diff']) ? round($val['nb_diff']): "0").'%'; print ''.price(price2num($val['total'], 'MT'), 1).''; - print ''.round($val['total_diff']).''; + print ''.(isset($val['total_diff']) ? round($val['total_diff']) : "0").'%'; print ''.price(price2num($val['avg'], 'MT'), 1).''; - print ''.round($val['avg_diff']).''; + print ''.(isset($val['avg_diff']) ? round($val['avg_diff']) : "0").'%'; print ''; $oldyear = $year; }