2004-10-19 22:35:36 +02:00
< ? php
2020-10-13 15:09:25 +02:00
/* Copyright ( C ) 2001 - 2003 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2004 - 2020 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2005 - 2009 Regis Houssin < regis . houssin @ inodbox . com >
* Copyright ( C ) 2011 - 2019 Alexandre Spangaro < aspangaro @ open - dsi . fr >
* Copyright ( C ) 2020 Tobias Sekan < tobias . sekan @ startmail . com >
2021-01-19 12:02:05 +01:00
* Copyright ( C ) 2021 Gauthier VERDOL < gauthier . verdol @ atm - consulting . fr >
2002-09-26 16:26:32 +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-09-26 16:26:32 +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
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2002-09-26 16:26:32 +02:00
*/
2005-05-08 21:25:55 +02:00
/**
2020-10-13 15:09:25 +02:00
* \file htdocs / compta / tva / list . php
* \ingroup tax
* \brief List of VAT payments
2009-10-29 18:30:29 +01:00
*/
2005-05-08 21:25:55 +02:00
2012-08-22 23:24:21 +02:00
require '../../main.inc.php' ;
2020-10-13 15:09:25 +02:00
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php' ;
2016-08-11 18:18:03 +02:00
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
2015-04-23 07:26:09 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
2021-08-06 12:18:51 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
2015-04-23 07:26:09 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
2017-05-31 05:27:39 +02:00
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php' ;
2002-09-26 16:26:32 +02:00
2018-05-27 09:27:09 +02:00
// Load translation files required by the page
$langs -> loadLangs ( array ( 'compta' , 'bills' ));
2005-05-08 21:25:55 +02:00
2020-10-13 15:09:25 +02:00
$action = GETPOST ( 'action' , 'alpha' );
$massaction = GETPOST ( 'massaction' , 'alpha' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
2020-10-31 14:32:18 +01:00
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
2020-10-13 15:09:25 +02:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'salestaxeslist' ;
$search_ref = GETPOST ( 'search_ref' , 'alpha' );
2020-10-31 14:32:18 +01:00
$search_label = GETPOST ( 'search_label' , 'alpha' );
$search_dateend_start = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'search_dateend_startmonth' , 'int' ), GETPOST ( 'search_dateend_startday' , 'int' ), GETPOST ( 'search_dateend_startyear' , 'int' ));
$search_dateend_end = dol_mktime ( 23 , 59 , 59 , GETPOST ( 'search_dateend_endmonth' , 'int' ), GETPOST ( 'search_dateend_endday' , 'int' ), GETPOST ( 'search_dateend_endyear' , 'int' ));
$search_datepayment_start = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'search_datepayment_startmonth' , 'int' ), GETPOST ( 'search_datepayment_startday' , 'int' ), GETPOST ( 'search_datepayment_startyear' , 'int' ));
$search_datepayment_end = dol_mktime ( 23 , 59 , 59 , GETPOST ( 'search_datepayment_endmonth' , 'int' ), GETPOST ( 'search_datepayment_endday' , 'int' ), GETPOST ( 'search_datepayment_endyear' , 'int' ));
$search_type = GETPOST ( 'search_type' , 'int' );
2020-10-13 15:09:25 +02:00
$search_account = GETPOST ( 'search_account' , 'int' );
$search_amount = GETPOST ( 'search_amount' , 'alpha' );
2021-01-19 12:02:05 +01:00
$search_status = GETPOST ( 'search_status' , 'int' );
2020-10-13 15:09:25 +02:00
2020-10-31 14:32:18 +01:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2022-01-13 11:09:37 +01:00
$sortfield = GETPOST ( 'sortfield' , 'aZ09comma' );
$sortorder = GETPOST ( 'sortorder' , 'aZ09comma' );
2020-10-31 14:32:18 +01:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( 'page' , 'int' );
2020-10-13 15:09:25 +02:00
2021-02-23 21:09:01 +01:00
if ( empty ( $page ) || $page == - 1 ) {
$page = 0 ; // If $page is not defined, or '' or -1
}
2016-02-16 17:43:05 +01:00
$offset = $limit * $page ;
2014-05-01 07:44:10 +02:00
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2021-02-23 21:09:01 +01:00
if ( ! $sortfield ) {
$sortfield = 't.datev' ;
}
if ( ! $sortorder ) {
$sortorder = 'DESC' ;
}
2014-05-01 07:44:10 +02:00
2020-10-13 15:09:25 +02:00
$arrayfields = array (
't.rowid' => array ( 'checked' => 1 , 'position' => 10 , 'label' => " Ref " ,),
't.label' => array ( 'checked' => 1 , 'position' => 20 , 'label' => " Label " ),
't.datev' => array ( 'checked' => 1 , 'position' => 30 , 'label' => " PeriodEndDate " ),
2021-03-29 16:22:22 +02:00
't.fk_typepayment' => array ( 'checked' => 1 , 'position' => 50 , 'label' => " DefaultPaymentMode " ),
2021-01-19 12:02:05 +01:00
't.amount' => array ( 'checked' => 1 , 'position' => 90 , 'label' => " Amount " ),
't.status' => array ( 'checked' => 1 , 'position' => 90 , 'label' => " Status " ),
2020-10-13 15:09:25 +02:00
);
2021-03-29 17:22:19 +02:00
2022-08-29 11:35:12 +02:00
if ( isModEnabled ( 'banque' )) {
2021-03-29 17:41:19 +02:00
$arrayfields [ 't.fk_account' ] = array ( 'checked' => 1 , 'position' => 60 , 'label' => " DefaultBankAccount " );
}
2021-03-29 17:22:19 +02:00
2020-10-13 15:09:25 +02:00
$arrayfields = dol_sort_array ( $arrayfields , 'position' );
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager -> initHooks ( array ( 'salestaxeslist' ));
$object = new Tva ( $db );
2021-04-03 02:11:16 +02:00
// Security check
$socid = GETPOST ( 'socid' , 'int' );
if ( $user -> socid ) {
$socid = $user -> socid ;
}
$result = restrictedArea ( $user , 'tax' , '' , 'tva' , 'charges' );
2020-10-13 15:09:25 +02:00
/*
* Actions
*/
$parameters = array ( 'socid' => $socid );
$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-10-13 15:09:25 +02:00
if ( empty ( $reshook )) {
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
2021-02-23 21:09:01 +01:00
if ( GETPOST ( 'button_removefilter_x' , 'alpha' ) || GETPOST ( 'button_removefilter.x' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) { // Both test are required to be compatible with all browsers
2020-10-13 15:09:25 +02:00
$search_ref = '' ;
$search_label = '' ;
$search_dateend_start = '' ;
$search_dateend_end = '' ;
$search_datepayment_start = '' ;
$search_datepayment_end = '' ;
$search_type = '' ;
$search_account = '' ;
$search_amount = '' ;
2021-01-19 12:02:05 +01:00
$search_status = '' ;
2014-05-01 07:44:10 +02:00
}
2014-11-02 14:19:28 +01:00
}
2016-08-11 18:18:03 +02:00
2008-10-13 16:22:10 +02:00
/*
* View
*/
2002-09-26 16:26:32 +02:00
2014-05-01 07:44:10 +02:00
$form = new Form ( $db );
2019-11-12 00:15:34 +01:00
$formother = new FormOther ( $db );
2021-08-06 12:18:51 +02:00
$formfile = new FormFile ( $db );
2008-04-03 21:35:46 +02:00
$tva_static = new Tva ( $db );
2017-05-31 05:27:39 +02:00
$bankstatic = new Account ( $db );
2020-10-13 15:09:25 +02:00
$accountingjournal = new AccountingJournal ( $db );
$bankline = new AccountLine ( $db );
2021-01-19 12:02:05 +01:00
llxHeader ( '' , $langs -> trans ( " VATDeclarations " ));
2020-10-13 15:09:25 +02:00
2021-03-25 11:59:22 +01:00
$sql = 'SELECT t.rowid, t.amount, t.label, t.datev, t.datep, t.paye, t.fk_typepayment as type, t.fk_account,' ;
2021-03-29 16:22:22 +02:00
$sql .= ' ba.label as blabel, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.iban_prefix as iban, ba.bic, ba.currency_code, ba.clos,' ;
2021-03-25 11:59:22 +01:00
$sql .= ' t.num_payment, pst.code as payment_code,' ;
2021-01-19 12:02:05 +01:00
$sql .= ' SUM(ptva.amount) as alreadypayed' ;
2020-10-13 15:09:25 +02:00
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'tva as t' ;
2021-03-25 11:59:22 +01:00
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_paiement as pst ON (t.fk_typepayment = pst.id)' ;
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON (t.fk_account = ba.rowid)' ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " payment_vat as ptva ON (ptva.fk_tva = t.rowid) " ;
2020-10-13 15:09:25 +02:00
$sql .= ' WHERE t.entity IN (' . getEntity ( $object -> element ) . ')' ;
2021-02-23 21:09:01 +01:00
if ( ! empty ( $search_ref )) {
$sql .= natural_search ( 't.rowid' , $search_ref );
}
if ( ! empty ( $search_label )) {
$sql .= natural_search ( 't.label' , $search_label );
}
if ( ! empty ( $search_dateend_start )) {
2021-08-28 00:55:51 +02:00
$sql .= " AND t.datev >= ' " . $db -> idate ( $search_dateend_start ) . " ' " ;
2021-02-23 21:09:01 +01:00
}
if ( ! empty ( $search_dateend_end )) {
2021-08-28 00:55:51 +02:00
$sql .= " AND t.datev <= ' " . $db -> idate ( $search_dateend_end ) . " ' " ;
2021-02-23 21:09:01 +01:00
}
if ( ! empty ( $search_datepayment_start )) {
2021-08-28 00:55:51 +02:00
$sql .= " AND t.datep >= ' " . $db -> idate ( $search_datepayment_start ) . " ' " ;
2021-02-23 21:09:01 +01:00
}
if ( ! empty ( $search_datepayment_end )) {
2021-08-28 00:55:51 +02:00
$sql .= " AND t.datep <= ' " . $db -> idate ( $search_datepayment_end ) . " ' " ;
2021-02-23 21:09:01 +01:00
}
if ( ! empty ( $search_type ) && $search_type > 0 ) {
2021-06-09 15:36:47 +02:00
$sql .= ' AND t.fk_typepayment = ' . (( int ) $search_type );
2021-02-23 21:09:01 +01:00
}
if ( ! empty ( $search_account ) && $search_account > 0 ) {
2021-06-09 15:36:47 +02:00
$sql .= ' AND t.fk_account = ' . (( int ) $search_account );
2021-02-23 21:09:01 +01:00
}
if ( ! empty ( $search_amount )) {
$sql .= natural_search ( 't.amount' , price2num ( trim ( $search_amount )), 1 );
}
if ( $search_status != '' && $search_status >= 0 ) {
2021-06-09 15:36:47 +02:00
$sql .= " AND t.paye = " . (( int ) $search_status );
2021-02-23 21:09:01 +01:00
}
2002-09-26 16:26:32 +02:00
2021-03-29 16:22:22 +02:00
$sql .= " GROUP BY t.rowid, t.amount, t.label, t.datev, t.datep, t.paye, t.fk_typepayment, t.fk_account, ba.label, ba.ref, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.clos, t.num_payment, pst.code " ;
2019-11-12 00:15:34 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
2020-10-13 15:09:25 +02:00
$nbtotalofrecords = '' ;
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST )) {
2022-05-10 11:38:56 +02:00
$resql = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $resql );
2020-10-13 15:09:25 +02:00
// if total resultset is smaller then paging size (filtering), goto and load page 0
if (( $page * $limit ) > $nbtotalofrecords ) {
$page = 0 ;
$offset = 0 ;
}
2015-12-28 00:20:48 +01:00
}
2020-10-13 15:09:25 +02:00
2019-11-12 00:15:34 +01:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
2003-06-20 16:30:08 +02:00
2022-05-10 11:38:56 +02:00
$resql = $db -> query ( $sql );
if ( ! $resql ) {
2020-10-13 15:09:25 +02:00
dol_print_error ( $db );
llxFooter ();
$db -> close ();
exit ;
}
2009-03-03 00:43:17 +01:00
2022-05-10 11:38:56 +02:00
$num = $db -> num_rows ( $resql );
2020-10-13 15:09:25 +02:00
$param = '' ;
2021-02-23 21:09:01 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ 'PHP_SELF' ]) {
$param .= '&contextpage=' . $contextpage ;
}
if ( $limit > 0 && $limit != $conf -> liste_limit ) {
$param .= '&limit=' . $limit ;
}
if ( $optioncss != '' ) {
$param .= '&optioncss=' . urlencode ( $optioncss );
}
if ( ! empty ( $search_ref )) {
$param .= '&search_ref="' . $search_ref . '"' ;
}
if ( ! empty ( $search_label )) {
$param .= '&search_label="' . $search_label . '"' ;
}
if ( ! empty ( $search_dateend_start )) {
$param .= '&search_dateend_startyear=' . GETPOST ( 'search_dateend_startyear' , 'int' );
}
if ( ! empty ( $search_dateend_start )) {
$param .= '&search_dateend_startmonth=' . GETPOST ( 'search_dateend_startmonth' , 'int' );
}
if ( ! empty ( $search_dateend_start )) {
$param .= '&search_dateend_startday=' . GETPOST ( 'search_dateend_startday' , 'int' );
}
if ( ! empty ( $search_dateend_end )) {
$param .= '&search_dateend_endyear=' . GETPOST ( 'search_dateend_endyear' , 'int' );
}
if ( ! empty ( $search_dateend_end )) {
$param .= '&search_dateend_endmonth=' . GETPOST ( 'search_dateend_endmonth' , 'int' );
}
if ( ! empty ( $search_dateend_end )) {
$param .= '&search_dateend_endday=' . GETPOST ( 'search_dateend_endday' , 'int' );
}
if ( ! empty ( $search_datepayment_start )) {
$param .= '&search_datepayment_startyear=' . GETPOST ( 'search_datepayment_startyear' , 'int' );
}
if ( ! empty ( $search_datepayment_start )) {
$param .= '&search_datepayment_startmonth=' . GETPOST ( 'search_datepayment_startmonth' , 'int' );
}
if ( ! empty ( $search_datepayment_start )) {
$param .= '&search_datepayment_startday=' . GETPOST ( 'search_datepayment_startday' , 'int' );
}
if ( ! empty ( $search_datepayment_end )) {
$param .= '&search_datepayment_endyear=' . GETPOST ( 'search_datepayment_endyear' , 'int' );
}
if ( ! empty ( $search_datepayment_end )) {
$param .= '&search_datepayment_endmonth=' . GETPOST ( 'search_datepayment_endmonth' , 'int' );
}
if ( ! empty ( $search_datepayment_end )) {
$param .= '&search_datepayment_endday=' . GETPOST ( 'search_datepayment_endday' , 'int' );
}
if ( ! empty ( $search_type ) && $search_type > 0 ) {
$param .= '&search_type=' . $search_type ;
}
if ( ! empty ( $search_account ) && $search_account > 0 ) {
$param .= '&search_account=' . $search_account ;
}
if ( ! empty ( $search_amount )) {
$param .= '&search_amount="' . $search_amount . '"' ;
}
if ( $search_status != '' && $search_status != '-1' ) {
$param .= '&search_status=' . urlencode ( $search_status );
}
2020-10-13 15:09:25 +02:00
print '<form method="POST" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2021-02-23 21:09:01 +01:00
if ( $optioncss != '' ) {
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
}
2020-10-13 15:09:25 +02:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<input type="hidden" name="formfilteraction" id="formfilteraction" 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 . '">' ;
$url = DOL_URL_ROOT . '/compta/tva/card.php?action=create' ;
2021-02-23 21:09:01 +01:00
if ( ! empty ( $socid )) {
$url .= '&socid=' . $socid ;
}
2020-10-13 15:09:25 +02:00
$newcardbutton = dolGetButtonTitle ( $langs -> trans ( 'NewVATPayment' , ( $ltt + 1 )), '' , 'fa fa-plus-circle' , $url , '' , $user -> rights -> tax -> charges -> creer );
2021-01-19 12:02:05 +01:00
print_barre_liste ( $langs -> trans ( " VATDeclarations " ), $page , $_SERVER [ 'PHP_SELF' ], $param , $sortfield , $sortorder , '' , $num , $nbtotalofrecords , 'title_accountancy' , 0 , $newcardbutton , '' , $limit , 0 , 0 , 1 );
2020-10-13 15:09:25 +02:00
$varpage = empty ( $contextpage ) ? $_SERVER [ 'PHP_SELF' ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
2021-02-23 21:09:01 +01:00
if ( $massactionbutton ) {
$selectedfields .= $form -> showCheckAddButtons ( 'checkforselect' , 1 );
}
2020-10-13 15:09:25 +02:00
print '<div class="div-table-responsive">' ;
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : '' ) . '">' ;
print '<tr class="liste_titre_filter">' ;
// Filters: Lines (placeholder)
if ( ! empty ( $conf -> global -> MAIN_VIEW_LINE_NUMBER_IN_LIST )) {
print '<td class="liste_titre">' ;
print '</td>' ;
}
2017-06-09 09:25:15 +02:00
2020-10-13 15:09:25 +02:00
// Filter: Ref
if ( ! empty ( $arrayfields [ 't.rowid' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" size="4" name="search_ref" value="' . dol_escape_htmltag ( $search_ref ) . '">' ;
print '</td>' ;
}
2017-06-09 09:25:15 +02:00
2020-10-13 15:09:25 +02:00
// Filter: Label
if ( ! empty ( $arrayfields [ 't.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>' ;
}
2014-11-21 23:52:12 +01:00
2020-10-13 15:09:25 +02:00
// Filter: Date end period
if ( ! empty ( $arrayfields [ 't.datev' ][ 'checked' ])) {
2019-11-07 08:34:06 +01:00
print '<td class="liste_titre center">' ;
print '<div class="nowrap">' ;
2020-10-13 15:09:25 +02:00
print $form -> selectDate ( $search_dateend_start ? $search_dateend_start : - 1 , 'search_dateend_start' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( " From " ));
2019-11-07 08:34:06 +01:00
print '</div>' ;
print '<div class="nowrap">' ;
2020-10-13 15:09:25 +02:00
print $form -> selectDate ( $search_dateend_end ? $search_dateend_end : - 1 , 'search_dateend_end' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( " to " ));
2019-11-07 08:34:06 +01:00
print '</div>' ;
2020-10-13 15:09:25 +02:00
print '</td>' ;
}
// Filter: Date payment
2021-01-19 12:02:05 +01:00
/* if ( ! empty ( $arrayfields [ 't.datep' ][ 'checked' ])) {
2019-11-07 08:34:06 +01:00
print '<td class="liste_titre center">' ;
print '<div class="nowrap">' ;
2020-10-13 15:09:25 +02:00
print $form -> selectDate ( $search_datepayment_start ? $search_datepayment_start : - 1 , 'search_datepayment_start' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( " From " ));
2019-11-07 08:34:06 +01:00
print '</div>' ;
print '<div class="nowrap">' ;
2020-10-13 15:09:25 +02:00
print $form -> selectDate ( $search_datepayment_end ? $search_datepayment_end : - 1 , 'search_datepayment_end' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( " to " ));
2019-11-07 08:34:06 +01:00
print '</div>' ;
2020-10-13 15:09:25 +02:00
print '</td>' ;
2021-01-19 12:02:05 +01:00
} */
2020-10-13 15:09:25 +02:00
// Filter: Type
2021-03-29 16:22:22 +02:00
if ( ! empty ( $arrayfields [ 't.fk_typepayment' ][ 'checked' ])) {
2019-11-07 08:34:06 +01:00
print '<td class="liste_titre left">' ;
2020-10-13 15:09:25 +02:00
$form -> select_types_paiements ( $search_type , 'search_type' , '' , 0 , 1 , 1 , 16 );
print '</td>' ;
}
2021-03-29 16:22:22 +02:00
// Filter: Bank Account
2021-03-25 11:59:22 +01:00
if ( ! empty ( $arrayfields [ 't.fk_account' ][ 'checked' ])) {
print '<td class="liste_titre left">' ;
$form -> select_comptes ( $search_account , 'search_account' , 0 , '' , 1 );
print '</td>' ;
2021-03-29 16:22:22 +02:00
}
2021-03-25 11:59:22 +01:00
2020-10-13 15:09:25 +02:00
// Filter: Amount
if ( ! empty ( $arrayfields [ 't.amount' ][ 'checked' ])) {
print '<td class="liste_titre right">' ;
print '<input name="search_amount" class="flat" type="text" size="8" value="' . $search_amount . '">' ;
2014-05-01 07:44:10 +02:00
print '</td>' ;
2020-10-13 15:09:25 +02:00
}
2021-01-19 12:02:05 +01:00
// Status
if ( ! empty ( $arrayfields [ 't.status' ][ 'checked' ])) {
print '<td class="liste_titre maxwidthonsmartphone right">' ;
$liststatus = array ( '0' => $langs -> trans ( " Unpaid " ), '1' => $langs -> trans ( " Paid " ));
print $form -> selectarray ( 'search_status' , $liststatus , $search_status , 1 );
print '</td>' ;
}
2020-10-13 15:09:25 +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 ;
// Filter: Buttons
print '<td class="liste_titre maxwidthsearch">' ;
print $form -> showFilterAndCheckAddButtons ( 0 );
print '</td>' ;
print '</tr>' ;
print '<tr class="liste_titre">' ;
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 ( ! empty ( $arrayfields [ 't.rowid' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.rowid' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 't.rowid' , '' , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 't.label' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.label' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 't.label' , '' , $param , 'align="left"' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 't.datev' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.datev' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 't.datev' , '' , $param , 'align="center"' , $sortfield , $sortorder );
}
2021-03-29 16:22:22 +02:00
if ( ! empty ( $arrayfields [ 't.fk_typepayment' ][ 'checked' ])) {
2021-02-23 21:09:01 +01:00
print_liste_field_titre ( $arrayfields [ 't.fk_typepayment' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 't.fk_typepayment' , '' , $param , '' , $sortfield , $sortorder , 'left ' );
}
2021-03-25 11:59:22 +01:00
if ( ! empty ( $arrayfields [ 't.fk_account' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.fk_account' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 't.fk_account' , '' , $param , '' , $sortfield , $sortorder , 'left ' );
2021-03-29 16:22:22 +02:00
}
2021-02-23 21:09:01 +01:00
if ( ! empty ( $arrayfields [ 't.amount' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.amount' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 't.amount' , '' , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 't.status' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.status' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " t.paye " , " " , $param , 'class="right"' , $sortfield , $sortorder );
}
2020-10-13 15:09:25 +02:00
// Hook fields
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
print_liste_field_titre ( $selectedfields , $_SERVER [ 'PHP_SELF' ], '' , '' , '' , 'align="center"' , $sortfield , $sortorder , 'maxwidthsearch ' );
print '</tr>' ;
$i = 0 ;
$totalarray = array ();
while ( $i < min ( $num , $limit )) {
2022-05-10 11:38:56 +02:00
$obj = $db -> fetch_object ( $resql );
2020-10-13 15:09:25 +02:00
$tva_static -> id = $obj -> rowid ;
$tva_static -> ref = $obj -> rowid ;
2021-01-19 13:40:13 +01:00
$tva_static -> label = $obj -> label ;
2020-10-13 15:09:25 +02:00
print '<tr class="oddeven">' ;
// No
if ( ! empty ( $conf -> global -> MAIN_VIEW_LINE_NUMBER_IN_LIST )) {
print '<td>' . (( $offset * $limit ) + $i ) . '</td>' ;
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-10-13 15:09:25 +02:00
}
// Ref
if ( ! empty ( $arrayfields [ 't.rowid' ][ 'checked' ])) {
2021-08-06 12:18:51 +02:00
print '<td>' ;
print $tva_static -> getNomUrl ( 1 );
$filename = dol_sanitizeFileName ( $tva_static -> ref );
$filedir = $conf -> tax -> dir_output . '/vat/' . dol_sanitizeFileName ( $tva_static -> ref );
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?id=' . $tva_static -> id ;
print $formfile -> getDocumentsLink ( $tva_static -> element , $filename , $filedir , '' , 'valignmiddle paddingleft2imp' );
print '</td>' ;
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-10-13 15:09:25 +02:00
}
// Label
2020-10-31 14:32:18 +01:00
if ( ! empty ( $arrayfields [ 't.label' ][ 'checked' ])) {
2020-10-13 15:09:25 +02:00
print '<td>' . dol_trunc ( $obj -> label , 40 ) . '</td>' ;
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-10-13 15:09:25 +02:00
}
2020-10-13 15:28:23 +02:00
2020-10-13 15:09:25 +02:00
// Date end period
2020-10-31 14:32:18 +01:00
if ( ! empty ( $arrayfields [ 't.datev' ][ 'checked' ])) {
2020-10-13 15:09:25 +02:00
print '<td class="center">' . dol_print_date ( $db -> jdate ( $obj -> datev ), 'day' ) . '</td>' ;
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-10-13 15:09:25 +02:00
}
2020-10-13 15:28:23 +02:00
2020-10-13 15:09:25 +02:00
// Date payment
2021-01-19 12:02:05 +01:00
/* if ( ! empty ( $arrayfields [ 't.datep' ][ 'checked' ])) {
2020-10-13 15:09:25 +02:00
print '<td class="center">' . dol_print_date ( $db -> jdate ( $obj -> datep ), 'day' ) . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2021-01-19 12:02:05 +01:00
} */
2020-10-13 15:28:23 +02:00
2020-10-13 15:09:25 +02:00
// Type
2021-03-29 16:22:22 +02:00
if ( ! empty ( $arrayfields [ 't.fk_typepayment' ][ 'checked' ])) {
print '<td>' ;
2021-03-29 16:25:36 +02:00
if ( ! empty ( $obj -> payment_code )) print $langs -> trans ( " PaymentTypeShort " . $obj -> payment_code );
2021-03-29 16:22:22 +02:00
print '</td>' ;
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-03-29 16:22:22 +02:00
}
2020-10-13 15:09:25 +02:00
2016-08-11 18:41:31 +02:00
// Account
2021-03-29 16:22:22 +02:00
if ( ! empty ( $arrayfields [ 't.fk_account' ][ 'checked' ])) {
2020-10-13 15:09:25 +02:00
print '<td>' ;
2021-03-25 11:59:22 +01:00
if ( $obj -> fk_account > 0 ) {
$bankstatic -> id = $obj -> fk_account ;
2020-10-13 15:09:25 +02:00
$bankstatic -> ref = $obj -> bref ;
$bankstatic -> number = $obj -> bnumber ;
2021-03-25 11:59:22 +01:00
$bankstatic -> iban = $obj -> iban ;
$bankstatic -> bic = $obj -> bic ;
$bankstatic -> currency_code = $langs -> trans ( " Currency " . $obj -> currency_code );
2020-10-13 15:09:25 +02:00
$bankstatic -> account_number = $obj -> account_number ;
2021-03-29 16:22:22 +02:00
$bankstatic -> clos = $obj -> clos ;
2020-10-13 15:28:23 +02:00
2021-03-26 16:14:00 +01:00
//$accountingjournal->fetch($obj->fk_accountancy_journal);
//$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
2020-10-13 15:28:23 +02:00
2020-10-13 15:09:25 +02:00
$bankstatic -> label = $obj -> blabel ;
print $bankstatic -> getNomUrl ( 1 );
2014-05-01 07:44:10 +02:00
}
2020-10-13 15:09:25 +02:00
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2021-03-29 16:22:22 +02:00
}
2014-11-21 23:52:12 +01:00
2020-10-13 15:09:25 +02:00
// Amount
2021-01-19 12:02:05 +01:00
if ( ! empty ( $arrayfields [ 't.amount' ][ 'checked' ])) {
$total = $total + $obj -> amount ;
2021-04-03 02:11:16 +02:00
print '<td class="nowrap right"><span class="amount">' . price ( $obj -> amount ) . '</span></td>' ;
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-01-19 12:02:05 +01:00
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 'amount' ;
$totalarray [ 'val' ][ 'amount' ] += $obj -> amount ;
}
if ( ! empty ( $arrayfields [ 't.status' ][ 'checked' ])) {
print '<td class="nowrap right">' . $tva_static -> LibStatut ( $obj -> paye , 5 , $obj -> alreadypayed ) . '</td>' ;
2021-02-23 21:09:01 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
if ( ! empty ( $arrayfields [ 't.amount' ][ 'checked' ])) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = '' ;
}
2021-01-19 12:02:05 +01:00
}
2020-10-13 15:09:25 +02:00
// Buttons
print '<td></td>' ;
2009-02-04 23:43:51 +01:00
2020-10-13 15:09:25 +02:00
print '</tr>' ;
2017-06-09 09:25:15 +02:00
2020-10-13 15:09:25 +02:00
$i ++ ;
}
2009-02-04 23:43:51 +01:00
2020-10-13 15:09:25 +02:00
// Add a buttons placeholder for the total line
$totalarray [ 'nbfield' ] ++ ;
2017-06-09 09:25:15 +02:00
2020-10-13 15:09:25 +02:00
// Show total line
include DOL_DOCUMENT_ROOT . '/core/tpl/list_print_total.tpl.php' ;
2014-11-21 23:52:12 +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 " ;
2020-10-13 15:09:25 +02:00
2022-05-10 11:38:56 +02:00
print '</form>' . " \n " ;
2009-02-04 23:43:51 +01:00
2019-02-14 16:38:03 +01:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2014-11-21 23:52:12 +01:00
$db -> close ();