Correction bug 14244 Probleme d'affichage lorsque le compte ne

contient aucune lignes a rapprocher
This commit is contained in:
Rodolphe Quiedeville 2005-08-21 15:22:46 +00:00
parent 811810619c
commit feddb25985

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -54,15 +54,15 @@ if ($_POST["action"] == 'rappro')
$sql.= " fk_user_rappro=".$user->id; $sql.= " fk_user_rappro=".$user->id;
$sql.= " WHERE rowid=".$_POST["rowid"]; $sql.= " WHERE rowid=".$_POST["rowid"];
$result = $db->query($sql); $resql = $db->query($sql);
if ($result) if ($resql)
{ {
if ($cat1 && $_POST["action"]) if ($cat1 && $_POST["action"])
{ {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES ($rowid, $cat1)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES ($rowid, $cat1)";
$result = $db->query($sql); $resql = $db->query($sql);
if ($result) if ($resql)
{ {
$db->commit(); $db->commit();
} }
@ -93,25 +93,25 @@ if ($_POST["action"] == 'rappro')
*/ */
if ($_GET["action"] == 'del') { if ($_GET["action"] == 'del') {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank WHERE rowid=".$_GET["rowid"]; $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank WHERE rowid=".$_GET["rowid"];
$result = $db->query($sql); $resql = $db->query($sql);
if (! $result) { if (! $resql) {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
} }
$sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."bank_categ ORDER BY label"; $sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."bank_categ ORDER BY label";
$result = $db->query($sql); $resql = $db->query($sql);
$options=""; $options="";
if ($result) { if ($resql) {
$var=True; $var=True;
$num = $db->num_rows($result); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) { while ($i < $num) {
if ($options == "") { $options = "<option value=\"0\" selected>&nbsp;</option>"; } if ($options == "") { $options = "<option value=\"0\" selected>&nbsp;</option>"; }
$obj = $db->fetch_object($result); $obj = $db->fetch_object($resql);
$options .= "<option value=\"$obj->rowid\">$obj->label</option>\n"; $i++; $options .= "<option value=\"$obj->rowid\">$obj->label</option>\n"; $i++;
} }
$db->free($result); $db->free($resql);
} }
@ -126,19 +126,11 @@ $sql .= " FROM ".MAIN_DB_PREFIX."bank as b WHERE rappro=0 AND fk_account=".$_GET
$sql .= " ORDER BY dateo"; $sql .= " ORDER BY dateo";
$sql .= " ASC LIMIT ".$conf->liste_limit; $sql .= " ASC LIMIT ".$conf->liste_limit;
$result = $db->query($sql); $resql = $db->query($sql);
if ($result) if ($resql)
{ {
$var=True; $var=True;
$num = $db->num_rows($result); $num = $db->num_rows($resql);
if ($num == 0)
{
header("Location: /compta/bank/account.php?account=".$_GET["account"]);
exit;
}
else
{
print_titre('Rapprochement compte bancaire : <a href="account.php?account='.$_GET["account"].'">'.$acct->label.'</a>'); print_titre('Rapprochement compte bancaire : <a href="account.php?account='.$_GET["account"].'">'.$acct->label.'</a>');
print '<br>'; print '<br>';
@ -156,14 +148,14 @@ if ($result)
$sql.= " ORDER BY num_releve DESC"; $sql.= " ORDER BY num_releve DESC";
$sql.= " LIMIT ".($nbmax+1); $sql.= " LIMIT ".($nbmax+1);
print $langs->trans("LastAccountStatements").' : '; print $langs->trans("LastAccountStatements").' : ';
$resultr=$db->query($sql); $resqlr=$db->query($sql);
if ($resultr) if ($resqlr)
{ {
$numr=$db->num_rows($resultr); $numr=$db->num_rows($resqlr);
$i=0; $i=0;
while (($i < $numr) && ($i < $nbmax)) while (($i < $numr) && ($i < $nbmax))
{ {
$objr = $db->fetch_object($resultr); $objr = $db->fetch_object($resqlr);
$last_releve = $objr->num_releve; $last_releve = $objr->num_releve;
$i++; $i++;
$liste='<a href="releve.php?account='.$_GET["account"].'&amp;num='.$objr->num_releve.'">'.$objr->num_releve.'</a> &nbsp; '.$liste; $liste='<a href="releve.php?account='.$_GET["account"].'&amp;num='.$objr->num_releve.'">'.$objr->num_releve.'</a> &nbsp; '.$liste;
@ -179,7 +171,7 @@ if ($result)
} }
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">"; print "<tr class=\"liste_titre\">\n";
print '<td>'.$langs->trans("Date").'</td>'; print '<td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("DateValue").'</td>'; print '<td>'.$langs->trans("DateValue").'</td>';
print '<td>'.$langs->trans("Type").'</td>'; print '<td>'.$langs->trans("Type").'</td>';
@ -189,12 +181,12 @@ if ($result)
print '<td align="center" width="60">'.$langs->trans("Action").'</td>'; print '<td align="center" width="60">'.$langs->trans("Action").'</td>';
print '<td align="center" width="100" colspan="2">'.$langs->trans("AccountStatement").' (Ex: YYYYMM)</td>'; print '<td align="center" width="100" colspan="2">'.$langs->trans("AccountStatement").' (Ex: YYYYMM)</td>';
print "</tr>\n"; print "</tr>\n";
}
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($resql);
$var=!$var; $var=!$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
@ -254,7 +246,8 @@ if ($result)
if ($objp->do <= mktime() ) { if ($objp->do <= mktime() ) {
print "<td align=\"center\">"; print "<td align=\"center\">";
print "<input class=\"flat\" name=\"num_releve\" type=\"text\" value=\"\" size=\"8\">"; print "<input class=\"flat\" name=\"num_releve\" type=\"text\" value=\"\" size=\"8\">";
if ($options) { if ($options)
{
print "<br><select name=\"cat1\">$options"; print "<br><select name=\"cat1\">$options";
print "</select>"; print "</select>";
} }
@ -262,24 +255,27 @@ if ($result)
print "<td align=\"center\"><input class=\"button\" type=\"submit\" value=\"".$langs->trans("Rapprocher")."\">"; print "<td align=\"center\"><input class=\"button\" type=\"submit\" value=\"".$langs->trans("Rapprocher")."\">";
print "</td>"; print "</td>";
} }
else { else
{
print "<td align=\"left\" colspan=\"2\">"; print "<td align=\"left\" colspan=\"2\">";
print "Ecriture future. Ne peut pas encore être rapprochée."; print "Ecriture future. Ne peut pas encore être rapprochée.";
print "</td>"; print "</td>";
} }
print "</tr>"; print "</tr>\n";
print "</form>\n";
print "</form>";
$i++; $i++;
} }
$db->free($result); $db->free($resql);
if ($num != 0) { if ($num != 0)
print "</table>"; {
print "</table>\n";
} }
} else { }
else
{
dolibarr_print_error($db); dolibarr_print_error($db);
} }