Fix: Do not show stat on reconciliation if there is no account to reconciliate

This commit is contained in:
Laurent Destailleur 2011-02-03 22:29:09 +00:00
parent 4dc39fb690
commit 73cf059a52
2 changed files with 16 additions and 11 deletions

View File

@ -796,7 +796,7 @@ class Account extends CommonObject
* Load indicators for dashboard (this->nbtodo and this->nbtodolate) * Load indicators for dashboard (this->nbtodo and this->nbtodolate)
* @param user Objet user * @param user Objet user
* @param filteraccountid To get info for a particular account id * @param filteraccountid To get info for a particular account id
* @return int <0 if KO, >0 if OK * @return int <0 if KO, 0=Nothing to show, >0 if OK
*/ */
function load_board($user,$filteraccountid=0) function load_board($user,$filteraccountid=0)
{ {
@ -809,8 +809,8 @@ class Account extends CommonObject
$this->nbtodo=$this->nbtodolate=0; $this->nbtodo=$this->nbtodolate=0;
$sql = "SELECT b.rowid, b.datev as datefin"; $sql = "SELECT b.rowid, b.datev as datefin";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b,";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.rappro=0"; $sql.= " WHERE b.rappro=0";
$sql.= " AND b.fk_account = ba.rowid"; $sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity; $sql.= " AND ba.entity = ".$conf->entity;
@ -821,12 +821,14 @@ class Account extends CommonObject
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$num=$this->db->num_rows($resql);
while ($obj=$this->db->fetch_object($resql)) while ($obj=$this->db->fetch_object($resql))
{ {
$this->nbtodo++; $this->nbtodo++;
if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) $this->nbtodolate++; if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) $this->nbtodolate++;
if ($obj->rappro) $foundaccounttoconciliate++;
} }
return 1; return $num;
} }
else else
{ {

View File

@ -425,13 +425,16 @@ if ($conf->banque->enabled && $user->rights->banque->lire && ! $user->societe_id
include_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php"); include_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php");
$board=new Account($db); $board=new Account($db);
$board->load_board($user); $found=$board->load_board($user);
if ($found > 0)
{
$board->warning_delay=$conf->bank->rappro->warning_delay/60/60/24; $board->warning_delay=$conf->bank->rappro->warning_delay/60/60/24;
$board->label=$langs->trans("TransactionsToConciliate"); $board->label=$langs->trans("TransactionsToConciliate");
$board->url=DOL_URL_ROOT.'/compta/bank/index.php?leftmenu=bank&mainmenu=bank'; $board->url=DOL_URL_ROOT.'/compta/bank/index.php?leftmenu=bank&mainmenu=bank';
$board->img=img_object($langs->trans("TransactionsToConciliate"),"payment"); $board->img=img_object($langs->trans("TransactionsToConciliate"),"payment");
$rowspan++; $rowspan++;
$dashboardlines[]=$board; $dashboardlines[]=$board;
}
} }
// Number of cheque to send // Number of cheque to send