2014-08-27 07:03:42 +02:00
< ? php
2016-02-27 16:21:40 +01:00
/* Copyright ( C ) 2013 - 2016 Olivier Geffroy < jeff @ jeffinfo . com >
2017-01-31 06:08:40 +01:00
* Copyright ( C ) 2013 - 2017 Alexandre Spangaro < aspangaro @ zendsi . com >
2018-04-09 11:31:24 +02:00
* Copyright ( C ) 2016 - 2018 Laurent Destailleur < eldy @ users . sourceforge . net >
2014-08-27 07:03:42 +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
* 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
* along with this program . If not , see < http :// www . gnu . org / licenses />.
*/
/**
2016-02-27 16:21:40 +01:00
* \file htdocs / accountancy / admin / account . php
2016-09-30 17:03:09 +02:00
* \ingroup Advanced accountancy
2016-02-27 16:21:40 +01:00
* \brief List accounting account
2014-08-27 07:03:42 +02:00
*/
2016-02-01 14:50:25 +01:00
2016-10-07 12:10:16 +02:00
require '../../main.inc.php' ;
2016-10-15 14:38:43 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php' ;
2016-02-01 14:50:25 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php' ;
2014-08-27 07:03:42 +02:00
2018-05-26 23:52:52 +02:00
// Load translation files required by the page
2018-04-18 06:20:34 +02:00
$langs -> loadLangs ( array ( " compta " , " bills " , " admin " , " accountancy " , " salaries " ));
2014-08-27 07:03:42 +02:00
$mesg = '' ;
2017-05-16 13:27:32 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2017-09-15 10:50:50 +02:00
$cancel = GETPOST ( 'cancel' , 'alpha' );
2014-08-27 07:03:42 +02:00
$id = GETPOST ( 'id' , 'int' );
$rowid = GETPOST ( 'rowid' , 'int' );
2018-03-31 18:48:27 +02:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'accountingaccountlist' ; // To manage different context of search
2017-01-31 06:08:40 +01:00
2018-10-12 15:55:36 +02:00
$search_account = GETPOST ( 'search_account' , 'alpha' );
$search_label = GETPOST ( 'search_label' , 'alpha' );
$search_accountparent = GETPOST ( 'search_accountparent' , 'alpha' );
$search_pcgtype = GETPOST ( 'search_pcgtype' , 'alpha' );
$search_pcgsubtype = GETPOST ( 'search_pcgsubtype' , 'alpha' );
2014-08-27 07:03:42 +02:00
// Security check
2016-10-15 14:38:43 +02:00
if ( $user -> societe_id > 0 ) accessforbidden ();
if ( ! $user -> rights -> accounting -> chartofaccount ) accessforbidden ();
2014-08-27 07:03:42 +02:00
2016-05-12 21:32:24 +02:00
// Load variable for pagination
2017-06-08 14:55:12 +02:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2017-09-19 00:31:51 +02:00
$sortfield = GETPOST ( 'sortfield' , 'alpha' );
$sortorder = GETPOST ( 'sortorder' , 'alpha' );
$page = GETPOST ( 'page' , 'int' );
if ( empty ( $page ) || $page == - 1 ) { $page = 0 ; } // If $page is not defined, or '' or -1
2016-05-12 21:32:24 +02:00
$offset = $limit * $page ;
2014-08-27 07:03:42 +02:00
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2017-05-29 11:17:33 +02:00
if ( ! $sortfield ) $sortfield = " aa.account_number " ;
if ( ! $sortorder ) $sortorder = " ASC " ;
2014-08-27 07:03:42 +02:00
2017-01-31 06:08:40 +01:00
$arrayfields = array (
'aa.account_number' => array ( 'label' => $langs -> trans ( " AccountNumber " ), 'checked' => 1 ),
'aa.label' => array ( 'label' => $langs -> trans ( " Label " ), 'checked' => 1 ),
2018-09-18 11:49:35 +02:00
'aa.account_parent' => array ( 'label' => $langs -> trans ( " Accountparent " ), 'checked' => 1 ),
2017-10-23 20:17:57 +02:00
'aa.pcg_type' => array ( 'label' => $langs -> trans ( " Pcgtype " ), 'checked' => 1 , 'help' => 'PcgtypeDesc' ),
2018-09-18 11:49:35 +02:00
'aa.pcg_subtype' => array ( 'label' => $langs -> trans ( " Pcgsubtype " ), 'checked' => 0 , 'help' => 'PcgtypeDesc' ),
2017-01-31 06:08:40 +01:00
'aa.active' => array ( 'label' => $langs -> trans ( " Activated " ), 'checked' => 1 )
);
2014-08-27 07:03:42 +02:00
$accounting = new AccountingAccount ( $db );
2017-05-29 11:17:33 +02:00
2016-05-12 21:32:24 +02:00
/*
* Actions
*/
2017-09-15 10:50:50 +02:00
if ( GETPOST ( 'cancel' , 'alpha' )) { $action = 'list' ; $massaction = '' ; }
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' )) { $massaction = '' ; }
2016-05-12 21:32:24 +02:00
$parameters = array ();
$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' );
2016-10-07 12:10:16 +02:00
if ( empty ( $reshook ))
2016-05-12 21:32:24 +02:00
{
2016-10-07 12:10:16 +02:00
if ( ! empty ( $cancel )) $action = '' ;
2017-08-31 18:29:57 +02:00
2016-10-07 12:10:16 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
2017-08-31 18:29:57 +02:00
2017-07-13 00:35:10 +02: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
2016-10-07 12:10:16 +02:00
{
$search_account = " " ;
$search_label = " " ;
$search_accountparent = " " ;
$search_pcgtype = " " ;
$search_pcgsubtype = " " ;
2017-01-31 06:08:40 +01:00
$search_array_options = array ();
2016-10-07 12:10:16 +02:00
}
2017-08-31 18:29:57 +02:00
2017-10-23 20:42:09 +02:00
if ( GETPOST ( 'change_chart' , 'alpha' ))
2016-10-15 14:38:43 +02:00
{
$chartofaccounts = GETPOST ( 'chartofaccounts' , 'int' );
2017-08-31 18:29:57 +02:00
2017-10-23 20:42:09 +02:00
if ( $chartofaccounts > 0 )
{
// Get language code for this $chartofaccounts
$sql = 'SELECT code FROM ' . MAIN_DB_PREFIX . 'c_country as c, ' . MAIN_DB_PREFIX . 'accounting_system as a' ;
$sql .= ' WHERE c.rowid = a.fk_country AND a.rowid = ' . ( int ) $chartofaccounts ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$obj = $db -> fetch_object ( $resql );
$country_code = $obj -> code ;
}
else dol_print_error ( $db );
// Try to load sql file
if ( $country_code )
{
$sqlfile = DOL_DOCUMENT_ROOT . '/install/mysql/data/llx_accounting_account_' . strtolower ( $country_code ) . '.sql' ;
2018-09-03 14:00:12 +02:00
2018-09-17 21:02:07 +02:00
$offsetforchartofaccount = 0 ;
// Get the comment line '-- ADD CCCNNNNN to rowid...' to find CCCNNNNN (CCC is country num, NNNNN is id of accounting account)
// and pass CCCNNNNN + (num of company * 100 000 000) as offset to the run_sql as a new parameter to say to update sql on the fly to add offset to rowid and account_parent value.
// This is to be sure there is no conflict for each chart of account, whatever is country, whatever is company when multicompany is used.
$tmp = file_get_contents ( $sqlfile );
if ( preg_match ( '/-- ADD (\d+) to rowid/ims' , $tmp , $reg ))
{
$offsetforchartofaccount += $reg [ 1 ];
}
$offsetforchartofaccount += ( $conf -> entity * 100000000 );
2018-09-18 11:49:35 +02:00
$result = run_sql ( $sqlfile , 1 , $conf -> entity , 1 , '' , 'default' , 32768 , 0 , $offsetforchartofaccount );
2018-09-17 21:02:07 +02:00
if ( $result > 0 )
{
setEventMessages ( $langs -> trans ( " ChartLoaded " ), null );
}
else
{
setEventMessages ( $langs -> trans ( " ErrorDuringChartLoad " ), null , 'warnings' );
}
2017-10-23 20:42:09 +02:00
}
2017-08-31 18:29:57 +02:00
2016-10-15 14:38:43 +02:00
if ( ! dolibarr_set_const ( $db , 'CHARTOFACCOUNTS' , $chartofaccounts , 'chaine' , 0 , '' , $conf -> entity )) {
2017-10-23 20:42:09 +02:00
$error ++ ;
2016-10-15 14:38:43 +02:00
}
} else {
2018-09-17 21:02:07 +02:00
$error ++ ;
2016-10-15 14:38:43 +02:00
}
}
2017-08-31 18:29:57 +02:00
2016-10-07 12:10:16 +02:00
if ( $action == 'disable' ) {
if ( $accounting -> fetch ( $id )) {
$result = $accounting -> account_desactivate ( $id );
}
2017-08-31 18:29:57 +02:00
2016-10-07 12:10:16 +02:00
$action = 'update' ;
if ( $result < 0 ) {
setEventMessages ( $accounting -> error , $accounting -> errors , 'errors' );
}
} else if ( $action == 'enable' ) {
if ( $accounting -> fetch ( $id )) {
$result = $accounting -> account_activate ( $id );
}
$action = 'update' ;
if ( $result < 0 ) {
setEventMessages ( $accounting -> error , $accounting -> errors , 'errors' );
}
}
2014-08-27 07:03:42 +02:00
}
2014-10-31 07:37:59 +01:00
2014-08-27 07:03:42 +02:00
/*
* View
*/
2017-05-29 11:17:33 +02:00
2017-01-31 06:08:40 +01:00
$form = new Form ( $db );
2016-05-12 21:32:24 +02:00
2014-08-27 07:03:42 +02:00
llxHeader ( '' , $langs -> trans ( " ListAccounts " ));
2016-05-12 21:32:24 +02:00
if ( $action == 'delete' ) {
$formconfirm = $html -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $id , $langs -> trans ( 'DeleteAccount' ), $langs -> trans ( 'ConfirmDeleteAccount' ), 'confirm_delete' , '' , 0 , 1 );
print $formconfirm ;
}
2014-08-27 07:03:42 +02:00
$pcgver = $conf -> global -> CHARTOFACCOUNTS ;
2016-02-27 16:21:40 +01:00
$sql = " SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active, " ;
$sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2 " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " accounting_account as aa " ;
2018-05-02 08:45:18 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = " . $conf -> entity ;
2018-05-05 14:40:39 +02:00
if ( $db -> type == 'pgsql' ) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = " . $conf -> entity ;
else $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = " . $conf -> entity ;
2016-02-27 16:21:40 +01:00
$sql .= " WHERE asy.rowid = " . $pcgver ;
2018-04-09 11:31:24 +02:00
//print $sql;
2017-01-31 06:08:40 +01:00
if ( strlen ( trim ( $search_account ))) $sql .= natural_search ( " aa.account_number " , $search_account );
if ( strlen ( trim ( $search_label ))) $sql .= natural_search ( " aa.label " , $search_label );
if ( strlen ( trim ( $search_accountparent ))) $sql .= natural_search ( " aa.account_parent " , $search_accountparent );
if ( strlen ( trim ( $search_pcgtype ))) $sql .= natural_search ( " aa.pcg_type " , $search_pcgtype );
if ( strlen ( trim ( $search_pcgsubtype ))) $sql .= natural_search ( " aa.pcg_subtype " , $search_pcgsubtype );
2014-08-27 07:03:42 +02:00
$sql .= $db -> order ( $sortfield , $sortorder );
2016-05-12 21:32:24 +02:00
// Count total nb of records
2017-01-15 20:49:20 +01:00
$nbtotalofrecords = '' ;
2016-05-12 21:32:24 +02:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST ))
{
2016-10-15 16:20:08 +02:00
$resql = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $resql );
2018-04-24 11:37:57 +02:00
if (( $page * $limit ) > $nbtotalofrecords ) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0 ;
$offset = 0 ;
}
2017-08-31 18:29:57 +02:00
}
2016-05-12 21:32:24 +02:00
2014-08-27 07:03:42 +02:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
2014-08-28 06:30:01 +02:00
dol_syslog ( 'accountancy/admin/account.php:: $sql=' . $sql );
2016-10-15 16:20:08 +02:00
$resql = $db -> query ( $sql );
2014-08-27 07:03:42 +02:00
2017-01-31 06:08:40 +01:00
if ( $resql )
{
2016-10-15 16:20:08 +02:00
$num = $db -> num_rows ( $resql );
2017-01-31 06:08:40 +01:00
2017-09-06 19:53:28 +02:00
$param = '' ;
2017-01-31 06:08:40 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) $param .= '&contextpage=' . $contextpage ;
2017-09-06 19:53:28 +02:00
if ( $limit > 0 && $limit != $conf -> liste_limit ) $param .= '&limit=' . $limit ;
if ( $search_account ) $param .= '&search_account=' . urlencode ( $search_account );
if ( $search_label ) $param .= '&search_label=' . urlencode ( $search_label );
if ( $search_accountparent ) $param .= '&search_accountparent=' . urlencode ( $search_accountparent );
if ( $search_pcgtype ) $param .= '&search_pcgtype=' . urlencode ( $search_pcgtype );
if ( $search_pcgsubtype ) $param .= '&search_pcgsubtype=' . urlencode ( $search_pcgsubtype );
2016-05-12 21:32:24 +02:00
if ( $optioncss != '' ) $param .= '&optioncss=' . $optioncss ;
2017-03-05 22:11:35 +01:00
2017-01-31 06:08:40 +01:00
2017-05-29 11:17:33 +02:00
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 . '">' ;
print '<input type="hidden" name="page" value="' . $page . '">' ;
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">' ;
2017-08-31 18:29:57 +02:00
2018-06-13 22:57:41 +02:00
$newcardbutton = '<a class="butActionNew" href="./card.php?action=create"><span class="valignmiddle">' . $langs -> trans ( " Addanaccount " ) . '</span>' ;
2018-04-18 03:26:15 +02:00
$newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>' ;
$newcardbutton .= '</a>' ;
2017-08-31 18:29:57 +02:00
2018-04-15 16:35:18 +02:00
print_barre_liste ( $langs -> trans ( 'ListAccounts' ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , '' , $num , $nbtotalofrecords , 'title_accountancy' , 0 , $newcardbutton , '' , $limit );
2017-08-31 18:29:57 +02:00
2016-11-16 18:00:37 +01:00
// Box to select active chart of account
2016-10-15 14:38:43 +02:00
print $langs -> trans ( " Selectchartofaccounts " ) . " : " ;
print '<select class="flat" name="chartofaccounts" id="chartofaccounts">' ;
2017-10-23 20:14:14 +02:00
$sql = " SELECT a.rowid, a.pcg_version, a.label, a.active, c.code as country_code " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " accounting_system as a " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_country as c ON a.fk_country = c.rowid " ;
$sql .= " WHERE a.active = 1 " ;
dol_syslog ( 'accountancy/admin/account.php $sql=' . $sql );
print $sql ;
2016-10-15 16:20:08 +02:00
$resqlchart = $db -> query ( $sql );
if ( $resqlchart ) {
$numbis = $db -> num_rows ( $resqlchart );
2016-10-15 14:38:43 +02:00
$i = 0 ;
2017-10-23 20:14:14 +02:00
while ( $i < $numbis ) {
$obj = $db -> fetch_object ( $resqlchart );
2017-08-31 18:29:57 +02:00
2017-10-23 20:14:14 +02:00
print '<option value="' . $obj -> rowid . '"' ;
print ( $pcgver == $obj -> rowid ) ? ' selected' : '' ;
print '>' . $obj -> pcg_version . ' - ' . $obj -> label . ' - (' . $obj -> country_code . ')</option>' ;
2017-08-31 18:29:57 +02:00
2017-10-23 20:14:14 +02:00
$i ++ ;
2016-10-15 14:38:43 +02:00
}
}
2017-10-23 20:14:14 +02:00
else dol_print_error ( $db );
2016-10-15 14:38:43 +02:00
print " </select> " ;
2017-10-23 20:14:14 +02:00
print ajax_combobox ( " chartofaccounts " );
2018-04-09 11:31:24 +02:00
print '<input type="submit" class="button" name="change_chart" tabindex="-1" value="' . dol_escape_htmltag ( $langs -> trans ( " ChangeAndLoad " )) . '">' ;
2017-11-28 11:01:02 +01:00
2017-08-31 18:29:57 +02:00
print '<br>' ;
2017-03-03 17:59:49 +01:00
print '<br>' ;
2017-08-31 18:29:57 +02:00
2017-01-31 06:08:40 +01:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
2017-08-31 18:29:57 +02:00
2017-01-31 06:08:40 +01:00
print '<div class="div-table-responsive">' ;
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
// Line for search fields
2017-04-01 12:46:47 +02:00
print '<tr class="liste_titre_filter">' ;
2017-01-31 06:08:40 +01:00
if ( ! empty ( $arrayfields [ 'aa.account_number' ][ 'checked' ])) print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_account" value="' . $search_account . '"></td>' ;
if ( ! empty ( $arrayfields [ 'aa.label' ][ 'checked' ])) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="' . $search_label . '"></td>' ;
if ( ! empty ( $arrayfields [ 'aa.account_parent' ][ 'checked' ])) print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_accountparent" value="' . $search_accountparent . '"></td>' ;
if ( ! empty ( $arrayfields [ 'aa.pcg_type' ][ 'checked' ])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgtype" value="' . $search_pcgtype . '"></td>' ;
if ( ! empty ( $arrayfields [ 'aa.pcg_subtype' ][ 'checked' ])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgsubtype" value="' . $search_pcgsubtype . '"></td>' ;
if ( ! empty ( $arrayfields [ 'aa.active' ][ 'checked' ])) print '<td class="liste_titre"> </td>' ;
2018-04-09 11:31:24 +02:00
print '<td align="right" class="liste_titre">' ;
2017-01-31 06:08:40 +01:00
$searchpicto = $form -> showFilterAndCheckAddButtons ( $massactionbutton ? 1 : 0 , 'checkforselect' , 1 );
print $searchpicto ;
2014-08-27 07:03:42 +02:00
print '</td>' ;
print '</tr>' ;
2017-08-31 18:29:57 +02:00
2017-04-01 12:46:47 +02:00
print '<tr class="liste_titre">' ;
if ( ! empty ( $arrayfields [ 'aa.account_number' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'aa.account_number' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " aa.account_number " , " " , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'aa.label' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'aa.label' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " aa.label " , " " , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'aa.account_parent' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'aa.account_parent' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " aa.account_parent " , " " , $param , 'align="left"' , $sortfield , $sortorder );
2017-08-31 18:29:57 +02:00
if ( ! empty ( $arrayfields [ 'aa.pcg_type' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'aa.pcg_type' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'aa.pcg_type' , '' , $param , '' , $sortfield , $sortorder , '' , $arrayfields [ 'aa.pcg_type' ][ 'help' ]);
if ( ! empty ( $arrayfields [ 'aa.pcg_subtype' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'aa.pcg_subtype' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'aa.pcg_subtype' , '' , $param , '' , $sortfield , $sortorder , '' , $arrayfields [ 'aa.pcg_subtype' ][ 'help' ]);
2017-04-01 12:46:47 +02:00
if ( ! empty ( $arrayfields [ 'aa.active' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'aa.active' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'aa.active' , '' , $param , '' , $sortfield , $sortorder );
2017-04-07 14:18:04 +02:00
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , 'align="center"' , $sortfield , $sortorder , 'maxwidthsearch ' );
2017-04-01 12:46:47 +02:00
print " </tr> \n " ;
2016-02-01 14:50:25 +01:00
$accountstatic = new AccountingAccount ( $db );
2016-02-27 16:21:40 +01:00
$accountparent = new AccountingAccount ( $db );
2017-01-31 06:08:40 +01:00
2017-05-29 11:17:33 +02:00
$i = 0 ;
2017-08-31 18:29:57 +02:00
while ( $i < min ( $num , $limit ))
2016-11-16 18:00:37 +01:00
{
2014-08-27 07:03:42 +02:00
$obj = $db -> fetch_object ( $resql );
2016-11-16 18:00:37 +01:00
2016-02-01 14:50:25 +01:00
$accountstatic -> id = $obj -> rowid ;
$accountstatic -> label = $obj -> label ;
$accountstatic -> account_number = $obj -> account_number ;
2017-08-31 18:29:57 +02:00
2017-04-01 12:46:47 +02:00
print '<tr class="oddeven">' ;
2017-01-31 06:08:40 +01:00
// Account number
if ( ! empty ( $arrayfields [ 'aa.account_number' ][ 'checked' ]))
{
print " <td> " ;
2018-04-09 11:31:24 +02:00
print $accountstatic -> getNomUrl ( 1 , 0 , 0 , '' , 0 , 1 );
2017-01-31 06:08:40 +01:00
print " </td> \n " ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-02-27 16:21:40 +01:00
}
2017-01-31 06:08:40 +01:00
// Account label
if ( ! empty ( $arrayfields [ 'aa.label' ][ 'checked' ]))
2016-02-27 16:21:40 +01:00
{
2017-01-31 06:08:40 +01:00
print " <td> " ;
print $obj -> label ;
print " </td> \n " ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2016-02-27 16:21:40 +01:00
}
2017-01-31 06:08:40 +01:00
// Account parent
if ( ! empty ( $arrayfields [ 'aa.account_parent' ][ 'checked' ]))
{
if ( ! empty ( $obj -> account_parent ))
{
$accountparent -> id = $obj -> rowid2 ;
$accountparent -> label = $obj -> label2 ;
$accountparent -> account_number = $obj -> account_number2 ;
2017-08-31 18:29:57 +02:00
2017-01-31 06:08:40 +01:00
print " <td> " ;
print $accountparent -> getNomUrl ( 1 );
print " </td> \n " ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
else
{
print '<td> </td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2014-08-27 07:03:42 +02:00
}
2017-01-31 06:08:40 +01:00
// Chart of accounts type
if ( ! empty ( $arrayfields [ 'aa.pcg_type' ][ 'checked' ]))
{
print " <td> " ;
print $obj -> pcg_type ;
print " </td> \n " ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Chart of accounts subtype
if ( ! empty ( $arrayfields [ 'aa.pcg_subtype' ][ 'checked' ]))
{
print " <td> " ;
print $obj -> pcg_subtype ;
print " </td> \n " ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Activated or not
if ( ! empty ( $arrayfields [ 'aa.active' ][ 'checked' ]))
{
print '<td>' ;
if ( empty ( $obj -> active )) {
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $obj -> rowid . '&action=enable">' ;
print img_picto ( $langs -> trans ( " Disabled " ), 'switch_off' );
print '</a>' ;
} else {
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $obj -> rowid . '&action=disable">' ;
print img_picto ( $langs -> trans ( " Activated " ), 'switch_on' );
print '</a>' ;
}
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2014-10-31 07:37:59 +01:00
// Action
print '<td align="center">' ;
2017-03-03 17:59:49 +01:00
if ( $user -> rights -> accounting -> chartofaccount ) {
print '<a href="./card.php?action=update&id=' . $obj -> rowid . '&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?chartofaccounts=' . $object -> id ) . '">' ;
2014-08-27 07:03:42 +02:00
print img_edit ();
2014-10-31 07:37:59 +01:00
print '</a>' ;
print ' ' ;
2017-03-03 17:59:49 +01:00
print '<a href="./card.php?action=delete&id=' . $obj -> rowid . '&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?chartofaccounts=' . $object -> id ) . '">' ;
2014-08-27 07:03:42 +02:00
print img_delete ();
print '</a>' ;
}
print '</td>' . " \n " ;
2017-01-31 06:08:40 +01:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-08-31 18:29:57 +02:00
2014-08-27 07:03:42 +02:00
print " </tr> \n " ;
2016-11-16 18:00:37 +01:00
$i ++ ;
2014-08-27 07:03:42 +02:00
}
2017-08-31 18:29:57 +02:00
2014-08-27 07:03:42 +02:00
print " </table> " ;
2017-01-31 06:08:40 +01:00
print " </div> " ;
2014-08-27 07:03:42 +02:00
print '</form>' ;
} else {
dol_print_error ( $db );
}
2018-07-28 14:02:33 +02:00
// End of page
2014-08-27 07:03:42 +02:00
llxFooter ();
2014-11-23 09:58:19 +01:00
$db -> close ();