dolibarr 21.0.0-beta
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 array<array{rowid:int,resource_id:int,resource_type:string,busy:int<0,1>,mandatory:int<0,1>}> $linked_resources
42';
43
44
45$form = new Form($db);
46
47
48print '<div class="tagtable centpercent noborder allwidth">';
49
50print '<form method="POST" class="tagtable centpercent noborder borderbottom allwidth">';
51
52print '<div class="tagtr liste_titre">';
53print '<div class="tagtd liste_titre">'.$langs->trans('Resource').'</div>';
54print '<div class="tagtd liste_titre">'.$langs->trans('Type').'</div>';
55print '<div class="tagtd liste_titre center">'.$langs->trans('Busy').'</div>';
56print '<div class="tagtd liste_titre center">'.$langs->trans('Mandatory').'</div>';
57print '<div class="tagtd liste_titre"></div>';
58print '</div>';
59
60print '<input type="hidden" name="token" value="'.newToken().'" />';
61print '<input type="hidden" name="id" value="'.$element_id.'" />';
62print '<input type="hidden" name="action" value="update_linked_resource" />';
63print '<input type="hidden" name="resource_type" value="'.$resource_type.'" />';
64
65if ((array) $linked_resources && count($linked_resources) > 0) {
66 foreach ($linked_resources as $linked_resource) {
67 $object_resource = fetchObjectByElement($linked_resource['resource_id'], $linked_resource['resource_type']);
68
69 //$element_id = $linked_resource['rowid'];
70
71 if ($mode == 'edit' && $linked_resource['rowid'] == GETPOSTINT('lineid')) {
72 print '<div class="tagtr oddeven">';
73 print '<input type="hidden" name="lineid" value="'.$linked_resource['rowid'].'" />';
74 print '<input type="hidden" name="element" value="'.$element.'" />';
75 print '<input type="hidden" name="element_id" value="'.$element_id.'" />';
76
77 print '<div class="tagtd">'.$object_resource->getNomUrl(1).'</div>';
78 print '<div class="tagtd">'.$object_resource->type_label.'</div>';
79 print '<div class="tagtd center">'.$form->selectyesno('busy', $linked_resource['busy'] ? 1 : 0, 1).'</div>';
80 print '<div class="tagtd center">'.$form->selectyesno('mandatory', $linked_resource['mandatory'] ? 1 : 0, 1).'</div>';
81 print '<div class="tagtd right"><input type="submit" class="button" value="'.$langs->trans("Update").'"></div>';
82 print '</div>';
83 } else {
84 $class = '';
85 if ($linked_resource['rowid'] == GETPOSTINT('lineid')) {
86 $class = 'highlight';
87 }
88
89 print '<div class="tagtr oddeven'.($class ? ' '.$class : '').'">';
90
91 print '<div class="tagtd">';
92 print $object_resource->getNomUrl(1);
93 print '</div>';
94
95 print '<div class="tagtd">';
96 print $object_resource->type_label;
97 print '</div>';
98
99 print '<div class="tagtd center">';
100 print yn($linked_resource['busy']);
101 print '</div>';
102
103 print '<div class="tagtd center">';
104 print yn($linked_resource['mandatory']);
105 print '</div>';
106
107 print '<div class="tagtd right">';
108 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'].'">';
109 print img_edit();
110 print '</a>';
111 print '&nbsp;';
112 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'].'">';
113 print img_picto($langs->trans("Unlink"), 'unlink');
114 print '</a>';
115 print '</div>';
116
117 print '</div>';
118 }
119 }
120} else {
121 print '<div class="tagtr oddeven">';
122 print '<div class="tagtd opacitymedium">'.$langs->trans('NoResourceLinked').'</div>';
123 print '<div class="tagtd opacitymedium"></div>';
124 print '<div class="tagtd opacitymedium"></div>';
125 print '<div class="tagtd opacitymedium"></div>';
126 print '<div class="tagtd opacitymedium"></div>';
127 print '</div>';
128}
129
130print '</form>';
131
132print '</div>';
133
134?>
135<!-- END TEMPLATE resource_view.tpl.php -->
Class to manage generation of HTML components Only common components must be here.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
fetchObjectByElement($element_id, $element_type, $element_ref='', $useCache=0, $maxCacheByType=10)
Fetch an object from its id and element_type Inclusion of classes is automatic.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79