27 require
'../main.inc.php';
28 require_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_');
57 if (!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'));
70 if (empty($sortorder)) {
73 if (empty($sortfield)) {
80 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
82 if (empty($page) || $page == -1) {
85 $offset = $limit * $page;
86 $pageprev = $page - 1;
87 $pagenext = $page + 1;
91 'label' => $langs->trans(
"Ref"),
95 'label' => $langs->trans(
"ResourceType"),
100 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
106 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
109 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
112 $search_array_options = array();
116 if (empty($user->rights->resource->read)) {
125 if (
GETPOST(
'cancel',
'alpha')) {
129 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
133 $parameters = array();
134 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
148 $title = $langs->trans(
'Resources');
153 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
156 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
157 $param .=
'&contextpage='.urlencode($contextpage);
159 if ($limit > 0 && $limit != $conf->liste_limit) {
160 $param .=
'&limit='.urlencode($limit);
163 if ($search_ref !=
'') {
164 $param .=
'&search_ref='.urlencode($search_ref);
165 $filter[
't.ref'] = $search_ref;
167 if ($search_type !=
'') {
168 $param .=
'&search_type='.urlencode($search_type);
169 $filter[
'ty.label'] = $search_type;
175 $filter[
'ef.resource'] = $sql;
177 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
180 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
184 if ($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);
192 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
193 if ($optioncss !=
'') {
194 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
196 print
'<input type="hidden" name="token" value="'.newToken().
'">';
197 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
198 print
'<input type="hidden" name="action" value="list">';
199 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
200 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
201 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
203 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
204 $ret = $object->fetchAll(
'',
'', 0, 0, $filter);
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);
229 print
'<div class="div-table-responsive">';
230 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
232 print
'<tr class="liste_titre_filter">';
233 if (!empty($arrayfields[
't.ref'][
'checked'])) {
234 print
'<td class="liste_titre">';
235 print
'<input type="text" class="flat" name="search_ref" value="'.$search_ref.
'" size="6">';
238 if (!empty($arrayfields[
'ty.label'][
'checked'])) {
239 print
'<td class="liste_titre">';
240 print
'<input type="text" class="flat" name="search_type" value="'.$search_type.
'" size="6">';
244 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
246 print
'<td class="liste_titre maxwidthsearch">';
247 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
252 print
'<tr class="liste_titre">';
253 if (!empty($arrayfields[
't.ref'][
'checked'])) {
254 print_liste_field_titre($arrayfields[
't.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"t.ref",
"", $param,
"", $sortfield, $sortorder);
256 if (!empty($arrayfields[
'ty.label'][
'checked'])) {
257 print_liste_field_titre($arrayfields[
'ty.label'][
'label'], $_SERVER[
"PHP_SELF"],
"ty.label",
"", $param,
"", $sortfield, $sortorder);
260 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
261 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
266 foreach ($object->lines as $resource) {
267 print
'<tr class="oddeven">';
269 if (!empty($arrayfields[
't.ref'][
'checked'])) {
271 print $resource->getNomUrl(5);
274 $totalarray[
'nbfield']++;
278 if (!empty($arrayfields[
'ty.label'][
'checked'])) {
280 print $resource->type_label;
283 $totalarray[
'nbfield']++;
287 $obj = (Object) $resource->array_options;
288 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
290 print
'<td class="center">';
291 print
'<a class="editfielda" href="./card.php?action=edit&token='.newToken().
'&id='.$resource->id.
'">';
295 print
'<a href="./card.php?action=delete&token='.newToken().
'&id='.$resource->id.
'">';
296 print
img_delete(
'',
'class="marginleftonly"');
300 $totalarray[
'nbfield']++;
307 foreach ($arrayfields as $key => $val) {
308 if (!empty($val[
'checked'])) {
312 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
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 from a POST of a form.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
$nbtotalofrecords
Count total nb of records.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.