26require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT .
'/core/lib/asset.lib.php';
28require_once DOL_DOCUMENT_ROOT .
'/asset/class/asset.class.php';
29require_once DOL_DOCUMENT_ROOT .
'/asset/class/assetdepreciationoptions.class.php';
32$langs->loadLangs(array(
"assets",
"companies"));
37$action =
GETPOST(
'action',
'aZ09');
38$cancel =
GETPOST(
'cancel',
'aZ09');
39$backtopage =
GETPOST(
'backtopage',
'alpha');
42$object =
new Asset($db);
45$diroutputmassaction = $conf->asset->dir_output.
'/temp/massgeneration/'.$user->id;
46$hookmanager->initHooks(array(
'assetdepreciation',
'globalcard'));
48$extrafields->fetch_name_optionals_label($object->table_element);
51include DOL_DOCUMENT_ROOT .
'/core/actions_fetchobject.inc.php';
52if ($id > 0 || !empty($ref)) {
53 $upload_dir = $conf->asset->multidir_output[$object->entity] .
"/" . $object->id;
58$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
59restrictedArea($user, $object->element, $object->id, $object->table_element,
'',
'fk_soc',
'rowid', $isdraft);
63$object->asset_depreciation_options = &$assetdepreciationoptions;
64$result = $assetdepreciationoptions->fetchDeprecationOptions($object->id);
66 setEventMessages($assetdepreciationoptions->error, $assetdepreciationoptions->errors,
'errors');
68$result = $object->fetchDepreciationLines();
79$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
94llxHeader(
'', $langs->trans(
'Asset'), $help_url);
96if ($id > 0 || !empty($ref)) {
98 print
dol_get_fiche_head($head,
'depreciation', $langs->trans(
"Asset"), -1, $object->picto);
102 $linkback =
'<a href="' . DOL_URL_ROOT .
'/asset/list.php?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
"BackToList") .
'</a>';
104 $morehtmlref =
'<div class="refidno">';
105 $morehtmlref .=
'</div>';
107 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
109 print
'<div class="fichecenter">';
110 print
'<div class="underbanner clearboth"></div>';
115 $parameters = array();
116 $reshook = $hookmanager->executeHooks(
'listAssetDeprecation', $parameters, $object, $action);
117 print $hookmanager->resPrint;
120 } elseif (empty($reshook)) {
121 $bookkeeping_icon =
'<i class="fas fa-save" title="'.$langs->trans(
'AssetDispatchedInBookkeeping').
'"></i>';
122 $future_icon =
'<i class="fas fa-clock" title="'.$langs->trans(
'AssetFutureDepreciationLine').
'"></i>';
125 foreach ($assetdepreciationoptions->deprecation_options_fields as $mode_key => $fields) {
126 $lines = $object->depreciation_lines[$mode_key];
127 if (!empty($lines)) {
128 $mode_info = $assetdepreciationoptions->deprecation_options_fields[$mode_key];
129 $depreciation_info = $assetdepreciationoptions->getGeneralDepreciationInfoForMode($mode_key);
135 print
'<div class="fichecenter">';
136 print
'<div class="fichehalfleft">';
137 print
'<div class="underbanner clearboth"></div>';
138 print
'<table class="border centpercent tableforfield">' .
"\n";
139 print
'<tr><td class="titlefield">' . $langs->trans(
'AssetBaseDepreciationHT') .
'</td><td>' .
price($depreciation_info[
'base_depreciation_ht']) .
'</td></tr>';
140 print
'<tr><td class="titlefield">' . $langs->trans(
'AssetDepreciationBeginDate') .
'</td><td>' .
dol_print_date($object->date_start > $object->date_acquisition ? $object->date_start : $object->date_acquisition,
'day') .
'</td></tr>';
145 print
'<div class="fichehalfright">';
147 print
'<div class="underbanner clearboth"></div>';
148 print
'<table class="border centpercent tableforfield">';
149 print
'<tr><td class="titlefield">' . $langs->trans(
'AssetDepreciationDuration') .
'</td><td>' . $depreciation_info[
'duration'] .
' ( ' . $depreciation_info[
'duration_type'] .
' )</td></tr>';
150 print
'<tr><td class="titlefield">' . $langs->trans(
'AssetDepreciationRate') .
'</td><td>' . $depreciation_info[
'rate'] .
'</td></tr>';
154 print
'<div class="clearboth"></div>';
159 print
'<div class="div-table-responsive-no-min">';
160 print
'<table class="noborder allwidth">';
162 print
'<tr class="liste_titre">';
163 print
'<td class="width20"></td>';
164 print
'<td>' . $langs->trans(
"Ref") .
'</td>';
165 print
'<td class="center">' . $langs->trans(
"AssetDepreciationDate") .
'</td>';
166 print
'<td class="right">' . $langs->trans(
"AssetDepreciationHT") .
'</td>';
167 print
'<td class="right">' . $langs->trans(
"AssetCumulativeDepreciationHT") .
'</td>';
168 print
'<td class="right">' . $langs->trans(
"AssetResidualHT") .
'</td>';
172 print
'<tr><td class="impair center" colspan="6"><span class="opacitymedium">' . $langs->trans(
"None") .
'</span></td></tr>';
174 foreach ($lines as $line) {
175 print
'<tr class="oddeven">';
176 print
'<td>' . ($line[
'bookkeeping'] ? $bookkeeping_icon : ($line[
'depreciation_date'] > $now ? $future_icon :
'')) .
'</td>';
177 print
'<td >' . (empty($line[
'ref']) ? $langs->trans(
'AssetDepreciationReversal') : $line[
'ref']) .
'</td>';
178 print
'<td class="center">' .
dol_print_date($line[
'depreciation_date'],
'day') .
'</td>';
179 print
'<td class="right">';
180 print
price($line[
'depreciation_ht']);
182 print
'<td class="right">';
183 print
price($line[
'cumulative_depreciation_ht']);
185 print
'<td class="right">';
186 print
price(
price2num($depreciation_info[
'base_depreciation_ht'] - $line[
'cumulative_depreciation_ht'],
'MT'));
assetPrepareHead(Asset $object)
Prepare array of tabs for Asset.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class for AssetDepreciationOptions.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
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.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.