dolibarr 25.0.0-alpha
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-2026 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21/* To call this template, you must define
22 * $textobject
23 * $langs
24 * $extrafield
25 * $elementtype
26 */
27
41'
42@phan-var-force string $action
43@phan-var-force string $elementtype
44@phan-var-force ?string $pagekey
45@phan-var-force string $textobject
46@phan-var-force string[] $type2label
47';
48// Protection to avoid direct call of template
49if (empty($langs) || !is_object($langs)) {
50 print "Error, template page can't be called as URL";
51 exit(1);
52}
53global $action, $form, $langs;
54
55// Prefer $pagekey (the whitelisted request key) for self-referencing links; fall back to
56// $elementtype for older-style callers of this shared template that don't define $pagekey.
57$pagekeyforurl = isset($pagekey) ? $pagekey : $elementtype;
58
59$langs->load("modulebuilder");
60
61if ($action == 'delete') {
62 $attributekey = GETPOST('attrname', 'aZ09');
63 print $form->formconfirm($_SERVER['PHP_SELF']."?attrname=$attributekey&elementtype=".urlencode($pagekeyforurl), $langs->trans("DeleteExtrafield"), $langs->trans("ConfirmDeleteExtrafield", $attributekey), "confirm_delete", '', 0, 1);
64}
65
66?>
67
68<!-- BEGIN PHP TEMPLATE admin_extrafields_view.tpl.php -->
69<?php
70
71$title = '<span class="opacitymedium">'.$langs->trans("DefineHereComplementaryAttributes", empty($textobject) ? '' : $textobject).'</span><br>'."\n";
72//if ($action != 'create' && $action != 'edit') {
73$newcardbutton = '';
74$newcardbutton .= dolGetButtonTitle($langs->trans('NewAttribute'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?action=create&elementtype='.urlencode($pagekeyforurl), '', 1);
75/*} else {
76 $newcardbutton = '';
77}*/
78
79print '<div class="centpercent tagtable marginbottomonly">';
80print '<div class="tagtr">';
81print '<div class="tagtd inline-block valignmiddle hideonsmartphoneimp">'.$title.'</div>';
82print '<div class="tagtd right inline-block valignmiddle"">'.$newcardbutton.'</div>';
83print '</div>';
84print '</div>';
85
86// Load $extrafields->attributes
87$extrafields->fetch_name_optionals_label($elementtype);
88
89print '<div class="div-table-responsive">';
90print '<table summary="listofattributes" class="noborder centpercent small">';
91
92print '<tr class="liste_titre">';
93if ($conf->main_checkbox_left_column) {
94 print '<td width="80">&nbsp;</td>';
95}
96print '<td class="left">'.$langs->trans("Position");
97print '<span class="nowrap">';
98print img_picto('A-Z', '1downarrow.png');
99print '</span>';
100print '</td>';
101print '<td>'.$langs->trans("LabelOrTranslationKey").'</td>';
102//print '<td>'.$langs->trans("TranslationString").'</td>';
103print '<td>'.$langs->trans("AttributeCode").'</td>';
104print '<td>'.$langs->trans("Type").'</td>';
105print '<td class="right">'.$langs->trans("Size").'</td>';
106print '<td>'.$langs->trans("ComputedFormula").'</td>';
107print '<td class="center">'.$langs->trans("Unique").'</td>';
108print '<td class="center">'.$langs->trans("Mandatory").'</td>';
109print '<td class="center">'.$form->textwithpicto($langs->trans("AlwaysEditable"), $langs->trans("EditableWhenDraftOnly")).'</td>';
110print '<td class="center">'.$form->textwithpicto($langs->trans("IsPersonalData"), $langs->trans("IsPersonalDataDesc")).'</td>';
111print '<td class="center">'.$form->textwithpicto($langs->trans("EmptyOnClone"), $langs->trans("EmptyOnCloneDesc")).'</td>';
112print '<td class="center">'.$form->textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc").'<br><br>'.$langs->trans("ItCanBeAnExpression")).'</td>';
113print '<td class="center">'.$form->textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")).'</td>';
114print '<td class="center">'.$form->textwithpicto($langs->trans("Totalizable"), $langs->trans("TotalizableDesc")).'</td>';
115print '<td class="center">'.$form->textwithpicto($langs->trans("CssOnEdit"), $langs->trans("HelpCssOnEditDesc")).'</td>';
116print '<td class="center">'.$form->textwithpicto($langs->trans("CssOnView"), $langs->trans("HelpCssOnViewDesc")).'</td>';
117print '<td class="center">'.$form->textwithpicto($langs->trans("CssOnList"), $langs->trans("HelpCssOnListDesc")).'</td>';
118if (isModEnabled('multicompany')) {
119 print '<td class="center">'.$langs->trans("Entity").'</td>';
120}
121// Action column
122if (!$conf->main_checkbox_left_column) {
123 print '<td width="80">&nbsp;</td>';
124}
125print "</tr>\n";
126
127if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafields->attributes[$elementtype]['type']) && count($extrafields->attributes[$elementtype]['type'])) {
128 foreach ($extrafields->attributes[$elementtype]['type'] as $key => $value) {
129 /*if (! (int) dol_eval((string) $extrafields->attributes[$elementtype]['enabled'][$key], 1, 1, '1')) {
130 // TODO Uncomment this to exclude extrafields of modules not enabled. Add a link to "Show extrafields disabled"
131 // continue;
132 }*/
133
134 // Load language if required
135 if (!empty($extrafields->attributes[$elementtype]['langfile'][$key])) {
136 $langs->load($extrafields->attributes[$elementtype]['langfile'][$key]);
137 }
138
139 print '<tr class="oddeven">';
140 // Actions
141 if ($conf->main_checkbox_left_column) {
142 print '<td class="center nowraponall">';
143 print '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&attrname='.urlencode($key).'&elementtype='.urlencode($pagekeyforurl).'#formeditextrafield">'.img_edit().'</a>';
144 print '&nbsp; <a class="paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&attrname='.urlencode($key).'&elementtype='.urlencode($pagekeyforurl).'">'.img_delete().'</a>';
145 if ($extrafields->attributes[$elementtype]['type'][$key] == 'password' && !empty($extrafields->attributes[$elementtype]['param'][$key]['options']) && array_key_exists('dolcrypt', $extrafields->attributes[$elementtype]['param'][$key]['options'])) {
146 print '&nbsp; <a class="aaa" href="'.$_SERVER["PHP_SELF"].'?action=encrypt&token='.newToken().'&attrname='.urlencode($key).'&elementtype='.urlencode($pagekeyforurl).'" title="'.dol_escape_htmltag($langs->trans("ReEncryptDesc")).'">'.img_picto('', 'refresh').'</a>';
147 }
148 print '</td>'."\n";
149 }
150 // Position
151 print "<td>".dol_escape_htmltag((string) $extrafields->attributes[$elementtype]['pos'][$key])."</td>\n";
152 // Label and label translated
153 print '<td title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['label'][$key]).'" class="tdoverflowmax150 subtitle">';
154 print dol_escape_htmltag($extrafields->attributes[$elementtype]['label'][$key]);
155 if ($langs->transnoentitiesnoconv($extrafields->attributes[$elementtype]['label'][$key]) != $extrafields->attributes[$elementtype]['label'][$key]) {
156 print '<br><span class="subtitle small opacitymedium inline-block" title="'.dolPrintHTMLForAttribute($langs->trans("LabelTranslatedInCurrentLanguage")).'">';
157 print $langs->transnoentitiesnoconv($extrafields->attributes[$elementtype]['label'][$key]);
158 }
159 print '</span>';
160 print "</td>\n"; // We don't translate here, we want admin to know what is the key not translated value
161 // Label translated
162 //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";
163 // Key
164 print '<td title="'.dol_escape_htmltag($key).'" class="tdoverflowmax100">'.dol_escape_htmltag($key)."</td>\n";
165 // Type
166 $fieldtype = $extrafields->attributes[$elementtype]['type'][$key];
167 // $type2label may not contain the type of an already existing field when that type has been
168 // disabled by config (icon => MAIN_USE_EXTRAFIELDS_ICON, point/polygon/... => MAIN_USE_GEOPHP)
169 $typetoshow = $type2label[$fieldtype] ?? $fieldtype;
170 print '<td title="'.dol_escape_htmltag($typetoshow).'" class="tdoverflowmax100">';
171 print getPictoForType($fieldtype);
172 print dol_escape_htmltag($typetoshow);
173 print "</td>\n";
174 // Size
175 print '<td class="right">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['size'][$key])."</td>\n";
176 // Computed field
177 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['computed'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['computed'][$key])."</td>\n";
178 // Is unique ?
179 print '<td class="center">'.yn($extrafields->attributes[$elementtype]['unique'][$key])."</td>\n";
180 // Is mandatory ?
181 print '<td class="center">'.yn($extrafields->attributes[$elementtype]['required'][$key])."</td>\n";
182 // Can always be editable ?
183 print '<td class="center">'.yn($extrafields->attributes[$elementtype]['alwayseditable'][$key])."</td>\n";
184 // Personal data ?
185 print '<td class="center">'.yn($extrafields->attributes[$elementtype]['personal_data'][$key])."</td>\n";
186 // Will be emptied on clone ?
187 print '<td class="center">'.yn($extrafields->attributes[$elementtype]['emptyonclone'][$key])."</td>\n";
188 // Visible
189 print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['list'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['list'][$key])."</td>\n";
190 // Print on PDF
191 print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag((string) $extrafields->attributes[$elementtype]['printable'][$key]).'">'.dol_escape_htmltag((string) $extrafields->attributes[$elementtype]['printable'][$key])."</td>\n";
192 // Summable
193 print '<td class="center">'.yn($extrafields->attributes[$elementtype]['totalizable'][$key])."</td>\n";
194 // CSS
195 print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['css'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['css'][$key])."</td>\n";
196 // CSS view
197 print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['cssview'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['cssview'][$key])."</td>\n";
198 // CSS list
199 print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['csslist'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['csslist'][$key])."</td>\n";
200 // Multicompany
201 if (isModEnabled('multicompany')) {
202 print '<td class="center tdoverflowmax100">';
203 if (empty($extrafields->attributes[$elementtype]['entityid'][$key])) {
204 print $langs->trans("All");
205 } else {
206 global $multicompanylabel_cache;
207 if (!is_array($multicompanylabel_cache)) {
208 $multicompanylabel_cache = array();
209 }
210 if (empty($multicompanylabel_cache[$extrafields->attributes[$elementtype]['entityid'][$key]])) {
211 global $mc;
212 if (is_object($mc) && method_exists($mc, 'getInfo')) {
213 $mc->getInfo($extrafields->attributes[$elementtype]['entityid'][$key]);
214 $multicompanylabel_cache[$extrafields->attributes[$elementtype]['entityid'][$key]] = $mc->label ? $mc->label : $extrafields->attributes[$elementtype]['entityid'][$key];
215 }
216 }
217 print $multicompanylabel_cache[$extrafields->attributes[$elementtype]['entityid'][$key]];
218 }
219 print '</td>';
220 }
221 // Actions
222 if (!$conf->main_checkbox_left_column) {
223 print '<td class="right nowraponall">';
224 print '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&attrname='.urlencode($key).'&elementtype='.urlencode($pagekeyforurl).'#formeditextrafield">'.img_edit().'</a>';
225 print '&nbsp; <a class="paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&attrname='.urlencode($key).'&elementtype='.urlencode($pagekeyforurl).'">'.img_delete().'</a>';
226 if ($extrafields->attributes[$elementtype]['type'][$key] == 'password' && !empty($extrafields->attributes[$elementtype]['param'][$key]['options']) && array_key_exists('dolcrypt', $extrafields->attributes[$elementtype]['param'][$key]['options'])) {
227 print '&nbsp; <a class="aaa" href="'.$_SERVER["PHP_SELF"].'?action=encrypt&token='.newToken().'&attrname='.urlencode($key).'&elementtype='.urlencode($pagekeyforurl).'" title="'.dol_escape_htmltag($langs->trans("ReEncryptDesc")).'">'.img_picto('', 'refresh').'</a>';
228 }
229 print '</td>'."\n";
230 }
231 print "</tr>";
232 }
233} else {
234 $colspan = 18;
235 if (isModEnabled('multicompany')) {
236 $colspan++;
237 }
238
239 print '<tr class="">';
240 print '<td colspan="'.$colspan.'"><span class="opacitymedium">';
241 print $langs->trans("None");
242 print '</span></td>';
243 print '</tr>';
244}
245
246print "</table>";
247print '</div>';
248?>
249<!-- END PHP TEMPLATE admin_extrafields_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:
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
isModEnabled($module)
Is Dolibarr module enabled.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
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.
getPictoForType($key, $morecss='')
Return the picto for a data type.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify 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...
Definition html.lib.php:172