changed parameter

This commit is contained in:
Cédric Salvador
2013-09-13 10:52:04 +02:00
parent b0e03462d3
commit fc136d0d06
17 changed files with 43 additions and 40 deletions

View File

@@ -117,11 +117,11 @@ if ($catid == -2) $sql.= " AND cs.fk_categorie IS NULL";
if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ; if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ;
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
if ($search_nom) { if ($search_nom) {
$sql .= natural_search(array('s.nom'), $search_nom); $sql .= natural_search('s.nom', $search_nom);
} }
if ($search_zipcode) $sql.= " AND s.zip LIKE '".$db->escape($search_zipcode)."%'"; if ($search_zipcode) $sql.= " AND s.zip LIKE '".$db->escape($search_zipcode)."%'";
if ($search_town) { if ($search_town) {
$sql .= natural_search(array('s.town'), $search_town); $sql .= natural_search('s.town', $search_town);
} }
if ($search_code) $sql.= " AND s.code_client LIKE '%".$db->escape($search_code)."%'"; if ($search_code) $sql.= " AND s.code_client LIKE '%".$db->escape($search_code)."%'";
if ($search_compta) $sql.= " AND s.code_compta LIKE '%".$db->escape($search_compta)."%'"; if ($search_compta) $sql.= " AND s.code_compta LIKE '%".$db->escape($search_compta)."%'";

View File

@@ -162,16 +162,16 @@ if (! $user->rights->societe->client->voir && ! $socid) //restriction
$sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
} }
if ($search_town) {//restriction if ($search_town) {//restriction
$sql .= natural_search(array('s.town'), $search_town); $sql .= natural_search('s.town', $search_town);
} }
if ($search_ref) { if ($search_ref) {
$sql .= natural_search(array('p.ref'), $search_ref); $sql .= natural_search('p.ref', $search_ref);
} }
if ($search_refcustomer) { if ($search_refcustomer) {
$sql .= natural_search(array('p.ref_client'), $search_refcustomer); $sql .= natural_search('p.ref_client', $search_refcustomer);
} }
if ($search_societe) { if ($search_societe) {
$sql .= natural_search(array('s.nom'), $search_societe); $sql .= natural_search('s.nom', $search_societe);
} }
if ($search_author) if ($search_author)
{ {

View File

@@ -195,14 +195,14 @@ if ($catid == -2) $sql.= " AND cs.fk_categorie IS NULL";
if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ; if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ;
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
if ($search_nom) { if ($search_nom) {
$sql .= natural_search(array('s.nom'), $search_nom); $sql .= natural_search('s.nom', $search_nom);
} }
if ($search_zipcode) $sql .= " AND s.zip LIKE '".$db->escape(strtolower($search_zipcode))."%'"; if ($search_zipcode) $sql .= " AND s.zip LIKE '".$db->escape(strtolower($search_zipcode))."%'";
if ($search_town) { if ($search_town) {
$sql .= natural_search(array('s.town'), $search_town); $sql .= natural_search('s.town', $search_town);
} }
if ($search_state) { if ($search_state) {
$sql .= natural_search(array('d.nom'), $search_state); $sql .= natural_search('d.nom', $search_state);
} }
if ($search_datec) $sql .= " AND s.datec LIKE '%".$db->escape($search_datec)."%'"; if ($search_datec) $sql .= " AND s.datec LIKE '%".$db->escape($search_datec)."%'";
// Insert levels filters // Insert levels filters
@@ -216,7 +216,7 @@ if ($search_sale)
$sql .= " AND sc.fk_user = ".$db->escape($search_sale); $sql .= " AND sc.fk_user = ".$db->escape($search_sale);
} }
if ($socname) { if ($socname) {
$sql .= natural_search(array('s.nom'), $search_nom); $sql .= natural_search('s.nom', $search_nom);
$sortfield = "s.nom"; $sortfield = "s.nom";
$sortorder = "ASC"; $sortorder = "ASC";
} }

View File

@@ -127,7 +127,7 @@ $sql.= ' AND c.entity = '.$conf->entity;
if ($socid) $sql.= ' AND s.rowid = '.$socid; if ($socid) $sql.= ' AND s.rowid = '.$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($sref) { if ($sref) {
$sql .= natural_search(array('c.ref'), $sref); $sql .= natural_search('c.ref', $sref);
} }
if ($sall) if ($sall)
{ {
@@ -187,7 +187,7 @@ else if ($deliveryyear > 0)
} }
if (!empty($snom)) if (!empty($snom))
{ {
$sql .= natural_search(array('s.nom'), $snom); $sql .= natural_search('s.nom', $snom);
} }
if (!empty($sref_client)) if (!empty($sref_client))
{ {

View File

@@ -76,7 +76,7 @@ if (trim($search_ref) != '')
} }
if (trim($search_company) != '') if (trim($search_company) != '')
{ {
$sql .= natural_search(array('d.societe'), $search_company); $sql .= natural_search('d.societe', $search_company);
} }
if (trim($search_name) != '') if (trim($search_name) != '')
{ {

View File

@@ -175,11 +175,11 @@ if ($filtre)
} }
if ($search_ref) if ($search_ref)
{ {
$sql .= natural_search(array('f.facnumber'), $search_ref); $sql .= natural_search('f.facnumber', $search_ref);
} }
if ($search_societe) if ($search_societe)
{ {
$sql .= natural_search(array('s.nom'), $search_societe); $sql .= natural_search('s.nom', $search_societe);
} }
if ($search_montant_ht) if ($search_montant_ht)
{ {

View File

@@ -113,7 +113,7 @@ else
if (GETPOST("search_account") > 0) $sql .=" AND b.fk_account=".GETPOST("search_account",'int'); if (GETPOST("search_account") > 0) $sql .=" AND b.fk_account=".GETPOST("search_account",'int');
if (GETPOST("search_paymenttype") != "") $sql .=" AND c.code='".GETPOST("search_paymenttype")."'"; if (GETPOST("search_paymenttype") != "") $sql .=" AND c.code='".GETPOST("search_paymenttype")."'";
if (GETPOST("search_amount")) $sql .=" AND p.amount=".price2num(GETPOST("search_amount")); if (GETPOST("search_amount")) $sql .=" AND p.amount=".price2num(GETPOST("search_amount"));
if (GETPOST("search_company")) $sql .= natural_search(array('s.nom'), GETPOST('search_company')); if (GETPOST("search_company")) $sql .= natural_search('s.nom', GETPOST('search_company'));
} }
$sql.= $db->order($sortfield,$sortorder); $sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit+1, $offset); $sql.= $db->plimit($limit+1, $offset);

View File

@@ -150,16 +150,16 @@ if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ;
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
if ($search_lastname) { // filter on lastname if ($search_lastname) { // filter on lastname
$sql .= natural_search(array('p.lastname'), $search_lastname); $sql .= natural_search('p.lastname', $search_lastname);
} }
if ($search_firstname) { // filter on firstname if ($search_firstname) { // filter on firstname
$sql .= natural_search(array('p.firstname'), $search_firstname); $sql .= natural_search('p.firstname', $search_firstname);
} }
if ($search_societe) { // filtre sur la societe if ($search_societe) { // filtre sur la societe
$sql .= natural_search(array('s.nom'), $search_societe); $sql .= natural_search('s.nom', $search_societe);
} }
if (strlen($search_poste)) { // filtre sur la societe if (strlen($search_poste)) { // filtre sur la societe
$sql .= natural_search(array('p.poste'), $search_poste); $sql .= natural_search('p.poste', $search_poste);
} }
if (strlen($search_phone)) if (strlen($search_phone))
{ {

View File

@@ -81,7 +81,7 @@ $sql.= " AND c.entity = ".$conf->entity;
if ($socid) $sql.= " AND s.rowid = ".$socid; if ($socid) $sql.= " AND s.rowid = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($search_nom) { if ($search_nom) {
$sql .= natural_search(array('s.nom'), $search_nom); $sql .= natural_search('s.nom', $search_nom);
} }
if ($search_contract) { if ($search_contract) {
$sql .= natural_search(array('c.rowid', 'c.ref'), $search_contract); $sql .= natural_search(array('c.rowid', 'c.ref'), $search_contract);

View File

@@ -4439,7 +4439,7 @@ if (! function_exists('getmypid'))
/** /**
* Natural search * Natural search
* @param array[string] $fields array filled with the fields names in the SQL query * @param mixed $fields string or array of strings filled with the fields names in the SQL query
* @param string $value the value to look for * @param string $value the value to look for
* @return string $res the statement to append to the SQL query * @return string $res the statement to append to the SQL query
* */ * */
@@ -4448,6 +4448,9 @@ function natural_search($fields, $value)
global $db; global $db;
$crits = explode(' ', $value); $crits = explode(' ', $value);
$res = ""; $res = "";
if (! is_array($fields)) {
$fields = array($fields);
}
$end = count($fields); $end = count($fields);
$end2 = count($crits); $end2 = count($crits);
$j = 0; $j = 0;

View File

@@ -75,10 +75,10 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.r
$sql.= " WHERE f.fk_soc = s.rowid "; $sql.= " WHERE f.fk_soc = s.rowid ";
$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.entity = ".$conf->entity;
if ($search_ref) { if ($search_ref) {
$sql .= natural_search(array('f.ref'), $search_ref); $sql .= natural_search('f.ref', $search_ref);
} }
if ($search_company) { if ($search_company) {
$sql .= natural_search(array('s.nom'), $search_company); $sql .= natural_search('s.nom', $search_company);
} }
if ($search_desc) { if ($search_desc) {
$sql .= natural_search(array('f.description', 'fd.description'), $search_desc); $sql .= natural_search(array('f.description', 'fd.description'), $search_desc);

View File

@@ -93,11 +93,11 @@ $sql.= " AND cf.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($sref) if ($sref)
{ {
$sql .= natural_search(array('cf.ref'), $sref); $sql .= natural_search('cf.ref', $sref);
} }
if ($snom) if ($snom)
{ {
$sql .= natural_search(array('s.nom'), $snom); $sql .= natural_search('s.nom', $snom);
} }
if ($suser) if ($suser)
{ {

View File

@@ -132,11 +132,11 @@ if (GETPOST('filtre'))
if (GETPOST("search_ref")) if (GETPOST("search_ref"))
{ {
if (is_numeric(GETPOST("search_ref"))) $sql .= natural_search(array('fac.rowid', 'fac.ref'), GETPOST('search_ref'));// For backward compatibility if (is_numeric(GETPOST("search_ref"))) $sql .= natural_search(array('fac.rowid', 'fac.ref'), GETPOST('search_ref'));// For backward compatibility
else $sql .= natural_search(array('fac.ref'), GETPOST("search_ref")); else $sql .= natural_search('fac.ref', GETPOST("search_ref"));
} }
if (GETPOST("search_ref_supplier")) if (GETPOST("search_ref_supplier"))
{ {
$sql .= natural_search(array('fac.ref_supplier'), GETPOST('search_ref_supplier')); $sql .= natural_search('fac.ref_supplier', GETPOST('search_ref_supplier'));
} }
if ($month > 0) if ($month > 0)
{ {
@@ -151,12 +151,12 @@ else if ($year > 0)
} }
if (GETPOST("search_libelle")) if (GETPOST("search_libelle"))
{ {
$sql .= natural_search(array('fac.libelle'), GETPOST('search_libelle')); $sql .= natural_search('fac.libelle', GETPOST('search_libelle'));
} }
if (GETPOST("search_societe")) if (GETPOST("search_societe"))
{ {
$sql .= natural_search(array('s.nom'), GETPOST('search_societe')); $sql .= natural_search('s.nom', GETPOST('search_societe'));
} }
if (GETPOST("search_montant_ht")) if (GETPOST("search_montant_ht"))

View File

@@ -90,16 +90,16 @@ $sql.= " AND s.entity IN (".getEntity('societe', 1).")";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid; if ($socid) $sql .= " AND s.rowid = ".$socid;
if ($socname) { if ($socname) {
$sql .= natural_search(array('s.nom'), $socname); $sql .= natural_search('s.nom', $socname);
$sortfield = "s.nom"; $sortfield = "s.nom";
$sortorder = "ASC"; $sortorder = "ASC";
} }
if ($search_nom) { if ($search_nom) {
$sql .= natural_search(array('s.nom'), $search_nom); $sql .= natural_search('s.nom', $search_nom);
} }
if ($search_zipcode) $sql .= " AND s.zip LIKE '".$db->escape($search_zipcode)."%'"; if ($search_zipcode) $sql .= " AND s.zip LIKE '".$db->escape($search_zipcode)."%'";
if ($search_town) { if ($search_town) {
$sql .= natural_search(array('s.town'), $search_town); $sql .= natural_search('s.town', $search_town);
} }
if ($search_code_fournisseur) $sql .= " AND s.code_fournisseur LIKE '%".$db->escape($search_code_fournisseur)."%'"; if ($search_code_fournisseur) $sql .= " AND s.code_fournisseur LIKE '%".$db->escape($search_code_fournisseur)."%'";
if ($search_compta_fournisseur) $sql .= " AND s.code_compta_fournisseur LIKE '%".$db->escape($search_compta_fournisseur)."%'"; if ($search_compta_fournisseur) $sql .= " AND s.code_compta_fournisseur LIKE '%".$db->escape($search_compta_fournisseur)."%'";

View File

@@ -106,11 +106,11 @@ else
} }
if ($sref) if ($sref)
{ {
$sql .= natural_search(array('p.ref'), $sref); $sql .= natural_search('p.ref', $sref);
} }
if ($snom) if ($snom)
{ {
$sql .= natural_search(array('p.label'), $snom); $sql .= natural_search('p.label', $snom);
} }
if($catid) if($catid)
{ {
@@ -119,7 +119,7 @@ else
} }
if ($sRefSupplier) if ($sRefSupplier)
{ {
$sql .= natural_search(array('ppf.ref_fourn'), $sRefSupplier); $sql .= natural_search('ppf.ref_fourn', $sRefSupplier);
} }
if ($fourn_id > 0) if ($fourn_id > 0)
{ {

View File

@@ -162,7 +162,7 @@ else
else $sql.= " AND p.fk_product_type <> '1'"; else $sql.= " AND p.fk_product_type <> '1'";
} }
if ($sref) { if ($sref) {
$sql .= natural_search(array('p.ref'), $sref); $sql .= natural_search('p.ref', $sref);
} }
if ($sbarcode) $sql.= " AND p.barcode LIKE '%".$sbarcode."%'"; if ($sbarcode) $sql.= " AND p.barcode LIKE '%".$sbarcode."%'";
if ($snom) if ($snom)

View File

@@ -87,15 +87,15 @@ if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$pro
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
if ($search_ref) if ($search_ref)
{ {
$sql .= natural_search(array('p.ref'), $search_ref); $sql .= natural_search('p.ref', $search_ref);
} }
if ($search_label) if ($search_label)
{ {
$sql .= natural_search(array('p.title'), $search_label); $sql .= natural_search('p.title', $search_label);
} }
if ($search_societe) if ($search_societe)
{ {
$sql .= natural_search(array('s.nom'), $search_societe); $sql .= natural_search('s.nom', $search_societe);
} }
$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);