dolibarr 21.0.0-beta
extrafields_add.tpl.php
1<?php
2/* Copyright (C) 2014 Maxime Kohlhaas <support@atm-consulting.fr>
3 * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 *
19 * Need to have the following variables defined:
20 * $object (invoice, order, ...)
21 * $action
22 * $db
23 * $conf
24 * $langs
25 * $parameters
26 * $thirdpartytopropagateextrafieldsfrom
27 */
28
42// Protection to avoid direct call of template
43if (empty($conf) || !is_object($conf)) {
44 print "Error, template page can't be called as URL";
45 exit(1);
46}
47
48'
49@phan-var-force CommonObject $object
50@phan-var-force string $action
51@phan-var-force DoliDB $db
52@phan-var-force Conf $conf
53@phan-var-force Translate $langs
54@phan-var-force array<string,mixed> $parameters
55@phan-var-force Societe $thirdpartytopropagateextrafieldsfrom
56';
57
58?>
59<!-- BEGIN PHP TEMPLATE extrafields_add.tpl.php -->
60<?php
61
62// Other attributes
63if (!isset($parameters)) {
64 $parameters = array();
65}
66
67$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
68
69print $hookmanager->resPrint;
70if (empty($reshook)) {
71 $params = array();
72 $params['cols'] = array_key_exists('colspanvalue', $parameters) ? $parameters['colspanvalue'] : '';
73 if (!empty($parameters['tdclass'])) {
74 $params['tdclass'] = $parameters['tdclass'];
75 }
76 if (!empty($parameters['tpl_context'])) {
77 $params['tpl_context'] = $parameters['tpl_context'];
78 }
79
80 // By default $thirdpartytopropagateextrafieldsfrom is not set.
81 // We can have it set to a thirdparty object to propagate also the extrafields from thirdparty to object.
82 if (!empty($thirdpartytopropagateextrafieldsfrom) && $thirdpartytopropagateextrafieldsfrom instanceof Societe && !empty($thirdpartytopropagateextrafieldsfrom->id)) {
83 // copy from thirdparty
84 $tpExtrafields = new ExtraFields($db);
85 $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($thirdpartytopropagateextrafieldsfrom->table_element);
86 if ($thirdpartytopropagateextrafieldsfrom->fetch_optionals() > 0) {
87 $object->array_options = array_merge($object->array_options, $thirdpartytopropagateextrafieldsfrom->array_options);
88 }
89 }
90
91 print $object->showOptionals($extrafields, 'create', $params);
92}
93
94?>
95<!-- END PHP TEMPLATE extrafields_add.tpl.php -->
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
Class to manage standard extra fields.
Class to manage third parties objects (customers, suppliers, prospects...)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79