Browse Source

Merge pull request #20973 from lmag/fix_number_cheque_receipt_list_bank_entries

fix : number cheque receipt list_bank entries #5366
Laurent Destailleur 3 years ago
parent
commit
038ce0c543
1 changed files with 60 additions and 22 deletions
  1. 60 22
      htdocs/compta/bank/bankentries_list.php

+ 60 - 22
htdocs/compta/bank/bankentries_list.php

@@ -32,14 +32,15 @@
  */
  */
 
 
 require '../../main.inc.php';
 require '../../main.inc.php';
+
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
+
 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
-
 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
 require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
 require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
 require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php';
 require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php';
@@ -54,6 +55,7 @@ require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
 require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php';
 require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php';
 require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
 require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
 require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
 require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
 
 
 // Load translation files required by the page
 // Load translation files required by the page
 $langs->loadLangs(array("banks", "bills", "categories", "companies", "margins", "salaries", "loan", "donations", "trips", "members", "compta", "accountancy"));
 $langs->loadLangs(array("banks", "bills", "categories", "companies", "margins", "salaries", "loan", "donations", "trips", "members", "compta", "accountancy"));
@@ -99,6 +101,7 @@ $search_thirdparty_user = GETPOST("search_thirdparty", 'alpha') ?GETPOST("search
 $search_req_nb = GETPOST("req_nb", 'alpha');
 $search_req_nb = GETPOST("req_nb", 'alpha');
 $search_num_releve = GETPOST("search_num_releve", 'alpha');
 $search_num_releve = GETPOST("search_num_releve", 'alpha');
 $search_conciliated = GETPOST("search_conciliated", 'int');
 $search_conciliated = GETPOST("search_conciliated", 'int');
+$search_fk_bordereau = GETPOST("search_fk_bordereau", 'int');
 $optioncss = GETPOST('optioncss', 'alpha');
 $optioncss = GETPOST('optioncss', 'alpha');
 $toselect = GETPOST('toselect', 'array');
 $toselect = GETPOST('toselect', 'array');
 $num_releve = GETPOST("num_releve", "alpha");
 $num_releve = GETPOST("num_releve", "alpha");
@@ -157,20 +160,21 @@ $extrafields->fetch_name_optionals_label('banktransaction');
 $search_array_options = $extrafields->getOptionalsFromPost('banktransaction', '', 'search_');
 $search_array_options = $extrafields->getOptionalsFromPost('banktransaction', '', 'search_');
 
 
 $arrayfields = array(
 $arrayfields = array(
-	'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
-	'b.label'=>array('label'=>$langs->trans("Description"), 'checked'=>1),
-	'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1),
-	'b.datev'=>array('label'=>$langs->trans("DateValueShort"), 'checked'=>1),
-	'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
-	'b.num_chq'=>array('label'=>$langs->trans("Numero"), 'checked'=>1),
-	'bu.label'=>array('label'=>$langs->trans("ThirdParty").'/'.$langs->trans("User"), 'checked'=>1, 'position'=>500),
-	'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>(($id > 0 || !empty($ref)) ? 0 : 1), 'position'=>1000),
-	'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600),
-	'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605),
-	'balancebefore'=>array('label'=>$langs->trans("BalanceBefore"), 'checked'=>0, 'position'=>1000),
-	'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1001),
-	'b.num_releve'=>array('label'=>$langs->trans("AccountStatement"), 'checked'=>1, 'position'=>1010),
-	'b.conciliated'=>array('label'=>$langs->trans("BankLineReconciled"), 'enabled'=> $object->rappro, 'checked'=>($action == 'reconcile' ? 1 : 0), 'position'=>1020),
+	'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1,'position'=>10),
+	'b.label'=>array('label'=>$langs->trans("Description"), 'checked'=>1,'position'=>20),
+	'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1,'position'=>30),
+	'b.datev'=>array('label'=>$langs->trans("DateValueShort"), 'checked'=>1,'position'=>40),
+	'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1,'position'=>50),
+	'b.num_chq'=>array('label'=>$langs->trans("Numero"), 'checked'=>1,'position'=>60),
+	'bu.label'=>array('label'=>$langs->trans("ThirdParty").'/'.$langs->trans("User"), 'checked'=>1, 'position'=>70),
+	'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>(($id > 0 || !empty($ref)) ? 0 : 1), 'position'=>80),
+	'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>90),
+	'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>100),
+	'balancebefore'=>array('label'=>$langs->trans("BalanceBefore"), 'checked'=>0, 'position'=>110),
+	'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>120),
+	'b.num_releve'=>array('label'=>$langs->trans("AccountStatement"), 'checked'=>1, 'position'=>130),
+	'b.conciliated'=>array('label'=>$langs->trans("BankLineReconciled"), 'enabled'=> $object->rappro, 'checked'=>($action == 'reconcile' ? 1 : 0), 'position'=>140),
+	'b.fk_bordereau'=>array('label'=>$langs->trans("ChequeReceipt"), 'checked'=>0, 'position'=>150),
 );
 );
 // Extra fields
 // Extra fields
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
@@ -178,7 +182,6 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
 $object->fields = dol_sort_array($object->fields, 'position');
 $object->fields = dol_sort_array($object->fields, 'position');
 $arrayfields = dol_sort_array($arrayfields, 'position');
 $arrayfields = dol_sort_array($arrayfields, 'position');
 
 
-
 /*
 /*
  * Actions
  * Actions
  */
  */
@@ -214,6 +217,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
 	$search_thirdparty_user = '';
 	$search_thirdparty_user = '';
 	$search_num_releve = '';
 	$search_num_releve = '';
 	$search_conciliated = '';
 	$search_conciliated = '';
+	$search_fk_bordereau = '';
 	$toselect = array();
 	$toselect = array();
 
 
 	$search_account = "";
 	$search_account = "";
@@ -390,8 +394,6 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && !empty($user->rights->ba
 	}
 	}
 }
 }
 
 
-
-
 /*
 /*
  * View
  * View
  */
  */
@@ -421,6 +423,7 @@ $paymentvariousstatic = new PaymentVarious($db);
 $paymentexpensereportstatic = new PaymentExpenseReport($db);
 $paymentexpensereportstatic = new PaymentExpenseReport($db);
 $bankstatic = new Account($db);
 $bankstatic = new Account($db);
 $banklinestatic = new AccountLine($db);
 $banklinestatic = new AccountLine($db);
+$bordereaustatic = new RemiseCheque($db);
 
 
 $now = dol_now();
 $now = dol_now();
 
 
@@ -465,6 +468,9 @@ if (!empty($search_num_releve)) {
 if ($search_conciliated != '' && $search_conciliated != '-1') {
 if ($search_conciliated != '' && $search_conciliated != '-1') {
 	$param .= '&search_conciliated='.urlencode($search_conciliated);
 	$param .= '&search_conciliated='.urlencode($search_conciliated);
 }
 }
+if ($search_fk_bordereau > 0) {
+	$param .= '$&search_fk_bordereau='.urlencode($search_fk_bordereau);
+}
 if ($search_bid > 0) {
 if ($search_bid > 0) {
 	$param .= '&search_bid='.urlencode($search_bid);
 	$param .= '&search_bid='.urlencode($search_bid);
 }
 }
@@ -568,8 +574,9 @@ if ($id > 0 || !empty($ref)) {
 	llxHeader('', $langs->trans("BankTransactions"), '', '', 0, 0, array(), array(), $param);
 	llxHeader('', $langs->trans("BankTransactions"), '', '', 0, 0, array(), array(), $param);
 }
 }
 
 
+
 $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro as conciliated, b.num_releve, b.num_chq,";
 $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro as conciliated, b.num_releve, b.num_chq,";
-$sql .= " b.fk_account, b.fk_type,";
+$sql .= " b.fk_account, b.fk_type, b.fk_bordereau,";
 $sql .= " ba.rowid as bankid, ba.ref as bankref";
 $sql .= " ba.rowid as bankid, ba.ref as bankref";
 // Add fields from extrafields
 // Add fields from extrafields
 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
@@ -621,6 +628,9 @@ if ($search_num_releve) {
 if ($search_conciliated != '' && $search_conciliated != '-1') {
 if ($search_conciliated != '' && $search_conciliated != '-1') {
 	$sql .= " AND b.rappro = ".((int) $search_conciliated);
 	$sql .= " AND b.rappro = ".((int) $search_conciliated);
 }
 }
+if ($search_fk_bordereau > 0) {
+	$sql .= " AND b.fk_bordereau = " . ((int) $search_fk_bordereau);
+}
 if ($search_thirdparty_user) {
 if ($search_thirdparty_user) {
 	$sql.= " AND (b.rowid IN ";
 	$sql.= " AND (b.rowid IN ";
 	$sql.= " 	( SELECT bu.fk_bank FROM ".MAIN_DB_PREFIX."bank_url AS bu";
 	$sql.= " 	( SELECT bu.fk_bank FROM ".MAIN_DB_PREFIX."bank_url AS bu";
@@ -737,6 +747,9 @@ if ($search_conciliated != '' && $search_conciliated != '-1') {
 if (!empty($search_num_releve)) {
 if (!empty($search_num_releve)) {
 	$mode_balance_ok = false;
 	$mode_balance_ok = false;
 }
 }
+if (!empty($search_fk_bordereau)) {
+	$mode_balance_ok = false;
+}
 
 
 $sql .= $db->plimit($limit + 1, $offset);
 $sql .= $db->plimit($limit + 1, $offset);
 //print $sql;
 //print $sql;
@@ -1067,34 +1080,40 @@ if ($resql) {
 		$form->select_types_paiements(empty($search_type) ? '' : $search_type, 'search_type', '', 2, 1, 1, 0, 1, 'maxwidth100');
 		$form->select_types_paiements(empty($search_type) ? '' : $search_type, 'search_type', '', 2, 1, 1, 0, 1, 'maxwidth100');
 		print '</td>';
 		print '</td>';
 	}
 	}
+	// Numero
 	if (!empty($arrayfields['b.num_chq']['checked'])) {
 	if (!empty($arrayfields['b.num_chq']['checked'])) {
-		// Numero
 		print '<td class="liste_titre" align="center"><input type="text" class="flat" name="req_nb" value="'.dol_escape_htmltag($search_req_nb).'" size="2"></td>';
 		print '<td class="liste_titre" align="center"><input type="text" class="flat" name="req_nb" value="'.dol_escape_htmltag($search_req_nb).'" size="2"></td>';
 	}
 	}
+	// Checked
 	if (!empty($arrayfields['bu.label']['checked'])) {
 	if (!empty($arrayfields['bu.label']['checked'])) {
 		print '<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty_user).'"></td>';
 		print '<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty_user).'"></td>';
 	}
 	}
+	// Ref
 	if (!empty($arrayfields['ba.ref']['checked'])) {
 	if (!empty($arrayfields['ba.ref']['checked'])) {
 		print '<td class="liste_titre">';
 		print '<td class="liste_titre">';
 		$form->select_comptes($search_account, 'search_account', 0, '', 1, ($id > 0 || !empty($ref) ? ' disabled="disabled"' : ''), 0, 'maxwidth100');
 		$form->select_comptes($search_account, 'search_account', 0, '', 1, ($id > 0 || !empty($ref) ? ' disabled="disabled"' : ''), 0, 'maxwidth100');
 		print '</td>';
 		print '</td>';
 	}
 	}
+	// Debit
 	if (!empty($arrayfields['b.debit']['checked'])) {
 	if (!empty($arrayfields['b.debit']['checked'])) {
 		print '<td class="liste_titre right">';
 		print '<td class="liste_titre right">';
 		print '<input type="text" class="flat width50" name="search_debit" value="'.dol_escape_htmltag($search_debit).'">';
 		print '<input type="text" class="flat width50" name="search_debit" value="'.dol_escape_htmltag($search_debit).'">';
 		print '</td>';
 		print '</td>';
 	}
 	}
+	// Credit
 	if (!empty($arrayfields['b.credit']['checked'])) {
 	if (!empty($arrayfields['b.credit']['checked'])) {
 		print '<td class="liste_titre right">';
 		print '<td class="liste_titre right">';
 		print '<input type="text" class="flat width50" name="search_credit" value="'.dol_escape_htmltag($search_credit).'">';
 		print '<input type="text" class="flat width50" name="search_credit" value="'.dol_escape_htmltag($search_credit).'">';
 		print '</td>';
 		print '</td>';
 	}
 	}
+	// Balance before
 	if (!empty($arrayfields['balancebefore']['checked'])) {
 	if (!empty($arrayfields['balancebefore']['checked'])) {
 		print '<td class="liste_titre right">';
 		print '<td class="liste_titre right">';
 		$htmltext = $langs->trans("BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv("DateValue"));
 		$htmltext = $langs->trans("BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv("DateValue"));
 		print $form->textwithpicto('', $htmltext, 1);
 		print $form->textwithpicto('', $htmltext, 1);
 		print '</td>';
 		print '</td>';
 	}
 	}
+	// Balance
 	if (!empty($arrayfields['balance']['checked'])) {
 	if (!empty($arrayfields['balance']['checked'])) {
 		print '<td class="liste_titre right">';
 		print '<td class="liste_titre right">';
 		$htmltext = $langs->trans("BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv("DateValue"));
 		$htmltext = $langs->trans("BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv("DateValue"));
@@ -1111,6 +1130,11 @@ if ($resql) {
 		print $form->selectyesno('search_conciliated', $search_conciliated, 1, false, 1, 1);
 		print $form->selectyesno('search_conciliated', $search_conciliated, 1, false, 1, 1);
 		print '</td>';
 		print '</td>';
 	}
 	}
+	// Bordereau
+	if (!empty($arrayfields['b.fk_bordereau']['checked'])) {
+		print '<td class="liste_titre" align="center"><input type="text" class="flat" name="search_fk_bordereau" value="'.dol_escape_htmltag($search_fk_bordereau).'" size="3"></td>';
+	}
+
 	// Actions and select
 	// Actions and select
 	print '<td class="liste_titre" align="middle">';
 	print '<td class="liste_titre" align="middle">';
 	$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
 	$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
@@ -1162,6 +1186,10 @@ if ($resql) {
 	if (!empty($arrayfields['b.conciliated']['checked'])) {
 	if (!empty($arrayfields['b.conciliated']['checked'])) {
 		print_liste_field_titre($arrayfields['b.conciliated']['label'], $_SERVER['PHP_SELF'], 'b.rappro', '', $param, '', $sortfield, $sortorder, "center ");
 		print_liste_field_titre($arrayfields['b.conciliated']['label'], $_SERVER['PHP_SELF'], 'b.rappro', '', $param, '', $sortfield, $sortorder, "center ");
 	}
 	}
+	if (!empty($arrayfields['b.fk_bordereau']['checked'])) {
+		print_liste_field_titre($arrayfields['b.fk_bordereau']['label'], $_SERVER['PHP_SELF'], 'b.fk_bordereau', '', $param, '', $sortfield, $sortorder, "center ");
+	}
+
 	// Extra fields
 	// Extra fields
 	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
 	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
 	// Hook fields
 	// Hook fields
@@ -1673,6 +1701,16 @@ if ($resql) {
 			}
 			}
 		}
 		}
 
 
+		if (!empty($arrayfields['b.fk_bordereau']['checked'])) {
+			$bordereaustatic->fetch($objp->fk_bordereau);
+			print '<td class="nowraponall" align="center">';
+			print $bordereaustatic->getNomUrl();
+			print '</td>';
+			if (!$i) {
+				$totalarray['nbfield']++;
+			}
+		}
+
 		// Action edit/delete and select
 		// Action edit/delete and select
 		print '<td class="nowraponall" align="center">';
 		print '<td class="nowraponall" align="center">';
 		// Transaction reconciliated or edit link
 		// Transaction reconciliated or edit link