26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/resource/class/dolresource.class.php';
30 $langs->loadLangs(array(
"resource",
"companies",
"other"));
34 $action =
GETPOST(
'action',
'alpha');
36 $lineid =
GETPOST(
'lineid',
'int');
37 $element =
GETPOST(
'element',
'alpha');
38 $element_id =
GETPOST(
'element_id',
'int');
39 $resource_id =
GETPOST(
'resource_id',
'int');
41 $sortorder =
GETPOST(
'sortorder',
'alpha');
42 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
45 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'resourcelist';
52 $extrafields->fetch_name_optionals_label($object->table_element);
53 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
54 if (!is_array($search_array_options)) $search_array_options = array();
55 $search_ref =
GETPOST(
"search_ref",
'alpha');
56 $search_type =
GETPOST(
"search_type",
'alpha');
59 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
65 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
66 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
68 if ($search_ref !=
'') {
69 $param .=
'&search_ref='.urlencode($search_ref);
70 $filter[
't.ref'] = $search_ref;
72 if ($search_type !=
'') {
73 $param .=
'&search_type='.urlencode($search_type);
74 $filter[
'ty.label'] = $search_type;
78 foreach ($search_array_options as $key => $val)
81 $tmpkey = preg_replace(
'/search_options_/',
'', $key);
82 $typ = $extrafields->attributes[$object->table_element][
'type'][$tmpkey];
84 $param .=
'&search_options_'.$tmpkey.
'='.urlencode($val);
87 if (in_array($typ, array(
'int',
'double',
'real'))) $mode_search = 1;
88 if (in_array($typ, array(
'sellist',
'link')) && $crit !=
'0' && $crit !=
'-1') $mode_search = 2;
89 if ($crit !=
'' && (!in_array($typ, array(
'select',
'sellist')) || $crit !=
'0') && (!in_array($typ, array(
'link')) || $crit !=
'-1'))
91 $filter[
'ef.'.$tmpkey] =
natural_search(
'ef.'.$tmpkey, $crit, $mode_search);
94 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
97 $hookmanager->initHooks(array(
'resourcelist'));
99 if (empty($sortorder)) $sortorder =
"ASC";
100 if (empty($sortfield)) $sortfield =
"t.ref";
101 if (empty($arch)) $arch = 0;
103 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
105 if (empty($page) || $page == -1) { $page = 0; }
106 $offset = $limit * $page;
107 $pageprev = $page - 1;
108 $pagenext = $page + 1;
110 if (!$user->rights->resource->read) {
113 $arrayfields = array(
115 'label' => $langs->trans(
"Ref"),
119 'label' => $langs->trans(
"ResourceType"),
124 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
130 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
133 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
137 $search_array_options = array();
146 $parameters = array();
147 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
148 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
155 $form =
new Form($db);
157 $pagetitle = $langs->trans(
'ResourcePageIndex');
161 if ($action ==
'delete_resource')
163 print $form->formconfirm(
$_SERVER[
'PHP_SELF'].
"?element=".$element.
"&element_id=".$element_id.
"&lineid=".$lineid, $langs->trans(
"DeleteResource"), $langs->trans(
"ConfirmDeleteResourceElement"),
"confirm_delete_resource",
'',
'', 1);
166 $varpage = empty($contextpage) ?
$_SERVER[
"PHP_SELF"] : $contextpage;
167 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
169 print '<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
170 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
171 print '<input type="hidden" name="token" value="'.newToken().
'">';
172 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
173 print '<input type="hidden" name="action" value="list">';
174 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
175 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
176 print '<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
178 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
180 $ret = $object->fetch_all(
'',
'', 0, 0, $filter);
185 $nbtotalofrecords = $ret;
190 $ret = $object->fetch_all($sortorder, $sortfield, $limit, $offset, $filter);
196 if ($user->rights->resource->write)
198 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'MenuResourceAdd'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/resource/card.php?action=create');
201 print_barre_liste($pagetitle, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $ret + 1, $nbtotalofrecords,
'object_resource', 0, $newcardbutton,
'', $limit, 0, 0, 1);
206 print '<div class="div-table-responsive">';
207 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
209 print '<tr class="liste_titre_filter">';
210 if (!empty($arrayfields[
't.ref'][
'checked']))
212 print
'<td class="liste_titre">';
213 print
'<input type="text" class="flat" name="search_ref" value="'.$search_ref.
'" size="6">';
216 if (!empty($arrayfields[
'ty.label'][
'checked']))
218 print
'<td class="liste_titre">';
219 print
'<input type="text" class="flat" name="search_type" value="'.$search_type.
'" size="6">';
223 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
225 print
'<td class="liste_titre maxwidthsearch">';
226 $searchpicto = $form->showFilterAndCheckAddButtons(0);
231 print
'<tr class="liste_titre">';
232 if (!empty($arrayfields[
't.ref'][
'checked']))
print_liste_field_titre($arrayfields[
't.ref'][
'label'],
$_SERVER[
"PHP_SELF"],
"t.ref",
"", $param,
"", $sortfield, $sortorder);
233 if (!empty($arrayfields[
'ty.label'][
'checked']))
print_liste_field_titre($arrayfields[
'ty.label'][
'label'],
$_SERVER[
"PHP_SELF"],
"ty.label",
"", $param,
"", $sortfield, $sortorder);
235 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
242 foreach ($object->lines as $resource)
244 print
'<tr class="oddeven">';
246 if (!empty($arrayfields[
't.ref'][
'checked']))
249 print $resource->getNomUrl(5);
251 if (!$i) $totalarray[
'nbfield']++;
254 if (!empty($arrayfields[
'ty.label'][
'checked']))
257 print $resource->type_label;
259 if (!$i) $totalarray[
'nbfield']++;
262 $obj = (Object) $resource->array_options;
263 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
265 print
'<td class="center">';
266 print
'<a class="editfielda" href="./card.php?action=edit&token='.newToken().
'&id='.$resource->id.
'">';
270 print
'<a href="./card.php?action=delete&token='.newToken().
'&id='.$resource->id.
'">';
271 print
img_delete(
'',
'class="marginleftonly"');
274 if (!$i) $totalarray[
'nbfield']++;
280 foreach ($arrayfields as $key => $val) {
if (!empty($val[
'checked'])) $colspan++; }
281 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
dolGetButtonTitle($label, $helpText= '', $iconClass= 'fa fa-file', $url= '', $id= '', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print
Draft customers invoices.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.