dolibarr/htdocs/adherents/list.php

1258 lines
45 KiB
PHP
Raw Normal View History

<?php
2015-05-23 18:52:31 +02:00
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
2022-05-25 23:27:26 +02:00
* Copyright (C) 2004-2022 Laurent Destailleur <eldy@users.sourceforge.net>
2015-05-23 18:52:31 +02:00
* Copyright (C) 2013-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
2016-07-15 17:31:44 +02:00
* Copyright (C) 2014-2016 Juanjo Menent <jmenent@2byte.es>
2019-01-28 21:39:22 +01:00
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
2021-05-26 18:24:06 +02:00
* Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr>
*
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
* 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
*/
2009-02-01 14:47:37 +01:00
/**
2018-11-18 21:50:58 +01:00
* \file htdocs/adherents/list.php
* \ingroup member
* \brief Page to list all members of foundation
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
$langs->loadLangs(array("members", "companies"));
2017-06-09 17:02:05 +02:00
$action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int');
$confirm = GETPOST('confirm', 'alpha');
2017-06-09 17:02:05 +02:00
$toselect = GETPOST('toselect', 'array');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'memberslist'; // To manage different context of search
$search = GETPOST("search", 'alpha');
$search_ref = GETPOST("search_ref", 'alpha');
$search_lastname = GETPOST("search_lastname", 'alpha');
$search_firstname = GETPOST("search_firstname", 'alpha');
$search_gender = GETPOST("search_gender", 'alpha');
$search_civility = GETPOST("search_civility", 'alpha');
2020-03-31 17:54:48 +02:00
$search_company = GETPOST('search_company', 'alphanohtml');
$search_login = GETPOST("search_login", 'alpha');
$search_address = GETPOST("search_address", 'alpha');
$search_zip = GETPOST("search_zip", 'alpha');
$search_town = GETPOST("search_town", 'alpha');
$search_state = GETPOST("search_state", 'alpha');
$search_country = GETPOST("search_country", 'alpha');
$search_phone = GETPOST("search_phone", 'alpha');
$search_phone_perso = GETPOST("search_phone_perso", 'alpha');
$search_phone_mobile = GETPOST("search_phone_mobile", 'alpha');
$search_type = GETPOST("search_type", 'alpha');
$search_email = GETPOST("search_email", 'alpha');
$search_categ = GETPOST("search_categ", 'int');
$search_filter = GETPOST("search_filter", 'alpha');
$search_status = GETPOST("search_status", 'intcomma');
2022-05-25 23:27:26 +02:00
$search_import_key = trim(GETPOST("search_import_key", "alpha"));
$catid = GETPOST("catid", 'int');
$optioncss = GETPOST('optioncss', 'alpha');
2021-06-30 10:22:00 +02:00
$socid = GETPOST('socid', 'int');
$filter = GETPOST("filter", 'alpha');
2021-03-01 00:19:52 +01:00
if ($filter) {
$search_filter = $filter; // For backward compatibility
}
$statut = GETPOST("statut", 'alpha');
2021-03-01 00:19:52 +01:00
if ($statut != '') {
$search_status = $statut; // For backward compatibility
}
$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
2021-03-13 16:11:48 +01:00
if ($search_status < -2) {
2021-03-01 00:19:52 +01:00
$search_status = '';
}
$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');
$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
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
2021-03-01 00:19:52 +01:00
if (!$sortorder) {
$sortorder = ($filter == 'outofdate' ? "DESC" : "ASC");
}
if (!$sortfield) {
$sortfield = ($filter == 'outofdate' ? "d.datefin" : "d.lastname");
}
$object = new Adherent($db);
2018-12-09 23:41:36 +01:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('memberlist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
2019-09-28 10:55:09 +02:00
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array(
'd.ref'=>'Ref',
'd.login'=>'Login',
'd.lastname'=>'Lastname',
'd.firstname'=>'Firstname',
'd.login'=>'Login',
'd.societe'=>"Company",
'd.email'=>'EMail',
'd.address'=>'Address',
'd.zip'=>'Zip',
'd.town'=>'Town',
2020-04-10 10:50:15 +02:00
'd.phone'=>"Phone",
'd.phone_perso'=>"PhonePerso",
2020-04-10 13:00:46 +02:00
'd.phone_mobile'=>"PhoneMobile",
'd.note_public'=>'NotePublic',
'd.note_private'=>'NotePrivate',
);
2021-03-01 00:19:52 +01:00
if ($db->type == 'pgsql') {
unset($fieldstosearchall['d.rowid']);
}
$arrayfields = array(
'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
2018-09-04 11:49:11 +02:00
'd.civility'=>array('label'=>$langs->trans("Civility"), 'checked'=>0),
'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1),
'd.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1),
2018-11-18 21:50:58 +01:00
'd.gender'=>array('label'=>$langs->trans("Gender"), 'checked'=>0),
'd.company'=>array('label'=>$langs->trans("Company"), 'checked'=>1),
'd.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1),
2020-08-18 11:52:00 +02:00
'd.morphy'=>array('label'=>$langs->trans("MemberNature"), 'checked'=>1),
't.libelle'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
'd.email'=>array('label'=>$langs->trans("Email"), 'checked'=>1),
'd.address'=>array('label'=>$langs->trans("Address"), 'checked'=>0),
'd.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0),
'd.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0),
'd.phone'=>array('label'=>$langs->trans("Phone"), 'checked'=>0),
'd.phone_perso'=>array('label'=>$langs->trans("PhonePerso"), 'checked'=>0),
2016-05-13 19:24:55 +02:00
'd.phone_mobile'=>array('label'=>$langs->trans("PhoneMobile"), 'checked'=>0),
'state.nom'=>array('label'=>$langs->trans("State"), 'checked'=>0),
'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
/*'d.note_public'=>array('label'=>$langs->trans("NotePublic"), 'checked'=>0),
2018-09-04 11:49:11 +02:00
'd.note_private'=>array('label'=>$langs->trans("NotePrivate"), 'checked'=>0),*/
'd.datefin'=>array('label'=>$langs->trans("EndSubscription"), 'checked'=>1, 'position'=>500),
'd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
2019-06-10 10:10:16 +02:00
'd.birth'=>array('label'=>$langs->trans("Birthday"), 'checked'=>0, 'position'=>500),
'd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
2022-05-25 23:27:26 +02:00
'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
'd.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100),
);
// Extra fields
2020-12-23 19:14:47 +01:00
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
2021-03-19 13:02:55 +01:00
// Security check
$result = restrictedArea($user, 'adherent');
/*
* Actions
*/
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 = '';
}
2021-07-26 15:24:58 +02:00
$parameters = array('socid'=>isset($socid) ? $socid : null);
$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');
}
2020-05-21 09:12:18 +02:00
if (empty($reshook)) {
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
2020-05-21 09:12:18 +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
$statut = '';
$filter = '';
$search = "";
$search_ref = "";
$search_lastname = "";
$search_firstname = "";
$search_gender = "";
$search_civility = "";
$search_login = "";
$search_company = "";
$search_type = "";
$search_email = "";
$search_address = "";
$search_zip = "";
$search_town = "";
$search_state = "";
$search_country = '';
$search_phone = '';
$search_phone_perso = '';
$search_phone_mobile = '';
$search_morphy = "";
$search_categ = "";
$search_filter = "";
$search_status = "";
2022-05-25 23:27:26 +02:00
$search_import_key = '';
$catid = "";
$sall = "";
2022-05-08 18:25:22 +02:00
$toselect = array();
$search_array_options = array();
}
2019-05-18 17:04:37 +02:00
// Close
2020-05-21 09:12:18 +02:00
if ($massaction == 'close' && $user->rights->adherent->creer) {
$tmpmember = new Adherent($db);
$error = 0;
$nbclose = 0;
$db->begin();
foreach ($toselect as $idtoclose) {
$tmpmember->fetch($idtoclose);
$result = $tmpmember->resiliate($user);
if ($result < 0 && !count($tmpmember->errors)) {
setEventMessages($tmpmember->error, $tmpmember->errors, 'errors');
} else {
2021-03-01 00:19:52 +01:00
if ($result > 0) {
$nbclose++;
}
}
}
if (!$error) {
setEventMessages($langs->trans("XMembersClosed", $nbclose), null, 'mesgs');
$db->commit();
} else {
$db->rollback();
}
2019-05-18 16:25:45 +02:00
}
2019-05-18 17:04:37 +02:00
2021-04-19 14:19:32 +02:00
// Create external user
if ($massaction == 'createexternaluser' && $user->rights->adherent->creer && $user->rights->user->user->creer) {
$tmpmember = new Adherent($db);
$error = 0;
$nbcreated = 0;
$db->begin();
foreach ($toselect as $idtoclose) {
$tmpmember->fetch($idtoclose);
2021-04-19 15:23:36 +02:00
if (!empty($tmpmember->fk_soc)) {
2021-04-19 14:19:32 +02:00
$nuser = new User($db);
$tmpuser = dol_clone($tmpmember);
$result = $nuser->create_from_member($tmpuser, $tmpmember->login);
if ($result < 0 && !count($tmpmember->errors)) {
setEventMessages($tmpmember->error, $tmpmember->errors, 'errors');
} else {
if ($result > 0) {
$nbcreated++;
}
}
}
}
if (!$error) {
setEventMessages($langs->trans("XExternalUserCreated", $nbcreated), null, 'mesgs');
$db->commit();
} else {
$db->rollback();
}
}
// Mass actions
$objectclass = 'Adherent';
$objectlabel = 'Members';
$permissiontoread = $user->rights->adherent->lire;
$permissiontodelete = $user->rights->adherent->supprimer;
$permissiontoadd = $user->rights->adherent->creer;
$uploaddir = $conf->adherent->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
2010-07-10 18:42:12 +02:00
/*
* View
*/
$form = new Form($db);
$formother = new FormOther($db);
$membertypestatic = new AdherentType($db);
$memberstatic = new Adherent($db);
2011-12-03 15:44:34 +01:00
2022-05-18 23:15:11 +02:00
$title = $langs->trans("Members");
$now = dol_now();
2022-02-26 19:15:40 +01:00
if ((!empty($search_categ) && $search_categ > 0) || !empty($catid)) {
2021-05-27 14:59:44 +02:00
$sql = "SELECT DISTINCT";
} else {
$sql = "SELECT";
}
$sql .= " d.rowid, d.ref, d.login, d.lastname, d.firstname, d.gender, d.societe as company, d.fk_soc,";
$sql .= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,";
$sql .= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.birth, d.public, d.photo,";
$sql .= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,";
2022-05-25 23:27:26 +02:00
$sql .= " d.note_private, d.note_public, d.import_key,";
2020-03-31 17:54:48 +02:00
$sql .= " s.nom,";
2021-08-30 18:57:41 +02:00
$sql .= " ".$db->ifsql("d.societe IS NULL", "s.nom", "d.societe")." as companyname,";
$sql .= " t.libelle as type, t.subscription,";
$sql .= " state.code_departement as state_code, state.nom as state_name,";
2017-06-09 17:02:05 +02:00
// Add fields from extrafields
2021-03-01 00:19:52 +01:00
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
2021-08-27 22:42:04 +02:00
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key." as options_".$key.', ' : '');
2021-03-01 00:19:52 +01:00
}
}
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
2021-05-26 18:24:06 +02:00
if (!empty($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)";
}
if ((!empty($search_categ) && ($search_categ > 0 || $search_categ == -2)) || !empty($catid)) {
// We need this table joined to the select in order to filter by categ
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member";
}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)";
2020-03-31 17:54:48 +02:00
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on (s.rowid = d.fk_soc)";
$sql .= ", ".MAIN_DB_PREFIX."adherent_type as t";
2021-05-27 14:59:44 +02:00
$sql .= " WHERE d.fk_adherent_type = t.rowid";
2021-03-01 00:19:52 +01:00
if ($catid > 0) {
2021-03-22 13:31:06 +01:00
$sql .= " AND cm.fk_categorie = ".((int) $catid);
2021-03-01 00:19:52 +01:00
}
if ($catid == -2) {
$sql .= " AND cm.fk_categorie IS NULL";
}
if ($search_categ > 0) {
2021-03-22 13:31:06 +01:00
$sql .= " AND cm.fk_categorie = ".((int) $search_categ);
2021-03-01 00:19:52 +01:00
}
if ($search_categ == -2) {
$sql .= " AND cm.fk_categorie IS NULL";
}
$sql .= " AND d.entity IN (".getEntity('adherent').")";
2021-03-01 00:19:52 +01:00
if ($sall) {
$sql .= natural_search(array_keys($fieldstosearchall), $sall);
}
if ($search_type > 0) {
2021-04-24 20:18:11 +02:00
$sql .= " AND t.rowid=".((int) $search_type);
2021-03-01 00:19:52 +01:00
}
if ($search_filter == 'withoutsubscription') {
$sql .= " AND (datefin IS NULL)";
2021-03-01 00:19:52 +01:00
}
if ($search_filter == 'uptodate') {
$sql .= " AND (datefin >= '".$db->idate($now)."' OR t.subscription = '0')";
2021-03-01 00:19:52 +01:00
}
if ($search_filter == 'outofdate') {
$sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = '1')";
2021-03-01 00:19:52 +01:00
}
if ($search_status != '') {
// Peut valoir un nombre ou liste de nombre separes par virgules
$sql .= " AND d.statut in (".$db->sanitize($db->escape($search_status)).")";
}
2020-05-21 09:12:18 +02:00
if ($search_ref) {
$sql .= natural_search("d.ref", $search_ref);
}
2021-03-01 00:19:52 +01:00
if ($search_civility) {
$sql .= natural_search("d.civility", $search_civility);
}
if ($search_firstname) {
$sql .= natural_search("d.firstname", $search_firstname);
}
if ($search_lastname) {
$sql .= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname);
}
if ($search_gender != '' && $search_gender != '-1') {
$sql .= natural_search("d.gender", $search_gender);
}
if ($search_login) {
$sql .= natural_search("d.login", $search_login);
}
if ($search_company) {
$sql .= natural_search("s.nom", $search_company);
}
if ($search_email) {
$sql .= natural_search("d.email", $search_email);
}
if ($search_address) {
$sql .= natural_search("d.address", $search_address);
}
if ($search_town) {
$sql .= natural_search("d.town", $search_town);
}
if ($search_zip) {
$sql .= natural_search("d.zip", $search_zip);
}
if ($search_state) {
$sql .= natural_search("state.nom", $search_state);
}
if ($search_phone) {
$sql .= natural_search("d.phone", $search_phone);
}
if ($search_phone_perso) {
$sql .= natural_search("d.phone_perso", $search_phone_perso);
}
if ($search_phone_mobile) {
$sql .= natural_search("d.phone_mobile", $search_phone_mobile);
}
if ($search_country) {
2021-03-22 11:30:18 +01:00
$sql .= " AND d.country IN (".$db->sanitize($search_country).')';
2021-03-01 00:19:52 +01:00
}
2022-05-25 23:27:26 +02:00
if ($search_import_key) {
$sql .= natural_search("d.import_key", $search_import_key);
}
// Add where from extra fields
2017-11-27 15:24:29 +01:00
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;
2010-07-10 18:42:12 +02:00
// Count total nb of records with no order and no limits
$nbtotalofrecords = '';
2020-05-21 09:12:18 +02:00
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$resql = $db->query($sql);
2021-03-01 00:19:52 +01:00
if ($resql) {
$nbtotalofrecords = $db->num_rows($resql);
} else {
dol_print_error($db);
}
2022-05-25 23:27:26 +02:00
2020-05-21 09:12:18 +02:00
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
$page = 0;
$offset = 0;
}
2022-05-25 23:27:26 +02:00
$db->free($resql);
}
// Complete request and execute it with limit
$sql .= $db->order($sortfield, $sortorder);
if ($limit) {
$sql .= $db->plimit($limit + 1, $offset);
2009-02-01 14:47:37 +01:00
}
2002-12-30 16:13:28 +01:00
$resql = $db->query($sql);
2020-05-21 09:12:18 +02:00
if (!$resql) {
dol_print_error($db);
exit;
}
2010-07-10 18:42:12 +02:00
$num = $db->num_rows($resql);
2010-07-10 18:42:12 +02:00
2022-05-25 23:27:26 +02:00
$arrayofselected = is_array($toselect) ? $toselect : array();
2017-04-11 09:55:45 +02:00
2020-05-21 09:12:18 +02: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/card.php?id='.$id);
exit;
}
2010-07-10 18:42:12 +02:00
2022-05-25 23:27:26 +02:00
$help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
llxHeader('', $title, $help_url);
if (GETPOSTISSET("search_status")) {
2021-06-14 12:41:32 +02:00
if ($search_status == '-1,1') { // TODO : check this test as -1 == Adherent::STATUS_DRAFT and -2 == Adherent::STATUS_EXLCUDED
2022-05-18 23:15:11 +02:00
$title = $langs->trans("MembersListQualified");
2021-03-01 00:19:52 +01:00
}
2021-06-14 12:41:32 +02:00
if ($search_status == Adherent::STATUS_DRAFT) {
2022-05-18 23:15:11 +02:00
$title = $langs->trans("MembersListToValid");
2021-03-01 00:19:52 +01:00
}
2021-06-14 12:41:32 +02:00
if ($search_status == Adherent::STATUS_VALIDATED && $filter == '') {
2022-05-18 23:15:11 +02:00
$title = $langs->trans("MenuMembersValidated");
2021-03-01 00:19:52 +01:00
}
2021-06-14 12:41:32 +02:00
if ($search_status == Adherent::STATUS_VALIDATED && $filter == 'withoutsubscription') {
2022-05-18 23:15:11 +02:00
$title = $langs->trans("MembersWithSubscriptionToReceive");
2021-03-01 00:19:52 +01:00
}
2021-06-14 12:41:32 +02:00
if ($search_status == Adherent::STATUS_VALIDATED && $filter == 'uptodate') {
2022-05-18 23:15:11 +02:00
$title = $langs->trans("MembersListUpToDate");
2021-03-01 00:19:52 +01:00
}
2021-06-14 12:41:32 +02:00
if ($search_status == Adherent::STATUS_VALIDATED && $filter == 'outofdate') {
2022-05-18 23:15:11 +02:00
$title = $langs->trans("MembersListNotUpToDate");
2021-03-01 00:19:52 +01:00
}
2021-08-30 19:21:52 +02:00
if ((string) $search_status == (string) Adherent::STATUS_RESILIATED) { // The cast to string is required to have test false when search_status is ''
2022-05-18 23:15:11 +02:00
$title = $langs->trans("MembersListResiliated");
2021-03-01 00:19:52 +01:00
}
2021-06-14 12:41:32 +02:00
if ($search_status == Adherent::STATUS_EXCLUDED) {
2022-05-18 23:15:11 +02:00
$title = $langs->trans("MembersListExcluded");
2021-03-13 16:11:48 +01:00
}
2020-05-21 09:21:30 +02:00
} elseif ($action == 'search') {
2022-05-18 23:15:11 +02:00
$title = $langs->trans("MembersListQualified");
}
2020-05-21 09:12:18 +02:00
if ($search_type > 0) {
$membertype = new AdherentType($db);
2022-04-07 18:16:06 +02:00
$result = $membertype->fetch($search_type);
2022-05-18 23:15:11 +02:00
$title .= " (".$membertype->label.")";
}
$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 ($sall != "") {
$param .= "&sall=".urlencode($sall);
}
if ($search_ref) {
$param .= "&search_ref=".urlencode($search_ref);
}
if ($search_civility) {
$param .= "&search_civility=".urlencode($search_civility);
}
if ($search_firstname) {
$param .= "&search_firstname=".urlencode($search_firstname);
}
if ($search_lastname) {
$param .= "&search_lastname=".urlencode($search_lastname);
}
if ($search_gender) {
$param .= "&search_gender=".urlencode($search_gender);
}
if ($search_login) {
$param .= "&search_login=".urlencode($search_login);
}
if ($search_email) {
$param .= "&search_email=".urlencode($search_email);
}
2022-02-26 19:15:40 +01:00
if ($search_categ > 0 || $search_categ == -2) {
2021-03-01 00:19:52 +01:00
$param .= "&search_categ=".urlencode($search_categ);
}
if ($search_company) {
$param .= "&search_company=".urlencode($search_company);
}
if ($search_address != '') {
$param .= "&search_address=".urlencode($search_address);
}
if ($search_town != '') {
$param .= "&search_town=".urlencode($search_town);
}
if ($search_zip != '') {
$param .= "&search_zip=".urlencode($search_zip);
}
if ($search_state != '') {
$param .= "&search_state=".urlencode($search_state);
}
if ($search_country != '') {
$param .= "&search_country=".urlencode($search_country);
}
if ($search_phone != '') {
$param .= "&search_phone=".urlencode($search_phone);
}
if ($search_phone_perso != '') {
$param .= "&search_phone_perso=".urlencode($search_phone_perso);
}
if ($search_phone_mobile != '') {
$param .= "&search_phone_mobile=".urlencode($search_phone_mobile);
}
if ($search_filter && $search_filter != '-1') {
$param .= "&search_filter=".urlencode($search_filter);
}
2022-02-26 19:15:40 +01:00
if ($search_status != "" && $search_status != -3) {
2021-03-01 00:19:52 +01:00
$param .= "&search_status=".urlencode($search_status);
}
2022-05-25 23:27:26 +02:00
if ($search_import_key != '') {
$param .= '&search_import_key='.urlencode($search_import_key);
}
2021-03-01 00:19:52 +01:00
if ($search_type > 0) {
$param .= "&search_type=".urlencode($search_type);
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
// Add $param from extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
2017-04-11 09:55:45 +02:00
// List of mass actions available
$arrayofmassactions = array(
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
2021-04-14 14:45:55 +02:00
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
2017-04-11 09:55:45 +02:00
);
2021-03-01 00:19:52 +01:00
if ($user->rights->adherent->creer) {
2021-04-14 12:28:01 +02:00
$arrayofmassactions['close'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Resiliate");
2021-03-01 00:19:52 +01:00
}
if ($user->rights->adherent->supprimer) {
2021-04-14 12:28:01 +02:00
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
2021-03-01 00:19:52 +01:00
}
if (isModEnabled('category') && $user->rights->adherent->creer) {
2021-04-14 12:33:53 +02:00
$arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
2021-03-01 00:19:52 +01:00
}
2021-04-19 14:19:32 +02:00
if ($user->rights->adherent->creer && $user->rights->user->user->creer) {
$arrayofmassactions['createexternaluser'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("CreateExternalUser");
}
2022-05-25 23:27:26 +02:00
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) {
2021-03-01 00:19:52 +01:00
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$newcardbutton = '';
2020-05-21 09:12:18 +02:00
if ($user->rights->adherent->creer) {
$newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create');
}
2017-06-09 17:02:05 +02: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-01 10:20:11 +01:00
print '<input type="hidden" name="token" value="'.newToken().'">';
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.'">';
2017-04-11 09:55:45 +02:00
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
2022-05-18 23:15:11 +02:00
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
$topicmail = "Information";
$modelmail = "member";
$objecttmp = new Adherent($db);
$trackid = 'mem'.$object->id;
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);
}
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
}
// Filter on categories
$moreforfilter = '';
if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$moreforfilter .= '<div class="divsearchfield">';
2021-02-15 20:13:38 +01:00
$moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedlength"').$formother->select_categories(Categorie::TYPE_MEMBER, $search_categ, 'search_categ', 1);
$moreforfilter .= '</div>';
}
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
2021-03-01 00:19:52 +01:00
if (empty($reshook)) {
$moreforfilter .= $hookmanager->resPrint;
} else {
$moreforfilter = $hookmanager->resPrint;
}
2020-05-21 09:12:18 +02:00
if (!empty($moreforfilter)) {
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
print '</div>';
}
$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);
}
2017-03-04 12:19:28 +01:00
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
2017-03-28 18:42:23 +02:00
// Line for filters fields
2017-03-28 18:42:23 +02:00
print '<tr class="liste_titre_filter">';
// Line numbering
2020-05-21 09:12:18 +02:00
if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
print '<td class="liste_titre">&nbsp;</td>';
}
// Ref
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.ref']['checked'])) {
print '<td class="liste_titre">';
2019-03-15 20:23:34 +01:00
print '<input class="flat maxwidth75imp" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
}
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.civility']['checked'])) {
2019-03-19 14:12:12 +01:00
print '<td class="liste_titre left">';
2019-03-15 20:23:34 +01:00
print '<input class="flat maxwidth50imp" type="text" name="search_civility" value="'.dol_escape_htmltag($search_civility).'"></td>';
2018-09-04 11:49:11 +02:00
}
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.firstname']['checked'])) {
2019-03-19 14:12:12 +01:00
print '<td class="liste_titre left">';
2019-03-15 20:23:34 +01:00
print '<input class="flat maxwidth75imp" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'"></td>';
}
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.lastname']['checked'])) {
2019-03-19 14:12:12 +01:00
print '<td class="liste_titre left">';
2019-03-15 20:23:34 +01:00
print '<input class="flat maxwidth75imp" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'"></td>';
}
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.gender']['checked'])) {
2018-11-18 21:50:58 +01:00
print '<td class="liste_titre">';
2020-09-16 01:09:54 +02:00
$arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother"));
2018-11-18 21:50:58 +01:00
print $form->selectarray('search_gender', $arraygender, $search_gender, 1);
print '</td>';
}
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.company']['checked'])) {
2019-03-19 14:12:12 +01:00
print '<td class="liste_titre left">';
2019-03-15 20:23:34 +01:00
print '<input class="flat maxwidth75imp" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'"></td>';
}
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.login']['checked'])) {
2019-03-19 14:12:12 +01:00
print '<td class="liste_titre left">';
2019-03-15 20:23:34 +01:00
print '<input class="flat maxwidth75imp" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'"></td>';
}
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.morphy']['checked'])) {
2019-03-19 14:12:12 +01:00
print '<td class="liste_titre left">';
print '</td>';
}
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['t.libelle']['checked'])) {
print '<td class="liste_titre">';
$listetype = $membertypestatic->liste_array();
print $form->selectarray("search_type", $listetype, $search_type, 1, 0, 0, '', 0, 32);
print '</td>';
}
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.address']['checked'])) {
2019-03-19 14:12:12 +01:00
print '<td class="liste_titre left">';
2020-09-19 20:11:04 +02:00
print '<input class="flat maxwidth75imp" type="text" name="search_address" value="'.dol_escape_htmltag($search_address).'"></td>';
}
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.zip']['checked'])) {
2019-03-19 14:12:12 +01:00
print '<td class="liste_titre left">';
2020-09-19 20:11:04 +02:00
print '<input class="flat maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>';
}
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.town']['checked'])) {
2019-03-19 14:12:12 +01:00
print '<td class="liste_titre left">';
2020-09-19 20:11:04 +02:00
print '<input class="flat maxwidth75imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
}
// State
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['state.nom']['checked'])) {
print '<td class="liste_titre">';
2019-03-15 20:23:34 +01:00
print '<input class="flat searchstring maxwidth75imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
print '</td>';
}
// Country
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['country.code_iso']['checked'])) {
2019-03-19 14:12:12 +01:00
print '<td class="liste_titre center">';
2019-03-02 12:57:07 +01:00
print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
print '</td>';
}
// Phone pro
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.phone']['checked'])) {
2019-03-19 14:12:12 +01:00
print '<td class="liste_titre left">';
2020-09-19 20:11:04 +02:00
print '<input class="flat maxwidth75imp" type="text" name="search_phone" value="'.dol_escape_htmltag($search_phone).'"></td>';
}
// Phone perso
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.phone_perso']['checked'])) {
2019-03-19 14:12:12 +01:00
print '<td class="liste_titre left">';
2020-09-19 20:11:04 +02:00
print '<input class="flat maxwidth50" type="text" name="search_phone_perso" value="'.dol_escape_htmltag($search_phone_perso).'"></td>';
}
// Phone mobile
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.phone_mobile']['checked'])) {
2019-03-19 14:12:12 +01:00
print '<td class="liste_titre left">';
2020-09-19 20:11:04 +02:00
print '<input class="flat maxwidth75imp" type="text" name="search_phone_mobile" value="'.dol_escape_htmltag($search_phone_mobile).'"></td>';
}
// Email
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.email']['checked'])) {
2019-03-19 14:12:12 +01:00
print '<td class="liste_titre left">';
2020-09-19 20:11:04 +02:00
print '<input class="flat maxwidth75imp" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'"></td>';
}
// End of subscription date
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.datefin']['checked'])) {
2022-04-07 18:16:06 +02:00
print '<td class="liste_titre center">';
$selectarray = array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate"));
print $form->selectarray('search_filter', $selectarray, $search_filter);
print '</td>';
}
// Extra fields
2017-11-27 15:24:29 +01:00
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
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.datec']['checked'])) {
print '<td class="liste_titre">';
print '</td>';
}
// Birthday
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.birth']['checked'])) {
2019-06-10 10:10:16 +02:00
print '<td class="liste_titre">';
print '</td>';
}
// Date modification
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.tms']['checked'])) {
print '<td class="liste_titre">';
print '</td>';
}
// Status
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.statut']['checked'])) {
2019-01-30 19:41:56 +01:00
print '<td class="liste_titre right maxwidthonsmartphone">';
$liststatus = array(
2021-06-14 12:41:32 +02:00
Adherent::STATUS_DRAFT => $langs->trans("Draft"),
Adherent::STATUS_VALIDATED => $langs->trans("Validated"),
Adherent::STATUS_RESILIATED => $langs->trans("MemberStatusResiliatedShort"),
Adherent::STATUS_EXCLUDED =>$langs->trans("MemberStatusExcludedShort")
);
2021-03-13 16:11:48 +01:00
print $form->selectarray('search_status', $liststatus, $search_status, -3);
print '</td>';
}
2022-05-25 23:27:26 +02:00
if (!empty($arrayfields['d.import_key']['checked'])) {
print '<td class="liste_titre center">';
print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
print '</td>';
}
if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
// Action column
print '<td class="liste_titre middle">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
}
print "</tr>\n";
2017-03-28 18:42:23 +02:00
print '<tr class="liste_titre">';
2022-05-25 23:27:26 +02:00
if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn ');
}
2021-03-01 00:19:52 +01:00
if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder);
}
if (!empty($arrayfields['d.ref']['checked'])) {
print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], 'd.ref', '', $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['d.civility']['checked'])) {
print_liste_field_titre($arrayfields['d.civility']['label'], $_SERVER["PHP_SELF"], 'd.civility', '', $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.lastname']['checked'])) {
print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], 'd.lastname', '', $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['d.gender']['checked'])) {
print_liste_field_titre($arrayfields['d.gender']['label'], $_SERVER['PHP_SELF'], 'd.gender', $param, "", "", $sortfield, $sortorder);
}
if (!empty($arrayfields['d.company']['checked'])) {
2021-08-30 18:57:41 +02:00
print_liste_field_titre($arrayfields['d.company']['label'], $_SERVER["PHP_SELF"], 'companyname', '', $param, '', $sortfield, $sortorder);
2021-03-01 00:19:52 +01:00
}
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['d.morphy']['checked'])) {
print_liste_field_titre($arrayfields['d.morphy']['label'], $_SERVER["PHP_SELF"], 'd.morphy', '', $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['t.libelle']['checked'])) {
print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], 't.libelle', '', $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['d.address']['checked'])) {
print_liste_field_titre($arrayfields['d.address']['label'], $_SERVER["PHP_SELF"], 'd.address', '', $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['d.zip']['checked'])) {
print_liste_field_titre($arrayfields['d.zip']['label'], $_SERVER["PHP_SELF"], 'd.zip', '', $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['d.town']['checked'])) {
print_liste_field_titre($arrayfields['d.town']['label'], $_SERVER["PHP_SELF"], 'd.town', '', $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['state.nom']['checked'])) {
print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['country.code_iso']['checked'])) {
2022-04-07 18:16:06 +02:00
print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
2021-03-01 00:19:52 +01:00
}
if (!empty($arrayfields['d.phone']['checked'])) {
print_liste_field_titre($arrayfields['d.phone']['label'], $_SERVER["PHP_SELF"], 'd.phone', '', $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['d.phone_perso']['checked'])) {
print_liste_field_titre($arrayfields['d.phone_perso']['label'], $_SERVER["PHP_SELF"], 'd.phone_perso', '', $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['d.phone_mobile']['checked'])) {
print_liste_field_titre($arrayfields['d.phone_mobile']['label'], $_SERVER["PHP_SELF"], 'd.phone_mobile', '', $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['d.email']['checked'])) {
print_liste_field_titre($arrayfields['d.email']['label'], $_SERVER["PHP_SELF"], 'd.email', '', $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['d.datefin']['checked'])) {
2022-04-07 18:16:06 +02:00
print_liste_field_titre($arrayfields['d.datefin']['label'], $_SERVER["PHP_SELF"], 'd.datefin', '', $param, '', $sortfield, $sortorder, 'center ');
2021-03-01 00:19:52 +01:00
}
2017-03-28 18:42:23 +02:00
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
2017-03-28 18:42:23 +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
2017-03-28 18:42:23 +02:00
print $hookmanager->resPrint;
2021-03-01 00:19:52 +01:00
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.birth']['checked'])) {
print_liste_field_titre($arrayfields['d.birth']['label'], $_SERVER["PHP_SELF"], "d.birth", "", $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);
}
if (!empty($arrayfields['d.statut']['checked'])) {
print_liste_field_titre($arrayfields['d.statut']['label'], $_SERVER["PHP_SELF"], "d.statut", "", $param, 'class="right"', $sortfield, $sortorder);
}
2022-05-25 23:27:26 +02:00
if (!empty($arrayfields['d.import_key']['checked'])) {
print_liste_field_titre($arrayfields['d.import_key']['label'], $_SERVER["PHP_SELF"], "d.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
}
2017-03-28 18:42:23 +02:00
print "</tr>\n";
$i = 0;
$totalarray = array();
2021-05-25 23:22:43 +02:00
$totalarray['nbfield'] = 0;
2020-05-21 09:12:18 +02:00
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
$datefin = $db->jdate($obj->datefin);
$memberstatic->id = $obj->rowid;
$memberstatic->ref = $obj->ref;
$memberstatic->civility_id = $obj->civility;
2021-08-30 19:13:02 +02:00
$memberstatic->login = $obj->login;
$memberstatic->lastname = $obj->lastname;
$memberstatic->firstname = $obj->firstname;
$memberstatic->gender = $obj->gender;
$memberstatic->statut = $obj->statut;
$memberstatic->datefin = $datefin;
$memberstatic->socid = $obj->fk_soc;
2017-04-05 14:48:24 +02:00
$memberstatic->photo = $obj->photo;
2020-10-26 21:51:17 +01:00
$memberstatic->email = $obj->email;
$memberstatic->morphy = $obj->morphy;
$memberstatic->note_public = $obj->note_public;
$memberstatic->note_private = $obj->note_private;
2017-06-09 17:02:05 +02:00
if (!empty($obj->fk_soc)) {
$memberstatic->fetch_thirdparty();
2021-08-30 18:38:31 +02:00
if ($memberstatic->thirdparty->id > 0) {
$companyname = $memberstatic->thirdparty->name;
$companynametoshow = $memberstatic->thirdparty->getNomUrl(1);
}
} else {
$companyname = $obj->company;
2021-08-30 18:38:31 +02:00
$companynametoshow = $obj->company;
}
$memberstatic->company = $companyname;
2017-04-05 14:48:24 +02:00
print '<tr class="oddeven">';
2017-06-09 17:02:05 +02:00
2020-05-21 09:12:18 +02:00
if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
2022-05-25 23:27:26 +02:00
print '<td class="center" data-key="id">'.$obj->rowid.'</td>';
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
}
// Ref
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.ref']['checked'])) {
2018-09-04 11:49:11 +02:00
print "<td>";
print $memberstatic->getNomUrl(-1, 0, 'card', 'ref', '', -1, 0, 1);
print "</td>\n";
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
2017-06-09 17:02:05 +02:00
}
2018-09-04 11:49:11 +02:00
// Civility
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.civility']['checked'])) {
2018-09-04 11:49:11 +02:00
print "<td>";
print $obj->civility;
print "</td>\n";
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
2018-09-04 11:49:11 +02:00
}
// Firstname
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.firstname']['checked'])) {
2021-05-27 14:57:16 +02:00
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->firstname).'">';
print $memberstatic->getNomUrl(0, 0, 'card', 'firstname');
2021-09-01 12:15:23 +02:00
//print $obj->firstname;
print "</td>\n";
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
2016-05-07 17:42:34 +02:00
}
// Lastname
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.lastname']['checked'])) {
2021-05-27 14:57:16 +02:00
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->lastname).'">';
2021-09-01 12:15:23 +02:00
print $memberstatic->getNomUrl(0, 0, 'card', 'lastname');
//print $obj->lastname;
print "</td>\n";
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
2016-05-07 17:42:34 +02:00
}
2018-11-18 21:50:58 +01:00
// Gender
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.gender']['checked'])) {
2018-11-18 21:50:58 +01:00
print '<td>';
2021-03-01 00:19:52 +01:00
if ($obj->gender) {
print $langs->trans("Gender".$obj->gender);
}
2018-11-18 21:50:58 +01:00
print '</td>';
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
2018-11-18 21:50:58 +01:00
}
// Company
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.company']['checked'])) {
2021-05-27 14:57:16 +02:00
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companyname).'">';
2021-08-30 18:38:31 +02:00
print $companynametoshow;
print "</td>\n";
2016-05-07 17:42:34 +02:00
}
// Login
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.login']['checked'])) {
2021-05-27 14:57:16 +02:00
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->login).'">'.$obj->login."</td>\n";
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
}
2020-08-18 11:52:00 +02:00
// Nature (Moral/Physical)
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.morphy']['checked'])) {
2020-08-18 11:52:00 +02:00
print '<td class="center">';
$s = '';
2020-10-26 21:51:17 +01:00
if ($obj->morphy == 'phy') {
2020-08-18 11:52:00 +02:00
$s .= '<span class="customer-back" title="'.$langs->trans("Physical").'">'.dol_substr($langs->trans("Physical"), 0, 1).'</span>';
}
2020-10-26 21:51:17 +01:00
if ($obj->morphy == 'mor') {
2020-08-18 11:52:00 +02:00
$s .= '<span class="vendor-back" title="'.$langs->trans("Moral").'">'.dol_substr($langs->trans("Moral"), 0, 1).'</span>';
}
print $s;
print "</td>\n";
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
2016-05-07 17:42:34 +02:00
}
// Type label
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['t.libelle']['checked'])) {
$membertypestatic->id = $obj->type_id;
$membertypestatic->label = $obj->type;
2021-05-27 14:57:16 +02:00
print '<td class="nowraponall">';
print $membertypestatic->getNomUrl(1, 32);
2016-05-07 17:42:34 +02:00
print '</td>';
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
2016-05-07 17:42:34 +02:00
}
// Address
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.address']['checked'])) {
2021-05-27 14:57:16 +02:00
print '<td class="nocellnopadd tdoverflowmax200" title="'.dol_escape_htmltag($obj->address).'">';
print $obj->address;
print '</td>';
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
2016-05-07 17:42:34 +02:00
}
// Zip
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.zip']['checked'])) {
print '<td class="nocellnopadd">';
print $obj->zip;
print '</td>';
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
2016-05-07 17:42:34 +02:00
}
// Town
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.town']['checked'])) {
print '<td class="nocellnopadd">';
print $obj->town;
print '</td>';
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
2016-05-07 17:42:34 +02:00
}
// State
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['state.nom']['checked'])) {
print "<td>".$obj->state_name."</td>\n";
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
}
// Country
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['country.code_iso']['checked'])) {
$tmparray = getCountry($obj->country, 'all');
2022-09-02 12:34:34 +02:00
print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($tmparray['label']).'">';
print dol_escape_htmltag($tmparray['label']);
print '</td>';
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
}
// Phone pro
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.phone']['checked'])) {
print '<td class="nocellnopadd">';
print $obj->phone;
print '</td>';
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
}
// Phone perso
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.phone_perso']['checked'])) {
print '<td class="nocellnopadd">';
print $obj->phone_perso;
print '</td>';
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
}
2016-05-13 19:24:55 +02:00
// Phone mobile
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.phone_mobile']['checked'])) {
print '<td class="nocellnopadd">';
print $obj->phone_mobile;
print '</td>';
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
2016-05-13 19:24:55 +02:00
}
// EMail
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.email']['checked'])) {
2021-09-01 12:15:23 +02:00
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->email).'">';
print dol_print_email($obj->email, 0, 0, 1, 64, 1, 1);
print "</td>\n";
2016-05-07 17:42:34 +02:00
}
// End of subscription date
$datefin = $db->jdate($obj->datefin);
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.datefin']['checked'])) {
2022-04-07 18:16:06 +02:00
print '<td class="nowrap center">';
2020-05-21 09:12:18 +02:00
if ($datefin) {
print dol_print_date($datefin, 'day');
if ($memberstatic->hasDelay()) {
2021-05-26 18:24:06 +02:00
$textlate = ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24).' '.$langs->trans("days").')';
2017-02-07 00:45:14 +01:00
print " ".img_warning($langs->trans("SubscriptionLate").$textlate);
}
2020-05-21 00:47:16 +02:00
} else {
if (!empty($obj->subscription)) {
print $langs->trans("SubscriptionNotReceived");
2021-03-01 00:19:52 +01:00
if ($obj->statut > 0) {
print " ".img_warning();
}
2020-05-21 00:47:16 +02:00
} else {
print '&nbsp;';
}
}
2022-04-07 18:16:06 +02:00
print '</td>';
2016-05-07 17:42:34 +02:00
}
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.datec']['checked'])) {
2019-03-19 14:12:12 +01:00
print '<td class="nowrap center">';
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']++;
}
}
2019-06-10 10:10:16 +02:00
// Birth
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.birth']['checked'])) {
2019-06-10 10:10:16 +02:00
print '<td class="nowrap center">';
print dol_print_date($db->jdate($obj->birth), 'day', 'tzuser');
print '</td>';
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
2019-06-10 10:10:16 +02:00
}
// Date modification
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.tms']['checked'])) {
2019-03-19 14:12:12 +01:00
print '<td class="nowrap center">';
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']++;
}
}
// Status
2020-05-21 09:12:18 +02:00
if (!empty($arrayfields['d.statut']['checked'])) {
2019-01-30 19:41:56 +01:00
print '<td class="nowrap right">';
print $memberstatic->LibStatut($obj->statut, $obj->subscription, $datefin, 5);
print '</td>';
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
}
2022-05-25 23:27:26 +02:00
if (!empty($arrayfields['d.import_key']['checked'])) {
2022-05-25 23:43:16 +02:00
print '<td class="tdoverflowmax100 center" title="'.dol_escape_htmltag($obj->import_key).'">';
print dol_escape_htmltag($obj->import_key);
2022-05-25 23:27:26 +02:00
print "</td>\n";
if (!$i) {
$totalarray['nbfield']++;
}
}
// Action column
2022-05-25 23:27:26 +02:00
if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
print '<td class="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"' : '').'>';
2021-03-01 00:19:52 +01:00
}
2022-05-25 23:27:26 +02:00
print '</td>';
}
2021-03-01 00:19:52 +01:00
if (!$i) {
$totalarray['nbfield']++;
}
2017-06-09 17:02:05 +02:00
2022-05-25 23:27:26 +02:00
print '</tr>'."\n";
$i++;
}
2007-05-02 00:35:14 +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';
2018-12-09 23:41:36 +01:00
// If no record found
2020-05-21 09:12:18 +02:00
if ($num == 0) {
$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>';
}
$db->free($resql);
$parameters = array('sql' => $sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print "</table>\n";
print "</div>";
print '</form>';
2018-07-28 14:29:28 +02:00
// End of page
llxFooter();
$db->close();