2020-10-05 10:05:21 +02:00
< ? php
/* Copyright ( C ) 2013 - 2016 Olivier Geffroy < jeff @ jeffinfo . com >
* Copyright ( C ) 2013 - 2020 Alexandre Spangaro < aspangaro @ open - dsi . fr >
* Copyright ( C ) 2016 - 2018 Laurent Destailleur < eldy @ users . sourceforge . net >
*
* 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 < https :// www . gnu . org / licenses />.
*/
/**
* \file htdocs / accountancy / admin / subaccount . php
* \ingroup Accountancy ( Double entries )
2020-10-06 15:11:45 +02:00
* \brief List of accounting sub - account ( auxiliary accounts )
2020-10-05 10:05:21 +02:00
*/
require '../../main.inc.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php' ;
// Load translation files required by the page
$langs -> loadLangs ( array ( " compta " , " bills " , " admin " , " accountancy " , " salaries " , " hrm " , " errors " ));
$mesg = '' ;
$action = GETPOST ( 'action' , 'aZ09' );
$cancel = GETPOST ( 'cancel' , 'alpha' );
$id = GETPOST ( 'id' , 'int' );
$rowid = GETPOST ( 'rowid' , 'int' );
$massaction = GETPOST ( 'massaction' , 'aZ09' );
2021-10-23 21:14:32 +02:00
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
2020-10-05 10:05:21 +02:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'accountingsubaccountlist' ; // To manage different context of search
$search_subaccount = GETPOST ( 'search_subaccount' , 'alpha' );
$search_label = GETPOST ( 'search_label' , 'alpha' );
$search_type = GETPOST ( 'search_type' , 'int' );
// Security check
2021-02-22 21:36:42 +01:00
if ( $user -> socid > 0 ) {
accessforbidden ();
}
2021-10-22 22:08:38 +02:00
if ( empty ( $user -> rights -> accounting -> chartofaccount )) {
2021-02-22 21:36:42 +01:00
accessforbidden ();
}
2020-10-05 10:05:21 +02:00
// Load variable for pagination
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
$sortfield = GETPOST ( 'sortfield' , 'aZ09comma' );
$sortorder = GETPOST ( 'sortorder' , 'aZ09comma' );
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
2021-02-22 21:36:42 +01:00
if ( empty ( $page ) || $page == - 1 ) {
$page = 0 ;
} // If $page is not defined, or '' or -1
2020-10-05 10:05:21 +02:00
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2021-02-22 21:36:42 +01:00
if ( ! $sortfield ) {
$sortfield = " label " ;
}
if ( ! $sortorder ) {
$sortorder = " ASC " ;
}
2020-10-05 10:05:21 +02:00
$arrayfields = array (
2020-10-07 15:01:28 +02:00
'subaccount' => array ( 'label' => $langs -> trans ( " AccountNumber " ), 'checked' => 1 ),
'label' => array ( 'label' => $langs -> trans ( " Label " ), 'checked' => 1 ),
'type' => array ( 'label' => $langs -> trans ( " Type " ), 'checked' => 1 ),
'reconcilable' => array ( 'label' => $langs -> trans ( " Reconcilable " ), 'checked' => 1 )
2020-10-05 10:05:21 +02:00
);
2021-02-22 21:36:42 +01:00
if ( $conf -> global -> MAIN_FEATURES_LEVEL < 2 ) {
unset ( $arrayfields [ 'reconcilable' ]);
}
2020-10-05 10:05:21 +02:00
/*
* Actions
*/
2021-02-22 21:36:42 +01:00
if ( GETPOST ( 'cancel' , 'alpha' )) {
$action = 'list' ; $massaction = '' ;
}
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' )) {
$massaction = '' ;
}
2020-10-05 10:05:21 +02:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-22 21:36:42 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2020-10-05 10:05:21 +02:00
2021-02-22 21:36:42 +01:00
if ( empty ( $reshook )) {
if ( ! empty ( $cancel )) {
$action = '' ;
}
2020-10-05 10:05:21 +02:00
2020-10-07 15:01:28 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
2020-10-05 10:05:21 +02:00
2021-02-22 21:36:42 +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-10-07 15:01:28 +02:00
$search_subaccount = " " ;
$search_label = " " ;
$search_type = " " ;
2020-10-05 10:05:21 +02:00
$search_array_options = array ();
2020-10-07 15:01:28 +02:00
}
2020-10-05 10:05:21 +02:00
}
/*
* View
*/
$form = new Form ( $db );
2021-03-08 11:08:58 +01:00
$help_url = '' ;
2020-10-09 19:34:57 +02:00
$title = $langs -> trans ( 'ChartOfIndividualAccountsOfSubsidiaryLedger' );
2021-03-08 11:08:58 +01:00
llxHeader ( '' , $title , $help_url );
2020-10-05 10:05:21 +02:00
// Customer
2020-11-08 03:51:35 +01:00
$sql = " SELECT sa.rowid, sa.nom as label, sa.code_compta as subaccount, '1' as type, sa.entity " ;
2020-10-05 10:05:21 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe sa " ;
2020-10-06 13:13:07 +02:00
$sql .= " WHERE sa.entity IN ( " . getEntity ( 'societe' ) . " ) " ;
$sql .= " AND sa.code_compta <> '' " ;
2020-10-05 10:05:21 +02:00
//print $sql;
if ( strlen ( trim ( $search_subaccount ))) {
$lengthpaddingaccount = 0 ;
if ( $conf -> global -> ACCOUNTING_LENGTH_AACCOUNT ) {
$lengthpaddingaccount = max ( $conf -> global -> ACCOUNTING_LENGTH_AACCOUNT );
}
$search_subaccount_tmp = $search_subaccount ;
$weremovedsomezero = 0 ;
if ( strlen ( $search_subaccount_tmp ) <= $lengthpaddingaccount ) {
for ( $i = 0 ; $i < $lengthpaddingaccount ; $i ++ ) {
if ( preg_match ( '/0$/' , $search_subaccount_tmp )) {
$weremovedsomezero ++ ;
$search_subaccount_tmp = preg_replace ( '/0$/' , '' , $search_subaccount_tmp );
}
}
}
//var_dump($search_subaccount); exit;
if ( $search_subaccount_tmp ) {
if ( $weremovedsomezero ) {
$search_subaccount_tmp_clean = $search_subaccount_tmp ;
$search_subaccount_clean = $search_subaccount ;
$startchar = '%' ;
2021-02-22 21:36:42 +01:00
if ( strpos ( $search_subaccount_tmp , '^' ) === 0 ) {
2020-10-05 10:05:21 +02:00
$startchar = '' ;
$search_subaccount_tmp_clean = preg_replace ( '/^\^/' , '' , $search_subaccount_tmp );
$search_subaccount_clean = preg_replace ( '/^\^/' , '' , $search_subaccount );
}
$sql .= " AND (sa.code_compta LIKE ' " . $db -> escape ( $startchar . $search_subaccount_tmp_clean ) . " ' " ;
$sql .= " OR sa.code_compta LIKE ' " . $db -> escape ( $startchar . $search_subaccount_clean ) . " %') " ;
2021-02-22 21:36:42 +01:00
} else {
$sql .= natural_search ( " sa.code_compta " , $search_subaccount_tmp );
}
2020-10-05 10:05:21 +02:00
}
}
2021-02-22 21:36:42 +01:00
if ( strlen ( trim ( $search_label ))) {
$sql .= natural_search ( " sa.nom " , $search_label );
}
if ( ! empty ( $search_type ) && $search_type >= 0 ) {
$sql .= " HAVING type LIKE ' " . $db -> escape ( $search_type ) . " ' " ;
}
2020-10-05 10:05:21 +02:00
// Supplier
$sql .= " UNION " ;
2020-11-08 03:51:35 +01:00
$sql .= " SELECT sa.rowid, sa.nom as label, sa.code_compta_fournisseur as subaccount, '2' as type, sa.entity FROM " . MAIN_DB_PREFIX . " societe sa " ;
2020-10-06 13:13:07 +02:00
$sql .= " WHERE sa.entity IN ( " . getEntity ( 'societe' ) . " ) " ;
$sql .= " AND sa.code_compta_fournisseur <> '' " ;
2020-10-05 10:05:21 +02:00
//print $sql;
if ( strlen ( trim ( $search_subaccount ))) {
$lengthpaddingaccount = 0 ;
if ( $conf -> global -> ACCOUNTING_LENGTH_AACCOUNT ) {
$lengthpaddingaccount = max ( $conf -> global -> ACCOUNTING_LENGTH_AACCOUNT );
}
$search_subaccount_tmp = $search_subaccount ;
$weremovedsomezero = 0 ;
if ( strlen ( $search_subaccount_tmp ) <= $lengthpaddingaccount ) {
for ( $i = 0 ; $i < $lengthpaddingaccount ; $i ++ ) {
if ( preg_match ( '/0$/' , $search_subaccount_tmp )) {
$weremovedsomezero ++ ;
$search_subaccount_tmp = preg_replace ( '/0$/' , '' , $search_subaccount_tmp );
}
}
}
//var_dump($search_subaccount); exit;
if ( $search_subaccount_tmp ) {
if ( $weremovedsomezero ) {
$search_subaccount_tmp_clean = $search_subaccount_tmp ;
$search_subaccount_clean = $search_subaccount ;
$startchar = '%' ;
2021-02-22 21:36:42 +01:00
if ( strpos ( $search_subaccount_tmp , '^' ) === 0 ) {
2020-10-05 10:05:21 +02:00
$startchar = '' ;
$search_subaccount_tmp_clean = preg_replace ( '/^\^/' , '' , $search_subaccount_tmp );
$search_subaccount_clean = preg_replace ( '/^\^/' , '' , $search_subaccount );
}
$sql .= " AND (sa.code_compta_fournisseur LIKE ' " . $db -> escape ( $startchar . $search_subaccount_tmp_clean ) . " ' " ;
$sql .= " OR sa.code_compta_fournisseur LIKE ' " . $db -> escape ( $startchar . $search_subaccount_clean ) . " %') " ;
2021-02-22 21:36:42 +01:00
} else {
$sql .= natural_search ( " sa.code_compta_fournisseur " , $search_subaccount_tmp );
}
2020-10-05 10:05:21 +02:00
}
}
2021-02-22 21:36:42 +01:00
if ( strlen ( trim ( $search_label ))) {
$sql .= natural_search ( " sa.nom " , $search_label );
}
if ( ! empty ( $search_type ) && $search_type >= 0 ) {
$sql .= " HAVING type LIKE ' " . $db -> escape ( $search_type ) . " ' " ;
}
2020-10-05 10:05:21 +02:00
// User
$sql .= " UNION " ;
2020-11-08 03:51:35 +01:00
$sql .= " SELECT u.rowid, u.lastname as label, u.accountancy_code as subaccount, '3' as type, u.entity FROM " . MAIN_DB_PREFIX . " user u " ;
2020-10-06 13:13:07 +02:00
$sql .= " WHERE u.entity IN ( " . getEntity ( 'user' ) . " ) " ;
$sql .= " AND u.accountancy_code <> '' " ;
2020-10-05 10:05:21 +02:00
//print $sql;
if ( strlen ( trim ( $search_subaccount ))) {
$lengthpaddingaccount = 0 ;
if ( $conf -> global -> ACCOUNTING_LENGTH_AACCOUNT ) {
$lengthpaddingaccount = max ( $conf -> global -> ACCOUNTING_LENGTH_AACCOUNT );
}
$search_subaccount_tmp = $search_subaccount ;
$weremovedsomezero = 0 ;
if ( strlen ( $search_subaccount_tmp ) <= $lengthpaddingaccount ) {
for ( $i = 0 ; $i < $lengthpaddingaccount ; $i ++ ) {
if ( preg_match ( '/0$/' , $search_subaccount_tmp )) {
$weremovedsomezero ++ ;
$search_subaccount_tmp = preg_replace ( '/0$/' , '' , $search_subaccount_tmp );
}
}
}
//var_dump($search_subaccount); exit;
if ( $search_subaccount_tmp ) {
if ( $weremovedsomezero ) {
$search_subaccount_tmp_clean = $search_subaccount_tmp ;
$search_subaccount_clean = $search_subaccount ;
$startchar = '%' ;
2021-02-22 21:36:42 +01:00
if ( strpos ( $search_subaccount_tmp , '^' ) === 0 ) {
2020-10-05 10:05:21 +02:00
$startchar = '' ;
$search_subaccount_tmp_clean = preg_replace ( '/^\^/' , '' , $search_subaccount_tmp );
$search_subaccount_clean = preg_replace ( '/^\^/' , '' , $search_subaccount );
}
$sql .= " AND (u.accountancy_code LIKE ' " . $db -> escape ( $startchar . $search_subaccount_tmp_clean ) . " ' " ;
$sql .= " OR u.accountancy_code LIKE ' " . $db -> escape ( $startchar . $search_subaccount_clean ) . " %') " ;
2021-02-22 21:36:42 +01:00
} else {
$sql .= natural_search ( " u.accountancy_code " , $search_subaccount_tmp );
}
2020-10-05 10:05:21 +02:00
}
}
2021-02-22 21:36:42 +01:00
if ( strlen ( trim ( $search_label ))) {
$sql .= natural_search ( " u.lastname " , $search_label );
}
if ( ! empty ( $search_type ) && $search_type >= 0 ) {
$sql .= " HAVING type LIKE ' " . $db -> escape ( $search_type ) . " ' " ;
}
2020-10-05 10:05:21 +02:00
$sql .= $db -> order ( $sortfield , $sortorder );
// Count total nb of records
$nbtotalofrecords = '' ;
2021-02-22 21:36:42 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST )) {
2020-10-05 10:05:21 +02:00
$resql = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $resql );
2021-02-22 21:36:42 +01:00
if (( $page * $limit ) > $nbtotalofrecords ) { // if total resultset is smaller then paging size (filtering), goto and load page 0
2020-10-05 10:05:21 +02:00
$page = 0 ;
$offset = 0 ;
}
}
$sql .= $db -> plimit ( $limit + 1 , $offset );
dol_syslog ( 'accountancy/admin/subaccount.php:: $sql=' . $sql );
$resql = $db -> query ( $sql );
2021-02-22 21:36:42 +01:00
if ( $resql ) {
2020-10-05 10:05:21 +02:00
$num = $db -> num_rows ( $resql );
$param = '' ;
2021-02-22 21:36:42 +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_subaccount ) {
$param .= '&search_subaccount=' . urlencode ( $search_subaccount );
}
if ( $search_label ) {
$param .= '&search_label=' . urlencode ( $search_label );
}
if ( $optioncss != '' ) {
$param .= '&optioncss=' . urlencode ( $optioncss );
}
2020-10-05 10:05:21 +02:00
print '<form method="POST" id="searchFormList" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2021-02-22 21:36:42 +01:00
if ( $optioncss != '' ) {
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
}
2020-10-05 10:05:21 +02:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">' ;
2020-10-09 19:34:57 +02:00
print_barre_liste ( $title , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , '' , $num , $nbtotalofrecords , 'title_accountancy' , 0 , '' , '' , $limit , 0 , 0 , 1 );
2020-10-05 10:05:21 +02:00
2021-03-08 11:08:58 +01:00
print '<div class="info">' . $langs -> trans ( " WarningCreateSubAccounts " ) . '</div>' ;
2020-10-05 10:05:21 +02:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
2020-10-07 15:01:28 +02:00
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
2020-10-05 10:05:21 +02:00
2020-10-07 15:01:28 +02:00
$moreforfilter = '' ;
$massactionbutton = '' ;
2020-10-05 10:05:21 +02:00
2020-10-07 15:01:28 +02:00
print '<div class="div-table-responsive">' ;
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2020-10-05 10:05:21 +02:00
// Line for search fields
print '<tr class="liste_titre_filter">' ;
2021-02-22 21:36:42 +01:00
if ( ! empty ( $arrayfields [ 'subaccount' ][ 'checked' ])) {
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_subaccount" value="' . $search_subaccount . '"></td>' ;
}
if ( ! empty ( $arrayfields [ 'label' ][ 'checked' ])) {
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="' . $search_label . '"></td>' ;
}
if ( ! empty ( $arrayfields [ 'type' ][ 'checked' ])) {
print '<td class="liste_titre center">' . $form -> selectarray ( 'search_type' , array ( '1' => $langs -> trans ( 'Customer' ), '2' => $langs -> trans ( 'Supplier' ), '3' => $langs -> trans ( 'Employee' )), $search_type , 1 ) . '</td>' ;
}
if ( $conf -> global -> MAIN_FEATURES_LEVEL >= 2 ) {
if ( ! empty ( $arrayfields [ 'reconcilable' ][ 'checked' ])) {
print '<td class="liste_titre"> </td>' ;
}
}
2020-10-05 10:05:21 +02:00
print '<td class="liste_titre maxwidthsearch">' ;
$searchpicto = $form -> showFilterAndCheckAddButtons ( $massactionbutton ? 1 : 0 , 'checkforselect' , 1 );
print $searchpicto ;
print '</td>' ;
print '</tr>' ;
2020-10-07 15:01:28 +02:00
print '<tr class="liste_titre">' ;
2021-02-22 21:36:42 +01:00
if ( ! empty ( $arrayfields [ 'subaccount' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'subaccount' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " subaccount " , " " , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'label' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'label' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " label " , " " , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'type' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'type' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " type " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
}
if ( $conf -> global -> MAIN_FEATURES_LEVEL >= 2 ) {
if ( ! empty ( $arrayfields [ 'reconcilable' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'reconcilable' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'reconcilable' , '' , $param , '' , $sortfield , $sortorder , 'center ' );
}
}
2020-10-05 10:05:21 +02:00
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch ' );
print " </tr> \n " ;
$totalarray = array ();
2021-10-23 21:14:32 +02:00
$totalarray [ 'nbfield' ] = 0 ;
2020-10-05 10:05:21 +02:00
$i = 0 ;
2021-02-22 21:36:42 +01:00
while ( $i < min ( $num , $limit )) {
2020-10-05 10:05:21 +02:00
$obj = $db -> fetch_object ( $resql );
print '<tr class="oddeven">' ;
// Account number
2021-02-22 21:36:42 +01:00
if ( ! empty ( $arrayfields [ 'subaccount' ][ 'checked' ])) {
2020-10-05 10:05:21 +02:00
print " <td> " ;
print length_accounta ( $obj -> subaccount );
print " </td> \n " ;
2021-02-22 21:36:42 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-10-05 10:05:21 +02:00
}
// Subaccount label
2021-02-22 21:36:42 +01:00
if ( ! empty ( $arrayfields [ 'label' ][ 'checked' ])) {
2020-10-05 10:05:21 +02:00
print " <td> " ;
print $obj -> label ;
print " </td> \n " ;
2021-02-22 21:36:42 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-10-05 10:05:21 +02:00
}
// Type
2021-02-22 21:36:42 +01:00
if ( ! empty ( $arrayfields [ 'type' ][ 'checked' ])) {
2020-10-05 10:05:21 +02:00
print '<td class="center">' ;
$s = '' ;
// Customer
2021-02-22 21:36:42 +01:00
if ( $obj -> type == 1 ) {
2020-10-09 18:18:18 +02:00
$s .= '<a class="customer-back" style="padding-left: 6px; padding-right: 6px" title="' . $langs -> trans ( " Customer " ) . '" href="' . DOL_URL_ROOT . '/comm/card.php?socid=' . $obj -> rowid . '">' . $langs -> trans ( " Customer " ) . '</a>' ;
2021-02-22 21:36:42 +01:00
} elseif ( $obj -> type == 2 ) {
// Supplier
2020-10-09 18:18:18 +02:00
$s .= '<a class="vendor-back" style="padding-left: 6px; padding-right: 6px" title="' . $langs -> trans ( " Supplier " ) . '" href="' . DOL_URL_ROOT . '/fourn/card.php?socid=' . $obj -> rowid . '">' . $langs -> trans ( " Supplier " ) . '</a>' ;
2021-02-22 21:36:42 +01:00
} elseif ( $obj -> type == 3 ) {
// User
2020-10-09 18:18:18 +02:00
$s .= '<a class="user-back" style="padding-left: 6px; padding-right: 6px" title="' . $langs -> trans ( " Employee " ) . '" href="' . DOL_URL_ROOT . '/user/card.php?id=' . $obj -> id . '">' . $langs -> trans ( " Employee " ) . '</a>' ;
2020-10-05 10:05:21 +02:00
}
print $s ;
print '</td>' ;
2021-02-22 21:36:42 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-10-05 10:05:21 +02:00
}
if ( $conf -> global -> MAIN_FEATURES_LEVEL >= 2 ) {
// Activated or not reconciliation on accounting account
if ( ! empty ( $arrayfields [ 'reconcilable' ][ 'checked' ])) {
print '<td class="center">' ;
if ( empty ( $obj -> reconcilable )) {
2021-03-19 12:44:59 +01:00
print '<a class="reposition" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $obj -> rowid . '&action=enable&mode=1&token=' . newToken () . '">' ;
2020-10-05 10:05:21 +02:00
print img_picto ( $langs -> trans ( " Disabled " ), 'switch_off' );
print '</a>' ;
} else {
2021-03-19 12:44:59 +01:00
print '<a class="reposition" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $obj -> rowid . '&action=disable&mode=1&token=' . newToken () . '">' ;
2020-10-05 10:05:21 +02:00
print img_picto ( $langs -> trans ( " Activated " ), 'switch_on' );
print '</a>' ;
}
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
}
}
// Action
print '<td class="center">' ;
2021-02-22 21:36:42 +01:00
$e = '' ;
// Customer
if ( $obj -> type == 1 ) {
2021-09-27 12:24:01 +02:00
$e .= '<a class="editfielda" title="' . $langs -> trans ( " Customer " ) . '" href="' . DOL_URL_ROOT . '/societe/card.php?action=edit&token=' . newToken () . '&socid=' . $obj -> rowid . '&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ]) . '">' . img_edit () . '</a>' ;
2021-02-22 21:36:42 +01:00
} elseif ( $obj -> type == 2 ) {
2020-10-05 10:05:21 +02:00
// Supplier
2021-09-27 12:24:01 +02:00
$e .= '<a class="editfielda" title="' . $langs -> trans ( " Supplier " ) . '" href="' . DOL_URL_ROOT . '/societe/card.php?action=edit&token=' . newToken () . '&socid=' . $obj -> rowid . '&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ]) . '">' . img_edit () . '</a>' ;
2021-02-22 21:36:42 +01:00
} elseif ( $obj -> type == 3 ) {
2020-10-05 10:05:21 +02:00
// User
2021-09-27 12:24:01 +02:00
$e .= '<a class="editfielda" title="' . $langs -> trans ( " Employee " ) . '" href="' . DOL_URL_ROOT . '/user/card.php?action=edit&token=' . newToken () . '&id=' . $obj -> rowid . '&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ]) . '">' . img_edit () . '</a>' ;
2020-10-05 10:10:39 +02:00
}
2021-02-22 21:36:42 +01:00
print $e ;
2020-10-05 10:05:21 +02:00
print '</td>' . " \n " ;
2021-02-22 21:36:42 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-10-05 10:05:21 +02:00
print '</tr>' . " \n " ;
$i ++ ;
}
$db -> free ( $resql );
$parameters = array ( 'arrayfields' => $arrayfields , 'sql' => $sql );
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
print " </table> " ;
print " </div> " ;
print '</form>' ;
} else {
dol_print_error ( $db );
}
// End of page
llxFooter ();
$db -> close ();