diff --git a/dev/skeletons/skeleton_page.php b/dev/skeletons/skeleton_page.php
index 334980b1470..653fd617a06 100644
--- a/dev/skeletons/skeleton_page.php
+++ b/dev/skeletons/skeleton_page.php
@@ -74,6 +74,7 @@ if (($id > 0 || ! empty($ref)) && $action != 'add')
// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('skeleton'));
+$extrafields = new ExtraFields($db);
@@ -230,8 +231,18 @@ if ($action == 'list' || empty($id))
$sql.= " t.rowid,";
$sql.= " t.field1,";
$sql.= " t.field2";
+ // Add fields for extrafields
+ foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key;
+ // Add fields from hooks
+ $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."mytable as t";
$sql.= " WHERE field3 = 'xxx'";
+ // Add where from hooks
+ $parameters=array();
+ $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
+ $sql.=$hookmanager->resPrint;
$sql.= " ORDER BY field1 ASC";
print '
\n";
diff --git a/htdocs/comm/list.php b/htdocs/comm/list.php
index cf5bacc5e25..9e42d2e7167 100644
--- a/htdocs/comm/list.php
+++ b/htdocs/comm/list.php
@@ -66,6 +66,7 @@ if (!$user->rights->societe->client->voir && !$socid) $search_sale = $user->id;
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('customerlist'));
+$extrafields = new ExtraFields($db);
/*
@@ -107,6 +108,12 @@ 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";
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;
+// Add fields from hooks
+$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";
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
@@ -116,33 +123,22 @@ $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 ($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 ($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;
if ($catid == -2) $sql.= " AND cs.fk_categorie IS NULL";
if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ;
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
-if ($search_company) {
- $sql .= natural_search(
- array(
- 's.nom',
- 's.name_alias'
- ),
- $search_company
- );
-}
-if ($search_zipcode) $sql.= " AND s.zip LIKE '".$db->escape($search_zipcode)."%'";
-if ($search_town) {
- $sql .= natural_search('s.town', $search_town);
-}
-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_status!='') $sql .= " AND s.status = ".$db->escape($search_status);
-// Insert sale filter
-if ($search_sale > 0)
-{
- $sql .= " AND sc.fk_user = ".$search_sale;
-}
+if ($search_company) $sql.= natural_search(array('s.nom', 's.name_alias'), $search_company);
+if ($search_zipcode) $sql.= natural_search("s.zip", $search_zipcode);
+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_sale > 0) $sql.= " AND sc.fk_user = ".$search_sale;
+// Add where from hooks
+$parameters=array();
+$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
+$sql.=$hookmanager->resPrint;
// Count total nb of records
$nbtotalofrecords = 0;
@@ -190,6 +186,9 @@ if ($result)
{
print '
';
print $moreforfilter;
+ $parameters=array();
+ $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
print '
';
}
@@ -202,11 +201,12 @@ if ($result)
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);
+ $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","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre('');
- $parameters=array();
- $formconfirm=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
- print "\n";
+ print "\n";
print '
';
@@ -234,6 +234,10 @@ if ($result)
print ' ';
print '';
+ $parameters=array();
+ $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+
print '
';
@@ -242,9 +246,6 @@ if ($result)
print '';
print '';
- $parameters=array();
- $formconfirm=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
-
print '
'."\n";
@@ -272,12 +273,15 @@ if ($result)
print '
'.$obj->code_client.'
';
print '
'.$obj->code_compta.'
';
print '
'.dol_print_date($db->jdate($obj->datec),'day').'
';
- print '
'.$thirdpartystatic->getLibStatut(3);
- print '
';
- print '
';
$parameters=array('obj' => $obj);
- $formconfirm=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
+ $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+
+ print '
'.$thirdpartystatic->getLibStatut(3);
+ print '
';
+
+ print '
';
print "\n";
$i++;
@@ -285,7 +289,8 @@ if ($result)
$db->free($result);
$parameters=array('sql' => $sql);
- $formconfirm=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
+ $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
print "\n";
print "\n";
diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php
index 68299c9a781..5f841b609da 100644
--- a/htdocs/comm/prospect/list.php
+++ b/htdocs/comm/prospect/list.php
@@ -156,6 +156,7 @@ $sts = array(-1,0,1,2,3);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('prospectlist'));
+$extrafields = new ExtraFields($db);
// Do we click on purge search criteria ?
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
@@ -214,6 +215,12 @@ $sql.= " s.prefix_comm, s.fk_prospectlevel, s.fk_stcomm as stcomm_id,";
$sql.= " st.libelle as stcomm_label,";
$sql.= " d.nom as departement";
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;
+// Add fields from hooks
+$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."c_stcomm as st";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d on (d.rowid = s.fk_departement)";
@@ -229,15 +236,7 @@ if ($catid > 0) $sql.= " AND cs.fk_categorie = ".$catid;
if ($catid == -2) $sql.= " AND cs.fk_categorie IS NULL";
if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ;
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
-if ($search_nom) {
- $sql .= natural_search(
- array(
- 's.nom',
- 's.name_alias'
- ),
- $search_nom
- );
-}
+if ($search_nom) $sql .= natural_search(array('s.nom','s.name_alias'), $search_nom);
if ($search_zipcode) $sql .= " AND s.zip LIKE '".$db->escape(strtolower($search_zipcode))."%'";
if ($search_town) $sql .= natural_search('s.town', $search_town);
if ($search_state) $sql .= natural_search('d.nom', $search_state);
@@ -253,6 +252,10 @@ if ($socname)
$sortfield = "s.nom";
$sortorder = "ASC";
}
+// Add where from hooks
+$parameters=array();
+$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
+$sql.=$hookmanager->resPrint;
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
@@ -326,6 +329,9 @@ if ($resql)
{
print '
';
print $moreforfilter;
+ $parameters=array();
+ $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
print '
';
}
@@ -340,11 +346,13 @@ if ($resql)
print_liste_field_titre($langs->trans("ProspectLevelShort"),$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("StatusProsp"),$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre('');
- print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder);
- print_liste_field_titre('');
- $parameters=array();
- $formconfirm=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
+ $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","",$param,'align="center"',$sortfield,$sortorder);
+ print_liste_field_titre('');
print "\n";
@@ -404,6 +412,10 @@ if ($resql)
print ' ';
print '';
+ $parameters=array();
+ $reshook=$hookmanager->executeHooks('printFieldListSearch',$parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+
print '
';
@@ -413,10 +425,6 @@ if ($resql)
print '';
print "\n";
- $parameters=array();
- $reshook=$hookmanager->executeHooks('printFieldListSearch',$parameters); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
-
print "\n";
$i = 0;
@@ -462,13 +470,15 @@ if ($resql)
}
print '';
- print '
';
+ $parameters=array('obj' => $obj);
+ $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+
+ print '
';
- $parameters=array('obj' => $obj);
- $formconfirm=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
+ print '
';
print "\n";
$i++;
@@ -483,7 +493,8 @@ if ($resql)
$db->free($resql);
$parameters=array('sql' => $sql);
- $formconfirm=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
+ $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
}
else
{
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 3aadf529843..0f4f826e27d 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -5037,10 +5037,10 @@ function dol_getmypid()
* If param $mode is 1, can contains an operator <, > or = like "<10" or ">=100.5 < 1000"
* If param $mode is 2, can contains a list of id separated by comma like "1,3,4"
* @param integer $mode 0=value is list of keywords, 1=value is a numeric test (Example ">5.5 <10"), 2=value is a list of id separated with comma (Example '1,3,4')
- * @param integer $nofinaland 1=Do now output the final 'AND'
+ * @param integer $nofirstand 1=Do now output the first 'AND'
* @return string $res The statement to append to the SQL query
*/
-function natural_search($fields, $value, $mode=0, $nofinaland=0)
+function natural_search($fields, $value, $mode=0, $nofirstand=0)
{
global $db,$langs;
@@ -5107,7 +5107,7 @@ function natural_search($fields, $value, $mode=0, $nofinaland=0)
if ($newres) $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') .$newres . ($i2 > 1 ? ')' : '');
$j++;
}
- $res = ($nofinaland?"":" AND ")."(" . $res . ")";
+ $res = ($nofirstand?"":" AND ")."(" . $res . ")";
//print 'xx'.$res.'yy';
return $res;
}
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index ef83701518c..66768696320 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -1133,6 +1133,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
/*
* Menu SUPPLIERS
*/
+ /*
if ($mainmenu == 'suppliers')
{
$langs->load("suppliers");
@@ -1173,6 +1174,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
}
}
+ */
/*
* Menu PROJECTS
diff --git a/htdocs/core/search_page.php b/htdocs/core/search_page.php
index 49fefc3ebed..dc90a7c3853 100644
--- a/htdocs/core/search_page.php
+++ b/htdocs/core/search_page.php
@@ -70,7 +70,7 @@ $searchform = '';
if ((( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)) && ! empty($conf->global->MAIN_SEARCHFORM_SOCIETE) && $user->rights->societe->lire)
{
$langs->load("companies");
- $searchform.=printSearchForm(DOL_URL_ROOT.'/societe/societe.php', DOL_URL_ROOT.'/societe/societe.php', img_object('','company').' '.$langs->trans("ThirdParties"), 'soc', 'socname');
+ $searchform.=printSearchForm(DOL_URL_ROOT.'/societe/list.php', DOL_URL_ROOT.'/societe/list.php', img_object('','company').' '.$langs->trans("ThirdParties"), 'soc', 'socname');
$nbofsearch++;
}
diff --git a/htdocs/fourn/list.php b/htdocs/fourn/list.php
index f5f4d4dc897..c473f89a3b1 100644
--- a/htdocs/fourn/list.php
+++ b/htdocs/fourn/list.php
@@ -105,7 +105,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.f
foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key;
// Add fields from hooks
$parameters=array();
-$result=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
+$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.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as ef ON ef.fk_object = s.rowid";
@@ -121,19 +121,9 @@ if ($socname) {
$sortfield = "s.nom";
$sortorder = "ASC";
}
-if ($search_name) {
- $sql .= natural_search(
- array(
- 's.nom',
- 's.name_alias'
- ),
- $search_name
- );
-}
+if ($search_name) $sql .= natural_search(array('s.nom', 's.name_alias'), $search_name);
if ($search_zipcode) $sql .= " AND s.zip LIKE '".$db->escape($search_zipcode)."%'";
-if ($search_town) {
- $sql .= natural_search('s.town', $search_town);
-}
+if ($search_town) $sql .= natural_search('s.town', $search_town);
if ($search_supplier_code) $sql .= " AND s.code_fournisseur LIKE '%".$db->escape($search_supplier_code)."%'";
if ($search_supplier_accounting) $sql .= " AND s.code_compta_fournisseur LIKE '%".$db->escape($search_supplier_accounting)."%'";
if ($search_datec) $sql .= " AND s.datec LIKE '%".$db->escape($search_datec)."%'";
@@ -143,8 +133,9 @@ if ($search_categ > 0) $sql.= " AND cf.fk_categorie = ".$search_categ;
if ($search_categ == -2) $sql.= " AND cf.fk_categorie IS NULL";
// Add where from hooks
$parameters=array();
-$result=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
+$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
+
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
@@ -166,7 +157,7 @@ if ($resql)
$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;
- print_barre_liste($langs->trans("ListOfSuppliers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords);
+ print_barre_liste($langs->trans("ListOfSuppliers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies');
print '\n";
diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php
index 383ed9e8ff8..b2b0f954a58 100644
--- a/htdocs/societe/canvas/actions_card_common.class.php
+++ b/htdocs/societe/canvas/actions_card_common.class.php
@@ -307,7 +307,7 @@ abstract class ActionsCardCommon
if ($result >= 0)
{
- header("Location: ".DOL_URL_ROOT."/societe/societe.php?delsoc=".$this->object->name."");
+ header("Location: ".DOL_URL_ROOT."/societe/list.php?delsoc=".$this->object->name."");
exit;
}
else
diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php
index b03cb62eef0..12de6db7707 100644
--- a/htdocs/societe/index.php
+++ b/htdocs/societe/index.php
@@ -61,7 +61,7 @@ print '
';
*/
$rowspan=2;
if (! empty($conf->barcode->enabled)) $rowspan++;
-print '