29 print
"Error, template page can't be called as URL";
33if (!is_object($form)) {
34 $form =
new Form($db);
37if (!isset($formadmin) || !is_object($formadmin)) {
38 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formadmin.class.php';
44<!-- BEGIN PHP TEMPLATE depreciation_options_edit.tpl.php -->
47if (!is_array($parameters)) {
48 $parameters = array();
50$enabled_field_info = array();
51if (empty($parameters[
'enabled_field_info'])) {
52 $parameters[
'enabled_field_info'] = &$enabled_field_info;
54if (empty($parameters[
'assetdepreciationoptions'])) {
55 $parameters[
'assetdepreciationoptions'] = &$assetdepreciationoptions;
57$reshook = $hookmanager->executeHooks(
'formAssetDeprecationOptions', $parameters,
$object, $action);
58print $hookmanager->resPrint;
64 $class_type = get_class(
$object) ==
'Asset' ? 0 : 1;
65 foreach ($assetdepreciationoptions->deprecation_options_fields as $mode_key => $mode_info) {
66 if (!empty($mode_info[
'enabled_field'])) {
67 $info = explode(
':', $mode_info[
'enabled_field']);
68 $enabled_field_info[] = array(
69 'mode_key' => $info[0],
70 'field_key' => $info[1],
72 'target' =>
'block_' . $mode_key,
76 $assetdepreciationoptions->setInfosForMode($mode_key, $class_type,
true);
77 $prefix_html_name = $mode_key .
'_';
78 $width = ($mode_key ==
"economic")?
"width50p pull-left" :
"width50p";
79 print
'<table class="border '. $width .
'" id="block_' . $mode_key .
'">' .
"\n";
80 print
'<tr><td class="info-box-title">'.$langs->trans($mode_info[
'label']).
'</td></tr>';
81 if ($mode_key ==
"economic") {
84 $mode_info[
'fields'] =
dol_sort_array($mode_info[
'fields'],
'position');
85 foreach ($mode_info[
'fields'] as $field_key => $field_info) {
87 if (abs($field_info[
'visible']) != 1 && abs($field_info[
'visible']) != 3 && abs($field_info[
'visible']) != 4) {
90 if (array_key_exists(
'enabled', $field_info) && isset($field_info[
'enabled']) && !
verifCond($field_info[
'enabled'])) {
95 $html_name = $prefix_html_name . $field_key;
96 if (!empty($field_info[
'enabled_field'])) {
97 $info = explode(
':', $field_info[
'enabled_field']);
98 $enabled_field_info[] = array(
99 'mode_key' => $info[0],
100 'field_key' => $info[1],
102 'target' =>
'field_' . $html_name,
107 if (!empty($field_info[
'required'])) {
108 $more_class .=
'width40p fieldrequired';
110 if (isset($val[
'type']) && preg_match(
'/^(text|html)/', $val[
'type'])) {
111 $more_class .=
' tdtop';
114 print
'<tr class="field_' . $html_name .
'" id="field_' . $html_name .
'"><td';
115 print
' class="' . $more_class .
'">';
116 if (!empty($field_info[
'help'])) {
117 print $form->textwithpicto($langs->trans($field_info[
'label']), $langs->trans($field_info[
'help']));
119 print $langs->trans($field_info[
'label']);
122 print
'<td class="valuefieldcreate">';
123 if (!empty($field_info[
'picto'])) {
124 print
img_picto(
'', $field_info[
'picto'],
'',
false, 0, 0,
'',
'pictofixedwidth');
126 if (in_array($field_info[
'type'], array(
'int',
'integer'))) {
127 $value = GETPOSTISSET($html_name) ?
GETPOSTINT($html_name) : $assetdepreciationoptions->$field_key;
128 } elseif ($field_info[
'type'] ==
'double') {
129 $value = GETPOSTISSET($html_name) ?
price2num(
GETPOST($html_name,
'alphanohtml')) : $assetdepreciationoptions->$field_key;
130 } elseif (preg_match(
'/^(text|html)/', $field_info[
'type'])) {
131 $tmparray = explode(
':', $field_info[
'type']);
132 if (!empty($tmparray[1])) {
133 $check = $tmparray[1];
135 $check =
'restricthtml';
137 $value = GETPOSTISSET($html_name) ?
GETPOST($html_name, $check) : $assetdepreciationoptions->$field_key;
138 } elseif ($field_info[
'type'] ==
'price') {
139 $value = GETPOSTISSET($html_name) ?
price2num(
GETPOST($html_name)) : ($assetdepreciationoptions->$field_key ?
price2num($assetdepreciationoptions->$field_key) : (!empty($field_info[
'default']) ? $field_info[
'default'] : 0));
140 } elseif ($field_key ==
'lang') {
141 $value = GETPOSTISSET($html_name) ?
GETPOST($html_name,
'aZ09') : $assetdepreciationoptions->lang;
143 $value = GETPOSTISSET($html_name) ?
GETPOST($html_name,
'alpha') : $assetdepreciationoptions->$field_key;
145 if (!empty($field_info[
'noteditable'])) {
146 print $assetdepreciationoptions->showOutputField($field_info, $field_key, $value,
'',
'', $prefix_html_name, 0);
148 if ($field_key ==
'lang') {
149 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
150 print $formadmin->select_language($value, $html_name, 0,
null, 1, 0, 0,
'minwidth300', 2);
152 print $assetdepreciationoptions->showInputField($field_info, $field_key, $value,
'',
'', $prefix_html_name, 0);
160 print
'<div class="clearboth"></div>';
163if (!empty($enabled_field_info)) {
164 $enabled_field_info = json_encode($enabled_field_info);
166<script
type=
"text/javascript">
167 jQuery(document).ready(
function () {
168 var enabled_field_info = $enabled_field_info;
171 enabled_field_info.map(
function(info) {
172 var html_name = info.mode_key +
'_' + info.field_key;
173 var source = $(
'#' + html_name);
174 if (!(source.length > 0)) source = $(
'[name="' + html_name +
'"]');
175 if (source.length > 0) {
176 source.attr(
'data-asset-enabled-field-value', info.value);
177 source.attr(
'data-asset-enabled-field-target', info.target);
178 updateEnabledField(source);
179 source.on(
'change click',
function() {
180 updateEnabledField(jQuery(
this));
185 function updateEnabledField(_this) {
186 var value = _this.attr(
'data-asset-enabled-field-value');
187 var target_name = _this.attr(
'data-asset-enabled-field-target');
190 var target = $(
'table#' + target_name);
193 if (!(target.length > 0)) {
194 target = $(
'#' + target_name);
195 if (!(target.length > 0)) target = $(
'[name="' + target_name +
'"]');
196 if (target.length > 0) target = target.closest(
'tr');
199 if (target.length > 0) {
200 var source_value = _this.attr(
'type') ==
'checkbox' ? (_this.is(
':checked') ? 1 : 0) : _this.val();
202 if (source_value != value) {
215<!-- END PHP TEMPLATE depreciation_options_edit.tpl.php -->
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
verifCond($strToEvaluate, $onlysimplestring='1')
Verify if condition in string is ok or not.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type