2006-12-20 21:48:29 +01:00
< ? php
2012-08-18 08:30:29 +02:00
/* Copyright ( C ) 2006 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2016-11-27 13:49:46 +01:00
* Copyright ( C ) 2007 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2009 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2015-07-15 20:30:33 +02:00
* Copyright ( C ) 2014 Alexandre Spangaro < aspangaro . dolibarr @ gmail . com >
2016-04-03 11:56:31 +02:00
* Copyright ( C ) 2016 Juanjo Menent < jmenent @ 2 byte . es >
2006-12-20 21:48:29 +01:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2006-12-20 21:48:29 +01: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-03 02:45:22 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2006-12-20 21:48:29 +01:00
*/
2009-07-15 17:04:58 +02:00
2006-12-20 21:48:29 +01:00
/**
2014-09-18 20:33:37 +02:00
* \file htdocs / compta / paiement / cheque / list . php
2009-07-15 17:04:58 +02:00
* \ingroup compta
2014-09-16 07:21:29 +02:00
* \brief Page list of cheque deposits
2009-07-15 17:04:58 +02:00
*/
2006-12-20 21:48:29 +01:00
2018-07-26 11:57:25 +02:00
require '../../../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/compta/paiement/cheque/class/remisecheque.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
2014-09-16 07:21:29 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
2013-06-05 16:24:32 +02:00
2018-05-27 09:27:09 +02:00
// Load translation files required by the page
$langs -> loadLangs ( array ( 'banks' , 'categories' , 'bills' ));
2006-12-20 21:48:29 +01:00
2008-02-25 17:30:43 +01:00
// Security check
2008-02-25 21:03:21 +01:00
if ( $user -> societe_id ) $socid = $user -> societe_id ;
2008-03-01 02:26:41 +01:00
$result = restrictedArea ( $user , 'banque' , '' , '' );
2006-12-20 21:48:29 +01:00
2016-02-11 20:24:15 +01:00
$search_ref = GETPOST ( 'search_ref' , 'alpha' );
2014-11-01 14:28:28 +01:00
$search_account = GETPOST ( 'search_account' , 'int' );
$search_amount = GETPOST ( 'search_amount' , 'alpha' );
2016-02-11 20:24:15 +01:00
2018-04-21 12:16:12 +02:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2010-11-20 14:08:44 +01: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
2015-12-16 19:38:40 +01:00
$offset = $limit * $page ;
2010-11-20 14:08:44 +01:00
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2006-12-20 21:48:29 +01:00
if ( ! $sortorder ) $sortorder = " DESC " ;
2014-09-16 07:21:29 +02:00
if ( ! $sortfield ) $sortfield = " dp " ;
2007-01-05 21:30:34 +01:00
2014-09-16 07:21:29 +02:00
$year = GETPOST ( " year " );
$month = GETPOST ( " month " );
$form = new Form ( $db );
$formother = new FormOther ( $db );
2007-01-05 21:30:34 +01:00
$checkdepositstatic = new RemiseCheque ( $db );
$accountstatic = new Account ( $db );
2016-11-27 13:49:46 +01:00
/*
* Actions
*/
2014-11-01 14:28:28 +01:00
// If click on purge search criteria ?
2017-07-13 00:35:10 +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
2014-11-01 14:28:28 +01:00
{
$search_ref = '' ;
$search_amount = '' ;
$search_account = '' ;
$year = '' ;
$month = '' ;
}
2016-11-27 13:49:46 +01:00
2007-01-05 21:30:34 +01:00
/*
2009-07-15 17:04:58 +02:00
* View
2007-01-05 21:30:34 +01:00
*/
2007-02-04 16:16:03 +01:00
llxHeader ( '' , $langs -> trans ( " ChequesReceipts " ));
2007-01-05 21:30:34 +01:00
2016-04-03 11:56:31 +02:00
$sql = " SELECT bc.rowid, bc.ref as ref, bc.date_bordereau as dp, " ;
2007-11-11 20:11:22 +01:00
$sql .= " bc.nbcheque, bc.amount, bc.statut, " ;
2006-12-20 21:48:29 +01:00
$sql .= " ba.rowid as bid, ba.label " ;
2008-02-12 04:36:05 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " bordereau_cheque as bc, " ;
$sql .= " " . MAIN_DB_PREFIX . " bank_account as ba " ;
2006-12-21 15:36:07 +01:00
$sql .= " WHERE bc.fk_bank_account = ba.rowid " ;
2009-05-07 16:33:52 +02:00
$sql .= " AND bc.entity = " . $conf -> entity ;
2014-09-16 07:21:29 +02:00
// Search criteria
2016-12-11 16:11:42 +01:00
if ( $search_ref ) $sql .= natural_search ( " bc.ref " , $search_ref );
2014-11-01 14:28:28 +01:00
if ( $search_account > 0 ) $sql .= " AND bc.fk_bank_account= " . $search_account ;
2016-12-11 16:11:42 +01:00
if ( $search_amount ) $sql .= natural_search ( " bc.amount " , price2num ( $search_amount ));
2014-09-16 07:21:29 +02:00
if ( $month > 0 )
{
if ( $year > 0 && empty ( $day ))
$sql .= " AND bc.date_bordereau BETWEEN ' " . $db -> idate ( dol_get_first_day ( $year , $month , false )) . " ' AND ' " . $db -> idate ( dol_get_last_day ( $year , $month , false )) . " ' " ;
else if ( $year > 0 && ! empty ( $day ))
$sql .= " AND bc.date_bordereau BETWEEN ' " . $db -> idate ( dol_mktime ( 0 , 0 , 0 , $month , $day , $year )) . " ' AND ' " . $db -> idate ( dol_mktime ( 23 , 59 , 59 , $month , $day , $year )) . " ' " ;
else
$sql .= " AND date_format(bc.date_bordereau, '%m') = ' " . $month . " ' " ;
}
else if ( $year > 0 )
2006-12-20 21:48:29 +01:00
{
2014-09-16 07:21:29 +02:00
$sql .= " AND bc.date_bordereau BETWEEN ' " . $db -> idate ( dol_get_first_day ( $year , 1 , false )) . " ' AND ' " . $db -> idate ( dol_get_last_day ( $year , 12 , false )) . " ' " ;
2006-12-20 21:48:29 +01:00
}
2016-02-11 20:24:15 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
2014-09-16 07:21:29 +02:00
2017-01-15 20:49:20 +01:00
$nbtotalofrecords = '' ;
2016-01-19 12:15:37 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST ))
{
$result = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $result );
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 ;
}
2016-01-19 12:15:37 +01:00
}
2012-03-18 19:23:01 +01:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
2006-12-20 21:48:29 +01:00
//print "$sql";
$resql = $db -> query ( $sql );
if ( $resql )
{
2009-07-15 17:04:58 +02:00
$num = $db -> num_rows ( $resql );
$i = 0 ;
2016-02-11 20:24:15 +01:00
$param = '' ;
2016-06-07 14:06:00 +02:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) $param .= '&contextpage=' . $contextpage ;
2016-02-11 20:24:15 +01:00
if ( $limit > 0 && $limit != $conf -> liste_limit ) $param .= '&limit=' . $limit ;
2018-03-30 16:54:38 +02:00
$newcardbutton = '' ;
if ( $user -> rights -> banque -> cheque )
{
2018-06-13 22:57:41 +02:00
$newcardbutton = '<a class="butActionNew" href="' . DOL_URL_ROOT . '/compta/paiement/cheque/card.php?action=new"><span class="valignmiddle">' . $langs -> trans ( 'NewCheckDeposit' ) . '</span>' ;
2018-04-18 03:26:15 +02:00
$newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>' ;
$newcardbutton .= '</a>' ;
2018-03-30 16:54:38 +02:00
}
2016-02-11 20:24:15 +01:00
print '<form method="POST" 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="view" value="' . dol_escape_htmltag ( $view ) . '">' ;
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 . '">' ;
2017-06-11 16:18:21 +02:00
2018-03-30 16:54:38 +02:00
print_barre_liste ( $langs -> trans ( " MenuChequeDeposits " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , '' , $num , $nbtotalofrecords , 'title_bank.png' , 0 , $newcardbutton , '' , $limit );
2017-06-11 16:18:21 +02:00
2016-11-27 13:49:46 +01:00
$moreforfilter = '' ;
2017-06-11 16:18:21 +02:00
2016-11-27 13:49:46 +01:00
print '<div class="div-table-responsive">' ;
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2009-07-15 17:04:58 +02:00
// Lignes des champs de filtre
print '<tr class="liste_titre">' ;
2014-09-16 07:21:29 +02:00
print '<td class="liste_titre" align="left">' ;
2014-11-02 14:19:28 +01:00
print '<input class="flat" type="text" size="4" name="search_ref" value="' . $search_ref . '">' ;
2014-09-16 07:21:29 +02:00
print '</td>' ;
print '<td class="liste_titre" align="center">' ;
if ( ! empty ( $conf -> global -> MAIN_LIST_FILTER_ON_DAY )) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="' . $day . '">' ;
print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="' . $month . '">' ;
$formother -> select_year ( $year ? $year :- 1 , 'year' , 1 , 20 , 5 );
print '</td>' ;
2016-12-11 16:11:42 +01:00
print '<td class="liste_titre">' ;
2014-11-01 14:28:28 +01:00
$form -> select_comptes ( $search_account , 'search_account' , 0 , '' , 1 );
2014-09-16 07:21:29 +02:00
print '</td>' ;
2009-07-15 17:04:58 +02:00
print '<td class="liste_titre"> </td>' ;
print '<td class="liste_titre" align="right">' ;
2016-12-03 15:22:26 +01:00
print '<input class="flat maxwidth50" type="text" name="search_amount" value="' . $search_amount . '">' ;
2009-07-15 17:04:58 +02:00
print '</td>' ;
2016-12-11 16:11:42 +01:00
print '<td class="liste_titre"></td>' ;
2016-02-07 15:50:48 +01:00
print '<td class="liste_titre" align="right">' ;
2017-05-14 21:06:33 +02:00
$searchpicto = $form -> showFilterAndCheckAddButtons ( 0 );
print $searchpicto ;
2016-02-07 15:50:48 +01:00
print '</td>' ;
print " </tr> \n " ;
2009-07-15 17:04:58 +02:00
2017-06-11 16:18:21 +02:00
print '<tr class="liste_titre">' ;
2017-08-02 13:31:53 +02:00
print_liste_field_titre ( " Ref " , $_SERVER [ " PHP_SELF " ], " bc.ref " , " " , $param , " " , $sortfield , $sortorder );
print_liste_field_titre ( " DateCreation " , $_SERVER [ " PHP_SELF " ], " dp " , " " , $param , 'align="center"' , $sortfield , $sortorder );
print_liste_field_titre ( " Account " , $_SERVER [ " PHP_SELF " ], " ba.label " , " " , $param , " " , $sortfield , $sortorder );
print_liste_field_titre ( " NbOfCheques " , $_SERVER [ " PHP_SELF " ], " bc.nbcheque " , " " , $param , 'align="right"' , $sortfield , $sortorder );
print_liste_field_titre ( " Amount " , $_SERVER [ " PHP_SELF " ], " bc.amount " , " " , $param , 'align="right"' , $sortfield , $sortorder );
print_liste_field_titre ( " Status " , $_SERVER [ " PHP_SELF " ], " bc.statut " , " " , $param , 'align="right"' , $sortfield , $sortorder );
2017-06-11 16:18:21 +02:00
print_liste_field_titre ( '' );
print " </tr> \n " ;
2015-10-09 12:30:16 +02:00
if ( $num > 0 )
{
while ( $i < min ( $num , $limit ))
{
$objp = $db -> fetch_object ( $resql );
2017-06-11 16:18:21 +02:00
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2017-06-11 16:18:21 +02:00
2015-10-09 12:30:16 +02:00
// Num ref cheque
2016-12-03 15:22:26 +01:00
print '<td>' ;
2015-10-09 12:30:16 +02:00
$checkdepositstatic -> id = $objp -> rowid ;
$checkdepositstatic -> ref = ( $objp -> ref ? $objp -> ref : $objp -> rowid );
$checkdepositstatic -> statut = $objp -> statut ;
print $checkdepositstatic -> getNomUrl ( 1 );
print '</td>' ;
2017-06-11 16:18:21 +02:00
2015-10-09 12:30:16 +02:00
// Date
print '<td align="center">' . dol_print_date ( $db -> jdate ( $objp -> dp ), 'day' ) . '</td>' ; // TODO Use date hour
2017-06-11 16:18:21 +02:00
2015-10-09 12:30:16 +02:00
// Bank
print '<td>' ;
2017-10-03 16:00:52 +02:00
if ( $objp -> bid ) print '<a href="' . DOL_URL_ROOT . '/compta/bank/bankentries_list.php?account=' . $objp -> bid . '">' . img_object ( $langs -> trans ( " ShowAccount " ), 'account' ) . ' ' . $objp -> label . '</a>' ;
2015-10-09 12:30:16 +02:00
else print ' ' ;
print '</td>' ;
2017-06-11 16:18:21 +02:00
2015-10-09 12:30:16 +02:00
// Number of cheques
print '<td align="right">' . $objp -> nbcheque . '</td>' ;
2017-06-11 16:18:21 +02:00
2015-10-09 12:30:16 +02:00
// Amount
print '<td align="right">' . price ( $objp -> amount ) . '</td>' ;
2017-06-11 16:18:21 +02:00
2015-10-09 12:30:16 +02:00
// Statut
print '<td align="right">' ;
print $checkdepositstatic -> LibStatut ( $objp -> statut , 5 );
2016-02-11 20:24:15 +01:00
print '</td>' ;
2017-06-11 16:18:21 +02:00
2016-02-11 20:24:15 +01:00
print '<td></td>' ;
2017-06-11 16:18:21 +02:00
2016-02-11 20:24:15 +01:00
print " </tr> \n " ;
2015-10-09 12:30:16 +02:00
$i ++ ;
}
}
else
{
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2016-06-07 15:58:02 +02:00
print '<td colspan="7" class="opacitymedium">' . $langs -> trans ( " None " ) . " </td> " ;
2015-10-09 12:30:16 +02:00
print '</tr>' ;
}
2009-07-15 17:04:58 +02:00
print " </table> " ;
2016-11-27 13:49:46 +01:00
print " </div> " ;
2009-07-15 17:04:58 +02:00
print " </form> \n " ;
2006-12-20 21:48:29 +01:00
}
else
{
2009-07-15 17:04:58 +02:00
dol_print_error ( $db );
2006-12-20 21:48:29 +01:00
}
2018-08-08 12:29:36 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2015-10-09 12:30:16 +02:00
$db -> close ();