diff --git a/htdocs/compta/bank/account_statement_document.php b/htdocs/compta/bank/account_statement_document.php index 575986efee0..29e87ca153b 100644 --- a/htdocs/compta/bank/account_statement_document.php +++ b/htdocs/compta/bank/account_statement_document.php @@ -40,8 +40,7 @@ $id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('account', 'int')); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); -$num = (GETPOST('num', 'alpha') ? GETPOST('num', 'alpha') : GETPOST('sectionid', 'alpha')); -$numref = $num; +$numref = (GETPOST('num', 'alpha') ? GETPOST('num', 'alpha') : GETPOST('sectionid', 'alpha')); // Security check if ($user->socid) { @@ -66,7 +65,11 @@ if (!$sortfield) $sortfield = "name"; $object = new Account($db); -if ($id > 0 || !empty($ref)) $object->fetch($id, $ref); +if ($id > 0 || !empty($ref)) +{ + $result = $object->fetch($id, $ref); + $account = $object->id; // Force the search field on id of account +} $result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', ''); @@ -78,7 +81,7 @@ if ($_GET["rel"] == 'prev') $sql = "SELECT DISTINCT(b.num_releve) as num"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql .= " WHERE b.num_releve < '".$db->escape($numref)."'"; - $sql .= " AND b.fk_account = ".$object->id; + $sql .= " AND b.fk_account = ".$id; $sql .= " ORDER BY b.num_releve DESC"; dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); @@ -99,7 +102,7 @@ if ($_GET["rel"] == 'prev') $sql = "SELECT DISTINCT(b.num_releve) as num"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql .= " WHERE b.num_releve > '".$db->escape($numref)."'"; - $sql .= " AND b.fk_account = ".$object->id; + $sql .= " AND b.fk_account = ".$id; $sql .= " ORDER BY b.num_releve ASC"; dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); @@ -124,12 +127,12 @@ if ($_GET["rel"] == 'prev') * Actions */ -if (!empty($num)) +if (!empty($numref)) { $object->fetch_thirdparty(); - $upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($num); + $upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($numref); } -$backtopage = $_SERVER['PHP_SELF']."?account=".$id."&num=".$num; +$backtopage = $_SERVER['PHP_SELF']."?account=".$id."&num=".$numref; include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; @@ -145,10 +148,10 @@ llxHeader('', $title, $helpurl); if ($id > 0 || !empty($ref)) { if ($object->fetch($id, $ref)) { - $upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($num); + $upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($numref); // Onglets - $head = account_statement_prepare_head($object, $num); + $head = account_statement_prepare_head($object, $numref); dol_fiche_head($head, 'document', $langs->trans("AccountStatement"), -1, 'account'); @@ -166,7 +169,7 @@ if ($id > 0 || !empty($ref)) { $morehtmlright .= '