Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-resource-management
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-resource-management
Commits
74daf015
Commit
74daf015
authored
Oct 23, 2020
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Implemented cutting percentages on the start- and end date of an assignment
when cutting into a fraction of a day
parent
eaf73b65
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
8 deletions
+38
-8
intranet-resource-management-procs-percentage.tcl
tcl/intranet-resource-management-procs-percentage.tcl
+38
-8
No files found.
tcl/intranet-resource-management-procs-percentage.tcl
View file @
74daf015
...
...
@@ -349,10 +349,10 @@ ad_proc -public im_resource_mgmt_resource_planning_percentage {
child.parent_id,
(
length
(
child.tree_sortkey
)
/ 8
)
- 3 as level,
greatest
(
to_char
(
child.start_date::date, 'J'
)
::integer, :report_start_julian::integer
)
child_start_julian,
extract
(
hour from child.start_date
)
* 60 + extract
(
minutes from child.start_date
)
as child_start_minute
s,
round
((
extract
(
hour from child.start_date
)
+ extract
(
minute from child.start_date
)
/ 60.0
)
::numeric, 2
)
as child_start_hour
s,
least
(
to_char
(
child.end_date, 'J'
)
::integer, :report_end_julian::integer
)
as child_end_julian,
extract
(
hour from child.end_date
)
* 60 + extract
(
minutes from child.end_date
)
as child_end_minute
s,
round
((
extract
(
hour from child.end_date
)
+ extract
(
minute from child.end_date
)
/ 60.0
)
::numeric ,2
)
as child_end_hour
s,
coalesce
(
t.planned_units, 0
)
as planned_units
from im_projects parent,
...
...
@@ -372,8 +372,8 @@ ad_proc -public im_resource_mgmt_resource_planning_percentage {
set project_start_julian_hash(
$project
_id)
$child
_start_julian
set project_end_julian_hash(
$project
_id)
$child
_end_julian
set project_start_
minutes_hash(
$project
_id)
$child
_start_minute
s
set project_end_
minutes_hash(
$project
_id)
$child
_end_minute
s
set project_start_
hours_hash(
$project
_id)
$child
_start_hour
s
set project_end_
hours_hash(
$project
_id)
$child
_end_hour
s
set project_level_hash(
$project
_id)
$level
set project_planned_hours(
$project
_id)
$planned
_units
...
...
@@ -648,8 +648,8 @@ ad_proc -public im_resource_mgmt_resource_planning_percentage {
set end_julian
$project
_end_julian_hash(
$project
_id)
set parent_list
$left
_dimension_hash(
$key
)
set start_
minutes
$project
_start_julian
_hash(
$project
_id)
set end_
minutes
$project
_end_julian_hash(
$project
_id); # !!!
set start_
hours
$project
_start_hours
_hash(
$project
_id)
set end_
hours
$project
_end_hours_hash(
$project
_id);
foreach oid
$parent
_list {
for {set j
$start
_julian} {
$j
<=
$end
_julian} {incr j} {
...
...
@@ -657,7 +657,37 @@ ad_proc -public im_resource_mgmt_resource_planning_percentage {
# Skip weekends
if {
[
info
exists weekend_hash
(
$j
)]
} { continue }
# if {48349 ==
$project
_id} { ad_return_complaint 1 "
pid=$project_id, uid=$user_id, start_julian=$start_julian, end_julian=$end_julian, perc=$percentage, assigavail=$assigavail
" }
set assig
$assigavail
# First day of the interval - Cut percentage based on start_hour
if {
$j
==
$start
_julian} {
set hours
[
expr
17.0 -
$start
_hours
]
; # Hours from start of interval until 5:00pm (=17.0)
if {
$hours
< 0.0} { set hours 0.0 }
if {
$hours
> 8.0} { set hours 8.0 }
set assig
[
expr
round
(
$assigavail
*
$hours
/ 8.0
)]
# ns_log Notice "
im_resource_mgmt_resource_planning_percentage: 1st day of interval: j=
[
expr
$j-$start
_julian
]
, oid=$oid, uid=$user_id, start_julian=$start_julian, start_hours=$start_hours, end_julian=$end_julian, end_hours=$end_hours, hours=$hours, perc=$percentage, assig=$assig
"
}
# Last day of the interval - Cut percentage based on end_hour
if {
$j
==
$end
_julian} {
set hours
[
expr
17.0 -
$end
_hours
]
; # Hours from start of interval until 5:00pm (=17.0)
if {
$hours
< 0.0} { set hours 0.0 }
if {
$hours
> 8.0} { set hours 8.0 }
set assig
[
expr
round
(
$assigavail
*
(
8.0 -
$hours
)
/ 8.0
)]
# ns_log Notice "
im_resource_mgmt_resource_planning_percentage: last day of interval: j=
[
expr
$j-$start
_julian
]
, oid=$oid, uid=$user_id, start_julian=$start_julian, start_hours=$start_hours, end_julian=$end_julian, end_hours=$end_hours, hours=$hours, perc=$percentage, assig=$assig
"
}
# Special case: 1-day assignment - Cut percentage based on both start and end
if {
$start
_julian ==
$end
_julian} {
if {
$start
_hours < 9.0} { set start_hours 9.0 }
if {
$end
_hours > 17.0} { set end_hours 17.0 }
set hours
[
expr
$end
_hours -
$start
_hours
]
if {
$hours
< 0.0} { set hours 0.0 }
if {
$hours
> 8.0} { set hours 8.0 }
set assig
[
expr
round
(
$assigavail
*
$hours
/ 8.0
)]
# ns_log Notice "
im_resource_mgmt_resource_planning_percentage: only day of interval: j=
[
expr
$j-$start
_julian
]
, oid=$oid, uid=$user_id, start_julian=$start_julian, start_hours=$start_hours, end_julian=$end_julian, end_hours=$end_hours, hours=$hours, perc=$percentage, assig=$assig
"
}
# Calculate the date component of the key, depending on top_vars
...
...
@@ -675,7 +705,7 @@ ad_proc -public im_resource_mgmt_resource_planning_percentage {
set key
[
join
$key
_list
"-"
]
set v 0
if {
[
info
exists assignment_hash
(
$key
)]
} { set v
$assignment
_hash(
$key
) }
set assignment_hash(
$key
)
[
expr
$v
+
$assig
avail
]
set assignment_hash(
$key
)
[
expr
$v
+
$assig
]
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment