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 (empty($user->rights->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"]) $param .=
'&contextpage='.urlencode($contextpage);
180include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
184if ($action ==
'delete_resource') {
185 print $form->formconfirm($_SERVER[
'PHP_SELF'].
"?element=".$element.
"&element_id=".$element_id.
"&lineid=".$lineid, $langs->trans(
"DeleteResource"), $langs->trans(
"ConfirmDeleteResourceElement"),
"confirm_delete_resource",
'',
'', 1);
188$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
189$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
192print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
193if ($optioncss !=
'') {
194 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
196print
'<input type="hidden" name="token" value="'.newToken().
'">';
197print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
198print
'<input type="hidden" name="action" value="list">';
199print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
200print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
201print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
204 $ret = $object->fetchAll(
'',
'', 0, 0, $filter);
209 $nbtotalofrecords = $ret;
214$ret = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter);
220 if ($user->rights->resource->write) {
221 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'MenuResourceAdd'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/resource/card.php?action=create');
224 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $ret + 1, $nbtotalofrecords,
'object_resource', 0, $newcardbutton,
'', $limit, 0, 0, 1);
229print
'<div class="div-table-responsive">';
230print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
232print
'<tr class="liste_titre_filter">';
235 print
'<td class="liste_titre maxwidthsearch">';
236 $searchpicto = $form->showFilterAndCheckAddButtons(0);
240if (!empty($arrayfields[
't.ref'][
'checked'])) {
241 print
'<td class="liste_titre">';
242 print
'<input type="text" class="flat" name="search_ref" value="'.$search_ref.
'" size="6">';
245if (!empty($arrayfields[
'ty.label'][
'checked'])) {
246 print
'<td class="liste_titre">';
247 print
'<input type="text" class="flat" name="search_type" value="'.$search_type.
'" size="6">';
251include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
254 print
'<td class="liste_titre maxwidthsearch">';
255 $searchpicto = $form->showFilterAndCheckAddButtons(0);
261print
'<tr class="liste_titre">';
264 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
266if (!empty($arrayfields[
't.ref'][
'checked'])) {
267 print_liste_field_titre($arrayfields[
't.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"t.ref",
"", $param,
"", $sortfield, $sortorder);
269if (!empty($arrayfields[
'ty.label'][
'checked'])) {
270 print_liste_field_titre($arrayfields[
'ty.label'][
'label'], $_SERVER[
"PHP_SELF"],
"ty.label",
"", $param,
"", $sortfield, $sortorder);
273include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
276 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
282 foreach ($object->lines as $resource) {
283 print
'<tr class="oddeven">';
287 print
'<td class="center">';
288 print
'<a class="editfielda" href="./card.php?action=edit&token='.newToken().
'&id='.$resource->id.
'">';
292 print
'<a href="./card.php?action=delete&token='.newToken().
'&id='.$resource->id.
'">';
293 print
img_delete(
'',
'class="marginleftonly"');
298 if (!empty($arrayfields[
't.ref'][
'checked'])) {
300 print $resource->getNomUrl(5);
303 $totalarray[
'nbfield']++;
307 if (!empty($arrayfields[
'ty.label'][
'checked'])) {
309 print $resource->type_label;
312 $totalarray[
'nbfield']++;
316 $obj = (Object) $resource->array_options;
317 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
321 print
'<td class="center">';
322 print
'<a class="editfielda" href="./card.php?action=edit&token='.newToken().
'&id='.$resource->id.
'">';
326 print
'<a href="./card.php?action=delete&token='.newToken().
'&id='.$resource->id.
'">';
327 print
img_delete(
'',
'class="marginleftonly"');
332 $totalarray[
'nbfield']++;
339 foreach ($arrayfields as $key => $val) {
340 if (!empty($val[
'checked'])) {
344 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 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.