dolibarr 21.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 */
5// Protection to avoid direct call of template
6if (empty($conf) || !is_object($conf)) {
7 print "Error, template page can't be called as URL";
8 exit(1);
9}
10
11'
12@phan-var-force string $element
13@phan-var-force int $element_id
14@phan-var-force string $resource_type
15@phan-var-force array<array{rowid:int,resource_id:int,resource_type:string,busy:int<0,1>,mandatory:int<0,1>}> $linked_resources
16';
17
18
19$form = new Form($db);
20
21
22print '<div class="tagtable centpercent noborder allwidth">';
23
24print '<form method="POST" class="tagtable centpercent noborder borderbottom allwidth">';
25
26print '<div class="tagtr liste_titre">';
27print '<div class="tagtd liste_titre">'.$langs->trans('Resource').'</div>';
28print '<div class="tagtd liste_titre">'.$langs->trans('Type').'</div>';
29print '<div class="tagtd liste_titre center">'.$langs->trans('Busy').'</div>';
30print '<div class="tagtd liste_titre center">'.$langs->trans('Mandatory').'</div>';
31print '<div class="tagtd liste_titre"></div>';
32print '</div>';
33
34print '<input type="hidden" name="token" value="'.newToken().'" />';
35print '<input type="hidden" name="id" value="'.$element_id.'" />';
36print '<input type="hidden" name="action" value="update_linked_resource" />';
37print '<input type="hidden" name="resource_type" value="'.$resource_type.'" />';
38
39if ((array) $linked_resources && count($linked_resources) > 0) {
40 foreach ($linked_resources as $linked_resource) {
41 $object_resource = fetchObjectByElement($linked_resource['resource_id'], $linked_resource['resource_type']);
42
43 //$element_id = $linked_resource['rowid'];
44
45 if ($mode == 'edit' && $linked_resource['rowid'] == GETPOSTINT('lineid')) {
46 print '<div class="tagtr oddeven">';
47 print '<input type="hidden" name="lineid" value="'.$linked_resource['rowid'].'" />';
48 print '<input type="hidden" name="element" value="'.$element.'" />';
49 print '<input type="hidden" name="element_id" value="'.$element_id.'" />';
50
51 print '<div class="tagtd">'.$object_resource->getNomUrl(1).'</div>';
52 print '<div class="tagtd">'.$object_resource->type_label.'</div>';
53 print '<div class="tagtd center">'.$form->selectyesno('busy', $linked_resource['busy'] ? 1 : 0, 1).'</div>';
54 print '<div class="tagtd center">'.$form->selectyesno('mandatory', $linked_resource['mandatory'] ? 1 : 0, 1).'</div>';
55 print '<div class="tagtd right"><input type="submit" class="button" value="'.$langs->trans("Update").'"></div>';
56 print '</div>';
57 } else {
58 $class = '';
59 if ($linked_resource['rowid'] == GETPOSTINT('lineid')) {
60 $class = 'highlight';
61 }
62
63 print '<div class="tagtr oddeven'.($class ? ' '.$class : '').'">';
64
65 print '<div class="tagtd">';
66 print $object_resource->getNomUrl(1);
67 print '</div>';
68
69 print '<div class="tagtd">';
70 print $object_resource->type_label;
71 print '</div>';
72
73 print '<div class="tagtd center">';
74 print yn($linked_resource['busy']);
75 print '</div>';
76
77 print '<div class="tagtd center">';
78 print yn($linked_resource['mandatory']);
79 print '</div>';
80
81 print '<div class="tagtd right">';
82 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'].'">';
83 print img_edit();
84 print '</a>';
85 print '&nbsp;';
86 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'].'">';
87 print img_picto($langs->trans("Unlink"), 'unlink');
88 print '</a>';
89 print '</div>';
90
91 print '</div>';
92 }
93 }
94} else {
95 print '<div class="tagtr oddeven">';
96 print '<div class="tagtd opacitymedium">'.$langs->trans('NoResourceLinked').'</div>';
97 print '<div class="tagtd opacitymedium"></div>';
98 print '<div class="tagtd opacitymedium"></div>';
99 print '<div class="tagtd opacitymedium"></div>';
100 print '<div class="tagtd opacitymedium"></div>';
101 print '</div>';
102}
103
104print '</form>';
105
106print '</div>';
107
108?>
109<!-- 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.