From 0cb04d14d7f4ad23a630e73bfd570bd219131bd5 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 15 Oct 2020 12:20:37 +0200 Subject: [PATCH 1/2] NEW: Thirdparty module : box on customer/supplier tab for outsantding amount late --- htdocs/comm/card.php | 22 +++++++++++++++++++++- htdocs/fourn/card.php | 15 +++++++++++++++ htdocs/langs/en_US/companies.lang | 3 ++- htdocs/societe/class/societe.class.php | 6 +++++- 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 8dabe102066..cdef197cc77 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,25 @@ 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..37a2115e62f 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -417,6 +417,21 @@ 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 { From cd5201e40a4022963d1cd5c413b9f6b0c4c78eb6 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 15 Oct 2020 10:24:00 +0000 Subject: [PATCH 2/2] Fixing style errors. --- htdocs/comm/card.php | 5 ++--- htdocs/fourn/card.php | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index cdef197cc77..3b0781a9e8a 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -639,7 +639,7 @@ if ($object->id > 0) if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { // Box factures - $tmp = $object->getOutstandingBills('customer',0); + $tmp = $object->getOutstandingBills('customer', 0); $outstandingOpened = $tmp['opened']; $outstandingTotal = $tmp['total_ht']; $outstandingTotalIncTax = $tmp['total_ttc']; @@ -670,7 +670,7 @@ if ($object->id > 0) $boxstat .= ''; if ($link) $boxstat .= ''; - $tmp = $object->getOutstandingBills('customer',1); + $tmp = $object->getOutstandingBills('customer', 1); $outstandingOpenedLate = $tmp['opened']; if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) { $warn = ''; @@ -687,7 +687,6 @@ if ($object->id > 0) $boxstat .= ''; if ($link) $boxstat .= ''; } - } $parameters = array(); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 37a2115e62f..1ad41c08da0 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -418,7 +418,7 @@ if ($object->id > 0) $boxstat .= ''; if ($link) $boxstat .= ''; - $tmp = $object->getOutstandingBills('supplier',1); + $tmp = $object->getOutstandingBills('supplier', 1); $outstandingOpenedLate = $tmp['opened']; if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) { $text = $langs->trans("CurrentOutstandingBillLate"); @@ -431,7 +431,6 @@ if ($object->id > 0) $boxstat .= ''; if ($link) $boxstat .= ''; } - } $boxstat .= '';