34 global $langs,
$conf, $extrafields;
36 $extrafields->fetch_name_optionals_label(
'asset');
37 $extrafields->fetch_name_optionals_label(
'asset_model');
39 $langs->load(
"assets");
44 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/asset/admin/setup.php');
45 $head[$h][1] = $langs->trans(
"Settings");
46 $head[$h][2] =
'settings';
59 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/extrafields.php', array(
'elementtype' =>
'asset'));
60 $head[$h][1] = $langs->trans(
"ExtraFields");
61 $nbExtrafields = $extrafields->attributes[
'asset'][
'count'];
62 if ($nbExtrafields > 0) {
63 $head[$h][1] .=
' <span class="badge">'.$nbExtrafields.
'</span>';
65 $head[$h][2] =
'asset_extrafields';
68 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/extrafields.php', array(
'elementtype' =>
'asset_model'));
69 $head[$h][1] = $langs->trans(
"ExtraFieldsAssetModel");
70 $nbExtrafields = $extrafields->attributes[
'asset_model'][
'count'];
71 if ($nbExtrafields > 0) {
72 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
74 $head[$h][2] =
'assetmodel_extrafields';
90 global $db, $langs,
$conf;
92 $langs->loadLangs(array(
"assets",
"admin"));
97 $head[$h][0] = DOL_URL_ROOT .
'/asset/card.php?id=' .
$object->id;
98 $head[$h][1] = $langs->trans(
"Asset");
99 $head[$h][2] =
'card';
102 if (empty(
$object->not_depreciated)) {
103 $head[$h][0] = DOL_URL_ROOT .
'/asset/depreciation_options.php?id=' .
$object->id;
104 $head[$h][1] = $langs->trans(
"AssetDepreciationOptions");
105 $head[$h][2] =
'depreciation_options';
109 $head[$h][0] = DOL_URL_ROOT .
'/asset/accountancy_codes.php?id=' .
$object->id;
110 $head[$h][1] = $langs->trans(
"AssetAccountancyCodes");
111 $head[$h][2] =
'accountancy_codes';
114 if (empty(
$object->not_depreciated)) {
115 $head[$h][0] = DOL_URL_ROOT .
'/asset/depreciation.php?id=' .
$object->id;
116 $head[$h][1] = $langs->trans(
"AssetDepreciation");
117 $head[$h][2] =
'depreciation';
121 if (isset(
$object->disposal_date) &&
$object->disposal_date !==
"") {
122 $head[$h][0] = DOL_URL_ROOT .
'/asset/disposal.php?id=' .
$object->id;
123 $head[$h][1] = $langs->trans(
"AssetDisposal");
124 $head[$h][2] =
'disposal';
128 if (isset(
$object->fields[
'note_public']) || isset(
$object->fields[
'note_private'])) {
130 if (!empty(
$object->note_private)) {
133 if (!empty(
$object->note_public)) {
136 $head[$h][0] = DOL_URL_ROOT .
'/asset/note.php?id=' .
$object->id;
137 $head[$h][1] = $langs->trans(
'Notes');
139 $head[$h][1] .= (!
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
'<span class="badge marginleftonlyshort">' . $nbNote .
'</span>' :
'');
141 $head[$h][2] =
'note';
145 require_once DOL_DOCUMENT_ROOT .
'/core/lib/files.lib.php';
146 require_once DOL_DOCUMENT_ROOT .
'/core/class/link.class.php';
148 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
150 $head[$h][0] = DOL_URL_ROOT .
'/asset/document.php?id=' .
$object->id;
151 $head[$h][1] = $langs->trans(
'Documents');
152 if (($nbFiles + $nbLinks) > 0) {
153 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . ($nbFiles + $nbLinks) .
'</span>';
155 $head[$h][2] =
'document';
158 $head[$h][0] = DOL_URL_ROOT .
'/asset/agenda.php?id=' .
$object->id;
159 $head[$h][1] = $langs->trans(
"Events");
160 $head[$h][2] =
'agenda';
186 global $langs,
$conf;
188 $langs->loadLangs(array(
"assets",
"admin"));
193 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/asset/model/card.php', [
'id' =>
$object->id]);
194 $head[$h][1] = $langs->trans(
"Card");
195 $head[$h][2] =
'card';
198 if (isset(
$object->fields[
'note_public']) || isset(
$object->fields[
'note_private'])) {
200 if (!empty(
$object->note_private)) {
203 if (!empty(
$object->note_public)) {
206 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/asset/model/note.php', [
'id' =>
$object->id]);
207 $head[$h][1] = $langs->trans(
'Notes');
209 $head[$h][1] .= (!
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
'<span class="badge marginleftonlyshort">' . $nbNote .
'</span>' :
'');
211 $head[$h][2] =
'note';
215 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/asset/model/agenda.php', [
'id' =>
$object->id]);
216 $head[$h][1] = $langs->trans(
"Events");
217 $head[$h][2] =
'agenda';
249 'THIRTY_360' =>
'AssetDayCountConventionThirty360',
250 'ACT_365' =>
'AssetDayCountConventionAct365',
251 'ACT_ACT' =>
'AssetDayCountConventionActAct',
274 $nbdaysperyear =
getDolGlobalInt(
'ASSET_DEPRECIATION_DURATION_PER_YEAR');
275 if ($nbdaysperyear == 360) {
277 } elseif ($nbdaysperyear >= 365) {
283 return (is_object(
$mysoc) && !empty(
$mysoc->country_code) &&
$mysoc->country_code ==
'FR') ?
'THIRTY_360' :
'ACT_365';
307 if ($timestampStart > $timestampEnd) {
311 if ($convention ==
'THIRTY_360') {
315 if ($convention ==
'ACT_ACT') {
318 $start =
dol_getdate((
int) $timestampStart,
false, $forcetimezone);
319 $end =
dol_getdate((
int) $timestampEnd,
false, $forcetimezone);
321 $daystart = $start[
'yday'] + 1;
322 $dayend = $end[
'yday'] + 1;
324 if ($start[
'year'] == $end[
'year']) {
329 for ($year = $start[
'year'] + 1; $year < $end[
'year']; $year++) {
361 if ($timestampStart > $timestampEnd) {
365 $start =
dol_getdate((
int) $timestampStart,
false, $forcetimezone);
366 $end =
dol_getdate((
int) $timestampEnd,
false, $forcetimezone);
368 if ($convention ==
'THIRTY_360') {
372 $dayend = ($end[
'mday'] >= $lastdayofendmonth[
'mday'] ? 30 : min($end[
'mday'], 30));
373 $daystart = min($start[
'mday'], 30);
375 return max(0.0, min(1.0, ($dayend - $daystart + 1) / 30));
381 $nbdaysinmonth = (int) $lastdayofstartmonth[
'mday'];
382 if ($nbdaysinmonth <= 0) {
386 return min(1.0,
num_between_day($timestampStart, $timestampEnd, 1) / $nbdaysinmonth);
if(! $sortfield) if(! $sortorder) $object
assetAdminPrepareHead()
Prepare admin pages header.
assetPrepareHead(Asset $object)
Prepare array of tabs for Asset.
assetModelPrepareHead($object)
Prepare array of tabs for AssetModel.
getAssetDepreciationDayCountConventions()
Return the list of the day count conventions available to compute the prorata temporis of a depreciat...
getAssetDepreciationPeriodFraction($timestampStart, $timestampEnd, $convention='', $forcetimezone='')
Return the fraction of a year (the prorata temporis) between two dates, for a given day count convent...
getAssetDepreciationDayCountConvention()
Return the day count convention to use to compute the prorata temporis of a depreciation.
getAssetDepreciationMonthFraction($timestampStart, $timestampEnd, $convention='', $forcetimezone='')
Return the fraction of a month covered by a period, for the given day count convention.
static count($dbs, $objecttype, $objectid)
Return nb of links.
num_days_in_year($year)
Function to return the real number of days of a year (365, or 366 for a leap year).
num_between_day_30_360($timestampStart, $timestampEnd, $lastday=0, $forcetimezone='')
Function to return number of days between two dates using the 30/360 day count convention: every mont...
num_between_day($timestampStart, $timestampEnd, $lastday=0)
Function to return number of days between two dates (date must be UTC date !) Example: 2012-01-01 201...
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.