Can use substitution variables into filter of fields link

This commit is contained in:
Laurent Destailleur 2019-11-01 18:35:48 +01:00
parent 2af23aa658
commit 012c5ef0c4
4 changed files with 15 additions and 10 deletions

View File

@ -5624,7 +5624,7 @@ abstract class CommonObject
{
$morecss = 'minwidth100imp';
}
elseif ($type == 'datetime')
elseif ($type == 'datetime' || $type == 'link')
{
$morecss = 'minwidth200imp';
}
@ -6093,7 +6093,7 @@ abstract class CommonObject
$param_list_array = explode(':', $param_list[0]);
$showempty=(($required && $default != '')?0:1);
$out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', '', '', 0, empty($val['disabled'])?0:1);
$out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, '', 0, empty($val['disabled'])?0:1);
if (! empty($param_list_array[2])) // If we set to add a create button
{

View File

@ -5865,7 +5865,11 @@ class Form
if ($classname && class_exists($classname))
{
$objecttmp = new $classname($this->db);
$objecttmp->filter = $filter;
// Make some replacement
$objecttmp->filter = str_replace(
array('__ENTITY__', '__USER_ID__'),
array($conf->entity, $user->id),
$filter);
}
}
if (! is_object($objecttmp))

View File

@ -134,4 +134,4 @@ KeyForTooltip=Key for tooltip
CSSClass=CSS Class
NotEditable=Not editable
ForeignKey=Foreign key
TypeOfFieldsHelp=Type of fields:<br>varchar(99), double(24,8), real, text, html, datetime, timestamp, integer, integer:ClassName:relativepath/to/classfile.class.php:1 (1 means we add a + button after the combo to create the record)
TypeOfFieldsHelp=Type of fields:<br>varchar(99), double(24,8), real, text, html, datetime, timestamp, integer, integer:ClassName:relativepath/to/classfile.class.php[:1[:filter]] ('1' means we add a + button after the combo to create the record, 'filter' can be 'status=1;entity=$conf->entity' for example)

View File

@ -153,6 +153,9 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
$permtoread = $user->rights->mymodule->myobject->read;
$permtowrite = $user->rights->mymodule->myobject->write;
$permtodelete = $user->rights->mymodule->myobject->delete;
/*
@ -190,8 +193,6 @@ if (empty($reshook))
// Mass actions
$objectclass='MyObject';
$objectlabel='MyObject';
$permtoread = $user->rights->mymodule->read;
$permtodelete = $user->rights->mymodule->delete;
$uploaddir = $conf->mymodule->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@ -346,7 +347,7 @@ $arrayofmassactions = array(
//'builddoc'=>$langs->trans("PDFMerge"),
//'presend'=>$langs->trans("SendByMail"),
);
if ($user->rights->mymodule->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if ($permtodelete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
@ -360,7 +361,7 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/mymodule/myobject_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->mymodule->write);
$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/mymodule/myobject_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permtowrite);
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit);
@ -593,8 +594,8 @@ if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $n
$urlsource.=str_replace('&amp;', '&', $param);
$filedir=$diroutputmassaction;
$genallowed=$user->rights->mymodule->read;
$delallowed=$user->rights->mymodule->write;
$genallowed=$permtoread;
$delallowed=$permtowrite;
print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
}