diff --git a/htdocs/compta/bank/account_statement_document.php b/htdocs/compta/bank/account_statement_document.php index 767c8f8709b..575986efee0 100644 --- a/htdocs/compta/bank/account_statement_document.php +++ b/htdocs/compta/bank/account_statement_document.php @@ -41,12 +41,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $num = (GETPOST('num', 'alpha') ? GETPOST('num', 'alpha') : GETPOST('sectionid', 'alpha')); - -$mesg = ''; -if (isset($_SESSION['DolMessage'])) { - $mesg = $_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); -} +$numref = $num; // Security check if ($user->socid) { @@ -75,6 +70,55 @@ if ($id > 0 || !empty($ref)) $object->fetch($id, $ref); $result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', ''); +// Define number of receipt to show (current, previous or next one ?) +$found = false; +if ($_GET["rel"] == 'prev') +{ + // Recherche valeur pour num = numero releve precedent + $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 .= " ORDER BY b.num_releve DESC"; + + dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $numrows = $db->num_rows($resql); + if ($numrows > 0) + { + $obj = $db->fetch_object($resql); + $numref = $obj->num; + $found = true; + } + } +} elseif ($_GET["rel"] == 'next') +{ + // Recherche valeur pour num = numero releve precedent + $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 .= " ORDER BY b.num_releve ASC"; + + dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $numrows = $db->num_rows($resql); + if ($numrows > 0) + { + $obj = $db->fetch_object($resql); + $numref = $obj->num; + $found = true; + } + } +} else { + // On veut le releve num + $found = true; +} + /* * Actions @@ -115,8 +159,15 @@ if ($id > 0 || !empty($ref)) { $totalsize += $file['size']; } + $morehtmlright = ''; + $morehtmlright .= '