Ajout filtre categ sur adherent

This commit is contained in:
Laurent Destailleur 2010-07-10 16:42:12 +00:00
parent 6c6e98f8bb
commit b9f28cca65
2 changed files with 182 additions and 150 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -26,6 +26,7 @@
*/ */
require("../main.inc.php"); 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.class.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php");
@ -57,9 +58,14 @@ if ($_REQUEST["button_removefilter"])
$_REQUEST["type"]=""; $_REQUEST["type"]="";
$_GET["search_email"]=""; $_GET["search_email"]="";
$_REQUEST["search_email"]=""; $_REQUEST["search_email"]="";
$_GET["search_categ"]="";
$_REQUEST["search_categ"]="";
$sall=""; $sall="";
} }
// Load categ filters
$search_categ = isset($_GET["search_categ"])?$_GET["search_categ"]:$_POST["search_categ"];
/* /*
* View * View
@ -68,6 +74,9 @@ if ($_REQUEST["button_removefilter"])
llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros'); llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
$form=new Form($db); $form=new Form($db);
$htmlother=new FormOther($db);
$now=dol_now();
$membertypestatic=new AdherentType($db); $membertypestatic=new AdherentType($db);
@ -76,7 +85,9 @@ $sql.= " d.datefin,";
$sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
$sql.= " t.libelle as type, t.cotisation"; $sql.= " t.libelle as type, t.cotisation";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_member as cf";
$sql.= " WHERE d.fk_adherent_type = t.rowid "; $sql.= " WHERE d.fk_adherent_type = t.rowid ";
if ($search_categ) $sql.= " AND d.rowid = cf.fk_member"; // Join for the needed table to filter by categ
$sql.= " AND d.entity = ".$conf->entity; $sql.= " AND d.entity = ".$conf->entity;
if ($sall) if ($sall)
{ {
@ -94,7 +105,8 @@ if (isset($_GET["statut"]))
} }
if ( $_POST["action"] == 'search') if ( $_POST["action"] == 'search')
{ {
if (isset($_POST['search']) && $_POST['search'] != ''){ if (isset($_POST['search']) && $_POST['search'] != '')
{
$sql.= " AND (d.prenom LIKE '%".$_POST['search']."%' OR d.nom LIKE '%".$_POST['search']."%')"; $sql.= " AND (d.prenom LIKE '%".$_POST['search']."%' OR d.nom LIKE '%".$_POST['search']."%')";
} }
} }
@ -112,13 +124,19 @@ if ($_GET["search_email"])
} }
if ($filter == 'uptodate') if ($filter == 'uptodate')
{ {
$sql.=" AND datefin >= ".$db->idate(mktime()); $sql.=" AND datefin >= ".$db->idate($now);
} }
if ($filter == 'outofdate') if ($filter == 'outofdate')
{ {
$sql.=" AND datefin < ".$db->idate(mktime()); $sql.=" AND datefin < ".$db->idate($now);
} }
// Count total nb of records // Insert categ filter
if ($search_categ)
{
$sql.= " AND cf.fk_categorie = ".addslashes($search_categ);
}
// Count total nb of records with no order and no limits
$nbtotalofrecords = 0; $nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
@ -127,8 +145,8 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
else dol_print_error($db); else dol_print_error($db);
} }
// Add order and limit // Add order and limit
$sql.= " ".$db->order($sortfield,$sortorder); $sql.= $db->order($sortfield,$sortorder);
$sql.= " ".$db->plimit($conf->liste_limit+1, $offset); $sql.= $db->plimit($conf->liste_limit+1, $offset);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
@ -146,7 +164,8 @@ if ($resql)
if ($statut == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); } if ($statut == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); }
if ($statut == '0') { $titre=$langs->trans("MembersListResiliated"); } if ($statut == '0') { $titre=$langs->trans("MembersListResiliated"); }
} }
elseif ($_POST["action"] == 'search') { elseif ($_POST["action"] == 'search')
{
$titre=$langs->trans("MembersListQualified"); $titre=$langs->trans("MembersListQualified");
} }
@ -170,8 +189,25 @@ if ($resql)
print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall; print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall;
} }
print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
print "<table class=\"noborder\" width=\"100%\">"; print "<table class=\"noborder\" width=\"100%\">";
// Filter on categories
$moreforfilter='';
if ($conf->categorie->enabled)
{
$moreforfilter.=$langs->trans('Categories'). ': ';
$moreforfilter.=$htmlother->select_categories(3,$search_categ,'search_categ');
$moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
}
if ($moreforfilter)
{
print '<tr class="liste_titre">';
print '<td class="liste_titre" colspan="8">';
print $moreforfilter;
print '</td></tr>';
}
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),"liste.php","d.nom",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),"liste.php","d.nom",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Login"),"liste.php","d.login",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Login"),"liste.php","d.login",$param,"","",$sortfield,$sortorder);
@ -184,7 +220,6 @@ if ($resql)
print "</tr>\n"; print "</tr>\n";
// Lignes des champs de filtre // Lignes des champs de filtre
print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';

View File

@ -21,7 +21,7 @@
/** /**
* \file htdocs/fourn/liste.php * \file htdocs/fourn/liste.php
* \ingroup fournisseur * \ingroup fournisseur
* \brief Page accueil de la zone fournisseurs * \brief Home page of supplier area
* \version $Id$ * \version $Id$
*/ */
@ -95,7 +95,6 @@ if ($search_categ)
{ {
$sql .= " AND cf.fk_categorie = ".addslashes($search_categ); $sql .= " AND cf.fk_categorie = ".addslashes($search_categ);
} }
// Count total nb of records // Count total nb of records
$nbtotalofrecords = 0; $nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
@ -103,7 +102,6 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
} }
$sql.= $db->order($sortfield,$sortorder); $sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($conf->liste_limit+1, $offset); $sql.= $db->plimit($conf->liste_limit+1, $offset);
@ -118,7 +116,7 @@ if ($resql)
print_barre_liste($langs->trans("ListOfSuppliers"), $page, "liste.php", $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords); print_barre_liste($langs->trans("ListOfSuppliers"), $page, "liste.php", $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords);
print '<form action="liste.php?cat='.$_GET["cat"].'" method="GET">'; print '<form action="liste.php" method="GET">';
print '<table class="liste" width="100%">'; print '<table class="liste" width="100%">';
// Filter on categories // Filter on categories
@ -132,7 +130,7 @@ if ($resql)
if ($moreforfilter) if ($moreforfilter)
{ {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre" colspan="9">'; print '<td class="liste_titre" colspan="6">';
print $moreforfilter; print $moreforfilter;
print '</td></tr>'; print '</td></tr>';
} }
@ -159,7 +157,6 @@ if ($resql)
print '<input class="flat" type="text" size="10" name="search_compta" value="'.$_GET["search_compta"].'">'; print '<input class="flat" type="text" size="10" name="search_compta" value="'.$_GET["search_compta"].'">';
print '</td>'; print '</td>';
print '<td class="liste_titre" colspan="2" align="right"><input class="liste_titre" type="image" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'"></td>'; print '<td class="liste_titre" colspan="2" align="right"><input class="liste_titre" type="image" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'"></td>';
print '</tr>'; print '</tr>';