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 25// Protection to avoid direct call of template 26if (empty($conf) || !is_object($conf)) { 27 print "Error, template page can't be called as URL"; 28 exit; 29} 30 31?> 32<!-- BEGIN PHP TEMPLATE commonfields_add.tpl.php --> 33<?php 34 35$object->fields = dol_sort_array($object->fields, 'position'); 36 37foreach ($object->fields as $key => $val) { 38 // Discard if extrafield is a hidden field on form 39 if (abs($val['visible']) != 1 && abs($val['visible']) != 3) { 40 continue; 41 } 42 43 if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) { 44 continue; // We don't want this field 45 } 46 47 print '<tr class="field_'.$key.'">'; 48 print '<td'; 49 print ' class="titlefieldcreate'; 50 if (isset($val['notnull']) && $val['notnull'] > 0) { 51 print ' fieldrequired'; 52 } 53 if ($val['type'] == 'text' || $val['type'] == 'html') { 54 print ' tdtop'; 55 } 56 print '"'; 57 print '>'; 58 if (!empty($val['help'])) { 59 print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); 60 } else { 61 print $langs->trans($val['label']); 62 } 63 print '</td>'; 64 print '<td class="valuefieldcreate">'; 65 if (!empty($val['picto'])) { 66 print img_picto('', $val['picto'], '', false, 0, 0, '', 'pictofixedwidth'); 67 } 68 if (in_array($val['type'], array('int', 'integer'))) { 69 $value = GETPOST($key, 'int'); 70 } elseif ($val['type'] == 'double') { 71 $value = price2num(GETPOST($key, 'alphanohtml')); 72 } elseif ($val['type'] == 'text' || $val['type'] == 'html') { 73 $value = GETPOST($key, 'restricthtml'); 74 } elseif ($val['type'] == 'date') { 75 $value = dol_mktime(12, 0, 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); 76 } elseif ($val['type'] == 'datetime') { 77 $value = dol_mktime(GETPOST($key.'hour', 'int'), GETPOST($key.'min', 'int'), 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); 78 } elseif ($val['type'] == 'boolean') { 79 $value = (GETPOST($key) == 'on' ? 1 : 0); 80 } elseif ($val['type'] == 'price') { 81 $value = price2num(GETPOST($key)); 82 } else { 83 $value = GETPOST($key, 'alphanohtml'); 84 } 85 if (!empty($val['noteditable'])) { 86 print $object->showOutputField($val, $key, $value, '', '', '', 0); 87 } else { 88 print $object->showInputField($val, $key, $value, '', '', '', 0); 89 } 90 print '</td>'; 91 print '</tr>'; 92} 93 94?> 95<!-- END PHP TEMPLATE commonfields_add.tpl.php --> 96