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 '
'; @@ -241,7 +252,8 @@ if ($action == 'list' || empty($id)) print '
'; print $moreforfilter; $parameters=array(); - $formconfirm=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; print '
'; } @@ -252,7 +264,8 @@ if ($action == 'list' || empty($id)) print_liste_field_titre($langs->trans('field1'),$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans('field2'),$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder); $parameters=array(); - $formconfirm=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; print ''."\n"; // Fields title search @@ -264,7 +277,8 @@ if ($action == 'list' || empty($id)) print ''; print ''; $parameters=array(); - $formconfirm=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; print ''."\n"; @@ -287,8 +301,9 @@ if ($action == 'list' || empty($id)) print $obj->field2; print ''; $parameters=array('obj' => $obj); - $formconfirm=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print ''; + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print ''; } $i++; } @@ -302,7 +317,8 @@ if ($action == 'list' || empty($id)) $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; print "\n"; 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 ''; print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status); 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 ''; print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status); 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 ''; print $prospectstatic->LibStatut($prospectstatic->status,3); print ''; - 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"; @@ -183,6 +174,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 '
'; } @@ -229,7 +223,7 @@ if ($resql) print ''; print ''; - print "\n"; + print "\n"; print ''; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 3d7da011d4a..1ccb594e472 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1526,7 +1526,7 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me 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', $langs->trans("ThirdParties"), 'soc', 'socname', 'T', 'searchleftt', img_object('','company')); + $searchform.=printSearchForm(DOL_URL_ROOT.'/societe/list.php', DOL_URL_ROOT.'/societe/list.php', $langs->trans("ThirdParties"), 'soc', 'socname', 'T', 'searchleftt', img_object('','company')); } if (! empty($conf->societe->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_CONTACT) && $user->rights->societe->lire) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 3463f3d0a7a..e79310a5ab6 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -103,7 +103,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('projectlist')); - +$extrafields = new ExtraFields($db); @@ -124,6 +124,12 @@ $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,($mine?$min $sql = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_statut, p.public, p.fk_user_creat"; $sql.= ", p.datec as date_create, p.dateo as date_start, p.datee as date_end"; $sql.= ", s.nom as name, s.rowid as socid"; +// 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."projet as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; @@ -140,18 +146,9 @@ if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$pro // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; -if ($search_ref) -{ - $sql .= natural_search('p.ref', $search_ref); -} -if ($search_label) -{ - $sql .= natural_search('p.title', $search_label); -} -if ($search_societe) -{ - $sql .= natural_search('s.nom', $search_societe); -} +if ($search_ref) $sql .= natural_search('p.ref', $search_ref); +if ($search_label) $sql .= natural_search('p.title', $search_label); +if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($smonth > 0) { if ($syear > 0 && empty($sday)) @@ -178,17 +175,15 @@ else if ($year > 0) { $sql.= " AND p.datee BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; } -if ($search_all) -{ - $sql .= natural_search(array('p.ref','p.title','s.nom'), $search_all); -} +if ($search_all) $sql .= natural_search(array('p.ref','p.title','s.nom'), $search_all); if ($search_status >= 0) $sql .= " AND p.fk_statut = ".$db->escape($search_status); if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public); if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; -if ($search_user > 0) -{ - $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='project' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$search_user; -} +if ($search_user > 0) $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='project' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$search_user; +// 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.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($conf->liste_limit+1, $offset); @@ -255,8 +250,9 @@ if ($resql) print '
'; print $moreforfilter; $parameters=array(); - $formconfirm=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook - print '
'; + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print ''; } @@ -270,10 +266,13 @@ if ($resql) if (! empty($conf->global->PROJECT_LIST_SHOW_STARTDATE)) print_liste_field_titre($langs->trans("DateStart"),$_SERVER["PHP_SELF"],"p.dateo","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"p.datee","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Visibility"),$_SERVER["PHP_SELF"],"p.public","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],'p.fk_statut',"",$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"],'p.fk_statut',"",$param,'align="right"',$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 ''; @@ -309,15 +308,18 @@ if ($resql) print $form->selectarray('search_public',$array,$search_public); print ''; + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print ''; print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('Draft'),'1'=>$langs->trans('Opened'),'2'=>$langs->trans('Closed')),$search_status); - print ''; + print ''; + print ''; print ''; print ''; print ''; - $parameters=array(); - $formconfirm=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook print ''."\n"; @@ -412,13 +414,14 @@ if ($resql) else print $langs->trans('PrivateProject'); print ''; + $parameters=array('obj' => $objp); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Status $projectstatic->statut = $objp->fk_statut; print ''.$projectstatic->getLibStatut(5).''; - $parameters=array('obj' => $objp); - $formconfirm=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print "\n"; } @@ -429,7 +432,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; print "\n"; 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 '
'; +print ''; print ''; print ''."\n"; print ''; diff --git a/htdocs/societe/societe.php b/htdocs/societe/list.php similarity index 86% rename from htdocs/societe/societe.php rename to htdocs/societe/list.php index 4e539c4236c..6f96729155d 100644 --- a/htdocs/societe/societe.php +++ b/htdocs/societe/list.php @@ -20,7 +20,7 @@ */ /** - * \file htdocs/societe/societe.php + * \file htdocs/societe/list.php * \ingroup societe * \brief Page to show list of third parties */ @@ -66,6 +66,10 @@ $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('thirdpartylist')); +$extrafields = new ExtraFields($db); + /* * Actions @@ -181,7 +185,6 @@ if ($socname) */ /* REM: Regle sur droits "Voir tous les clients" - REM: Exemple, voir la page societe.php dans le mode liste. Utilisateur interne socid=0 + Droits voir tous clients => Voit toute societe Utilisateur interne socid=0 + Pas de droits voir tous clients => Ne voit que les societes liees comme commercial Utilisateur externe socid=x + Droits voir tous clients => Ne voit que lui meme @@ -196,6 +199,12 @@ $sql.= " s.siren as idprof1, s.siret as idprof2, ape as idprof3, idprof4 as idpr if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user"; // We'll need these fields in order to filter by categ if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_soc"; +// 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,"; $sql.= " ".MAIN_DB_PREFIX."c_stcomm as st"; // We'll need this table joined to the select in order to filter by sale @@ -209,40 +218,11 @@ if ($socid) $sql.= " AND s.rowid = ".$socid; if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale if ($search_categ) $sql.= " AND s.rowid = cs.fk_soc"; // Join for the needed table to filter by categ if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible -// Insert sale filter -if ($search_sale) -{ - $sql .= " AND sc.fk_user = ".$db->escape($search_sale); -} -// Insert categ filter -if ($search_categ) -{ - $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ); -} -if ($search_nom_only) -{ - $sql.= " AND s.nom LIKE '%".$db->escape($search_nom_only)."%'"; -} -if ($search_all) -{ - $sql.= " AND ("; - $sql.= "s.nom LIKE '%".$db->escape($search_all)."%'"; - $sql.= " OR s.code_client LIKE '%".$db->escape($search_all)."%'"; - $sql.= " OR s.email LIKE '%".$db->escape($search_all)."%'"; - $sql.= " OR s.url LIKE '%".$db->escape($search_all)."%'"; - $sql.= " OR s.siren LIKE '%".$db->escape($search_all)."%'"; - $sql.= ")"; -} -if ($search_nom) -{ - $sql.= " AND ("; - $sql.= "s.nom LIKE '%".$db->escape($search_nom)."%'"; - $sql.= " OR s.code_client LIKE '%".$db->escape($search_nom)."%'"; - $sql.= " OR s.email LIKE '%".$db->escape($search_nom)."%'"; - $sql.= " OR s.url LIKE '%".$db->escape($search_nom)."%'"; - $sql.= " OR s.siren LIKE '%".$db->escape($search_nom)."%'"; - $sql.= ")"; -} +if ($search_sale) $sql .= " AND sc.fk_user = ".$db->escape($search_sale); +if ($search_categ) $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ); +if ($search_nom_only) $sql.= natural_search("s.nom",$search_nom_only); +if ($search_all) $sql.= natural_search(array("s.nom", "s.name_alias", "s.code_client", "s.code_fournisseur", "s.email", "s.url","s.siren","s.siret","s.ape","s.idprof4","s.idprof5","s.idprof6"), $search_all); +if ($search_nom) $sql.= natural_search(array("s.nom", "s.name_alias", "s.code_client", "s.code_fournisseur", "s.email", "s.url","s.siren","s.siret","s.ape","s.idprof4","s.idprof5","s.idprof6"), $search_nom); if ($search_town) $sql .= " AND s.town LIKE '%".$db->escape($search_town)."%'"; if ($search_idprof1) $sql .= " AND s.siren LIKE '%".$db->escape($search_idprof1)."%'"; if ($search_idprof2) $sql .= " AND s.siret LIKE '%".$db->escape($search_idprof2)."%'"; @@ -255,7 +235,10 @@ 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)."%'"; -//print $sql; +// 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; @@ -281,7 +264,7 @@ if ($resql) $params.= '&search_idprof3='.htmlspecialchars($search_idprof3); $params.= '&search_idprof4='.htmlspecialchars($search_idprof4); - print_barre_liste($title, $page, $_SERVER["PHP_SELF"],$params,$sortfield,$sortorder,'',$num,$nbtotalofrecords); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"],$params,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_companies'); // Show delete result message if (GETPOST('delsoc')) @@ -305,8 +288,6 @@ if ($resql) print ''; print ''; - print '
'; - // Filter on categories /* Not possible in this page because list is for ALL third parties type $moreforfilter=''; @@ -330,6 +311,17 @@ if ($resql) print ''; } */ + if (! empty($moreforfilter)) + { + 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 '
'; + } + + print '
'; // Lines of titles print ''; @@ -341,10 +333,13 @@ if ($resql) 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(''); + $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 "\n"; - // Lignes des champs de filtre + // Fields title search print ''; print ''; - // Status + + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Status print ''; + + $parameters=array('obj' => $obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Status print ''; print ''."\n"; @@ -454,6 +460,10 @@ if ($resql) $db->free($resql); + $parameters=array('sql' => $sql); + $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print "
'; print ''; @@ -389,7 +384,12 @@ if ($resql) print ''; print ''; print ''; print ''; print '  '; @@ -446,6 +446,12 @@ if ($resql) } print $s; print ''.$companystatic->getLibStatut(3).'
"; print '
'; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b46bec9201c..ae58f2d85c0 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -643,7 +643,7 @@ if (empty($reshook)) if ($result > 0) { - header("Location: ".DOL_URL_ROOT."/societe/societe.php?delsoc=".urlencode($object->name)); + header("Location: ".DOL_URL_ROOT."/societe/list.php?delsoc=".urlencode($object->name)); exit; } else