Explorar el Código

Fix compatibility with old behaviour (direct open of card after a
search)

Laurent Destailleur hace 9 años
padre
commit
3c6c509358
Se han modificado 1 ficheros con 523 adiciones y 518 borrados
  1. 523 518
      htdocs/societe/list.php

+ 523 - 518
htdocs/societe/list.php

@@ -254,9 +254,6 @@ $prospectstatic=new Client($db);
 $prospectstatic->client=2;
 $prospectstatic->loadCacheOfProspStatus();
 
-$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
-llxHeader('',$langs->trans("ThirdParty"),$help_url);
-
 
 $title=$langs->trans("ListOfThirdParties");
 if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) $title=$langs->trans("ListOfCustomers");
@@ -432,347 +429,567 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 $sql.= $db->plimit($limit+1, $offset);
 
 $resql = $db->query($sql);
-if ($resql)
+if (! $resql)
 {
-	$num = $db->num_rows($resql);
-	$i = 0;
-
-	$param='';
-    if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
-	if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
-	if ($sall != '') $param .= "&sall=".urlencode($sall);
- 	if ($search_categ > 0) $param.='&search_categ='.urlencode($search_categ);
- 	if ($search_sale > 0)	$param.='&search_sale='.urlencode($search_sale);
-	if ($search_nom != '') $param.= "&search_nom=".urlencode($search_nom);
-	if ($search_town != '') $param.= "&search_town=".urlencode($search_town);
-	if ($search_zip != '') $param.= "&search_zip=".urlencode($search_zip);
-	if ($search_state != '') $param.= "&search_state=".urlencode($search_state);
-	if ($search_country != '') $param.= "&search_country=".urlencode($search_country);
-	if ($search_customer_code != '') $param.= "&search_customer_code=".urlencode($search_customer_code);
-	if ($search_supplier_code != '') $param.= "&search_supplier_code=".urlencode($search_supplier_code);
-	if ($search_account_customer_code != '') $param.= "&search_account_customer_code=".urlencode($search_account_customer_code);
-	if ($search_account_supplier_code != '') $param.= "&search_account_supplier_code=".urlencode($search_account_supplier_code);
-	if ($search_barcode != '') $param.= "&sbarcode=".urlencode($search_barcode);
-	if ($search_idprof1 != '') $param.= '&search_idprof1='.urlencode($search_idprof1);
-	if ($search_idprof2 != '') $param.= '&search_idprof2='.urlencode($search_idprof2);
-	if ($search_idprof3 != '') $param.= '&search_idprof3='.urlencode($search_idprof3);
-	if ($search_idprof4 != '') $param.= '&search_idprof4='.urlencode($search_idprof4);
-	if ($search_idprof5 != '') $param.= '&search_idprof5='.urlencode($search_idprof5);
-	if ($search_idprof6 != '') $param.= '&search_idprof6='.urlencode($search_idprof6);
-	if ($search_country != '') $param.='&search_country='.urlencode($search_country);
-	if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty);
-	if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
-    if ($search_status != '') $param.='&search_status='.urlencode($search_status);
-	if ($search_stcomm != '') $param.='&search_stcomm='.$search_stcomm;
- 	if ($search_level_from != '') $param.='&search_level_from='.$search_level_from;
- 	if ($search_level_to != '') $param.='&search_level_to='.$search_level_to;
-    if ($type != '') $param.='&type='.urlencode($type);
-    // Add $param from extra fields
-    foreach ($search_array_options as $key => $val)
-    {
-        $crit=$val;
-        $tmpkey=preg_replace('/search_options_/','',$key);
-        if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
-    } 	
-    
-    // Show delete result message
-    if (GETPOST('delsoc'))
-    {
-	    setEventMessages($langs->trans("CompanyDeleted",GETPOST('delsoc')), null, 'mesgs');
-    }
+    dol_print_error($db);
+    exit;
+}
 
-    print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
-    if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
-	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-	print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
-	print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
-	print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
-	
-    print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit);
+$num = $db->num_rows($resql);
+$i = 0;
 
-	$langs->load("other");
-	$textprofid=array();
-	foreach(array(1,2,3,4,5,6) as $key)
-	{
-		$label=$langs->transnoentities("ProfId".$key.$mysoc->country_code);
-		$textprofid[$key]='';
-		if ($label != "ProfId".$key.$mysoc->country_code)
-		{	// Get only text between ()
-			if (preg_match('/\((.*)\)/i',$label,$reg)) $label=$reg[1];
-			$textprofid[$key]=$langs->trans("ProfIdShortDesc",$key,$mysoc->country_code,$label);
-		}
+if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE))
+{
+    $obj = $db->fetch_object($resql);
+    $id = $obj->rowid;
+    header("Location: ".DOL_URL_ROOT.'/societe/soc.php?socid='.$id);
+    exit;
+}
+
+$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
+llxHeader('',$langs->trans("ThirdParty"),$help_url);
+
+$param='';
+if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
+if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
+if ($sall != '') $param .= "&amp;sall=".urlencode($sall);
+if ($search_categ > 0) $param.='&amp;search_categ='.urlencode($search_categ);
+if ($search_sale > 0)	$param.='&amp;search_sale='.urlencode($search_sale);
+if ($search_nom != '') $param.= "&amp;search_nom=".urlencode($search_nom);
+if ($search_town != '') $param.= "&amp;search_town=".urlencode($search_town);
+if ($search_zip != '') $param.= "&amp;search_zip=".urlencode($search_zip);
+if ($search_state != '') $param.= "&amp;search_state=".urlencode($search_state);
+if ($search_country != '') $param.= "&amp;search_country=".urlencode($search_country);
+if ($search_customer_code != '') $param.= "&amp;search_customer_code=".urlencode($search_customer_code);
+if ($search_supplier_code != '') $param.= "&amp;search_supplier_code=".urlencode($search_supplier_code);
+if ($search_account_customer_code != '') $param.= "&amp;search_account_customer_code=".urlencode($search_account_customer_code);
+if ($search_account_supplier_code != '') $param.= "&amp;search_account_supplier_code=".urlencode($search_account_supplier_code);
+if ($search_barcode != '') $param.= "&amp;sbarcode=".urlencode($search_barcode);
+if ($search_idprof1 != '') $param.= '&amp;search_idprof1='.urlencode($search_idprof1);
+if ($search_idprof2 != '') $param.= '&amp;search_idprof2='.urlencode($search_idprof2);
+if ($search_idprof3 != '') $param.= '&amp;search_idprof3='.urlencode($search_idprof3);
+if ($search_idprof4 != '') $param.= '&amp;search_idprof4='.urlencode($search_idprof4);
+if ($search_idprof5 != '') $param.= '&amp;search_idprof5='.urlencode($search_idprof5);
+if ($search_idprof6 != '') $param.= '&amp;search_idprof6='.urlencode($search_idprof6);
+if ($search_country != '') $param.='&amp;search_country='.urlencode($search_country);
+if ($search_type_thirdparty != '') $param.='&amp;search_type_thirdparty='.urlencode($search_type_thirdparty);
+if ($optioncss != '') $param.='&amp;optioncss='.urlencode($optioncss);
+if ($search_status != '') $param.='&amp;search_status='.urlencode($search_status);
+if ($search_stcomm != '') $param.='&search_stcomm='.$search_stcomm;
+if ($search_level_from != '') $param.='&search_level_from='.$search_level_from;
+if ($search_level_to != '') $param.='&search_level_to='.$search_level_to;
+if ($type != '') $param.='&amp;type='.urlencode($type);
+// Add $param from extra fields
+foreach ($search_array_options as $key => $val)
+{
+    $crit=$val;
+    $tmpkey=preg_replace('/search_options_/','',$key);
+    if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
+} 	
+
+// Show delete result message
+if (GETPOST('delsoc'))
+{
+    setEventMessages($langs->trans("CompanyDeleted",GETPOST('delsoc')), null, 'mesgs');
+}
+
+print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
+if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
+print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
+print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
+
+print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit);
+
+$langs->load("other");
+$textprofid=array();
+foreach(array(1,2,3,4,5,6) as $key)
+{
+	$label=$langs->transnoentities("ProfId".$key.$mysoc->country_code);
+	$textprofid[$key]='';
+	if ($label != "ProfId".$key.$mysoc->country_code)
+	{	// Get only text between ()
+		if (preg_match('/\((.*)\)/i',$label,$reg)) $label=$reg[1];
+		$textprofid[$key]=$langs->trans("ProfIdShortDesc",$key,$mysoc->country_code,$label);
 	}
+}
 
-    if ($search_all)
-    {
-        foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
-        print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall);
-    }
-	
-	// Filter on categories
-	$moreforfilter='';
-	if ($type == 'c' || $type == 'p')
+if ($search_all)
+{
+    foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
+    print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall);
+}
+
+// Filter on categories
+$moreforfilter='';
+if ($type == 'c' || $type == 'p')
+{
+	if (! empty($conf->categorie->enabled))
 	{
-		if (! empty($conf->categorie->enabled))
-		{
-			require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
-			$moreforfilter.='<div class="divsearchfield">';
-		 	$moreforfilter.=$langs->trans('Categories'). ': ';
-			$moreforfilter.=$formother->select_categories('customer',$search_categ,'search_categ',1);
-		 	$moreforfilter.='</div>';
-		}
+		require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
+		$moreforfilter.='<div class="divsearchfield">';
+	 	$moreforfilter.=$langs->trans('Categories'). ': ';
+		$moreforfilter.=$formother->select_categories('customer',$search_categ,'search_categ',1);
+	 	$moreforfilter.='</div>';
 	}
-	
-	// If the user can view prospects other than his'
-	if ($user->rights->societe->client->voir || $socid)
+}
+
+// If the user can view prospects other than his'
+if ($user->rights->societe->client->voir || $socid)
+{
+ 	$moreforfilter.='<div class="divsearchfield">';
+ 	$moreforfilter.=$langs->trans('SalesRepresentatives'). ': ';
+	$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user, 0, 1, 'maxwidth300');
+	$moreforfilter.='</div>';
+}
+if ($type == 'f')
+{
+	if (! empty($conf->categorie->enabled))
 	{
-	 	$moreforfilter.='<div class="divsearchfield">';
-	 	$moreforfilter.=$langs->trans('SalesRepresentatives'). ': ';
-		$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user, 0, 1, 'maxwidth300');
+		require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
+		$moreforfilter.='<div class="divsearchfield">';
+		$moreforfilter.=$langs->trans('Categories'). ': ';
+		$moreforfilter.=$formother->select_categories('supplier',$search_categ,'search_categ',1);
 		$moreforfilter.='</div>';
 	}
-	if ($type == 'f')
+}
+if (! empty($moreforfilter))
+{
+	print '<div class="liste_titre liste_titre_bydiv centpercent">';
+	print $moreforfilter;
+	$parameters=array('type'=>$type);
+	$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters);    // Note that $action and $object may have been modified by hook
+    print $hookmanager->resPrint;
+    print '</div>';
+}
+
+$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
+$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);	// This also change content of $arrayfields
+
+print '<table class="liste'.($moreforfilter?" listwithfilterbefore":"").'">';
+
+print '<tr class="liste_titre">';
+if (! empty($arrayfields['s.nom']['checked']))            print_liste_field_titre($langs->trans("Company"), $_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder);
+if (! empty($arrayfields['s.barcode']['checked']))        print_liste_field_titre($langs->trans("Gencod"), $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder);
+if (! empty($arrayfields['s.code_client']['checked']))             print_liste_field_titre($arrayfields['s.code_client']['label'],$_SERVER["PHP_SELF"],"s.code_client","",$param,'',$sortfield,$sortorder);
+if (! empty($arrayfields['s.code_fournisseur']['checked']))        print_liste_field_titre($arrayfields['s.code_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'',$sortfield,$sortorder);
+if (! empty($arrayfields['s.code_compta']['checked']))             print_liste_field_titre($arrayfields['s.code_compta']['label'],$_SERVER["PHP_SELF"],"s.code_compta","",$param,'',$sortfield,$sortorder);
+if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_compta_fournisseur","",$param,'',$sortfield,$sortorder);
+if (! empty($arrayfields['s.town']['checked']))           print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder);
+if (! empty($arrayfields['s.zip']['checked']))            print_liste_field_titre($langs->trans("Zip"),$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder);
+if (! empty($arrayfields['state.nom']['checked']))        print_liste_field_titre($langs->trans("StateShort"),$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
+if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($langs->trans("Country"),$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
+if (! empty($arrayfields['typent.code']['checked']))      print_liste_field_titre($langs->trans("ThirdPartyType"),$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
+if (! empty($arrayfields['s.siren']['checked']))          print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"),$textprofid[1],1,0),$_SERVER["PHP_SELF"],"s.siren","",$param,'class="nowrap"',$sortfield,$sortorder);
+if (! empty($arrayfields['s.siret']['checked']))          print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"),$textprofid[2],1,0),$_SERVER["PHP_SELF"],"s.siret","",$param,'class="nowrap"',$sortfield,$sortorder);
+if (! empty($arrayfields['s.ape']['checked']))            print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"),$textprofid[3],1,0),$_SERVER["PHP_SELF"],"s.ape","",$param,'class="nowrap"',$sortfield,$sortorder);
+if (! empty($arrayfields['s.idprof4']['checked']))        print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$param,'class="nowrap"',$sortfield,$sortorder);
+if (! empty($arrayfields['s.idprof5']['checked']))        print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof5","",$param,'class="nowrap"',$sortfield,$sortorder);
+if (! empty($arrayfields['s.idprof6']['checked']))        print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof6","",$param,'class="nowrap"',$sortfield,$sortorder);
+print_liste_field_titre('');   // type of customer
+if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'],$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder);
+if (! empty($arrayfields['s.fk_stcomm']['checked']))      print_liste_field_titre($arrayfields['s.fk_stcomm']['label'],$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder);
+// Extra fields
+if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
+{
+   foreach($extrafields->attribute_label as $key => $val) 
+   {
+       if (! empty($arrayfields["ef.".$key]['checked'])) 
+       {
+			$align=$extrafields->getAlignFlag($key);
+			print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
+       }
+   }
+}
+// Hook fields
+$parameters=array('arrayfields'=>$arrayfields);
+$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters);    // Note that $action and $object may have been modified by hook
+print $hookmanager->resPrint;
+if (! empty($arrayfields['s.datec']['checked']))  print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
+if (! empty($arrayfields['s.tms']['checked']))    print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"s.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
+if (! empty($arrayfields['s.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder);
+print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
+print "</tr>\n";
+
+// Fields title search
+print '<tr class="liste_titre">';
+if (! empty($arrayfields['s.nom']['checked']))
+{
+	print '<td class="liste_titre">';
+	if (! empty($search_nom_only) && empty($search_nom)) $search_nom=$search_nom_only;
+	print '<input class="flat searchstring" type="text" name="search_nom" size="8" value="'.dol_escape_htmltag($search_nom).'">';
+	print '</td>';
+}
+// Barcode
+if (! empty($arrayfields['s.barcode']['checked']))
+{
+	print '<td class="liste_titre">';
+	print '<input class="flat searchstring" type="text" name="sbarcode" size="6" value="'.dol_escape_htmltag($search_barcode).'">';
+	print '</td>';
+}
+// Customer code
+if (! empty($arrayfields['s.code_client']['checked']))
+{
+    print '<td class="liste_titre">';
+	print '<input class="flat searchstring" size="8" type="text" name="search_customer_code" value="'.dol_escape_htmltag($search_customer_code).'">';
+	print '</td>';
+}
+// Supplier code
+if (! empty($arrayfields['s.code_fournisseur']['checked']))
+{
+    print '<td class="liste_titre">';
+	print '<input class="flat searchstring" size="8" type="text" name="search_supplier_code" value="'.dol_escape_htmltag($search_supplier_code).'">';
+	print '</td>';
+}
+// Account Customer code
+if (! empty($arrayfields['s.code_compta']['checked']))
+{
+    print '<td class="liste_titre">';
+	print '<input class="flat searchstring" size="8" type="text" name="search_account_customer_code" value="'.dol_escape_htmltag($search_account_customer_code).'">';
+	print '</td>';
+}
+// Account Supplier code
+if (! empty($arrayfields['s.code_compta_fournisseur']['checked']))
+{
+    print '<td class="liste_titre">';
+	print '<input class="flat" size="8" type="text" name="search_account_supplier_code" value="'.dol_escape_htmltag($search_account_supplier_code).'">';
+	print '</td>';
+}
+// Town
+if (! empty($arrayfields['s.town']['checked']))
+{
+    print '<td class="liste_titre">';
+	print '<input class="flat searchstring" size="6" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'">';
+	print '</td>';
+}
+// Zip
+if (! empty($arrayfields['s.zip']['checked']))
+{
+    print '<td class="liste_titre">';
+	print '<input class="flat searchstring" size="4" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'">';
+	print '</td>';
+}
+// State
+if (! empty($arrayfields['state.nom']['checked']))
+{
+    print '<td class="liste_titre">';
+	print '<input class="flat searchstring" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
+	print '</td>';
+}
+// Country
+if (! empty($arrayfields['country.code_iso']['checked']))
+{
+    print '<td class="liste_titre" align="center">';
+	print $form->select_country($search_country,'search_country','',0,'maxwidth100');
+	print '</td>';
+}
+// Company type
+if (! empty($arrayfields['typent.code']['checked']))
+{
+    print '<td class="liste_titre maxwidthonsmartphone" align="center">';
+	print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
+	print '</td>';
+}
+if (! empty($arrayfields['s.siren']['checked']))
+{
+    // IdProf1
+	print '<td class="liste_titre">';
+	print '<input class="flat searchstring" size="4" type="text" name="search_idprof1" value="'.dol_escape_htmltag($search_idprof1).'">';
+	print '</td>';
+}
+if (! empty($arrayfields['s.siret']['checked']))
+{
+    // IdProf2
+	print '<td class="liste_titre">';
+	print '<input class="flat searchstring" size="4" type="text" name="search_idprof2" value="'.dol_escape_htmltag($search_idprof2).'">';
+	print '</td>';
+}
+if (! empty($arrayfields['s.ape']['checked']))
+{
+    // IdProf3
+	print '<td class="liste_titre">';
+	print '<input class="flat searchstring" size="4" type="text" name="search_idprof3" value="'.dol_escape_htmltag($search_idprof3).'">';
+	print '</td>';
+}
+if (! empty($arrayfields['s.idprof4']['checked']))
+{
+    // IdProf4
+	print '<td class="liste_titre">';
+	print '<input class="flat searchstring" size="4" type="text" name="search_idprof4" value="'.dol_escape_htmltag($search_idprof4).'">';
+	print '</td>';
+}
+if (! empty($arrayfields['s.idprof5']['checked']))
+{
+    // IdProf5
+	print '<td class="liste_titre">';
+	print '<input class="flat searchstring" size="4" type="text" name="search_idprof5" value="'.dol_escape_htmltag($search_idprof5).'">';
+	print '</td>';
+}
+if (! empty($arrayfields['s.idprof6']['checked']))
+{
+    // IdProf6
+	print '<td class="liste_titre">';
+	print '<input class="flat searchstring" size="4" type="text" name="search_idprof6" value="'.dol_escape_htmltag($search_idprof6).'">';
+	print '</td>';
+}
+
+// Type (customer/prospect/supplier)
+print '<td class="liste_titre maxwidthonsmartphone" align="middle">';
+if ($type != '') print '<input type="hidden" name="type" value="'.$type.'">';
+print '<select class="flat" name="search_type">';
+print '<option value="-1"'.($search_type==''?' selected':'').'>&nbsp;</option>';
+if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="1,3"'.($search_type=='1,3'?' selected':'').'>'.$langs->trans('Customer').'</option>';
+if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2,3"'.($search_type=='2,3'?' selected':'').'>'.$langs->trans('Prospect').'</option>';
+//if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="3"'.($search_type=='3'?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>';
+print '<option value="4"'.($search_type=='4'?' selected':'').'>'.$langs->trans('Supplier').'</option>';
+print '<option value="0"'.($search_type=='0'?' selected':'').'>'.$langs->trans('Others').'</option>';
+print '</select></td>';
+
+if (! empty($arrayfields['s.fk_prospectlevel']['checked']))
+{
+    // Prospect level
+ 	print '<td class="liste_titre" align="center">';
+ 	$options_from = '<option value="">&nbsp;</option>';	 	// Generate in $options_from the list of each option sorted
+ 	foreach ($tab_level as $tab_level_sortorder => $tab_level_label)
+ 	{
+ 		$options_from .= '<option value="'.$tab_level_sortorder.'"'.($search_level_from == $tab_level_sortorder ? ' selected':'').'>';
+ 		$options_from .= $langs->trans($tab_level_label);
+ 		$options_from .= '</option>';
+ 	}
+ 	array_reverse($tab_level, true);	// Reverse the list
+ 	$options_to = '<option value="">&nbsp;</option>';		// Generate in $options_to the list of each option sorted in the reversed order
+ 	foreach ($tab_level as $tab_level_sortorder => $tab_level_label)
+ 	{
+ 		$options_to .= '<option value="'.$tab_level_sortorder.'"'.($search_level_to == $tab_level_sortorder ? ' selected':'').'>';
+ 		$options_to .= $langs->trans($tab_level_label);
+ 		$options_to .= '</option>';
+ 	}
+
+    // Print these two select
+ 	print $langs->trans("From").' <select class="flat" name="search_level_from">'.$options_from.'</select>';
+ 	print ' ';
+ 	print $langs->trans("to").' <select class="flat" name="search_level_to">'.$options_to.'</select>';
+
+    print '</td>';
+}
+
+if (! empty($arrayfields['s.fk_stcomm']['checked']))
+{
+    // Prospect status
+    print '<td class="liste_titre maxwidthonsmartphone" align="center">';
+    $arraystcomm=array();
+	foreach($prospectstatic->cacheprospectstatus as $key => $val)
 	{
-		if (! empty($conf->categorie->enabled))
+        $arraystcomm[$val['id']]=($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
+	}
+    print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2);
+    print '</td>';
+}
+// Extra fields
+if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
+{
+   foreach($extrafields->attribute_label as $key => $val) 
+   {
+		if (! empty($arrayfields["ef.".$key]['checked'])) 
 		{
-			require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
-			$moreforfilter.='<div class="divsearchfield">';
-			$moreforfilter.=$langs->trans('Categories'). ': ';
-			$moreforfilter.=$formother->select_categories('supplier',$search_categ,'search_categ',1);
-			$moreforfilter.='</div>';
+            $align=$extrafields->getAlignFlag($key);
+            $typeofextrafield=$extrafields->attribute_type[$key];
+            print '<td class="liste_titre'.($align?' '.$align:'').'">';
+		    if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')))
+			{
+			    $crit=$val;
+				$tmpkey=preg_replace('/search_options_/','',$key);
+				$searchclass='';
+				if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
+				if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
+				print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
+			}
+			print '</td>';
 		}
-	}
-	if (! empty($moreforfilter))
-	{
-		print '<div class="liste_titre liste_titre_bydiv centpercent">';
-		print $moreforfilter;
-    	$parameters=array('type'=>$type);
-    	$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters);    // Note that $action and $object may have been modified by hook
-	    print $hookmanager->resPrint;
-	    print '</div>';
-	}
+   }
+}
+// Fields from hook
+$parameters=array('arrayfields'=>$arrayfields);
+$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters);    // Note that $action and $object may have been modified by hook
+print $hookmanager->resPrint;
+// Date creation
+if (! empty($arrayfields['s.datec']['checked']))
+{
+    print '<td class="liste_titre">';
+    print '</td>';
+}
+// Date modification
+if (! empty($arrayfields['s.tms']['checked']))
+{
+    print '<td class="liste_titre">';
+    print '</td>';
+}
+// Status
+if (! empty($arrayfields['s.status']['checked']))
+{
+    print '<td class="liste_titre maxwidthonsmartphone" align="center">';
+    print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status);
+    print '</td>';
+}
+// Action column
+print '<td class="liste_titre" align="right">';
+$searchpitco=$form->showFilterAndCheckAddButtons(0);
+print $searchpitco;
+print '</td>';
 
-    $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
-    $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);	// This also change content of $arrayfields
+print "</tr>\n";
+
+$var=True;
+
+while ($i < min($num, $limit))
+{
+	$obj = $db->fetch_object($resql);
+	$var=!$var;
 	
-	print '<table class="liste'.($moreforfilter?" listwithfilterbefore":"").'">';
-
-	print '<tr class="liste_titre">';
-	if (! empty($arrayfields['s.nom']['checked']))            print_liste_field_titre($langs->trans("Company"), $_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder);
-    if (! empty($arrayfields['s.barcode']['checked']))        print_liste_field_titre($langs->trans("Gencod"), $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder);
-	if (! empty($arrayfields['s.code_client']['checked']))             print_liste_field_titre($arrayfields['s.code_client']['label'],$_SERVER["PHP_SELF"],"s.code_client","",$param,'',$sortfield,$sortorder);
-	if (! empty($arrayfields['s.code_fournisseur']['checked']))        print_liste_field_titre($arrayfields['s.code_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'',$sortfield,$sortorder);
-	if (! empty($arrayfields['s.code_compta']['checked']))             print_liste_field_titre($arrayfields['s.code_compta']['label'],$_SERVER["PHP_SELF"],"s.code_compta","",$param,'',$sortfield,$sortorder);
-	if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_compta_fournisseur","",$param,'',$sortfield,$sortorder);
-	if (! empty($arrayfields['s.town']['checked']))           print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder);
-	if (! empty($arrayfields['s.zip']['checked']))            print_liste_field_titre($langs->trans("Zip"),$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder);
-	if (! empty($arrayfields['state.nom']['checked']))        print_liste_field_titre($langs->trans("StateShort"),$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
-	if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($langs->trans("Country"),$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
-	if (! empty($arrayfields['typent.code']['checked']))      print_liste_field_titre($langs->trans("ThirdPartyType"),$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
-	if (! empty($arrayfields['s.siren']['checked']))          print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"),$textprofid[1],1,0),$_SERVER["PHP_SELF"],"s.siren","",$param,'class="nowrap"',$sortfield,$sortorder);
-	if (! empty($arrayfields['s.siret']['checked']))          print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"),$textprofid[2],1,0),$_SERVER["PHP_SELF"],"s.siret","",$param,'class="nowrap"',$sortfield,$sortorder);
-	if (! empty($arrayfields['s.ape']['checked']))            print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"),$textprofid[3],1,0),$_SERVER["PHP_SELF"],"s.ape","",$param,'class="nowrap"',$sortfield,$sortorder);
-	if (! empty($arrayfields['s.idprof4']['checked']))        print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$param,'class="nowrap"',$sortfield,$sortorder);
-	if (! empty($arrayfields['s.idprof5']['checked']))        print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof5","",$param,'class="nowrap"',$sortfield,$sortorder);
-	if (! empty($arrayfields['s.idprof6']['checked']))        print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof6","",$param,'class="nowrap"',$sortfield,$sortorder);
-	print_liste_field_titre('');   // type of customer
-	if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'],$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder);
-	if (! empty($arrayfields['s.fk_stcomm']['checked']))      print_liste_field_titre($arrayfields['s.fk_stcomm']['label'],$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder);
-	// Extra fields
-	if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
+	$companystatic->id=$obj->rowid;
+	$companystatic->name=$obj->name;
+	$companystatic->canvas=$obj->canvas;
+	$companystatic->client=$obj->client;
+	$companystatic->status=$obj->status;
+	$companystatic->fournisseur=$obj->fournisseur;
+	$companystatic->code_client=$obj->code_client;
+	$companystatic->code_fournisseur=$obj->code_fournisseur;
+    $companystatic->fk_prospectlevel=$obj->fk_prospectlevel;
+    $companystatic->name_alias=$obj->name_alias;
+	
+	print "<tr ".$bc[$var].">";
+	if (! empty($arrayfields['s.nom']['checked']))
 	{
-	   foreach($extrafields->attribute_label as $key => $val) 
-	   {
-           if (! empty($arrayfields["ef.".$key]['checked'])) 
-           {
-				$align=$extrafields->getAlignFlag($key);
-				print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
-           }
-	   }
+		print "<td>";
+		print $companystatic->getNomUrl(1,'',100);
+		print "</td>\n";
 	}
-	// Hook fields
-	$parameters=array('arrayfields'=>$arrayfields);
-    $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters);    // Note that $action and $object may have been modified by hook
-    print $hookmanager->resPrint;
-	if (! empty($arrayfields['s.datec']['checked']))  print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
-	if (! empty($arrayfields['s.tms']['checked']))    print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"s.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
-	if (! empty($arrayfields['s.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder);
-	print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
-	print "</tr>\n";
-
-	// Fields title search
-	print '<tr class="liste_titre">';
-    if (! empty($arrayfields['s.nom']['checked']))
-    {
-    	print '<td class="liste_titre">';
-    	if (! empty($search_nom_only) && empty($search_nom)) $search_nom=$search_nom_only;
-    	print '<input class="flat searchstring" type="text" name="search_nom" size="8" value="'.dol_escape_htmltag($search_nom).'">';
-    	print '</td>';
-    }
 	// Barcode
     if (! empty($arrayfields['s.barcode']['checked']))
-    {
-		print '<td class="liste_titre">';
-		print '<input class="flat searchstring" type="text" name="sbarcode" size="6" value="'.dol_escape_htmltag($search_barcode).'">';
-		print '</td>';
-    }
+	{
+		print '<td>'.$obj->barcode.'</td>';
+	}
 	// Customer code
     if (! empty($arrayfields['s.code_client']['checked']))
-    {
-        print '<td class="liste_titre">';
-    	print '<input class="flat searchstring" size="8" type="text" name="search_customer_code" value="'.dol_escape_htmltag($search_customer_code).'">';
-    	print '</td>';
-    }
-	// Supplier code
+	{
+		print '<td>'.$obj->code_client.'</td>';
+	}
+    // Supplier code
     if (! empty($arrayfields['s.code_fournisseur']['checked']))
-    {
-        print '<td class="liste_titre">';
-    	print '<input class="flat searchstring" size="8" type="text" name="search_supplier_code" value="'.dol_escape_htmltag($search_supplier_code).'">';
-    	print '</td>';
-    }
-	// Account Customer code
+	{
+		print '<td>'.$obj->code_fournisseur.'</td>';
+	}
+	// Account customer code
     if (! empty($arrayfields['s.code_compta']['checked']))
-    {
-        print '<td class="liste_titre">';
-    	print '<input class="flat searchstring" size="8" type="text" name="search_account_customer_code" value="'.dol_escape_htmltag($search_account_customer_code).'">';
-    	print '</td>';
-    }
-	// Account Supplier code
+	{
+		print '<td>'.$obj->code_compta.'</td>';
+	}
+    // Account supplier code
     if (! empty($arrayfields['s.code_compta_fournisseur']['checked']))
-    {
-        print '<td class="liste_titre">';
-    	print '<input class="flat" size="8" type="text" name="search_account_supplier_code" value="'.dol_escape_htmltag($search_account_supplier_code).'">';
-    	print '</td>';
-    }
-    // Town
+	{
+		print '<td>'.$obj->code_compta_fournisseur.'</td>';
+	}
+	// Town
     if (! empty($arrayfields['s.town']['checked']))
     {
-        print '<td class="liste_titre">';
-    	print '<input class="flat searchstring" size="6" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'">';
-    	print '</td>';
+        print "<td>".$obj->town."</td>\n";
     }
-	// Zip
+    // Zip
     if (! empty($arrayfields['s.zip']['checked']))
     {
-        print '<td class="liste_titre">';
-    	print '<input class="flat searchstring" size="4" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'">';
-    	print '</td>';
-    }
-	// State
+        print "<td>".$obj->zip."</td>\n";
+    }        
+    // State
     if (! empty($arrayfields['state.nom']['checked']))
     {
-        print '<td class="liste_titre">';
-    	print '<input class="flat searchstring" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
-    	print '</td>';
-    }
+        print "<td>".$obj->state_name."</td>\n";
+    }        
     // Country
     if (! empty($arrayfields['country.code_iso']['checked']))
     {
-        print '<td class="liste_titre" align="center">';
-    	print $form->select_country($search_country,'search_country','',0,'maxwidth100');
-    	print '</td>';
+        print '<td align="center">';
+		$tmparray=getCountry($obj->fk_pays,'all');
+		print $tmparray['label'];
+		print '</td>';
     }
-	// Company type
+	// Type ent
     if (! empty($arrayfields['typent.code']['checked']))
     {
-        print '<td class="liste_titre maxwidthonsmartphone" align="center">';
-    	print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
-    	print '</td>';
+        print '<td align="center">';
+		if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
+		print $typenArray[$obj->typent_code];
+		print '</td>';
+    }
+    if (! empty($arrayfields['s.siren']['checked']))
+    {
+        print "<td>".$obj->idprof1."</td>\n";
     }
-	if (! empty($arrayfields['s.siren']['checked']))
-	{
-	    // IdProf1
-    	print '<td class="liste_titre">';
-    	print '<input class="flat searchstring" size="4" type="text" name="search_idprof1" value="'.dol_escape_htmltag($search_idprof1).'">';
-    	print '</td>';
-	}
     if (! empty($arrayfields['s.siret']['checked']))
     {
-        // IdProf2
-    	print '<td class="liste_titre">';
-    	print '<input class="flat searchstring" size="4" type="text" name="search_idprof2" value="'.dol_escape_htmltag($search_idprof2).'">';
-    	print '</td>';
+        print "<td>".$obj->idprof2."</td>\n";
     }
     if (! empty($arrayfields['s.ape']['checked']))
     {
-        // IdProf3
-    	print '<td class="liste_titre">';
-    	print '<input class="flat searchstring" size="4" type="text" name="search_idprof3" value="'.dol_escape_htmltag($search_idprof3).'">';
-    	print '</td>';
+        print "<td>".$obj->idprof3."</td>\n";
     }
     if (! empty($arrayfields['s.idprof4']['checked']))
     {
-        // IdProf4
-    	print '<td class="liste_titre">';
-    	print '<input class="flat searchstring" size="4" type="text" name="search_idprof4" value="'.dol_escape_htmltag($search_idprof4).'">';
-    	print '</td>';
+        print "<td>".$obj->idprof4."</td>\n";
     }
     if (! empty($arrayfields['s.idprof5']['checked']))
     {
-        // IdProf5
-    	print '<td class="liste_titre">';
-    	print '<input class="flat searchstring" size="4" type="text" name="search_idprof5" value="'.dol_escape_htmltag($search_idprof5).'">';
-    	print '</td>';
+        print "<td>".$obj->idprof5."</td>\n";
     }
     if (! empty($arrayfields['s.idprof6']['checked']))
     {
-        // IdProf6
-    	print '<td class="liste_titre">';
-    	print '<input class="flat searchstring" size="4" type="text" name="search_idprof6" value="'.dol_escape_htmltag($search_idprof6).'">';
-    	print '</td>';
+        print "<td>".$obj->idprof6."</td>\n";
     }
-    
-    // Type (customer/prospect/supplier)
-    print '<td class="liste_titre maxwidthonsmartphone" align="middle">';
-	if ($type != '') print '<input type="hidden" name="type" value="'.$type.'">';
-    print '<select class="flat" name="search_type">';
-	print '<option value="-1"'.($search_type==''?' selected':'').'>&nbsp;</option>';
-	if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="1,3"'.($search_type=='1,3'?' selected':'').'>'.$langs->trans('Customer').'</option>';
-	if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2,3"'.($search_type=='2,3'?' selected':'').'>'.$langs->trans('Prospect').'</option>';
-	//if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="3"'.($search_type=='3'?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>';
-	print '<option value="4"'.($search_type=='4'?' selected':'').'>'.$langs->trans('Supplier').'</option>';
-	print '<option value="0"'.($search_type=='0'?' selected':'').'>'.$langs->trans('Others').'</option>';
-	print '</select></td>';
-    
+    // Type
+    print '<td align="center">';
+	$s='';
+	if (($obj->client==1 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
+	{
+  		$companystatic->name=$langs->trans("Customer");
+  		$companystatic->name_alias='';
+	    $s.=$companystatic->getNomUrl(0,'customer');
+	}
+	if (($obj->client==2 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
+	{
+        if ($s) $s.=" / ";
+	    $companystatic->name=$langs->trans("Prospect");
+  		$companystatic->name_alias='';
+	    $s.=$companystatic->getNomUrl(0,'prospect');
+	}
+	if (! empty($conf->fournisseur->enabled) && $obj->fournisseur)
+	{
+		if ($s) $s.=" / ";
+        $companystatic->name=$langs->trans("Supplier");
+  		$companystatic->name_alias='';
+        $s.=$companystatic->getNomUrl(0,'supplier');
+	}
+	print $s;
+	print '</td>';
     if (! empty($arrayfields['s.fk_prospectlevel']['checked']))
     {
-	    // Prospect level
-	 	print '<td class="liste_titre" align="center">';
-	 	$options_from = '<option value="">&nbsp;</option>';	 	// Generate in $options_from the list of each option sorted
-	 	foreach ($tab_level as $tab_level_sortorder => $tab_level_label)
-	 	{
-	 		$options_from .= '<option value="'.$tab_level_sortorder.'"'.($search_level_from == $tab_level_sortorder ? ' selected':'').'>';
-	 		$options_from .= $langs->trans($tab_level_label);
-	 		$options_from .= '</option>';
-	 	}
-	 	array_reverse($tab_level, true);	// Reverse the list
-	 	$options_to = '<option value="">&nbsp;</option>';		// Generate in $options_to the list of each option sorted in the reversed order
-	 	foreach ($tab_level as $tab_level_sortorder => $tab_level_label)
-	 	{
-	 		$options_to .= '<option value="'.$tab_level_sortorder.'"'.($search_level_to == $tab_level_sortorder ? ' selected':'').'>';
-	 		$options_to .= $langs->trans($tab_level_label);
-	 		$options_to .= '</option>';
-	 	}
-    
-	    // Print these two select
-	 	print $langs->trans("From").' <select class="flat" name="search_level_from">'.$options_from.'</select>';
-	 	print ' ';
-	 	print $langs->trans("to").' <select class="flat" name="search_level_to">'.$options_to.'</select>';
-	
-	    print '</td>';
+		// Prospect level
+		print '<td align="center">';
+		print $companystatic->getLibProspLevel();
+		print "</td>";
     }
-    
     if (! empty($arrayfields['s.fk_stcomm']['checked']))
     {
-	    // Prospect status
-	    print '<td class="liste_titre maxwidthonsmartphone" align="center">';
-	    $arraystcomm=array();
+        // Prospect status
+		print '<td align="center" class="nowrap"><div class="nowrap">';
+		print '<div class="inline-block">'.$companystatic->LibProspCommStatut($obj->stcomm_id,2,$prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label']);
+		print '</div> - <div class="inline-block">';
 		foreach($prospectstatic->cacheprospectstatus as $key => $val)
 		{
-	        $arraystcomm[$val['id']]=($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
+			$titlealt='default';
+			if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt=$val['label'];
+			if ($obj->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?stcommsocid='.$obj->rowid.'&stcomm='.$val['code'].'&action=setstcomm'.$param.($page?'&page='.urlencode($page):'').'">'.img_action($titlealt,$val['code']).'</a>';
 		}
-	    print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2);
-	    print '</td>';
+		print '</div></div></td>';
     }
 	// Extra fields
 	if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
@@ -781,267 +998,55 @@ if ($resql)
 	   {
 			if (! empty($arrayfields["ef.".$key]['checked'])) 
 			{
-                $align=$extrafields->getAlignFlag($key);
-                $typeofextrafield=$extrafields->attribute_type[$key];
-                print '<td class="liste_titre'.($align?' '.$align:'').'">';
-    		    if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')))
-				{
-				    $crit=$val;
-    				$tmpkey=preg_replace('/search_options_/','',$key);
-    				$searchclass='';
-    				if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
-    				if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
-    				print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
-				}
+				print '<td';
+				$align=$extrafields->getAlignFlag($key);
+				if ($align) print ' align="'.$align.'"';
+				print '>';
+				$tmpkey='options_'.$key;
+				print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
 				print '</td>';
 			}
 	   }
 	}
     // Fields from hook
-	$parameters=array('arrayfields'=>$arrayfields);
-    $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters);    // Note that $action and $object may have been modified by hook
+    $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
+	$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters);    // Note that $action and $object may have been modified by hook
     print $hookmanager->resPrint;
     // Date creation
     if (! empty($arrayfields['s.datec']['checked']))
     {
-        print '<td class="liste_titre">';
+        print '<td align="center" class="nowrap">';
+        print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
         print '</td>';
     }
     // Date modification
     if (! empty($arrayfields['s.tms']['checked']))
     {
-        print '<td class="liste_titre">';
+        print '<td align="center" class="nowrap">';
+        print dol_print_date($db->jdate($obj->date_update), 'dayhour');
         print '</td>';
     }
     // Status
     if (! empty($arrayfields['s.status']['checked']))
     {
-        print '<td class="liste_titre maxwidthonsmartphone" align="center">';
-        print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status);
-        print '</td>';
+        print '<td align="center" class="nowrap">'.$companystatic->getLibStatut(3).'</td>';
     }
     // Action column
-    print '<td class="liste_titre" align="right">';
-    $searchpitco=$form->showFilterAndCheckAddButtons(0);
-    print $searchpitco;
-    print '</td>';
+    print '<td></td>';
 
-	print "</tr>\n";
-
-	$var=True;
-
-	while ($i < min($num, $limit))
-	{
-		$obj = $db->fetch_object($resql);
-		$var=!$var;
-		
-		$companystatic->id=$obj->rowid;
-		$companystatic->name=$obj->name;
-		$companystatic->canvas=$obj->canvas;
-		$companystatic->client=$obj->client;
-		$companystatic->status=$obj->status;
-		$companystatic->fournisseur=$obj->fournisseur;
-		$companystatic->code_client=$obj->code_client;
-		$companystatic->code_fournisseur=$obj->code_fournisseur;
-        $companystatic->fk_prospectlevel=$obj->fk_prospectlevel;
-        $companystatic->name_alias=$obj->name_alias;
-		
-		print "<tr ".$bc[$var].">";
-		if (! empty($arrayfields['s.nom']['checked']))
-		{
-    		print "<td>";
-    		print $companystatic->getNomUrl(1,'',100);
-    		print "</td>\n";
-		}
-		// Barcode
-        if (! empty($arrayfields['s.barcode']['checked']))
-		{
-			print '<td>'.$obj->barcode.'</td>';
-		}
-    	// Customer code
-        if (! empty($arrayfields['s.code_client']['checked']))
-		{
-			print '<td>'.$obj->code_client.'</td>';
-		}
-	    // Supplier code
-        if (! empty($arrayfields['s.code_fournisseur']['checked']))
-		{
-			print '<td>'.$obj->code_fournisseur.'</td>';
-		}
-    	// Account customer code
-        if (! empty($arrayfields['s.code_compta']['checked']))
-		{
-			print '<td>'.$obj->code_compta.'</td>';
-		}
-	    // Account supplier code
-        if (! empty($arrayfields['s.code_compta_fournisseur']['checked']))
-		{
-			print '<td>'.$obj->code_compta_fournisseur.'</td>';
-		}
-		// Town
-        if (! empty($arrayfields['s.town']['checked']))
-        {
-            print "<td>".$obj->town."</td>\n";
-        }
-        // Zip
-	    if (! empty($arrayfields['s.zip']['checked']))
-        {
-            print "<td>".$obj->zip."</td>\n";
-        }        
-	    // State
-	    if (! empty($arrayfields['state.nom']['checked']))
-        {
-            print "<td>".$obj->state_name."</td>\n";
-        }        
-        // Country
-        if (! empty($arrayfields['country.code_iso']['checked']))
-        {
-            print '<td align="center">';
-    		$tmparray=getCountry($obj->fk_pays,'all');
-    		print $tmparray['label'];
-    		print '</td>';
-        }
-		// Type ent
-        if (! empty($arrayfields['typent.code']['checked']))
-        {
-            print '<td align="center">';
-    		if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
-    		print $typenArray[$obj->typent_code];
-    		print '</td>';
-        }
-        if (! empty($arrayfields['s.siren']['checked']))
-        {
-            print "<td>".$obj->idprof1."</td>\n";
-        }
-        if (! empty($arrayfields['s.siret']['checked']))
-        {
-            print "<td>".$obj->idprof2."</td>\n";
-        }
-        if (! empty($arrayfields['s.ape']['checked']))
-        {
-            print "<td>".$obj->idprof3."</td>\n";
-        }
-	    if (! empty($arrayfields['s.idprof4']['checked']))
-        {
-            print "<td>".$obj->idprof4."</td>\n";
-        }
-	    if (! empty($arrayfields['s.idprof5']['checked']))
-        {
-            print "<td>".$obj->idprof5."</td>\n";
-        }
-	    if (! empty($arrayfields['s.idprof6']['checked']))
-        {
-            print "<td>".$obj->idprof6."</td>\n";
-        }
-        // Type
-        print '<td align="center">';
-		$s='';
-		if (($obj->client==1 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
-		{
-	  		$companystatic->name=$langs->trans("Customer");
-	  		$companystatic->name_alias='';
-		    $s.=$companystatic->getNomUrl(0,'customer');
-		}
-		if (($obj->client==2 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
-		{
-            if ($s) $s.=" / ";
-		    $companystatic->name=$langs->trans("Prospect");
-	  		$companystatic->name_alias='';
-		    $s.=$companystatic->getNomUrl(0,'prospect');
-		}
-		if (! empty($conf->fournisseur->enabled) && $obj->fournisseur)
-		{
-			if ($s) $s.=" / ";
-            $companystatic->name=$langs->trans("Supplier");
-	  		$companystatic->name_alias='';
-            $s.=$companystatic->getNomUrl(0,'supplier');
-		}
-		print $s;
-		print '</td>';
-	    if (! empty($arrayfields['s.fk_prospectlevel']['checked']))
-        {
-			// Prospect level
-			print '<td align="center">';
-			print $companystatic->getLibProspLevel();
-			print "</td>";
-        }
-	    if (! empty($arrayfields['s.fk_stcomm']['checked']))
-        {
-	        // Prospect status
-			print '<td align="center" class="nowrap"><div class="nowrap">';
-			print '<div class="inline-block">'.$companystatic->LibProspCommStatut($obj->stcomm_id,2,$prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label']);
-			print '</div> - <div class="inline-block">';
-			foreach($prospectstatic->cacheprospectstatus as $key => $val)
-			{
-				$titlealt='default';
-				if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt=$val['label'];
-				if ($obj->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?stcommsocid='.$obj->rowid.'&stcomm='.$val['code'].'&action=setstcomm'.$param.($page?'&page='.urlencode($page):'').'">'.img_action($titlealt,$val['code']).'</a>';
-			}
-			print '</div></div></td>';
-        }
-		// Extra fields
-		if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
-		{
-		   foreach($extrafields->attribute_label as $key => $val) 
-		   {
-				if (! empty($arrayfields["ef.".$key]['checked'])) 
-				{
-					print '<td';
-					$align=$extrafields->getAlignFlag($key);
-					if ($align) print ' align="'.$align.'"';
-					print '>';
-					$tmpkey='options_'.$key;
-					print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
-					print '</td>';
-				}
-		   }
-		}
-        // Fields from hook
-	    $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
-		$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters);    // Note that $action and $object may have been modified by hook
-        print $hookmanager->resPrint;
-        // Date creation
-        if (! empty($arrayfields['s.datec']['checked']))
-        {
-            print '<td align="center" class="nowrap">';
-            print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
-            print '</td>';
-        }
-        // Date modification
-        if (! empty($arrayfields['s.tms']['checked']))
-        {
-            print '<td align="center" class="nowrap">';
-            print dol_print_date($db->jdate($obj->date_update), 'dayhour');
-            print '</td>';
-        }
-	    // Status
-        if (! empty($arrayfields['s.status']['checked']))
-        {
-            print '<td align="center" class="nowrap">'.$companystatic->getLibStatut(3).'</td>';
-        }
-        // Action column
-        print '<td></td>';
-
-		print '</tr>'."\n";
-		$i++;
-	}
-
-	$db->free($resql);
+	print '</tr>'."\n";
+	$i++;
+}
 
-	$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
-	$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters);    // Note that $action and $object may have been modified by hook
-	print $hookmanager->resPrint;
+$db->free($resql);
 
-	print "</table>";
+$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
+$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters);    // Note that $action and $object may have been modified by hook
+print $hookmanager->resPrint;
 
-	print '</form>';
+print "</table>";
 
-}
-else
-{
-	dol_print_error($db);
-}
+print '</form>';
 
 llxFooter();
-
 $db->close();