From 1d17d990bd850f8c598aeea33dcbea00b5a2afc7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Dec 2012 17:42:23 +0100 Subject: [PATCH] Fix: Patch from antar3s: Re: Filter on company type in modSociete --- htdocs/societe/societe.php | 62 ++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/htdocs/societe/societe.php b/htdocs/societe/societe.php index 827b646bf13..f2a71d76f2b 100644 --- a/htdocs/societe/societe.php +++ b/htdocs/societe/societe.php @@ -46,10 +46,13 @@ $search_idprof1=trim(GETPOST('search_idprof1')); $search_idprof2=trim(GETPOST('search_idprof2')); $search_idprof3=trim(GETPOST('search_idprof3')); $search_idprof4=trim(GETPOST('search_idprof4')); +$search_idprof5=trim(GETPOST('search_idprof5')); +$search_idprof6=trim(GETPOST('search_idprof6')); $search_sale=trim(GETPOST("search_sale")); $search_categ=trim(GETPOST("search_categ")); $mode=GETPOST("mode"); $modesearch=GETPOST("mode_search"); +$search_type=trim(GETPOST('search_type')); $sortfield=GETPOST("sortfield",'alpha'); $sortorder=GETPOST("sortorder",'alpha'); @@ -107,6 +110,11 @@ if ($mode == 'search') { $sql .= " AND cs.fk_categorie = ".$search_categ; } + // Filter on type of thirdparty + if ($search_type > 0 && in_array($search_type,array('1,3','2,3'))) $sql .= " AND s.client IN (".$db->escape($search_type).")"; + if ($search_type > 0 && in_array($search_type,array('4'))) $sql .= " AND s.fournisseur = 1"; + if ($search_type == '0') $sql .= " AND s.client = 0 AND s.fournisseur = 0"; + $result=$db->query($sql); if ($result) { @@ -147,6 +155,7 @@ if (GETPOST("button_removefilter_x")) $search_idprof2=''; $search_idprof3=''; $search_idprof4=''; + $search_type=''; } if ($socname) @@ -187,13 +196,6 @@ if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = s if ($socid) $sql.= " AND s.rowid = ".$socid; 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 -// TODO $stcomm is not defined ! -/* -if (dol_strlen($stcomm)) -{ - $sql.= " AND s.fk_stcomm=".$stcomm; -} -*/ if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible // Insert sale filter if ($search_sale) @@ -227,27 +229,17 @@ if ($search_nom) $sql.= " OR s.url LIKE '%".$db->escape($search_nom)."%'"; $sql.= ")"; } - -if ($search_ville) -{ - $sql .= " AND s.ville LIKE '%".$db->escape($search_ville)."%'"; -} -if ($search_idprof1) -{ - $sql .= " AND s.siren LIKE '%".$db->escape($search_idprof1)."%'"; -} -if ($search_idprof2) -{ - $sql .= " AND s.siret LIKE '%".$db->escape($search_idprof2)."%'"; -} -if ($search_idprof3) -{ - $sql .= " AND s.ape LIKE '%".$db->escape($search_idprof3)."%'"; -} -if ($search_idprof4) -{ - $sql .= " AND s.idprof4 LIKE '%".$db->escape($search_idprof4)."%'"; -} +if ($search_ville) $sql .= " AND s.ville LIKE '%".$db->escape($search_ville)."%'"; +if ($search_idprof1) $sql .= " AND s.siren LIKE '%".$db->escape($search_idprof1)."%'"; +if ($search_idprof2) $sql .= " AND s.siret LIKE '%".$db->escape($search_idprof2)."%'"; +if ($search_idprof3) $sql .= " AND s.ape LIKE '%".$db->escape($search_idprof3)."%'"; +if ($search_idprof4) $sql .= " AND s.idprof4 LIKE '%".$db->escape($search_idprof4)."%'"; +if ($search_idprof5) $sql .= " AND s.idprof5 LIKE '%".$db->escape($search_idprof5)."%'"; +if ($search_idprof6) $sql .= " AND s.idprof6 LIKE '%".$db->escape($search_idprof6)."%'"; +// Filter on type of thirdparty +if ($search_type > 0 && in_array($search_type,array('1,3','2,3'))) $sql .= " AND s.client IN (".$db->escape($search_type).")"; +if ($search_type > 0 && in_array($search_type,array('4'))) $sql .= " AND s.fournisseur = 1"; +if ($search_type == '0') $sql .= " AND s.client = 0 AND s.fournisseur = 0"; //print $sql; // Count total nb of records @@ -361,8 +353,18 @@ if ($resql) print ''; print ''; print ''; - // Type (customer/prospect/supplier) - print ''; + // Type (customer/prospect/supplier) + print ''; + print ''; + // Status + print ''; print ''; print '  '; print '';