2017-03-19 08:17:32 +01:00
< ? php
2022-06-20 04:57:38 +02:00
/* Copyright ( C ) 2017 - 2022 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2018-09-09 11:25:59 +02:00
* Copyright ( C ) 2017 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2018 Frédéric France < frederic . france @ netlogic . fr >
2020-09-09 11:34:47 +02:00
* Copyright ( C ) 2020 Tobias Sekan < tobias . sekan @ startmail . com >
2017-03-19 08:17:32 +01:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2017-03-19 08:17:32 +01:00
*/
/**
2018-10-04 19:10:39 +02:00
* \file htdocs / compta / bank / various_payment / list . php
2017-12-10 14:05:36 +01:00
* \ingroup bank
* \brief List of various payments
2017-03-19 08:17:32 +01:00
*/
require '../../../main.inc.php' ;
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/paymentvarious.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
2018-01-10 10:42:36 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php' ;
2020-09-09 11:34:47 +02:00
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
2017-03-19 08:17:32 +01:00
2018-05-27 09:40:17 +02:00
// Load translation files required by the page
2020-01-18 16:17:07 +01:00
$langs -> loadLangs ( array ( " compta " , " banks " , " bills " , " accountancy " ));
2017-03-19 08:17:32 +01:00
2022-06-20 04:57:38 +02:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'directdebitcredittransferlist' ; // To manage different context of search
2017-03-19 08:17:32 +01:00
// Security check
2019-01-27 11:55:16 +01:00
$socid = GETPOST ( " socid " , " int " );
2021-02-23 21:09:01 +01:00
if ( $user -> socid ) {
$socid = $user -> socid ;
}
2017-03-19 08:17:32 +01:00
2019-01-27 11:55:16 +01:00
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
2017-07-15 03:41:07 +02:00
2020-01-18 16:17:07 +01:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2019-01-27 11:55:16 +01:00
$search_ref = GETPOST ( 'search_ref' , 'int' );
$search_user = GETPOST ( 'search_user' , 'alpha' );
$search_label = GETPOST ( 'search_label' , 'alpha' );
2020-09-09 11:34:47 +02:00
$search_datep_start = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'search_date_startmonth' , 'int' ), GETPOST ( 'search_date_startday' , 'int' ), GETPOST ( 'search_date_startyear' , 'int' ));
$search_datep_end = dol_mktime ( 23 , 59 , 59 , GETPOST ( 'search_date_endmonth' , 'int' ), GETPOST ( 'search_date_endday' , 'int' ), GETPOST ( 'search_date_endyear' , 'int' ));
$search_datev_start = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'search_date_value_startmonth' , 'int' ), GETPOST ( 'search_date_value_startday' , 'int' ), GETPOST ( 'search_date_value_startyear' , 'int' ));
$search_datev_end = dol_mktime ( 23 , 59 , 59 , GETPOST ( 'search_date_value_endmonth' , 'int' ), GETPOST ( 'search_date_value_endday' , 'int' ), GETPOST ( 'search_date_value_endyear' , 'int' ));
2019-01-27 11:55:16 +01:00
$search_amount_deb = GETPOST ( 'search_amount_deb' , 'alpha' );
$search_amount_cred = GETPOST ( 'search_amount_cred' , 'alpha' );
2020-09-09 11:34:47 +02:00
$search_bank_account = GETPOST ( 'search_account' , 'int' );
$search_bank_entry = GETPOST ( 'search_bank_entry' , 'int' );
2019-11-07 09:19:48 +01:00
$search_accountancy_account = GETPOST ( " search_accountancy_account " );
2021-02-23 21:09:01 +01:00
if ( $search_accountancy_account == - 1 ) {
$search_accountancy_account = '' ;
}
2019-11-07 09:19:48 +01:00
$search_accountancy_subledger = GETPOST ( " search_accountancy_subledger " );
2021-02-23 21:09:01 +01:00
if ( $search_accountancy_subledger == - 1 ) {
$search_accountancy_subledger = '' ;
}
if ( empty ( $search_datep_start )) {
$search_datep_start = GETPOST ( " search_datep_start " , 'int' );
}
if ( empty ( $search_datep_end )) {
$search_datep_end = GETPOST ( " search_datep_end " , 'int' );
}
if ( empty ( $search_datev_start )) {
$search_datev_start = GETPOST ( " search_datev_start " , 'int' );
}
if ( empty ( $search_datev_end )) {
$search_datev_end = GETPOST ( " search_datev_end " , 'int' );
}
2022-06-20 04:57:38 +02:00
$search_type_id = GETPOST ( 'search_type_id' , 'int' );
2017-03-19 08:17:32 +01:00
2022-01-13 11:09:37 +01:00
$sortfield = GETPOST ( 'sortfield' , 'aZ09comma' );
$sortorder = GETPOST ( 'sortorder' , 'aZ09comma' );
2020-03-13 13:07:11 +01:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
2021-02-23 21:09:01 +01:00
if ( empty ( $page ) || $page == - 1 ) {
$page = 0 ;
} // If $page is not defined, or '' or -1
2020-04-20 14:53:17 +02:00
$offset = $limit * $page ;
2017-03-19 08:17:32 +01:00
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2021-02-23 21:09:01 +01:00
if ( ! $sortfield ) {
$sortfield = " v.datep,v.rowid " ;
}
if ( ! $sortorder ) {
$sortorder = " DESC,DESC " ;
}
2017-03-19 08:17:32 +01:00
2020-01-18 16:17:07 +01:00
$filtre = GETPOST ( " filtre " , 'alpha' );
2017-03-19 08:17:32 +01:00
2021-02-23 21:09:01 +01:00
if ( GETPOST ( 'button_removefilter_x' , 'alpha' ) || GETPOST ( 'button_removefilter.x' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) { // All test are required to be compatible with all browsers
2020-09-09 11:34:47 +02:00
$search_ref = '' ;
$search_label = '' ;
$search_datep_start = '' ;
$search_datep_end = '' ;
$search_datev_start = '' ;
$search_datev_end = '' ;
$search_amount_deb = '' ;
$search_amount_cred = '' ;
$search_bank_account = '' ;
$search_bank_entry = '' ;
2019-11-07 09:19:48 +01:00
$search_accountancy_account = '' ;
$search_accountancy_subledger = '' ;
2022-06-20 04:57:38 +02:00
$search_type_id = '' ;
2017-03-19 08:17:32 +01:00
}
2020-09-14 04:24:35 +02:00
$search_all = GETPOSTISSET ( " search_all " ) ? trim ( GETPOST ( " search_all " , 'alpha' )) : trim ( GETPOST ( 'sall' ));
2020-09-11 09:55:34 +02:00
/*
* TODO : fill array " $fields " in " /compta/bank/class/paymentvarious.class.php " and use
*
*
* $object = new PaymentVarious ( $db );
*
* $search = array ();
* foreach ( $object -> fields as $key => $val )
* {
* if ( GETPOST ( 'search_' . $key , 'alpha' )) $search [ $key ] = GETPOST ( 'search_' . $key , 'alpha' );
* }
* $fieldstosearchall = array ();
* foreach ( $object -> fields as $key => $val )
* {
* if ( $val [ 'searchall' ]) $fieldstosearchall [ 't.' . $key ] = $val [ 'label' ];
* }
*
*/
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array (
'v.rowid' => " Ref " ,
'v.label' => " Label " ,
'v.datep' => " DatePayment " ,
'v.datev' => " DateValue " ,
'v.amount' => $langs -> trans ( " Debit " ) . " , " . $langs -> trans ( " Credit " ),
);
2020-09-09 11:34:47 +02:00
// Definition of fields for lists
$arrayfields = array (
2020-09-14 04:30:04 +02:00
'ref' => array ( 'label' => " Ref " , 'checked' => 1 , 'position' => 100 ),
'label' => array ( 'label' => " Label " , 'checked' => 1 , 'position' => 110 ),
'datep' => array ( 'label' => " DatePayment " , 'checked' => 1 , 'position' => 120 ),
2021-11-29 01:13:43 +01:00
'datev' => array ( 'label' => " DateValue " , 'checked' =>- 1 , 'position' => 130 ),
2020-09-14 04:30:04 +02:00
'type' => array ( 'label' => " PaymentMode " , 'checked' => 1 , 'position' => 140 ),
2022-06-14 17:53:17 +02:00
'project' => array ( 'label' => " Project " , 'checked' => 1 , 'position' => 200 , " enabled " =>! empty ( $conf -> project -> enabled )),
2022-08-29 11:22:21 +02:00
'bank' => array ( 'label' => " BankAccount " , 'checked' => 1 , 'position' => 300 , " enabled " => isModEnabled ( 'banque' )),
'entry' => array ( 'label' => " BankTransactionLine " , 'checked' => 1 , 'position' => 310 , " enabled " => isModEnabled ( 'banque' )),
'account' => array ( 'label' => " AccountAccountingShort " , 'checked' => 1 , 'position' => 400 , " enabled " => isModEnabled ( 'accounting' )),
'subledger' => array ( 'label' => " SubledgerAccount " , 'checked' => 1 , 'position' => 410 , " enabled " => isModEnabled ( 'accounting' )),
2020-09-14 04:30:04 +02:00
'debit' => array ( 'label' => " Debit " , 'checked' => 1 , 'position' => 500 ),
'credit' => array ( 'label' => " Credit " , 'checked' => 1 , 'position' => 510 ),
2020-09-09 11:34:47 +02:00
);
$arrayfields = dol_sort_array ( $arrayfields , 'position' );
2022-05-10 11:38:56 +02:00
$object = new PaymentVarious ( $db );
$result = restrictedArea ( $user , 'banque' , '' , '' , '' );
2020-09-09 11:34:47 +02:00
/*
* Actions
*/
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-23 21:09:01 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2020-09-09 11:34:47 +02:00
if ( empty ( $reshook )) {
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
}
2020-04-20 19:39:34 +02:00
2017-03-19 08:17:32 +01:00
/*
* View
*/
$form = new Form ( $db );
2021-02-23 21:09:01 +01:00
if ( $arrayfields [ 'account' ][ 'checked' ] || $arrayfields [ 'subledger' ][ 'checked' ]) {
$formaccounting = new FormAccounting ( $db );
}
2022-08-29 11:22:21 +02:00
if ( $arrayfields [ 'bank' ][ 'checked' ] && isModEnabled ( 'accounting' )) {
2021-02-23 21:09:01 +01:00
$accountingjournal = new AccountingJournal ( $db );
}
if ( $arrayfields [ 'ref' ][ 'checked' ]) {
$variousstatic = new PaymentVarious ( $db );
}
if ( $arrayfields [ 'bank' ][ 'checked' ]) {
$accountstatic = new Account ( $db );
}
if ( $arrayfields [ 'project' ][ 'checked' ]) {
$proj = new Project ( $db );
}
if ( $arrayfields [ 'entry' ][ 'checked' ]) {
$bankline = new AccountLine ( $db );
}
if ( $arrayfields [ 'account' ][ 'checked' ]) {
$accountingaccount = new AccountingAccount ( $db );
}
2020-09-09 11:34:47 +02:00
$sql = " SELECT v.rowid, v.sens, v.amount, v.label, v.datep as datep, v.datev as datev, v.fk_typepayment as type, v.num_payment, v.fk_bank, v.accountancy_code, v.subledger_account, v.fk_projet as fk_project, " ;
2020-01-18 16:17:07 +01:00
$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number as bank_account_number, ba.fk_accountancy_journal as accountancy_journal, ba.label as blabel, " ;
$sql .= " pst.code as payment_code " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " payment_various as v " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_paiement as pst ON v.fk_typepayment = pst.id " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " bank as b ON v.fk_bank = b.rowid " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " bank_account as ba ON b.fk_account = ba.rowid " ;
$sql .= " WHERE v.entity IN ( " . getEntity ( 'payment_various' ) . " ) " ;
2017-03-19 08:17:32 +01:00
// Search criteria
2021-02-23 21:09:01 +01:00
if ( $search_ref ) {
2021-04-25 15:55:36 +02:00
$sql .= " AND v.rowid = " . (( int ) $search_ref );
2021-02-23 21:09:01 +01:00
}
if ( $search_label ) {
$sql .= natural_search ( array ( 'v.label' ), $search_label );
}
if ( $search_datep_start ) {
$sql .= " AND v.datep >= ' " . $db -> idate ( $search_datep_start ) . " ' " ;
}
if ( $search_datep_end ) {
$sql .= " AND v.datep <= ' " . $db -> idate ( $search_datep_end ) . " ' " ;
}
if ( $search_datev_start ) {
$sql .= " AND v.datev >= ' " . $db -> idate ( $search_datev_start ) . " ' " ;
}
if ( $search_datev_end ) {
$sql .= " AND v.datev <= ' " . $db -> idate ( $search_datev_end ) . " ' " ;
}
if ( $search_amount_deb ) {
$sql .= natural_search ( " v.amount " , $search_amount_deb , 1 );
}
if ( $search_amount_cred ) {
$sql .= natural_search ( " v.amount " , $search_amount_cred , 1 );
}
if ( $search_bank_account > 0 ) {
2021-06-09 15:36:47 +02:00
$sql .= " AND b.fk_account = " . (( int ) $search_bank_account );
2021-02-23 21:09:01 +01:00
}
if ( $search_bank_entry > 0 ) {
2021-06-09 15:36:47 +02:00
$sql .= " AND b.fk_account = " . (( int ) $search_bank_account );
2021-02-23 21:09:01 +01:00
}
if ( $search_accountancy_account > 0 ) {
2021-06-09 15:36:47 +02:00
$sql .= " AND v.accountancy_code = " . (( int ) $search_accountancy_account );
2021-02-23 21:09:01 +01:00
}
if ( $search_accountancy_subledger > 0 ) {
2021-06-09 15:36:47 +02:00
$sql .= " AND v.subledger_account = " . (( int ) $search_accountancy_subledger );
2021-02-23 21:09:01 +01:00
}
2022-06-20 04:57:38 +02:00
if ( $search_type_id > 0 ) {
$sql .= " AND v.fk_typepayment= " . (( int ) $search_type_id );
2021-02-23 21:09:01 +01:00
}
if ( $search_all ) {
$sql .= natural_search ( array_keys ( $fieldstosearchall ), $search_all );
}
2018-01-29 19:07:42 +01:00
2020-01-18 16:17:07 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
2017-03-19 08:17:32 +01:00
2020-01-18 16:17:07 +01:00
$totalnboflines = 0 ;
2022-05-10 11:38:56 +02:00
$resql = $db -> query ( $sql );
if ( $resql ) {
$totalnboflines = $db -> num_rows ( $resql );
2017-03-19 08:17:32 +01:00
}
2020-01-18 16:17:07 +01:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
2017-03-19 08:17:32 +01:00
2022-05-10 11:38:56 +02:00
$resql = $db -> query ( $sql );
if ( $resql ) {
$num = $db -> num_rows ( $resql );
2020-09-11 09:55:34 +02:00
// Direct jump if only one record found
2021-02-23 21:09:01 +01:00
if ( $num == 1 && ! empty ( $conf -> global -> MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE ) && $search_all ) {
2022-05-10 11:38:56 +02:00
$obj = $db -> fetch_object ( $resql );
2020-09-11 09:55:34 +02:00
$id = $obj -> rowid ;
header ( " Location: " . DOL_URL_ROOT . '/compta/bank/various_payment/card.php?id=' . $id );
exit ;
}
// must be place behind the last "header(...)" call
llxHeader ();
2017-07-07 06:09:49 +02:00
$i = 0 ;
2020-01-18 16:17:07 +01:00
$total = 0 ;
$param = '' ;
2021-02-23 21:09:01 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) {
$param .= '&contextpage=' . urlencode ( $contextpage );
}
if ( $limit > 0 && $limit != $conf -> liste_limit ) {
$param .= '&limit=' . urlencode ( $limit );
}
if ( $search_ref ) {
$param .= '&search_ref=' . urlencode ( $search_ref );
}
if ( $search_label ) {
$param .= '&search_label=' . urlencode ( $search_label );
}
if ( $search_datep_start ) {
$param .= '&search_datep_start=' . urlencode ( $search_datep_start );
}
if ( $search_datep_end ) {
$param .= '&search_datep_end=' . urlencode ( $search_datep_end );
}
if ( $search_datev_start ) {
$param .= '&search_datev_start=' . urlencode ( $search_datev_start );
}
if ( $search_datev_end ) {
$param .= '&search_datev_end=' . urlencode ( $search_datev_end );
}
2022-06-20 04:57:38 +02:00
if ( $search_type_id > 0 ) {
$param .= '&search_type_id=' . urlencode ( $search_type_id );
2021-02-23 21:09:01 +01:00
}
if ( $search_amount_deb ) {
$param .= '&search_amount_deb=' . urlencode ( $search_amount_deb );
}
if ( $search_amount_cred ) {
$param .= '&search_amount_cred=' . urlencode ( $search_amount_cred );
}
if ( $search_bank_account > 0 ) {
$param .= '&search_account=' . urlencode ( $search_bank_account );
}
if ( $search_accountancy_account > 0 ) {
$param .= '&search_accountancy_account=' . urlencode ( $search_accountancy_account );
}
if ( $search_accountancy_subledger > 0 ) {
$param .= '&search_accountancy_subledger=' . urlencode ( $search_accountancy_subledger );
}
if ( $optioncss != '' ) {
2021-05-12 22:21:20 +02:00
$param .= '&optioncss=' . urlencode ( $optioncss );
2021-02-23 21:09:01 +01:00
}
2017-03-19 08:17:32 +01:00
2020-09-18 10:46:23 +02:00
$url = DOL_URL_ROOT . '/compta/bank/various_payment/card.php?action=create' ;
2021-02-23 21:09:01 +01:00
if ( ! empty ( $socid )) {
2021-05-12 22:21:20 +02:00
$url .= '&socid=' . urlencode ( $socid );
2021-02-23 21:09:01 +01:00
}
2020-09-18 10:52:17 +02:00
$newcardbutton = dolGetButtonTitle ( $langs -> trans ( 'MenuNewVariousPayment' ), '' , 'fa fa-plus-circle' , $url , '' , $user -> rights -> banque -> modifier );
2018-03-30 16:54:38 +02:00
2017-11-17 14:57:14 +01:00
print '<form method="POST" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2020-09-09 11:46:46 +02:00
2021-02-23 21:09:01 +01:00
if ( $optioncss != '' ) {
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
}
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-03-19 08:17:32 +01:00
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
2017-07-07 06:09:49 +02:00
print '<input type="hidden" name="action" value="list">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
2020-09-09 11:34:47 +02:00
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">' ;
2020-09-09 11:46:46 +02:00
2020-07-06 11:52:28 +02:00
print_barre_liste ( $langs -> trans ( " MenuVariousPayment " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , '' , $num , $totalnboflines , 'object_payment' , 0 , $newcardbutton , '' , $limit , 0 , 0 , 1 );
2017-06-09 09:25:15 +02:00
2021-02-23 21:09:01 +01:00
if ( $search_all ) {
foreach ( $fieldstosearchall as $key => $val ) {
$fieldstosearchall [ $key ] = $langs -> trans ( $val );
}
2020-09-11 09:55:34 +02:00
print '<div class="divsearchfieldfilter">' . $langs -> trans ( " FilterOnInto " , $search_all ) . join ( ', ' , $fieldstosearchall ) . '</div>' ;
}
2020-09-09 11:34:47 +02:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
2022-06-20 04:57:38 +02:00
$moreforfilter = '' ;
2020-09-09 11:34:47 +02:00
2017-07-07 06:09:49 +02:00
print '<div class="div-table-responsive">' ;
2020-09-09 11:34:47 +02:00
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' ;
2017-03-19 08:17:32 +01:00
print '<tr class="liste_titre">' ;
2017-07-28 07:42:02 +02:00
2020-09-09 11:34:47 +02:00
if ( ! empty ( $conf -> global -> MAIN_VIEW_LINE_NUMBER_IN_LIST )) {
print '<td class="liste_titre">' ;
print '</td>' ;
}
2017-03-19 08:17:32 +01:00
// Ref
2020-09-09 11:34:47 +02:00
if ( $arrayfields [ 'ref' ][ 'checked' ]) {
print '<td class="liste_titre left">' ;
print '<input class="flat" type="text" size="3" name="search_ref" value="' . dol_escape_htmltag ( $search_ref ) . '">' ;
print '</td>' ;
}
2017-07-28 07:42:02 +02:00
2017-03-19 08:17:32 +01:00
// Label
2020-09-09 11:34:47 +02:00
if ( $arrayfields [ 'label' ][ 'checked' ]) {
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" size="10" name="search_label" value="' . dol_escape_htmltag ( $search_label ) . '">' ;
print '</td>' ;
}
2017-07-28 07:42:02 +02:00
2020-09-09 11:34:47 +02:00
// Payment date
if ( $arrayfields [ 'datep' ][ 'checked' ]) {
print '<td class="liste_titre center">' ;
print '<div class="nowrap">' ;
2020-09-22 15:26:29 +02:00
print $form -> selectDate ( $search_datep_start ? $search_datep_start : - 1 , 'search_date_start' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'From' ));
2020-09-09 11:34:47 +02:00
print '</div>' ;
print '<div class="nowrap">' ;
2020-09-22 15:26:29 +02:00
print $form -> selectDate ( $search_datep_end ? $search_datep_end : - 1 , 'search_date_end' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'to' ));
2020-09-09 11:34:47 +02:00
print '</div>' ;
print '</td>' ;
}
2019-11-07 09:19:48 +01:00
2020-09-09 11:34:47 +02:00
// Value date
if ( $arrayfields [ 'datev' ][ 'checked' ]) {
print '<td class="liste_titre center">' ;
print '<div class="nowrap">' ;
2020-09-22 15:26:29 +02:00
print $form -> selectDate ( $search_datev_start ? $search_datev_start : - 1 , 'search_date_value_start' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'From' ));
2020-09-09 11:34:47 +02:00
print '</div>' ;
print '<div class="nowrap">' ;
2020-09-22 15:26:29 +02:00
print $form -> selectDate ( $search_datev_end ? $search_datev_end : - 1 , 'search_date_value_end' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'to' ));
2020-09-09 11:34:47 +02:00
print '</div>' ;
print '</td>' ;
}
2017-07-28 07:42:02 +02:00
2020-09-09 11:34:47 +02:00
// Payment type
if ( $arrayfields [ 'type' ][ 'checked' ]) {
2021-05-12 22:21:20 +02:00
print '<td class="liste_titre center">' ;
2022-06-20 04:57:38 +02:00
$form -> select_types_paiements ( $search_type_id , 'search_type_id' , '' , 0 , 1 , 1 , 16 , 1 , 'maxwidth100' );
2020-09-09 11:34:47 +02:00
print '</td>' ;
}
2017-07-28 07:42:02 +02:00
2020-09-09 11:34:47 +02:00
// Project
if ( $arrayfields [ 'project' ][ 'checked' ]) {
2017-07-07 06:09:49 +02:00
print '<td class="liste_titre">' ;
2020-09-09 11:34:47 +02:00
// TODO
2020-09-09 11:46:46 +02:00
print '</td>' ;
2020-09-09 11:34:47 +02:00
}
// Bank account
if ( $arrayfields [ 'bank' ][ 'checked' ]) {
print '<td class="liste_titre">' ;
2020-09-22 15:26:29 +02:00
$form -> select_comptes ( $search_bank_account , 'search_account' , 0 , '' , 1 , '' , 0 , 'maxwidth100' );
2020-09-09 11:46:46 +02:00
print '</td>' ;
2020-09-09 11:34:47 +02:00
}
// Bank entry
if ( $arrayfields [ 'entry' ][ 'checked' ]) {
2020-09-22 15:26:29 +02:00
print '<td class="liste_titre left">' ;
print '<input name="search_bank_entry" class="flat maxwidth50" type="text" value="' . dol_escape_htmltag ( $search_bank_entry ) . '">' ;
2020-09-09 11:46:46 +02:00
print '</td>' ;
2017-07-07 06:09:49 +02:00
}
2017-07-28 07:42:02 +02:00
// Accounting account
2020-09-09 11:34:47 +02:00
if ( $arrayfields [ 'account' ][ 'checked' ]) {
2017-12-15 07:04:05 +01:00
print '<td class="liste_titre">' ;
print '<div class="nowrap">' ;
2020-01-18 16:17:07 +01:00
print $formaccounting -> select_account ( $search_accountancy_account , 'search_accountancy_account' , 1 , array (), 1 , 1 , 'maxwidth200' );
2019-11-07 09:19:48 +01:00
print '</div>' ;
print '</td>' ;
2020-09-09 11:34:47 +02:00
}
2019-11-07 09:19:48 +01:00
2020-09-09 11:34:47 +02:00
// Subledger account
if ( $arrayfields [ 'subledger' ][ 'checked' ]) {
2019-11-07 09:19:48 +01:00
print '<td class="liste_titre">' ;
print '<div class="nowrap">' ;
2020-01-18 16:13:10 +01:00
print $formaccounting -> select_auxaccount ( $search_accountancy_subledger , 'search_accountancy_subledger' , 1 , 'maxwidth200' );
2017-12-15 07:04:05 +01:00
print '</div>' ;
print '</td>' ;
}
2017-07-28 07:42:02 +02:00
2017-08-01 06:44:37 +02:00
// Debit
2020-09-09 11:34:47 +02:00
if ( $arrayfields [ 'debit' ][ 'checked' ]) {
print '<td class="liste_titre right">' ;
2020-09-22 15:26:29 +02:00
print '<input name="search_amount_deb" class="flat maxwidth50" type="text" value="' . dol_escape_htmltag ( $search_amount_deb ) . '">' ;
2020-09-09 11:34:47 +02:00
print '</td>' ;
}
2017-07-28 07:42:02 +02:00
2017-08-01 06:44:37 +02:00
// Credit
2020-09-09 11:34:47 +02:00
if ( $arrayfields [ 'credit' ][ 'checked' ]) {
print '<td class="liste_titre right">' ;
2020-09-22 15:26:29 +02:00
print '<input name="search_amount_cred" class="flat maxwidth50" type="text" size="8" value="' . dol_escape_htmltag ( $search_amount_cred ) . '">' ;
2020-09-09 11:34:47 +02:00
print '</td>' ;
}
2017-03-19 08:17:32 +01:00
2019-05-19 13:51:47 +02:00
print '<td class="liste_titre maxwidthsearch">' ;
2020-01-18 16:17:07 +01:00
$searchpicto = $form -> showFilterAndCheckAddButtons ( 0 );
2017-07-07 06:09:49 +02:00
print $searchpicto ;
print '</td>' ;
2017-06-09 09:25:15 +02:00
2020-09-09 11:34:47 +02:00
print '</tr>' ;
2018-01-29 19:07:42 +01:00
print '<tr class="liste_titre">' ;
2020-09-09 11:34:47 +02:00
2021-02-23 21:09:01 +01:00
if ( ! empty ( $conf -> global -> MAIN_VIEW_LINE_NUMBER_IN_LIST )) {
print_liste_field_titre ( '#' , $_SERVER [ 'PHP_SELF' ], '' , '' , $param , '' , $sortfield , $sortorder );
}
if ( $arrayfields [ 'ref' ][ 'checked' ]) {
print_liste_field_titre ( $arrayfields [ 'ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'v.rowid' , '' , $param , '' , $sortfield , $sortorder );
}
if ( $arrayfields [ 'label' ][ 'checked' ]) {
2021-05-12 22:21:20 +02:00
print_liste_field_titre ( $arrayfields [ 'label' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'v.label' , '' , $param , '' , $sortfield , $sortorder );
2021-02-23 21:09:01 +01:00
}
if ( $arrayfields [ 'datep' ][ 'checked' ]) {
print_liste_field_titre ( $arrayfields [ 'datep' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'v.datep,v.rowid' , '' , $param , '' , $sortfield , $sortorder , 'center ' );
}
if ( $arrayfields [ 'datev' ][ 'checked' ]) {
print_liste_field_titre ( $arrayfields [ 'datev' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'v.datev,v.rowid' , '' , $param , '' , $sortfield , $sortorder , 'center ' );
}
if ( $arrayfields [ 'type' ][ 'checked' ]) {
2021-05-12 22:21:20 +02:00
print_liste_field_titre ( $arrayfields [ 'type' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'type' , '' , $param , '' , $sortfield , $sortorder , 'center ' );
2021-02-23 21:09:01 +01:00
}
if ( $arrayfields [ 'project' ][ 'checked' ]) {
print_liste_field_titre ( $arrayfields [ 'project' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'fk_project' , '' , $param , '' , $sortfield , $sortorder );
}
if ( $arrayfields [ 'bank' ][ 'checked' ]) {
print_liste_field_titre ( $arrayfields [ 'bank' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'ba.label' , '' , $param , '' , $sortfield , $sortorder );
}
if ( $arrayfields [ 'entry' ][ 'checked' ]) {
print_liste_field_titre ( $arrayfields [ 'entry' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'ba.label' , '' , $param , '' , $sortfield , $sortorder );
}
if ( $arrayfields [ 'account' ][ 'checked' ]) {
print_liste_field_titre ( $arrayfields [ 'account' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'v.accountancy_code' , '' , $param , '' , $sortfield , $sortorder , 'left ' );
}
if ( $arrayfields [ 'subledger' ][ 'checked' ]) {
print_liste_field_titre ( $arrayfields [ 'subledger' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'v.subledger_account' , '' , $param , '' , $sortfield , $sortorder , 'left ' );
}
if ( $arrayfields [ 'debit' ][ 'checked' ]) {
print_liste_field_titre ( $arrayfields [ 'debit' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'v.amount' , '' , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( $arrayfields [ 'credit' ][ 'checked' ]) {
print_liste_field_titre ( $arrayfields [ 'credit' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'v.amount' , '' , $param , '' , $sortfield , $sortorder , 'right ' );
}
2020-09-09 11:34:47 +02:00
// Fields from hook
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2022-05-17 23:23:50 +02:00
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], '' , '' , '' , '' , $sortfield , $sortorder , 'maxwidthsearch center ' );
2020-09-09 11:34:47 +02:00
print '</tr>' ;
2018-01-29 19:07:42 +01:00
2019-11-13 19:37:08 +01:00
$totalarray = array ();
2022-06-20 04:57:38 +02:00
$totalarray [ 'nbfield' ] = 0 ;
$totalarray [ 'val' ][ 'total_cred' ] = 0 ;
2022-07-26 11:53:00 +02:00
$totalarray [ 'val' ][ 'total_deb' ] = 0 ;
2021-02-23 21:09:01 +01:00
while ( $i < min ( $num , $limit )) {
2022-05-10 11:38:56 +02:00
$obj = $db -> fetch_object ( $resql );
2017-06-09 09:25:15 +02:00
2021-02-02 11:41:32 +01:00
$variousstatic -> id = $obj -> rowid ;
$variousstatic -> ref = $obj -> rowid ;
$variousstatic -> label = $obj -> label ;
2017-07-07 06:09:49 +02:00
print '<tr class="oddeven">' ;
2017-03-19 08:17:32 +01:00
2020-09-09 11:34:47 +02:00
// No
if ( ! empty ( $conf -> global -> MAIN_VIEW_LINE_NUMBER_IN_LIST )) {
print '<td>' . (( $offset * $limit ) + $i ) . '</td>' ;
}
2020-09-09 11:46:46 +02:00
2017-07-07 06:09:49 +02:00
// Ref
2020-09-09 11:34:47 +02:00
if ( $arrayfields [ 'ref' ][ 'checked' ]) {
2021-02-02 11:41:32 +01:00
print '<td>' . $variousstatic -> getNomUrl ( 1 ) . " </td> " ;
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-09-09 11:34:47 +02:00
}
2017-07-28 07:42:02 +02:00
2017-03-19 08:17:32 +01:00
// Label payment
2020-09-09 11:34:47 +02:00
if ( $arrayfields [ 'label' ][ 'checked' ]) {
2021-02-02 11:41:32 +01:00
print '<td class="tdoverflowmax150" title="' . $variousstatic -> label . '">' . $variousstatic -> label . " </td> " ;
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-09-09 11:34:47 +02:00
}
2017-07-28 07:42:02 +02:00
2017-03-19 08:17:32 +01:00
// Date payment
2020-09-09 11:34:47 +02:00
if ( $arrayfields [ 'datep' ][ 'checked' ]) {
print '<td class="center">' . dol_print_date ( $obj -> datep , 'day' ) . " </td> " ;
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-09-09 11:34:47 +02:00
}
2020-09-09 11:46:46 +02:00
2020-09-09 11:34:47 +02:00
// Date value
if ( $arrayfields [ 'datev' ][ 'checked' ]) {
print '<td class="center">' . dol_print_date ( $obj -> datev , 'day' ) . " </td> " ;
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-09-09 11:34:47 +02:00
}
2017-07-28 07:42:02 +02:00
2017-07-07 06:09:49 +02:00
// Type
2020-09-09 11:34:47 +02:00
if ( $arrayfields [ 'type' ][ 'checked' ]) {
2021-05-12 22:21:20 +02:00
print '<td class="center">' ;
2021-02-02 11:41:32 +01:00
if ( $obj -> payment_code ) {
print $langs -> trans ( " PaymentTypeShort " . $obj -> payment_code );
print ' ' ;
}
print $obj -> num_payment ;
print '</td>' ;
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-09-09 11:34:47 +02:00
}
// Project
if ( $arrayfields [ 'project' ][ 'checked' ]) {
2020-12-24 01:35:59 +01:00
print '<td class="nowraponall">' ;
if ( $obj -> fk_project > 0 ) {
$proj -> fetch ( $obj -> fk_project );
print $proj -> getNomUrl ( 1 );
}
print '</td>' ;
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-09-09 11:34:47 +02:00
}
2017-07-28 07:42:02 +02:00
2020-09-09 11:34:47 +02:00
// Bank account
if ( $arrayfields [ 'bank' ][ 'checked' ]) {
2020-12-24 01:35:59 +01:00
print '<td class="nowraponall">' ;
2021-02-23 21:09:01 +01:00
if ( $obj -> bid > 0 ) {
2019-11-13 19:37:08 +01:00
$accountstatic -> id = $obj -> bid ;
$accountstatic -> ref = $obj -> bref ;
$accountstatic -> number = $obj -> bnumber ;
2017-07-28 07:42:02 +02:00
2022-08-29 11:22:21 +02:00
if ( isModEnabled ( 'accounting' )) {
2019-11-13 19:37:08 +01:00
$accountstatic -> account_number = $obj -> bank_account_number ;
2017-07-28 07:42:02 +02:00
$accountingjournal -> fetch ( $obj -> accountancy_journal );
2019-01-27 11:55:16 +01:00
$accountstatic -> accountancy_journal = $accountingjournal -> getNomUrl ( 0 , 1 , 1 , '' , 1 );
2017-07-28 07:42:02 +02:00
}
2019-11-13 19:37:08 +01:00
$accountstatic -> label = $obj -> blabel ;
2017-07-07 06:09:49 +02:00
print $accountstatic -> getNomUrl ( 1 );
2020-09-09 11:34:47 +02:00
} else {
print ' ' ;
}
2020-10-06 14:39:10 +02:00
print '</td>' ;
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-09-09 11:34:47 +02:00
}
// Bank entry
if ( $arrayfields [ 'entry' ][ 'checked' ]) {
$bankline -> fetch ( $obj -> fk_bank );
print '<td>' . $bankline -> getNomUrl ( 1 ) . '</td>' ;
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-07-07 06:09:49 +02:00
}
2017-07-28 07:42:02 +02:00
// Accounting account
2020-09-09 11:34:47 +02:00
if ( $arrayfields [ 'account' ][ 'checked' ]) {
2023-01-04 09:15:39 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php' ;
2017-12-11 07:03:37 +01:00
$accountingaccount -> fetch ( '' , $obj -> accountancy_code , 1 );
2017-07-28 07:42:02 +02:00
2022-06-20 04:57:38 +02:00
print '<td class="tdoverflowmax150" title="' . dol_escape_htmltag ( $obj -> accountancy_code . ' ' . $accountingaccount -> label ) . '">' . $accountingaccount -> getNomUrl ( 0 , 1 , 1 , '' , 1 ) . '</td>' ;
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-07-28 07:42:02 +02:00
}
2019-11-07 09:19:48 +01:00
// Accounting subledger account
2020-09-09 11:34:47 +02:00
if ( $arrayfields [ 'subledger' ][ 'checked' ]) {
2022-05-17 23:23:50 +02:00
print '<td class="tdoverflowmax150">' . length_accounta ( $obj -> subledger_account ) . '</td>' ;
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2019-11-07 09:19:48 +01:00
}
2017-08-01 06:44:37 +02:00
// Debit
2020-09-09 11:34:47 +02:00
if ( $arrayfields [ 'debit' ][ 'checked' ]) {
print '<td class="nowrap right">' ;
2021-02-23 21:09:01 +01:00
if ( $obj -> sens == 0 ) {
2021-03-29 13:00:17 +02:00
print '<span class="amount">' . price ( $obj -> amount ) . '</span>' ;
2020-09-09 11:34:47 +02:00
$totalarray [ 'val' ][ 'total_deb' ] += $obj -> amount ;
}
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 'total_deb' ;
}
2020-09-09 11:34:47 +02:00
print '</td>' ;
2017-08-01 06:44:37 +02:00
}
2017-07-28 07:42:02 +02:00
2017-08-01 06:44:37 +02:00
// Credit
2020-09-09 11:34:47 +02:00
if ( $arrayfields [ 'credit' ][ 'checked' ]) {
print '<td class="nowrap right">' ;
2021-02-23 21:09:01 +01:00
if ( $obj -> sens == 1 ) {
2021-03-29 13:00:17 +02:00
print '<span class="amount">' . price ( $obj -> amount ) . '</span>' ;
2020-09-09 11:34:47 +02:00
$totalarray [ 'val' ][ 'total_cred' ] += $obj -> amount ;
}
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 'total_cred' ;
}
2020-09-09 11:34:47 +02:00
print '</td>' ;
2017-08-01 06:44:37 +02:00
}
2020-09-09 11:34:47 +02:00
2019-11-26 20:28:24 +01:00
print '<td></td>' ;
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-03-19 08:17:32 +01:00
2022-05-10 11:38:56 +02:00
print '</tr>' . " \n " ;
2017-03-19 08:17:32 +01:00
2017-07-07 06:09:49 +02:00
$i ++ ;
}
2017-03-19 08:17:32 +01:00
2019-11-05 12:47:38 +01:00
// Show total line
include DOL_DOCUMENT_ROOT . '/core/tpl/list_print_total.tpl.php' ;
2017-03-19 08:17:32 +01:00
2022-05-10 11:38:56 +02:00
// If no record found
if ( $num == 0 ) {
$colspan = 1 ;
foreach ( $arrayfields as $key => $val ) {
if ( ! empty ( $val [ 'checked' ])) {
$colspan ++ ;
}
}
print '<tr><td colspan="' . $colspan . '"><span class="opacitymedium">' . $langs -> trans ( " NoRecordFound " ) . '</span></td></tr>' ;
}
$db -> free ( $resql );
$parameters = array ( 'arrayfields' => $arrayfields , 'sql' => $sql );
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters , $object ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
print '</table>' . " \n " ;
print '</div>' . " \n " ;
2017-03-19 08:17:32 +01:00
2022-05-10 11:38:56 +02:00
print '</form>' . " \n " ;
2020-05-21 15:05:19 +02:00
} else {
2017-07-07 06:09:49 +02:00
dol_print_error ( $db );
2017-03-19 08:17:32 +01:00
}
2018-07-29 19:16:28 +02:00
// End of page
2017-03-19 08:17:32 +01:00
llxFooter ();
$db -> close ();