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',
'aZ09comma');
42 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
43 $optioncss =
GETPOST(
'optioncss',
'alpha');
46 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'resourcelist';
53 $extrafields->fetch_name_optionals_label($object->table_element);
54 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
55 if (!is_array($search_array_options)) {
56 $search_array_options = array();
58 $search_ref =
GETPOST(
"search_ref",
'alpha');
59 $search_type =
GETPOST(
"search_type",
'alpha');
62 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
66 $hookmanager->initHooks(array(
'resourcelist'));
68 if (empty($sortorder)) {
71 if (empty($sortfield)) {
78 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
80 if (empty($page) || $page == -1) {
83 $offset = $limit * $page;
84 $pageprev = $page - 1;
85 $pagenext = $page + 1;
89 'label' => $langs->trans(
"Ref"),
93 'label' => $langs->trans(
"ResourceType"),
98 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
104 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
107 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
110 $search_array_options = array();
114 if (empty($user->rights->resource->read)) {
123 if (
GETPOST(
'cancel',
'alpha')) {
127 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
131 $parameters = array();
132 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
146 $title = $langs->trans(
'Resources');
151 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
154 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
155 $param .=
'&contextpage='.urlencode($contextpage);
157 if ($limit > 0 && $limit != $conf->liste_limit) {
158 $param .=
'&limit='.urlencode($limit);
161 if ($search_ref !=
'') {
162 $param .=
'&search_ref='.urlencode($search_ref);
163 $filter[
't.ref'] = $search_ref;
165 if ($search_type !=
'') {
166 $param .=
'&search_type='.urlencode($search_type);
167 $filter[
'ty.label'] = $search_type;
173 $filter[
'ef.resource'] = $sql;
175 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
178 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
182 if ($action ==
'delete_resource') {
183 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
"?element=".$element.
"&element_id=".$element_id.
"&lineid=".$lineid, $langs->trans(
"DeleteResource"), $langs->trans(
"ConfirmDeleteResourceElement"),
"confirm_delete_resource",
'',
'', 1);
186 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
187 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
190 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
191 if ($optioncss !=
'') {
192 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
194 print
'<input type="hidden" name="token" value="'.newToken().
'">';
195 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
196 print
'<input type="hidden" name="action" value="list">';
197 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
198 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
199 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
201 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
202 $ret = $object->fetchAll(
'',
'', 0, 0, $filter);
207 $nbtotalofrecords = $ret;
212 $ret = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter);
218 if ($user->rights->resource->write) {
219 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'MenuResourceAdd'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/resource/card.php?action=create');
222 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $ret + 1, $nbtotalofrecords,
'object_resource', 0, $newcardbutton,
'', $limit, 0, 0, 1);
227 print
'<div class="div-table-responsive">';
228 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
230 print
'<tr class="liste_titre_filter">';
231 if (!empty($arrayfields[
't.ref'][
'checked'])) {
232 print
'<td class="liste_titre">';
233 print
'<input type="text" class="flat" name="search_ref" value="'.$search_ref.
'" size="6">';
236 if (!empty($arrayfields[
'ty.label'][
'checked'])) {
237 print
'<td class="liste_titre">';
238 print
'<input type="text" class="flat" name="search_type" value="'.$search_type.
'" size="6">';
242 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
244 print
'<td class="liste_titre maxwidthsearch">';
245 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
250 print
'<tr class="liste_titre">';
251 if (!empty($arrayfields[
't.ref'][
'checked'])) {
252 print_liste_field_titre($arrayfields[
't.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"t.ref",
"", $param,
"", $sortfield, $sortorder);
254 if (!empty($arrayfields[
'ty.label'][
'checked'])) {
255 print_liste_field_titre($arrayfields[
'ty.label'][
'label'], $_SERVER[
"PHP_SELF"],
"ty.label",
"", $param,
"", $sortfield, $sortorder);
258 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
259 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
264 foreach ($object->lines as $resource) {
265 print
'<tr class="oddeven">';
267 if (!empty($arrayfields[
't.ref'][
'checked'])) {
269 print $resource->getNomUrl(5);
272 $totalarray[
'nbfield']++;
276 if (!empty($arrayfields[
'ty.label'][
'checked'])) {
278 print $resource->type_label;
281 $totalarray[
'nbfield']++;
285 $obj = (Object) $resource->array_options;
286 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
288 print
'<td class="center">';
289 print
'<a class="editfielda" href="./card.php?action=edit&token='.newToken().
'&id='.$resource->id.
'">';
293 print
'<a href="./card.php?action=delete&token='.newToken().
'&id='.$resource->id.
'">';
294 print
img_delete(
'',
'class="marginleftonly"');
298 $totalarray[
'nbfield']++;
305 foreach ($arrayfields as $key => $val) {
306 if (!empty($val[
'checked'])) {
310 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';