dolibarr 19.0.3
admin_extrafields_view.tpl.php
1<?php
2/* Copyright (C) 2010-2018 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2012-2021 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.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
20/* To call this template, you must define
21 * $textobject
22 * $langs
23 * $extrafield
24 * $elementtype
25 */
26
27// Protection to avoid direct call of template
28if (empty($langs) || !is_object($langs)) {
29 print "Error, template page can't be called as URL";
30 exit;
31}
32global $action, $form, $langs;
33
34$langs->load("modulebuilder");
35
36if ($action == 'delete') {
37 $attributekey = GETPOST('attrname', 'aZ09');
38 print $form->formconfirm($_SERVER['PHP_SELF']."?attrname=$attributekey", $langs->trans("DeleteExtrafield"), $langs->trans("ConfirmDeleteExtrafield", $attributekey), "confirm_delete", '', 0, 1);
39}
40
41?>
42
43<!-- BEGIN PHP TEMPLATE admin_extrafields_view.tpl.php -->
44<?php
45
46$title = '<span class="opacitymedium">'.$langs->trans("DefineHereComplementaryAttributes", empty($textobject) ? '' : $textobject).'</span><br>'."\n";
47//if ($action != 'create' && $action != 'edit') {
48$newcardbutton = '';
49$newcardbutton .= dolGetButtonTitle($langs->trans('NewAttribute'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?action=create', '', (($action != 'create' && $action != 'edit') ? 1 : 1));
50/*} else {
51 $newcardbutton = '';
52}*/
53
54print '<div class="centpercent tagtable marginbottomonly">';
55print '<div class="tagtr">';
56print '<div class="tagtd inline-block valignmiddle hideonsmartphoneimp">'.$title.'</div>';
57print '<div class="tagtd right inline-block valignmiddle"">'.$newcardbutton.'</div>';
58print '</div>';
59print '</div>';
60
61// Load $extrafields->attributes
62$extrafields->fetch_name_optionals_label($elementtype);
63
64print '<div class="div-table-responsive">';
65print '<table summary="listofattributes" class="noborder centpercent small">';
66
67print '<tr class="liste_titre">';
68if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
69 print '<td width="80">&nbsp;</td>';
70}
71print '<td class="left">'.$langs->trans("Position");
72print '<span class="nowrap">';
73print img_picto('A-Z', '1downarrow.png');
74print '</span>';
75print '</td>';
76print '<td>'.$langs->trans("LabelOrTranslationKey").'</td>';
77print '<td>'.$langs->trans("TranslationString").'</td>';
78print '<td>'.$langs->trans("AttributeCode").'</td>';
79print '<td>'.$langs->trans("Type").'</td>';
80print '<td class="right">'.$langs->trans("Size").'</td>';
81print '<td>'.$langs->trans("ComputedFormula").'</td>';
82print '<td class="center">'.$langs->trans("Unique").'</td>';
83print '<td class="center">'.$langs->trans("Mandatory").'</td>';
84print '<td class="center">'.$form->textwithpicto($langs->trans("AlwaysEditable"), $langs->trans("EditableWhenDraftOnly")).'</td>';
85print '<td class="center">'.$form->textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc").'<br><br>'.$langs->trans("ItCanBeAnExpression")).'</td>';
86print '<td class="center">'.$form->textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")).'</td>';
87print '<td class="center">'.$form->textwithpicto($langs->trans("Totalizable"), $langs->trans("TotalizableDesc")).'</td>';
88print '<td class="center">'.$form->textwithpicto($langs->trans("CssOnEdit"), $langs->trans("HelpCssOnEditDesc")).'</td>';
89print '<td class="center">'.$form->textwithpicto($langs->trans("CssOnView"), $langs->trans("HelpCssOnViewDesc")).'</td>';
90print '<td class="center">'.$form->textwithpicto($langs->trans("CssOnList"), $langs->trans("HelpCssOnListDesc")).'</td>';
91if (isModEnabled('multicompany')) {
92 print '<td class="center">'.$langs->trans("Entity").'</td>';
93}
94// Action column
95if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
96 print '<td width="80">&nbsp;</td>';
97}
98print "</tr>\n";
99
100if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafields->attributes[$elementtype]['type']) && count($extrafields->attributes[$elementtype]['type'])) {
101 foreach ($extrafields->attributes[$elementtype]['type'] as $key => $value) {
102 /*if (! dol_eval($extrafields->attributes[$elementtype]['enabled'][$key], 1, 1, '1')) {
103 // TODO Uncomment this to exclude extrafields of modules not enabled. Add a link to "Show extrafields disabled"
104 // continue;
105 }*/
106
107 // Load language if required
108 if (!empty($extrafields->attributes[$elementtype]['langfile'][$key])) {
109 $langs->load($extrafields->attributes[$elementtype]['langfile'][$key]);
110 }
111
112 print '<tr class="oddeven">';
113 // Actions
114 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
115 print '<td class="center nowraponall">';
116 print '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&attrname='.urlencode($key).'#formeditextrafield">'.img_edit().'</a>';
117 print '&nbsp; <a class="paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&attrname='.urlencode($key).'">'.img_delete().'</a>';
118 if ($extrafields->attributes[$elementtype]['type'][$key] == 'password' && !empty($extrafields->attributes[$elementtype]['param'][$key]['options']) && array_key_exists('dolcrypt', $extrafields->attributes[$elementtype]['param'][$key]['options'])) {
119 print '&nbsp; <a class="aaa" href="'.$_SERVER["PHP_SELF"].'?action=encrypt&token='.newToken().'&attrname='.urlencode($key).'" title="'.dol_escape_htmltag($langs->trans("ReEncryptDesc")).'">'.img_picto('', 'refresh').'</a>';
120 }
121 print '</td>'."\n";
122 }
123 // Position
124 print "<td>".dol_escape_htmltag($extrafields->attributes[$elementtype]['pos'][$key])."</td>\n";
125 // Label
126 print '<td title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['label'][$key]).'" class="tdoverflowmax150">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['label'][$key])."</td>\n"; // We don't translate here, we want admin to know what is the key not translated value
127 // Label translated
128 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv($extrafields->attributes[$elementtype]['label'][$key])).'">'.dol_escape_htmltag($langs->transnoentitiesnoconv($extrafields->attributes[$elementtype]['label'][$key]))."</td>\n";
129 // Key
130 print '<td title="'.dol_escape_htmltag($key).'" class="tdoverflowmax100">'.dol_escape_htmltag($key)."</td>\n";
131 // Type
132 $typetoshow = $type2label[$extrafields->attributes[$elementtype]['type'][$key]];
133 print '<td title="'.dol_escape_htmltag($typetoshow).'" class="tdoverflowmax100">';
134 print getPictoForType($extrafields->attributes[$elementtype]['type'][$key]);
135 print dol_escape_htmltag($typetoshow);
136 print "</td>\n";
137 // Size
138 print '<td class="right">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['size'][$key])."</td>\n";
139 // Computed field
140 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['computed'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['computed'][$key])."</td>\n";
141 // Is unique ?
142 print '<td class="center">'.yn($extrafields->attributes[$elementtype]['unique'][$key])."</td>\n";
143 // Is mandatory ?
144 print '<td class="center">'.yn($extrafields->attributes[$elementtype]['required'][$key])."</td>\n";
145 // Can always be editable ?
146 print '<td class="center">'.yn($extrafields->attributes[$elementtype]['alwayseditable'][$key])."</td>\n";
147 // Visible
148 print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['list'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['list'][$key])."</td>\n";
149 // Print on PDF
150 print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['printable'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['printable'][$key])."</td>\n";
151 // Summable
152 print '<td class="center">'.yn($extrafields->attributes[$elementtype]['totalizable'][$key])."</td>\n";
153 // CSS
154 print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['css'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['css'][$key])."</td>\n";
155 // CSS view
156 print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['cssview'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['cssview'][$key])."</td>\n";
157 // CSS list
158 print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['csslist'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['csslist'][$key])."</td>\n";
159 // Multicompany
160 if (isModEnabled('multicompany')) {
161 print '<td class="center">';
162 if (empty($extrafields->attributes[$elementtype]['entityid'][$key])) {
163 print $langs->trans("All");
164 } else {
165 global $multicompanylabel_cache;
166 if (!is_array($multicompanylabel_cache)) {
167 $multicompanylabel_cache = array();
168 }
169 if (empty($multicompanylabel_cache[$extrafields->attributes[$elementtype]['entityid'][$key]])) {
170 global $mc;
171 if (is_object($mc) && method_exists($mc, 'getInfo')) {
172 $mc->getInfo($extrafields->attributes[$elementtype]['entityid'][$key]);
173 $multicompanylabel_cache[$extrafields->attributes[$elementtype]['entityid'][$key]] = $mc->label ? $mc->label : $extrafields->attributes[$elementtype]['entityid'][$key];
174 }
175 }
176 print $multicompanylabel_cache[$extrafields->attributes[$elementtype]['entityid'][$key]];
177 }
178 print '</td>';
179 }
180 // Actions
181 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
182 print '<td class="right nowraponall">';
183 print '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&attrname='.urlencode($key).'#formeditextrafield">'.img_edit().'</a>';
184 print '&nbsp; <a class="paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&attrname='.urlencode($key).'">'.img_delete().'</a>';
185 if ($extrafields->attributes[$elementtype]['type'][$key] == 'password' && !empty($extrafields->attributes[$elementtype]['param'][$key]['options']) && array_key_exists('dolcrypt', $extrafields->attributes[$elementtype]['param'][$key]['options'])) {
186 print '&nbsp; <a class="aaa" href="'.$_SERVER["PHP_SELF"].'?action=encrypt&token='.newToken().'&attrname='.urlencode($key).'" title="'.dol_escape_htmltag($langs->trans("ReEncryptDesc")).'">'.img_picto('', 'refresh').'</a>';
187 }
188 print '</td>'."\n";
189 }
190 print "</tr>";
191 }
192} else {
193 $colspan = 17;
194 if (isModEnabled('multicompany')) {
195 $colspan++;
196 }
197
198 print '<tr class="oddeven">';
199 print '<td colspan="'.$colspan.'"><span class="opacitymedium">';
200 print $langs->trans("None");
201 print '</span></td>';
202 print '</tr>';
203}
204
205print "</table>";
206print '</div>';
207?>
208<!-- END PHP TEMPLATE admin_extrafields_view.tpl.php -->
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
getPictoForType($key)
Return the picto for a data type.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...