28if (empty($object) || !is_object($object)) {
29 print
"Error, template page can't be called as URL";
33if (!is_object($form)) {
34 $form =
new Form($db);
37if (!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 .
'_';
79 print
'<div id="block_' . $mode_key .
'">';
81 print
'<div class="fichecenter">';
82 print
'<div class="fichehalfleft">';
83 print
'<div class="underbanner clearboth"></div>';
84 print
'<table class="border centpercent tableforfield">' .
"\n";
85 $mode_info[
'fields'] =
dol_sort_array($mode_info[
'fields'],
'position');
86 foreach ($mode_info[
'fields'] as $field_key => $field_info) {
88 if (abs($field_info[
'visible']) != 1 && abs($field_info[
'visible']) != 3 && abs($field_info[
'visible']) != 4) {
91 if (array_key_exists(
'enabled', $field_info) && isset($field_info[
'enabled']) && !
verifCond($field_info[
'enabled'])) {
94 if (!empty($field_info[
'column_break'])) {
99 print
'<div class="fichehalfright">';
101 print
'<div class="underbanner clearboth"></div>';
102 print
'<table class="border centpercent tableforfield">';
105 $html_name = $prefix_html_name . $field_key;
106 if (!empty($field_info[
'enabled_field'])) {
107 $info = explode(
':', $field_info[
'enabled_field']);
108 $enabled_field_info[] = array(
109 'mode_key' => $info[0],
110 'field_key' => $info[1],
112 'target' =>
'field_' . $html_name,
117 if (!empty($field_info[
'required']) || (isset($field_info[
'notnull']) && $field_info[
'notnull'] > 0)) {
118 $more_class .=
' fieldrequired';
120 if (preg_match(
'/^(text|html)/', $val[
'type'])) {
121 $more_class .=
' tdtop';
124 print
'<tr class="field_' . $html_name .
'" id="field_' . $html_name .
'"><td';
125 print
' class="titlefieldcreate' . $more_class .
'">';
126 if (!empty($field_info[
'help'])) {
127 print $form->textwithpicto($langs->trans($field_info[
'label']), $langs->trans($field_info[
'help']));
129 print $langs->trans($field_info[
'label']);
132 print
'<td class="valuefieldcreate">';
133 if (!empty($field_info[
'picto'])) {
134 print
img_picto(
'', $field_info[
'picto'],
'',
false, 0, 0,
'',
'pictofixedwidth');
136 if (in_array($field_info[
'type'], array(
'int',
'integer'))) {
137 $value = GETPOSTISSET($html_name) ?
GETPOST($html_name,
'int') : $assetdepreciationoptions->$field_key;
138 } elseif ($field_info[
'type'] ==
'double') {
139 $value = GETPOSTISSET($html_name) ?
price2num(
GETPOST($html_name,
'alphanohtml')) : $assetdepreciationoptions->$field_key;
140 } elseif (preg_match(
'/^(text|html)/', $field_info[
'type'])) {
141 $tmparray = explode(
':', $field_info[
'type']);
142 if (!empty($tmparray[1])) {
143 $check = $tmparray[1];
145 $check =
'restricthtml';
147 $value = GETPOSTISSET($html_name) ?
GETPOST($html_name, $check) : $assetdepreciationoptions->$field_key;
148 } elseif ($field_info[
'type'] ==
'price') {
149 $value = GETPOSTISSET($html_name) ?
price2num(
GETPOST($html_name)) : ($assetdepreciationoptions->$field_key ?
price2num($assetdepreciationoptions->$field_key) : (!empty($field_info[
'default']) ?
dol_eval($field_info[
'default'], 1) : 0));
150 } elseif ($field_key ==
'lang') {
151 $value = GETPOSTISSET($html_name) ?
GETPOST($html_name,
'aZ09') : $assetdepreciationoptions->lang;
153 $value = GETPOSTISSET($html_name) ?
GETPOST($html_name,
'alpha') : $assetdepreciationoptions->$field_key;
155 if (!empty($field_info[
'noteditable'])) {
156 print $assetdepreciationoptions->showOutputField($field_info, $field_key, $value,
'',
'', $prefix_html_name, 0);
158 if ($field_key ==
'lang') {
159 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
160 print $formadmin->select_language($value, $html_name, 0,
null, 1, 0, 0,
'minwidth300', 2);
162 print $assetdepreciationoptions->showInputField($field_info, $field_key, $value,
'',
'', $prefix_html_name, 0);
171 print
'<div class="clearboth"></div>';
176if (!empty($enabled_field_info)) {
177 $enabled_field_info = json_encode($enabled_field_info);
179<script
type=
"text/javascript">
180 jQuery(document).ready(
function () {
181 var enabled_field_info = $enabled_field_info;
184 enabled_field_info.map(
function(info) {
185 var html_name = info.mode_key +
'_' + info.field_key;
186 var source = $(
'#' + html_name);
187 if (!(source.length > 0)) source = $(
'[name="' + html_name +
'"]');
188 if (source.length > 0) {
189 source.attr(
'data-asset-enabled-field-value', info.value);
190 source.attr(
'data-asset-enabled-field-target', info.target);
191 updateEnabledField(source);
192 source.on(
'change click',
function() {
193 updateEnabledField(jQuery(
this));
198 function updateEnabledField(_this) {
199 var value = _this.attr(
'data-asset-enabled-field-value');
200 var target_name = _this.attr(
'data-asset-enabled-field-target');
203 var target = $(
'div#' + target_name);
206 if (!(target.length > 0)) {
207 target = $(
'#' + target_name);
208 if (!(target.length > 0)) target = $(
'[name="' + target_name +
'"]');
209 if (target.length > 0) target = target.closest(
'tr');
212 if (target.length > 0) {
213 var source_value = _this.attr(
'type') ==
'checkbox' ? (_this.is(
':checked') ? 1 : 0) : _this.val();
215 if (source_value != value) {
228<!-- END PHP TEMPLATE depreciation_options_edit.tpl.php -->
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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.
verifCond($strToEvaluate)
Verify if condition in string is ok or not.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type