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
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// 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' ;
2019-01-17 17:36:14 +01:00
require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent_type.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
2019-11-13 19:35:39 +01:00
$langs -> loadLangs ( array ( " members " , " companies " ));
2007-05-28 15:14:50 +02:00
2019-11-13 19:35:39 +01:00
$action = GETPOST ( 'action' , 'aZ09' );
$massaction = GETPOST ( 'massaction' , 'alpha' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
2018-12-09 23:41:36 +01:00
$toselect = GETPOST ( 'toselect' , 'array' );
2020-09-25 10:27:30 +02:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'subscriptionlist' ; // To manage different context of search
2018-12-09 23:41:36 +01:00
2019-11-13 19:35:39 +01:00
$statut = ( GETPOSTISSET ( " statut " ) ? GETPOST ( " statut " , " alpha " ) : 1 );
$search_ref = GETPOST ( 'search_ref' , 'alpha' );
$search_type = GETPOST ( 'search_type' , 'alpha' );
$search_lastname = GETPOST ( 'search_lastname' , 'alpha' );
$search_firstname = GETPOST ( 'search_firstname' , 'alpha' );
$search_login = GETPOST ( 'search_login' , 'alpha' );
$search_note = GETPOST ( 'search_note' , 'alpha' );
$search_account = GETPOST ( 'search_account' , 'int' );
$search_amount = GETPOST ( 'search_amount' , 'alpha' );
2019-01-27 11:55:16 +01:00
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
2020-02-21 17:53:37 +01:00
$sall = '' ;
2019-01-27 11:55:16 +01:00
2019-11-13 19:35:39 +01:00
$date_select = GETPOST ( " date_select " , 'alpha' );
2019-01-27 11:55:16 +01:00
2019-11-13 19:35:39 +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-03-13 13:07:11 +01:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
2021-03-01 00:19:52 +01:00
if ( empty ( $page ) || $page == - 1 ) {
$page = 0 ;
} // If $page is not defined, or '' or -1
2019-11-13 19:35:39 +01:00
$offset = $limit * $page ;
2005-08-11 20:24:58 +02:00
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2021-03-01 00:19:52 +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
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2019-09-28 10:55:09 +02:00
2019-11-13 19:35:39 +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 (
);
2019-11-13 19:35:39 +01:00
$arrayfields = array (
2020-02-12 15:19:42 +01:00
'd.ref' => array ( 'label' => " Ref " , 'checked' => 1 ),
'd.fk_type' => array ( 'label' => " Type " , 'checked' => 1 ),
'd.lastname' => array ( 'label' => " Lastname " , 'checked' => 1 ),
'd.firstname' => array ( 'label' => " Firstname " , 'checked' => 1 ),
'd.login' => array ( 'label' => " Login " , 'checked' => 1 ),
't.libelle' => array ( 'label' => " Label " , 'checked' => 1 ),
'd.bank' => array ( 'label' => " BankAccount " , 'checked' => 1 , 'enabled' => ( ! empty ( $conf -> banque -> enabled ))),
/* 'd.note_public' => array ( 'label' => " NotePublic " , 'checked' => 0 ),
'd.note_private' => array ( 'label' => " NotePrivate " , 'checked' => 0 ), */
'c.dateadh' => array ( 'label' => " DateSubscription " , 'checked' => 1 , 'position' => 100 ),
'c.datef' => array ( 'label' => " EndSubscription " , 'checked' => 1 , 'position' => 101 ),
'd.amount' => array ( 'label' => " Amount " , 'checked' => 1 , 'position' => 102 ),
'c.datec' => array ( 'label' => " DateCreation " , 'checked' => 0 , 'position' => 500 ),
'c.tms' => array ( 'label' => " DateModificationShort " , 'checked' => 0 , 'position' => 500 ),
// 'd.statut'=>array('label'=>"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
2019-11-13 19:35:39 +01:00
$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
2021-03-01 00:19:52 +01:00
if ( GETPOST ( 'cancel' , 'alpha' )) {
$action = 'list' ; $massaction = '' ;
}
2022-04-25 14:28:57 +02:00
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' ) && $massaction != 'presend' && $massaction != 'confirm_presend' ) {
2021-03-01 00:19:52 +01:00
$massaction = '' ;
}
2017-04-11 09:55:45 +02:00
2021-07-26 15:37:36 +02:00
$parameters = array ( 'socid' => isset ( $socid ) ? $socid : null );
2019-11-13 19:35:39 +01:00
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-03-01 00:19:52 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2017-04-11 09:55:45 +02:00
2020-05-21 09:12:18 +02:00
if ( empty ( $reshook )) {
2020-10-31 14:32:18 +01:00
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
2017-04-11 09:55:45 +02:00
2020-10-31 14:32:18 +01:00
// Purge search criteria
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
2020-05-21 09:12:18 +02:00
$search_type = " " ;
2020-10-31 14:32:18 +01:00
$search_ref = " " ;
$search_lastname = " " ;
$search_firstname = " " ;
$search_login = " " ;
$search_note = " " ;
$search_amount = " " ;
$search_account = " " ;
2022-05-08 18:25:22 +02:00
$toselect = array ();
2020-10-31 14:32:18 +01:00
$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
2019-11-13 19:35:39 +01:00
$form = new Form ( $db );
$subscription = new Subscription ( $db );
$adherent = new Adherent ( $db );
$accountstatic = new Account ( $db );
2015-02-14 19:10:40 +01:00
2019-11-13 19:35:39 +01:00
$now = dol_now ();
2002-12-30 16:13:28 +01:00
2014-05-05 00:42:52 +02:00
// List of subscriptions
2019-06-25 10:12:24 +02:00
$sql = " SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, d.photo, d.statut, " ;
2020-10-26 21:51:17 +01:00
$sql .= " d.gender, d.email, d.morphy, " ;
2019-11-13 19:35:39 +01:00
$sql .= " c.rowid as crowid, c.fk_type, c.subscription, " ;
$sql .= " c.dateadh, c.datef, c.datec as date_creation, c.tms as date_update, " ;
$sql .= " c.fk_bank as bank, c.note, " ;
$sql .= " b.fk_account " ;
2020-09-13 21:15:25 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " adherent as d " ;
$sql .= " JOIN " . MAIN_DB_PREFIX . " subscription as c on d.rowid = c.fk_adherent " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " adherent_extrafields as ef on (d.rowid = ef.fk_object) " ;
2019-11-13 19:35:39 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " bank as b ON c.fk_bank=b.rowid " ;
2020-09-13 21:15:25 +02:00
$sql .= " WHERE d.entity IN ( " . getEntity ( 'adherent' ) . " ) " ;
2020-10-26 21:51:17 +01:00
if ( isset ( $date_select ) && $date_select != '' ) {
2020-10-31 14:32:18 +01:00
$sql .= " AND c.dateadh >= ' " . (( int ) $date_select ) . " -01-01 00:00:00' " ;
$sql .= " AND c.dateadh < ' " . (( int ) $date_select + 1 ) . " -01-01 00:00:00' " ;
2003-02-28 18:18:04 +01:00
}
2020-05-21 09:12:18 +02:00
if ( $search_ref ) {
2021-03-01 00:19:52 +01:00
if ( is_numeric ( $search_ref )) {
2021-04-24 20:18:11 +02:00
$sql .= " AND c.rowid = " . (( int ) $search_ref );
2021-03-01 00:19:52 +01:00
} else {
$sql .= " AND 1 = 2 " ; // Always wrong
}
}
if ( $search_type ) {
$sql .= natural_search ( array ( 'c.fk_type' ), $search_type );
}
if ( $search_lastname ) {
$sql .= natural_search ( array ( 'd.lastname' , 'd.societe' ), $search_lastname );
}
if ( $search_firstname ) {
$sql .= natural_search ( array ( 'd.firstname' ), $search_firstname );
}
if ( $search_login ) {
$sql .= natural_search ( 'd.login' , $search_login );
}
if ( $search_note ) {
$sql .= natural_search ( 'c.note' , $search_note );
}
if ( $search_account > 0 ) {
2021-03-22 13:31:06 +01:00
$sql .= " AND b.fk_account = " . (( int ) $search_account );
2021-03-01 00:19:52 +01:00
}
if ( $search_amount ) {
$sql .= natural_search ( 'c.subscription' , $search_amount , 1 );
2015-02-14 19:10:40 +01:00
}
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
2019-11-13 19:35:39 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2018-12-09 23:41:36 +01:00
2019-11-13 19:35:39 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
2016-02-11 20:24:15 +01:00
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 = '' ;
2020-05-21 09:12:18 +02:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST )) {
2020-10-31 14:32:18 +01:00
$resql = $db -> query ( $sql );
2021-03-01 00:19:52 +01:00
if ( $resql ) {
$nbtotalofrecords = $db -> num_rows ( $resql );
} else {
dol_print_error ( $db );
}
2020-10-31 14:32:18 +01:00
if (( $page * $limit ) > $nbtotalofrecords ) { // if total resultset is smaller then paging size (filtering), goto and load page 0
2020-05-21 09:12:18 +02:00
$page = 0 ;
2020-10-31 14:32:18 +01:00
$offset = 0 ;
}
2015-02-14 19:10:40 +01:00
}
2018-12-09 23:41:36 +01:00
// Add limit
2019-11-13 19:35:39 +01:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
2002-12-30 16:13:28 +01:00
$result = $db -> query ( $sql );
2020-05-21 09:12:18 +02:00
if ( ! $result ) {
2018-12-09 23:41:36 +01:00
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
2019-11-13 19:35:39 +01:00
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
2017-08-02 13:31:53 +02:00
2020-05-21 09:12:18 +02:00
if ( $num == 1 && ! empty ( $conf -> global -> MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE ) && $sall ) {
2018-12-09 23:41:36 +01:00
$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
2021-02-16 11:15:42 +01:00
$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros' ;
llxHeader ( '' , $langs -> trans ( " ListOfSubscriptions " ), $help_url );
2005-09-06 18:47:39 +02:00
2018-12-09 23:41:36 +01:00
$i = 0 ;
2019-11-13 19:35:39 +01:00
$title = $langs -> trans ( " ListOfSubscriptions " );
2021-03-01 00:19:52 +01:00
if ( ! empty ( $date_select )) {
$title .= ' (' . $langs -> trans ( " Year " ) . ' ' . $date_select . ')' ;
}
2019-11-13 19:35:39 +01:00
$param = '' ;
2021-03-01 00:19:52 +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 ( $statut != '' ) {
$param .= " &statut= " . urlencode ( $statut );
}
if ( $search_type ) {
$param .= " &search_type= " . urlencode ( $search_type );
}
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_account ) {
$param .= " &search_account= " . urlencode ( $search_account );
}
if ( $search_amount ) {
$param .= " &search_amount= " . urlencode ( $search_amount );
}
if ( $optioncss != '' ) {
$param .= '&optioncss=' . urlencode ( $optioncss );
}
2018-12-09 23:41:36 +01:00
// Add $param from extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php' ;
// List of mass actions available
2019-11-13 19:35:39 +01:00
$arrayofmassactions = array (
2021-04-14 14:45:55 +02:00
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
2018-12-09 23:41:36 +01:00
);
2021-04-14 14:45:55 +02:00
//if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
2021-03-01 00:19:52 +01:00
if ( in_array ( $massaction , array ( 'presend' , 'predelete' ))) {
$arrayofmassactions = array ();
}
2019-11-13 19:35:39 +01:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2015-02-14 19:10:40 +01:00
2019-11-13 19:35:39 +01:00
$newcardbutton = '' ;
2020-05-21 09:12:18 +02:00
if ( $user -> rights -> adherent -> cotisation -> creer ) {
2020-10-31 14:32:18 +01:00
$newcardbutton .= dolGetButtonTitle ( $langs -> trans ( 'NewSubscription' ), '' , 'fa fa-plus-circle' , DOL_URL_ROOT . '/adherents/list.php?status=-1,1' );
2018-12-09 23:41:36 +01:00
}
print '<form method="POST" id="searchFormList" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2021-03-01 00:19:52 +01:00
if ( $optioncss != '' ) {
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
}
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2018-12-09 23:41:36 +01:00
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 . '">' ;
2021-11-11 20:06:21 +01:00
print '<input type="hidden" name="date_select" value="' . $date_select . '">' ;
2018-12-09 23:41:36 +01:00
2021-02-15 20:13:38 +01:00
print_barre_liste ( $title , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , $subscription -> picto , 0 , $newcardbutton , '' , $limit , 0 , 0 , 1 );
2018-12-09 23:41:36 +01:00
2019-11-13 19:35:39 +01:00
$topicmail = " Information " ;
$modelmail = " subscription " ;
$objecttmp = new Subscription ( $db );
$trackid = 'sub' . $object -> id ;
2018-12-09 23:41:36 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php' ;
2020-05-21 09:12:18 +02:00
if ( $sall ) {
2021-03-01 00:19:52 +01:00
foreach ( $fieldstosearchall as $key => $val ) {
$fieldstosearchall [ $key ] = $langs -> trans ( $val );
}
2019-11-13 19:35:39 +01:00
print '<div class="divsearchfieldfilter">' . $langs -> trans ( " FilterOnInto " , $sall ) . join ( ', ' , $fieldstosearchall ) . '</div>' ;
2018-12-09 23:41:36 +01:00
}
$moreforfilter = '' ;
2019-11-13 19:35:39 +01:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
2021-03-01 00:19:52 +01:00
if ( $massactionbutton ) {
$selectedfields .= $form -> showCheckAddButtons ( 'checkforselect' , 1 );
}
2018-12-09 23:41:36 +01:00
print '<div class="div-table-responsive">' ;
2019-11-13 19:35:39 +01:00
print '<table class="tagtable nobottomiftotal liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2018-12-09 23:41:36 +01:00
// Line for filters fields
print '<tr class="liste_titre_filter">' ;
// Line numbering
2020-05-21 09:12:18 +02:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_TECHNICAL_ID )) {
2018-12-09 23:41:36 +01:00
print '<td class="liste_titre"> </td>' ;
}
// Ref
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'd.ref' ][ 'checked' ])) {
2019-03-19 13:57:08 +01:00
print '<td class="liste_titre left">' ;
2019-06-25 10:28:58 +02:00
print '<input class="flat maxwidth50" type="text" name="search_ref" value="' . dol_escape_htmltag ( $search_ref ) . '"></td>' ;
2018-12-09 23:41:36 +01:00
}
2019-01-17 17:36:14 +01:00
// Type
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'd.fk_type' ][ 'checked' ])) {
2019-03-19 13:57:08 +01:00
print '<td class="liste_titre left">' ;
2019-06-25 10:28:58 +02:00
print '<input class="flat maxwidth50" type="text" name="search_type" value="' . dol_escape_htmltag ( $search_type ) . '">' ;
2019-05-23 14:25:16 +02:00
print '</td>' ;
2019-01-17 17:36:14 +01:00
}
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'd.lastname' ][ 'checked' ])) {
2019-03-19 13:57:08 +01:00
print '<td class="liste_titre left">' ;
2019-06-25 10:28:58 +02:00
print '<input class="flat maxwidth75" type="text" name="search_lastname" value="' . dol_escape_htmltag ( $search_lastname ) . '"></td>' ;
2018-12-09 23:41:36 +01:00
}
2015-02-14 19:10:40 +01:00
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'd.firstname' ][ 'checked' ])) {
2019-03-19 13:57:08 +01:00
print '<td class="liste_titre left">' ;
2019-06-25 10:28:58 +02:00
print '<input class="flat maxwidth75" type="text" name="search_firstname" value="' . dol_escape_htmltag ( $search_firstname ) . '"></td>' ;
2018-12-09 23:41:36 +01:00
}
2015-02-14 19:10:40 +01:00
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'd.login' ][ 'checked' ])) {
2019-03-19 13:57:08 +01:00
print '<td class="liste_titre left">' ;
2019-06-25 10:28:58 +02:00
print '<input class="flat maxwidth75" type="text" name="search_login" value="' . dol_escape_htmltag ( $search_login ) . '"></td>' ;
2018-12-09 23:41:36 +01:00
}
2015-02-14 19:10:40 +01:00
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 't.libelle' ][ 'checked' ])) {
2018-12-09 23:41:36 +01:00
print '<td class="liste_titre">' ;
print '' ;
print '</td>' ;
}
2015-02-14 19:10:40 +01:00
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'd.bank' ][ 'checked' ])) {
2018-12-09 23:41:36 +01:00
print '<td class="liste_titre">' ;
2020-04-05 12:07:00 +02:00
$form -> select_comptes ( $search_account , 'search_account' , 0 , '' , 1 , '' , 0 , 'maxwidth150' );
2018-12-09 23:41:36 +01:00
print '</td>' ;
}
2015-02-14 19:10:40 +01:00
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'c.dateadh' ][ '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
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'c.datef' ][ '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
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'd.amount' ][ 'checked' ])) {
2019-01-30 19:41:56 +01:00
print '<td class="liste_titre right">' ;
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
2019-11-13 19:35:39 +01:00
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters ); // Note that $action and $object may have been modified by hook
2018-12-09 23:41:36 +01:00
print $hookmanager -> resPrint ;
// Date creation
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'c.datec' ][ 'checked' ])) {
2018-12-09 23:41:36 +01:00
print '<td class="liste_titre">' ;
print '</td>' ;
}
// Date modification
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'c.tms' ][ 'checked' ])) {
2018-12-09 23:41:36 +01:00
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
2019-01-30 19:41:56 +01:00
print '<td class="liste_titre right">' ;
2019-11-13 19:35:39 +01:00
$searchpicto = $form -> showFilterButtons ();
2018-12-09 23:41:36 +01:00
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">' ;
2021-03-01 00:19:52 +01:00
if ( ! empty ( $arrayfields [ 'd.ref' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'd.ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " c.rowid " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'd.fk_type' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'd.fk_type' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " c.fk_type " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'd.lastname' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'd.lastname' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " d.lastname " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'd.firstname' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'd.firstname' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " d.firstname " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'd.login' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'd.login' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " d.login " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 't.libelle' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 't.libelle' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " c.note " , $param , " " , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'd.bank' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'd.bank' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " b.fk_account " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'c.dateadh' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'c.dateadh' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " c.dateadh " , $param , " " , '' , $sortfield , $sortorder , 'center nowraponall ' );
}
if ( ! empty ( $arrayfields [ 'c.datef' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'c.datef' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " c.datef " , $param , " " , '' , $sortfield , $sortorder , 'center nowraponall ' );
}
if ( ! empty ( $arrayfields [ 'd.amount' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'd.amount' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " c.subscription " , $param , " " , '' , $sortfield , $sortorder , 'right ' );
}
2020-02-10 16:01:09 +01:00
2018-12-09 23:41:36 +01:00
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php' ;
// Hook fields
2019-11-13 19:35:39 +01:00
$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
2018-12-09 23:41:36 +01:00
print $hookmanager -> resPrint ;
2021-03-01 00:19:52 +01:00
if ( ! empty ( $arrayfields [ 'c.datec' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'c.datec' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " c.datec " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'c.tms' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'c.tms' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " c.tms " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
}
2019-02-18 19:14:25 +01:00
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], '' , '' , '' , 'align="center"' , $sortfield , $sortorder , 'maxwidthsearch ' );
2018-12-09 23:41:36 +01:00
print " </tr> \n " ;
2019-11-13 19:35:39 +01:00
$totalarray = array ();
2021-05-25 23:20:55 +02:00
$totalarray [ 'nbfield' ] = 0 ;
2020-05-21 09:12:18 +02:00
while ( $i < min ( $num , $limit )) {
2018-12-09 23:41:36 +01:00
$obj = $db -> fetch_object ( $result );
2017-08-02 13:31:53 +02:00
2019-11-13 19:35:39 +01:00
$subscription -> ref = $obj -> crowid ;
$subscription -> id = $obj -> crowid ;
2020-11-23 12:29:38 +01:00
$subscription -> dateh = $db -> jdate ( $obj -> dateadh );
$subscription -> datef = $db -> jdate ( $obj -> datef );
2017-08-02 13:31:53 +02:00
2019-11-13 19:35:39 +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 ;
2020-10-26 21:51:17 +01:00
$adherent -> gender = $obj -> gender ;
$adherent -> morphy = $obj -> morphy ;
$adherent -> email = $obj -> email ;
2021-07-26 15:29:46 +02:00
$adherent -> typeid = $obj -> fk_type ;
2021-03-26 18:16:12 +01:00
$adherent -> datefin = $db -> jdate ( $obj -> datef );
2019-02-03 14:29:45 +01:00
2019-06-25 11:18:31 +02:00
$typeid = ( $obj -> fk_type > 0 ? $obj -> fk_type : $adherent -> typeid );
2020-10-31 14:32:18 +01:00
$adht = new AdherentType ( $db );
$adht -> fetch ( $typeid );
2005-09-06 18:47:39 +02:00
2021-03-26 18:16:12 +01:00
$adherent -> need_subscription = $adht -> subscription ;
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
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'd.ref' ][ 'checked' ])) {
2018-12-09 23:41:36 +01:00
print '<td>' . $subscription -> getNomUrl ( 1 ) . '</td>' ;
2021-03-01 00:19:52 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2018-12-09 23:41:36 +01:00
}
2020-10-31 14:32:18 +01:00
// Type
if ( ! empty ( $arrayfields [ 'd.fk_type' ][ 'checked' ])) {
print '<td class="nowraponall">' ;
if ( $typeid > 0 ) {
print $adht -> getNomUrl ( 1 );
}
print '</td>' ;
2021-03-01 00:19:52 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2019-01-17 17:36:14 +01:00
}
2017-08-02 13:31:53 +02:00
2018-12-09 23:41:36 +01:00
// Lastname
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'd.lastname' ][ 'checked' ])) {
2021-05-27 14:47:06 +02:00
print '<td class="tdoverflowmax150">' . $adherent -> getNomUrl ( - 1 , 0 , 'card' , 'lastname' ) . '</td>' ;
2021-03-01 00:19:52 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2018-12-09 23:41:36 +01:00
}
// Firstname
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'd.firstname' ][ 'checked' ])) {
2020-04-05 12:11:58 +02:00
print '<td class="tdoverflowmax150" title="' . dol_escape_htmltag ( $adherent -> firstname ) . '">' . $adherent -> firstname . '</td>' ;
2021-03-01 00:19:52 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2018-12-09 23:41:36 +01:00
}
2007-05-28 15:14:50 +02:00
2018-12-09 23:41:36 +01:00
// Login
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'd.login' ][ 'checked' ])) {
2020-04-05 12:11:58 +02:00
print '<td class="tdoverflowmax150" title="' . dol_escape_htmltag ( $adherent -> login ) . '">' . $adherent -> login . '</td>' ;
2021-03-01 00:19:52 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2018-12-09 23:41:36 +01:00
}
2009-03-09 11:27:21 +01:00
2018-12-09 23:41:36 +01:00
// Label
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 't.libelle' ][ 'checked' ])) {
2021-05-27 14:45:16 +02:00
print '<td class="tdoverflowmax400" title="' . dol_escape_htmltag ( $obj -> note ) . '">' ;
2021-03-24 23:44:50 +01:00
print $obj -> note ;
2018-12-09 23:41:36 +01:00
print '</td>' ;
2021-03-01 00:19:52 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2018-12-09 23:41:36 +01:00
}
2010-08-29 17:25:39 +02:00
2018-12-09 23:41:36 +01:00
// Banque
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'd.bank' ][ 'checked' ])) {
2020-04-05 12:05:27 +02:00
print '<td class="tdmaxoverflow150">' ;
2020-05-21 09:12:18 +02:00
if ( $obj -> fk_account > 0 ) {
2019-11-13 19:35:39 +01:00
$accountstatic -> id = $obj -> fk_account ;
2018-12-09 23:41:36 +01:00
$accountstatic -> fetch ( $obj -> fk_account );
//$accountstatic->label=$obj->label;
print $accountstatic -> getNomUrl ( 1 );
}
print " </td> \n " ;
2021-03-01 00:19:52 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2018-12-09 23:41:36 +01:00
}
2010-08-29 17:25:39 +02:00
2018-12-09 23:41:36 +01:00
// Date start
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'c.dateadh' ][ 'checked' ])) {
2019-03-19 13:57:08 +01:00
print '<td class="center">' . dol_print_date ( $db -> jdate ( $obj -> dateadh ), 'day' ) . " </td> \n " ;
2021-03-01 00:19:52 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2018-12-09 23:41:36 +01:00
}
// Date end
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'c.datef' ][ 'checked' ])) {
2019-03-19 13:57:08 +01:00
print '<td class="center">' . dol_print_date ( $db -> jdate ( $obj -> datef ), 'day' ) . " </td> \n " ;
2021-03-01 00:19:52 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2018-12-09 23:41:36 +01:00
}
// Price
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'd.amount' ][ 'checked' ])) {
2021-03-24 23:44:50 +01:00
print '<td class="right amount">' . price ( $obj -> subscription ) . '</td>' ;
2021-03-01 00:19:52 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 'd.amount' ;
}
2022-07-24 18:59:07 +02:00
if ( empty ( $totalarray [ 'val' ][ 'd.amount' ])) {
$totalarray [ 'val' ][ 'd.amount' ] = $obj -> subscription ;
} else {
$totalarray [ 'val' ][ 'd.amount' ] += $obj -> subscription ;
}
2018-12-09 23:41:36 +01:00
}
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php' ;
// Fields from hook
2020-05-08 01:40:25 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'obj' => $obj , 'i' => $i , 'totalarray' =>& $totalarray );
2019-11-13 19:35:39 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters ); // Note that $action and $object may have been modified by hook
2018-12-09 23:41:36 +01:00
print $hookmanager -> resPrint ;
// Date creation
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'c.datec' ][ 'checked' ])) {
2019-03-19 13:57:08 +01:00
print '<td class="nowrap center">' ;
2018-12-09 23:41:36 +01:00
print dol_print_date ( $db -> jdate ( $obj -> date_creation ), 'dayhour' , 'tzuser' );
print '</td>' ;
2021-03-01 00:19:52 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2018-12-09 23:41:36 +01:00
}
// Date modification
2020-05-21 09:12:18 +02:00
if ( ! empty ( $arrayfields [ 'c.tms' ][ 'checked' ])) {
2019-03-19 13:57:08 +01:00
print '<td class="nowrap center">' ;
2018-12-09 23:41:36 +01:00
print dol_print_date ( $db -> jdate ( $obj -> date_update ), 'dayhour' , 'tzuser' );
print '</td>' ;
2021-03-01 00:19:52 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2018-12-09 23:41:36 +01:00
}
// Action column
2019-03-19 13:57:08 +01:00
print '<td class="center">' ;
2020-05-21 09:12:18 +02:00
if ( $massactionbutton || $massaction ) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2019-11-13 19:35:39 +01:00
$selected = 0 ;
2022-05-31 17:38:23 +02:00
if ( in_array ( $obj -> crowid , $arrayofselected )) {
2021-03-01 00:19:52 +01:00
$selected = 1 ;
}
2022-05-31 17:38:23 +02:00
print '<input id="cb' . $obj -> crowid . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj -> crowid . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
2018-12-09 23:41:36 +01:00
}
print '</td>' ;
2021-03-01 00:19:52 +01:00
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
2019-11-05 12:47:38 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/list_print_total.tpl.php' ;
2007-09-09 12:43:26 +02:00
2018-12-09 23:41:36 +01:00
// If no record found
2020-05-21 09:12:18 +02:00
if ( $num == 0 ) {
2019-11-13 19:35:39 +01:00
$colspan = 1 ;
2021-03-01 00:19:52 +01:00
foreach ( $arrayfields as $key => $val ) {
if ( ! empty ( $val [ 'checked' ])) {
$colspan ++ ;
}
}
2018-12-09 23:41:36 +01:00
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
2019-11-13 19:35:39 +01:00
$parameters = array ( 'sql' => $sql );
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters ); // Note that $action and $object may have been modified by hook
2018-12-09 23:41:36 +01:00
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 ();