27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/resource/class/dolresource.class.php';
31$langs->loadLangs(array(
"resource",
"companies",
"other"));
35$action =
GETPOST(
'action',
'alpha');
36$massaction =
GETPOST(
'massaction',
'alpha');
38$lineid =
GETPOST(
'lineid',
'int');
39$element =
GETPOST(
'element',
'alpha');
40$element_id =
GETPOST(
'element_id',
'int');
41$resource_id =
GETPOST(
'resource_id',
'int');
43$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
44$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
45$optioncss =
GETPOST(
'optioncss',
'alpha');
48$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'resourcelist';
55$extrafields->fetch_name_optionals_label($object->table_element);
56$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
57if (!is_array($search_array_options)) {
58 $search_array_options = array();
60$search_ref =
GETPOST(
"search_ref",
'alpha');
61$search_type =
GETPOST(
"search_type",
'alpha');
64$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
68$hookmanager->initHooks(array(
'resourcelist'));
70if (empty($sortorder)) {
73if (empty($sortfield)) {
80$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
81$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
82if (empty($page) || $page == -1) {
85$offset = $limit * $page;
91 'label' => $langs->trans(
"Ref"),
95 'label' => $langs->trans(
"ResourceType"),
100include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
106include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
109if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
112 $search_array_options = array();
116if (!$user->hasRight(
'resource',
'read')) {
125if (
GETPOST(
'cancel',
'alpha')) {
129if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
133$parameters = array();
134$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
144$form =
new Form($db);
148$title = $langs->trans(
'Resources');
153include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
156if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
157 $param .=
'&contextpage='.urlencode($contextpage);
159if ($limit > 0 && $limit != $conf->liste_limit) {
160 $param .=
'&limit='.((int) $limit);
163if ($search_ref !=
'') {
164 $param .=
'&search_ref='.urlencode($search_ref);
165 $filter[
't.ref'] = $search_ref;
167if ($search_type !=
'') {
168 $param .=
'&search_type='.urlencode($search_type);
169 $filter[
'ty.label'] = $search_type;
175$filter[
'ef.resource'] = $sql;
177if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
178 $param .=
'&contextpage='.urlencode($contextpage);
182include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
186if ($action ==
'delete_resource') {
187 print $form->formconfirm($_SERVER[
'PHP_SELF'].
"?element=".$element.
"&element_id=".$element_id.
"&lineid=".$lineid, $langs->trans(
"DeleteResource"), $langs->trans(
"ConfirmDeleteResourceElement"),
"confirm_delete_resource",
'',
'', 1);
190$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
191$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
194print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
195if ($optioncss !=
'') {
196 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
198print
'<input type="hidden" name="token" value="'.newToken().
'">';
199print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
200print
'<input type="hidden" name="action" value="list">';
201print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
202print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
203print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
206 $ret = $object->fetchAll(
'',
'', 0, 0, $filter);
211 $nbtotalofrecords = $ret;
216$ret = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter);
222 if ($user->hasRight(
'resource',
'write')) {
223 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'MenuResourceAdd'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/resource/card.php?action=create');
226 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $ret + 1, $nbtotalofrecords,
'object_resource', 0, $newcardbutton,
'', $limit, 0, 0, 1);
231print
'<div class="div-table-responsive">';
232print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
234print
'<tr class="liste_titre_filter">';
237 print
'<td class="liste_titre maxwidthsearch">';
238 $searchpicto = $form->showFilterAndCheckAddButtons(0);
242if (!empty($arrayfields[
't.ref'][
'checked'])) {
243 print
'<td class="liste_titre">';
244 print
'<input type="text" class="flat" name="search_ref" value="'.$search_ref.
'" size="6">';
247if (!empty($arrayfields[
'ty.label'][
'checked'])) {
248 print
'<td class="liste_titre">';
249 print
'<input type="text" class="flat" name="search_type" value="'.$search_type.
'" size="6">';
253include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
256 print
'<td class="liste_titre maxwidthsearch">';
257 $searchpicto = $form->showFilterAndCheckAddButtons(0);
263print
'<tr class="liste_titre">';
266 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
268if (!empty($arrayfields[
't.ref'][
'checked'])) {
269 print_liste_field_titre($arrayfields[
't.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"t.ref",
"", $param,
"", $sortfield, $sortorder);
271if (!empty($arrayfields[
'ty.label'][
'checked'])) {
272 print_liste_field_titre($arrayfields[
'ty.label'][
'label'], $_SERVER[
"PHP_SELF"],
"ty.label",
"", $param,
"", $sortfield, $sortorder);
275include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
278 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
284 foreach ($object->lines as $resource) {
285 print
'<tr class="oddeven">';
289 print
'<td class="center">';
290 print
'<a class="editfielda" href="./card.php?action=edit&token='.newToken().
'&id='.$resource->id.
'">';
294 print
'<a href="./card.php?action=delete&token='.newToken().
'&id='.$resource->id.
'">';
295 print
img_delete(
'',
'class="marginleftonly"');
300 if (!empty($arrayfields[
't.ref'][
'checked'])) {
302 print $resource->getNomUrl(5);
305 $totalarray[
'nbfield']++;
309 if (!empty($arrayfields[
'ty.label'][
'checked'])) {
311 print $resource->type_label;
314 $totalarray[
'nbfield']++;
318 $obj = (object) $resource->array_options;
319 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
323 print
'<td class="center">';
324 print
'<a class="editfielda" href="./card.php?action=edit&token='.newToken().
'&id='.$resource->id.
'">';
328 print
'<a href="./card.php?action=delete&token='.newToken().
'&id='.$resource->id.
'">';
329 print
img_delete(
'',
'class="marginleftonly"');
334 $totalarray[
'nbfield']++;
341 foreach ($arrayfields as $key => $val) {
342 if (!empty($val[
'checked'])) {
346 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.