From db6ed7a646f0c7f84e33927cacb96379bedcff06 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Jul 2020 13:40:33 +0200 Subject: [PATCH] FIX Navigation from bank receipts --- .../bank/account_statement_document.php | 65 +++++++++++++++++-- htdocs/compta/bank/document.php | 6 -- htdocs/compta/bank/releve.php | 18 ++--- 3 files changed, 67 insertions(+), 22 deletions(-) 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 .= ''; + $title = $langs->trans("AccountStatement").' '.$num.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts'); - print load_fiche_titre($title, '', ''); + print load_fiche_titre($title,$morehtmlright, ''); print '
'; print '
'; diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 09cd81d4198..e3863cd2922 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -39,12 +39,6 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); -$mesg = ''; -if (isset($_SESSION['DolMessage'])) { - $mesg = $_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); -} - // Security check if ($user->socid) { $action = ''; diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index ba5896d6d7d..fcf15f473fd 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -247,6 +247,8 @@ if (empty($numref)) $linkback = ''.$langs->trans("BackToList").''; + $morehtmlref = ''; + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); dol_fiche_end(); @@ -362,17 +364,15 @@ if (empty($numref)) dol_fiche_head($head, 'statement', $langs->trans("AccountStatement"), -1, 'account'); - $mesprevnext = ''; - $mesprevnext .= ''; + $morehtmlright = ''; + $morehtmlright .= ''; $title = $langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts'); - print load_fiche_titre($title, $mesprevnext, ''); + print load_fiche_titre($title, $morehtmlright, ''); //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, 0, $nbtotalofrecords, 'bank_account', 0, '', '', 0, 1); print "
";