commonfields_edit.tpl.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /* Copyright (C) 2017-2019 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. print "Error, template page can't be called as URL";
  27. exit;
  28. }
  29. if (!is_object($form)) {
  30. $form = new Form($db);
  31. }
  32. ?>
  33. <!-- BEGIN PHP TEMPLATE commonfields_edit.tpl.php -->
  34. <?php
  35. $object->fields = dol_sort_array($object->fields, 'position');
  36. //$warehouses = $settlementsGroup->getWarehouses();
  37. //$entities = $settlementsGroup->getEntites();
  38. $entities = $helper->getAllEntities();
  39. foreach ($object->fields as $key => $val) {
  40. // Discard if extrafield is a hidden field on form
  41. if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4) {
  42. continue;
  43. }
  44. if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) {
  45. continue; // We don't want this field
  46. }
  47. print '<tr class="field_'.$key.'"><td';
  48. print ' class="titlefieldcreate';
  49. if (isset($val['notnull']) && $val['notnull'] > 0) {
  50. print ' fieldrequired';
  51. }
  52. if (preg_match('/^(text|html)/', $val['type'])) {
  53. print ' tdtop';
  54. }
  55. print '">';
  56. if (!empty($val['help'])) {
  57. print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
  58. } else {
  59. print $langs->trans($val['label']);
  60. }
  61. print '</td>';
  62. print '<td class="valuefieldcreate">';
  63. if (!empty($val['picto'])) {
  64. print img_picto('', $val['picto'], '', false, 0, 0, '', 'pictofixedwidth');
  65. }
  66. if (in_array($val['type'], array('int', 'integer'))) {
  67. $value = GETPOSTISSET($key) ?GETPOST($key, 'int') : $object->$key;
  68. } elseif ($val['type'] == 'double') {
  69. $value = GETPOSTISSET($key) ? price2num(GETPOST($key, 'alphanohtml')) : $object->$key;
  70. } elseif (preg_match('/^(text|html)/', $val['type'])) {
  71. $tmparray = explode(':', $val['type']);
  72. if (!empty($tmparray[1])) {
  73. $check = $tmparray[1];
  74. } else {
  75. $check = 'restricthtml';
  76. }
  77. $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $object->$key;
  78. } elseif (in_array($val['type'], array('date', 'datetime'))) {
  79. $value = GETPOSTISSET($key) ? dol_mktime(GETPOST($key.'hour', 'int'), GETPOST($key.'min', 'int'), GETPOST($key.'sec', 'int'), GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')) : $object->$key;
  80. } elseif ($val['type'] == 'price') {
  81. $value = GETPOSTISSET($key) ? price2num(GETPOST($key)) : price2num($object->$key);
  82. } elseif ($key == 'lang') {
  83. $value = GETPOSTISSET($key) ? GETPOST($key, 'aZ09') : $object->lang;
  84. } else {
  85. $value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $object->$key;
  86. }
  87. //var_dump($val.' '.$key.' '.$value
  88. if (!empty($val['noteditable'])) {
  89. print $object->showOutputField($val, $key, $value, '', '', '', 0);
  90. } else {
  91. if ($key == 'lang') {
  92. print img_picto('', 'language', 'class="pictofixedwidth"');
  93. print $formadmin->select_language($value, $key, 0, null, 1, 0, 0, 'minwidth300', 2);
  94. } elseif ($key == 'ref') {
  95. print $object->showInputField($val, $key, $value, '', '', '', 'minwidth500');
  96. } elseif ($key == 'fk_group') {
  97. print $object->showInputField($val, $key, $value, '', '', '', 'minwidth300');
  98. } elseif ($key == 'fk_entity') {
  99. include DOL_DOCUMENT_ROOT.'/custom/settlements/core/tpl/entities_add_edit_field.tpl.php';
  100. } else {
  101. print $object->showInputField($val, $key, $value, '', '', '', 0);
  102. }
  103. }
  104. print '</td>';
  105. print '</tr>';
  106. }
  107. ?>
  108. <!-- END PHP TEMPLATE commonfields_edit.tpl.php -->