diff --git a/htdocs/admin/resource.php b/htdocs/admin/resource.php
index 06ae59d64a3..ebd1269f74a 100644
--- a/htdocs/admin/resource.php
+++ b/htdocs/admin/resource.php
@@ -100,7 +100,7 @@ if (empty($conf->use_javascript_ajax)) {
print $form->selectarray("activate_RESOURCE_USE_SEARCH_TO_SELECT", $arrval, $conf->global->RESOURCE_USE_SEARCH_TO_SELECT);
print '';
print '
';
- print '';
+ print '';
print ' | ';
}
print '';
@@ -108,7 +108,7 @@ print '';
print '';
print '| '.$langs->trans('DisabledResourceLinkUser').' | ';
-print '';
+print ' | ';
echo ajax_constantonoff('RESOURCE_HIDE_ADD_CONTACT_USER');
print ' | ';
print ' | ';
@@ -117,7 +117,7 @@ print '
';
print '';
print '| '.$langs->trans('DisabledResourceLinkContact').' | ';
-print '';
+print ' | ';
echo ajax_constantonoff('RESOURCE_HIDE_ADD_CONTACT_THIPARTY');
print ' | ';
print ' | ';
@@ -126,7 +126,7 @@ print '
';
print '';
print '| '.$langs->trans('EnableResourceUsedInEventCheck').' | ';
-print '';
+print ' | ';
echo ajax_constantonoff('RESOURCE_USED_IN_EVENT_CHECK');
print ' | ';
print ' | ';
diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php
index b93a3f40cea..63fec8968ec 100644
--- a/htdocs/core/db/DoliDB.class.php
+++ b/htdocs/core/db/DoliDB.class.php
@@ -319,16 +319,22 @@ abstract class DoliDB implements Database
* Return first result from query as object
* Note : This method executes a given SQL query and retrieves the first row of results as an object. It should only be used with SELECT queries
* Dont add LIMIT to your query, it will be added by this method
- * @param string $sql the sql query string
- * @return bool| object
+ *
+ * @param string $sql The sql query string
+ * @return bool|int|object False on failure, 0 on empty, object on success
*/
public function getRow($sql)
{
- $sql .= ' LIMIT 1;';
+ $sql .= ' LIMIT 1';
$res = $this->query($sql);
if ($res) {
- return $this->fetch_object($res);
+ $obj = $this->fetch_object($res);
+ if ($obj) {
+ return $obj;
+ } else {
+ return 0;
+ }
}
return false;
diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php
index 356df3a746e..5a7cd3856b3 100644
--- a/htdocs/resource/list.php
+++ b/htdocs/resource/list.php
@@ -64,47 +64,6 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$filter = array();
-$param = '';
-if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
- $param .= '&contextpage='.urlencode($contextpage);
-}
-if ($limit > 0 && $limit != $conf->liste_limit) {
- $param .= '&limit='.urlencode($limit);
-}
-
-if ($search_ref != '') {
- $param .= '&search_ref='.urlencode($search_ref);
- $filter['t.ref'] = $search_ref;
-}
-if ($search_type != '') {
- $param .= '&search_type='.urlencode($search_type);
- $filter['ty.label'] = $search_type;
-}
-
-// Add $param from extra fields
-foreach ($search_array_options as $key => $val) {
- $crit = $val;
- $tmpkey = preg_replace('/search_options_/', '', $key);
- $typ = $extrafields->attributes[$object->table_element]['type'][$tmpkey];
- if ($val != '') {
- $param .= '&search_options_'.$tmpkey.'='.urlencode($val);
- }
- $mode_search = 0;
- if (in_array($typ, array('int', 'double', 'real'))) {
- $mode_search = 1; // Search on a numeric
- }
- if (in_array($typ, array('sellist', 'link')) && $crit != '0' && $crit != '-1') {
- $mode_search = 2; // Search on a foreign key int
- }
- if ($crit != '' && (!in_array($typ, array('select', 'sellist')) || $crit != '0') && (!in_array($typ, array('link')) || $crit != '-1')) {
- $filter['ef.'.$tmpkey] = natural_search('ef.'.$tmpkey, $crit, $mode_search);
- }
-}
-if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
- $param .= '&contextpage='.urlencode($contextpage);
-}
-
-
$hookmanager->initHooks(array('resourcelist'));
if (empty($sortorder)) {
@@ -158,9 +117,17 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
/*
- * Action
+ * Actions
*/
+if (GETPOST('cancel', 'alpha')) {
+ $action = 'list';
+ $massaction = '';
+}
+if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
+ $massaction = '';
+}
+
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
@@ -174,8 +141,42 @@ if ($reshook < 0) {
$form = new Form($db);
+//$help_url="EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject";
+$help_url = '';
$pagetitle = $langs->trans('ResourcePageIndex');
-llxHeader('', $pagetitle, '');
+llxHeader('', $pagetitle, $help_url);
+
+
+$sql = '';
+include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
+
+$param = '';
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
+ $param .= '&contextpage='.urlencode($contextpage);
+}
+if ($limit > 0 && $limit != $conf->liste_limit) {
+ $param .= '&limit='.urlencode($limit);
+}
+
+if ($search_ref != '') {
+ $param .= '&search_ref='.urlencode($search_ref);
+ $filter['t.ref'] = $search_ref;
+}
+if ($search_type != '') {
+ $param .= '&search_type='.urlencode($search_type);
+ $filter['ty.label'] = $search_type;
+}
+
+// Including the previous script generate the correct SQL filter for all the extrafields
+// we are playing with the behaviour of the Dolresource::fetch_all() by generating a fake
+// extrafields filter key to make it works
+$filter['ef.resource'] = $sql;
+
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
+
+// Add $param from extra fields
+include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
+
// Confirmation suppression resource line
if ($action == 'delete_resource') {
@@ -185,6 +186,7 @@ if ($action == 'delete_resource') {
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);
+
print '