diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 3a73861f2e9..4fed43d5c75 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -155,7 +155,7 @@ $formaccounting = new FormAccounting($db); $form = new Form($db); if (!in_array($action, array('delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOST('page', 'alpha') == '' && !GETPOSTINT('noreset') && $user->hasRight('accounting', 'mouvements', 'export')) { - if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_accountancy_code_start')) { + if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_mvt_num') && !GETPOST('search_accountancy_code_start')) { $sql = "SELECT date_start, date_end"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear "; if (getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT')) { diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index c9feabd8c86..017b527f105 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -2856,15 +2856,17 @@ class AccountLine extends CommonObjectLine /** * Return if a bank line was dispatched into bookkeeping * - * @return int Return integer <0 if KO, 0=no, 1=yes + * @param int $mode 0=Return nb of record, 1=return the transaction ID (piece_num) + * @return int Return integer <0 if KO, 0=no, 1=yes or ID transaction */ - public function getVentilExportCompta() + public function getVentilExportCompta($mode = 0) { $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 = ".((int) $this->id); + $sql = " SELECT ".($mode ? 'DISTINCT piece_num' : 'COUNT(ab.rowid)')." as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type = '".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->id); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -2877,7 +2879,7 @@ class AccountLine extends CommonObjectLine } if ($alreadydispatched) { - return 1; + return $alreadydispatched; } return 0; } diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 9b69a519d0e..70756cdc05c 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -794,9 +794,10 @@ class PaymentVarious extends CommonObject /** * Return if a various payment linked to a bank line id was dispatched into bookkeeping * - * @return int Return integer <0 if KO, 0=no, 1=yes + * @param int $mode 0=Return nb of record, 1=return the transaction ID (piece_num) + * @return int Return integer <0 if KO, 0=no, 1=yes or ID transaction */ - public function getVentilExportCompta() + public function getVentilExportCompta($mode = 0) { $banklineid = $this->fk_bank; @@ -804,7 +805,8 @@ class PaymentVarious extends CommonObject $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 = ".((int) $banklineid); + $sql = " SELECT ".($mode ? 'DISTINCT piece_num' : 'COUNT(ab.rowid)')." as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type = '".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $banklineid); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -817,7 +819,7 @@ class PaymentVarious extends CommonObject } if ($alreadydispatched) { - return 1; + return $alreadydispatched; } return 0; } diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index 95f3968d84b..6ed7ea54a72 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -116,11 +116,6 @@ $head[$h][1] = $langs->trans("PaymentSocialContribution"); $hselected = (string) $h; $h++; -/*$head[$h][0] = DOL_URL_ROOT.'/compta/payment_sc/info.php?id='.$id; -$head[$h][1] = $langs->trans("Info"); -$h++; -*/ - print dol_get_fiche_head($head, $hselected, $langs->trans("PaymentSocialContribution"), -1, 'payment'); diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 1d9910fec7d..fa8dc5a4da7 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -167,8 +167,6 @@ class PaymentSocialContribution extends CommonObject */ public function create($user, $closepaidcontrib = 0) { - global $conf, $langs; - $error = 0; $now = dol_now(); @@ -812,17 +810,21 @@ class PaymentSocialContribution extends CommonObject /** - * Return if object was dispatched into bookkeeping + * Return if object was dispatched into bookkeeping, or return the array of bookkeeping id. * - * @return int Return integer <0 if KO, 0=no, 1=yes + * @param int $mode 0=Mode to return the nb of record, 1=Mode to return array of ID in bookkeeping table. + * @return int Return integer <0 if KO, 0=no, 1=yes or ID transaction */ - public function getVentilExportCompta() + public function getVentilExportCompta($mode = 0) { $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 = ".((int) $this->bank_line); + $sql = " SELECT ".($mode ? 'DISTINCT piece_num' : 'COUNT(ab.rowid)')." as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab"; + $sql .= " WHERE ab.doc_type = '".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->bank_line); + $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -835,7 +837,7 @@ class PaymentSocialContribution extends CommonObject } if ($alreadydispatched) { - return 1; + return $alreadydispatched; } return 0; } diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index cc2bc4b44a0..45825732d55 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -745,9 +745,10 @@ abstract class CommonInvoice extends CommonObject * Return if an invoice was transferred into accountnancy. * This is true if at least on line was transferred into table accounting_bookkeeping * - * @return int Return integer <0 if KO, 0=no, 1=yes + * @param int $mode 0=Return nb of record, 1=return the transaction ID (piece_num) + * @return int Return integer <0 if KO, 0=no, nb transaction=yes or ID transaction */ - public function getVentilExportCompta() + public function getVentilExportCompta($mode = 0) { $alreadydispatched = 0; @@ -756,8 +757,9 @@ abstract class CommonInvoice extends CommonObject $type = 'supplier_invoice'; } - $sql = " SELECT COUNT(ab.rowid) as nb FROM ".$this->db->prefix()."accounting_bookkeeping as ab"; - $sql .= " WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->id); + $sql = " SELECT ".($mode ? 'DISTINCT piece_num' : 'COUNT(ab.rowid)')." as nb"; + $sql .= " FROM ".$this->db->prefix()."accounting_bookkeeping as ab"; + $sql .= " WHERE ab.doc_type = '".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->id); $resql = $this->db->query($sql); if ($resql) { @@ -771,7 +773,7 @@ abstract class CommonInvoice extends CommonObject } if ($alreadydispatched) { - return 1; + return $alreadydispatched; } return 0; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f45716fb67d..dd7b5986146 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3398,13 +3398,13 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi $morehtmlstatus .= $tmptxt; } - // Add if object was dispatched "into accountancy" + // Say if object was dispatched/transferred "into accountancy" if (isModEnabled('accounting') && 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')) { - $accounted = $object->getVentilExportCompta(); + $accounted = $object->getVentilExportCompta(1); $langs->load("accountancy"); - $morehtmlstatus .= '
'.($accounted > 0 ? $langs->trans("Accounted") : $langs->trans("NotYetAccounted")).''; + $morehtmlstatus .= '
'.($accounted > 0 ? ''.$langs->trans("Accounted").'' : $langs->trans("NotYetAccounted")).''; } } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 50306162967..e4b74798e77 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -2668,17 +2668,19 @@ class ExpenseReport extends CommonObject } /** - * Return if object was dispatched into bookkeeping + * Return if object was dispatched into bookkeeping. * - * @return int Return integer <0 if KO, 0=no, 1=yes + * @param int $mode 0=Return nb of record, 1=return the transaction ID (piece_num) + * @return int Return integer <0 if KO, 0=no, 1=yes */ - public function getVentilExportCompta() + public function getVentilExportCompta($mode = 0) { $alreadydispatched = 0; $type = 'expense_report'; - $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 = ".((int) $this->id); + $sql = " SELECT ".($mode ? 'DISTINCT piece_num' : 'COUNT(ab.rowid)')." as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type = '".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->id); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -2691,7 +2693,7 @@ class ExpenseReport extends CommonObject } if ($alreadydispatched) { - return 1; + return $alreadydispatched; } return 0; } diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 9dc89a5587c..d437ca16b6c 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -197,3 +197,4 @@ XNewLinesConciliated=%s new line(s) conciliated InSepa=SEPA Area CountryIsInSepa=Countries in Sepa area Bank_line=Bank transaction line +BankId=Bank line ID