2004-10-19 20:58:50 +02:00
< ? php
2002-12-30 16:13:28 +01:00
/* Copyright ( C ) 2001 - 2002 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2016-02-11 20:24:15 +01:00
* Copyright ( C ) 2003 Jean - Louis Bergamo < jlb @ j1b . org >
* Copyright ( C ) 2004 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
2002-12-30 16:13:28 +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
2002-12-30 16:13:28 +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 />.
2002-12-30 16:13:28 +01:00
*/
2004-08-14 14:37:59 +02:00
2005-04-02 22:36:17 +02:00
/**
2016-09-24 06:48:40 +02:00
* \file htdocs / adherents / subscription / list . php
2009-10-10 18:00:35 +02:00
* \ingroup member
2016-09-24 06:48:40 +02:00
* \brief list of subscription
2008-08-17 23:50:27 +02:00
*/
2004-08-14 14:37:59 +02:00
2016-10-02 20:15:11 +02:00
require '../../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php' ;
2016-09-24 06:48:40 +02:00
require_once DOL_DOCUMENT_ROOT . '/adherents/class/subscription.class.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
2005-01-12 21:53:29 +01:00
2018-12-09 23:41:36 +01:00
$langs -> load ( array ( " members " , " companies " ));
2007-05-28 15:14:50 +02:00
2018-12-09 23:41:36 +01:00
$action = GETPOST ( 'action' , 'aZ09' );
$massaction = GETPOST ( 'massaction' , 'alpha' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
$toselect = GETPOST ( 'toselect' , 'array' );
$filter = GETPOST ( " filter " , " alpha " );
$statut = ( GETPOSTISSET ( " statut " ) ? GETPOST ( " statut " , " alpha " ) : 1 );
2016-02-11 20:24:15 +01:00
$search_ref = GETPOST ( 'search_ref' , 'alpha' );
$search_lastname = GETPOST ( 'search_lastname' , 'alpha' );
2018-12-09 23:41:36 +01:00
$search_firstname = GETPOST ( 'search_firstname' , 'alpha' );
2016-02-11 20:24:15 +01:00
$search_login = GETPOST ( 'search_login' , 'alpha' );
$search_note = GETPOST ( 'search_note' , 'alpha' );
2015-02-14 19:10:40 +01:00
$search_account = GETPOST ( 'search_account' , 'int' );
2016-02-11 20:24:15 +01:00
$search_amount = GETPOST ( 'search_amount' , 'alpha' );
2015-10-04 11:17:19 +02:00
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
2002-12-30 16:13:28 +01:00
2018-10-30 12:30:56 +01:00
$date_select = GETPOST ( " date_select " , 'alpha' );
2017-04-11 09:55:45 +02:00
2017-06-08 14:55: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-11-03 19:52:02 +01:00
if ( empty ( $page ) || $page == - 1 ) { $page = 0 ; } // If $page is not defined, or '' or -1
2016-02-11 20:24:15 +01:00
$offset = $limit * $page ;
2005-08-11 20:24:58 +02:00
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2010-11-20 14:08:44 +01:00
if ( ! $sortorder ) { $sortorder = " DESC " ; }
if ( ! $sortfield ) { $sortfield = " c.dateadh " ; }
2005-01-12 21:53:29 +01:00
2018-11-07 12:49:17 +01:00
$object = new Subscription ( $db );
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2017-04-11 09:55:45 +02:00
$hookmanager -> initHooks ( array ( 'subscriptionlist' ));
$extrafields = new ExtraFields ( $db );
// fetch optionals attributes and labels
$extralabels = $extrafields -> fetch_name_optionals_label ( 'subscription' );
2018-11-07 12:49:17 +01:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $object -> table_element , '' , 'search_' );
2017-04-11 09:55:45 +02:00
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array (
);
$arrayfields = array (
2018-12-09 23:41:36 +01:00
'd.ref' => array ( 'label' => $langs -> trans ( " Ref " ), 'checked' => 1 ),
'd.lastname' => array ( 'label' => $langs -> trans ( " Lastname " ), 'checked' => 1 ),
'd.firstname' => array ( 'label' => $langs -> trans ( " Firstname " ), 'checked' => 1 ),
'd.login' => array ( 'label' => $langs -> trans ( " Login " ), 'checked' => 1 ),
't.libelle' => array ( 'label' => $langs -> trans ( " Type " ), 'checked' => 1 ),
'd.bank' => array ( 'label' => $langs -> trans ( " BankAccount " ), 'checked' => 1 , 'enabled' => ( ! empty ( $conf -> banque -> enabled ))),
/* 'd.note_public' => array ( 'label' => $langs -> trans ( " NotePublic " ), 'checked' => 0 ),
'd.note_private' => array ( 'label' => $langs -> trans ( " NotePrivate " ), 'checked' => 0 ), */
'd.datedebut' => array ( 'label' => $langs -> trans ( " DateSubscription " ), 'checked' => 1 , 'position' => 100 ),
'd.datefin' => array ( 'label' => $langs -> trans ( " EndSubscription " ), 'checked' => 1 , 'position' => 101 ),
'd.amount' => array ( 'label' => $langs -> trans ( " Amount " ), 'checked' => 1 , 'position' => 102 ),
'd.datec' => array ( 'label' => $langs -> trans ( " DateCreation " ), 'checked' => 0 , 'position' => 500 ),
'd.tms' => array ( 'label' => $langs -> trans ( " DateModificationShort " ), 'checked' => 0 , 'position' => 500 ),
// 'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000)
2017-04-11 09:55:45 +02:00
);
2002-12-30 16:13:28 +01:00
2013-01-10 08:27:12 +01:00
// Security check
$result = restrictedArea ( $user , 'adherent' , '' , '' , 'cotisation' );
2007-06-01 23:27:51 +02:00
2002-12-30 16:13:28 +01:00
2007-05-28 15:14:50 +02:00
/*
2018-12-09 23:41:36 +01:00
* Actions
2010-08-29 17:25:39 +02:00
*/
2005-01-12 21:53:29 +01:00
2017-09-15 10:50:50 +02:00
if ( GETPOST ( 'cancel' , 'alpha' )) { $action = 'list' ; $massaction = '' ; }
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' ) && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills' ) { $massaction = '' ; }
2017-04-11 09:55:45 +02:00
$parameters = array ( 'socid' => $socid );
$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' );
if ( empty ( $reshook ))
2015-02-14 19:10:40 +01:00
{
2017-04-11 09:55:45 +02:00
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
// 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
2017-04-11 09:55:45 +02:00
{
$search = " " ;
$search_ref = " " ;
$search_lastname = " " ;
$search_firstname = " " ;
$search_login = " " ;
$search_note = " " ;
$search_amount = " " ;
$search_account = " " ;
$toselect = '' ;
$search_array_options = array ();
}
2015-02-14 19:10:40 +01:00
}
2005-01-12 21:53:29 +01:00
2006-03-18 01:06:55 +01:00
/*
2009-08-12 14:59:14 +02:00
* View
2006-03-18 01:06:55 +01:00
*/
2002-12-30 16:13:28 +01:00
2015-02-14 19:10:40 +01:00
$form = new Form ( $db );
2018-12-09 23:41:36 +01:00
$subscription = new Subscription ( $db );
$adherent = new Adherent ( $db );
$accountstatic = new Account ( $db );
2015-02-14 19:10:40 +01:00
2018-12-09 23:41:36 +01:00
$now = dol_now ();
2002-12-30 16:13:28 +01:00
2014-05-05 00:42:52 +02:00
// List of subscriptions
2017-04-11 09:55:45 +02:00
$sql = " SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, d.photo, " ;
2016-09-24 06:48:40 +02:00
$sql .= " c.rowid as crowid, c.subscription, " ;
2018-12-09 23:41:36 +01:00
$sql .= " c.dateadh, c.datef, c.datec as date_creation, c.tms as date_update, " ;
2007-09-09 12:43:26 +02:00
$sql .= " c.fk_bank as bank, c.note, " ;
2005-08-11 20:24:58 +02:00
$sql .= " b.fk_account " ;
2016-09-24 06:48:40 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " adherent as d, " . MAIN_DB_PREFIX . " subscription as c " ;
2005-08-11 20:24:58 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " bank as b ON c.fk_bank=b.rowid " ;
$sql .= " WHERE d.rowid = c.fk_adherent " ;
2017-05-30 18:50:54 +02:00
$sql .= " AND d.entity IN ( " . getEntity ( 'adherent' ) . " ) " ;
2006-11-26 19:24:53 +01:00
if ( isset ( $date_select ) && $date_select != '' )
2005-09-06 18:47:39 +02:00
{
2018-10-29 11:04:16 +01:00
$sql .= " AND c.dateadh >= ' " . $date_select . " -01-01 00:00:00' " ;
$sql .= " AND c.dateadh < ' " . ( $date_select + 1 ) . " -01-01 00:00:00' " ;
2003-02-28 18:18:04 +01:00
}
2015-02-14 19:10:40 +01:00
if ( $search_ref )
{
if ( is_numeric ( $search_ref )) $sql .= " AND (c.rowid = " . $db -> escape ( $search_ref ) . " ) " ;
else $sql .= " AND 1 = 2 " ; // Always wrong
}
2018-12-09 23:41:36 +01:00
if ( $search_lastname ) $sql .= natural_search ( array ( 'd.lastname' , 'd.societe' ), $search_lastname );
if ( $search_firstname ) $sql .= natural_search ( array ( 'd.firstname' ), $search_firstname );
2018-12-09 23:58:27 +01:00
if ( $search_login ) $sql .= natural_search ( 'd.login' , $search_login );
2016-02-11 20:24:15 +01:00
if ( $search_note ) $sql .= natural_search ( 'c.note' , $search_note );
2018-12-09 23:41:36 +01:00
if ( $search_account > 0 ) $sql .= " AND b.fk_account = " . urldecode ( $search_account );
2016-09-24 06:48:40 +02:00
if ( $search_amount ) $sql .= natural_search ( 'c.subscription' , $search_amount , 1 );
2018-12-09 23:41:36 +01:00
// Add where from extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php' ;
// Add where from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2016-02-11 20:24:15 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
2018-12-09 23:41:36 +01:00
// Count total nb of records with no order and no limits
2017-01-15 20:49:20 +01:00
$nbtotalofrecords = '' ;
2016-02-11 20:24:15 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST ))
2015-02-14 19:10:40 +01:00
{
2018-12-09 23:41:36 +01:00
$resql = $db -> query ( $sql );
if ( $resql ) $nbtotalofrecords = $db -> num_rows ( $resql );
else dol_print_error ( $db );
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 ;
}
2015-02-14 19:10:40 +01:00
}
2018-12-09 23:41:36 +01:00
// Add limit
2016-02-11 20:24:15 +01:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
2002-12-30 16:13:28 +01:00
$result = $db -> query ( $sql );
2018-12-09 23:41:36 +01:00
if ( ! $result )
{
dol_print_error ( $db );
exit ;
}
2018-04-03 15:28:12 +02:00
2018-12-09 23:41:36 +01:00
$num = $db -> num_rows ( $result );
2006-11-26 19:24:53 +01:00
2018-12-09 23:41:36 +01:00
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
2017-08-02 13:31:53 +02:00
2018-12-09 23:41:36 +01:00
if ( $num == 1 && ! empty ( $conf -> global -> MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE ) && $sall )
{
$obj = $db -> fetch_object ( $resql );
$id = $obj -> rowid ;
header ( " Location: " . DOL_URL_ROOT . '/adherents/subscription/card.php?id=' . $id );
exit ;
}
2017-08-02 13:31:53 +02:00
2018-12-09 23:41:36 +01:00
llxHeader ( '' , $langs -> trans ( " ListOfSubscriptions " ), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros' );
2005-09-06 18:47:39 +02:00
2018-12-09 23:41:36 +01:00
$i = 0 ;
$title = $langs -> trans ( " ListOfSubscriptions " );
if ( ! empty ( $date_select )) $title .= ' (' . $langs -> trans ( " Year " ) . ' ' . $date_select . ')' ;
$param = '' ;
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) $param .= '&contextpage=' . urlencode ( $contextpage );
if ( $limit > 0 && $limit != $conf -> liste_limit ) $param .= '&limit=' . urlencode ( $limit );
if ( $statut != '' ) $param .= " &statut= " . urlencode ( $statut );
if ( $date_select ) $param .= " &date_select= " . urlencode ( $date_select );
if ( $search_lastname ) $param .= " &search_lastname= " . urlencode ( $search_lastname );
if ( $search_login ) $param .= " &search_login= " . urlencode ( $search_login );
if ( $search_acount ) $param .= " &search_account= " . urlencode ( $search_account );
if ( $search_amount ) $param .= " &search_amount= " . urlencode ( $search_amount );
if ( $optioncss != '' ) $param .= '&optioncss=' . urlencode ( $optioncss );
// Add $param from extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php' ;
// List of mass actions available
$arrayofmassactions = array (
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);
2018-12-09 23:58:27 +01:00
//if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
2018-12-09 23:41:36 +01:00
if ( in_array ( $massaction , array ( 'presend' , 'predelete' ))) $arrayofmassactions = array ();
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2015-02-14 19:10:40 +01:00
2018-12-09 23:41:36 +01:00
$newcardbutton = '' ;
if ( $user -> rights -> adherent -> cotisation -> creer )
{
$newcardbutton = '<a class="butActionNew" href="' . DOL_URL_ROOT . '/adherents/list.php?status=-1,1"><span class="valignmiddle">' . $langs -> trans ( 'NewSubscription' ) . '</span>' ;
$newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>' ;
$newcardbutton .= '</a>' ;
}
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="view" value="' . dol_escape_htmltag ( $view ) . '">' ;
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 . '">' ;
print_barre_liste ( $title , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'title_generic.png' , 0 , $newcardbutton , '' , $limit );
$topicmail = " Information " ;
$modelmail = " subscription " ;
$objecttmp = new Subscription ( $db );
$trackid = 'sub' . $object -> id ;
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php' ;
if ( $sall )
{
foreach ( $fieldstosearchall as $key => $val ) $fieldstosearchall [ $key ] = $langs -> trans ( $val );
print '<div class="divsearchfieldfilter">' . $langs -> trans ( " FilterOnInto " , $sall ) . join ( ', ' , $fieldstosearchall ) . '</div>' ;
}
$moreforfilter = '' ;
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
if ( $massactionbutton ) $selectedfields .= $form -> showCheckAddButtons ( 'checkforselect' , 1 );
print '<div class="div-table-responsive">' ;
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
// Line for filters fields
print '<tr class="liste_titre_filter">' ;
// Line numbering
if ( ! empty ( $conf -> global -> MAIN_SHOW_TECHNICAL_ID ))
{
print '<td class="liste_titre"> </td>' ;
}
// Ref
if ( ! empty ( $arrayfields [ 'd.ref' ][ 'checked' ]))
{
2015-02-14 19:10:40 +01:00
print '<td class="liste_titre" align="left">' ;
2017-04-11 09:55:45 +02:00
print '<input class="flat" type="text" name="search_ref" value="' . dol_escape_htmltag ( $search_ref ) . '" size="4"></td>' ;
2018-12-09 23:41:36 +01:00
}
if ( ! empty ( $arrayfields [ 'd.lastname' ][ 'checked' ]))
{
print '<td class="liste_titre" align="left">' ;
print '<input class="flat" type="text" name="search_lastname" value="' . dol_escape_htmltag ( $search_lastname ) . '" size="7"></td>' ;
}
2015-02-14 19:10:40 +01:00
2018-12-09 23:41:36 +01:00
if ( ! empty ( $arrayfields [ 'd.firstname' ][ 'checked' ]))
{
2015-02-14 19:10:40 +01:00
print '<td class="liste_titre" align="left">' ;
2018-12-09 23:41:36 +01:00
print '<input class="flat" type="text" name="search_firstname" value="' . dol_escape_htmltag ( $search_firstname ) . '" size="12"></td>' ;
}
2015-02-14 19:10:40 +01:00
2018-12-09 23:41:36 +01:00
if ( ! empty ( $arrayfields [ 'd.login' ][ 'checked' ]))
{
2015-02-14 19:10:40 +01:00
print '<td class="liste_titre" align="left">' ;
2017-04-11 09:55:45 +02:00
print '<input class="flat" type="text" name="search_login" value="' . dol_escape_htmltag ( $search_login ) . '" size="7"></td>' ;
2018-12-09 23:41:36 +01:00
}
2015-02-14 19:10:40 +01:00
2018-12-09 23:41:36 +01:00
if ( ! empty ( $arrayfields [ 't.libelle' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '' ;
print '</td>' ;
}
2015-02-14 19:10:40 +01:00
2018-12-09 23:41:36 +01:00
if ( ! empty ( $arrayfields [ 'd.bank' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print $form -> select_comptes ( $search_account , 'search_account' , 0 , '' , 1 );
print '</td>' ;
}
2015-02-14 19:10:40 +01:00
2018-12-09 23:41:36 +01:00
if ( ! empty ( $arrayfields [ 'd.date_debut' ][ 'checked' ]))
{
2015-02-14 19:10:40 +01:00
print '<td class="liste_titre"> </td>' ;
2018-12-09 23:41:36 +01:00
}
2015-02-14 19:10:40 +01:00
2018-12-09 23:41:36 +01:00
if ( ! empty ( $arrayfields [ 'd.date_fin' ][ 'checked' ]))
{
2015-02-14 19:10:40 +01:00
print '<td class="liste_titre"> </td>' ;
2018-12-09 23:41:36 +01:00
}
2015-02-14 19:10:40 +01:00
2018-12-09 23:41:36 +01:00
if ( ! empty ( $arrayfields [ 'd.amount' ][ 'checked' ]))
{
2015-02-14 19:10:40 +01:00
print '<td align="right" class="liste_titre">' ;
2017-04-11 09:55:45 +02:00
print '<input class="flat" type="text" name="search_amount" value="' . dol_escape_htmltag ( $search_amount ) . '" size="4">' ;
2015-02-14 19:10:40 +01:00
print '</td>' ;
2018-12-09 23:41:36 +01:00
}
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php' ;
// 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 ;
// Date creation
if ( ! empty ( $arrayfields [ 'd.datec' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
// Date modification
if ( ! empty ( $arrayfields [ 'd.tms' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
2017-08-02 13:31:53 +02:00
2018-12-09 23:41:36 +01:00
// Action column
print '<td class="liste_titre" align="right">' ;
$searchpicto = $form -> showFilterButtons ();
print $searchpicto ;
print '</td>' ;
2015-02-14 19:10:40 +01:00
2018-12-09 23:41:36 +01:00
print " </tr> \n " ;
2015-02-14 19:10:40 +01:00
2018-12-09 23:41:36 +01:00
print '<tr class="liste_titre">' ;
if ( ! empty ( $arrayfields [ 'd.ref' ][ 'checked' ]))
{
2017-08-02 13:31:53 +02:00
print_liste_field_titre ( " Ref " , $_SERVER [ " PHP_SELF " ], " c.rowid " , $param , " " , " " , $sortfield , $sortorder );
2018-12-09 23:41:36 +01:00
}
if ( ! empty ( $arrayfields [ 'd.lastname' ][ 'checked' ]))
{
print_liste_field_titre ( " LastName " , $_SERVER [ " PHP_SELF " ], " d.lastname " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'd.firstname' ][ 'checked' ]))
{
print_liste_field_titre ( " FirstName " , $_SERVER [ " PHP_SELF " ], " d.firstname " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'd.login' ][ 'checked' ]))
{
2017-08-02 13:31:53 +02:00
print_liste_field_titre ( " Login " , $_SERVER [ " PHP_SELF " ], " d.login " , $param , " " , " " , $sortfield , $sortorder );
2018-12-09 23:41:36 +01:00
}
if ( ! empty ( $arrayfields [ 't.libelle' ][ 'checked' ]))
{
2017-08-02 13:31:53 +02:00
print_liste_field_titre ( " Label " , $_SERVER [ " PHP_SELF " ], " c.note " , $param , " " , 'align="left"' , $sortfield , $sortorder );
2018-12-09 23:41:36 +01:00
}
if ( ! empty ( $arrayfields [ 'd.bank' ][ 'checked' ]))
{
print_liste_field_titre ( " Account " , $_SERVER [ " PHP_SELF " ], " b.fk_account " , $pram , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'd.date_debut' ][ 'checked' ]))
{
2017-08-02 13:31:53 +02:00
print_liste_field_titre ( " Date " , $_SERVER [ " PHP_SELF " ], " c.dateadh " , $param , " " , 'align="center"' , $sortfield , $sortorder );
2018-12-09 23:41:36 +01:00
}
if ( ! empty ( $arrayfields [ 'd.date_fin' ][ 'checked' ]))
{
2017-08-02 13:31:53 +02:00
print_liste_field_titre ( " DateEnd " , $_SERVER [ " PHP_SELF " ], " c.datef " , $param , " " , 'align="center"' , $sortfield , $sortorder );
2018-12-09 23:41:36 +01:00
}
if ( ! empty ( $arrayfields [ 'd.amount' ][ 'checked' ]))
{
2017-08-02 13:31:53 +02:00
print_liste_field_titre ( " Amount " , $_SERVER [ " PHP_SELF " ], " c.subscription " , $param , " " , 'align="right"' , $sortfield , $sortorder );
2018-12-09 23:41:36 +01:00
}
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php' ;
// 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 ;
if ( ! empty ( $arrayfields [ 'd.datec' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'd.datec' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " d.datec " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'd.tms' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'd.tms' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " d.tms " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , 'align="center"' , $sortfield , $sortorder , 'maxwidthsearch ' );
print " </tr> \n " ;
$total = 0 ;
$totalarray = array ();
while ( $i < min ( $num , $limit ))
{
$obj = $db -> fetch_object ( $result );
$total += $obj -> subscription ;
2017-08-02 13:31:53 +02:00
2018-12-09 23:41:36 +01:00
$subscription -> ref = $obj -> crowid ;
$subscription -> id = $obj -> crowid ;
2017-08-02 13:31:53 +02:00
2018-12-09 23:41:36 +01:00
$adherent -> lastname = $obj -> lastname ;
$adherent -> firstname = $obj -> firstname ;
$adherent -> ref = $obj -> rowid ;
$adherent -> id = $obj -> rowid ;
$adherent -> statut = $obj -> statut ;
$adherent -> login = $obj -> login ;
$adherent -> photo = $obj -> photo ;
2007-05-28 15:14:50 +02:00
2005-09-06 18:47:39 +02:00
2018-12-09 23:41:36 +01:00
print '<tr class="oddeven">' ;
2006-11-26 19:24:53 +01:00
2018-12-09 23:41:36 +01:00
// Ref
if ( ! empty ( $arrayfields [ 'd.ref' ][ 'checked' ]))
{
print '<td>' . $subscription -> getNomUrl ( 1 ) . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2017-08-02 13:31:53 +02:00
2018-12-09 23:41:36 +01:00
// Lastname
if ( ! empty ( $arrayfields [ 'd.lastname' ][ 'checked' ]))
{
$adherent -> firstname = '' ;
print '<td>' . $adherent -> getNomUrl ( - 1 ) . '</td>' ;
$adherent -> firstname = $obj -> firstname ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Firstname
if ( ! empty ( $arrayfields [ 'd.firstname' ][ 'checked' ]))
{
print '<td>' . $adherent -> firstname . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2007-05-28 15:14:50 +02:00
2018-12-09 23:41:36 +01:00
// Login
if ( ! empty ( $arrayfields [ 'd.login' ][ 'checked' ]))
{
print '<td>' . $adherent -> login . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2009-03-09 11:27:21 +01:00
2018-12-09 23:41:36 +01:00
// Label
if ( ! empty ( $arrayfields [ 't.libelle' ][ 'checked' ]))
{
print '<td>' ;
print dol_trunc ( $obj -> note , 128 );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2010-08-29 17:25:39 +02:00
2018-12-09 23:41:36 +01:00
// Banque
if ( ! empty ( $arrayfields [ 'd.bank' ][ 'checked' ]))
{
print " <td> " ;
if ( $obj -> fk_account > 0 )
{
$accountstatic -> id = $obj -> fk_account ;
$accountstatic -> fetch ( $obj -> fk_account );
//$accountstatic->label=$obj->label;
print $accountstatic -> getNomUrl ( 1 );
}
print " </td> \n " ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2010-08-29 17:25:39 +02:00
2018-12-09 23:41:36 +01:00
// Date start
if ( ! empty ( $arrayfields [ 'd.date_start' ][ 'checked' ]))
{
print '<td align="center">' . dol_print_date ( $db -> jdate ( $obj -> dateadh ), 'day' ) . " </td> \n " ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Date end
if ( ! empty ( $arrayfields [ 'd.date_end' ][ 'checked' ]))
{
print '<td align="center">' . dol_print_date ( $db -> jdate ( $obj -> datef ), 'day' ) . " </td> \n " ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Price
if ( ! empty ( $arrayfields [ 'd.amount' ][ 'checked' ]))
{
print '<td align="right">' . price ( $obj -> subscription ) . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
if ( ! $i ) $totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 'd.amount' ;
$totalarray [ 'val' ][ 'd.amount' ] += $obj -> subscription ;
}
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php' ;
// Fields from hook
$parameters = array ( 'arrayfields' => $arrayfields , 'obj' => $obj );
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
// Date creation
if ( ! empty ( $arrayfields [ 'd.datec' ][ 'checked' ]))
{
print '<td align="center" class="nowrap">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_creation ), 'dayhour' , 'tzuser' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Date modification
if ( ! empty ( $arrayfields [ 'd.tms' ][ 'checked' ]))
{
print '<td align="center" class="nowrap">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_update ), 'dayhour' , 'tzuser' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Action column
print '<td align="center">' ;
if ( $massactionbutton || $massaction ) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected = 0 ;
if ( in_array ( $obj -> rowid , $arrayofselected )) $selected = 1 ;
print '<input id="cb' . $obj -> rowid . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj -> rowid . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
}
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2010-08-29 17:25:39 +02:00
2018-12-09 23:41:36 +01:00
print " </tr> \n " ;
$i ++ ;
}
2010-08-29 17:25:39 +02:00
2018-12-09 23:41:36 +01:00
// Show total line
if ( isset ( $totalarray [ 'pos' ]))
{
print '<tr class="liste_total">' ;
$i = 0 ;
while ( $i < $totalarray [ 'nbfield' ])
{
$i ++ ;
if ( ! empty ( $totalarray [ 'pos' ][ $i ])) print '<td align="right">' . price ( $totalarray [ 'val' ][ $totalarray [ 'pos' ][ $i ]]) . '</td>' ;
else
2017-10-10 07:56:10 +02:00
{
2018-12-09 23:41:36 +01:00
if ( $i == 1 )
2017-10-10 07:56:10 +02:00
{
2018-12-09 23:41:36 +01:00
if ( $num < $limit ) print '<td align="left">' . $langs -> trans ( " Total " ) . '</td>' ;
else print '<td align="left">' . $langs -> trans ( " Totalforthispage " ) . '</td>' ;
2017-10-10 07:56:10 +02:00
}
2018-12-09 23:41:36 +01:00
else print '<td></td>' ;
2017-10-10 07:56:10 +02:00
}
2018-12-09 23:41:36 +01:00
}
print '</tr>' ;
}
2007-09-09 12:43:26 +02:00
2018-12-09 23:41:36 +01: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 . '" class="opacitymedium">' . $langs -> trans ( " NoRecordFound " ) . '</td></tr>' ;
}
2015-02-14 19:10:40 +01:00
2018-12-09 23:41:36 +01:00
$db -> free ( $resql );
2005-09-06 18:47:39 +02:00
2018-12-09 23:41:36 +01:00
$parameters = array ( 'sql' => $sql );
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2017-08-02 13:31:53 +02:00
2018-12-09 23:41:36 +01:00
print " </table> " ;
print '</div>' ;
print '</form>' ;
2009-03-09 11:27:21 +01:00
2002-12-30 16:13:28 +01:00
2018-07-28 14:29:28 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2015-02-14 19:10:40 +01:00
$db -> close ();