diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 6bfa9de9926..6d769d4261c 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -735,13 +735,14 @@ class ActionComm extends CommonObject /** * Load object from database * - * @param int $id Id of action to get - * @param string $ref Ref of action to get - * @param string $ref_ext Ref ext to get - * @param string $email_msgid Email msgid - * @return int <0 if KO, >0 if OK + * @param int $id Id of action to get + * @param string $ref Ref of action to get + * @param string $ref_ext Ref ext to get + * @param string $email_msgid Email msgid + * @param string $loadresources 1=Load also resources + * @return int <0 if KO, >0 if OK */ - public function fetch($id, $ref = '', $ref_ext = '', $email_msgid = '') + public function fetch($id, $ref = '', $ref_ext = '', $email_msgid = '', $loadresources = 1) { global $langs; @@ -858,7 +859,11 @@ class ActionComm extends CommonObject $this->event_paid = $obj->event_paid; $this->status = $obj->status; - $this->fetchResources(); + $this->fetch_optionals(); + + if ($loadresources){ + $this->fetchResources(); + } } $this->db->free($resql); } else { diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 756c80e5777..b52e4a3f554 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -6,7 +6,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2017 Alexandre Spangaro - * Copyright (C) 2018 Ferran Marcet + * Copyright (C) 2018-2021 Ferran Marcet * Copyright (C) 2018 Charlene Benke * Copyright (C) 2020 Tobias Sekan * @@ -31,13 +31,6 @@ */ require '../../main.inc.php'; - -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'facture', $facid, ''); - require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -60,6 +53,10 @@ $day = GETPOST('day', 'int'); $month = GETPOST('month', 'int'); $year = GETPOST('year', 'int'); +// Security check +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'facture', $facid, ''); + $search_ref = GETPOST("search_ref", "alpha"); $search_company = GETPOST("search_company", 'alpha'); $search_paymenttype = GETPOST("search_paymenttype"); diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php index 40d36e5e4f6..2ac24706cb6 100644 --- a/htdocs/fourn/paiement/list.php +++ b/htdocs/fourn/paiement/list.php @@ -47,6 +47,9 @@ $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 've $socid = GETPOST('socid', 'int'); +// Security check +if ($user->socid) $socid = $user->socid; + $search_ref = GETPOST('search_ref', 'alpha'); $search_day = GETPOST('search_day', 'int'); $search_month = GETPOST('search_month', 'int'); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 48ee75df62e..a85fdcf2db1 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1073,6 +1073,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as inv ON inv.rowid = il.fk_facture,"; $sql .= " ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; + if (empty($projectidforalltimes)) { $sql .= " AND t.fk_task =".((int) $object->id); } else { @@ -1088,7 +1089,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { $sql .= natural_search('pt.label', $search_task_label); } if ($search_user > 0) { - $sql .= natural_search('t.fk_user', $search_user); + $sql .= natural_search('t.fk_user', $search_user, 2); } if ($search_valuebilled == '1') { $sql .= ' AND t.invoice_id > 0'; @@ -1103,6 +1104,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); + + if (! $resql) { + dol_print_error($db); + exit; + } + $nbtotalofrecords = $db->num_rows($resql); if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0;