diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php index 9fbcca64d8b..51ea3a0c799 100644 --- a/htdocs/asset/class/asset_type.class.php +++ b/htdocs/asset/class/asset_type.class.php @@ -73,14 +73,23 @@ class AssetType extends CommonObject $error=0; $this->label=trim($this->label); + $this->accountancy_code_asset = trim($this->accountancy_code_asset); + $this->accountancy_code_depreciation_asset = trim($this->accountancy_code_depreciation_asset); + $this->accountancy_code_depreciation_expense = trim($this->accountancy_code_depreciation_expense); $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."asset_type ("; $sql.= "label"; + $sql.= ", accountancy_code_asset"; + $sql.= ", accountancy_code_depreciation_asset"; + $sql.= ", accountancy_code_depreciation_expense"; $sql.= ", entity"; $sql.= ") VALUES ("; $sql.= "'".$this->db->escape($this->label)."'"; + $sql.= ", '".$this->db->escape($this->accountancy_code_asset)."'"; + $sql.= ", '".$this->db->escape($this->accountancy_code_depreciation_asset)."'"; + $sql.= ", '".$this->db->escape($this->accountancy_code_depreciation_expense)."'"; $sql.= ", ".$conf->entity; $sql.= ")"; @@ -411,4 +420,14 @@ class AssetType extends CommonObject ); } + /** + * getLibStatut + * + * @return string Return status of a type of asset + */ + function getLibStatut() + { + return ''; + } + } diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index d26175d168f..64800488cb6 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -26,6 +26,9 @@ 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/asset_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; $langs->load("assets"); @@ -232,8 +235,9 @@ if (! $rowid && $action != 'create' && $action != 'edit') print ''; print ''.$langs->trans("Ref").''; print ''.$langs->trans("Label").''; - print ''.$langs->trans("SubscriptionRequired").''; - print ''.$langs->trans("VoteAllowed").''; + print ''.$langs->trans("AccountancyCodeAsset").''; + print ''.$langs->trans("AccountancyCodeDepreciationAsset").''; + print ''.$langs->trans("AccountancyCodeDepreciationExpense").''; print ' '; print "\n"; @@ -253,9 +257,44 @@ if (! $rowid && $action != 'create' && $action != 'edit') //'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.' print ''; print ''.dol_escape_htmltag($objp->label).''; - print ''.yn($objp->subscription).''; - print ''.yn($objp->vote).''; - if ($user->rights->asset->configurer) + + print ''; + if (! empty($conf->accounting->enabled)) + { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch('',$object->accountancy_code_asset,1); + + print $accountingaccount->getNomUrl(0,1,1,'',1); + } else { + print $object->accountancy_code_asset; + } + print ''; + + print ''; + if (! empty($conf->accounting->enabled)) + { + $accountingaccount2 = new AccountingAccount($db); + $accountingaccount2->fetch('',$object->accountancy_code_depreciation_asset,1); + + print $accountingaccount2->getNomUrl(0,1,1,'',1); + } else { + print $object->accountancy_code_depreciation_asset; + } + print ''; + + print ''; + if (! empty($conf->accounting->enabled)) + { + $accountingaccount3 = new AccountingAccount($db); + $accountingaccount3->fetch('',$object->accountancy_code_depreciation_expense,1); + + print $accountingaccount3->getNomUrl(0,1,1,'',1); + } else { + print $object->accountancy_code_depreciation_expense; + } + print ''; + + if ($user->rights->asset->write) print 'rowid.'">'.img_edit().''; else print ' '; @@ -282,8 +321,9 @@ if (! $rowid && $action != 'create' && $action != 'edit') if ($action == 'create') { $object = new AssetType($db); + if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); - print load_fiche_titre($langs->trans("NewMemberType")); + print load_fiche_titre($langs->trans("NewAssetType")); print '
'; print ''; @@ -296,23 +336,48 @@ if ($action == 'create') print ''.$langs->trans("Label").''; - print ''.$langs->trans("SubscriptionRequired").''; - print $form->selectyesno("subscription",1,1); - print ''; + if (! empty($conf->accounting->enabled)) + { + // Accountancy_code_asset + print ''.$langs->trans("AccountancyCodeAsset").''; + print ''; + print $formaccounting->select_account($object->accountancy_code_asset, 'accountancy_code_asset', 1, '', 1, 1); + print ''; - print ''.$langs->trans("VoteAllowed").''; - print $form->selectyesno("vote",0,1); - print ''; + // Accountancy_code_depreciation_expense + print ''.$langs->trans("AccountancyCodeDepreciationAsset").''; + print ''; + print $formaccounting->select_account($object->accountancy_code_depreciation_asset, 'accountancy_code_depreciation_asset', 1, '', 1, 1); + print ''; + + // Accountancy_code_depreciation_expense + print ''.$langs->trans("AccountancyCodeDepreciationExpense").''; + print ''; + print $formaccounting->select_account($object->accountancy_code_depreciation_expense, 'accountancy_code_depreciation_expense', 1, '', 1, 1); + print ''; + + } + else // For external software + { + // Accountancy_code_asset + print ''.$langs->trans("AccountancyCodeAsset").''; + print ''; + print ''; + + // Accountancy_code_depreciation_asset + print ''.$langs->trans("AccountancyCodeDepreciationAsset").''; + print ''; + print ''; + + // Accountancy_code_depreciation_expense + print ''.$langs->trans("AccountancyCodeDepreciationExpense").''; + print ''; + print ''; + } print ''.$langs->trans("Description").''; print ''; - print ''.$langs->trans("WelcomeEMail").''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('mail_valid',$object->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,'90%'); - $doleditor->Create(); - print ''; - // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook @@ -356,9 +421,9 @@ if ($rowid > 0) print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id,$langs->trans("DeleteAMemberType"),$langs->trans("ConfirmDeleteMemberType",$object->label),"confirm_delete", '',0,1); } - $head = member_type_prepare_head($object); + $head = asset_type_prepare_head($object); - dol_fiche_head($head, 'card', $langs->trans("MemberType"), -1, 'group'); + dol_fiche_head($head, 'card', $langs->trans("AssetType"), -1, 'setup'); $linkback = ''.$langs->trans("BackToList").''; @@ -369,20 +434,45 @@ if ($rowid > 0) print ''; - print ''; + if (! empty($conf->accounting->enabled)) + { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch('',$object->accountancy_code_asset,1); - print ''; + + print ''; + + print ''; print '"; - print '"; - // Other attributes include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; @@ -612,35 +702,6 @@ if ($rowid > 0) print $adh->LibStatut($objp->statut,$objp->subscription,$datefin,2); print ""; - // Date end subscription - if ($datefin) - { - print ''; - } - else - { - print ''; - } - // Actions print '
'.$langs->trans("SubscriptionRequired").''; - print yn($object->subscription); print '
'.$langs->trans("VoteAllowed").''; - print yn($object->vote); + print $accountingaccount->getNomUrl(0,1,1,'',1); + } else { + print $object->accountancy_code_asset; + } + print ''; + if (! empty($conf->accounting->enabled)) + { + $accountingaccount2 = new AccountingAccount($db); + $accountingaccount2->fetch('',$object->accountancy_code_depreciation_asset,1); + + print $accountingaccount2->getNomUrl(0,1,1,'',1); + } else { + print $object->accountancy_code_depreciation_asset; + } + print ''; + if (! empty($conf->accounting->enabled)) + { + $accountingaccount3 = new AccountingAccount($db); + $accountingaccount3->fetch('',$object->accountancy_code_depreciation_expense,1); + + print $accountingaccount3->getNomUrl(0,1,1,'',1); + } else { + print $object->accountancy_code_depreciation_expense; + } print '
'.$langs->trans("Description").''; print nl2br($object->note)."
'.$langs->trans("WelcomeEMail").''; - print nl2br($object->mail_valid)."
'; - if ($datefin < dol_now() && $objp->statut > 0) - { - print dol_print_date($datefin,'day')." ".img_warning($langs->trans("SubscriptionLate")); - } - else - { - print dol_print_date($datefin,'day'); - } - print ''; - if ($objp->subscription == 'yes') - { - print $langs->trans("SubscriptionNotReceived"); - if ($objp->statut > 0) print " ".img_warning(); - } - else - { - print ' '; - } - print ''; if ($user->rights->asset->creer) @@ -685,15 +746,16 @@ if ($rowid > 0) $object = new AssetType($db); $object->fetch($rowid); $object->fetch_optionals(); + if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); - $head = member_type_prepare_head($object); + $head = asset_type_prepare_head($object); print ''; print ''; print ''; print ''; - dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group'); + dol_fiche_head($head, 'card', $langs->trans("AssetsType"), -1, 'setup'); print ''; @@ -701,23 +763,48 @@ if ($rowid > 0) print ''; - print ''; + if (! empty($conf->accounting->enabled)) + { + // Accountancy_code_asset + print ''; + print ''; - print ''; + // Accountancy_code_depreciation_expense + print ''; + print ''; + + // Accountancy_code_depreciation_expense + print ''; + print ''; + + } + else // For external software + { + // Accountancy_code_asset + print ''; + print ''; + + // Accountancy_code_depreciation_asset + print ''; + print ''; + + // Accountancy_code_depreciation_expense + print ''; + print ''; + } print ''; - print '"; - // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/core/lib/asset.lib.php b/htdocs/core/lib/asset.lib.php index 460d368f2c4..5953c8b9420 100644 --- a/htdocs/core/lib/asset.lib.php +++ b/htdocs/core/lib/asset.lib.php @@ -118,3 +118,32 @@ function AssetsPrepareHead() return $head; } + +/** + * Return array head with list of tabs to view object informations + * + * @param AssetType $object Asset + * @return array head + */ +function asset_type_prepare_head(AssetType $object) +{ + global $langs, $conf, $user; + + $h=0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/asset/type.php?rowid='.$object->id; + $head[$h][1] = $langs->trans("Card"); + $head[$h][2] = 'card'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab + complete_head_from_modules($conf,$langs,$object,$head,$h,'assettype'); + + complete_head_from_modules($conf,$langs,$object,$head,$h,'assettype','remove'); + + return $head; +} diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 4d3951f7b5e..69db8554729 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1143,11 +1143,11 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu { $langs->load("assets"); $newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy",$langs->trans("MenuAssets"), 0, $user->rights->asset->read, '', $mainmenu, 'asset'); - $newmenu->add("/asset/card.php?leftmenu=asset&action=create",$langs->trans("MenuNewAsset"), 1, $user->rights->asset->write); - $newmenu->add("/asset/type.php?leftmenu=asset",$langs->trans("MenuTypeAssets"), 1, $user->rights->asset->read, '', $mainmenu, 'asset_type'); - $newmenu->add("/asset/type.php?leftmenu=asset_type&action=create",$langs->trans("MenuNewTypeAssets"), 1, $user->rights->asset->write); - $newmenu->add("/asset/type.php?leftmenu=asset_type",$langs->trans("MenuListTypeAssets"), 1, $user->rights->asset->read); - $newmenu->add("/asset/list.php?leftmenu=asset",$langs->trans("MenuListAssets"), 1, $user->rights->asset->read); + $newmenu->add("/asset/card.php?action=create",$langs->trans("MenuNewAsset"), 1, $user->rights->asset->write); + $newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy",$langs->trans("MenuListAssets"), 1, $user->rights->asset->read); + $newmenu->add("/asset/type.php?leftmenu=asset_type",$langs->trans("MenuTypeAssets"), 1, $user->rights->asset->read, '', $mainmenu, 'asset_type'); + if ($usemenuhider || empty($leftmenu) || preg_match('/asset_type/',$leftmenu)) $newmenu->add("/asset/type.php?leftmenu=asset_type&action=create",$langs->trans("MenuNewTypeAssets"), 2, $user->rights->asset->write); + if ($usemenuhider || empty($leftmenu) || preg_match('/asset_type/',$leftmenu)) $newmenu->add("/asset/type.php?leftmenu=asset_type",$langs->trans("MenuListTypeAssets"), 2, $user->rights->asset->read); } } diff --git a/htdocs/langs/en_US/assets.lang b/htdocs/langs/en_US/assets.lang index cd310e48333..db865ff3f87 100644 --- a/htdocs/langs/en_US/assets.lang +++ b/htdocs/langs/en_US/assets.lang @@ -18,9 +18,10 @@ # Assets = Assets NewAsset = New asset -AccountancyAccountAsset = Accounting code (asset) -AccountancyAccountDepreciationAsset = Accounting code (depreciation asset account) -AccountancyAccountDepreciationExpense = Accounting code (depreciation expense account) +AccountancyCodeAsset = Accounting code (asset) +AccountancyCodeDepreciationAsset = Accounting code (depreciation asset account) +AccountancyCodeDepreciationExpense = Accounting code (depreciation expense account) +NewAssetType=New asset type # Module label 'ModuleAssetsName' ModuleAssetsName = Assets @@ -44,5 +45,7 @@ AssetsTypes=Assets types # MenuAssets = Assets MenuNewAsset = New asset -MenuTypeAssets = Type +MenuTypeAssets = Type assets MenuListAssets = List +MenuNewTypeAssets = New type +MenuListTypeAssets = List
'.$langs->trans("Label").'
'.$langs->trans("SubscriptionRequired").''; - print $form->selectyesno("subscription",$object->subscription,1); - print '
'.$langs->trans("AccountancyCodeAsset").''; + print $formaccounting->select_account($object->accountancy_code_asset, 'accountancy_code_asset', 1, '', 1, 1); + print '
'.$langs->trans("VoteAllowed").''; - print $form->selectyesno("vote",$object->vote,1); - print '
'.$langs->trans("AccountancyCodeDepreciationAsset").''; + print $formaccounting->select_account($object->accountancy_code_depreciation_asset, 'accountancy_code_depreciation_asset', 1, '', 1, 1); + print '
'.$langs->trans("AccountancyCodeDepreciationExpense").''; + print $formaccounting->select_account($object->accountancy_code_depreciation_expense, 'accountancy_code_depreciation_expense', 1, '', 1, 1); + print '
'.$langs->trans("AccountancyCodeAsset").''; + print '
'.$langs->trans("AccountancyCodeDepreciationAsset").''; + print '
'.$langs->trans("AccountancyCodeDepreciationExpense").''; + print '
'.$langs->trans("Description").''; print '
'.$langs->trans("WelcomeEMail").''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('mail_valid',$object->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,'90%'); - $doleditor->Create(); - print "