admin_extrafields_view.tpl.php 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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-2019 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. /* To call this template, you must define
  20. * $textobject
  21. * $langs
  22. * $extrafield
  23. * $elementtype
  24. */
  25. // Protection to avoid direct call of template
  26. if (empty($langs) || !is_object($langs)) {
  27. print "Error, template page can't be called as URL";
  28. exit;
  29. }
  30. $langs->load("modulebuilder");
  31. ?>
  32. <!-- BEGIN PHP TEMPLATE admin_extrafields_view.tpl.php -->
  33. <?php
  34. $title = '<span class="opacitymedium">'.$langs->trans("DefineHereComplementaryAttributes", empty($textobject) ? '': $textobject).'</span><br>'."\n";
  35. //if ($action != 'create' && $action != 'edit') {
  36. $newcardbutton = dolGetButtonTitle($langs->trans('NewAttribute'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?action=create', '', (($action != 'create' && $action != 'edit') ? 1 : 1));
  37. /*} else {
  38. $newcardbutton = '';
  39. }*/
  40. print '<div class="centpercent tagtable marginbottomonly">';
  41. print '<div class="tagtr">';
  42. print '<div class="tagtd inline-block valignmiddle hideonsmartphoneimp">'.$title.'</div>';
  43. print '<div class="tagtd right inline-block valignmiddle"">'.$newcardbutton.'</div>';
  44. print '</div>';
  45. print '</div>';
  46. // Load $extrafields->attributes
  47. $extrafields->fetch_name_optionals_label($elementtype);
  48. print '<div class="div-table-responsive">';
  49. print '<table summary="listofattributes" class="noborder centpercent small">';
  50. print '<tr class="liste_titre">';
  51. print '<td class="left">'.$langs->trans("Position");
  52. print '<span class="nowrap">';
  53. print img_picto('A-Z', '1downarrow.png');
  54. print '</span>';
  55. print '</td>';
  56. print '<td>'.$langs->trans("LabelOrTranslationKey").'</td>';
  57. print '<td>'.$langs->trans("TranslationString").'</td>';
  58. print '<td>'.$langs->trans("AttributeCode").'</td>';
  59. print '<td>'.$langs->trans("Type").'</td>';
  60. print '<td class="right">'.$langs->trans("Size").'</td>';
  61. print '<td>'.$langs->trans("ComputedFormula").'</td>';
  62. print '<td class="center">'.$langs->trans("Unique").'</td>';
  63. print '<td class="center">'.$langs->trans("Mandatory").'</td>';
  64. print '<td class="center">'.$form->textwithpicto($langs->trans("AlwaysEditable"), $langs->trans("EditableWhenDraftOnly")).'</td>';
  65. print '<td class="center">'.$form->textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc")).'</td>';
  66. print '<td class="center">'.$form->textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")).'</td>';
  67. print '<td class="center">'.$form->textwithpicto($langs->trans("Totalizable"), $langs->trans("TotalizableDesc")).'</td>';
  68. print '<td class="center">'.$form->textwithpicto($langs->trans("CssOnEdit"), $langs->trans("HelpCssOnEditDesc")).'</td>';
  69. print '<td class="center">'.$form->textwithpicto($langs->trans("CssOnView"), $langs->trans("HelpCssOnViewDesc")).'</td>';
  70. print '<td class="center">'.$form->textwithpicto($langs->trans("CssOnList"), $langs->trans("HelpCssOnListDesc")).'</td>';
  71. if (isModEnabled('multicompany')) {
  72. print '<td class="center">'.$langs->trans("Entity").'</td>';
  73. }
  74. print '<td width="80">&nbsp;</td>';
  75. print "</tr>\n";
  76. if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafields->attributes[$elementtype]['type']) && count($extrafields->attributes[$elementtype]['type'])) {
  77. foreach ($extrafields->attributes[$elementtype]['type'] as $key => $value) {
  78. /*if (! dol_eval($extrafields->attributes[$elementtype]['enabled'][$key], 1, 1, '1')) {
  79. // TODO Uncomment this to exclude extrafields of modules not enabled. Add a link to "Show extrafields disabled"
  80. // continue;
  81. }*/
  82. // Load language if required
  83. if (!empty($extrafields->attributes[$elementtype]['langfile'][$key])) {
  84. $langs->load($extrafields->attributes[$elementtype]['langfile'][$key]);
  85. }
  86. print '<tr class="oddeven">';
  87. // Position
  88. print "<td>".dol_escape_htmltag($extrafields->attributes[$elementtype]['pos'][$key])."</td>\n";
  89. // Label
  90. 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
  91. // Label translated
  92. 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";
  93. // Key
  94. print '<td title="'.dol_escape_htmltag($key).'" class="tdoverflowmax100">'.dol_escape_htmltag($key)."</td>\n";
  95. // Type
  96. $typetoshow = $type2label[$extrafields->attributes[$elementtype]['type'][$key]];
  97. print '<td title="'.dol_escape_htmltag($typetoshow).'" class="tdoverflowmax100">';
  98. print dol_escape_htmltag($typetoshow);
  99. print "</td>\n";
  100. // Size
  101. print '<td class="right">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['size'][$key])."</td>\n";
  102. // Computed field
  103. print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['computed'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['computed'][$key])."</td>\n";
  104. // Is unique ?
  105. print '<td class="center">'.yn($extrafields->attributes[$elementtype]['unique'][$key])."</td>\n";
  106. // Is mandatory ?
  107. print '<td class="center">'.yn($extrafields->attributes[$elementtype]['required'][$key])."</td>\n";
  108. // Can always be editable ?
  109. print '<td class="center">'.yn($extrafields->attributes[$elementtype]['alwayseditable'][$key])."</td>\n";
  110. // Visible
  111. print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['list'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['list'][$key])."</td>\n";
  112. // Print on PDF
  113. print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['printable'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['printable'][$key])."</td>\n";
  114. // Summable
  115. print '<td class="center">'.yn($extrafields->attributes[$elementtype]['totalizable'][$key])."</td>\n";
  116. // CSS
  117. print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['css'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['css'][$key])."</td>\n";
  118. // CSS view
  119. print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['cssview'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['cssview'][$key])."</td>\n";
  120. // CSS list
  121. print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($extrafields->attributes[$elementtype]['csslist'][$key]).'">'.dol_escape_htmltag($extrafields->attributes[$elementtype]['csslist'][$key])."</td>\n";
  122. // Multicompany
  123. if (isModEnabled('multicompany')) {
  124. print '<td class="center">';
  125. if (empty($extrafields->attributes[$elementtype]['entityid'][$key])) {
  126. print $langs->trans("All");
  127. } else {
  128. global $multicompanylabel_cache;
  129. if (!is_array($multicompanylabel_cache)) {
  130. $multicompanylabel_cache = array();
  131. }
  132. if (empty($multicompanylabel_cache[$extrafields->attributes[$elementtype]['entityid'][$key]])) {
  133. global $mc;
  134. $mc->getInfo($extrafields->attributes[$elementtype]['entityid'][$key]);
  135. $multicompanylabel_cache[$extrafields->attributes[$elementtype]['entityid'][$key]] = $mc->label ? $mc->label : $extrafields->attributes[$elementtype]['entityid'][$key];
  136. }
  137. print $multicompanylabel_cache[$extrafields->attributes[$elementtype]['entityid'][$key]];
  138. }
  139. print '</td>';
  140. }
  141. // Actions
  142. print '<td class="right nowraponall">';
  143. print '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&attrname='.urlencode($key).'#formeditextrafield">'.img_edit().'</a>';
  144. print '&nbsp; <a class="paddingleft" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&attrname='.urlencode($key).'">'.img_delete().'</a>';
  145. print '</td>'."\n";
  146. print "</tr>";
  147. }
  148. } else {
  149. $colspan = 17;
  150. if (isModEnabled('multicompany')) {
  151. $colspan++;
  152. }
  153. print '<tr class="oddeven">';
  154. print '<td colspan="'.$colspan.'"><span class="opacitymedium">';
  155. print $langs->trans("None");
  156. print '</span></td>';
  157. print '</tr>';
  158. }
  159. print "</table>";
  160. print '</div>';
  161. ?>
  162. <!-- END PHP TEMPLATE admin_extrafields_view.tpl.php -->