FIX Navigation from bank receipts

This commit is contained in:
Laurent Destailleur 2020-07-10 13:40:33 +02:00
parent 2dc1008663
commit db6ed7a646
3 changed files with 67 additions and 22 deletions

View File

@ -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 .= '<div class="pagination"><ul>';
$morehtmlright .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=prev&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-left" title="'.dol_escape_htmltag($langs->trans("Previous")).'"></i></a></li>';
$morehtmlright .= '<li class="pagination"><span class="active">'.$langs->trans("AccountStatement")." ".$numref.'</span></li>';
$morehtmlright .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=next&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-right" title="'.dol_escape_htmltag($langs->trans("Next")).'"></i></a></li>';
$morehtmlright .= '</ul></div>';
$title = $langs->trans("AccountStatement").' '.$num.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts');
print load_fiche_titre($title, '', '');
print load_fiche_titre($title,$morehtmlright, '');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';

View File

@ -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 = '';

View File

@ -247,6 +247,8 @@ if (empty($numref))
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$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 .= '<div class="pagination"><ul>';
$mesprevnext .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=prev&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-left" title="'.dol_escape_htmltag($langs->trans("Previous")).'"></i></a></li>';
//$mesprevnext.=' &nbsp; ';
$mesprevnext .= '<li class="pagination"><span class="active">'.$langs->trans("AccountStatement")." ".$numref.'</span></li>';
//$mesprevnext.=' &nbsp; ';
$mesprevnext .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=next&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-right" title="'.dol_escape_htmltag($langs->trans("Next")).'"></i></a></li>';
$mesprevnext .= '</ul></div>';
$morehtmlright = '';
$morehtmlright .= '<div class="pagination"><ul>';
$morehtmlright .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=prev&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-left" title="'.dol_escape_htmltag($langs->trans("Previous")).'"></i></a></li>';
$morehtmlright .= '<li class="pagination"><span class="active">'.$langs->trans("AccountStatement")." ".$numref.'</span></li>';
$morehtmlright .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=next&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-right" title="'.dol_escape_htmltag($langs->trans("Next")).'"></i></a></li>';
$morehtmlright .= '</ul></div>';
$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 "<form method=\"post\" action=\"releve.php\">";