From 3dbe27030e0a431406b89c3146f27b2480b4348d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sun, 6 Mar 2016 12:39:59 +0100 Subject: [PATCH] FIX If all banks account are reconcilable to off, we must not show nb of transactions to reconciles. FIX Switching status reconcile on-off was broken. --- htdocs/compta/bank/card.php | 2 +- htdocs/compta/bank/class/account.class.php | 28 ++++++++++++++++++++++ htdocs/index.php | 6 ++++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 8a2ee5bce35..6a9a67d1c55 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -870,7 +870,7 @@ else $conciliate=$account->canBeConciliated(); if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')'; else if ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')'; - else print '<input type="checkbox" class="flat" name="norappro"'.($account->rappro?'':' checked').'"> '.$langs->trans("DisableConciliation"); + else print '<input type="checkbox" class="flat" name="norappro"'.(($conciliate > 0)?'':' checked="checked"').'"> '.$langs->trans("DisableConciliation"); print '</td></tr>'; // Balance diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index cf38669d554..9747703c58f 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -970,6 +970,34 @@ class Account extends CommonObject } + /** + * Load indicators for dashboard (this->nbtodo and this->nbtodolate) + * + * @return int Nb of account we can reconciliate + */ + public static function countAccountToReconcile() + { + global $db, $conf, $langs; + + if ($user->societe_id) return 0; // protection pour eviter appel par utilisateur externe + + $nb=0; + + $sql = "SELECT COUNT(ba.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; + $sql.= " WHERE ba.rappro > 0 and ba.clos = 0"; + if (empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) $sql.= " AND ba.courant != 2"; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $nb = $obj->nb; + } + else dol_print_error($db); + + return $nb; + } + /** * Return clicable name (with picto eventually) * diff --git a/htdocs/index.php b/htdocs/index.php index 0b6bbbbc4a9..c3771c37121 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -400,7 +400,11 @@ if (! empty($conf->banque->enabled) && $user->rights->banque->lire && ! $user->s { include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $board=new Account($db); - $dashboardlines[] = $board->load_board($user); + $nb = $board::countAccountToReconcile(); + if ($nb > 0) + { + $dashboardlines[] = $board->load_board($user); + } } // Number of cheque to send -- GitLab