diff --git a/htdocs/asset/accountancy_codes.php b/htdocs/asset/accountancy_codes.php
index b0518902a34..4641f61a021 100644
--- a/htdocs/asset/accountancy_codes.php
+++ b/htdocs/asset/accountancy_codes.php
@@ -27,6 +27,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/asset.lib.php';
require_once DOL_DOCUMENT_ROOT . '/asset/class/asset.class.php';
require_once DOL_DOCUMENT_ROOT . '/asset/class/assetaccountancycodes.class.php';
+require_once DOL_DOCUMENT_ROOT . '/asset/class/assetdepreciationoptions.class.php';
// Load translation files required by the page
$langs->loadLangs(array("assets", "companies"));
@@ -37,10 +38,12 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
+$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
// Initialize technical objects
$object = new Asset($db);
$assetaccountancycodes = new AssetAccountancyCodes($db);
+$assetdepreciationoptions = new AssetDepreciationOptions($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->asset->dir_output . '/temp/massgeneration/' . $user->id;
$hookmanager->initHooks(array('assetaccountancycodes', 'globalcard')); // Note that conf->hooks_modules contains array
@@ -50,7 +53,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) {
- $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id;
+ $upload_dir = $conf->asset->multidir_output[isset($object->entity) ? $object->entity : 1] . "/" . $object->id;
}
$permissiontoadd = $user->hasRight('asset', 'write'); // Used by the include of actions_addupdatedelete.inc.php
@@ -65,9 +68,18 @@ if (!isModEnabled('asset')) {
accessforbidden();
}
-$result = $assetaccountancycodes->fetchAccountancyCodes($object->id);
-if ($result < 0) {
- setEventMessages($assetaccountancycodes->error, $assetaccountancycodes->errors, 'errors');
+$object->asset_depreciation_options = &$assetdepreciationoptions;
+$object->asset_accountancy_codes = &$assetaccountancycodes;
+if (!empty($id)) {
+ $depreciationoptionserrors = $assetdepreciationoptions->fetchDeprecationOptions($object->id, 0);
+ $accountancycodeserrors = $assetaccountancycodes->fetchAccountancyCodes($object->id, 0);
+
+ if ($depreciationoptionserrors < 0) {
+ setEventMessages($assetdepreciationoptions->error, $assetdepreciationoptions->errors, 'errors');
+ }
+ if ($accountancycodeserrors < 0) {
+ setEventMessages($assetaccountancycodes->error, $assetaccountancycodes->errors, 'errors');
+ }
}
diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php
index ac214b4fc64..7f4827e81b2 100644
--- a/htdocs/asset/class/asset.class.php
+++ b/htdocs/asset/class/asset.class.php
@@ -166,6 +166,7 @@ class Asset extends CommonObject
* @var AssetDepreciationOptions Used for computed fields of depreciation options class.
*/
public $asset_depreciation_options;
+ public $asset_accountancy_codes;
/**
* @var array List of depreciation lines for each mode (sort by depreciation date).
*/
diff --git a/htdocs/asset/class/assetaccountancycodes.class.php b/htdocs/asset/class/assetaccountancycodes.class.php
index 966aaa745c7..88c71d86889 100644
--- a/htdocs/asset/class/assetaccountancycodes.class.php
+++ b/htdocs/asset/class/assetaccountancycodes.class.php
@@ -47,7 +47,7 @@ class AssetAccountancyCodes extends CommonObject
'receivable_on_assignment' => array('label' => 'AssetAccountancyCodeReceivableOnAssignment'),
'proceeds_from_sales' => array('label' => 'AssetAccountancyCodeProceedsFromSales'),
'vat_collected' => array('label' => 'AssetAccountancyCodeVatCollected'),
- 'vat_deductible' => array('label' => 'AssetAccountancyCodeVatDeductible'),
+ 'vat_deductible' => array('label' => 'AssetAccountancyCodeVatDeductible','column_break' => true),
),
),
'accelerated_depreciation' => array(
diff --git a/htdocs/asset/class/assetdepreciationoptions.class.php b/htdocs/asset/class/assetdepreciationoptions.class.php
index e77d7106651..1e0fb2f4065 100644
--- a/htdocs/asset/class/assetdepreciationoptions.class.php
+++ b/htdocs/asset/class/assetdepreciationoptions.class.php
@@ -114,6 +114,12 @@ class AssetDepreciationOptions extends CommonObject
*/
public $deprecation_options = array();
+ public $depreciation_type;
+ public $degressive_coefficient;
+ public $duration;
+ public $duration_type;
+ public $accelerated_depreciation_option;
+
/**
* Constructor
*
@@ -165,12 +171,12 @@ class AssetDepreciationOptions extends CommonObject
// Unset required option (notnull) if field disabled
if (!empty($field_info['enabled_field'])) {
$info = explode(':', $field_info['enabled_field']);
- if ($this->deprecation_options[$info[0]][$info[1]] != $info[2] && isset($this->fields[$field_key]['notnull'])) {
+ if (!empty($this->deprecation_options[$info[0]][$info[1]]) && $this->deprecation_options[$info[0]][$info[1]] != $info[2] && isset($this->fields[$field_key]['notnull'])) {
unset($this->fields[$field_key]['notnull']);
}
}
// Set value of the field in the object (for createCommon and setDeprecationOptionsFromPost functions)
- $this->{$field_key} = $this->deprecation_options[$mode][$field_key];
+ $this->{$field_key} = $this->deprecation_options[$mode][$field_key] ?? null;
}
$this->fields['rowid'] = array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id");
@@ -358,7 +364,7 @@ class AssetDepreciationOptions extends CommonObject
foreach ($this->deprecation_options_fields as $mode_key => $mode_info) {
if (!empty($mode_info['enabled_field'])) {
$info = explode(':', $mode_info['enabled_field']);
- if ($deprecation_options[$info[0]][$info[1]] != $info[2]) {
+ if (isset($deprecation_options[$info[0]][$info[1]]) && $deprecation_options[$info[0]][$info[1]] != $info[2]) {
unset($deprecation_options[$info[0]][$info[1]]);
}
}
@@ -527,8 +533,8 @@ class AssetDepreciationOptions extends CommonObject
*/
public function getRate($mode)
{
- $duration = $this->deprecation_options[$mode]["duration"] > 0 ? $this->deprecation_options[$mode]["duration"] : 0;
- $duration_type = $this->deprecation_options[$mode]["duration_type"] > 0 ? $this->deprecation_options[$mode]["duration_type"] : 0;
+ $duration = (isset($this->deprecation_options[$mode]["duration"]) && $this->deprecation_options[$mode]["duration"] > 0) ? $this->deprecation_options[$mode]["duration"] : 0;
+ $duration_type = (isset($this->deprecation_options[$mode]["duration_type"]) && $this->deprecation_options[$mode]["duration_type"] > 0) ? $this->deprecation_options[$mode]["duration_type"] : 0;
return price(price2num($duration > 0 ? (100 * ($duration_type == 1 ? 12 : 1) / $duration) : 0, 2));
}
diff --git a/htdocs/asset/class/assetmodel.class.php b/htdocs/asset/class/assetmodel.class.php
index 9dfdf810fc3..17e49bf9bde 100644
--- a/htdocs/asset/class/assetmodel.class.php
+++ b/htdocs/asset/class/assetmodel.class.php
@@ -112,7 +112,7 @@ class AssetModel extends CommonObject
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',),
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
- 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'default'=>'0', 'visible'=>2, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Enabled', '9'=>'Disabled'), 'validate'=>'1',),
+ 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'default'=>'1', 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Enabled', '9'=>'Disabled'), 'validate'=>'1',),
);
public $rowid;
public $ref;
@@ -129,6 +129,7 @@ class AssetModel extends CommonObject
public $model_pdf;
public $status;
public $asset_depreciation_options;
+ public $asset_accountancy_codes;
// /**
// * @var string Field with ID of parent key if this object has a parent
@@ -194,6 +195,16 @@ class AssetModel extends CommonObject
{
$resultcreate = $this->createCommon($user, $notrigger);
+ if ($resultcreate > 0 && !empty($this->asset_depreciation_options)) {
+ $this->asset_depreciation_options->setDeprecationOptionsFromPost(1);
+ $this->asset_depreciation_options->updateDeprecationOptions($user, 0, $resultcreate);
+ }
+
+ if ($resultcreate > 0 && !empty($this->asset_accountancy_codes)) {
+ $this->asset_accountancy_codes->setAccountancyCodesFromPost();
+ $this->asset_accountancy_codes->updateAccountancyCodes($user, 0, $resultcreate);
+ }
+
return $resultcreate;
}
@@ -414,7 +425,19 @@ class AssetModel extends CommonObject
*/
public function update(User $user, $notrigger = 0)
{
- return $this->updateCommon($user, $notrigger);
+ $resultupdate = $this->updateCommon($user, $notrigger);
+
+ if ($resultupdate > 0 && !empty($this->asset_depreciation_options)) {
+ $this->asset_depreciation_options->setDeprecationOptionsFromPost(1);
+ $this->asset_depreciation_options->updateDeprecationOptions($user, 0, $resultupdate);
+ }
+
+ if ($resultupdate > 0 && !empty($this->asset_accountancy_codes)) {
+ $this->asset_accountancy_codes->setAccountancyCodesFromPost();
+ $this->asset_accountancy_codes->updateAccountancyCodes($user, 0, $resultupdate);
+ }
+
+ return $resultupdate;
}
/**
diff --git a/htdocs/asset/depreciation_options.php b/htdocs/asset/depreciation_options.php
index bc11e2196ed..0b771b216d5 100644
--- a/htdocs/asset/depreciation_options.php
+++ b/htdocs/asset/depreciation_options.php
@@ -37,6 +37,7 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
+$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); // if not set, $backtopage will be used
// Initialize technical objects
$object = new Asset($db);
@@ -50,7 +51,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) {
- $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id;
+ $upload_dir = $conf->asset->multidir_output[isset($object->entity) ? $object->entity : 1] . "/" . $object->id;
}
$permissiontoadd = $user->hasRight('asset', 'write'); // Used by the include of actions_addupdatedelete.inc.php
diff --git a/htdocs/asset/model/accountancy_codes.php b/htdocs/asset/model/accountancy_codes.php
index 7e41aaf4288..292c69defa7 100644
--- a/htdocs/asset/model/accountancy_codes.php
+++ b/htdocs/asset/model/accountancy_codes.php
@@ -50,7 +50,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) {
- $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id;
+ $upload_dir = $conf->asset->multidir_output[isset($object->entity) ? $object->entity : 1] . "/" . $object->id;
}
$permissiontoread = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('asset', 'read')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('asset', 'model_advance', 'read')));
diff --git a/htdocs/asset/model/agenda.php b/htdocs/asset/model/agenda.php
index d7faf856b9a..e0b62ecec79 100644
--- a/htdocs/asset/model/agenda.php
+++ b/htdocs/asset/model/agenda.php
@@ -79,7 +79,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) {
- $upload_dir = $conf->asset->multidir_output[$object->entity] . "/model/" . $object->id;
+ $upload_dir = $conf->asset->multidir_output[isset($object->entity) ? $object->entity : 1] . "/model/" . $object->id;
}
$permissiontoread = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('asset', 'read')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('asset', 'model_advance', 'read')));
diff --git a/htdocs/asset/model/card.php b/htdocs/asset/model/card.php
index fc461d5658d..3ab71c675c4 100644
--- a/htdocs/asset/model/card.php
+++ b/htdocs/asset/model/card.php
@@ -28,6 +28,8 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/asset.lib.php';
require_once DOL_DOCUMENT_ROOT . '/asset/class/assetmodel.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
+require_once DOL_DOCUMENT_ROOT . '/asset/class/assetdepreciationoptions.class.php';
+require_once DOL_DOCUMENT_ROOT . '/asset/class/assetaccountancycodes.class.php';
// Load translation files required by the page
$langs->loadLangs(array("assets", "other"));
@@ -44,6 +46,8 @@ $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
// Initialize technical objects
$object = new AssetModel($db);
+$assetdepreciationoptions = new AssetDepreciationOptions($db);
+$assetaccountancycodes = new AssetAccountancyCodes($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->asset->dir_output . '/temp/massgeneration/' . $user->id;
$hookmanager->initHooks(array('assetmodelcard', 'globalcard')); // Note that conf->hooks_modules contains array
@@ -92,6 +96,20 @@ if (!$permissiontoread) {
accessforbidden();
}
+// Model depreciation options and accountancy codes
+$object->asset_depreciation_options = &$assetdepreciationoptions;
+$object->asset_accountancy_codes = &$assetaccountancycodes;
+if (!empty($id)) {
+ $depreciationoptionserrors = $assetdepreciationoptions->fetchDeprecationOptions(0, $object->id);
+ $accountancycodeserrors = $assetaccountancycodes->fetchAccountancyCodes(0, $object->id);
+
+ if ($depreciationoptionserrors < 0) {
+ setEventMessages($assetdepreciationoptions->error, $assetdepreciationoptions->errors, 'errors');
+ }
+ if ($accountancycodeserrors < 0) {
+ setEventMessages($assetaccountancycodes->error, $assetaccountancycodes->errors, 'errors');
+ }
+}
/*
* Actions
@@ -173,6 +191,14 @@ if ($action == 'create') {
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php';
+ // Depreciation options
+ include DOL_DOCUMENT_ROOT . '/asset/tpl/depreciation_options_edit.tpl.php';
+
+ // Accountancy codes
+ print '
';
+ print ' ';
+ include DOL_DOCUMENT_ROOT . '/asset/tpl/accountancy_codes_edit.tpl.php';
+
print '' . "\n";
print dol_get_fiche_end();
@@ -209,6 +235,14 @@ if (($id || $ref) && $action == 'edit') {
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php';
+ // Depreciation options
+ include DOL_DOCUMENT_ROOT . '/asset/tpl/depreciation_options_edit.tpl.php';
+
+ // Accountancy codes
+ print '
';
+ print ' ';
+ include DOL_DOCUMENT_ROOT . '/asset/tpl/accountancy_codes_edit.tpl.php';
+
print '';
print dol_get_fiche_end();
@@ -262,20 +296,111 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '';
- print '
';
print '
';
print '
' . "\n";
// Common attributes
- include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
+ $object->fields = dol_sort_array($object->fields, 'position');
+
+ foreach ($object->fields as $key => $val) {
+ if (!empty($keyforbreak) && $key == $keyforbreak) {
+ break; // key used for break on second column
+ }
+
+ // Discard if extrafield is a hidden field on form
+ if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4 && abs($val['visible']) != 5) {
+ continue;
+ }
+
+ if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) {
+ continue; // We don't want this field
+ }
+ if (in_array($key, array('ref', 'status'))) {
+ continue; // Ref and status are already in dol_banner
+ }
+
+ $value = $object->$key;
+
+ print '';
+
+ $labeltoshow = '';
+ if (!empty($val['help'])) {
+ $labeltoshow .= $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
+ } else {
+ if (isset($val['copytoclipboard']) && $val['copytoclipboard'] == 1) {
+ $labeltoshow .= showValueWithClipboardCPButton($value, 0, $langs->transnoentitiesnoconv($val['label']));
+ } else {
+ $labeltoshow .= $langs->trans($val['label']);
+ }
+ }
+ if (empty($val['alwayseditable'])) {
+ print $labeltoshow;
+ } else {
+ print $form->editfieldkey($labeltoshow, $key, $value, $object, 1, $val['type']);
+ }
+
+ print ' ';
+ print '';
+ if (empty($val['alwayseditable'])) {
+ if (preg_match('/^(text|html)/', $val['type'])) {
+ print '';
+ }
+ if ($key == 'lang') {
+ $langs->load("languages");
+ $labellang = ($value ? $langs->trans('Language_'.$value) : '');
+ print picto_from_langcode($value, 'class="paddingrightonly saturatemedium opacitylow"');
+ print $labellang;
+ } else {
+ if (isset($val['copytoclipboard']) && $val['copytoclipboard'] == 2) {
+ $out = $object->showOutputField($val, $key, $value, '', '', '', 0);
+ print showValueWithClipboardCPButton($out, 0, $out);
+ } else {
+ print $object->showOutputField($val, $key, $value, '', '', '', 0);
+ }
+ }
+ //print dol_escape_htmltag($object->$key, 1, 1);
+ if (preg_match('/^(text|html)/', $val['type'])) {
+ print '
';
+ }
+ } else {
+ print $form->editfieldval($labeltoshow, $key, $value, $object, 1, $val['type']);
+ }
+ print ' ';
+ print ' ';
+ }
// Other attributes. Fields from hook formObjectOptions and Extrafields.
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
+ print '
';
+ // Depreciation options attributes
+ print '
';
+ print '
';
+ include DOL_DOCUMENT_ROOT . '/asset/tpl/depreciation_options_view.tpl.php';
print '
';
print '
';
+
+ // Accountancy codes attributes
+ print '
';
+ print '
';
+ include DOL_DOCUMENT_ROOT . '/asset/tpl/accountancy_codes_view.tpl.php';
+ print '
';
print '
';
+ print '
';
print '
';
print dol_get_fiche_end();
diff --git a/htdocs/asset/model/depreciation_options.php b/htdocs/asset/model/depreciation_options.php
index 89b85be1f04..0000f2bf723 100644
--- a/htdocs/asset/model/depreciation_options.php
+++ b/htdocs/asset/model/depreciation_options.php
@@ -37,6 +37,7 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
+$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
// Initialize technical objects
$object = new AssetModel($db);
@@ -50,7 +51,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) {
- $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id;
+ $upload_dir = $conf->asset->multidir_output[isset($object->entity) ? $object->entity : 1] . "/" . $object->id;
}
$permissiontoread = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('asset', 'read')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('asset', 'model_advance', 'read')));
diff --git a/htdocs/asset/model/note.php b/htdocs/asset/model/note.php
index 984b3fb867b..0476b6f4a57 100644
--- a/htdocs/asset/model/note.php
+++ b/htdocs/asset/model/note.php
@@ -48,7 +48,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) {
- $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id;
+ $upload_dir = $conf->asset->multidir_output[isset($object->entity) ? $object->entity : 1] . "/" . $object->id;
}
$permissiontoread = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('asset', 'read')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('asset', 'model_advance', 'read')));
diff --git a/htdocs/asset/tpl/accountancy_codes_edit.tpl.php b/htdocs/asset/tpl/accountancy_codes_edit.tpl.php
index fa01cbd59bc..93a261c442a 100644
--- a/htdocs/asset/tpl/accountancy_codes_edit.tpl.php
+++ b/htdocs/asset/tpl/accountancy_codes_edit.tpl.php
@@ -34,6 +34,7 @@ if (!is_object($form)) {
$form = new Form($db);
}
+global $formaccounting;
if (isModEnabled('accounting') && !is_object($formaccounting)) {
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
$formaccounting = new FormAccounting($db);
@@ -57,25 +58,24 @@ if ($reshook < 0) {
if (empty($reshook)) {
foreach ($assetaccountancycodes->accountancy_codes_fields as $mode_key => $mode_info) {
//if (empty($object->enabled_modes[$mode_key])) continue;
-
- print load_fiche_titre($langs->trans($mode_info['label']), '', '');
- print '
';
- print '
';
- print '
';
+ $width = ($mode_key == "economic")? "width50p pull-left" : "width50p";
+ print '';
+ print ''.$langs->trans($mode_info['label']).' ';
foreach ($mode_info['fields'] as $field_key => $field_info) {
$html_name = $mode_key . '_' . $field_key;
- print '' . $langs->trans($field_info['label']) . ' ';
+ print ' ' . $langs->trans($field_info['label']) . ' ';
$accountancy_code = GETPOSTISSET($html_name) ? GETPOST($html_name, 'aZ09') : (!empty($assetaccountancycodes->accountancy_codes[$mode_key][$field_key]) ? $assetaccountancycodes->accountancy_codes[$mode_key][$field_key] : '');
if (isModEnabled('accounting')) {
- print $formaccounting->select_account($accountancy_code, $html_name, 1, null, 1, 1, 'minwidth150 maxwidth300', 1);
+ print $formaccounting->select_account($accountancy_code, $html_name, 1, null, 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 1);
} else {
- print ' ';
+ print ' ';
}
print ' ';
}
print '
';
- print '';
}
+
+ print '
';
}
?>
diff --git a/htdocs/asset/tpl/accountancy_codes_view.tpl.php b/htdocs/asset/tpl/accountancy_codes_view.tpl.php
index 46c04bbb0ef..61954bfc936 100644
--- a/htdocs/asset/tpl/accountancy_codes_view.tpl.php
+++ b/htdocs/asset/tpl/accountancy_codes_view.tpl.php
@@ -55,14 +55,15 @@ if (empty($reshook)) {
}
foreach ($assetaccountancycodes->accountancy_codes_fields as $mode_key => $mode_info) {
- //if (empty($object->enabled_modes[$mode_key])) continue;
-
- print load_fiche_titre($langs->trans($mode_info['label']), '', '');
- print '';
- print '
';
- print '
';
+ if (empty($assetdepreciationoptions->deprecation_options[$mode_key]) && $mode_key == "accelerated_depreciation") {
+ continue;
+ }
+ $width = ($mode_key == "economic")? "pull-left" : "pull-left";
+ print '' . "\n";
+ print ''.$langs->trans($mode_info['label']).' ';
foreach ($mode_info['fields'] as $field_key => $field_info) {
- print '' . $langs->trans($field_info['label']) . ' ';
+ $key = $mode_key . '_' . $field_key;
+ print ' ' . $langs->trans($field_info['label']) . ' ';
if (!empty($assetaccountancycodes->accountancy_codes[$mode_key][$field_key])) {
$accountancy_code = $assetaccountancycodes->accountancy_codes[$mode_key][$field_key];
if (isModEnabled('accounting')) {
@@ -77,8 +78,10 @@ if (empty($reshook)) {
print ' ';
}
print '
';
- print '';
+ print '
';
+ print ' ';
}
+ print '
';
}
?>
diff --git a/htdocs/asset/tpl/depreciation_options_edit.tpl.php b/htdocs/asset/tpl/depreciation_options_edit.tpl.php
index 60e8f0fef14..649a00e0797 100644
--- a/htdocs/asset/tpl/depreciation_options_edit.tpl.php
+++ b/htdocs/asset/tpl/depreciation_options_edit.tpl.php
@@ -34,7 +34,7 @@ if (!is_object($form)) {
$form = new Form($db);
}
-if (!is_object($formadmin)) {
+if (!isset($formadmin) || !is_object($formadmin)) {
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formadmin.class.php';
$formadmin = new FormAdmin($db);
}
@@ -75,13 +75,12 @@ if (empty($reshook)) {
$assetdepreciationoptions->setInfosForMode($mode_key, $class_type, true);
$prefix_html_name = $mode_key . '_';
-
- print '';
- print load_fiche_titre($langs->trans($mode_info['label']), '', '');
- print '
';
- print '
';
- print '
';
- print '
' . "\n";
+ $width = ($mode_key == "economic")? "width50p pull-left" : "width50p";
+ print '' . "\n";
+ print ''.$langs->trans($mode_info['label']).' ';
+ if ($mode_key == "economic") {
+ print ' ';
+ }
$mode_info['fields'] = dol_sort_array($mode_info['fields'], 'position');
foreach ($mode_info['fields'] as $field_key => $field_info) {
// Discard if extrafield is a hidden field on form
@@ -91,16 +90,7 @@ if (empty($reshook)) {
if (array_key_exists('enabled', $field_info) && isset($field_info['enabled']) && !verifCond($field_info['enabled'])) {
continue; // We don't want this field
}
- if (!empty($field_info['column_break'])) {
- print '
';
- // We close div and reopen for second column
- print '';
- print '';
-
- print '
';
- print '
';
- }
$html_name = $prefix_html_name . $field_key;
if (!empty($field_info['enabled_field'])) {
@@ -114,15 +104,15 @@ if (empty($reshook)) {
}
$more_class = '';
- if (!empty($field_info['required']) || (isset($field_info['notnull']) && $field_info['notnull'] > 0)) {
- $more_class .= ' fieldrequired';
+ if (!empty($field_info['required'])) {
+ $more_class .= 'width40p fieldrequired';
}
- if (preg_match('/^(text|html)/', $val['type'])) {
+ if (isset($val['type']) && preg_match('/^(text|html)/', $val['type'])) {
$more_class .= ' tdtop';
}
print '';
+ print ' class="' . $more_class . '">';
if (!empty($field_info['help'])) {
print $form->textwithpicto($langs->trans($field_info['label']), $langs->trans($field_info['help']));
} else {
@@ -166,11 +156,8 @@ if (empty($reshook)) {
print ' ';
}
print '
';
- print '
';
- print '';
- print '
';
- print '';
}
+ print '
';
}
if (!empty($enabled_field_info)) {
@@ -200,7 +187,7 @@ if (!empty($enabled_field_info)) {
var target_name = _this.attr('data-asset-enabled-field-target');
// for block mode
- var target = $('div#' + target_name);
+ var target = $('table#' + target_name);
// for field
if (!(target.length > 0)) {
diff --git a/htdocs/asset/tpl/depreciation_options_view.tpl.php b/htdocs/asset/tpl/depreciation_options_view.tpl.php
index 2660fbbaee7..a98171ed1ea 100644
--- a/htdocs/asset/tpl/depreciation_options_view.tpl.php
+++ b/htdocs/asset/tpl/depreciation_options_view.tpl.php
@@ -53,26 +53,25 @@ if ($reshook < 0) {
if (empty($reshook)) {
$class_type = get_class($object) == 'Asset' ? 0 : 1;
+ print ' ';
foreach ($assetdepreciationoptions->deprecation_options_fields as $mode_key => $mode_info) {
if (!empty($mode_info['enabled_field'])) {
$info = explode(':', $mode_info['enabled_field']);
- if ($assetdepreciationoptions->deprecation_options[$info[0]][$info[1]] != $info[2]) {
+ if (empty($assetdepreciationoptions->deprecation_options[$info[0]][$info[1]]) || $assetdepreciationoptions->deprecation_options[$info[0]][$info[1]] != $info[2]) {
continue;
}
}
$assetdepreciationoptions->setInfosForMode($mode_key, $class_type, true);
- print load_fiche_titre($langs->trans($mode_info['label']), '', '');
- print '';
- print '
';
- print '
';
- print '
' . "\n";
+ $width = ($mode_key == "economic")? "pull-left" : "pull-left";
+ print '' . "\n";
+ print ''.$langs->trans($mode_info['label']).' ';
$mode_info['fields'] = dol_sort_array($mode_info['fields'], 'position');
foreach ($mode_info['fields'] as $field_key => $field_info) {
if (!empty($field_info['enabled_field'])) {
$info = explode(':', $field_info['enabled_field']);
- if ($assetdepreciationoptions->deprecation_options[$info[0]][$info[1]] != $info[2]) {
+ if (empty($assetdepreciationoptions->deprecation_options[$info[0]][$info[1]]) || $assetdepreciationoptions->deprecation_options[$info[0]][$info[1]] != $info[2]) {
continue;
}
}
@@ -83,22 +82,11 @@ if (empty($reshook)) {
if (array_key_exists('enabled', $field_info) && isset($field_info['enabled']) && !verifCond($field_info['enabled'])) {
continue; // We don't want this field
}
- if (!empty($field_info['column_break'])) {
- print '
';
-
- // We close div and reopen for second column
- print '';
- print '';
-
- print '
';
- print '
';
- }
-
$key = $mode_key . '_' . $field_key;
- $value = $assetdepreciationoptions->deprecation_options[$mode_key][$field_key];
+ $value = $assetdepreciationoptions->deprecation_options[$mode_key][$field_key] ?? null;
- print '';
+ print ' ';
}
}
diff --git a/htdocs/core/lib/asset.lib.php b/htdocs/core/lib/asset.lib.php
index 455230cdb65..0a8e06eb1bf 100644
--- a/htdocs/core/lib/asset.lib.php
+++ b/htdocs/core/lib/asset.lib.php
@@ -194,16 +194,6 @@ function assetModelPrepareHead($object)
$head[$h][2] = 'card';
$h++;
- $head[$h][0] = DOL_URL_ROOT . '/asset/model/depreciation_options.php?id=' . $object->id;
- $head[$h][1] = $langs->trans("AssetDepreciationOptions");
- $head[$h][2] = 'depreciation_options';
- $h++;
-
- $head[$h][0] = DOL_URL_ROOT . '/asset/model/accountancy_codes.php?id=' . $object->id;
- $head[$h][1] = $langs->trans("AssetAccountancyCodes");
- $head[$h][2] = 'accountancy_codes';
- $h++;
-
if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
$nbNote = 0;
if (!empty($object->note_private)) {