diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 79e99c87c4c..2f4f772fca0 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -707,4 +707,37 @@ class PaymentSocialContribution extends CommonObject return $result; } + + + /** + * Return if object was dispatched into bookkeeping + * + * @return int <0 if KO, 0=no, 1=yes + */ + public function getVentilExportCompta() + { + $alreadydispatched = 0; + + $type = 'bank'; + + $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".$this->bank_line; + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($obj) + { + $alreadydispatched = $obj->nb; + } + } else { + $this->error = $this->db->lasterror(); + return -1; + } + + if ($alreadydispatched) + { + return 1; + } + return 0; + } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 434942b0f5c..e67269b71ba 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1781,7 +1781,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi } // Add if object was dispatched "into accountancy" - if (!empty($conf->accounting->enabled) && in_array($object->element, array('bank', 'facture', 'invoice', 'invoice_supplier', 'expensereport', 'payment_various'))) + if (!empty($conf->accounting->enabled) && in_array($object->element, array('bank', 'paiementcharge', 'facture', 'invoice', 'invoice_supplier', 'expensereport', 'payment_various'))) { // Note: For 'chargesociales', 'salaries'... this is the payments that are dispatched (so element = 'bank') if (method_exists($object, 'getVentilExportCompta'))