From 16c81ab331c3e25d682d865ab38325530d0ba000 Mon Sep 17 00:00:00 2001
From: Kamel Khelifa <kkhelifa@open-dsi.fr>
Date: Thu, 20 Mar 2025 15:14:51 +0100
Subject: [PATCH 1/2] =?UTF-8?q?FIX=20-=20Mise=20=C3=A0=20jour=20de=20l'url?=
 =?UTF-8?q?=20par=20d=C3=A9faut=20des=20statuts=20des=20connexions=20Powen?=
 =?UTF-8?q?s=20(https://powens.statuspal.eu/)=20-=20Rajout=20de=20la=20cla?=
 =?UTF-8?q?ss=20'tdoverflowmax100'=20sur=20la=20colonne=20"Type"=20de=20la?=
 =?UTF-8?q?=20liste=20des=20=C3=A9critures=20t=C3=A9l=C3=A9charg=C3=A9es?=
 =?UTF-8?q?=20-=20On=20peut=20maintenant=20continuer=20la=20validation=20d?=
 =?UTF-8?q?'un=20rapprochement=20automatique=20pr=C3=A9alablement=20lanc?=
 =?UTF-8?q?=C3=A9=20-=20Correction=20warning=20php?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ChangeLog.md                      |    8 +-
 VERSION                           |    2 +-
 admin/setup.php                   |    2 +-
 bankrecords.php                   |   34 +-
 class/budgetinsight.class.php     |   30 +
 langs/en_US/banking4dolibarr.lang |    3 +
 langs/fr_FR/banking4dolibarr.lang |    3 +
 prelink.php                       | 1396 ++++++++++++++---------------
 8 files changed, 770 insertions(+), 708 deletions(-)

diff --git a/ChangeLog.md b/ChangeLog.md
index 0324b6f..e877f96 100755
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -3,8 +3,14 @@ Le format du fichier est basé sur [Tenez un ChangeLog](http://keepachangelog.co
 
 ## [Non Distribué]
 
+## [14.0.63] - 20-03-2025
+- Mise à jour de l'url par défaut des statuts des connexions Powens (https://powens.statuspal.eu/)
+- Rajout de la class 'tdoverflowmax100' sur la colonne "Type" de la liste des écritures téléchargées
+- On peut maintenant continuer la validation d'un rapprochement automatique préalablement lancé
+- Correction warning php
+
 ## [14.0.62] - 26-02-2025
-- Ajout d'une option pour choisir le libellé traité lors de la récupération des écritures téléchargées dans le paramètrage des Comptes Bancaires Distants 
+- Ajout d'une option pour choisir le libellé traité lors de la récupération des écritures téléchargées dans le paramètrage des Comptes Bancaires Distants
 
 ## [14.0.61] - 31-01-2025
 - Correction d'acces à l'onglet des écritures téléchargées si l'utilisateur n'a pas de clé d'activation
diff --git a/VERSION b/VERSION
index 27906ba..6a55cb1 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-14.0.62
\ No newline at end of file
+14.0.63
\ No newline at end of file
diff --git a/admin/setup.php b/admin/setup.php
index 11bdf7a..91392e6 100755
--- a/admin/setup.php
+++ b/admin/setup.php
@@ -110,7 +110,7 @@ if (!$error) {
 		$action = 'update_views';
 	} elseif ($action == 'set_others_options') {
 		$value = GETPOST('BANKING4DOLIBARR_URL_POWENS_STATUS', 'alphanohtml');
-		if (empty($value)) $value = 'https://powens-com.statuspal.eu/';
+		if (empty($value)) $value = 'https://powens.statuspal.eu/';
 		$res = dolibarr_set_const($db, 'BANKING4DOLIBARR_URL_POWENS_STATUS', $value, 'chaine', 0, '', $conf->entity);
 		if (!($res > 0)) {
 			$errors[] = $db->lasterror();
diff --git a/bankrecords.php b/bankrecords.php
index b04871c..fd21f8d 100755
--- a/bankrecords.php
+++ b/bankrecords.php
@@ -343,7 +343,7 @@ if ($has_remote_bank_account == 1) {
 	if ($search_duplicate_only) $param .= "&search_duplicate_only=" . urlencode($search_duplicate_only);
 	if ($optioncss != '') $param .= '&optioncss=' . urlencode($optioncss);
 
-// Url de base for form confirm add button, ...
+	// Url de base for form confirm add button, ...
 	$base_url = $_SERVER['PHP_SELF'] . '?restore_lastsearch_values=1' . $param;
 	if ($sortfield) $base_url .= '&sortfield=' . urlencode($sortfield);
 	if ($sortorder) $base_url .= '&sortorder=' . urlencode($sortorder);
@@ -371,6 +371,16 @@ if ($has_remote_bank_account == 1) {
 		}
 
 		if (!$error) {
+			if ($action == 'confirm_b4d_resume_auto_reconcile_bank_records' && $confirm == "yes" && $object->clos == 0 && $user->rights->banque->consolidate) {
+				$force_auto_reconcile = GETPOST('force_auto_reconcile', 'alphanohtml');
+				if (!empty($force_auto_reconcile)) {
+					$action = 'b4d_auto_reconcile_bank_records';
+				} else {
+					header("Location: " . dol_buildpath('/banking4dolibarr/prelink.php', 1) . '?id=' . $id);
+					exit();
+				}
+			}
+
 			if ($remote_bank_account_id > 0 && $action == 'confirm_b4d_refresh_bank_records' && $confirm == "yes" && isset($_SESSION['b4d_token']) && $_SESSION['b4d_token'] == $b4d_token && $object->clos == 0 && $user->rights->banking4dolibarr->bank_records->refresh) {
 				unset($_SESSION['b4d_token']);
 				$date = $last_update_date;
@@ -1099,7 +1109,7 @@ if (!empty($budgetinsight->module_key)) {
 	print '<tr><td>' . $form->textwithpicto($langs->trans("Banking4DolibarrBankAccountUpdateDate"), $langs->trans("Banking4DolibarrBankAccountUpdateDateHelp")) . '</td><td>' .
 		$extrafields->showOutputField('b4d_account_update_date', $object->array_options['options_b4d_account_update_date'], '',
 			$object->table_element) . ' ' . $object->array_options['options_b4d_account_update_status'] .
-		' <a href="' . (!empty($conf->global->BANKING4DOLIBARR_URL_POWENS_STATUS) ? $conf->global->BANKING4DOLIBARR_URL_POWENS_STATUS : 'https://powens-com.statuspal.eu/') . '" target="_blank">' . $langs->trans('Banking4DolibarrPowensStatusPage') . '</a>' .
+		' <a href="' . (!empty($conf->global->BANKING4DOLIBARR_URL_POWENS_STATUS) ? $conf->global->BANKING4DOLIBARR_URL_POWENS_STATUS : 'https://powens.statuspal.eu/') . '" target="_blank">' . $langs->trans('Banking4DolibarrPowensStatusPage') . '</a>' .
 		'</td></tr>';
 
 	print '<tr><td>';
@@ -1186,6 +1196,11 @@ if ($has_remote_bank_account == 1) {
 		}
 		$_SESSION['b4d_token'] = uniqid('', true);
 		$formconfirm = $form->formconfirm($base_url . "&b4d_token=" . $_SESSION['b4d_token'], $langs->trans('Banking4DolibarrRefreshBankRecords'), $langs->trans("Banking4DolibarrConfirmRefreshBankRecords"), 'confirm_b4d_refresh_bank_records', $formquestion, 0, 1, $height, $width);
+	} elseif ($action == 'b4d_resume_auto_reconcile_bank_records' && $object->clos == 0 && $user->rights->banque->consolidate) {
+		$formquestion = array(
+			array('type' => 'checkbox', 'name' => 'force_auto_reconcile', 'label' => $langs->trans('Banking4DolibarrForceAutoReconcileBankRecords')),
+		);
+		$formconfirm = $form->formconfirm($base_url, $langs->trans('Banking4DolibarrResumeAutoReconcileBankRecords'), $langs->trans("Banking4DolibarrConfirmResumeAutoReconcileBankRecords"), 'confirm_b4d_resume_auto_reconcile_bank_records', $formquestion, 0, 1, 250, 600);
 	} elseif ($action == 'b4d_auto_reconcile_bank_records' && $no_cli_process && $object->clos == 0 && $user->rights->banque->consolidate) {
 		$height = 200;
 		$width = 500;
@@ -1437,9 +1452,18 @@ if ($has_remote_bank_account == 1) {
 			}
 		}
 		if ($object->clos == 0 && $user->rights->banque->consolidate && $budgetinsight->hasUnReconliledRecords($id)) {
-			if (empty($conf->global->BANKING4DOLIBARR_DISABLE_BUTTON_AUTORECONCILE)) {
+			$nb_pre_link = $budgetinsight->hasPreLink($id);
+			if ($nb_pre_link < 0) {
+				setEventMessages($budgetinsight->error, $budgetinsight->errors, 'errors');
+			}
+			if ($nb_pre_link > 0) {
+				$icon_autoreconcile = (!empty($conf->global->EASYA_VERSION) || version_compare(DOL_VERSION, "11.0.0") >= 0) ? 'fa-magic' : 'fa-bolt';
+				print '<div class="inline-block divButAction"><a class="butAction" href="' . $base_url . '&token=' . newToken() . '&action=b4d_resume_auto_reconcile_bank_records">' .
+					'<span class="' . $class_fonts_awesome . ' ' . $icon_autoreconcile . ' paddingleftonly">&nbsp;</span>' .
+					$langs->trans('Banking4DolibarrResumeAutoReconcileBankRecords') . ' (' . $nb_pre_link . ')</a></div>';
+			} elseif (empty($conf->global->BANKING4DOLIBARR_DISABLE_BUTTON_AUTORECONCILE)) {
 				$icon_autoreconcile = (!empty($conf->global->EASYA_VERSION) || version_compare(DOL_VERSION, "11.0.0") >= 0) ? 'fa-magic' : 'fa-bolt';
-				print '<div class="inline-block divButAction"><a class="butAction" href="' . $base_url . '&token=' . newToken() . '&action=b4d_auto_reconcile_bank_records" >' .
+				print '<div class="inline-block divButAction"><a class="butAction" href="' . $base_url . '&token=' . newToken() . '&action=b4d_auto_reconcile_bank_records">' .
 					'<span class="' . $class_fonts_awesome . ' ' . $icon_autoreconcile . ' paddingleftonly">&nbsp;</span>' .
 					$langs->trans('Banking4DolibarrAutoReconcileBankRecords') . '</a></div>';
 			}
@@ -1794,7 +1818,7 @@ if ($has_remote_bank_account == 1) {
 		print '</td>';
 //        }
 //        if (!empty($arrayfields['br.record_type']['checked'])) {
-		print '<td class="liste_titre center">';
+		print '<td class="liste_titre center tdoverflowmax100">';
 		print $formdictionary->select_dictionary('banking4dolibarr', 'banking4dolibarrbankrecordtypes', $search_record_type, 'search_record_type', 1, 'code');
 		print '</td>';
 //        }
diff --git a/class/budgetinsight.class.php b/class/budgetinsight.class.php
index 8ecb649..cd882be 100755
--- a/class/budgetinsight.class.php
+++ b/class/budgetinsight.class.php
@@ -2522,6 +2522,36 @@ class BudgetInsight
 		}
 	}
 
+	/**
+	 *  Has pre-linking of the result in the auto link process who require confirm by user
+	 *
+	 * @param   int     $fk_bank_account        ID of the bank account
+	 * @return	int	                            <0 if KO otherwise nb waiting line
+	 */
+	public function hasPreLink($fk_bank_account)
+	{
+		dol_syslog(__METHOD__ . " fk_bank_account=$fk_bank_account", LOG_DEBUG);
+
+		// Check parameters
+		$fk_bank_account = max(0, (int) $fk_bank_account);
+
+		$sql = "SELECT COUNT(*) AS nb FROM " . MAIN_DB_PREFIX . "banking4dolibarr_bank_record_pre_link WHERE fk_bank_account = " . $fk_bank_account;
+
+		$resql = $this->db->query($sql);
+		if (!$resql) {
+			$this->errors[] = 'Error ' . $this->db->lasterror();
+			dol_syslog(__METHOD__ . " SQL: " . $sql . "; Error: " . $this->db->lasterror(), LOG_ERR);
+			return -1;
+		}
+
+		$nb = 0;
+		if ($obj = $this->db->fetch_object($resql)) {
+			$nb = (int) $obj->nb;
+		}
+
+		return $nb;
+	}
+
 	/**
 	 *  Get all manual reconciliation type
 	 *
diff --git a/langs/en_US/banking4dolibarr.lang b/langs/en_US/banking4dolibarr.lang
index a5cbfdb..66a201f 100755
--- a/langs/en_US/banking4dolibarr.lang
+++ b/langs/en_US/banking4dolibarr.lang
@@ -149,6 +149,7 @@ Banking4DolibarrBankAccountNotLinked                    = Cette banque n'est pas
 Banking4DolibarrBankRecords                             = Suivi bancaire automatique
 Banking4DolibarrRefreshBankRecords                      = Télécharger les écritures bancaires
 Banking4DolibarrAutoReconcileBankRecords                = Rapprochement automatique
+Banking4DolibarrResumeAutoReconcileBankRecords          = Continuer la validation du dernier rapprochement automatique
 Banking4DolibarrManualReconcileBankRecords              = Rapprochement manuel
 Banking4DolibarrListOfBankRecords                       = Écritures bancaires téléchargées
 Banking4DolibarrRemoteID                                = ID distant
@@ -216,6 +217,8 @@ Banking4DolibarrStartDate                                       = Date de début
 Banking4DolibarrConfirmRefreshBankRecords                       = Êtes-vous sûr de vouloir rafraîchir les écritures bancaires à partir de cette date ?
 Banking4DolibarrConfirmAutoReconcileBankRecords                 = Êtes-vous sûr de vouloir rapprocher automatiquement les écritures bancaires ?
 Banking4DolibarrConfirmContinueAutoReconcileBankRecords         = Voulez-vous arrêter le rapprochement automatiquement des écritures bancaires en cours de traitement et lancer celle-ci ?
+Banking4DolibarrForceAutoReconcileBankRecords                   = Relancer un rapprochement automatique
+Banking4DolibarrConfirmResumeAutoReconcileBankRecords           = Êtes-vous sûr de vouloir continuer à valider les écritures bancaires rapprochées automatiquement ?
 Banking4DolibarrConfirmUnlinkRecords                            = Êtes-vous sûr de vouloir dé-rapprocher ces écritures bancaires ?
 Banking4DolibarrConfirmDiscardRecords                           = Êtes-vous sûr de vouloir abandonner ces écritures bancaires ?
 Banking4DolibarrConfirmUndiscardRecords                         = Êtes-vous sûr de vouloir reprendre ces écritures bancaires abandonnées ?
diff --git a/langs/fr_FR/banking4dolibarr.lang b/langs/fr_FR/banking4dolibarr.lang
index f82a8e0..cc3932c 100755
--- a/langs/fr_FR/banking4dolibarr.lang
+++ b/langs/fr_FR/banking4dolibarr.lang
@@ -149,6 +149,7 @@ Banking4DolibarrBankAccountNotLinked                    = Cette banque n'est pas
 Banking4DolibarrBankRecords                             = Suivi bancaire automatique
 Banking4DolibarrRefreshBankRecords                      = Télécharger les écritures bancaires
 Banking4DolibarrAutoReconcileBankRecords                = Rapprochement automatique
+Banking4DolibarrResumeAutoReconcileBankRecords          = Continuer la validation du dernier rapprochement automatique
 Banking4DolibarrManualReconcileBankRecords              = Rapprochement manuel
 Banking4DolibarrListOfBankRecords                       = Écritures bancaires téléchargées
 Banking4DolibarrRemoteID                                = ID distant
@@ -216,6 +217,8 @@ Banking4DolibarrStartDate                                       = Date de début
 Banking4DolibarrConfirmRefreshBankRecords                       = Êtes-vous sûr de vouloir rafraîchir les écritures bancaires à partir de cette date ?
 Banking4DolibarrConfirmAutoReconcileBankRecords                 = Êtes-vous sûr de vouloir rapprocher automatiquement les écritures bancaires ?
 Banking4DolibarrConfirmContinueAutoReconcileBankRecords         = Voulez-vous arrêter le rapprochement automatiquement des écritures bancaires en cours de traitement et lancer celle-ci ?
+Banking4DolibarrForceAutoReconcileBankRecords                   = Relancer un rapprochement automatique
+Banking4DolibarrConfirmResumeAutoReconcileBankRecords           = Êtes-vous sûr de vouloir continuer à valider les écritures bancaires préalablement rapprochées automatiquement ?
 Banking4DolibarrConfirmUnlinkRecords                            = Êtes-vous sûr de vouloir dé-rapprocher ces écritures bancaires ?
 Banking4DolibarrConfirmDiscardRecords                           = Êtes-vous sûr de vouloir abandonner ces écritures bancaires ?
 Banking4DolibarrConfirmUndiscardRecords                         = Êtes-vous sûr de vouloir reprendre ces écritures bancaires abandonnées ?
diff --git a/prelink.php b/prelink.php
index 8702f93..777a23a 100755
--- a/prelink.php
+++ b/prelink.php
@@ -364,62 +364,62 @@ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0,
 dol_fiche_end();
 
 if ($has_remote_bank_account == 1) {
-    // Form Confirm
-    //--------------------------------------------------------
-    $formconfirm = '';
-
-    // Confirm refresh
-    if ($action == 'b4d_valid_links' && count($toselect) > 0) {
-        $_SESSION['b4dbankrecordsprelinklist_toselect_' . $id] = $toselect;
-        $payment_modes = array();
-        foreach ($_POST as $k => $v) {
-            if (preg_match('/^payment_mode_(\d+)$/', $k, $matches) && $v > 0) {
-                $payment_modes[$matches[1]] = $v;
-            }
-        }
-        $_SESSION['b4dbankrecordsprelinklist_payment_modes_' . $id] = $payment_modes;
-
-        $nbtotalofrecords = GETPOST('nbtotalofrecords', 'int');
+	// Form Confirm
+	//--------------------------------------------------------
+	$formconfirm = '';
+
+	// Confirm refresh
+	if ($action == 'b4d_valid_links' && count($toselect) > 0) {
+		$_SESSION['b4dbankrecordsprelinklist_toselect_' . $id] = $toselect;
+		$payment_modes = array();
+		foreach ($_POST as $k => $v) {
+			if (preg_match('/^payment_mode_(\d+)$/', $k, $matches) && $v > 0) {
+				$payment_modes[$matches[1]] = $v;
+			}
+		}
+		$_SESSION['b4dbankrecordsprelinklist_payment_modes_' . $id] = $payment_modes;
+
+		$nbtotalofrecords = GETPOST('nbtotalofrecords', 'int');
 		$_SESSION['b4d_token'] = uniqid('', true);
-        $formconfirm = $form->formconfirm($base_url . '&nbtotalofrecords=' . $nbtotalofrecords . "&b4d_token=" . $_SESSION['b4d_token'], $langs->trans('Banking4DolibarrValidLinks'), $langs->trans("Banking4DolibarrConfirmValidLinks"), 'confirm_b4d_valid_links', '', 0, 1);
-    }
+		$formconfirm = $form->formconfirm($base_url . '&nbtotalofrecords=' . $nbtotalofrecords . "&b4d_token=" . $_SESSION['b4d_token'], $langs->trans('Banking4DolibarrValidLinks'), $langs->trans("Banking4DolibarrConfirmValidLinks"), 'confirm_b4d_valid_links', '', 0, 1);
+	}
 
-    $parameters = array('base_url' => $base_url);
-    $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
-    if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
-    elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
-    print $formconfirm;
-
-    // List
-    //--------------------------------------------------------
-    $sql = 'SELECT DISTINCT ';
-    $sql .= ' br.rowid, br.id_record, br.id_account,';
-    $sql .= ' br.label, br.comment, CONCAT(' . $db->ifsql("cb4dbrsc.rowid IS NULL", "''", "CONCAT(cb4dbrsc.label, ' - ')") . ', cb4dbrc.label) AS category_label, br.record_type, br.original_country, br.original_amount, br.original_currency,';
-    $sql .= ' br.commission, br.commission_currency, br.amount, br.coming, br.deleted_date, br.record_date, br.rdate, br.bdate,';
-    $sql .= ' br.vdate, br.date_scraped, br.last_update_date, br.tms,';
-    $sql .= ' brpl.rowid AS pre_link_id, brpl.element_type, brpl.element_id, brpl.fk_bank,';
+	$parameters = array('base_url' => $base_url);
+	$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+	if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
+	elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
+	print $formconfirm;
+
+	// List
+	//--------------------------------------------------------
+	$sql = 'SELECT DISTINCT ';
+	$sql .= ' br.rowid, br.id_record, br.id_account,';
+	$sql .= ' br.label, br.comment, CONCAT(' . $db->ifsql("cb4dbrsc.rowid IS NULL", "''", "CONCAT(cb4dbrsc.label, ' - ')") . ', cb4dbrc.label) AS category_label, br.record_type, br.original_country, br.original_amount, br.original_currency,';
+	$sql .= ' br.commission, br.commission_currency, br.amount, br.coming, br.deleted_date, br.record_date, br.rdate, br.bdate,';
+	$sql .= ' br.vdate, br.date_scraped, br.last_update_date, br.tms,';
+	$sql .= ' brpl.rowid AS pre_link_id, brpl.element_type, brpl.element_id, brpl.fk_bank,';
 	$sql .= ' ' . $db->ifsql("baef.b4d_include_reject_amount = 1 AND (ul.element_type = 'widthdraw' OR ul.element_type = 'payment_by_bank_transfer')", "ul.amount2", "ul.amount") . ' AS unpaid_amount, ul.dateb AS unpaid_dateb, ul.datee AS unpaid_datee';
-    // Add fields from hooks
-    $parameters = array();
-    $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters);    // Note that $action and $object may have been modified by hook
-    $sql .= $hookmanager->resPrint;
-    $sql .= " FROM " . MAIN_DB_PREFIX . "banking4dolibarr_bank_record_pre_link as brpl";
-    $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "banking4dolibarr_bank_record as br ON br.rowid = brpl.fk_bank_record";
+	// Add fields from hooks
+	$parameters = array();
+	$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters);    // Note that $action and $object may have been modified by hook
+	$sql .= $hookmanager->resPrint;
+	$sql .= " FROM " . MAIN_DB_PREFIX . "banking4dolibarr_bank_record_pre_link as brpl";
+	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "banking4dolibarr_bank_record as br ON br.rowid = brpl.fk_bank_record";
 	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_account as ba ON ba.rowid = brpl.fk_bank_account";
 	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_account_extrafields as baef ON baef.fk_object = brpl.fk_bank_account";
-    $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "banking4dolibarr_view_" . ((int) $conf->entity) . "_unpaid_list as ul ON ul.element_type = brpl.element_type AND ul.element_id = brpl.element_id";
-    $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_banking4dolibarr_bank_record_category as cb4dbrc ON cb4dbrc.rowid = br.id_category AND cb4dbrc.entity IN (" . getEntity('bank_account') . ")";
-    $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_banking4dolibarr_bank_record_category as cb4dbrsc ON cb4dbrsc.rowid = cb4dbrc.id_parent_category AND cb4dbrsc.entity IN (" . getEntity('bank_account') . ")";
-    // Add join from hooks
-    $parameters = array();
-    $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters);    // Note that $action and $object may have been modified by hook
-    $sql .= $hookmanager->resPrint;
-    $sql .= ' WHERE ba.entity IN (' . getEntity('bank_account') . ')';
-    $sql .= ' AND brpl.fk_bank_account = ' . $id;
+	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "banking4dolibarr_view_" . ((int) $conf->entity) . "_unpaid_list as ul ON ul.element_type = brpl.element_type AND ul.element_id = brpl.element_id";
+	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_banking4dolibarr_bank_record_category as cb4dbrc ON cb4dbrc.rowid = br.id_category AND cb4dbrc.entity IN (" . getEntity('bank_account') . ")";
+	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_banking4dolibarr_bank_record_category as cb4dbrsc ON cb4dbrsc.rowid = cb4dbrc.id_parent_category AND cb4dbrsc.entity IN (" . getEntity('bank_account') . ")";
+	// Add join from hooks
+	$parameters = array();
+	$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters);    // Note that $action and $object may have been modified by hook
+	$sql .= $hookmanager->resPrint;
+	$sql .= ' WHERE ba.entity IN (' . getEntity('bank_account') . ')';
+	$sql .= ' AND brpl.fk_bank_account = ' . $id;
 	$sql .= ' AND br.status = ' . BudgetInsightBankRecord::BANK_RECORD_STATUS_NOT_RECONCILED; // TODO check if it is necessary
-    if ($search_id_record) $sql .= natural_search('br.id_record', $search_id_record);
-    if ($search_label) $sql .= natural_search('br.label', $search_label);
-    if ($search_comment) $sql .= natural_search('br.comment', $search_comment);
+	if ($search_id_record) $sql .= natural_search('br.id_record', $search_id_record);
+	if ($search_label) $sql .= natural_search('br.label', $search_label);
+	if ($search_comment) $sql .= natural_search('br.comment', $search_comment);
 	if (dol_strlen($search_record_date_start) > 0) $sql .= " AND br.record_date >= '" . $db->idate($search_record_date_start) . "'";
 	if (dol_strlen($search_record_date_end) > 0) $sql .= " AND br.record_date <= '" . $db->idate($search_record_date_end) . "'";
 	if (dol_strlen($search_rdate_start) > 0) $sql .= " AND br.rdate >= '" . $db->idate($search_rdate_start) . "'";
@@ -430,373 +430,373 @@ if ($has_remote_bank_account == 1) {
 	if (dol_strlen($search_vdate_end) > 0) $sql .= " AND br.vdate <= '" . $db->idate($search_vdate_end) . "'";
 	if (dol_strlen($search_date_scraped_start) > 0) $sql .= " AND br.date_scraped >= '" . $db->idate($search_date_scraped_start) . "'";
 	if (dol_strlen($search_date_scraped_end) > 0) $sql .= " AND br.date_scraped <= '" . $db->idate($search_date_scraped_end) . "'";
-    if ($search_record_type) $sql .= natural_search("br.record_type", $search_record_type);
-    if ($search_category) $sql .= natural_search("cb4dbrc.label", $search_category);
-    if ($search_original_country) $sql .= natural_search("br.original_country", $search_original_country);
-    if ($search_original_amount) $sql .= natural_search("br.original_amount", $search_original_amount, 1);
-    if ($search_original_currency) $sql .= natural_search("br.original_currency", $search_original_currency);
-    if ($search_commission) $sql .= natural_search("br.commission", $search_commission, 1);
-    if ($search_commission_currency) $sql .= natural_search("br.commission_currency", $search_commission_currency);
+	if ($search_record_type) $sql .= natural_search("br.record_type", $search_record_type);
+	if ($search_category) $sql .= natural_search("cb4dbrc.label", $search_category);
+	if ($search_original_country) $sql .= natural_search("br.original_country", $search_original_country);
+	if ($search_original_amount) $sql .= natural_search("br.original_amount", $search_original_amount, 1);
+	if ($search_original_currency) $sql .= natural_search("br.original_currency", $search_original_currency);
+	if ($search_commission) $sql .= natural_search("br.commission", $search_commission, 1);
+	if ($search_commission_currency) $sql .= natural_search("br.commission_currency", $search_commission_currency);
 	if (dol_strlen($search_last_update_date_start) > 0) $sql .= " AND br.last_update_date >= '" . $db->idate($search_last_update_date_start) . "'";
 	if (dol_strlen($search_last_update_date_end) > 0) $sql .= " AND br.last_update_date <= '" . $db->idate($search_last_update_date_end) . "'";
 	if (dol_strlen($search_tms_start) > 0) $sql .= " AND br.tms >= '" . $db->idate($search_tms_start) . "'";
 	if (dol_strlen($search_tms_end) > 0) $sql .= " AND br.tms <= '" . $db->idate($search_tms_end) . "'";
-    if ($search_debit) $sql .= natural_search("- br.amount", $search_debit, 1) . ' AND br.amount < 0';
-    if ($search_credit) $sql .= natural_search("br.amount", $search_credit, 1) . ' AND br.amount > 0';
-    // Add where from hooks
-    $parameters = array();
-    $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters);    // Note that $action and $object may have been modified by hook
-    $sql .= $hookmanager->resPrint;
-
-    if ($sortfield == 'br.vdate') $sql .= " ORDER BY COALESCE(br.vdate, br.record_date) " . $sortorder . ($view_mode == 1 ? ',br.rowid ASC' : ',brpl.element_type ASC,brpl.element_id ASC,brpl.fk_bank ASC');
-    else $sql .= $db->order($sortfield . ($view_mode == 1 ? ',br.rowid' : ',brpl.element_type,brpl.element_id,brpl.fk_bank'), $sortorder . ($view_mode == 1 ? ',ASC' : ',ASC,ASC,ASC'));
-
-    // Count total nb of records
-    $nbtotalofrecords = '';
-    $resql = $db->query('SELECT COUNT(*) As nb FROM (' . $sql . ') As count_table');
-    if ($resql && ($obj = $db->fetch_object($resql))) {
-        $nbtotalofrecords = $obj->nb;
-    } else {
-        setEventMessage($db->lasterror(), 'errors');
-    }
+	if ($search_debit) $sql .= natural_search("- br.amount", $search_debit, 1) . ' AND br.amount < 0';
+	if ($search_credit) $sql .= natural_search("br.amount", $search_credit, 1) . ' AND br.amount > 0';
+	// Add where from hooks
+	$parameters = array();
+	$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters);    // Note that $action and $object may have been modified by hook
+	$sql .= $hookmanager->resPrint;
+
+	if ($sortfield == 'br.vdate') $sql .= " ORDER BY COALESCE(br.vdate, br.record_date) " . $sortorder . ($view_mode == 1 ? ',br.rowid ASC' : ',brpl.element_type ASC,brpl.element_id ASC,brpl.fk_bank ASC');
+	else $sql .= $db->order($sortfield . ($view_mode == 1 ? ',br.rowid' : ',brpl.element_type,brpl.element_id,brpl.fk_bank'), $sortorder . ($view_mode == 1 ? ',ASC' : ',ASC,ASC,ASC'));
+
+	// Count total nb of records
+	$nbtotalofrecords = '';
+	$resql = $db->query('SELECT COUNT(*) As nb FROM (' . $sql . ') As count_table');
+	if ($resql && ($obj = $db->fetch_object($resql))) {
+		$nbtotalofrecords = $obj->nb;
+	} else {
+		setEventMessage($db->lasterror(), 'errors');
+	}
+
+	$sql .= $db->plimit($limit + 1, $offset);
+
+	$resql = $db->query($sql);
+	if ($resql) {
+		$title = $langs->trans('Banking4DolibarrPreLinkListOfBankRecords');
+
+		$num = $db->num_rows($resql);
+
+		$arrayofselected = is_array($toselect) ? $toselect : array();
+
+		// Lignes des champs de filtre
+		print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '&state=' . $state . '">';
+		if ($optioncss != '') print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
+		print '<input type="hidden" name="token" value="' . newToken() . '">';
+		print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
+		print '<input type="hidden" name="action" value="list">';
+		print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
+		print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
+		print '<input type="hidden" name="page" value="' . $page . '">';
+		print '<input type="hidden" name="contextpage" value="' . $contextpage . '">';
+		print '<input type="hidden" name="nbtotalofrecords" value="' . $nbtotalofrecords . '">';
+
+		$morehtmlcenter = '';
+		if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+			$morehtmlcenter .= '<input type="submit" name="button_cancel" class="button" value="' . $langs->trans("Banking4DolibarrFinish") . '">';
+			$morehtmlcenter .= '&nbsp;&nbsp;';
+			$morehtmlcenter .= '<input type="submit" name="button_valid_links" class="button" value="' . $langs->trans("Banking4DolibarrValidLinks") . '">';
+		}
+
+		$morehtmlright = '';
+		if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+			$morehtmlright .= '<input type="submit" name="button_cancel" class="button" value="' . $langs->trans("Banking4DolibarrFinish") . '">';
+			$morehtmlright .= '&nbsp;&nbsp;';
+			$morehtmlright .= '<input type="submit" name="button_valid_links" class="button" value="' . $langs->trans("Banking4DolibarrValidLinks") . '">';
+		}
+
+		print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $morehtmlcenter, $num, $nbtotalofrecords, '', 0, $morehtmlright, '', $limit);
+
+		$i = 0;
 
-    $sql .= $db->plimit($limit + 1, $offset);
-
-    $resql = $db->query($sql);
-    if ($resql) {
-        $title = $langs->trans('Banking4DolibarrPreLinkListOfBankRecords');
-
-        $num = $db->num_rows($resql);
-
-        $arrayofselected = is_array($toselect) ? $toselect : array();
-
-        // Lignes des champs de filtre
-        print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '&state=' . $state . '">';
-        if ($optioncss != '') print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
-        print '<input type="hidden" name="token" value="' . newToken() . '">';
-        print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
-        print '<input type="hidden" name="action" value="list">';
-        print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
-        print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
-        print '<input type="hidden" name="page" value="' . $page . '">';
-        print '<input type="hidden" name="contextpage" value="' . $contextpage . '">';
-        print '<input type="hidden" name="nbtotalofrecords" value="' . $nbtotalofrecords . '">';
-
-        $morehtmlcenter = '';
-        if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
-            $morehtmlcenter .= '<input type="submit" name="button_cancel" class="button" value="' . $langs->trans("Banking4DolibarrFinish") . '">';
-            $morehtmlcenter .= '&nbsp;&nbsp;';
-            $morehtmlcenter .= '<input type="submit" name="button_valid_links" class="button" value="' . $langs->trans("Banking4DolibarrValidLinks") . '">';
-        }
-
-        $morehtmlright = '';
-        if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
-            $morehtmlright .= '<input type="submit" name="button_cancel" class="button" value="' . $langs->trans("Banking4DolibarrFinish") . '">';
-            $morehtmlright .= '&nbsp;&nbsp;';
-            $morehtmlright .= '<input type="submit" name="button_valid_links" class="button" value="' . $langs->trans("Banking4DolibarrValidLinks") . '">';
-        }
-
-        print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $morehtmlcenter, $num, $nbtotalofrecords, '', 0, $morehtmlright, '', $limit);
-
-        $i = 0;
-
-        $moreforfilter = '';
-
-        // View mode
-        $moreforfilter .= '<div class="divsearchfield">';
-        $moreforfilter .= $langs->trans('Banking4DolibarrPreLinkViewListMode') . ': ';
-        $moreforfilter .= $form->selectarray('view_mode', array(
-            1 => $langs->trans("Banking4DolibarrPreLinkViewListModeBankRecord"),
-            2 => $langs->trans("Banking4DolibarrPreLinkViewListModeObject"),
-        ), $view_mode, 0, 0, 0, '', 0, 0, 0, '', ' minwidth200');
-        $moreforfilter .= '</div>';
-
-        $parameters = array();
-        $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters);    // Note that $action and $object may have been modified by hook
-        if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
-        else $moreforfilter = $hookmanager->resPrint;
-
-        if (!empty($moreforfilter)) {
-            print '<div class="liste_titre liste_titre_bydiv centpercent">';
-            print $moreforfilter;
-            print '</div>';
-        }
-
-        $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
-        $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);    // This also change content of $arrayfields
-        $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
-
-        print '<div class="div-table-responsive">';
-        print '<table class="tagtable liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n";
-
-        print '<tr class="liste_titre_filter">';
-        // Action column
-        if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
-            print '<td class="liste_titre maxwidthsearch center actioncolumn">';
-            $searchpicto = $form->showFilterButtons('left');
-            print $searchpicto;
-            print '</td>';
-        }
-        if (!empty($arrayfields['br.rowid']['checked'])) {
-            print '<td class="liste_titre"></td>';
-        }
-        if (!empty($arrayfields['br.id_record']['checked'])) {
-            print '<td class="liste_titre">';
-            print '<input class="flat" size="6" type="text" name="search_id_record" value="' . dol_escape_htmltag($search_id_record) . '">';
-            print '</td>';
-        }
-        print '<td class="liste_titre">';
-        print '<input class="flat" size="6" type="text" name="search_label" value="' . dol_escape_htmltag($search_label) . '">';
-        print '</td>';
-        if (!empty($arrayfields['br.comment']['checked'])) {
-            print '<td class="liste_titre">';
-            print '<input class="flat" size="6" type="text" name="search_comment" value="' . dol_escape_htmltag($search_comment) . '">';
-            print '</td>';
-        }
-        if (!empty($arrayfields['br.record_date']['checked'])) {
-            print '<td class="liste_titre nowrap center">';
+		$moreforfilter = '';
+
+		// View mode
+		$moreforfilter .= '<div class="divsearchfield">';
+		$moreforfilter .= $langs->trans('Banking4DolibarrPreLinkViewListMode') . ': ';
+		$moreforfilter .= $form->selectarray('view_mode', array(
+			1 => $langs->trans("Banking4DolibarrPreLinkViewListModeBankRecord"),
+			2 => $langs->trans("Banking4DolibarrPreLinkViewListModeObject"),
+		), $view_mode, 0, 0, 0, '', 0, 0, 0, '', ' minwidth200');
+		$moreforfilter .= '</div>';
+
+		$parameters = array();
+		$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters);    // Note that $action and $object may have been modified by hook
+		if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
+		else $moreforfilter = $hookmanager->resPrint;
+
+		if (!empty($moreforfilter)) {
+			print '<div class="liste_titre liste_titre_bydiv centpercent">';
+			print $moreforfilter;
+			print '</div>';
+		}
+
+		$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
+		$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);    // This also change content of $arrayfields
+		$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
+
+		print '<div class="div-table-responsive">';
+		print '<table class="tagtable liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n";
+
+		print '<tr class="liste_titre_filter">';
+		// Action column
+		if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+			print '<td class="liste_titre maxwidthsearch center actioncolumn">';
+			$searchpicto = $form->showFilterButtons('left');
+			print $searchpicto;
+			print '</td>';
+		}
+		if (!empty($arrayfields['br.rowid']['checked'])) {
+			print '<td class="liste_titre"></td>';
+		}
+		if (!empty($arrayfields['br.id_record']['checked'])) {
+			print '<td class="liste_titre">';
+			print '<input class="flat" size="6" type="text" name="search_id_record" value="' . dol_escape_htmltag($search_id_record) . '">';
+			print '</td>';
+		}
+		print '<td class="liste_titre">';
+		print '<input class="flat" size="6" type="text" name="search_label" value="' . dol_escape_htmltag($search_label) . '">';
+		print '</td>';
+		if (!empty($arrayfields['br.comment']['checked'])) {
+			print '<td class="liste_titre">';
+			print '<input class="flat" size="6" type="text" name="search_comment" value="' . dol_escape_htmltag($search_comment) . '">';
+			print '</td>';
+		}
+		if (!empty($arrayfields['br.record_date']['checked'])) {
+			print '<td class="liste_titre nowrap center">';
 			print '<div class="nowrap">';
-            if ($isV11p) {
-                print $form->selectDate($search_record_date_start ? $search_record_date_start : -1, 'search_record_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
-            } else {
-                print $langs->trans('From') . ' ';
-                print $form->selectDate($search_record_date_start ? $search_record_date_start : -1, 'search_record_date_start', 0, 0, 1);
-            }
+			if ($isV11p) {
+				print $form->selectDate($search_record_date_start ? $search_record_date_start : -1, 'search_record_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
+			} else {
+				print $langs->trans('From') . ' ';
+				print $form->selectDate($search_record_date_start ? $search_record_date_start : -1, 'search_record_date_start', 0, 0, 1);
+			}
 			print '</div>';
 			print '<div class="nowrap">';
-            if ($isV11p) {
-                print $form->selectDate($search_record_date_end ? $search_record_date_end : -1, 'search_record_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
-            } else {
-                print $langs->trans('to') . ' ';
-                print $form->selectDate($search_record_date_end ? $search_record_date_end : -1, 'search_record_date_end', 0, 0, 1);
-            }
+			if ($isV11p) {
+				print $form->selectDate($search_record_date_end ? $search_record_date_end : -1, 'search_record_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
+			} else {
+				print $langs->trans('to') . ' ';
+				print $form->selectDate($search_record_date_end ? $search_record_date_end : -1, 'search_record_date_end', 0, 0, 1);
+			}
 			print '</div>';
-            print '</td>';
-        }
-        if (!empty($arrayfields['br.vdate']['checked'])) {
-            print '<td class="liste_titre nowrap center">';
+			print '</td>';
+		}
+		if (!empty($arrayfields['br.vdate']['checked'])) {
+			print '<td class="liste_titre nowrap center">';
 			print '<div class="nowrap">';
-            if ($isV11p) {
-                print $form->selectDate($search_vdate_start ? $search_vdate_start : -1, 'search_vdate_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
-            } else {
-                print $langs->trans('From') . ' ';
-                print $form->selectDate($search_vdate_start ? $search_vdate_start : -1, 'search_vdate_start', 0, 0, 1);
-            }
+			if ($isV11p) {
+				print $form->selectDate($search_vdate_start ? $search_vdate_start : -1, 'search_vdate_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
+			} else {
+				print $langs->trans('From') . ' ';
+				print $form->selectDate($search_vdate_start ? $search_vdate_start : -1, 'search_vdate_start', 0, 0, 1);
+			}
 			print '</div>';
 			print '<div class="nowrap">';
-            if ($isV11p) {
-                print $form->selectDate($search_vdate_end ? $search_vdate_end : -1, 'search_vdate_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
-            } else {
-                print $langs->trans('to') . ' ';
-                print $form->selectDate($search_vdate_end ? $search_vdate_end : -1, 'search_vdate_end', 0, 0, 1);
-            }
+			if ($isV11p) {
+				print $form->selectDate($search_vdate_end ? $search_vdate_end : -1, 'search_vdate_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
+			} else {
+				print $langs->trans('to') . ' ';
+				print $form->selectDate($search_vdate_end ? $search_vdate_end : -1, 'search_vdate_end', 0, 0, 1);
+			}
 			print '</div>';
-            print '</td>';
-        }
-        if (!empty($arrayfields['br.rdate']['checked'])) {
-            print '<td class="liste_titre nowrap center">';
+			print '</td>';
+		}
+		if (!empty($arrayfields['br.rdate']['checked'])) {
+			print '<td class="liste_titre nowrap center">';
 			print '<div class="nowrap">';
-            if ($isV11p) {
-                print $form->selectDate($search_rdate_start ? $search_rdate_start : -1, 'search_rdate_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
-            } else {
-                print $langs->trans('From') . ' ';
-                print $form->selectDate($search_rdate_start ? $search_rdate_start : -1, 'search_rdate_start', 0, 0, 1);
-            }
+			if ($isV11p) {
+				print $form->selectDate($search_rdate_start ? $search_rdate_start : -1, 'search_rdate_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
+			} else {
+				print $langs->trans('From') . ' ';
+				print $form->selectDate($search_rdate_start ? $search_rdate_start : -1, 'search_rdate_start', 0, 0, 1);
+			}
 			print '</div>';
 			print '<div class="nowrap">';
-            if ($isV11p) {
-                print $form->selectDate($search_rdate_end ? $search_rdate_end : -1, 'search_rdate_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
-            } else {
-                print $langs->trans('to') . ' ';
-                print $form->selectDate($search_rdate_end ? $search_rdate_end : -1, 'search_rdate_end', 0, 0, 1);
-            }
+			if ($isV11p) {
+				print $form->selectDate($search_rdate_end ? $search_rdate_end : -1, 'search_rdate_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
+			} else {
+				print $langs->trans('to') . ' ';
+				print $form->selectDate($search_rdate_end ? $search_rdate_end : -1, 'search_rdate_end', 0, 0, 1);
+			}
 			print '</div>';
-            print '</td>';
-        }
-        if (!empty($arrayfields['br.bdate']['checked'])) {
-            print '<td class="liste_titre nowrap center">';
+			print '</td>';
+		}
+		if (!empty($arrayfields['br.bdate']['checked'])) {
+			print '<td class="liste_titre nowrap center">';
 			print '<div class="nowrap">';
-            if ($isV11p) {
-                print $form->selectDate($search_bdate_start ? $search_bdate_start : -1, 'search_bdate_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
-            } else {
-                print $langs->trans('From') . ' ';
-                print $form->selectDate($search_bdate_start ? $search_bdate_start : -1, 'search_bdate_start', 0, 0, 1);
-            }
+			if ($isV11p) {
+				print $form->selectDate($search_bdate_start ? $search_bdate_start : -1, 'search_bdate_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
+			} else {
+				print $langs->trans('From') . ' ';
+				print $form->selectDate($search_bdate_start ? $search_bdate_start : -1, 'search_bdate_start', 0, 0, 1);
+			}
 			print '</div>';
 			print '<div class="nowrap">';
-            if ($isV11p) {
-                print $form->selectDate($search_bdate_end ? $search_bdate_end : -1, 'search_bdate_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
-            } else {
-                print $langs->trans('to') . ' ';
-                print $form->selectDate($search_bdate_end ? $search_bdate_end : -1, 'search_bdate_end', 0, 0, 1);
-            }
+			if ($isV11p) {
+				print $form->selectDate($search_bdate_end ? $search_bdate_end : -1, 'search_bdate_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
+			} else {
+				print $langs->trans('to') . ' ';
+				print $form->selectDate($search_bdate_end ? $search_bdate_end : -1, 'search_bdate_end', 0, 0, 1);
+			}
 			print '</div>';
-            print '</td>';
-        }
-        if (!empty($arrayfields['br.date_scraped']['checked'])) {
-            print '<td class="liste_titre center nowrap">';
+			print '</td>';
+		}
+		if (!empty($arrayfields['br.date_scraped']['checked'])) {
+			print '<td class="liste_titre center nowrap">';
 			print '<div class="nowrap">';
-            if ($isV11p) {
-                print $form->selectDate($search_date_scraped_start ? $search_date_scraped_start : -1, 'search_date_scraped_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
-            } else {
-                print $langs->trans('From') . ' ';
-                print $form->selectDate($search_date_scraped_start ? $search_date_scraped_start : -1, 'search_date_scraped_start', 0, 0, 1);
-            }
+			if ($isV11p) {
+				print $form->selectDate($search_date_scraped_start ? $search_date_scraped_start : -1, 'search_date_scraped_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
+			} else {
+				print $langs->trans('From') . ' ';
+				print $form->selectDate($search_date_scraped_start ? $search_date_scraped_start : -1, 'search_date_scraped_start', 0, 0, 1);
+			}
 			print '</div>';
 			print '<div class="nowrap">';
-            if ($isV11p) {
-                print $form->selectDate($search_date_scraped_end ? $search_date_scraped_end : -1, 'search_date_scraped_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
-            } else {
-                print $langs->trans('to') . ' ';
-                print $form->selectDate($search_date_scraped_end ? $search_date_scraped_end : -1, 'search_date_scraped_end', 0, 0, 1);
-            }
+			if ($isV11p) {
+				print $form->selectDate($search_date_scraped_end ? $search_date_scraped_end : -1, 'search_date_scraped_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
+			} else {
+				print $langs->trans('to') . ' ';
+				print $form->selectDate($search_date_scraped_end ? $search_date_scraped_end : -1, 'search_date_scraped_end', 0, 0, 1);
+			}
 			print '</div>';
-            print '</td>';
-        }
-        if (!empty($arrayfields['br.record_type']['checked'])) {
-            print '<td class="liste_titre center">';
-            print $formdictionary->select_dictionary('banking4dolibarr', 'banking4dolibarrbankrecordtypes', $search_record_type, 'search_record_type', 1);
-            print '</td>';
-        }
-        if (!empty($arrayfields['br.id_category']['checked'])) {
-            print '<td class="liste_titre">';
-            print '<input class="flat" size="6" type="text" name="search_category" value="' . dol_escape_htmltag($search_category) . '">';
-            print '</td>';
-        }
-        if (!empty($arrayfields['br.original_country']['checked'])) {
-            print '<td class="liste_titre">';
-            print '<input class="flat" size="6" type="text" name="search_original_country" value="' . dol_escape_htmltag($search_original_country) . '">';
-            print '</td>';
-        }
-        if (!empty($arrayfields['br.original_amount']['checked'])) {
-            print '<td class="liste_titre right">';
-            print '<input class="flat" size="6" type="text" name="search_original_amount" value="' . dol_escape_htmltag($search_original_amount) . '">';
-            print '</td>';
-        }
-        if (!empty($arrayfields['br.original_currency']['checked'])) {
-            print '<td class="liste_titre center">';
-            print $form->selectCurrency($search_original_currency, 'search_original_currency');
-            // Add empty option
-            print <<<SCRIPT
+			print '</td>';
+		}
+		if (!empty($arrayfields['br.record_type']['checked'])) {
+			print '<td class="liste_titre center">';
+			print $formdictionary->select_dictionary('banking4dolibarr', 'banking4dolibarrbankrecordtypes', $search_record_type, 'search_record_type', 1);
+			print '</td>';
+		}
+		if (!empty($arrayfields['br.id_category']['checked'])) {
+			print '<td class="liste_titre">';
+			print '<input class="flat" size="6" type="text" name="search_category" value="' . dol_escape_htmltag($search_category) . '">';
+			print '</td>';
+		}
+		if (!empty($arrayfields['br.original_country']['checked'])) {
+			print '<td class="liste_titre">';
+			print '<input class="flat" size="6" type="text" name="search_original_country" value="' . dol_escape_htmltag($search_original_country) . '">';
+			print '</td>';
+		}
+		if (!empty($arrayfields['br.original_amount']['checked'])) {
+			print '<td class="liste_titre right">';
+			print '<input class="flat" size="6" type="text" name="search_original_amount" value="' . dol_escape_htmltag($search_original_amount) . '">';
+			print '</td>';
+		}
+		if (!empty($arrayfields['br.original_currency']['checked'])) {
+			print '<td class="liste_titre center">';
+			print $form->selectCurrency($search_original_currency, 'search_original_currency');
+			// Add empty option
+			print <<<SCRIPT
     <script type="text/javascript">
         $(document).ready(function () {
             $("#search_original_currency").prepend('<option value=""' + ("$search_original_currency" == "" ? ' selected' : '') + '>&nbsp;</option>')
         });
     </script>
 SCRIPT;
-            print '</td>';
-        }
-        if (!empty($arrayfields['br.commission']['checked'])) {
-            print '<td class="liste_titre right">';
-            print '<input class="flat" size="6" type="text" name="search_commission" value="' . dol_escape_htmltag($search_commission) . '">';
-            print '</td>';
-        }
-        if (!empty($arrayfields['br.commission_currency']['checked'])) {
-            print '<td class="liste_titre center">';
-            print $form->selectCurrency($search_commission_currency, 'search_commission_currency');
-            // Add empty option
-            print <<<SCRIPT
+			print '</td>';
+		}
+		if (!empty($arrayfields['br.commission']['checked'])) {
+			print '<td class="liste_titre right">';
+			print '<input class="flat" size="6" type="text" name="search_commission" value="' . dol_escape_htmltag($search_commission) . '">';
+			print '</td>';
+		}
+		if (!empty($arrayfields['br.commission_currency']['checked'])) {
+			print '<td class="liste_titre center">';
+			print $form->selectCurrency($search_commission_currency, 'search_commission_currency');
+			// Add empty option
+			print <<<SCRIPT
     <script type="text/javascript">
         $(document).ready(function () {
             $("#search_commission_currency").prepend('<option value=""' + ("$search_commission_currency" == "" ? ' selected' : '') + '>&nbsp;</option>')
         });
     </script>
 SCRIPT;
-            print '</td>';
-        }
-        // Fields from hook
-        $parameters = array('arrayfields' => $arrayfields);
-        $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters);    // Note that $action and $object may have been modified by hook
-        print $hookmanager->resPrint;
-        if (!empty($arrayfields['br.last_update_date']['checked'])) {
-            print '<td class="liste_titre nowrap center">';
+			print '</td>';
+		}
+		// Fields from hook
+		$parameters = array('arrayfields' => $arrayfields);
+		$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters);    // Note that $action and $object may have been modified by hook
+		print $hookmanager->resPrint;
+		if (!empty($arrayfields['br.last_update_date']['checked'])) {
+			print '<td class="liste_titre nowrap center">';
 			print '<div class="nowrap">';
-            if ($isV11p) {
-                print $form->selectDate($search_last_update_date_start ? $search_last_update_date_start : -1, 'search_last_update_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
-            } else {
-                print $langs->trans('From') . ' ';
-                print $form->selectDate($search_last_update_date_start ? $search_last_update_date_start : -1, 'search_last_update_date_start', 0, 0, 1);
-            }
+			if ($isV11p) {
+				print $form->selectDate($search_last_update_date_start ? $search_last_update_date_start : -1, 'search_last_update_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
+			} else {
+				print $langs->trans('From') . ' ';
+				print $form->selectDate($search_last_update_date_start ? $search_last_update_date_start : -1, 'search_last_update_date_start', 0, 0, 1);
+			}
 			print '</div>';
 			print '<div class="nowrap">';
-            if ($isV11p) {
-                print $form->selectDate($search_last_update_date_end ? $search_last_update_date_end : -1, 'search_last_update_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
-            } else {
-                print $langs->trans('to') . ' ';
-                print $form->selectDate($search_last_update_date_end ? $search_last_update_date_end : -1, 'search_last_update_date_end', 0, 0, 1);
-            }
+			if ($isV11p) {
+				print $form->selectDate($search_last_update_date_end ? $search_last_update_date_end : -1, 'search_last_update_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
+			} else {
+				print $langs->trans('to') . ' ';
+				print $form->selectDate($search_last_update_date_end ? $search_last_update_date_end : -1, 'search_last_update_date_end', 0, 0, 1);
+			}
 			print '</div>';
-            print '</td>';
-        }
-        if (!empty($arrayfields['br.tms']['checked'])) {
-            print '<td class="liste_titre center nowrap">';
+			print '</td>';
+		}
+		if (!empty($arrayfields['br.tms']['checked'])) {
+			print '<td class="liste_titre center nowrap">';
 			print '<div class="nowrap">';
-            if ($isV11p) {
-                print $form->selectDate($search_tms_start ? $search_tms_start : -1, 'search_tms_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
-            } else {
-                print $langs->trans('From') . ' ';
-                print $form->selectDate($search_tms_start ? $search_tms_start : -1, 'search_tms_start', 0, 0, 1);
-            }
+			if ($isV11p) {
+				print $form->selectDate($search_tms_start ? $search_tms_start : -1, 'search_tms_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
+			} else {
+				print $langs->trans('From') . ' ';
+				print $form->selectDate($search_tms_start ? $search_tms_start : -1, 'search_tms_start', 0, 0, 1);
+			}
 			print '</div>';
 			print '<div class="nowrap">';
-            if ($isV11p) {
-                print $form->selectDate($search_tms_end ? $search_tms_end : -1, 'search_tms_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
-            } else {
-                print $langs->trans('to') . ' ';
-                print $form->selectDate($search_tms_end ? $search_tms_end : -1, 'search_tms_end', 0, 0, 1);
-            }
+			if ($isV11p) {
+				print $form->selectDate($search_tms_end ? $search_tms_end : -1, 'search_tms_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
+			} else {
+				print $langs->trans('to') . ' ';
+				print $form->selectDate($search_tms_end ? $search_tms_end : -1, 'search_tms_end', 0, 0, 1);
+			}
 			print '</div>';
-            print '</td>';
-        }
-        print '<td class="liste_titre right">';
-        print '<input class="flat" size="6" type="text" name="search_debit" value="' . dol_escape_htmltag($search_debit) . '">';
-        print '</td>';
-        print '<td class="liste_titre right">';
-        print '<input class="flat" size="6" type="text" name="search_credit" value="' . dol_escape_htmltag($search_credit) . '">';
-        print '</td>';
-        // Action column
-        if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
-            print '<td class="liste_titre center maxwidthsearch actioncolumn">';
-            $searchpicto = $form->showFilterButtons();
-            print $searchpicto;
-            print '</td>';
-        }
-        print "</tr>\n";
-
-        // Fields title
+			print '</td>';
+		}
+		print '<td class="liste_titre right">';
+		print '<input class="flat" size="6" type="text" name="search_debit" value="' . dol_escape_htmltag($search_debit) . '">';
+		print '</td>';
+		print '<td class="liste_titre right">';
+		print '<input class="flat" size="6" type="text" name="search_credit" value="' . dol_escape_htmltag($search_credit) . '">';
+		print '</td>';
+		// Action column
+		if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+			print '<td class="liste_titre center maxwidthsearch actioncolumn">';
+			$searchpicto = $form->showFilterButtons();
+			print $searchpicto;
+			print '</td>';
+		}
+		print "</tr>\n";
+
+		// Fields title
 		$filter_date_help = ' ' . $form->textwithpicto('', $langs->transnoentitiesnoconv('Banking4DolibarrFilterDateHelp'));
-        print '<tr class="liste_titre">';
-        if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
-            print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
-        }
-        if (!empty($arrayfields['br.rowid']['checked'])) print_liste_field_titre($arrayfields['br.rowid']['label'], $_SERVER["PHP_SELF"], 'br.rowid', '', $param, '', $sortfield, $sortorder);
-        if (!empty($arrayfields['br.id_record']['checked'])) print_liste_field_titre($arrayfields['br.id_record']['label'], $_SERVER["PHP_SELF"], 'br.id_record', '', $param, '', $sortfield, $sortorder);
-        print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], 'br.label', '', $param, '', $sortfield, $sortorder);
-        if (!empty($arrayfields['br.comment']['checked'])) print_liste_field_titre($arrayfields['br.comment']['label'], $_SERVER["PHP_SELF"], 'br.comment', '', $param, '', $sortfield, $sortorder);
-        if (!empty($arrayfields['br.record_date']['checked'])) print_liste_field_titre($arrayfields['br.record_date']['label'].$filter_date_help, $_SERVER["PHP_SELF"], 'br.record_date', '', $param, 'align="center"', $sortfield, $sortorder);
-        if (!empty($arrayfields['br.vdate']['checked'])) print_liste_field_titre($arrayfields['br.vdate']['label'].$filter_date_help, $_SERVER["PHP_SELF"], 'br.vdate', '', $param, 'align="center"', $sortfield, $sortorder);
-        if (!empty($arrayfields['br.rdate']['checked'])) print_liste_field_titre($arrayfields['br.rdate']['label'].$filter_date_help, $_SERVER["PHP_SELF"], 'br.rdate', '', $param, 'align="center"', $sortfield, $sortorder);
-        if (!empty($arrayfields['br.bdate']['checked'])) print_liste_field_titre($arrayfields['br.bdate']['label'].$filter_date_help, $_SERVER["PHP_SELF"], 'br.bdate', '', $param, 'align="center"', $sortfield, $sortorder);
-        if (!empty($arrayfields['br.date_scraped']['checked'])) print_liste_field_titre($arrayfields['br.date_scraped']['label'].$filter_date_help, $_SERVER["PHP_SELF"], "br.date_scraped", "", $param, 'align="center"', $sortfield, $sortorder);
-        if (!empty($arrayfields['br.record_type']['checked'])) print_liste_field_titre($langs->trans("Type"), $_SERVER["PHP_SELF"], "br.record_type", "", $param, 'align="center"', $sortfield, $sortorder);
-        if (!empty($arrayfields['br.id_category']['checked'])) print_liste_field_titre($arrayfields['br.id_category']['label'], $_SERVER["PHP_SELF"], 'cb4dbrc.label', '', $param, '', $sortfield, $sortorder);
-        if (!empty($arrayfields['br.original_country']['checked'])) print_liste_field_titre($arrayfields['br.original_country']['label'], $_SERVER["PHP_SELF"], 'br.original_country', '', $param, '', $sortfield, $sortorder);
-        if (!empty($arrayfields['br.original_amount']['checked'])) print_liste_field_titre($arrayfields['br.original_amount']['label'], $_SERVER["PHP_SELF"], 'br.original_amount', '', $param, 'align="right"', $sortfield, $sortorder);
-        if (!empty($arrayfields['br.original_currency']['checked'])) print_liste_field_titre($arrayfields['br.original_currency']['label'], $_SERVER["PHP_SELF"], 'br.original_currency', '', $param, 'align="center"', $sortfield, $sortorder);
-        if (!empty($arrayfields['br.commission']['checked'])) print_liste_field_titre($arrayfields['br.commission']['label'], $_SERVER["PHP_SELF"], 'br.commission', '', $param, 'align="right"', $sortfield, $sortorder);
-        if (!empty($arrayfields['br.commission_currency']['checked'])) print_liste_field_titre($arrayfields['br.commission_currency']['label'], $_SERVER["PHP_SELF"], 'br.commission_currency', '', $param, 'align="center"', $sortfield, $sortorder);
-        // Hook fields
-        $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
-        $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters);    // Note that $action and $object may have been modified by hook
-        print $hookmanager->resPrint;
-        if (!empty($arrayfields['br.last_update_date']['checked'])) print_liste_field_titre($arrayfields['br.last_update_date']['label'].$filter_date_help, $_SERVER["PHP_SELF"], "br.last_update_date", "", $param, 'align="center"', $sortfield, $sortorder);
-        if (!empty($arrayfields['br.tms']['checked'])) print_liste_field_titre($arrayfields['br.tms']['label'].$filter_date_help, $_SERVER["PHP_SELF"], "br.tms", "", $param, 'align="center"', $sortfield, $sortorder);
-        print_liste_field_titre($langs->trans("Debit"), $_SERVER["PHP_SELF"], 'br.amount', '', $param, 'align="right"', $sortfield, $sortorder);
-        print_liste_field_titre($langs->trans("Credit"), $_SERVER["PHP_SELF"], 'br.amount', '', $param, 'align="right"', $sortfield, $sortorder);
-        if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
-            print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
-        }
-        print '</tr>' . "\n";
+		print '<tr class="liste_titre">';
+		if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+			print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ') . "\n";
+		}
+		if (!empty($arrayfields['br.rowid']['checked'])) print_liste_field_titre($arrayfields['br.rowid']['label'], $_SERVER["PHP_SELF"], 'br.rowid', '', $param, '', $sortfield, $sortorder);
+		if (!empty($arrayfields['br.id_record']['checked'])) print_liste_field_titre($arrayfields['br.id_record']['label'], $_SERVER["PHP_SELF"], 'br.id_record', '', $param, '', $sortfield, $sortorder);
+		print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], 'br.label', '', $param, '', $sortfield, $sortorder);
+		if (!empty($arrayfields['br.comment']['checked'])) print_liste_field_titre($arrayfields['br.comment']['label'], $_SERVER["PHP_SELF"], 'br.comment', '', $param, '', $sortfield, $sortorder);
+		if (!empty($arrayfields['br.record_date']['checked'])) print_liste_field_titre($arrayfields['br.record_date']['label'] . $filter_date_help, $_SERVER["PHP_SELF"], 'br.record_date', '', $param, 'align="center"', $sortfield, $sortorder);
+		if (!empty($arrayfields['br.vdate']['checked'])) print_liste_field_titre($arrayfields['br.vdate']['label'] . $filter_date_help, $_SERVER["PHP_SELF"], 'br.vdate', '', $param, 'align="center"', $sortfield, $sortorder);
+		if (!empty($arrayfields['br.rdate']['checked'])) print_liste_field_titre($arrayfields['br.rdate']['label'] . $filter_date_help, $_SERVER["PHP_SELF"], 'br.rdate', '', $param, 'align="center"', $sortfield, $sortorder);
+		if (!empty($arrayfields['br.bdate']['checked'])) print_liste_field_titre($arrayfields['br.bdate']['label'] . $filter_date_help, $_SERVER["PHP_SELF"], 'br.bdate', '', $param, 'align="center"', $sortfield, $sortorder);
+		if (!empty($arrayfields['br.date_scraped']['checked'])) print_liste_field_titre($arrayfields['br.date_scraped']['label'] . $filter_date_help, $_SERVER["PHP_SELF"], "br.date_scraped", "", $param, 'align="center"', $sortfield, $sortorder);
+		if (!empty($arrayfields['br.record_type']['checked'])) print_liste_field_titre($langs->trans("Type"), $_SERVER["PHP_SELF"], "br.record_type", "", $param, 'align="center"', $sortfield, $sortorder);
+		if (!empty($arrayfields['br.id_category']['checked'])) print_liste_field_titre($arrayfields['br.id_category']['label'], $_SERVER["PHP_SELF"], 'cb4dbrc.label', '', $param, '', $sortfield, $sortorder);
+		if (!empty($arrayfields['br.original_country']['checked'])) print_liste_field_titre($arrayfields['br.original_country']['label'], $_SERVER["PHP_SELF"], 'br.original_country', '', $param, '', $sortfield, $sortorder);
+		if (!empty($arrayfields['br.original_amount']['checked'])) print_liste_field_titre($arrayfields['br.original_amount']['label'], $_SERVER["PHP_SELF"], 'br.original_amount', '', $param, 'align="right"', $sortfield, $sortorder);
+		if (!empty($arrayfields['br.original_currency']['checked'])) print_liste_field_titre($arrayfields['br.original_currency']['label'], $_SERVER["PHP_SELF"], 'br.original_currency', '', $param, 'align="center"', $sortfield, $sortorder);
+		if (!empty($arrayfields['br.commission']['checked'])) print_liste_field_titre($arrayfields['br.commission']['label'], $_SERVER["PHP_SELF"], 'br.commission', '', $param, 'align="right"', $sortfield, $sortorder);
+		if (!empty($arrayfields['br.commission_currency']['checked'])) print_liste_field_titre($arrayfields['br.commission_currency']['label'], $_SERVER["PHP_SELF"], 'br.commission_currency', '', $param, 'align="center"', $sortfield, $sortorder);
+		// Hook fields
+		$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
+		$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters);    // Note that $action and $object may have been modified by hook
+		print $hookmanager->resPrint;
+		if (!empty($arrayfields['br.last_update_date']['checked'])) print_liste_field_titre($arrayfields['br.last_update_date']['label'] . $filter_date_help, $_SERVER["PHP_SELF"], "br.last_update_date", "", $param, 'align="center"', $sortfield, $sortorder);
+		if (!empty($arrayfields['br.tms']['checked'])) print_liste_field_titre($arrayfields['br.tms']['label'] . $filter_date_help, $_SERVER["PHP_SELF"], "br.tms", "", $param, 'align="center"', $sortfield, $sortorder);
+		print_liste_field_titre($langs->trans("Debit"), $_SERVER["PHP_SELF"], 'br.amount', '', $param, 'align="right"', $sortfield, $sortorder);
+		print_liste_field_titre($langs->trans("Credit"), $_SERVER["PHP_SELF"], 'br.amount', '', $param, 'align="right"', $sortfield, $sortorder);
+		if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+			print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
+		}
+		print '</tr>' . "\n";
 
 		$bankaccountstatic = new Account($db);
 		$banktransferstatic = new BonPrelevement($db);
@@ -814,219 +814,216 @@ SCRIPT;
 		$banklinestatic = new AccountLine($db);
 
 		$i = 0;
-        $totalarray = array();
-        $print_lines = array();
-        $object_cached = array();
-        $payment_type_cached = array();
-        $last_key = '';
-        while ($i < min($num, $limit)) {
-            $obj = $db->fetch_object($resql);
-
-            $object_key = $obj->element_type . '_' . $obj->element_id . '_' . $obj->fk_bank;
-            $key = $view_mode == 1 ? $obj->rowid : $object_key;
-
-            if (!isset($object_cached[$object_key])) {
-                if (!empty($obj->element_type)) {
-                    $srcobject = opendsi_get_object($db, $obj->element_type, $obj->element_id);
-                } else {
-                    $srcobject = new AccountLine($db);
-                    $srcobject->fetch($obj->fk_bank);
-                }
-                $srcobject->fetch_thirdparty();
-
-                $object_cached[$object_key] = $srcobject;
-            }
-
-            $object_temp = $object_cached[$object_key];
-            $amount = $object_temp->element == 'bank' ? $object_temp->amount : $obj->unpaid_amount;
-
-            //-----------------------------------------------------
-            // Bank record - Begin
-            //-----------------------------------------------------
-            ob_start();
-
-            $padding_class = $view_mode != 1 ? ' class="b4d_padding"' : '';
-
-            // Action column
-            if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
-                print '<td class="right nowrap">';
-                if ($view_mode != 1)   // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
-                {
-                    $selected = 0;
-                    if (in_array($obj->pre_link_id, $arrayofselected)) $selected = 1;
-                    print ' <input id="cb_' . $obj->pre_link_id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj->pre_link_id . '"' . ($selected ? ' checked="checked"' : '') . '>';
-                }
-                print '</td>';
-                if (!$i) $totalarray['nbfield']++;
-            }
-            if (!empty($arrayfields['br.rowid']['checked'])) {
-                print '<td' . $padding_class . '>';
-                print $obj->rowid;
-                print "</td>\n";
-                if (!$i) $totalarray['nbfield']++;
-            }
-            if (!empty($arrayfields['br.id_record']['checked'])) {
-                print '<td' . (empty($arrayfields['br.rowid']['checked']) ? $padding_class : '') . '>';
-                print $obj->id_record;
-                print "</td>\n";
-                if (!$i) $totalarray['nbfield']++;
-            }
-            print '<td' . (empty($arrayfields['br.rowid']['checked']) || empty($arrayfields['br.id_record']['checked']) ? $padding_class : '') . '>';
-            print $obj->label;
-            print "</td>\n";
-            if (!$i) $totalarray['nbfield']++;
-            if (!empty($arrayfields['br.comment']['checked'])) {
-                print '<td>';
-                print $obj->comment;
-                print "</td>\n";
-                if (!$i) $totalarray['nbfield']++;
-            }
-            if (!$i) $totalarray['nbfield_pre_record_date'] = $totalarray['nbfield'];
-            if (!empty($arrayfields['br.record_date']['checked'])) {
-                print '<td align="center">';
-                if (!empty($obj->record_date)) print dol_print_date($db->jdate($obj->record_date), 'day');
-                print "</td>\n";
-                if (!$i) $totalarray['nbfield']++;
-            }
-            if (!empty($arrayfields['br.vdate']['checked'])) {
-                print '<td align="center">';
-                if (!empty($obj->vdate)) print dol_print_date($db->jdate($obj->vdate), 'day');
-                elseif (!empty($obj->record_date)) print dol_print_date($db->jdate($obj->record_date), 'day');
-                print "</td>\n";
-                if (!$i) $totalarray['nbfield']++;
-            }
-            if (!empty($arrayfields['br.rdate']['checked'])) {
-                print '<td align="center">';
-                if (!empty($obj->rdate)) print dol_print_date($db->jdate($obj->rdate), 'day');
-                print "</td>\n";
-                if (!$i) $totalarray['nbfield']++;
-            }
-            if (!empty($arrayfields['br.bdate']['checked'])) {
-                print '<td align="center">';
-                if (!empty($obj->bdate)) print dol_print_date($db->jdate($obj->bdate), 'day');
-                print "</td>\n";
-                if (!$i) $totalarray['nbfield']++;
-            }
-            if (!empty($arrayfields['br.date_scraped']['checked'])) {
-                print '<td align="center">';
-                if (!empty($obj->date_scraped)) print dol_print_date($db->jdate($obj->date_scraped), 'dayhour');
-                print "</td>\n";
-                if (!$i) $totalarray['nbfield']++;
-            }
-            if (!$i) $totalarray['nbfield_pre_record_type'] = $totalarray['nbfield'];
-            if (!empty($arrayfields['br.record_type']['checked'])) {
-                print '<td align="center">';
-                print $budgetinsightbankrecord->LibType($obj->record_type);
-                if ($budgetinsightbankrecord->getDolibarrPaymentModeId($obj->record_type) < 0) {
-                    print ' : ';
-                    $form->select_types_paiements(isset($payment_modes[$obj->pre_link_id]) ? $payment_modes[$obj->pre_link_id] : GETPOST('payment_mode_' . $obj->pre_link_id, 'alpha'),
-                        'payment_mode_' . $obj->pre_link_id, $obj->amount < 0 ? 'DBIT' : 'CRDT', 0, 1);
-                }
-                print "</td>\n";
-                if (!$i) $totalarray['nbfield']++;
-            }
-            if (!empty($arrayfields['br.id_category']['checked'])) {
-                print '<td>';
-                print $obj->category_label;
-                print "</td>\n";
-                if (!$i) $totalarray['nbfield']++;
-            }
-            if (!empty($arrayfields['br.original_country']['checked'])) {
-                print '<td>';
-                print $obj->original_country;
-                print "</td>\n";
-                if (!$i) $totalarray['nbfield']++;
-            }
-            if (!empty($arrayfields['br.original_amount']['checked'])) {
-                print '<td class="right">';
-                if ($obj->original_amount > 0) print price($obj->original_amount);
-                print "</td>\n";
-                if (!$i) $totalarray['nbfield']++;
-            }
-            if (!empty($arrayfields['br.original_currency']['checked'])) {
-                print '<td align="center">';
-                if (!empty($obj->original_currency)) print $langs->trans('Currency' . $obj->original_currency);
-                print "</td>\n";
-                if (!$i) $totalarray['nbfield']++;
-            }
-            if (!empty($arrayfields['br.commission']['checked'])) {
-                print '<td class="right">';
-                if ($obj->commission > 0) print price($obj->commission);
-                print "</td>\n";
-                if (!$i) $totalarray['nbfield']++;
-            }
-            if (!empty($arrayfields['br.commission_currency']['checked'])) {
-                print '<td align="center">';
-                if (!empty($obj->commission_currency)) print $langs->trans('Currency' . $obj->commission_currency);
-                print "</td>\n";
-                if (!$i) $totalarray['nbfield']++;
-            }
-            // Fields from hook
-            $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj);
-            $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters);    // Note that $action and $object may have been modified by hook
-            print $hookmanager->resPrint;
-            if (!empty($arrayfields['br.last_update_date']['checked'])) {
-                print '<td align="center">';
-                print dol_print_date($db->jdate($obj->last_update_date), 'dayhour', 'tzuser');
-                print '</td>';
-                if (!$i) $totalarray['nbfield']++;
-            }
-            if (!empty($arrayfields['br.tms']['checked'])) {
-                print '<td align="center">';
-                print dol_print_date($db->jdate($obj->tms), 'dayhour', 'tzuser');
-                print '</td>';
-                if (!$i) $totalarray['nbfield']++;
-            }
-            print '<td class="right">';
-            if ($obj->amount < 0) {
-                print price($obj->amount * -1);
-            }
-            print "</td>\n";
-            if (!$i) $totalarray['nbfield']++;
-            print '<td class="right">';
-            if ($obj->amount > 0) {
-                print price($obj->amount);
-            }
-            print "</td>\n";
-            if (!$i) $totalarray['nbfield']++;
-            // Action column
-            if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
-                print '<td class="right nowrap">';
-                if ($view_mode != 1)   // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
-                {
-                    $selected = 0;
-                    if (in_array($obj->pre_link_id, $arrayofselected)) $selected = 1;
-                    print ' <input id="cb_' . $obj->pre_link_id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj->pre_link_id . '"' . ($selected ? ' checked="checked"' : '') . '>';
-                }
-                print '</td>';
-                if (!$i) $totalarray['nbfield']++;
-            }
-
-            $bank_record_line = ob_get_contents();
-            ob_end_clean();
-            //-----------------------------------------------------
-            // Bank record - End
-            //-----------------------------------------------------
-
-            //-----------------------------------------------------
-            // Object - Begin
-            //-----------------------------------------------------
-            ob_start();
-
-            if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
-                print '<td class="right nowrap">';
-                if ($view_mode == 1)   // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
-                {
-                    $selected = 0;
-                    if (in_array($obj->pre_link_id, $arrayofselected)) $selected = 1;
-                    print ' <input id="cb_' . $obj->pre_link_id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj->pre_link_id . '"' . ($selected ? ' checked="checked"' : '') . '>';
-                }
-                print '</td>';
-            }
-            $colspan = $totalarray['nbfield_pre_record_date'];
-            print '<td colspan="' . $colspan . '"' . ($view_mode == 1 ? ' class="b4d_padding"' : '') . '>';
-            if (isset($object_temp)) print $object_temp->getNomUrl(1);
-            $infos_to_print = array();
+		$totalarray = array();
+		$print_lines = array();
+		$object_cached = array();
+		$payment_type_cached = array();
+		$last_key = '';
+		while ($i < min($num, $limit)) {
+			$obj = $db->fetch_object($resql);
+
+			$object_key = $obj->element_type . '_' . $obj->element_id . '_' . $obj->fk_bank;
+			$key = $view_mode == 1 ? $obj->rowid : $object_key;
+
+			if (!isset($object_cached[$object_key])) {
+				if (!empty($obj->element_type)) {
+					$srcobject = opendsi_get_object($db, $obj->element_type, $obj->element_id);
+				} else {
+					$srcobject = new AccountLine($db);
+					$srcobject->fetch($obj->fk_bank);
+				}
+				$srcobject->fetch_thirdparty();
+
+				$object_cached[$object_key] = $srcobject;
+			}
+
+			$object_temp = $object_cached[$object_key];
+			$amount = $object_temp->element == 'bank' ? $object_temp->amount : $obj->unpaid_amount;
+
+			//-----------------------------------------------------
+			// Bank record - Begin
+			//-----------------------------------------------------
+			ob_start();
+
+			$padding_class = $view_mode != 1 ? ' class="b4d_padding"' : '';
+
+			// Action column
+			if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+				print '<td class="right nowrap">';
+				if ($view_mode != 1) {  // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+					$selected = 0;
+					if (in_array($obj->pre_link_id, $arrayofselected)) $selected = 1;
+					print ' <input id="cb_' . $obj->pre_link_id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj->pre_link_id . '"' . ($selected ? ' checked="checked"' : '') . '>';
+				}
+				print '</td>';
+				if (!$i) $totalarray['nbfield']++;
+			}
+			if (!empty($arrayfields['br.rowid']['checked'])) {
+				print '<td' . $padding_class . '>';
+				print $obj->rowid;
+				print "</td>\n";
+				if (!$i) $totalarray['nbfield']++;
+			}
+			if (!empty($arrayfields['br.id_record']['checked'])) {
+				print '<td' . (empty($arrayfields['br.rowid']['checked']) ? $padding_class : '') . '>';
+				print $obj->id_record;
+				print "</td>\n";
+				if (!$i) $totalarray['nbfield']++;
+			}
+			print '<td' . (empty($arrayfields['br.rowid']['checked']) || empty($arrayfields['br.id_record']['checked']) ? $padding_class : '') . '>';
+			print $obj->label;
+			print "</td>\n";
+			if (!$i) $totalarray['nbfield']++;
+			if (!empty($arrayfields['br.comment']['checked'])) {
+				print '<td>';
+				print $obj->comment;
+				print "</td>\n";
+				if (!$i) $totalarray['nbfield']++;
+			}
+			if (!$i) $totalarray['nbfield_pre_record_date'] = $totalarray['nbfield'];
+			if (!empty($arrayfields['br.record_date']['checked'])) {
+				print '<td align="center">';
+				if (!empty($obj->record_date)) print dol_print_date($db->jdate($obj->record_date), 'day');
+				print "</td>\n";
+				if (!$i) $totalarray['nbfield']++;
+			}
+			if (!empty($arrayfields['br.vdate']['checked'])) {
+				print '<td align="center">';
+				if (!empty($obj->vdate)) print dol_print_date($db->jdate($obj->vdate), 'day');
+				elseif (!empty($obj->record_date)) print dol_print_date($db->jdate($obj->record_date), 'day');
+				print "</td>\n";
+				if (!$i) $totalarray['nbfield']++;
+			}
+			if (!empty($arrayfields['br.rdate']['checked'])) {
+				print '<td align="center">';
+				if (!empty($obj->rdate)) print dol_print_date($db->jdate($obj->rdate), 'day');
+				print "</td>\n";
+				if (!$i) $totalarray['nbfield']++;
+			}
+			if (!empty($arrayfields['br.bdate']['checked'])) {
+				print '<td align="center">';
+				if (!empty($obj->bdate)) print dol_print_date($db->jdate($obj->bdate), 'day');
+				print "</td>\n";
+				if (!$i) $totalarray['nbfield']++;
+			}
+			if (!empty($arrayfields['br.date_scraped']['checked'])) {
+				print '<td align="center">';
+				if (!empty($obj->date_scraped)) print dol_print_date($db->jdate($obj->date_scraped), 'dayhour');
+				print "</td>\n";
+				if (!$i) $totalarray['nbfield']++;
+			}
+			if (!$i) $totalarray['nbfield_pre_record_type'] = $totalarray['nbfield'];
+			if (!empty($arrayfields['br.record_type']['checked'])) {
+				print '<td align="center">';
+				print $budgetinsightbankrecord->LibType($obj->record_type);
+				if ($budgetinsightbankrecord->getDolibarrPaymentModeId($obj->record_type) < 0) {
+					print ' : ';
+					$form->select_types_paiements(isset($payment_modes[$obj->pre_link_id]) ? $payment_modes[$obj->pre_link_id] : GETPOST('payment_mode_' . $obj->pre_link_id, 'alpha'),
+						'payment_mode_' . $obj->pre_link_id, $obj->amount < 0 ? 'DBIT' : 'CRDT', 0, 1);
+				}
+				print "</td>\n";
+				if (!$i) $totalarray['nbfield']++;
+			}
+			if (!empty($arrayfields['br.id_category']['checked'])) {
+				print '<td>';
+				print $obj->category_label;
+				print "</td>\n";
+				if (!$i) $totalarray['nbfield']++;
+			}
+			if (!empty($arrayfields['br.original_country']['checked'])) {
+				print '<td>';
+				print $obj->original_country;
+				print "</td>\n";
+				if (!$i) $totalarray['nbfield']++;
+			}
+			if (!empty($arrayfields['br.original_amount']['checked'])) {
+				print '<td class="right">';
+				if ($obj->original_amount > 0) print price($obj->original_amount);
+				print "</td>\n";
+				if (!$i) $totalarray['nbfield']++;
+			}
+			if (!empty($arrayfields['br.original_currency']['checked'])) {
+				print '<td align="center">';
+				if (!empty($obj->original_currency)) print $langs->trans('Currency' . $obj->original_currency);
+				print "</td>\n";
+				if (!$i) $totalarray['nbfield']++;
+			}
+			if (!empty($arrayfields['br.commission']['checked'])) {
+				print '<td class="right">';
+				if ($obj->commission > 0) print price($obj->commission);
+				print "</td>\n";
+				if (!$i) $totalarray['nbfield']++;
+			}
+			if (!empty($arrayfields['br.commission_currency']['checked'])) {
+				print '<td align="center">';
+				if (!empty($obj->commission_currency)) print $langs->trans('Currency' . $obj->commission_currency);
+				print "</td>\n";
+				if (!$i) $totalarray['nbfield']++;
+			}
+			// Fields from hook
+			$parameters = array('arrayfields' => $arrayfields, 'obj' => $obj);
+			$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters);    // Note that $action and $object may have been modified by hook
+			print $hookmanager->resPrint;
+			if (!empty($arrayfields['br.last_update_date']['checked'])) {
+				print '<td align="center">';
+				print dol_print_date($db->jdate($obj->last_update_date), 'dayhour', 'tzuser');
+				print '</td>';
+				if (!$i) $totalarray['nbfield']++;
+			}
+			if (!empty($arrayfields['br.tms']['checked'])) {
+				print '<td align="center">';
+				print dol_print_date($db->jdate($obj->tms), 'dayhour', 'tzuser');
+				print '</td>';
+				if (!$i) $totalarray['nbfield']++;
+			}
+			print '<td class="right">';
+			if ($obj->amount < 0) {
+				print price($obj->amount * -1);
+			}
+			print "</td>\n";
+			if (!$i) $totalarray['nbfield']++;
+			print '<td class="right">';
+			if ($obj->amount > 0) {
+				print price($obj->amount);
+			}
+			print "</td>\n";
+			if (!$i) $totalarray['nbfield']++;
+			// Action column
+			if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+				print '<td class="right nowrap">';
+				if ($view_mode != 1) {  // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+					$selected = 0;
+					if (in_array($obj->pre_link_id, $arrayofselected)) $selected = 1;
+					print ' <input id="cb_' . $obj->pre_link_id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj->pre_link_id . '"' . ($selected ? ' checked="checked"' : '') . '>';
+				}
+				print '</td>';
+				if (!$i) $totalarray['nbfield']++;
+			}
+
+			$bank_record_line = ob_get_contents();
+			ob_end_clean();
+			//-----------------------------------------------------
+			// Bank record - End
+			//-----------------------------------------------------
+
+			//-----------------------------------------------------
+			// Object - Begin
+			//-----------------------------------------------------
+			ob_start();
+
+			if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+				print '<td class="right nowrap">';
+				if ($view_mode == 1) {  // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+					$selected = 0;
+					if (in_array($obj->pre_link_id, $arrayofselected)) $selected = 1;
+					print ' <input id="cb_' . $obj->pre_link_id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj->pre_link_id . '"' . ($selected ? ' checked="checked"' : '') . '>';
+				}
+				print '</td>';
+			}
+			$colspan = $totalarray['nbfield_pre_record_date'];
+			print '<td colspan="' . $colspan . '"' . ($view_mode == 1 ? ' class="b4d_padding"' : '') . '>';
+			if (isset($object_temp)) print $object_temp->getNomUrl(1);
+			$infos_to_print = array();
 			if ($object_temp->element == 'bank') {
 				$reg = array();
 				preg_match('/\((.+)\)/i', $object_temp->label, $reg); // Si texte entoure de parenthee on tente recherche de traduction
@@ -1148,128 +1145,127 @@ SCRIPT;
 				$infos_to_print[] = $langs->trans('ThirdParty') . ' : ' . $object_temp->thirdparty->getNomUrl(1);
 			}
 			if (!empty($infos_to_print)) print ' ( ' . implode('; ', $infos_to_print) . ' )';
-            print "</td>\n";
-            if (!empty($arrayfields['br.record_date']['checked'])) {
-                print '<td class="center">';
+			print "</td>\n";
+			if (!empty($arrayfields['br.record_date']['checked'])) {
+				print '<td class="center">';
 				if (isset($object_temp) && $object_temp->element == 'bank') print dol_print_date($db->jdate($object_temp->dateo), 'day');
 				else {
 					print dol_print_date($db->jdate($obj->unpaid_dateb), 'day');
 					if (!empty($obj->unpaid_datee)) print ' ' . $langs->trans('to') . ' ' . dol_print_date($db->jdate($obj->unpaid_datee), 'day');
 				}
-                print "</td>\n";
-                $colspan++;
-            }
-            if (!empty($arrayfields['br.vdate']['checked'])) {
-                print '<td class="center">';
-                if (isset($object_temp) && $object_temp->element == 'bank') print dol_print_date($db->jdate($object_temp->datev), 'day');
-                print "</td>\n";
-                $colspan++;
-            }
-            $colspan2 = $colspan < $totalarray['nbfield_pre_record_type'] ? $totalarray['nbfield_pre_record_type'] - $colspan : 0;
-            if ($colspan2 > 0) print '<td colspan="' . $colspan2 . '">' . "</td>\n";
-            if (!empty($arrayfields['br.record_type']['checked'])) {
-                print '<td align="center">';
-                if (isset($object_temp) && $object_temp->element == 'bank') {
-                    if (!isset($payment_type_cached[$object_temp->type])) {
-                        $payment_type = ($langs->trans("PaymentTypeShort" . $object_temp->type) != "PaymentTypeShort" . $object_temp->type) ? $langs->trans("PaymentTypeShort" . $object_temp->type) : $langs->getLabelFromKey($db, $object_temp->type, 'c_paiement', 'code', 'libelle', '', 1);
-                        if ($payment_type == 'SOLD') $payment_type = '';
-                        $payment_type_cached[$object_temp->type] = $payment_type;
-                    }
-                    print $payment_type_cached[$object_temp->type];
-                }
-                print "</td>\n";
-                $colspan2++;
-            }
-            $colspan3 = $colspan + $colspan2 + 3 < $totalarray['nbfield'] ? $totalarray['nbfield'] - ($colspan + $colspan2 + 3) : 0;
-            if ($colspan3 > 0) print '<td colspan="' . $colspan3 . '">' . "</td>\n";
-            print '<td class="nowrap right">';
-            if ($amount < 0) {
-                print price($amount * -1);
-            }
-            print "</td>\n";
-            print '<td class="nowrap right">';
-            if ($amount > 0) {
-                print price($amount);
-            }
-            print "</td>\n";
-            // Action column
-            if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
-                print '<td class="right nowrap">';
-                if ($view_mode == 1)   // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
-                {
-                    $selected = 0;
-                    if (in_array($obj->pre_link_id, $arrayofselected)) $selected = 1;
-                    print ' <input id="cb_' . $obj->pre_link_id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj->pre_link_id . '"' . ($selected ? ' checked="checked"' : '') . '>';
-                }
-                print '</td>';
-            }
-
-            $object_line = ob_get_contents();
-            ob_end_clean();
-            //-----------------------------------------------------
-            // Object - End
-            //-----------------------------------------------------
-
-            if ($key != $last_key) {
-                if (!empty($print_lines)) {
-                    print '<tr class="oddeven" id="' . $last_key . '">' . $print_lines['header'] . '</tr>' . "\n";
-                    $nb_lines = count($print_lines['lines']);
-
-                    for ($idx = 0; $idx < $nb_lines; $idx++) {
-                        $class = ' b4d_middle_line';
-                        if ($idx == 0) $class .= ' b4d_first_line';
-                        if ($idx == $nb_lines - 1) $class .= ' b4d_last_line';
-                        print '<tr class="oddeven' . $class . '">' . $print_lines['lines'][$idx] . '</tr>' . "\n";
-                    }
-                }
-
-                $print_lines = [
-                    'header' => $view_mode == 1 ? $bank_record_line : $object_line,
-                    'lines' => array(),
-                ];
-            }
-            $print_lines['lines'][] = $view_mode == 1 ? $object_line : $bank_record_line;
-
-            $last_key = $key;
-
-            $i++;
-        }
-
-        // Print lines
-        print '<tr class="oddeven" id="' . $last_key . '">' . $print_lines['header'] . '</tr>' . "\n";
-        $nb_lines = count($print_lines['lines']);
-        for ($idx = 0; $idx < $nb_lines; $idx++) {
-            print '<tr class="oddeven">' . $print_lines['lines'][$idx] . '</tr>' . "\n";
-        }
-
-        $db->free($resql);
-
-        $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
-        $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters);    // Note that $action and $object may have been modified by hook
-        print $hookmanager->resPrint;
-
-        print '</table>' . "\n";
-
-        if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
-            $balign = 'left';
-        } else {
-            $balign = 'right';
-        }
-
-        print '<div class="'.$balign.'">';
-        print '<input type="submit" name="button_cancel" class="button" value="' . $langs->trans("Banking4DolibarrFinish") . '">';
-        print '&nbsp;&nbsp;';
-        print '<input type="submit" name="button_valid_links" class="button" value="' . $langs->trans("Banking4DolibarrValidLinks") . '">';
-        print '</div>';
-
-        print '</div>' . "\n";
-
-        print '</form>' . "\n";
-    } else {
-        dol_print_error($db);
-    }
+				print "</td>\n";
+				$colspan++;
+			}
+			if (!empty($arrayfields['br.vdate']['checked'])) {
+				print '<td class="center">';
+				if (isset($object_temp) && $object_temp->element == 'bank') print dol_print_date($db->jdate($object_temp->datev), 'day');
+				print "</td>\n";
+				$colspan++;
+			}
+			$colspan2 = $colspan < $totalarray['nbfield_pre_record_type'] ? $totalarray['nbfield_pre_record_type'] - $colspan : 0;
+			if ($colspan2 > 0) print '<td colspan="' . $colspan2 . '">' . "</td>\n";
+			if (!empty($arrayfields['br.record_type']['checked'])) {
+				print '<td align="center">';
+				if (isset($object_temp) && $object_temp->element == 'bank') {
+					if (!isset($payment_type_cached[$object_temp->type])) {
+						$payment_type = ($langs->trans("PaymentTypeShort" . $object_temp->type) != "PaymentTypeShort" . $object_temp->type) ? $langs->trans("PaymentTypeShort" . $object_temp->type) : $langs->getLabelFromKey($db, $object_temp->type, 'c_paiement', 'code', 'libelle', '', 1);
+						if ($payment_type == 'SOLD') $payment_type = '';
+						$payment_type_cached[$object_temp->type] = $payment_type;
+					}
+					print $payment_type_cached[$object_temp->type];
+				}
+				print "</td>\n";
+				$colspan2++;
+			}
+			$colspan3 = $colspan + $colspan2 + 3 < $totalarray['nbfield'] ? $totalarray['nbfield'] - ($colspan + $colspan2 + 3) : 0;
+			if ($colspan3 > 0) print '<td colspan="' . $colspan3 . '">' . "</td>\n";
+			print '<td class="nowrap right">';
+			if ($amount < 0) {
+				print price($amount * -1);
+			}
+			print "</td>\n";
+			print '<td class="nowrap right">';
+			if ($amount > 0) {
+				print price($amount);
+			}
+			print "</td>\n";
+			// Action column
+			if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+				print '<td class="right nowrap">';
+				if ($view_mode == 1) {   // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+					$selected = 0;
+					if (in_array($obj->pre_link_id, $arrayofselected)) $selected = 1;
+					print ' <input id="cb_' . $obj->pre_link_id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj->pre_link_id . '"' . ($selected ? ' checked="checked"' : '') . '>';
+				}
+				print '</td>';
+			}
+
+			$object_line = ob_get_contents();
+			ob_end_clean();
+			//-----------------------------------------------------
+			// Object - End
+			//-----------------------------------------------------
+
+			if ($key != $last_key) {
+				if (!empty($print_lines)) {
+					print '<tr class="oddeven" id="' . $last_key . '">' . $print_lines['header'] . '</tr>' . "\n";
+					$nb_lines = count($print_lines['lines']);
+
+					for ($idx = 0; $idx < $nb_lines; $idx++) {
+						$class = ' b4d_middle_line';
+						if ($idx == 0) $class .= ' b4d_first_line';
+						if ($idx == $nb_lines - 1) $class .= ' b4d_last_line';
+						print '<tr class="oddeven' . $class . '">' . $print_lines['lines'][$idx] . '</tr>' . "\n";
+					}
+				}
+
+				$print_lines = [
+					'header' => $view_mode == 1 ? $bank_record_line : $object_line,
+					'lines' => array(),
+				];
+			}
+			$print_lines['lines'][] = $view_mode == 1 ? $object_line : $bank_record_line;
+
+			$last_key = $key;
+
+			$i++;
+		}
+
+		// Print lines
+		print '<tr class="oddeven" id="' . $last_key . '">' . $print_lines['header'] . '</tr>' . "\n";
+		$nb_lines = count($print_lines['lines']);
+		for ($idx = 0; $idx < $nb_lines; $idx++) {
+			print '<tr class="oddeven">' . $print_lines['lines'][$idx] . '</tr>' . "\n";
+		}
+
+		$db->free($resql);
+
+		$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
+		$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters);    // Note that $action and $object may have been modified by hook
+		print $hookmanager->resPrint;
+
+		print '</table>' . "\n";
+
+		if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+			$balign = 'left';
+		} else {
+			$balign = 'right';
+		}
+
+		print '<div class="' . $balign . '">';
+		print '<input type="submit" name="button_cancel" class="button" value="' . $langs->trans("Banking4DolibarrFinish") . '">';
+		print '&nbsp;&nbsp;';
+		print '<input type="submit" name="button_valid_links" class="button" value="' . $langs->trans("Banking4DolibarrValidLinks") . '">';
+		print '</div>';
+
+		print '</div>' . "\n";
+
+		print '</form>' . "\n";
+	} else {
+		dol_print_error($db);
+	}
 } else {
-    print $langs->trans("None");
+	print $langs->trans("None");
 }
 
 $wait_text = dol_escape_js($langs->trans('Banking4DolibarrPleaseWait'), 2);
-- 
GitLab


From b502c268e6f5316479785057f853a91415feee74 Mon Sep 17 00:00:00 2001
From: Kamel Khelifa <kkhelifa@open-dsi.fr>
Date: Mon, 7 Apr 2025 15:54:52 +0200
Subject: [PATCH 2/2] =?UTF-8?q?FIX=20-=20N'affiche=20que=20les=20bordereau?=
 =?UTF-8?q?x=20de=20cheques=20non=20rapproch=C3=A9s=20dans=20les=20bordere?=
 =?UTF-8?q?aux=20disponible=20sur=20l'=C3=A9cran=20du=20rapprochement=20ma?=
 =?UTF-8?q?nuelle=20-=20N'affiche=20que=20les=20ordres=20de=20prelevements?=
 =?UTF-8?q?=20non=20rapproch=C3=A9s=20dans=20les=20ordres=20de=20preleveme?=
 =?UTF-8?q?nts=20disponible=20sur=20l'=C3=A9cran=20du=20rapprochement=20ma?=
 =?UTF-8?q?nuelle=20-=20Suppression=20de=20la=20liste=20des=20ordres=20de?=
 =?UTF-8?q?=20virements=20disponible=20sur=20l'=C3=A9cran=20du=20rapproche?=
 =?UTF-8?q?ment=20manuelle=20-=20Suppression=20du=20rapprochement=20auto?=
 =?UTF-8?q?=20des=20ordres=20de=20virements=20-=20Les=20=C3=A9critures=20b?=
 =?UTF-8?q?ancaires=20issue=20des=20ordres=20de=20viremment=20apparaitrons?=
 =?UTF-8?q?=20sur=20l'ecran=20de=20rapprochement=20manuelles=20des=20ecrit?=
 =?UTF-8?q?ures=20bancaires=20dolibarr=20et=20seront=20aussi=20dans=20les?=
 =?UTF-8?q?=20tests=20de=20rapprochement=20automatique=20des=20ecritures?=
 =?UTF-8?q?=20bancaires=20dolibarr?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ChangeLog.md                                  | 11 ++-
 VERSION                                       |  2 +-
 class/budgetinsight.class.php                 | 78 +++++++++----------
 ...anual_reconciliation_chequereceipt.tpl.php |  5 +-
 ...4d_manual_reconciliation_widthdraw.tpl.php | 23 ++++--
 5 files changed, 71 insertions(+), 48 deletions(-)

diff --git a/ChangeLog.md b/ChangeLog.md
index e877f96..bbe0abe 100755
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -3,6 +3,13 @@ Le format du fichier est basé sur [Tenez un ChangeLog](http://keepachangelog.co
 
 ## [Non Distribué]
 
+## [14.0.64] - 07-04-2025
+- N'affiche que les bordereaux de cheques non rapprochés dans les bordereaux disponible sur l'écran du rapprochement manuelle
+- N'affiche que les ordres de prelevements non rapprochés dans les ordres de prelevements disponible sur l'écran du rapprochement manuelle
+- Suppression de la liste des ordres de virements disponible sur l'écran du rapprochement manuelle
+- Suppression du rapprochement auto des ordres de virements
+- Les écritures bancaires issue des ordres de viremment apparaitrons sur l'ecran de rapprochement manuelles des ecritures bancaires dolibarr et seront aussi dans les tests de rapprochement automatique des ecritures bancaires dolibarr
+
 ## [14.0.63] - 20-03-2025
 - Mise à jour de l'url par défaut des statuts des connexions Powens (https://powens.statuspal.eu/)
 - Rajout de la class 'tdoverflowmax100' sur la colonne "Type" de la liste des écritures téléchargées
@@ -811,7 +818,9 @@ Le format du fichier est basé sur [Tenez un ChangeLog](http://keepachangelog.co
 ## [7.0.0] - 15-11-2019
 - Version initiale.
 
-[Non Distribué]: http://git.open-dsi.fr/dolibarr-extension/banking4dolibarr/compare/14.0.62...HEAD
+[Non Distribué]: http://git.open-dsi.fr/dolibarr-extension/banking4dolibarr/compare/14.0.64...HEAD
+[14.0.64]: http://git.open-dsi.fr/dolibarr-extension/banking4dolibarr/commits/14.0.64
+[14.0.63]: http://git.open-dsi.fr/dolibarr-extension/banking4dolibarr/commits/14.0.63
 [14.0.62]: http://git.open-dsi.fr/dolibarr-extension/banking4dolibarr/commits/14.0.62
 [14.0.61]: http://git.open-dsi.fr/dolibarr-extension/banking4dolibarr/commits/14.0.61
 [14.0.60]: http://git.open-dsi.fr/dolibarr-extension/banking4dolibarr/commits/14.0.60
diff --git a/VERSION b/VERSION
index 6a55cb1..d4ad64c 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-14.0.63
\ No newline at end of file
+14.0.64
\ No newline at end of file
diff --git a/class/budgetinsight.class.php b/class/budgetinsight.class.php
index cd882be..cd7236b 100755
--- a/class/budgetinsight.class.php
+++ b/class/budgetinsight.class.php
@@ -2581,10 +2581,10 @@ class BudgetInsight
 		if (!empty($conf->prelevement->enabled)) {
 			$objectTypes['widthdraw'] = array('label' => $langs->trans('StandingOrders'), 'payment_mode_require' => 0);;
 		}
-		if (!empty($conf->paymentbybanktransfer->enabled)) {
-			$langs->load('withdrawals');
-			$objectTypes['payment_by_bank_transfer'] = array('label' => $langs->trans('BankTransferReceipts'), 'payment_mode_require' => 0);
-		}
+//		if (!empty($conf->paymentbybanktransfer->enabled)) {
+//			$langs->load('withdrawals');
+//			$objectTypes['payment_by_bank_transfer'] = array('label' => $langs->trans('BankTransferReceipts'), 'payment_mode_require' => 0);
+//		}
 		if ($user->rights->banque->transfer) {
 			$objectTypes['bank_transfer'] = array('label' => $langs->trans('Banking4DolibarrNewBankTransfers'), 'payment_mode_require' => 0);
 		}
@@ -4430,20 +4430,20 @@ class BudgetInsight
 				" LEFT JOIN " . MAIN_DB_PREFIX . "bank_account AS ba ON ba.rowid = b.fk_account" .
 				" LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu ON bu.fk_bank = b.rowid" .
 				" WHERE ba.entity IN (" . getEntity('bank_account') . ")" .
-				" AND bu.type = 'withdraw'" . ($isV19p ? " OR bu.type = 'direct-debit'" : "") .
-				" ORDER BY b.rowid ASC;",
-			),
-			array('sql' => "CREATE OR REPLACE VIEW " . MAIN_DB_PREFIX . "banking4dolibarr_view_" . ((int) $conf->entity) . "_bank_transferpayment AS" .
-				" SELECT DISTINCT b.rowid" .
-				" FROM " . MAIN_DB_PREFIX . "bank AS b" .
-				" LEFT JOIN " . MAIN_DB_PREFIX . "bank_account AS ba ON ba.rowid = b.fk_account" .
-				" LEFT JOIN " . MAIN_DB_PREFIX . "paiementfourn AS pf ON pf.fk_bank = b.rowid" .
-				" LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu ON bu.fk_bank = b.rowid" .
-				" WHERE ba.entity IN (" . getEntity('bank_account') . ")" .
-				($isV19p ? " AND (bu.type = 'credit-transfer' OR (b.label = '(SalaryPayment)' AND pf.num_paiement IS NOT NULL AND pf.num_paiement != ''))" :
-					" AND b.label = '(BankTransferPayment)' AND pf.num_paiement IS NOT NULL AND pf.num_paiement != ''") .
+				" AND (bu.type = 'withdraw'" . ($isV19p ? " OR bu.type = 'direct-debit'" : "") . ")" .
 				" ORDER BY b.rowid ASC;",
 			),
+//			array('sql' => "CREATE OR REPLACE VIEW " . MAIN_DB_PREFIX . "banking4dolibarr_view_" . ((int) $conf->entity) . "_bank_transferpayment AS" .
+//				" SELECT DISTINCT b.rowid" .
+//				" FROM " . MAIN_DB_PREFIX . "bank AS b" .
+//				" LEFT JOIN " . MAIN_DB_PREFIX . "bank_account AS ba ON ba.rowid = b.fk_account" .
+//				" LEFT JOIN " . MAIN_DB_PREFIX . "paiementfourn AS pf ON pf.fk_bank = b.rowid" .
+//				" LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu ON bu.fk_bank = b.rowid" .
+//				" WHERE ba.entity IN (" . getEntity('bank_account') . ")" .
+//				($isV19p ? " AND (bu.type = 'credit-transfer' OR (b.label = '(SalaryPayment)' AND pf.num_paiement IS NOT NULL AND pf.num_paiement != ''))" :
+//					" AND b.label = '(BankTransferPayment)' AND pf.num_paiement IS NOT NULL AND pf.num_paiement != ''") .
+//				" ORDER BY b.rowid ASC;",
+//			),
 			array('sql' => "CREATE OR REPLACE VIEW " . MAIN_DB_PREFIX . "banking4dolibarr_view_" . ((int) $conf->entity) . "_bank_same_ad AS" .
 				" SELECT b.fk_account, b.rowid AS fk_bank, b4dbr.rowid AS fk_bank_record, b4dbr.id_category" .
 				", COALESCE(b4dbr.vdate, b4dbr.record_date) AS record_date" .
@@ -4459,7 +4459,7 @@ class BudgetInsight
 				" AND b4dbr.status = " . BudgetInsightBankRecord::BANK_RECORD_STATUS_NOT_RECONCILED .
 				" AND NOT EXISTS (SELECT bcr.rowid FROM " . MAIN_DB_PREFIX . "banking4dolibarr_view_" . ((int) $conf->entity) . "_bank_chequereceipt AS bcr WHERE bcr.rowid = b.rowid)" .
 				" AND NOT EXISTS (SELECT bw.rowid FROM " . MAIN_DB_PREFIX . "banking4dolibarr_view_" . ((int) $conf->entity) . "_bank_withdraw AS bw WHERE bw.rowid = b.rowid)" .
-				" AND NOT EXISTS (SELECT btp.rowid FROM " . MAIN_DB_PREFIX . "banking4dolibarr_view_" . ((int) $conf->entity) . "_bank_transferpayment AS btp WHERE btp.rowid = b.rowid)" .
+//				" AND NOT EXISTS (SELECT btp.rowid FROM " . MAIN_DB_PREFIX . "banking4dolibarr_view_" . ((int) $conf->entity) . "_bank_transferpayment AS btp WHERE btp.rowid = b.rowid)" .
 				" AND (" .
 				"   (" .
 				($this->db->type == 'pgsql' ?
@@ -4658,28 +4658,28 @@ class BudgetInsight
 					" AND pb.type = 'debit-order'" .
 					" AND (pb.amount - COALESCE(bwr.amount, 0)) != 0";
 			}
-			if (!empty($conf->paymentbybanktransfer->enabled)) {
-				$payment_by_bank_transfer_id = dol_getIdFromCode($this->db, 'VIR', 'c_paiement', 'code', 'id', 1);
-				if (!($payment_by_bank_transfer_id > 0)) {
-					setEventMessage('Error get bank transfer payment type id :' . $this->db->lasterror(), 'errors');
-					return 0;
-				}
-				$banking4dolibarr_unpaid_list[] =
-					"SELECT 'payment_by_bank_transfer' AS element_type, pb.rowid AS element_id, pb.ref AS ref, NULL AS ref_ext" .
-					", '' AS label, pb.date_trans AS dateb, NULL AS datee" .
-					", - pb.amount AS amount" .
-					", - (pb.amount - COALESCE(bwr.amount, 0)) AS amount2" .
-					", " . (!empty($conf->multicurrency->enabled) ? "0" : "NULL") . " AS multicurrency_amount" .
-					", " . (!empty($conf->multicurrency->enabled) ? "'" . $this->db->escape($conf->currency) . "'" : "NULL") . " AS currency_code" .
-					", 0 AS fk_soc, NULL AS company_name, NULL AS company_alt_name, NULL AS company_spe_name, 0 AS fk_account, $payment_by_bank_transfer_id AS fk_payment_mode" .
-					" FROM " . MAIN_DB_PREFIX . "prelevement_bons as pb" .
-					" LEFT JOIN " . MAIN_DB_PREFIX . "banking4dolibarr_view_" . ((int) $conf->entity) . "_widthdraw_rejected AS bwr ON bwr.fk_prelevement_bons = pb.rowid" .
-					" LEFT JOIN " . MAIN_DB_PREFIX . "banking4dolibarr_view_" . ((int) $conf->entity) . "_all_widthdraw as al ON al.fk_prelevement_bons = pb.rowid" .
-					" WHERE pb.statut = 1" .
-					" AND al.fk_prelevement_bons IS NOT NULL" .
-					" AND pb.type = 'bank-transfer'" .
-					" AND (pb.amount - COALESCE(bwr.amount, 0)) != 0";
-			}
+//			if (!empty($conf->paymentbybanktransfer->enabled)) {
+//				$payment_by_bank_transfer_id = dol_getIdFromCode($this->db, 'VIR', 'c_paiement', 'code', 'id', 1);
+//				if (!($payment_by_bank_transfer_id > 0)) {
+//					setEventMessage('Error get bank transfer payment type id :' . $this->db->lasterror(), 'errors');
+//					return 0;
+//				}
+//				$banking4dolibarr_unpaid_list[] =
+//					"SELECT 'payment_by_bank_transfer' AS element_type, pb.rowid AS element_id, pb.ref AS ref, NULL AS ref_ext" .
+//					", '' AS label, pb.date_trans AS dateb, NULL AS datee" .
+//					", - pb.amount AS amount" .
+//					", - (pb.amount - COALESCE(bwr.amount, 0)) AS amount2" .
+//					", " . (!empty($conf->multicurrency->enabled) ? "0" : "NULL") . " AS multicurrency_amount" .
+//					", " . (!empty($conf->multicurrency->enabled) ? "'" . $this->db->escape($conf->currency) . "'" : "NULL") . " AS currency_code" .
+//					", 0 AS fk_soc, NULL AS company_name, NULL AS company_alt_name, NULL AS company_spe_name, 0 AS fk_account, $payment_by_bank_transfer_id AS fk_payment_mode" .
+//					" FROM " . MAIN_DB_PREFIX . "prelevement_bons as pb" .
+//					" LEFT JOIN " . MAIN_DB_PREFIX . "banking4dolibarr_view_" . ((int) $conf->entity) . "_widthdraw_rejected AS bwr ON bwr.fk_prelevement_bons = pb.rowid" .
+//					" LEFT JOIN " . MAIN_DB_PREFIX . "banking4dolibarr_view_" . ((int) $conf->entity) . "_all_widthdraw as al ON al.fk_prelevement_bons = pb.rowid" .
+//					" WHERE pb.statut = 1" .
+//					" AND al.fk_prelevement_bons IS NOT NULL" .
+//					" AND pb.type = 'bank-transfer'" .
+//					" AND (pb.amount - COALESCE(bwr.amount, 0)) != 0";
+//			}
 		}
 		// Invoices enabled
 		if (!empty($conf->facture->enabled)) {
diff --git a/tpl/b4d_manual_reconciliation_chequereceipt.tpl.php b/tpl/b4d_manual_reconciliation_chequereceipt.tpl.php
index 54ddd6a..557fa3d 100755
--- a/tpl/b4d_manual_reconciliation_chequereceipt.tpl.php
+++ b/tpl/b4d_manual_reconciliation_chequereceipt.tpl.php
@@ -114,11 +114,14 @@ $checkdepositstatic=new RemiseCheque($db);
 $now = dol_now();
 
 
-$sql = "SELECT bc.rowid, bc.ref, bc.amount, bc.date_bordereau, bc.nbcheque, bc.statut,";
+$sql = "SELECT DISTINCT bc.rowid, bc.ref, bc.amount, bc.date_bordereau, bc.nbcheque, bc.statut,";
 $sql .= " bc.fk_bank_account, ba.ref as bank_ref, ba.label as bank_label";
 $sql .= " FROM " . MAIN_DB_PREFIX . "bordereau_cheque as bc";
 $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON ba.rowid = bc.fk_bank_account';
+$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON b.fk_bordereau = bc.rowid';
+$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'banking4dolibarr_bank_record_link as brl ON brl.fk_bank = b.rowid';
 $sql .= " WHERE bc.entity = " . $conf->entity;
+$sql .= " AND brl.rowid IS NULL";
 // Search period criteria
 if (dol_strlen($search_date_start) > 0) $sql .= " AND bc.date_bordereau >= '" . $db->idate($search_date_start) . "'";
 if (dol_strlen($search_date_end) > 0) $sql .= " AND bc.date_bordereau <= '" . $db->idate($search_date_end) . "'";
diff --git a/tpl/b4d_manual_reconciliation_widthdraw.tpl.php b/tpl/b4d_manual_reconciliation_widthdraw.tpl.php
index 1cc4923..28b34bd 100755
--- a/tpl/b4d_manual_reconciliation_widthdraw.tpl.php
+++ b/tpl/b4d_manual_reconciliation_widthdraw.tpl.php
@@ -110,6 +110,7 @@ $unpaid_element_shared = !empty($conf->multicompany->enabled) && !empty($conf->g
 $minus_rejectamount = empty($account->array_options['options_b4d_include_reject_amount']) ? "" : " - COALESCE(bwr.amount, 0)";
 
 $isV17p = version_compare(DOL_VERSION, "17.0.0") >= 0;
+$isV19p = version_compare(DOL_VERSION, "19.0.0") >= 0;
 $prelevement_table = $isV17p ? 'prelevement' : 'prelevement_facture';
 
 $sql = "SELECT DISTINCT pb.rowid, pb.ref, {$sign}(pb.amount{$minus_rejectamount}) AS amount, pb.date_trans, pb.statut";
@@ -117,15 +118,25 @@ $sql .= " FROM " . MAIN_DB_PREFIX . "prelevement_bons as pb";
 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "banking4dolibarr_view_" . ((int) $conf->entity) . "_all_widthdraw_rejected AS bwr ON bwr.fk_prelevement_bons = pb.rowid";
 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "prelevement_lignes as pl ON pl.fk_prelevement_bons = pb.rowid";
 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $prelevement_table . " as pf ON pf.fk_prelevement_lignes = pl.rowid";
-if ($manual_reconciliation_type == 'payment_by_bank_transfer') {
-	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = pf.fk_facture_fourn";
-	$sql .= " WHERE ff.entity " . ($unpaid_element_shared ? "IN (" . getEntity('facture_fourn') . ")" : "= " . ((int) $conf->entity));
-	$sql .= " AND pb.type = 'bank-transfer'";
-} else { // $manual_reconciliation_type == 'widthdraw'
+//if ($manual_reconciliation_type == 'payment_by_bank_transfer') {
+//	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu ON bu.url_id = pb.rowid";
+//	$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'banking4dolibarr_bank_record_link as brl ON brl.fk_bank = bu.fk_bank';
+//	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank as b ON b.rowid = bu.fk_bank";
+//	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "paiementfourn AS paf ON paf.fk_bank = b.rowid";
+//	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = pf.fk_facture_fourn";
+//	$sql .= " WHERE ff.entity " . ($unpaid_element_shared ? "IN (" . getEntity('facture_fourn') . ")" : "= " . ((int) $conf->entity));
+//	$sql .= " AND pb.type = 'bank-transfer'";
+//	$sql .= ($isV19p ? " AND (bu.type = 'credit-transfer' OR (b.label = '(SalaryPayment)' AND paf.num_paiement IS NOT NULL AND paf.num_paiement != ''))" :
+//			" AND b.label = '(BankTransferPayment)' AND paf.num_paiement IS NOT NULL AND paf.num_paiement != ''");
+//} else { // $manual_reconciliation_type == 'widthdraw'
+	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu ON bu.url_id = pb.rowid";
+	$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'banking4dolibarr_bank_record_link as brl ON brl.fk_bank = bu.fk_bank';
 	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = pf.fk_facture";
 	$sql .= " WHERE f.entity " . ($unpaid_element_shared ? "IN (" . getEntity('invoice') . ")" : "= " . ((int) $conf->entity));
 	$sql .= " AND pb.type = 'debit-order'";
-}
+	$sql .= " AND (bu.type = 'withdraw'" . ($isV19p ? " OR bu.type = 'direct-debit'" : "") . ")";
+//}
+$sql .= " AND brl.rowid IS NULL";
 // Search period criteria
 if (dol_strlen($search_date_start) > 0) $sql .= " AND pb.date_trans >= '" . $db->idate($search_date_start) . "'";
 if (dol_strlen($search_date_end) > 0) $sql .= " AND pb.date_trans <= '" . $db->idate($search_date_end) . "'";
-- 
GitLab