dolibarr 25.0.0-alpha
resource_view.tpl.php
1<!-- BEGIN TEMPLATE resource_view.tpl.php -->
2<?php
3/* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
31// Protection to avoid direct call of template
32if (empty($conf) || !is_object($conf)) {
33 print "Error, template page can't be called as URL";
34 exit(1);
35}
36
37'
38@phan-var-force string $element
39@phan-var-force int $element_id
40@phan-var-force string $resource_type
41@phan-var-force string $mode
42@phan-var-force array<array{rowid:int,resource_id:int,resource_type:string,busy:int<0,1>,mandatory:int<0,1>}> $linked_resources
43';
44
45
46$form = new Form($db);
47
48
49print '<div class="tagtable centpercent noborder allwidth">';
50
51print '<form method="POST" class="tagtable centpercent noborder borderbottom allwidth">';
52
53print '<div class="tagtr liste_titre">';
54print '<div class="tagtd liste_titre">'.$langs->trans('Resource').'</div>';
55print '<div class="tagtd liste_titre">'.$langs->trans('Type').'</div>';
56print '<div class="tagtd liste_titre center">'.$langs->trans('Busy').'</div>';
57print '<div class="tagtd liste_titre center">'.$langs->trans('Mandatory').'</div>';
58print '<div class="tagtd liste_titre"></div>';
59print '</div>';
60
61print '<input type="hidden" name="token" value="'.newToken().'" />';
62print '<input type="hidden" name="id" value="'.$element_id.'" />';
63print '<input type="hidden" name="action" value="update_linked_resource" />';
64print '<input type="hidden" name="resource_type" value="'.$resource_type.'" />';
65
66if ((array) $linked_resources && count($linked_resources) > 0) {
67 foreach ($linked_resources as $linked_resource) {
68 $object_resource = fetchObjectByElement($linked_resource['resource_id'], $linked_resource['resource_type']);
69 '@phan-var-force Dolresource $object_resource';
70
71 //$element_id = $linked_resource['rowid'];
72
73 if ($mode == 'edit' && $linked_resource['rowid'] == GETPOSTINT('lineid')) {
74 print '<div class="tagtr oddeven">';
75 print '<input type="hidden" name="lineid" value="'.$linked_resource['rowid'].'" />';
76 print '<input type="hidden" name="element" value="'.$element.'" />';
77 print '<input type="hidden" name="element_id" value="'.$element_id.'" />';
78
79 print '<div class="tagtd">'.$object_resource->getNomUrl(1).'</div>';
80 print '<div class="tagtd">'.$object_resource->type_label.'</div>';
81 print '<div class="tagtd center">'.$form->selectyesno('busy', $linked_resource['busy'] ? 1 : 0, 1).'</div>';
82 print '<div class="tagtd center">'.$form->selectyesno('mandatory', $linked_resource['mandatory'] ? 1 : 0, 1).'</div>';
83 print '<div class="tagtd right"><input type="submit" class="button" value="'.$langs->trans("Update").'"></div>';
84 print '</div>';
85 } else {
86 $class = '';
87 if ($linked_resource['rowid'] == GETPOSTINT('lineid')) {
88 $class = 'highlight';
89 }
90
91 print '<div class="tagtr oddeven'.($class ? ' '.$class : '').'">';
92
93 print '<div class="tagtd">';
94 print $object_resource->getNomUrl(1);
95 print '</div>';
96
97 print '<div class="tagtd">';
98 print $object_resource->type_label;
99 print '</div>';
100
101 print '<div class="tagtd center">';
102 print yn($linked_resource['busy']);
103 print '</div>';
104
105 print '<div class="tagtd center">';
106 print yn($linked_resource['mandatory']);
107 print '</div>';
108
109 print '<div class="tagtd right">';
110 print '<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=edit&token='.newToken().'&resource_type='.$linked_resource['resource_type'].'&element='.$element.'&element_id='.$element_id.'&lineid='.$linked_resource['rowid'].'">';
111 print img_edit();
112 print '</a>';
113 print '&nbsp;';
114 print '<a class="marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?action=delete_resource&token='.newToken().'&id='.$linked_resource['resource_id'].'&element='.$element.'&element_id='.$element_id.'&lineid='.$linked_resource['rowid'].'">';
115 print img_picto($langs->trans("Unlink"), 'unlink');
116 print '</a>';
117 print '</div>';
118
119 print '</div>';
120 }
121 }
122} else {
123 print '<div class="tagtr oddeven">';
124 print '<div class="tagtd opacitymedium">'.$langs->trans('NoResourceLinked').'</div>';
125 print '<div class="tagtd opacitymedium"></div>';
126 print '<div class="tagtd opacitymedium"></div>';
127 print '<div class="tagtd opacitymedium"></div>';
128 print '<div class="tagtd opacitymedium"></div>';
129 print '</div>';
130}
131
132print '</form>';
133
134print '</div>';
135
136?>
137<!-- END TEMPLATE resource_view.tpl.php -->
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage generation of HTML components Only common components must be here.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.