New: [ task #454 ] Add "No category" into filters on category
This commit is contained in:
parent
eb79646315
commit
f31277401b
@ -41,7 +41,8 @@ $search_prenom=GETPOST("search_prenom");
|
||||
$search_login=GETPOST("search_login");
|
||||
$type=GETPOST("type");
|
||||
$search_email=GETPOST("search_email");
|
||||
$search_categ=GETPOST("search_categ");
|
||||
$search_categ = GETPOST("search_categ",'int');
|
||||
$catid = GETPOST("catid",'int');
|
||||
$sall=GETPOST("sall");
|
||||
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
@ -64,6 +65,7 @@ if (GETPOST("button_removefilter"))
|
||||
$type="";
|
||||
$search_email="";
|
||||
$search_categ="";
|
||||
$catid="";
|
||||
$sall="";
|
||||
}
|
||||
|
||||
@ -86,10 +88,14 @@ $sql = "SELECT d.rowid, d.login, d.nom as lastname, d.prenom as firstname, d.soc
|
||||
$sql.= " d.datefin,";
|
||||
$sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
|
||||
$sql.= " t.libelle as type, t.cotisation";
|
||||
$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.= " FROM ".MAIN_DB_PREFIX."adherent as d";
|
||||
if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; // We need this table joined to the select in order to filter by categ
|
||||
$sql.= ", ".MAIN_DB_PREFIX."adherent_type as t";
|
||||
$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
|
||||
if ($catid > 0) $sql.= " AND cm.fk_categorie = ".$catid;
|
||||
if ($catid == -2) $sql.= " AND cm.fk_categorie IS NULL";
|
||||
if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$search_categ;
|
||||
if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL";
|
||||
$sql.= " AND d.entity = ".$conf->entity;
|
||||
if ($sall)
|
||||
{
|
||||
@ -132,11 +138,6 @@ if ($filter == 'outofdate')
|
||||
{
|
||||
$sql.=" AND datefin < '".$db->idate($now)."'";
|
||||
}
|
||||
// Insert categ filter
|
||||
if ($search_categ)
|
||||
{
|
||||
$sql.= " AND cf.fk_categorie = ".$db->escape($search_categ);
|
||||
}
|
||||
|
||||
// Count total nb of records with no order and no limits
|
||||
$nbtotalofrecords = 0;
|
||||
@ -200,7 +201,7 @@ if ($resql)
|
||||
if ($conf->categorie->enabled)
|
||||
{
|
||||
$moreforfilter.=$langs->trans('Categories'). ': ';
|
||||
$moreforfilter.=$formother->select_categories(3,$search_categ,'search_categ');
|
||||
$moreforfilter.=$formother->select_categories(3,$search_categ,'search_categ',1);
|
||||
$moreforfilter.=' ';
|
||||
}
|
||||
if ($moreforfilter)
|
||||
|
||||
@ -268,7 +268,7 @@ if ($socid)
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
dol_fiche_end();
|
||||
|
||||
dol_htmloutput_mesg($mesg);
|
||||
|
||||
@ -328,7 +328,7 @@ else if ($id || $ref)
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
dol_fiche_end();
|
||||
|
||||
dol_htmloutput_mesg($mesg);
|
||||
|
||||
@ -409,7 +409,7 @@ else if ($id || $ref)
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
dol_fiche_end();
|
||||
|
||||
dol_htmloutput_mesg($mesg);
|
||||
|
||||
@ -482,6 +482,7 @@ function formCategory($db,$object,$typeid,$socid=0)
|
||||
foreach ($cats as $cat)
|
||||
{
|
||||
$ways = $cat->print_all_ways();
|
||||
|
||||
foreach ($ways as $way)
|
||||
{
|
||||
$var = ! $var;
|
||||
|
||||
@ -42,6 +42,8 @@ $search_nom = GETPOST("search_nom");
|
||||
$search_ville = GETPOST("search_ville");
|
||||
$search_departement = GETPOST("search_departement");
|
||||
$search_datec = GETPOST("search_datec");
|
||||
$search_categ = GETPOST("search_categ",'int');
|
||||
$catid = GETPOST("catid",'int');
|
||||
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
@ -165,25 +167,22 @@ $sql = "SELECT s.rowid, s.nom, s.ville, s.datec, s.datea, s.status as status,";
|
||||
$sql.= " st.libelle as stcomm, s.prefix_comm, s.fk_stcomm, s.fk_prospectlevel,";
|
||||
$sql.= " d.nom as departement";
|
||||
// Updated by Matelli
|
||||
// We'll need these fields in order to filter by sale (including the case where the user can only see his prospects)
|
||||
if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
// We'll need these fields in order to filter by categ
|
||||
if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_societe";
|
||||
if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_stcomm as st";
|
||||
// We'll need this table joined to the select in order to filter by sale
|
||||
if ($search_sale || !$user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
// We'll need this table joined to the select in order to filter by categ
|
||||
if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_societe as cs";
|
||||
if ($search_sale || !$user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d on (d.rowid = s.fk_departement)";
|
||||
if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_societe"; // We need this table joined to the select in order to filter by categ
|
||||
$sql.= " WHERE s.fk_stcomm = st.id";
|
||||
$sql.= " AND s.client IN (2, 3)";
|
||||
$sql.= ' AND s.entity IN ('.getEntity('societe', 1).')';
|
||||
if ($user->societe_id) $sql.= " AND s.rowid = " .$user->societe_id;
|
||||
if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
||||
if ($search_categ) $sql.= " AND s.rowid = cs.fk_societe"; // Join for the needed table to filter by categ
|
||||
if (isset($stcomm) && $stcomm != '') $sql.= " AND s.fk_stcomm=".$stcomm;
|
||||
|
||||
if ($catid > 0) $sql.= " AND cs.fk_categorie = ".$catid;
|
||||
if ($catid == -2) $sql.= " AND cs.fk_categorie IS NULL";
|
||||
if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ;
|
||||
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
|
||||
if ($search_nom) $sql .= " AND s.nom LIKE '%".$db->escape(strtolower($search_nom))."%'";
|
||||
if ($search_ville) $sql .= " AND s.ville LIKE '%".$db->escape(strtolower($search_ville))."%'";
|
||||
if ($search_departement) $sql .= " AND d.nom LIKE '%".$db->escape(strtolower($search_departement))."%'";
|
||||
@ -198,11 +197,6 @@ if ($search_sale)
|
||||
{
|
||||
$sql .= " AND sc.fk_user = ".$db->escape($search_sale);
|
||||
}
|
||||
// Insert categ filter
|
||||
if ($search_categ)
|
||||
{
|
||||
$sql .= " AND cs.fk_categorie = ".$db->escape($search_categ);
|
||||
}
|
||||
if ($socname)
|
||||
{
|
||||
$sql .= " AND s.nom LIKE '%".$db->escape($socname)."%'";
|
||||
@ -271,7 +265,7 @@ if ($resql)
|
||||
if ($conf->categorie->enabled)
|
||||
{
|
||||
$moreforfilter.=$langs->trans('Categories'). ': ';
|
||||
$moreforfilter.=$formother->select_categories(2,$search_categ,'search_categ');
|
||||
$moreforfilter.=$formother->select_categories(2,$search_categ,'search_categ',1);
|
||||
$moreforfilter.=' ';
|
||||
}
|
||||
// If the user can view prospects other than his'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user