Browse Source

Merge remote-tracking branch 'upstream/develop' into develop

Juanjo Menent 9 years ago
parent
commit
2d6d3502ac
2 changed files with 74 additions and 25 deletions
  1. 35 13
      htdocs/contact/list.php
  2. 39 12
      htdocs/contrat/list.php

+ 35 - 13
htdocs/contact/list.php

@@ -57,6 +57,8 @@ $search_email=GETPOST("search_email");
 $search_skype=GETPOST("search_skype");
 $search_priv=GETPOST("search_priv");
 $search_categ=GETPOST("search_categ",'int');
+$search_categ_thirdparty=GETPOST("search_categ_thirdparty",'int');
+$search_categ_supplier=GETPOST("search_categ_supplier",'int');
 $search_status=GETPOST("search_status",'int');
 $search_type=GETPOST('search_type','alpha');
 if ($search_status=='') $search_status=1; // always display activ customer first
@@ -191,6 +193,10 @@ if (GETPOST('button_removefilter_x') || GETPOST('button_removefilter.x') || GETP
     $search_skype="";
     $search_priv="";
     $search_status=-1;
+    $search_categ='';
+    $search_categ_thirdparty='';
+    $search_categ_supplier='';
+    $search_array_options=array();
 }
 if ($search_priv < 0) $search_priv='';
 
@@ -220,7 +226,9 @@ $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as p";
 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (p.rowid = ef.fk_object)";
 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays";
 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
-if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cs ON p.rowid = cs.fk_socpeople"; // We need this table joined to the select in order to filter by categ
+if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cc ON p.rowid = cc.fk_socpeople"; // We need this table joined to the select in order to filter by categ
+if (! empty($search_categ_thirdparty)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc";       // We need this table joined to the select in order to filter by categ
+if (! empty($search_categ_supplier)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc";       // We need this table joined to the select in order to filter by categ
 if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
 $sql.= ' WHERE p.entity IN ('.getEntity('societe', 1).')';
 if (!$user->rights->societe->client->voir && !$socid) //restriction
@@ -243,8 +251,12 @@ else
 	if ($search_priv == '1') $sql .= " AND (p.priv='1' AND p.fk_user_creat=".$user->id.")";
 }
 
-if ($search_categ > 0)   $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ);
-if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
+if ($search_categ > 0)   $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ);
+if ($search_categ == -2) $sql.= " AND cc.fk_categorie IS NULL";
+if ($search_categ_thirdparty > 0)   $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ_thirdparty);
+if ($search_categ_thirdparty == -2) $sql.= " AND cs.fk_categorie IS NULL";
+if ($search_categ_supplier > 0)   $sql.= " AND cs2.fk_categorie = ".$db->escape($search_categ_supplier);
+if ($search_categ_supplier == -2) $sql.= " AND cs2.fk_categorie IS NULL";
 
 if ($search_firstlast_only) {
     $sql .= natural_search(array('p.lastname','p.firstname'), $search_firstlast_only);
@@ -333,7 +345,7 @@ $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters);    // No
 $sql.=$hookmanager->resPrint;
 
 // Add order
-if($view == "recent")
+if ($view == "recent")
 {
     $sql.= $db->order("p.datec","DESC");
 }
@@ -350,15 +362,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
     $nbtotalofrecords = $db->num_rows($result);
 }
 
-// Add limit
-if($view == "recent")
-{
-    $sql.= $db->plimit($limit+1, $offset);
-}
-else
-{
-    $sql.= $db->plimit($limit+1, $offset);
-}
+$sql.= $db->plimit($limit+1, $offset);
 
 //print $sql;
 dol_syslog("contact/list.php", LOG_DEBUG);
@@ -374,6 +378,8 @@ if ($result)
     $param.='&begin='.urlencode($begin).'&view='.urlencode($view).'&userid='.urlencode($userid).'&contactname='.urlencode($sall);
     $param.='&type='.urlencode($type).'&view='.urlencode($view);
     if (!empty($search_categ)) $param.='&search_categ='.urlencode($search_categ);
+    if (!empty($search_categ_thirdparty)) $param.='&search_categ_thirdparty='.urlencode($search_categ_thirdparty);
+    if (!empty($search_categ_supplier)) $param.='&search_categ_supplier='.urlencode($search_categ_supplier);
     if ($search_lastname != '') $param.='&amp;search_lastname='.urlencode($search_lastname);
     if ($search_firstname != '') $param.='&amp;search_firstname='.urlencode($search_firstname);
     if ($search_societe != '') $param.='&amp;search_societe='.urlencode($search_societe);
@@ -423,6 +429,22 @@ if ($result)
 		$moreforfilter.=$langs->trans('Categories'). ': ';
     	$moreforfilter.=$formother->select_categories(Categorie::TYPE_CONTACT,$search_categ,'search_categ',1);
     	$moreforfilter.='</div>';
+    	if (empty($type) || $type == 'c' || $type == 'p')
+    	{
+	        $moreforfilter.='<div class="divsearchfield">';
+	        if ($type == 'c') $moreforfilter.=$langs->trans('CustomersCategoriesShort'). ': ';
+	    	else if ($type == 'p') $moreforfilter.=$langs->trans('ProspectsCategoriesShort'). ': ';
+	    	else $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort'). ': ';
+	    	$moreforfilter.=$formother->select_categories(Categorie::TYPE_CUSTOMER,$search_categ_thirdparty,'search_categ_thirdparty',1);
+	    	$moreforfilter.='</div>';
+    	}
+    	if (empty($type) || $type == 'f')
+    	{
+	    	$moreforfilter.='<div class="divsearchfield">';
+			$moreforfilter.=$langs->trans('SuppliersCategoriesShort'). ': ';
+	    	$moreforfilter.=$formother->select_categories(Categorie::TYPE_SUPPLIER,$search_categ_supplier,'search_categ_supplier',1);
+	    	$moreforfilter.='</div>';
+    	}
     }
     if ($moreforfilter)
     {

+ 39 - 12
htdocs/contrat/list.php

@@ -67,20 +67,18 @@ $result = restrictedArea($user, 'contrat', $id);
 $staticcontrat=new Contrat($db);
 $staticcontratligne=new ContratLigne($db);
 
-if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
-{
-	$search_name="";
-	$search_contract="";
-	$search_ref_supplier="";
-    $search_user='';
-    $search_sale='';
-    $search_product_category='';
-	$sall="";
-	$search_status="";
-}
-
 if ($search_status == '') $search_status=1;
 
+$contextpage='contractlist';
+
+// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
+$hookmanager->initHooks(array($contextpage));
+$extrafields = new ExtraFields($db);
+
+// fetch optionals attributes and labels
+$extralabels = $extrafields->fetch_name_optionals_label('contract');
+$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
+
 // List of fields to search into when doing a "search in all"
 $fieldstosearchall = array(
     'c.ref'=>'Ref',
@@ -93,6 +91,35 @@ $fieldstosearchall = array(
 if (empty($user->socid)) $fieldstosearchall["c.note_private"]="NotePrivate";
 
 
+/*
+ * Action
+ */
+
+$parameters=array();
+$reshook=$hookmanager->executeHooks('doActions',$parameters, $object, $action);    // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
+
+if (empty($reshook))
+{
+
+}
+
+if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
+{
+	$search_name="";
+	$search_contract="";
+	$search_ref_supplier="";
+    $search_user='';
+    $search_sale='';
+    $search_product_category='';
+	$sall="";
+	$search_status="";
+	$search_array_options=array();
+}
+
+
 /*
  * View
  */