27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT .
'/core/lib/asset.lib.php';
29require_once DOL_DOCUMENT_ROOT .
'/asset/class/asset.class.php';
30require_once DOL_DOCUMENT_ROOT .
'/asset/class/assetdepreciationoptions.class.php';
33$langs->loadLangs(array(
"assets",
"companies"));
38$action =
GETPOST(
'action',
'aZ09');
39$cancel =
GETPOST(
'cancel',
'aZ09');
40$backtopage =
GETPOST(
'backtopage',
'alpha');
46$diroutputmassaction = $conf->asset->dir_output.
'/temp/massgeneration/'.$user->id;
47$hookmanager->initHooks(array(
'assetdepreciation',
'globalcard'));
49$extrafields->fetch_name_optionals_label(
$object->table_element);
52include DOL_DOCUMENT_ROOT .
'/core/actions_fetchobject.inc.php';
53if ($id > 0 || !empty($ref)) {
54 $upload_dir = $conf->asset->multidir_output[
$object->entity] .
"/" .
$object->id;
58if ($user->socid > 0) {
61$isdraft = ((
$object->status == $object::STATUS_DRAFT) ? 1 : 0);
63if (!isModEnabled(
'asset')) {
66if (!empty(
$object->not_depreciated)) {
70$object->asset_depreciation_options = &$assetdepreciationoptions;
71$result = $assetdepreciationoptions->fetchDeprecationOptions(
$object->id);
73 setEventMessages($assetdepreciationoptions->error, $assetdepreciationoptions->errors,
'errors');
75$result =
$object->fetchDepreciationLines();
86$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
101llxHeader(
'', $langs->trans(
'Asset'), $help_url,
'', 0, 0,
'',
'',
'',
'mod-asset page-card_depreciation');
103if ($id > 0 || !empty($ref)) {
109 $linkback =
'<a href="' . DOL_URL_ROOT .
'/asset/list.php?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
"BackToList") .
'</a>';
111 $morehtmlref =
'<div class="refidno">';
112 $morehtmlref .=
'</div>';
114 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
116 print
'<div class="fichecenter">';
117 print
'<div class="underbanner clearboth"></div>';
122 $parameters = array();
123 $reshook = $hookmanager->executeHooks(
'listAssetDeprecation', $parameters, $object, $action);
124 print $hookmanager->resPrint;
127 } elseif (empty($reshook)) {
128 $bookkeeping_icon =
'<i class="fas fa-save" title="'.$langs->trans(
'AssetDispatchedInBookkeeping').
'"></i>';
129 $future_icon =
'<i class="fas fa-clock" title="'.$langs->trans(
'AssetFutureDepreciationLine').
'"></i>';
132 foreach ($assetdepreciationoptions->deprecation_options_fields as $mode_key => $fields) {
133 $lines =
$object->depreciation_lines[$mode_key];
134 if (!empty($lines)) {
135 $mode_info = $assetdepreciationoptions->deprecation_options_fields[$mode_key];
136 $depreciation_info = $assetdepreciationoptions->getGeneralDepreciationInfoForMode($mode_key);
142 print
'<div class="fichecenter">';
143 print
'<div class="fichehalfleft">';
144 print
'<div class="underbanner clearboth"></div>';
145 print
'<table class="border centpercent tableforfield">' .
"\n";
146 print
'<tr><td class="titlefield">' . $langs->trans(
'AssetBaseDepreciationHT') .
'</td><td>' .
price($depreciation_info[
'base_depreciation_ht']) .
'</td></tr>';
147 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>';
152 print
'<div class="fichehalfright">';
154 print
'<div class="underbanner clearboth"></div>';
155 print
'<table class="border centpercent tableforfield">';
156 print
'<tr><td class="titlefield">' . $langs->trans(
'AssetDepreciationDuration') .
'</td><td>' . $depreciation_info[
'duration'] .
' ( ' . $depreciation_info[
'duration_type'] .
' )</td></tr>';
157 print
'<tr><td class="titlefield">' . $langs->trans(
'AssetDepreciationRate') .
'</td><td>' . $depreciation_info[
'rate'] .
'</td></tr>';
161 print
'<div class="clearboth"></div>';
166 print
'<div class="div-table-responsive-no-min">';
167 print
'<table class="noborder allwidth">';
169 print
'<tr class="liste_titre">';
170 print
'<td class="width20"></td>';
171 print
'<td>' . $langs->trans(
"Ref") .
'</td>';
172 print
'<td class="center">' . $langs->trans(
"AssetDepreciationDate") .
'</td>';
173 print
'<td class="right">' . $langs->trans(
"AssetDepreciationHT") .
'</td>';
174 print
'<td class="right">' . $langs->trans(
"AssetCumulativeDepreciationHT") .
'</td>';
175 print
'<td class="right">' . $langs->trans(
"AssetResidualHT") .
'</td>';
179 print
'<tr><td class="impair center" colspan="6"><span class="opacitymedium">' . $langs->trans(
"None") .
'</span></td></tr>';
181 foreach ($lines as $line) {
182 print
'<tr class="oddeven">';
183 print
'<td>' . ($line[
'bookkeeping'] ? $bookkeeping_icon : ($line[
'depreciation_date'] > $now ? $future_icon :
'')) .
'</td>';
184 print
'<td >' . (empty($line[
'ref']) ? $langs->trans(
'AssetDepreciationReversal') : $line[
'ref']) .
'</td>';
185 print
'<td class="center">' .
dol_print_date($line[
'depreciation_date'],
'day') .
'</td>';
186 print
'<td class="right">';
187 print
price($line[
'depreciation_ht']);
189 print
'<td class="right">';
190 print
price($line[
'cumulative_depreciation_ht']);
192 print
'<td class="right">';
193 print
price(
price2num((
float) $depreciation_info[
'base_depreciation_ht'] - (
float) $line[
'cumulative_depreciation_ht'],
'MT'));
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class for AssetDepreciationOptions.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.