2012-08-22 23:27:53 +02:00
< ? php
2009-04-27 22:37:50 +02:00
/* Copyright ( C ) 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2016-12-11 16:11:42 +01:00
* Copyright ( C ) 2005 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2009 Regis Houssin < regis . houssin @ inodbox . com >
2018-02-06 18:49:29 +01:00
* Copyright ( C ) 2010 - 2018 Juanjo Menent < jmenent @ 2 byte . es >
2005-01-07 16:12:08 +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
2005-01-07 16:12:08 +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-01 00:21:57 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2005-01-07 16:12:08 +01:00
*/
2005-08-15 18:51:36 +02:00
/**
2014-09-18 20:33:37 +02:00
* \file htdocs / compta / prelevement / list . php
2010-09-05 15:24:59 +02:00
* \ingroup prelevement
* \brief Page liste des prelevements
*/
2017-01-22 13:19:07 +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/prelevement/class/bonprelevement.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/compta/prelevement/class/ligneprelevement.class.php' ;
2013-06-05 16:24:32 +02:00
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
2018-05-27 09:27:09 +02:00
// Load translation files required by the page
$langs -> loadLangs ( array ( 'banks' , 'withdrawals' , 'companies' , 'categories' ));
2005-09-10 14:13:47 +02:00
2009-04-27 22:37:50 +02:00
// Security check
2012-02-27 22:26:22 +01:00
$socid = GETPOST ( 'socid' , 'int' );
2009-04-27 22:37:50 +02:00
if ( $user -> societe_id ) $socid = $user -> societe_id ;
$result = restrictedArea ( $user , 'prelevement' , '' , '' , 'bons' );
2005-01-07 16:12:08 +01:00
2017-01-22 13:19:07 +01:00
2018-04-21 12:16:12 +02:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2017-01-22 13:19:07 +01:00
$sortfield = GETPOST ( 'sortfield' , 'alpha' );
$sortorder = GETPOST ( 'sortorder' , 'alpha' );
2012-02-29 18:56:54 +01:00
$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
2017-01-22 13:19:07 +01:00
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
if ( ! $sortorder ) $sortorder = " DESC " ;
if ( ! $sortfield ) $sortfield = " p.datec " ;
2014-11-02 21:44:03 +01:00
$search_line = GETPOST ( 'search_line' , 'alpha' );
2012-02-29 18:56:54 +01:00
$search_bon = GETPOST ( 'search_bon' , 'alpha' );
$search_code = GETPOST ( 'search_code' , 'alpha' );
2014-11-02 21:44:03 +01:00
$search_company = GETPOST ( 'search_company' , 'alpha' );
2012-02-29 18:56:54 +01:00
$statut = GETPOST ( 'statut' , 'int' );
2011-05-06 16:20:20 +02:00
2011-01-05 10:57:55 +01:00
$bon = new BonPrelevement ( $db , " " );
$ligne = new LignePrelevement ( $db , $user );
2010-09-05 15:24:59 +02:00
2017-01-22 13:19:07 +01:00
/*
* Actions
*/
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-02 21:44:03 +01:00
{
$search_line = " " ;
$search_bon = " " ;
$search_code = " " ;
$search_company = " " ;
$statut = " " ;
}
2005-09-10 14:13:47 +02:00
2017-01-22 13:19:07 +01:00
2005-01-07 16:12:08 +01:00
/*
2010-09-05 15:24:59 +02:00
* View
2005-01-07 16:12:08 +01:00
*/
2017-01-22 13:19:07 +01:00
$form = new Form ( $db );
2005-09-10 16:41:53 +02:00
llxHeader ( '' , $langs -> trans ( " WithdrawalsLines " ));
2005-09-10 14:13:47 +02:00
2010-09-05 15:24:59 +02:00
$sql = " SELECT p.rowid, p.ref, p.statut, p.datec " ;
2018-12-02 14:31:45 +01:00
$sql .= " ,f.rowid as facid, f.ref, f.total_ttc " ;
2014-10-04 17:20:17 +02:00
$sql .= " , s.rowid as socid, s.nom as name, s.code_client " ;
2010-09-05 15:24:59 +02:00
$sql .= " , pl.amount, pl.statut as statut_ligne, pl.rowid as rowid_ligne " ;
2009-04-27 22:37:50 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " prelevement_bons as p " ;
$sql .= " , " . MAIN_DB_PREFIX . " prelevement_lignes as pl " ;
2010-09-05 15:24:59 +02:00
$sql .= " , " . MAIN_DB_PREFIX . " prelevement_facture as pf " ;
$sql .= " , " . MAIN_DB_PREFIX . " facture as f " ;
2009-04-27 22:37:50 +02:00
$sql .= " , " . MAIN_DB_PREFIX . " societe as s " ;
$sql .= " WHERE pl.fk_prelevement_bons = p.rowid " ;
2010-09-05 15:24:59 +02:00
$sql .= " AND pf.fk_prelevement_lignes = pl.rowid " ;
$sql .= " AND pf.fk_facture = f.rowid " ;
$sql .= " AND f.fk_soc = s.rowid " ;
$sql .= " AND f.entity = " . $conf -> entity ;
if ( $socid ) $sql .= " AND s.rowid = " . $socid ;
2017-01-22 13:19:07 +01:00
if ( $search_line ) $sql .= " AND pl.rowid = ' " . $db -> escape ( $search_line ) . " ' " ;
if ( $search_bon ) $sql .= natural_search ( " p.ref " , $search_bon );
if ( $search_code ) $sql .= natural_search ( " s.code_client " , $search_code );
2018-02-06 18:49:29 +01:00
if ( $search_company ) $sql .= natural_search ( " s.nom " , $search_company );
2017-01-22 13:19:07 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
// Count total nb of records
$nbtotalofrecords = '' ;
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST ))
2005-01-07 16:12:08 +01:00
{
2017-01-22 13:19:07 +01:00
$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 ;
}
2005-01-07 16:12:08 +01:00
}
2017-01-22 13:19:07 +01:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
2005-01-07 16:12:08 +01:00
$result = $db -> query ( $sql );
if ( $result )
{
2010-09-05 15:24:59 +02:00
$num = $db -> num_rows ( $result );
$i = 0 ;
2011-05-06 16:20:20 +02:00
$urladd = " &statut= " . $statut ;
$urladd .= " &search_bon= " . $search_bon ;
2018-02-06 18:49:29 +01:00
if ( $limit > 0 && $limit != $conf -> liste_limit ) $urladd .= '&limit=' . urlencode ( $limit );
2010-09-05 15:24:59 +02:00
print " \n <!-- debut table --> \n " ;
2016-02-07 15:50:48 +01:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="GET">' ;
2017-01-22 13:19:07 +01:00
2018-02-06 18:49:29 +01:00
print_barre_liste ( $langs -> trans ( " WithdrawalsLines " ), $page , $_SERVER [ " PHP_SELF " ], $urladd , $sortfield , $sortorder , '' , $num , $nbtotalofrecords , 'title_generic' , 0 , '' , '' , $limit );
$moreforfilter = '' ;
2017-06-07 16:44:04 +02:00
2017-01-22 13:19:07 +01:00
print '<div class="div-table-responsive">' ;
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2010-09-05 15:24:59 +02:00
print '<tr class="liste_titre">' ;
2014-11-02 21:44:03 +01:00
print '<td class="liste_titre"><input type="text" class="flat" name="search_line" value="' . dol_escape_htmltag ( $search_line ) . '" size="6"></td>' ;
2016-12-11 16:11:42 +01:00
print '<td class="liste_titre"><input type="text" class="flat" name="search_bon" value="' . dol_escape_htmltag ( $search_bon ) . '" size="6"></td>' ;
print '<td class="liste_titre"> </td>' ;
print '<td class="liste_titre"><input type="text" class="flat" name="search_company" value="' . dol_escape_htmltag ( $search_company ) . '" size="6"></td>' ;
print '<td class="liste_titre" align="center"><input type="text" class="flat" name="search_code" value="' . dol_escape_htmltag ( $search_code ) . '" size="6"></td>' ;
2010-09-05 15:24:59 +02:00
print '<td class="liste_titre"> </td>' ;
print '<td class="liste_titre"> </td>' ;
2014-11-02 21:44:03 +01:00
print '<td class="liste_titre" align="right">' ;
2017-06-07 16:44:04 +02:00
$searchpicto = $form -> showFilterButtons ();
2017-05-14 21:06:33 +02:00
print $searchpicto ;
2016-02-07 15:50:48 +01:00
print '</td>' ;
print '</tr>' ;
2010-09-05 15:24:59 +02:00
2017-06-07 16:44:04 +02:00
print '<tr class="liste_titre">' ;
2017-08-02 13:31:53 +02:00
print_liste_field_titre ( " Line " , $_SERVER [ " PHP_SELF " ]);
print_liste_field_titre ( " WithdrawalsReceipts " , $_SERVER [ " PHP_SELF " ], " p.ref " );
2018-12-02 14:31:45 +01:00
print_liste_field_titre ( " Bill " , $_SERVER [ " PHP_SELF " ], " f.ref " , '' , $urladd );
2017-08-02 13:31:53 +02:00
print_liste_field_titre ( " Company " , $_SERVER [ " PHP_SELF " ], " s.nom " );
print_liste_field_titre ( " CustomerCode " , $_SERVER [ " PHP_SELF " ], " s.code_client " , '' , '' , 'align="center"' );
print_liste_field_titre ( " Date " , $_SERVER [ " PHP_SELF " ], " p.datec " , " " , " " , 'align="center"' );
print_liste_field_titre ( " Amount " , $_SERVER [ " PHP_SELF " ], " pl.amount " , " " , " " , 'align="right"' );
2017-06-07 16:44:04 +02:00
print_liste_field_titre ( '' );
print " </tr> \n " ;
2017-01-22 13:19:07 +01:00
while ( $i < min ( $num , $limit ))
2005-01-07 16:12:08 +01:00
{
2017-06-07 16:44:04 +02:00
$obj = $db -> fetch_object ( $result );
2010-09-05 15:24:59 +02:00
2017-05-10 16:41:19 +02:00
print '<tr class="oddeven"><td>' ;
2010-09-05 15:24:59 +02:00
2011-01-05 10:57:55 +01:00
print $ligne -> LibStatut ( $obj -> statut_ligne , 2 );
2011-01-04 17:23:18 +01:00
print " " ;
2012-08-05 14:37:45 +02:00
2010-09-05 15:24:59 +02:00
print '<a href="' . DOL_URL_ROOT . '/compta/prelevement/ligne.php?id=' . $obj -> rowid_ligne . '">' ;
print substr ( '000000' . $obj -> rowid_ligne , - 6 );
print '</a></td>' ;
2011-01-04 17:23:18 +01:00
print '<td>' ;
2012-08-05 14:37:45 +02:00
2011-01-05 10:57:55 +01:00
print $bon -> LibStatut ( $obj -> statut , 2 );
2011-01-04 17:23:18 +01:00
print " " ;
2012-08-05 14:37:45 +02:00
2014-09-18 21:18:25 +02:00
print '<a href="card.php?id=' . $obj -> rowid . '">' . $obj -> ref . " </a></td> \n " ;
2010-09-05 15:24:59 +02:00
2017-03-20 20:58:43 +01:00
print '<td><a href="' . DOL_URL_ROOT . '/compta/facture/card.php?facid=' . $obj -> facid . '">' ;
2010-09-05 15:24:59 +02:00
print img_object ( $langs -> trans ( " ShowBill " ), " bill " );
2018-12-02 14:31:45 +01:00
print ' <a href="' . DOL_URL_ROOT . '/compta/facture/card.php?facid=' . $obj -> facid . '">' . $obj -> ref . " </a></td> \n " ;
2010-09-05 15:24:59 +02:00
print '</a></td>' ;
2005-03-23 10:48:27 +01:00
2014-10-04 17:20:17 +02:00
print '<td><a href="card.php?id=' . $obj -> rowid . '">' . $obj -> name . " </a></td> \n " ;
2005-01-07 16:12:08 +01:00
2014-09-18 21:18:25 +02:00
print '<td align="center"><a href="card.php?id=' . $obj -> rowid . '">' . $obj -> code_client . " </a></td> \n " ;
2005-01-07 16:12:08 +01:00
2010-09-05 15:24:59 +02:00
print '<td align="center">' . dol_print_date ( $db -> jdate ( $obj -> datec ), 'day' ) . " </td> \n " ;
2005-01-07 16:12:08 +01:00
2010-09-05 15:24:59 +02:00
print '<td align="right">' . price ( $obj -> amount ) . " </td> \n " ;
2005-01-31 15:24:45 +01:00
2010-09-05 15:24:59 +02:00
print '<td> </td>' ;
2009-07-22 19:13:59 +02:00
2010-09-05 15:24:59 +02:00
print " </tr> \n " ;
$i ++ ;
2005-01-07 16:12:08 +01:00
}
2010-09-05 15:24:59 +02:00
print " </table> " ;
2017-01-22 13:19:07 +01:00
print '</div>' ;
2017-06-07 16:44:04 +02:00
2016-02-07 15:50:48 +01:00
print '</form>' ;
2017-06-07 16:44:04 +02:00
2010-09-05 15:24:59 +02:00
$db -> free ( $result );
2005-01-07 16:12:08 +01:00
}
2009-07-22 19:13:59 +02:00
else
2005-01-07 16:12:08 +01:00
{
2010-09-05 15:24:59 +02:00
dol_print_error ( $db );
2005-01-07 16:12:08 +01:00
}
2018-08-08 12:29:36 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2015-12-11 14:19:38 +01:00
$db -> close ();