diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 8dabe102066..3b0781a9e8a 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -639,10 +639,11 @@ if ($object->id > 0) if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { // Box factures - $tmp = $object->getOutstandingBills(); + $tmp = $object->getOutstandingBills('customer', 0); $outstandingOpened = $tmp['opened']; $outstandingTotal = $tmp['total_ht']; $outstandingTotalIncTax = $tmp['total_ttc']; + $text = $langs->trans("OverAllInvoices"); $link = DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id; $icon = 'bill'; @@ -668,6 +669,24 @@ if ($object->id > 0) $boxstat .= ''.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; $boxstat .= ''; if ($link) $boxstat .= ''; + + $tmp = $object->getOutstandingBills('customer', 1); + $outstandingOpenedLate = $tmp['opened']; + if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) { + $warn = ''; + if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpenedLate) { + $warn = ' ' . img_warning($langs->trans("OutstandingBillReached")); + } + $text = $langs->trans("CurrentOutstandingBillLate"); + $link = DOL_URL_ROOT . '/compta/recap-compta.php?socid=' . $object->id; + $icon = 'bill'; + if ($link) $boxstat .= ''; + $boxstat .= '
'; + $boxstat .= '' . img_object("", $icon) . ' ' . $text . '
'; + $boxstat .= ''.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency) . $warn . ''; + $boxstat .= '
'; + if ($link) $boxstat .= '
'; + } } $parameters = array(); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 9aeef877bab..1ad41c08da0 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -417,6 +417,20 @@ if ($object->id > 0) $boxstat .= ''.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; $boxstat .= ''; if ($link) $boxstat .= ''; + + $tmp = $object->getOutstandingBills('supplier', 1); + $outstandingOpenedLate = $tmp['opened']; + if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) { + $text = $langs->trans("CurrentOutstandingBillLate"); + $link = DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id; + $icon = 'bill'; + if ($link) $boxstat .= ''; + $boxstat .= '
'; + $boxstat .= '' . img_object("", $icon) . ' ' . $text . '
'; + $boxstat .= ''.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency) . $warn . ''; + $boxstat .= '
'; + if ($link) $boxstat .= '
'; + } } $boxstat .= ''; diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 4145d7184c5..98dc451b5bb 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -459,4 +459,5 @@ MulticurrencyUsed=Use Multicurrency MulticurrencyCurrency=Currency InEEC=Europe (EEC) RestOfEurope=Rest of Europe (EEC) -OutOfEurope=Out of Europe (EEC) \ No newline at end of file +OutOfEurope=Out of Europe (EEC) +CurrentOutstandingBillLate=Current outstanding bill late diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index fee36c3ff1b..5efabc066e4 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4092,9 +4092,10 @@ class Societe extends CommonObject * Return amount of bill not paid and total * * @param string $mode 'customer' or 'supplier' + * @param int $late 0 => all invoice, 1=> only late * @return array array('opened'=>Amount, 'total'=>Total amount) */ - public function getOutstandingBills($mode = 'customer') + public function getOutstandingBills($mode = 'customer', $late = 0) { $table = 'facture'; if ($mode == 'supplier') $table = 'facture_fourn'; @@ -4109,6 +4110,9 @@ class Societe extends CommonObject if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, type, fk_statut as status, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; else $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut as status, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; $sql .= " WHERE fk_soc = ".$this->id; + if (!empty($late)) { + $sql .= " AND date_lim_reglement < '".$this->db->idate(dol_now())."'"; + } if ($mode == 'supplier') { $sql .= " AND entity IN (".getEntity('facture_fourn').")"; } else {