commonfields_add.tpl.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. print "Error, template page can't be called as URL";
  27. exit;
  28. }
  29. ?>
  30. <!-- BEGIN PHP TEMPLATE commonfields_add.tpl.php -->
  31. <?php
  32. $object->fields = dol_sort_array($object->fields, 'position');
  33. foreach ($object->fields as $key => $val) {
  34. // Discard if field is a hidden field on form
  35. if (abs($val['visible']) != 1 && abs($val['visible']) != 3) {
  36. continue;
  37. }
  38. if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) {
  39. continue; // We don't want this field
  40. }
  41. print '<tr class="field_' . $key . '">';
  42. print '<td';
  43. print ' class="titlefieldcreate';
  44. if (isset($val['notnull']) && $val['notnull'] > 0) {
  45. print ' fieldrequired';
  46. }
  47. if ($val['type'] == 'text' || $val['type'] == 'html') {
  48. print ' tdtop';
  49. }
  50. print '"';
  51. print '>';
  52. if (!empty($val['help'])) {
  53. print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
  54. } else {
  55. print $langs->trans($val['label']);
  56. }
  57. print '</td>';
  58. print '<td class="valuefieldcreate">';
  59. if (!empty($val['picto'])) {
  60. print img_picto('', $val['picto'], '', false, 0, 0, '', 'pictofixedwidth');
  61. }
  62. if (in_array($val['type'], array('int', 'integer'))) {
  63. $value = GETPOST($key, 'int');
  64. } elseif ($val['type'] == 'double') {
  65. $value = price2num(GETPOST($key, 'alphanohtml'));
  66. } elseif ($val['type'] == 'text' || $val['type'] == 'html') {
  67. $value = GETPOST($key, 'restricthtml');
  68. } elseif ($val['type'] == 'date') {
  69. $value = dol_mktime(12, 0, 0, GETPOST($key . 'month', 'int'), GETPOST($key . 'day', 'int'), GETPOST($key . 'year', 'int'));
  70. } elseif ($val['type'] == 'datetime') {
  71. $value = dol_mktime(GETPOST($key . 'hour', 'int'), GETPOST($key . 'min', 'int'), 0, GETPOST($key . 'month', 'int'), GETPOST($key . 'day', 'int'), GETPOST($key . 'year', 'int'));
  72. } elseif ($val['type'] == 'boolean') {
  73. $value = (GETPOST($key) == 'on' ? 1 : 0);
  74. } elseif ($val['type'] == 'price') {
  75. $value = price2num(GETPOST($key));
  76. } elseif ($key == 'lang') {
  77. $value = GETPOST($key, 'aZ09');
  78. } else {
  79. $value = GETPOST($key, 'alphanohtml');
  80. }
  81. if (!empty($val['noteditable'])) {
  82. print $object->showOutputField($val, $key, $value, '', '', '', 0);
  83. } else {
  84. if ($key == 'lang') {
  85. print img_picto('', 'language', 'class="pictofixedwidth"');
  86. print $formadmin->select_language($value, $key, 0, null, 1, 0, 0, 'minwidth300', 2);
  87. } elseif ($key == 'fk_product') {
  88. print $VoucherHelper->showInputField($fk_product);
  89. print '<!-- ' . $key . ' JS for SELECT input -->';
  90. print $VoucherHelper->JSGeneratorForSelectInput($key);
  91. } else {
  92. print $VoucherHelper->showInputField($fk_product);
  93. }
  94. }
  95. //print_r($_REQUEST);
  96. //var_dump($fk_product);
  97. $display = $fk_product == '' || $fk_product == -1 ? 'TDhideClass' : '';
  98. print '</td>';
  99. print '</tr>';
  100. print '<tr id="eventDateSelector" class="' . $display . '">
  101. <td class="titlefieldcreate fieldrequired">Dátum</td>
  102. <td class="valuefieldcreateflat"><input type="date" id="date" name="date">
  103. <p class="error-message" id="error-message">Ez a dátum nem választható!</p></td>
  104. </tr>';
  105. print '<tr id="eventTimeSelector" class="TDhideClass">
  106. <td class="titlefieldcreate fieldrequired">Időpont</td>
  107. <td><select id="eventId" name="eventId">
  108. </select>
  109. </td></tr>';
  110. }
  111. ?>
  112. <!-- END PHP TEMPLATE commonfields_add.tpl.php -->