diff --git a/htdocs/comm/list.php b/htdocs/comm/list.php index 126ffc5f470..9752abd31cb 100644 --- a/htdocs/comm/list.php +++ b/htdocs/comm/list.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Cédric Salvador - * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013-2015 Florian Henry * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Marcos García * @@ -29,6 +29,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $langs->load("companies"); $langs->load("customers"); @@ -50,12 +52,14 @@ $pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="s.nom"; -$search_company=GETPOST("search_company"); -$search_zipcode=GETPOST("search_zipcode"); -$search_town=GETPOST("search_town"); -$search_code=GETPOST("search_code"); -$search_compta=GETPOST("search_compta"); -$search_status= GETPOST("search_status",'int'); +$search_company = GETPOST("search_company"); +$search_zipcode = GETPOST("search_zipcode"); +$search_town = GETPOST("search_town"); +$search_code = GETPOST("search_code"); +$search_compta = GETPOST("search_compta"); +$search_status = GETPOST("search_status",'int'); +$search_country = GETPOST("search_country",'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty",'int'); // Load sale and categ filters $search_sale = GETPOST("search_sale",'int'); @@ -89,6 +93,8 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_code=''; $search_compta=''; $search_status=''; + $search_country=""; + $search_type_thirdparty=''; } if ($search_status=='') $search_status=1; // always display activ customer first @@ -101,12 +107,15 @@ if ($search_status=='') $search_status=1; // always display activ customer first $formother=new FormOther($db); $form = new Form($db); $thirdpartystatic=new Societe($db); +$formcompany=new FormCompany($db); $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('',$langs->trans("ThirdParty"),$help_url); $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.client, s.zip, s.town, st.libelle as stcomm, s.prefix_comm, s.code_client, s.code_compta, s.status as status,"; $sql.= " s.datec, s.canvas"; +$sql.= ",s.fk_pays"; +$sql.= ",typent.code as typent_code"; if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $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) // Add fields for extrafields foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key; @@ -116,12 +125,14 @@ $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // N $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (! empty($search_categ) || ! empty($catid)) $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 ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays) "; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent) "; +if ((!$user->rights->societe->client->voir && !$socid) || $search_sale) $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."c_stcomm as st"; $sql.= " WHERE s.fk_stcomm = st.id"; $sql.= " AND s.client IN (1, 3)"; $sql.= ' AND s.entity IN ('.getEntity('societe', 1).')'; -if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; +if ((!$user->rights->societe->client->voir && !$socid) || $search_sale) $sql.= " AND s.rowid = sc.fk_soc"; if ($socid) $sql.= " AND s.rowid = ".$socid; if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale if ($catid > 0) $sql.= " AND cs.fk_categorie = ".$catid; @@ -134,6 +145,8 @@ if ($search_town) $sql.= natural_search('s.town', $search_town); if ($search_code) $sql.= natural_search("s.code_client", $search_code); if ($search_compta) $sql.= natural_search("s.code_compta", $search_compta); if ($search_status!='') $sql.= " AND s.status = ".$db->escape($search_status); +if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; +if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_sale > 0) $sql.= " AND sc.fk_user = ".$search_sale; // Add where from hooks $parameters=array(); @@ -157,10 +170,15 @@ if ($result) { $num = $db->num_rows($result); - $param = "&search_company=".$search_company."&search_code=".$search_code."&search_zipcode=".$search_zipcode."&search_town=".$search_town; - if ($search_categ != '') $param.='&search_categ='.$search_categ; - if ($search_sale > 0) $param.='&search_sale='.$search_sale; - if ($search_status != '') $param.='&search_status='.$search_status; + $param = "&search_company=".htmlspecialchars($search_company); + $param.="&search_code=".htmlspecialchars($search_code); + $param.="&search_zipcode=".htmlspecialchars($search_zipcode); + $param.="&search_town=".htmlspecialchars($search_town); + if ($search_categ != '') $param.='&search_categ='.htmlspecialchars($search_categ); + if ($search_sale > 0) $param.='&search_sale='.htmlspecialchars($search_sale); + if ($search_status != '') $param.='&search_status='.htmlspecialchars($search_status); + if ($search_country != '') $param.='&search_country='.htmlspecialchars($search_country); + if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.htmlspecialchars($search_type_thirdparty); print_barre_liste($langs->trans("ListOfCustomers"), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_companies.png'); @@ -198,6 +216,8 @@ if ($result) print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Zip"),$_SERVER["PHP_SELF"],"s.zip","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"s.town","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Country"),$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ThirdPartyType"),$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("AccountancyCode"),$_SERVER["PHP_SELF"],"s.code_compta","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"datec","",$param,'align="right"',$sortfield,$sortorder); @@ -222,6 +242,14 @@ if ($result) print ''; print ''; + print ''; + print $form->select_country($search_country,'search_country'); + print ''; + + print ''; + 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 ''; + print ''; print ''; print ''; @@ -270,6 +298,16 @@ if ($result) print ''; print ''.$obj->zip.''; print ''.$obj->town.''; + //Country + print ''; + $tmparray=getCountry($obj->fk_pays,'all'); + print $tmparray['label']; + print ''; + //Type ent + print ''; + if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); + print $typenArray[$obj->typent_code]; + print ''; print ''.$obj->code_client.''; print ''.$obj->code_compta.''; print ''.dol_print_date($db->jdate($obj->datec),'day').''; diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php index 6977c80be87..b7a48331dd9 100644 --- a/htdocs/comm/prospect/list.php +++ b/htdocs/comm/prospect/list.php @@ -33,6 +33,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $langs->load("propal"); $langs->load("companies"); @@ -216,6 +217,7 @@ if (empty($reshook)) $formother=new FormOther($db); $form=new Form($db); +$formcompany=new FormCompany($db); $prospectstatic=new Client($db); $prospectstatic->client=2; $prospectstatic->loadCacheOfProspStatus(); @@ -259,6 +261,8 @@ if ($search_datec) $sql .= " AND s.datec LIKE '%".$db->escape($search_datec)." if ($search_status!='') $sql .= " AND s.status = ".$db->escape($search_status); // Insert levels filters if ($search_levels) $sql .= " AND s.fk_prospectlevel IN (".$search_levels.')'; +if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; +if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; // Insert sale filter if ($search_sale > 0) $sql .= " AND sc.fk_user = ".$db->escape($search_sale); if ($socname) @@ -313,7 +317,10 @@ if ($resql) llxHeader('',$langs->trans("ThirdParty"),$help_url); } - $param='&search_stcomm='.$search_stcomm.'&search_nom='.urlencode($search_nom).'&search_zipcode='.urlencode($search_zipcode).'&search_town='.urlencode($search_town); + $param='&search_stcomm='.$search_stcomm; + $param.='&search_nom='.urlencode($search_nom); + $param.='&search_zipcode='.urlencode($search_zipcode); + $param.='&search_town='.urlencode($search_town); // Store the status filter in the URL if (isSet($search_setstcomm)) { @@ -419,6 +426,12 @@ if ($resql) print ''; print ''; print ''; + print ''; + print $form->select_country($search_country,'search_country'); + print ''; + print ''; + 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 ''; print ''; print ''; print ''; @@ -522,9 +535,7 @@ if ($resql) print ''; //Type ent print ''; - if (count($typenArray)==0) { - $typenArray = $formcompany->typent_array(1); - } + if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); print $typenArray[$obj->typent_code]; print ''; // Creation date diff --git a/htdocs/fourn/list.php b/htdocs/fourn/list.php index 3333ffefba2..d05359945d1 100644 --- a/htdocs/fourn/list.php +++ b/htdocs/fourn/list.php @@ -5,6 +5,7 @@ * Copyright (C) 2011 Philippe Grand * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2015 Florian Henry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,6 +30,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $langs->load("suppliers"); $langs->load("orders"); @@ -44,6 +47,8 @@ $search_datec = GETPOST("search_datec"); $search_categ = GETPOST('search_categ','int'); $search_status = GETPOST("search_status",'int'); $catid = GETPOST("catid",'int'); +$search_country = GETPOST("search_country",'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty",'int'); // Security check $socid = GETPOST('socid','int'); @@ -76,6 +81,8 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_categ=""; $search_status=''; $catid=""; + $search_country=""; + $search_type_thirdparty=""; } if ($search_status=='') $search_status=1; // always display activ customer first @@ -99,12 +106,15 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e $form=new Form($db); $htmlother=new FormOther($db); $thirdpartystatic=new Societe($db); +$formcompany=new FormCompany($db); $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('',$langs->trans("ThirdParty"),$help_url); $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias, s.zip, s.town, s.datec, st.libelle as stcomm, s.prefix_comm, s.status as status, "; $sql.= "code_fournisseur, code_compta_fournisseur"; +$sql.= ",s.fk_pays"; +$sql.= ",typent.code as typent_code"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; // Add fields for extrafields foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key; @@ -114,6 +124,8 @@ $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // N $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as ef ON ef.fk_object = s.rowid"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays) "; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent) "; if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cf ON s.rowid = cf.fk_soc"; // We need this table joined to the select in order to filter by categ $sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -137,6 +149,8 @@ if ($catid > 0) $sql.= " AND cf.fk_categorie = ".$catid; if ($catid == -2) $sql.= " AND cf.fk_categorie IS NULL"; if ($search_categ > 0) $sql.= " AND cf.fk_categorie = ".$search_categ; if ($search_categ == -2) $sql.= " AND cf.fk_categorie IS NULL"; +if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; +if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook @@ -160,9 +174,14 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; - $param = "&search_name=".$search_name."&search_supplier_code=".$search_supplier_code."&search_zipcode=".$search_zipcode."&search_town=".$search_town; - if ($search_categ != '') $param.='&search_categ='.$search_categ; - if ($search_status != '') $param.='&search_status='.$search_status; + $param = "&search_name=".htmlspecialchars($search_name); + $param.="&search_supplier_code=".htmlspecialchars($search_supplier_code); + $param.="&search_zipcode=".htmlspecialchars($search_zipcode); + $param.="&search_town=".htmlspecialchars($search_town); + if ($search_categ != '') $param.='&search_categ='.htmlspecialchars($search_categ); + if ($search_status != '') $param.='&search_status='.htmlspecialchars($search_status); + if ($search_country != '') $param.='&search_country='.htmlspecialchars($search_country); + if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.htmlspecialchars($search_type_thirdparty); print_barre_liste($langs->trans("ListOfSuppliers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies'); @@ -193,6 +212,8 @@ if ($resql) print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","",$param,'valign="middle"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Zip"),$_SERVER["PHP_SELF"],"s.zip","",$param,'valign="middle"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"s.town","",$param,'valign="middle"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Country"),$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ThirdPartyType"),$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("SupplierCode"),$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("AccountancyCode"),$_SERVER["PHP_SELF"],"s.code_compta_fournisseur","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"s.datec","",$param,'align="right"',$sortfield,$sortorder); @@ -213,6 +234,14 @@ if ($resql) print ''; + print ''; + print $form->select_country($search_country,'search_country'); + print ''; + + print ''; + 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 ''; + print ''; print ''; print ''; @@ -257,6 +286,16 @@ if ($resql) print "\n"; print ''.$obj->zip.''."\n"; print ''.$obj->town.''."\n"; + //Country + print ''; + $tmparray=getCountry($obj->fk_pays,'all'); + print $tmparray['label']; + print ''; + //Type ent + print ''; + if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); + print $typenArray[$obj->typent_code]; + print ''; print ''.$obj->code_fournisseur.' '; print ''.$obj->code_compta_fournisseur.' '; print ''.dol_print_date($db->jdate($obj->datec),'day').''; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 281746fe824..20d4b6c477f 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Marcos García * Copyright (C) 2013-2015 Raphaël Doursenaud + * Copyright (C) 2015 Florian Henry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,6 +29,8 @@ require_once '../main.inc.php'; include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $langs->load("companies"); $langs->load("customers"); @@ -55,6 +58,8 @@ $search_categ=trim(GETPOST("search_categ")); $mode=GETPOST("mode"); $modesearch=GETPOST("mode_search"); $search_type=trim(GETPOST('search_type')); +$search_country = GETPOST("search_country",'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty",'int'); $sortfield=GETPOST("sortfield",'alpha'); $sortorder=GETPOST("sortorder",'alpha'); @@ -153,6 +158,7 @@ if ($mode == 'search') $form=new Form($db); $htmlother=new FormOther($db); $companystatic=new Societe($db); +$formcompany=new FormCompany($db); $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('',$langs->trans("ThirdParty"),$help_url); @@ -172,6 +178,8 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_idprof3=''; $search_idprof4=''; $search_type=''; + $search_country=''; + $search_type_thirdparty=''; } if ($socname) @@ -195,6 +203,8 @@ $title=$langs->trans("ListOfThirdParties"); $sql = "SELECT s.rowid, s.nom as name, s.barcode, s.town, s.datec, s.code_client, s.code_fournisseur, "; $sql.= " st.libelle as stcomm, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,"; $sql.= " s.siren as idprof1, s.siret as idprof2, ape as idprof3, idprof4 as idprof4"; +$sql.= ",s.fk_pays"; +$sql.= ",typent.code as typent_code"; // 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 @@ -205,8 +215,10 @@ foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as op $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,"; -$sql.= " ".MAIN_DB_PREFIX."c_stcomm as st"; +$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays) "; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent) "; +$sql.= " ,".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 && !$socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We'll need this table joined to the select in order to filter by categ @@ -235,6 +247,8 @@ if ($search_type > 0 && in_array($search_type,array('1,3','2,3'))) $sql .= " AND 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"; if (!empty($conf->barcode->enabled) && $sbarcode) $sql.= " AND s.barcode LIKE '%".$db->escape($sbarcode)."%'"; +if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; +if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook @@ -257,14 +271,18 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; - $params = "&socname=".htmlspecialchars($socname)."&search_nom=".htmlspecialchars($search_nom)."&search_town=".htmlspecialchars($search_town); - $params.= ($sbarcode?"&sbarcode=".htmlspecialchars($sbarcode):""); - $params.= '&search_idprof1='.htmlspecialchars($search_idprof1); - $params.= '&search_idprof2='.htmlspecialchars($search_idprof2); - $params.= '&search_idprof3='.htmlspecialchars($search_idprof3); - $params.= '&search_idprof4='.htmlspecialchars($search_idprof4); + $param = "&socname=".htmlspecialchars($socname); + $param.= "&search_nom=".htmlspecialchars($search_nom); + $param.= "&search_town=".htmlspecialchars($search_town); + $param.= ($sbarcode?"&sbarcode=".htmlspecialchars($sbarcode):""); + $param.= '&search_idprof1='.htmlspecialchars($search_idprof1); + $param.= '&search_idprof2='.htmlspecialchars($search_idprof2); + $param.= '&search_idprof3='.htmlspecialchars($search_idprof3); + $param.= '&search_idprof4='.htmlspecialchars($search_idprof4); + if ($search_country != '') $param.='&search_country='.htmlspecialchars($search_country); + if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.htmlspecialchars($search_type_thirdparty); - print_barre_liste($title, $page, $_SERVER["PHP_SELF"],$params,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_companies'); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_companies'); // Show delete result message if (GETPOST('delsoc')) @@ -325,18 +343,20 @@ if ($resql) // Lines of titles print ''; - print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","",$params,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); if (! empty($conf->barcode->enabled)) print_liste_field_titre($langs->trans("BarCode"), $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"s.town","",$params,'',$sortfield,$sortorder); - print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"),$textprofid[1],1,0),$_SERVER["PHP_SELF"],"s.siren","",$params,'class="nowrap"',$sortfield,$sortorder); - print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"),$textprofid[2],1,0),$_SERVER["PHP_SELF"],"s.siret","",$params,'class="nowrap"',$sortfield,$sortorder); - print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"),$textprofid[3],1,0),$_SERVER["PHP_SELF"],"s.ape","",$params,'class="nowrap"',$sortfield,$sortorder); - print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$params,'class="nowrap"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Country"),$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ThirdPartyType"),$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"),$textprofid[1],1,0),$_SERVER["PHP_SELF"],"s.siren","",$param,'class="nowrap"',$sortfield,$sortorder); + print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"),$textprofid[2],1,0),$_SERVER["PHP_SELF"],"s.siret","",$param,'class="nowrap"',$sortfield,$sortorder); + print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"),$textprofid[3],1,0),$_SERVER["PHP_SELF"],"s.ape","",$param,'class="nowrap"',$sortfield,$sortorder); + print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$param,'class="nowrap"',$sortfield,$sortorder); print_liste_field_titre(''); $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$params,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; @@ -359,6 +379,14 @@ if ($resql) print ''; print ''; print ''; + //Country + print ''; + print $form->select_country($search_country,'search_country'); + print ''; + //Company type + print ''; + 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 ''; // IdProf1 print ''; print ''; @@ -424,6 +452,16 @@ if ($resql) print ''.$objp->barcode.''; } print "".$obj->town."\n"; + //Country + print ''; + $tmparray=getCountry($obj->fk_pays,'all'); + print $tmparray['label']; + print ''; + //Type ent + print ''; + if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); + print $typenArray[$obj->typent_code]; + print ''; print "".$obj->idprof1."\n"; print "".$obj->idprof2."\n"; print "".$obj->idprof3."\n";