| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <?php
- /* Copyright (C) 2017-2019 Laurent Destailleur <eldy@users.sourceforge.net>
- *
- * 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
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- * Need to have following variables defined:
- * $object (invoice, order, ...)
- * $action
- * $conf
- * $langs
- * $form
- */
- // Protection to avoid direct call of template
- if (empty($conf) || !is_object($conf)) {
- print "Error, template page can't be called as URL";
- exit;
- }
- if (!is_object($form)) {
- $form = new Form($db);
- }
- ?>
- <!-- BEGIN PHP TEMPLATE commonfields_edit.tpl.php -->
- <?php
- $object->fields = dol_sort_array($object->fields, 'position');
- if (empty($object->fields['status']['arrayofkeyval'])) {
- $object->fields['status']['arrayofkeyval'] = $stasusesObj->getStatusIds($db);
- }
- foreach ($object->fields as $key => $val) {
- // Discard if extrafield is a hidden field on form
- if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4) {
- continue;
- }
- if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) {
- continue; // We don't want this field
- }
- print '<tr class="field_' . $key . '"><td';
- print ' class="titlefieldcreate';
- if (isset($val['notnull']) && $val['notnull'] > 0) {
- print ' fieldrequired';
- }
- if (preg_match('/^(text|html)/', $val['type'])) {
- print ' tdtop';
- }
- print '">';
- if (!empty($val['help'])) {
- print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
- } else {
- print $langs->trans($val['label']);
- }
- print '</td>';
- print '<td class="valuefieldcreate">';
- if (!empty($val['picto'])) {
- print img_picto('', $val['picto'], '', false, 0, 0, '', 'pictofixedwidth');
- }
- if (in_array($val['type'], array('int', 'integer'))) {
- $val['arrayofkeyval'] = [110 => 'Raktárban1', 111 => 'Szervízben1', 112 => 'Kiadva1', 113 => 'Szállítás alatt1', 114 => 'Hibás1'];
- $value = GETPOSTISSET($key) ? GETPOST($key, 'int') : $object->$key;
- } elseif ($val['type'] == 'double') {
- $value = GETPOSTISSET($key) ? price2num(GETPOST($key, 'alphanohtml')) : $object->$key;
- } elseif (preg_match('/^(text|html)/', $val['type'])) {
- $tmparray = explode(':', $val['type']);
- if (!empty($tmparray[1])) {
- $check = $tmparray[1];
- } else {
- $check = 'restricthtml';
- }
- $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $object->$key;
- } elseif (in_array($val['type'], array('date', 'datetime'))) {
- $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;
- } elseif ($val['type'] == 'price') {
- $value = GETPOSTISSET($key) ? price2num(GETPOST($key)) : price2num($object->$key);
- } elseif ($key == 'lang') {
- $value = GETPOSTISSET($key) ? GETPOST($key, 'aZ09') : $object->lang;
- } else {
- $value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $object->$key;
- }
- //var_dump($val.' '.$key.' '.$value);
- if (!empty($val['noteditable'])) {
- print $object->showOutputField($val, $key, $value, '', '', '', 0);
- } else {
- if ($key == 'lang') {
- print img_picto('', 'language', 'class="pictofixedwidth"');
- print $formadmin->select_language($value, $key, 0, null, 1, 0, 0, 'minwidth300', 2);
- } else {
- print_r($val[$key]);
- print $object->showInputField($val, $key, $value, '', '', '', 0);
- }
- }
- print '</td>';
- print '</tr>';
- }
- ?>
- <!-- END PHP TEMPLATE commonfields_edit.tpl.php -->
- <script>
- /* var warehouses = ['1', '2', '3'];
- var mySelect = document.getElementById('fk_warehouse');
- mySelect.onchange = (event) => {
- var warehouse_id = event.target.value;
- if (warehouses.includes(warehouse_id)) {
- $("#status").val("113");
- $("#select2-status-container").html("Szállítás alatt");
- $('span.select2-selection__rendered').attr('title', 'Szállítás alatt');
- } else {
- $("#status").val("111");
- $("#select2-status-container").html("Szervízben");
- $('span.select2-selection__rendered').attr('title', 'Szervízben');
- }
- } */
- </script>
|