2004-10-19 22:35:36 +02:00
< ? php
2018-03-31 18:48:27 +02:00
use Stripe\BankAccount ;
2005-08-02 16:52:04 +02:00
/* Copyright ( C ) 2001 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2016-12-11 11:51:21 +01:00
* Copyright ( C ) 2004 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
2015-03-03 06:32:46 +01:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
2015-04-18 23:11:17 +02:00
* Copyright ( C ) 2015 Jean - François Ferry < jfefe @ aternatik . fr >
2018-04-20 10:38:16 +02:00
* Copyright ( C ) 2018 Ferran Marcet < fmarcet @ 2 byte . es >
2002-05-11 20:52:36 +02: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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2002-05-11 20:52:36 +02:00
* ( 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
2011-08-01 00:21:57 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2002-05-11 20:52:36 +02:00
*/
2004-11-26 01:16:52 +01:00
2005-02-14 21:26:23 +01:00
/**
2017-10-03 16:00:52 +02:00
* \file htdocs / compta / bank / list . php
2009-01-02 17:43:58 +01:00
* \ingroup banque
2011-12-30 00:33:34 +01:00
* \brief Home page of bank module
2009-01-02 17:43:58 +01:00
*/
2004-11-26 01:16:52 +01:00
2013-04-15 13:11:29 +02:00
require ( '../../main.inc.php' );
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/compta/sociales/class/chargesociales.class.php' ;
2013-06-05 16:24:32 +02:00
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
2017-05-06 08:33:12 +02:00
if ( ! empty ( $conf -> accounting -> enabled )) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php' ;
if ( ! empty ( $conf -> accounting -> enabled )) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php' ;
2013-06-05 16:24:32 +02:00
2018-05-27 09:40:17 +02:00
// Load translation files required by the page
$langs -> loadLangs ( array ( 'banks' , 'categories' , 'accountancy' , 'compta' ));
2005-02-14 21:26:23 +01:00
2016-09-18 15:48:29 +02:00
$action = GETPOST ( 'action' , 'alpha' );
$massaction = GETPOST ( 'massaction' , 'alpha' );
$show_files = GETPOST ( 'show_files' , 'int' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
$toselect = GETPOST ( 'toselect' , 'array' );
2018-03-31 18:48:27 +02:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'bankaccountlist' ; // To manage different context of search
2016-09-18 15:48:29 +02:00
2016-11-04 17:48:20 +01:00
$search_ref = GETPOST ( 'search_ref' , 'alpha' );
$search_label = GETPOST ( 'search_label' , 'alpha' );
$search_number = GETPOST ( 'search_number' , 'alpha' );
2017-09-19 19:00:28 +02:00
$search_status = GETPOST ( 'search_status' ) ? GETPOST ( 'search_status' , 'alpha' ) : 'opened' ; // 'all' or ''='opened'
2016-09-18 15:48:29 +02:00
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
2009-05-05 14:43:51 +02:00
// Security check
if ( $user -> societe_id ) $socid = $user -> societe_id ;
2018-04-09 10:47:26 +02:00
if ( ! empty ( $user -> rights -> accounting -> chartofaccount )) $allowed = 1 ; // Dictionary with list of banks accounting account allowed to manager of chart account
if ( ! $allowed ) $result = restrictedArea ( $user , 'banque' );
2003-11-05 10:59:16 +01:00
2016-10-05 22:24:14 +02:00
$diroutputmassaction = $conf -> bank -> dir_output . '/temp/massgeneration/' . $user -> id ;
2016-09-18 15:48:29 +02:00
2017-06-08 14:55:12 +02:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2016-09-18 15:48:29 +02:00
$sortfield = GETPOST ( " sortfield " , 'alpha' );
$sortorder = GETPOST ( " sortorder " , 'alpha' );
$page = GETPOST ( " page " , 'int' );
2017-06-06 10:53:53 +02:00
if ( empty ( $page ) || $page == - 1 ) { $page = 0 ; } // If $page is not defined, or '' or -1
2016-09-18 15:48:29 +02:00
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
if ( ! $sortfield ) $sortfield = 'b.label' ;
if ( ! $sortorder ) $sortorder = 'ASC' ;
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2018-03-31 18:48:27 +02:00
$object = new Account ( $db );
$hookmanager -> initHooks ( array ( 'bankaccountlist' ));
2016-09-18 15:48:29 +02:00
$extrafields = new ExtraFields ( $db );
// fetch optionals attributes and labels
2017-10-21 16:20:06 +02:00
$extralabels = $extrafields -> fetch_name_optionals_label ( 'bank_account' );
2016-09-18 15:48:29 +02:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $extralabels , '' , 'search_' );
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array (
'b.ref' => 'Ref' ,
'b.label' => 'Label' ,
);
$checkedtypetiers = 0 ;
$arrayfields = array (
'b.ref' => array ( 'label' => $langs -> trans ( " BankAccounts " ), 'checked' => 1 ),
2016-11-16 19:56:03 +01:00
'accountype' => array ( 'label' => $langs -> trans ( " Type " ), 'checked' => 1 ),
2016-09-18 15:48:29 +02:00
'b.label' => array ( 'label' => $langs -> trans ( " Label " ), 'checked' => 1 ),
'b.number' => array ( 'label' => $langs -> trans ( " AccountIdShort " ), 'checked' => 1 ),
2018-03-11 00:40:35 +01:00
'b.account_number' => array ( 'label' => $langs -> trans ( " AccountAccounting " ), 'checked' => ( ! empty ( $conf -> accounting -> enabled ) || ! empty ( $conf -> accounting -> enabled ))),
'b.fk_accountancy_journal' => array ( 'label' => $langs -> trans ( " AccountancyJournal " ), 'checked' => ( ! empty ( $conf -> accounting -> enabled ) || ! empty ( $conf -> accounting -> enabled ))),
2016-09-18 15:48:29 +02:00
'toreconcile' => array ( 'label' => $langs -> trans ( " TransactionsToConciliate " ), 'checked' => 1 ),
2017-09-25 18:11:03 +02:00
'b.currency_code' => array ( 'label' => $langs -> trans ( " Currency " ), 'checked' => 0 ),
'b.datec' => array ( 'label' => $langs -> trans ( " DateCreation " ), 'checked' => 0 , 'position' => 500 ),
2016-09-18 15:48:29 +02:00
'b.tms' => array ( 'label' => $langs -> trans ( " DateModificationShort " ), 'checked' => 0 , 'position' => 500 ),
'b.clos' => array ( 'label' => $langs -> trans ( " Status " ), 'checked' => 1 , 'position' => 1000 ),
'balance' => array ( 'label' => $langs -> trans ( " Balance " ), 'checked' => 1 , 'position' => 1010 ),
);
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
foreach ( $extrafields -> attribute_label as $key => $val )
{
2017-10-29 11:00:02 +01:00
if ( ! empty ( $extrafields -> attribute_list [ $key ])) $arrayfields [ " ef. " . $key ] = array ( 'label' => $extrafields -> attribute_label [ $key ], 'checked' => (( $extrafields -> attribute_list [ $key ] < 0 ) ? 0 : 1 ), 'position' => $extrafields -> attribute_pos [ $key ], 'enabled' => ( abs ( $extrafields -> attribute_list [ $key ]) != 3 && $extrafields -> attribute_perms [ $key ]));
2016-09-18 15:48:29 +02:00
}
}
2005-08-13 19:55:18 +02:00
2016-09-18 15:48:29 +02:00
/*
* Actions
*/
2005-08-13 19:55:18 +02:00
2017-09-15 10:50:50 +02:00
if ( GETPOST ( 'cancel' , 'alpha' )) { $action = 'list' ; $massaction = '' ; }
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' ) && $massaction != 'presend' && $massaction != 'confirm_presend' ) { $massaction = '' ; }
2008-09-04 21:47:46 +02:00
2016-09-18 15:48:29 +02:00
$parameters = array ( 'socid' => $socid );
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
// Purge search criteria
2017-09-25 18:11:03 +02:00
if ( GETPOST ( 'button_removefilter_x' , 'alpha' ) || GETPOST ( 'button_removefilter.x' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) // All tests are required to be compatible with all browsers
2016-09-18 15:48:29 +02:00
{
2016-11-04 17:48:20 +01:00
$search_ref = '' ;
$search_label = '' ;
$search_number = '' ;
2017-09-19 19:00:28 +02:00
$search_status = '' ;
2016-09-18 15:48:29 +02:00
}
2017-06-19 14:31:08 +02:00
2008-09-04 21:47:46 +02:00
/*
* View
*/
2016-11-05 03:27:56 +01:00
$form = new Form ( $db );
2016-06-25 14:20:23 +02:00
$title = $langs -> trans ( 'BankAccounts' );
2002-05-11 20:52:36 +02:00
2016-06-25 14:20:23 +02:00
// Load array of financial accounts (opened by default)
2005-05-07 23:56:12 +02:00
$accounts = array ();
2017-11-25 12:13:03 +01:00
$sql = " SELECT b.rowid, b.label, b.courant, b.rappro, b.account_number, b.fk_accountancy_journal, b.currency_code, b.datec as date_creation, b.tms as date_update " ;
2016-09-18 15:48:29 +02:00
// Add fields from extrafields
foreach ( $extrafields -> attribute_label as $key => $val ) $sql .= ( $extrafields -> attribute_type [ $key ] != 'separate' ? " ,ef. " . $key . ' as options_' . $key : '' );
// 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 . " bank_account as b " ;
2017-10-21 16:20:06 +02:00
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label )) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " bank_account_extrafields as ef on (b.rowid = ef.fk_object) " ;
2017-11-25 12:13:03 +01:00
$sql .= " WHERE b.entity IN ( " . getEntity ( 'bank_account' ) . " ) " ;
2017-09-19 19:00:28 +02:00
if ( $search_status == 'opened' ) $sql .= " AND clos = 0 " ;
if ( $search_status == 'closed' ) $sql .= " AND clos = 1 " ;
2016-11-04 17:48:20 +01:00
if ( $search_ref != '' ) $sql .= natural_search ( 'b.ref' , $search_ref );
if ( $search_label != '' ) $sql .= natural_search ( 'b.label' , $search_label );
if ( $search_number != '' ) $sql .= natural_search ( 'b.number' , $search_number );
2016-09-18 15:48:29 +02:00
// Add where from extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php' ;
2016-09-18 15:48:29 +02:00
// 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 ;
$sql .= $db -> order ( $sortfield , $sortorder );
// Count total nb of records
2017-01-15 20:49:20 +01:00
$nbtotalofrecords = '' ;
2016-09-18 15:48:29 +02:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST ))
{
$result = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $result );
}
$sql .= $db -> plimit ( $limit + 1 , $offset );
2002-05-11 20:52:36 +02:00
2005-08-02 16:52:04 +02:00
$resql = $db -> query ( $sql );
if ( $resql )
2003-08-26 12:10:42 +02:00
{
2016-06-25 14:20:23 +02:00
$num = $db -> num_rows ( $resql );
$i = 0 ;
while ( $i < $num )
{
$objp = $db -> fetch_object ( $resql );
$accounts [ $objp -> rowid ] = $objp -> courant ;
$i ++ ;
}
$db -> free ( $resql );
2002-05-11 20:52:36 +02:00
}
2016-09-18 15:57:53 +02:00
else dol_print_error ( $db );
2002-05-11 20:52:36 +02:00
2016-06-25 14:20:23 +02:00
$help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:Módulo_Bancos_y_Cajas' ;
llxHeader ( '' , $title , $help_url );
$link = '' ;
2016-09-18 15:48:29 +02:00
$num_rows = count ( $accounts );
2016-06-25 14:20:23 +02:00
2016-09-18 15:48:29 +02:00
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
2005-05-07 23:56:12 +02:00
2016-09-18 15:48:29 +02:00
$param = '' ;
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) $param .= '&contextpage=' . $contextpage ;
if ( $limit > 0 && $limit != $conf -> liste_limit ) $param .= '&limit=' . $limit ;
2016-11-04 17:48:20 +01:00
if ( $search_ref != '' ) $param .= '&search_ref=' . $search_ref ;
if ( $search_label != '' ) $param .= '&search_label=' . $search_label ;
if ( $search_number != '' ) $param .= '&search_number=' . $search_number ;
2017-09-19 19:00:28 +02:00
if ( $search_status != '' ) $param .= '&search_status=' . $search_status ;
2016-09-18 15:48:29 +02:00
if ( $show_files ) $param .= '&show_files=' . $show_files ;
if ( $optioncss != '' ) $param .= '&optioncss=' . $optioncss ;
// Add $param from extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php' ;
2011-12-30 00:33:34 +01:00
2016-09-18 15:48:29 +02:00
// List of mass actions available
$arrayofmassactions = array (
// 'presend'=>$langs->trans("SendByMail"),
// 'builddoc'=>$langs->trans("PDFMerge"),
);
2017-11-15 11:39:11 +01:00
if ( $user -> rights -> banque -> supprimer ) $arrayofmassactions [ 'predelete' ] = $langs -> trans ( " Delete " );
2017-11-11 16:03:22 +01:00
if ( in_array ( $massaction , array ( 'presend' , 'predelete' ))) $arrayofmassactions = array ();
2016-09-18 15:48:29 +02:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2006-07-01 16:37:19 +02:00
2016-12-11 11:51:21 +01:00
$newcardbutton = '' ;
if ( $user -> rights -> banque -> configurer )
{
2018-06-13 22:57:41 +02:00
$newcardbutton .= '<a class="butActionNew" href="card.php?action=create"><span class="valignmiddle">' . $langs -> trans ( " NewFinancialAccount " ) . '</span>' ;
2018-04-18 03:26:15 +02:00
$newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>' ;
$newcardbutton .= '</a>' ;
2016-12-11 11:51:21 +01:00
}
2006-07-01 16:37:19 +02:00
2016-09-18 15:48:29 +02:00
// Lines of title fields
print '<form method="POST" id="searchFormList" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
if ( $optioncss != '' ) print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ '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 . '">' ;
2017-05-21 02:43:51 +02:00
print '<input type="hidden" name="page" value="' . $page . '">' ;
2016-09-18 15:48:29 +02:00
print '<input type="hidden" name="viewstatut" value="' . $viewstatut . '">' ;
2006-07-01 16:37:19 +02:00
2016-12-11 11:51:21 +01:00
print_barre_liste ( $title , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , '' , $num , $nbtotalofrecords , 'title_bank.png' , 0 , $newcardbutton , '' , $limit , 1 );
2016-09-18 15:48:29 +02:00
2017-11-15 11:39:11 +01:00
$topicmail = " Information " ;
//$modelmail="subscription";
$objecttmp = new Account ( $db );
//$trackid='sub'.$object->id;
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php' ;
2016-09-18 15:48:29 +02:00
if ( $sall )
2014-06-11 17:42:03 +02:00
{
2016-09-18 15:48:29 +02:00
foreach ( $fieldstosearchall as $key => $val ) $fieldstosearchall [ $key ] = $langs -> trans ( $val );
2018-10-23 17:16:46 +02:00
print '<div class="divsearchfieldfilter">' . $langs -> trans ( " FilterOnInto " , $sall ) . join ( ', ' , $fieldstosearchall ) . '</div>' ;
2014-06-11 17:42:03 +02:00
}
2004-02-15 19:42:02 +01:00
2016-09-18 15:48:29 +02:00
$moreforfilter = '' ;
2004-11-16 21:42:37 +01:00
2005-05-07 23:56:12 +02:00
2016-09-18 15:48:29 +02:00
// Bank accounts
$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 ))
2005-05-07 23:56:12 +02:00
{
2016-09-18 15:48:29 +02:00
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
print '</div>' ;
}
2011-12-30 00:33:34 +01:00
2016-09-18 15:48:29 +02:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
2016-11-16 19:56:03 +01:00
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
2006-07-01 16:37:19 +02:00
2016-11-27 11:41:10 +01:00
print '<div class="div-table-responsive">' ;
2016-09-18 15:48:29 +02:00
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2006-07-01 16:37:19 +02:00
2017-03-28 18:42:23 +02:00
print '<tr class="liste_titre_filter">' ;
2016-09-18 15:48:29 +02:00
// Ref
if ( ! empty ( $arrayfields [ 'b.ref' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '<input class="flat" size="6" type="text" name="search_ref" value="' . $search_ref . '">' ;
print '</td>' ;
2005-05-07 23:56:12 +02:00
}
2016-11-04 17:48:20 +01:00
// Label
if ( ! empty ( $arrayfields [ 'b.label' ][ 'checked' ]))
2015-03-08 02:37:25 +01:00
{
2016-09-18 15:48:29 +02:00
print '<td class="liste_titre">' ;
2016-11-04 17:48:20 +01:00
print '<input class="flat" size="6" type="text" name="search_label" value="' . $search_label . '">' ;
2016-09-18 15:48:29 +02:00
print '</td>' ;
2015-03-08 02:37:25 +01:00
}
2016-11-04 17:48:20 +01:00
// Account type
if ( ! empty ( $arrayfields [ 'accountype' ][ 'checked' ]))
2014-06-11 17:42:03 +02:00
{
2016-09-18 15:48:29 +02:00
print '<td class="liste_titre">' ;
print '</td>' ;
2014-06-11 17:42:03 +02:00
}
2017-04-29 15:30:40 +02:00
// Bank number
2016-09-18 15:48:29 +02:00
if ( ! empty ( $arrayfields [ 'b.number' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '<input class="flat" size="6" type="text" name="search_number" value="' . $search_number . '">' ;
print '</td>' ;
}
2017-04-29 15:30:40 +02:00
// Account number
2016-11-16 19:56:03 +01:00
if ( ! empty ( $arrayfields [ 'b.account_number' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
2017-04-29 15:30:40 +02:00
// Accountancy journal
2017-05-06 08:33:12 +02:00
if ( ! empty ( $arrayfields [ 'b.fk_accountancy_journal' ][ 'checked' ]))
2017-04-29 15:30:40 +02:00
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
2016-09-18 15:48:29 +02:00
// Transactions to reconcile
if ( ! empty ( $arrayfields [ 'toreconcile' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
2017-09-25 18:11:03 +02:00
// Currency
if ( ! empty ( $arrayfields [ 'b.currency_code' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
2016-09-18 15:48:29 +02:00
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php' ;
2016-09-18 15:48:29 +02:00
// 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 ;
// Date creation
if ( ! empty ( $arrayfields [ 'b.datec' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
// Date modification
if ( ! empty ( $arrayfields [ 'b.tms' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
2017-09-19 19:00:28 +02:00
// Status
2016-09-18 15:48:29 +02:00
if ( ! empty ( $arrayfields [ 'b.clos' ][ 'checked' ]))
{
2016-09-18 15:57:53 +02:00
print '<td class="liste_titre center">' ;
2016-09-18 15:48:29 +02:00
$array = array (
'opened' => $langs -> trans ( " Opened " ),
'closed' => $langs -> trans ( " Closed " )
);
2017-09-19 19:00:28 +02:00
print $form -> selectarray ( " search_status " , $array , $search_status , 1 );
2016-09-18 15:48:29 +02:00
print '</td>' ;
}
// Balance
2016-11-16 19:56:03 +01:00
if ( ! empty ( $arrayfields [ 'balance' ][ 'checked' ]))
{
2016-12-11 16:11:42 +01:00
print '<td class="liste_titre"></td>' ;
2016-11-16 19:56:03 +01:00
}
2016-09-18 15:48:29 +02:00
// Action column
print '<td class="liste_titre" align="middle">' ;
2017-05-14 21:06:33 +02:00
$searchpicto = $form -> showFilterAndCheckAddButtons ( $massactionbutton ? 1 : 0 , 'checkforselect' , 1 );
print $searchpicto ;
2016-09-18 15:48:29 +02:00
print '</td>' ;
print '</tr>' ;
2005-05-07 23:56:12 +02:00
2017-03-28 18:42:23 +02:00
// Fields title
print '<tr class="liste_titre">' ;
if ( ! empty ( $arrayfields [ 'b.ref' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'b.ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'b.ref' , '' , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'b.label' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'b.label' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'b.label' , '' , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'accountype' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'accountype' ][ 'label' ], $_SERVER [ " PHP_SELF " ], '' , '' , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'b.number' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'b.number' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'b.number' , '' , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'b.account_number' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'b.account_number' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'b.account_number' , '' , $param , '' , $sortfield , $sortorder );
2017-05-06 08:33:12 +02:00
if ( ! empty ( $arrayfields [ 'b.fk_accountancy_journal' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'b.fk_accountancy_journal' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'b.fk_accountancy_journal' , '' , $param , '' , $sortfield , $sortorder );
2017-11-15 11:39:11 +01:00
if ( ! empty ( $arrayfields [ 'b.currency_code' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'b.currency_code' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'b.currency_code' , '' , $param , 'align="center"' , $sortfield , $sortorder );
2017-03-28 18:42:23 +02:00
if ( ! empty ( $arrayfields [ 'toreconcile' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'toreconcile' ][ 'label' ], $_SERVER [ " PHP_SELF " ], '' , '' , $param , 'align="center"' , $sortfield , $sortorder );
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php' ;
2017-03-28 18:42:23 +02:00
// Hook fields
2018-04-20 10:38:16 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
2017-03-28 18:42:23 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
if ( ! empty ( $arrayfields [ 'b.datec' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'b.datec' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " b.datec " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'b.tms' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'b.tms' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " b.tms " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'b.clos' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'b.clos' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'b.clos' , '' , $param , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'balance' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'balance' ][ 'label' ], $_SERVER [ " PHP_SELF " ], '' , '' , $param , 'align="right"' , $sortfield , $sortorder );
2017-04-07 14:18:04 +02:00
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , 'align="center"' , $sortfield , $sortorder , 'maxwidthsearch ' );
2017-03-28 18:42:23 +02:00
print " </tr> \n " ;
2005-05-07 23:56:12 +02:00
2016-12-11 11:51:21 +01:00
$total = array (); $found = 0 ; $i = 0 ; $lastcurrencycode = '' ;
2018-06-13 22:52:24 +02:00
2005-05-07 23:56:12 +02:00
foreach ( $accounts as $key => $type )
{
2016-12-11 11:51:21 +01:00
if ( $i >= $limit ) break ;
2017-06-19 14:31:08 +02:00
2016-11-16 21:24:51 +01:00
$found ++ ;
2011-12-30 00:33:34 +01:00
2017-09-25 18:11:03 +02:00
$obj = new Account ( $db );
$obj -> fetch ( $key );
2005-05-07 23:56:12 +02:00
2017-09-25 18:11:03 +02:00
$solde = $obj -> solde ( 1 );
2005-05-07 23:56:12 +02:00
2017-09-25 18:11:03 +02:00
if ( ! empty ( $lastcurrencycode ) && $lastcurrencycode != $obj -> currency_code )
2016-12-11 11:51:21 +01:00
{
$lastcurrencycode = 'various' ; // We found several different currencies
}
if ( $lastcurrencycode != 'various' )
{
2017-09-25 18:11:03 +02:00
$lastcurrencycode = $obj -> currency_code ;
2016-12-11 11:51:21 +01:00
}
2017-06-19 14:31:08 +02:00
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2016-11-16 19:56:03 +01:00
2016-11-16 21:24:51 +01:00
// Ref
if ( ! empty ( $arrayfields [ 'b.ref' ][ 'checked' ]))
{
2017-09-25 18:11:03 +02:00
print '<td>' . $obj -> getNomUrl ( 1 ) . '</td>' ;
2016-11-16 21:24:51 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2017-06-19 14:31:08 +02:00
2016-11-16 21:24:51 +01:00
// Label
if ( ! empty ( $arrayfields [ 'b.label' ][ 'checked' ]))
{
2017-09-25 18:11:03 +02:00
print '<td>' . $obj -> label . '</td>' ;
2016-11-16 21:24:51 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2017-06-19 14:31:08 +02:00
2016-11-16 21:24:51 +01:00
// Account type
if ( ! empty ( $arrayfields [ 'accountype' ][ 'checked' ]))
{
print '<td>' ;
2017-09-25 18:11:03 +02:00
print $obj -> type_lib [ $obj -> type ];
2016-11-16 21:24:51 +01:00
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2017-06-19 14:31:08 +02:00
2016-11-16 21:24:51 +01:00
// Number
if ( ! empty ( $arrayfields [ 'b.number' ][ 'checked' ]))
{
2017-09-25 18:11:03 +02:00
print '<td>' . $obj -> number . '</td>' ;
2016-11-16 21:24:51 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2017-06-19 14:31:08 +02:00
2016-11-16 21:24:51 +01:00
// Account number
if ( ! empty ( $arrayfields [ 'b.account_number' ][ 'checked' ]))
{
2017-08-22 18:42:35 +02:00
print '<td>' ;
if ( ! empty ( $conf -> accounting -> enabled ))
{
$accountingaccount = new AccountingAccount ( $db );
2017-11-25 12:13:03 +01:00
$accountingaccount -> fetch ( '' , $obj -> account_number , 1 );
2017-08-22 18:42:35 +02:00
print $accountingaccount -> getNomUrl ( 0 , 1 , 1 , '' , 1 );
}
else
{
2017-09-25 18:11:03 +02:00
print $obj -> account_number ;
2017-08-22 18:42:35 +02:00
}
print '</td>' ;
2016-11-16 21:24:51 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2017-06-19 14:31:08 +02:00
2017-04-29 15:30:40 +02:00
// Accountancy journal
2017-05-06 08:33:12 +02:00
if ( ! empty ( $arrayfields [ 'b.fk_accountancy_journal' ][ 'checked' ]))
2017-04-29 15:30:40 +02:00
{
2017-08-22 18:42:35 +02:00
print '<td>' ;
if ( ! empty ( $conf -> accounting -> enabled ))
{
$accountingjournal = new AccountingJournal ( $db );
2017-09-25 18:11:03 +02:00
$accountingjournal -> fetch ( $obj -> fk_accountancy_journal );
2017-08-22 18:42:35 +02:00
print $accountingjournal -> getNomUrl ( 0 , 1 , 1 , '' , 1 );
}
else
{
print '' ;
}
print '</td>' ;
2017-05-06 08:33:12 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-04-29 15:30:40 +02:00
}
2017-06-19 14:31:08 +02:00
2017-09-25 18:11:03 +02:00
// Currency
if ( ! empty ( $arrayfields [ 'b.currency_code' ][ 'checked' ]))
{
print '<td align="center">' ;
print $obj -> currency_code ;
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2016-11-16 21:24:51 +01:00
// Transactions to reconcile
if ( ! empty ( $arrayfields [ 'toreconcile' ][ 'checked' ]))
{
print '<td align="center">' ;
2017-09-25 18:11:03 +02:00
if ( $obj -> rappro )
2016-09-18 15:48:29 +02:00
{
2017-09-25 18:11:03 +02:00
$result = $obj -> load_board ( $user , $obj -> id );
2016-11-16 21:24:51 +01:00
if ( $result < 0 ) {
2017-09-25 18:11:03 +02:00
setEventMessages ( $obj -> error , $obj -> errors , 'errors' );
2016-11-16 21:24:51 +01:00
} else {
print $result -> nbtodo ;
if ( $result -> nbtodolate ) print ' (' . $result -> nbtodolate . img_warning ( $langs -> trans ( " Late " )) . ')' ;
}
2016-09-18 15:48:29 +02:00
}
2016-11-16 21:24:51 +01:00
else print $langs -> trans ( " FeatureDisabled " );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2017-06-19 14:31:08 +02:00
2017-11-27 15:24:29 +01:00
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php' ;
2016-11-16 21:24:51 +01:00
// 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 ;
// Date creation
if ( ! empty ( $arrayfields [ 'b.datec' ][ 'checked' ]))
{
print '<td align="center">' ;
2017-09-25 18:11:03 +02:00
print dol_print_date ( $obj -> date_creation , 'dayhour' );
2016-11-16 21:24:51 +01:00
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Date modification
if ( ! empty ( $arrayfields [ 'b.tms' ][ 'checked' ]))
{
print '<td align="center">' ;
2017-09-25 18:11:03 +02:00
print dol_print_date ( $obj -> date_update , 'dayhour' );
2016-11-16 21:24:51 +01:00
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2017-06-19 14:31:08 +02:00
2017-09-19 19:00:28 +02:00
// Status
2016-11-16 21:24:51 +01:00
if ( ! empty ( $arrayfields [ 'b.clos' ][ 'checked' ]))
{
2017-09-25 18:11:03 +02:00
print '<td align="center">' . $obj -> getLibStatut ( 5 ) . '</td>' ;
2016-11-16 21:24:51 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2017-06-19 14:31:08 +02:00
2016-11-16 21:24:51 +01:00
// Balance
if ( ! empty ( $arrayfields [ 'balance' ][ 'checked' ]))
{
print '<td align="right">' ;
2018-06-13 08:39:26 +02:00
print '<a href="' . DOL_URL_ROOT . '/compta/bank/bankentries_list.php?id=' . $obj -> id . '">' . price ( $solde , 0 , $langs , 0 , - 1 , - 1 , $obj -> currency_code ) . '</a>' ;
2016-09-18 15:48:29 +02:00
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-11-16 21:24:51 +01:00
if ( ! $i ) $totalarray [ 'totalbalancefield' ] = $totalarray [ 'nbfield' ];
$totalarray [ 'totalbalance' ] += $solde ;
}
2017-06-19 14:31:08 +02:00
2016-11-16 21:24:51 +01:00
// Action column
print '<td class="nowrap" align="center">' ;
if ( $massactionbutton || $massaction ) // 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 -> rowid , $arrayofselected )) $selected = 1 ;
print '<input id="cb' . $obj -> rowid . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj -> rowid . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
}
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-06-19 14:31:08 +02:00
2016-11-16 21:24:51 +01:00
print '</tr>' ;
2017-09-25 18:11:03 +02:00
$total [ $obj -> currency_code ] += $solde ;
2016-11-16 21:24:51 +01:00
$i ++ ;
2014-10-16 20:55:13 +02:00
}
2016-11-16 21:24:51 +01:00
2017-04-14 13:02:29 +02:00
if ( ! $found ) print '<tr class="oddeven"><td colspan="' . $totalarray [ 'nbfield' ] . '" class="opacitymedium">' . $langs -> trans ( " None " ) . '</td></tr>' ;
2016-11-16 21:24:51 +01:00
// Show total line
2016-12-11 11:51:21 +01:00
if ( isset ( $totalarray [ 'totalbalancefield' ]) && $lastcurrencycode != 'various' ) // If there is several currency, $lastcurrencycode is set to 'various' before
2014-06-11 17:42:03 +02:00
{
2016-11-16 21:24:51 +01:00
print '<tr class="liste_total">' ;
$i = 0 ;
while ( $i < $totalarray [ 'nbfield' ])
{
$i ++ ;
if ( $i == 1 )
{
2017-05-10 11:57:59 +02:00
if ( $num < $limit && empty ( $offset )) print '<td align="left">' . $langs -> trans ( " Total " ) . '</td>' ;
2016-11-16 21:24:51 +01:00
else print '<td align="left">' . $langs -> trans ( " Totalforthispage " ) . '</td>' ;
}
2016-12-11 11:51:21 +01:00
elseif ( $totalarray [ 'totalbalancefield' ] == $i ) print '<td align="right">' . price ( $totalarray [ 'totalbalance' ], 0 , $langs , 0 , 0 , - 1 , $lastcurrencycode ) . '</td>' ;
2016-11-16 21:24:51 +01:00
else print '<td></td>' ;
}
print '</tr>' ;
2014-06-11 17:42:03 +02:00
}
2005-05-07 23:56:12 +02:00
2016-09-18 15:48:29 +02:00
print '</table>' ;
2016-11-27 11:41:10 +01:00
print " </div> " ;
print " </form> " ;
2002-05-11 20:52:36 +02:00
2004-01-24 22:40:00 +01:00
2011-08-27 16:24:16 +02:00
llxFooter ();
2011-12-30 00:33:34 +01:00
$db -> close ();