dolibarr/htdocs/core/tpl/admin_extrafields_view.tpl.php

239 lines
13 KiB
PHP
Raw Permalink Normal View History

<?php
/* Copyright (C) 2010-2018 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012-2021 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 19:55:30 +00:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* To call this template, you must define
* $textobject
* $langs
* $extrafield
* $elementtype
*/
add baseline exclude for phpstan (#31632) * add baseline exclude for phpstan * update * update * update * update * update * merge * restore one filter * delete old errors * fix * fix * fix * $moreforfilter can t be empty * fix * enable check * refresh baseline * add phpdoc * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-11-04 22:53:20 +00:00
/**
* @var Conf $conf
* @var DoliDB $db
* @var ExtraFields $extrafields
* @var Form $form
* @var Translate $langs
*
* @var string $action
* @var string $elementtype
* @var string $textobject
* @var string[] $type2label
add baseline exclude for phpstan (#31632) * add baseline exclude for phpstan * update * update * update * update * update * merge * restore one filter * delete old errors * fix * fix * fix * $moreforfilter can t be empty * fix * enable check * refresh baseline * add phpdoc * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-11-04 22:53:20 +00:00
*/
// Protection to avoid direct call of template
2021-02-23 21:03:23 +00:00
if (empty($langs) || !is_object($langs)) {
print "Error, template page can't be called as URL";
exit(1);
}
2023-11-13 12:01:14 +00:00
global $action, $form, $langs;
// Prefer $pagekey (the whitelisted request key) for self-referencing links; fall back to
// $elementtype for older-style callers of this shared template that don't define $pagekey.
$pagekeyforurl = isset($pagekey) ? $pagekey : $elementtype;
$langs->load("modulebuilder");
2023-11-13 12:01:14 +00:00
if ($action == 'delete') {
$attributekey = GETPOST('attrname', 'aZ09');
print $form->formconfirm($_SERVER['PHP_SELF']."?attrname=$attributekey&elementtype=".urlencode($pagekeyforurl), $langs->trans("DeleteExtrafield"), $langs->trans("ConfirmDeleteExtrafield", $attributekey), "confirm_delete", '', 0, 1);
2023-11-13 12:01:14 +00:00
}
?>
<!-- BEGIN PHP TEMPLATE admin_extrafields_view.tpl.php -->
<?php
2023-12-04 11:07:53 +00:00
$title = '<span class="opacitymedium">'.$langs->trans("DefineHereComplementaryAttributes", empty($textobject) ? '' : $textobject).'</span><br>'."\n";
//if ($action != 'create' && $action != 'edit') {
$newcardbutton = '';
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAttribute'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?action=create&elementtype='.urlencode($pagekeyforurl), '', 1);
/*} else {
$newcardbutton = '';
}*/
print '<div class="centpercent tagtable marginbottomonly">';
print '<div class="tagtr">';
print '<div class="tagtd inline-block valignmiddle hideonsmartphoneimp">'.$title.'</div>';
print '<div class="tagtd right inline-block valignmiddle"">'.$newcardbutton.'</div>';
print '</div>';
print '</div>';
2021-11-28 23:49:18 +00:00
// Load $extrafields->attributes
$extrafields->fetch_name_optionals_label($elementtype);
2016-11-27 13:21:23 +00:00
print '<div class="div-table-responsive">';
print '<table summary="listofattributes" class="noborder centpercent small">';
print '<tr class="liste_titre">';
2026-04-23 15:41:15 +00:00
if ($conf->main_checkbox_left_column) {
print '<td width="80">&nbsp;</td>';
}
2019-01-19 11:40:17 +00:00
print '<td class="left">'.$langs->trans("Position");
2018-09-12 19:57:32 +00:00
print '<span class="nowrap">';
print img_picto('A-Z', '1downarrow.png');
print '</span>';
print '</td>';
2018-07-08 18:06:24 +00:00
print '<td>'.$langs->trans("LabelOrTranslationKey").'</td>';
2024-11-05 18:02:33 +00:00
//print '<td>'.$langs->trans("TranslationString").'</td>';
print '<td>'.$langs->trans("AttributeCode").'</td>';
print '<td>'.$langs->trans("Type").'</td>';
2019-02-16 09:29:15 +00:00
print '<td class="right">'.$langs->trans("Size").'</td>';
print '<td>'.$langs->trans("ComputedFormula").'</td>';
2019-02-16 09:29:15 +00:00
print '<td class="center">'.$langs->trans("Unique").'</td>';
print '<td class="center">'.$langs->trans("Mandatory").'</td>';
print '<td class="center">'.$form->textwithpicto($langs->trans("AlwaysEditable"), $langs->trans("EditableWhenDraftOnly")).'</td>';
print '<td class="center">'.$form->textwithpicto($langs->trans("IsPersonalData"), $langs->trans("IsPersonalDataDesc")).'</td>';
print '<td class="center">'.$form->textwithpicto($langs->trans("EmptyOnClone"), $langs->trans("EmptyOnCloneDesc")).'</td>';
2023-03-17 14:28:07 +00:00
print '<td class="center">'.$form->textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc").'<br><br>'.$langs->trans("ItCanBeAnExpression")).'</td>';
print '<td class="center">'.$form->textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")).'</td>';
2019-02-16 09:29:15 +00:00
print '<td class="center">'.$form->textwithpicto($langs->trans("Totalizable"), $langs->trans("TotalizableDesc")).'</td>';
print '<td class="center">'.$form->textwithpicto($langs->trans("CssOnEdit"), $langs->trans("HelpCssOnEditDesc")).'</td>';
print '<td class="center">'.$form->textwithpicto($langs->trans("CssOnView"), $langs->trans("HelpCssOnViewDesc")).'</td>';
print '<td class="center">'.$form->textwithpicto($langs->trans("CssOnList"), $langs->trans("HelpCssOnListDesc")).'</td>';
2022-08-28 12:07:20 +00:00
if (isModEnabled('multicompany')) {
2021-03-20 19:51:19 +00:00
print '<td class="center">'.$langs->trans("Entity").'</td>';
}
// Action column
2026-04-23 15:41:15 +00:00
if (!$conf->main_checkbox_left_column) {
print '<td width="80">&nbsp;</td>';
}
print "</tr>\n";
2021-03-17 13:32:25 +00:00
if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafields->attributes[$elementtype]['type']) && count($extrafields->attributes[$elementtype]['type'])) {
2021-02-23 21:03:23 +00:00
foreach ($extrafields->attributes[$elementtype]['type'] as $key => $value) {
2025-11-06 12:15:03 +00:00
/*if (! (int) dol_eval((string) $extrafields->attributes[$elementtype]['enabled'][$key], 1, 1, '1')) {
// TODO Uncomment this to exclude extrafields of modules not enabled. Add a link to "Show extrafields disabled"
// continue;
}*/
// Load language if required
if (!empty($extrafields->attributes[$elementtype]['langfile'][$key])) {
2017-10-16 08:57:39 +00:00
$langs->load($extrafields->attributes[$elementtype]['langfile'][$key]);
}
print '<tr class="oddeven">';
// Actions
2026-04-23 15:41:15 +00:00
if ($conf->main_checkbox_left_column) {
print '<td class="center nowraponall">';
print '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&attrname='.urlencode($key).'&elementtype='.urlencode($pagekeyforurl).'#formeditextrafield">'.img_edit().'</a>';
print '&nbsp; <a class="paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&attrname='.urlencode($key).'&elementtype='.urlencode($pagekeyforurl).'">'.img_delete().'</a>';
if ($extrafields->attributes[$elementtype]['type'][$key] == 'password' && !empty($extrafields->attributes[$elementtype]['param'][$key]['options']) && array_key_exists('dolcrypt', $extrafields->attributes[$elementtype]['param'][$key]['options'])) {
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>';
}
print '</td>'."\n";
}
// Position
add baseline exclude for phpstan (#31632) * add baseline exclude for phpstan * update * update * update * update * update * merge * restore one filter * delete old errors * fix * fix * fix * $moreforfilter can t be empty * fix * enable check * refresh baseline * add phpdoc * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-11-04 22:53:20 +00:00
print "<td>".dol_escape_htmltag((string) $extrafields->attributes[$elementtype]['pos'][$key])."</td>\n";
2024-11-05 18:02:33 +00:00
// Label and label translated
print '<td title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['label'][$key]).'" class="tdoverflowmax150 subtitle">';
print dol_escape_htmltag($extrafields->attributes[$elementtype]['label'][$key]);
if ($langs->transnoentitiesnoconv($extrafields->attributes[$elementtype]['label'][$key]) != $extrafields->attributes[$elementtype]['label'][$key]) {
print '<br><span class="subtitle small opacitymedium inline-block" title="'.dolPrintHTMLForAttribute($langs->trans("LabelTranslatedInCurrentLanguage")).'">';
print $langs->transnoentitiesnoconv($extrafields->attributes[$elementtype]['label'][$key]);
}
print '</span>';
print "</td>\n"; // We don't translate here, we want admin to know what is the key not translated value
// Label translated
2024-11-05 18:02:33 +00:00
//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";
// Key
print '<td title="'.dol_escape_htmltag($key).'" class="tdoverflowmax100">'.dol_escape_htmltag($key)."</td>\n";
// Type
2021-10-25 11:57:02 +00:00
$typetoshow = $type2label[$extrafields->attributes[$elementtype]['type'][$key]];
print '<td title="'.dol_escape_htmltag($typetoshow).'" class="tdoverflowmax100">';
print getPictoForType($extrafields->attributes[$elementtype]['type'][$key]);
2021-10-25 11:57:02 +00:00
print dol_escape_htmltag($typetoshow);
print "</td>\n";
// Size
print '<td class="right">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['size'][$key])."</td>\n";
// Computed field
print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['computed'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['computed'][$key])."</td>\n";
// Is unique ?
2019-02-16 09:29:15 +00:00
print '<td class="center">'.yn($extrafields->attributes[$elementtype]['unique'][$key])."</td>\n";
// Is mandatory ?
2019-02-16 09:29:15 +00:00
print '<td class="center">'.yn($extrafields->attributes[$elementtype]['required'][$key])."</td>\n";
// Can always be editable ?
2019-02-16 09:29:15 +00:00
print '<td class="center">'.yn($extrafields->attributes[$elementtype]['alwayseditable'][$key])."</td>\n";
// Personal data ?
print '<td class="center">'.yn($extrafields->attributes[$elementtype]['personal_data'][$key])."</td>\n";
// Will be emptied on clone ?
print '<td class="center">'.yn($extrafields->attributes[$elementtype]['emptyonclone'][$key])."</td>\n";
// Visible
print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['list'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['list'][$key])."</td>\n";
// Print on PDF
add baseline exclude for phpstan (#31632) * add baseline exclude for phpstan * update * update * update * update * update * merge * restore one filter * delete old errors * fix * fix * fix * $moreforfilter can t be empty * fix * enable check * refresh baseline * add phpdoc * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-11-04 22:53:20 +00:00
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";
// Summable
2019-02-16 09:29:15 +00:00
print '<td class="center">'.yn($extrafields->attributes[$elementtype]['totalizable'][$key])."</td>\n";
// CSS
print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['css'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['css'][$key])."</td>\n";
// CSS view
print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['cssview'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['cssview'][$key])."</td>\n";
// CSS list
print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['csslist'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['csslist'][$key])."</td>\n";
// Multicompany
2022-08-28 12:07:20 +00:00
if (isModEnabled('multicompany')) {
2025-02-06 14:21:11 +00:00
print '<td class="center tdoverflowmax100">';
2021-02-23 21:03:23 +00:00
if (empty($extrafields->attributes[$elementtype]['entityid'][$key])) {
2019-11-11 18:26:19 +00:00
print $langs->trans("All");
2020-05-21 13:05:19 +00:00
} else {
2019-11-11 18:26:19 +00:00
global $multicompanylabel_cache;
2021-02-23 21:03:23 +00:00
if (!is_array($multicompanylabel_cache)) {
$multicompanylabel_cache = array();
}
2019-11-11 18:26:19 +00:00
if (empty($multicompanylabel_cache[$extrafields->attributes[$elementtype]['entityid'][$key]])) {
global $mc;
2023-08-10 08:30:18 +00:00
if (is_object($mc) && method_exists($mc, 'getInfo')) {
2023-08-04 16:24:56 +00:00
$mc->getInfo($extrafields->attributes[$elementtype]['entityid'][$key]);
$multicompanylabel_cache[$extrafields->attributes[$elementtype]['entityid'][$key]] = $mc->label ? $mc->label : $extrafields->attributes[$elementtype]['entityid'][$key];
}
2019-11-11 18:26:19 +00:00
}
print $multicompanylabel_cache[$extrafields->attributes[$elementtype]['entityid'][$key]];
}
print '</td>';
}
// Actions
2026-04-23 15:41:15 +00:00
if (!$conf->main_checkbox_left_column) {
print '<td class="right nowraponall">';
print '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&attrname='.urlencode($key).'&elementtype='.urlencode($pagekeyforurl).'#formeditextrafield">'.img_edit().'</a>';
print '&nbsp; <a class="paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&attrname='.urlencode($key).'&elementtype='.urlencode($pagekeyforurl).'">'.img_delete().'</a>';
if ($extrafields->attributes[$elementtype]['type'][$key] == 'password' && !empty($extrafields->attributes[$elementtype]['param'][$key]['options']) && array_key_exists('dolcrypt', $extrafields->attributes[$elementtype]['param'][$key]['options'])) {
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>';
}
print '</td>'."\n";
}
print "</tr>";
}
2020-05-21 13:05:19 +00:00
} else {
$colspan = 18;
2022-08-28 12:07:20 +00:00
if (isModEnabled('multicompany')) {
2021-02-23 21:03:23 +00:00
$colspan++;
}
2026-04-26 20:40:14 +00:00
print '<tr class="">';
2021-10-04 02:14:31 +00:00
print '<td colspan="'.$colspan.'"><span class="opacitymedium">';
print $langs->trans("None");
2021-10-04 02:14:31 +00:00
print '</span></td>';
print '</tr>';
}
print "</table>";
2016-11-27 13:21:23 +00:00
print '</div>';
?>
<!-- END PHP TEMPLATE admin_extrafields_view.tpl.php -->