commonfields_add.tpl.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. *
  17. * Need to have following variables defined:
  18. * $object (invoice, order, ...)
  19. * $action
  20. * $conf
  21. * $langs
  22. * $form
  23. */
  24. // Protection to avoid direct call of template
  25. if (empty($conf) || !is_object($conf))
  26. {
  27. print "Error, template page can't be called as URL";
  28. exit;
  29. }
  30. ?>
  31. <!-- BEGIN PHP TEMPLATE commonfields_add.tpl.php -->
  32. <?php
  33. $object->fields = dol_sort_array($object->fields, 'position');
  34. foreach ($object->fields as $key => $val)
  35. {
  36. // Discard if extrafield is a hidden field on form
  37. if (abs($val['visible']) != 1 && abs($val['visible']) != 3) continue;
  38. if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) continue; // We don't want this field
  39. print '<tr id="field_'.$key.'">';
  40. print '<td';
  41. print ' class="titlefieldcreate';
  42. if ($val['notnull'] > 0) print ' fieldrequired';
  43. if ($val['type'] == 'text' || $val['type'] == 'html') print ' tdtop';
  44. print '"';
  45. print '>';
  46. if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
  47. else print $langs->trans($val['label']);
  48. print '</td>';
  49. print '<td>';
  50. if (in_array($val['type'], array('int', 'integer'))) $value = GETPOST($key, 'int');
  51. elseif ($val['type'] == 'text' || $val['type'] == 'html') $value = GETPOST($key, 'restricthtml');
  52. else $value = GETPOST($key, 'alpha');
  53. if ($val['noteditable']) print $object->showOutputField($val, $key, $value, '', '', '', 0);
  54. else print $object->showInputField($val, $key, $value, '', '', '', 0);
  55. print '</td>';
  56. print '</tr>';
  57. }
  58. ?>
  59. <!-- END PHP TEMPLATE commonfields_add.tpl.php -->