Commit a80e73ae authored by Frank Bergmann's avatar Frank Bergmann

- Changed EVA scale from percentage to hours

- Improved L10n
parent 2a486687
......@@ -5,65 +5,64 @@
Ext.require(['Ext.chart.*', 'Ext.Window', 'Ext.fx.target.Sprite', 'Ext.layout.container.Fit']);
Ext.onReady(function () {
projectEvaStore = Ext.create('Ext.data.Store', {
fields: ['date', 'planned_work', 'percent_completed', 'reported_hours_cache'],
data: @data_json;noquote@
});
projectEvaChart = new Ext.chart.Chart({
store: projectEvaStore,
legend: { position: 'float', x:40 },
theme: 'Base:gradients',
axes: [{
type: 'Numeric',
position: 'left',
minimum: 0,
fields: ['planned_work', 'percent_completed']
}, {
type: 'Time',
position: 'bottom',
fields: ['date'],
dateFormat: 'M Y',
label: {rotate: { degrees: 315}},
step: [@step_uom@, @step_units@]
}],
series: [
{ title: 'Work Planned', type: 'line', axis: 'left', xField: 'date', yField: 'planned_work'},
{ title: 'Work Done', type: 'line', axis: 'left', xField: 'date', yField: 'percent_completed'},
{ title: 'Work Logged', type: 'line', axis: 'left', xField: 'date', yField: 'logged_hours'}
]
});
var projectEvaPanel = Ext.create('widget.panel', {
width: @diagram_width@,
height: @diagram_height@,
title: 'Test',
renderTo: '@diagram_id@',
layout: 'fit',
header: false,
tbar: [{
xtype: 'combo',
editable: false,
store: false,
mode: 'local',
displayField: 'display',
valueField: 'value',
triggerAction: 'all',
width: 150,
forceSelection: true,
value: 'all_time',
listeners:{select:{fn:function(combo, comboValues) {
var value = comboValues[0].data.value;
var extraParams = projectEvaStore.getProxy().extraParams;
extraParams.diagram_interval = value;
projectEvaStore.load();
}
}
}
}],
items: projectEvaChart
});
projectEvaStore = Ext.create('Ext.data.Store', {
fields: [@fields_json;noquote@],
data: @data_json;noquote@
});
projectEvaChart = new Ext.chart.Chart({
store: projectEvaStore,
legend: { position: 'float', x:40 },
theme: 'Base:gradients',
axes: [{
type: 'Numeric',
position: 'left',
minimum: 0,
fields: ['planned_hours', 'logged_hours', 'completed_hours']
}, {
type: 'Time',
position: 'bottom',
fields: ['date'],
dateFormat: 'M Y',
label: {rotate: { degrees: 315}},
step: [@step_uom@, @step_units@]
}],
series: [
{ title: '@work_planned_l10n;noquote@', type: 'line', axis: 'left', xField: 'date', yField: 'planned_hours'},
{ title: '@work_done_l10n;noquote@', type: 'line', axis: 'left', xField: 'date', yField: 'completed_hours'},
{ title: '@work_logged_l10n;noquote@', type: 'line', axis: 'left', xField: 'date', yField: 'logged_hours'}
]
});
var projectEvaPanel = Ext.create('widget.panel', {
width: @diagram_width@,
height: @diagram_height@,
title: 'Test',
renderTo: '@diagram_id@',
layout: 'fit',
header: false,
tbar: [{
xtype: 'combo',
editable: false,
store: false,
mode: 'local',
displayField: 'display',
valueField: 'value',
triggerAction: 'all',
width: 150,
forceSelection: true,
value: 'all_time',
listeners:{select:{fn:function(combo, comboValues) {
var value = comboValues[0].data.value;
var extraParams = projectEvaStore.getProxy().extraParams;
extraParams.diagram_interval = value;
projectEvaStore.load();
}
}
}
}],
items: projectEvaChart
});
});
</script>
</if>
......@@ -2,6 +2,11 @@
#
# project_id ID of the main project to be tracked
set work_planned_l10n [lang::message::lookup "" intranet-earned-value-management.work_planned_hours "Work Planned (hours)"]
set work_logged_l10n [lang::message::lookup "" intranet-earned-value-management.work_logged_hours "Work Logged (hours)"]
set work_done_l10n [lang::message::lookup "" intranet-earned-value-management.work_completed_hours "Work Done (hours)"]
set start_time [clock clicks -milliseconds]
if {"" eq $project_id} { set project_id 0 }
......@@ -112,55 +117,42 @@ db_foreach julian $julian_sql {
# -----------------------------------------------------
# Get resource assignments and planned units per task
#
set percentage_sql "
set planned_hours_sql "
select parent.project_id as parent_project_id,
to_char(parent.start_date, 'J') as parent_start_julian,
to_char(parent.end_date, 'J') as parent_end_julian,
child.project_id,
to_char(child.start_date, 'J') as child_start_julian,
to_char(child.end_date, 'J') as child_end_julian,
t.planned_units as child_planned_units,
u.user_id,
coalesce(round(bom.percentage), 0) as percentage
coalesce(t.planned_units,0) as child_planned_hours
from im_projects parent,
im_projects child
LEFT OUTER JOIN im_timesheet_tasks t ON (child.project_id = t.task_id)
LEFT OUTER JOIN acs_rels r ON (child.project_id = r.object_id_one),
im_biz_object_members bom,
users u
where parent.project_id = :project_id and
child.tree_sortkey between parent.tree_sortkey and tree_right(parent.tree_sortkey) and
child.start_date is not null and
child.end_date is not null and
r.rel_id = bom.rel_id and
bom.percentage is not null and bom.percentage > 0.0 and
r.object_id_two = u.user_id and
u.user_id not in (select member_id from group_distinct_member_map where group_id = [im_profile_skill_profile])
child.end_date is not null
"
# ad_return_complaint 1 "<pre>[join [db_list_of_lists t $percentage_sql] "\n"]</pre>"
array set task_planned_units_hash {}
array set percent_hash {}
db_foreach percentages $percentage_sql {
array set planned_hours_hash {}
set total_planned_hours 0.0
db_foreach planned_hours $planned_hours_sql {
set total_planned_hours [expr $total_planned_hours + $child_planned_hours]
set child_duration_days [expr $child_end_julian - $child_start_julian]
if {$child_duration_days <= 1} { set child_duration_days 1 }; # Avoid divison by zero or negative...
for {set j $child_start_julian} {$j <= $child_end_julian} {incr j} {
set key "$j"
# Sum up percentages, except for weekends
set dow [im_date_julian_to_dow $j]
if {6 ne $dow && 7 ne $dow} {
set perc 0.0
if {[info exists percent_hash($key)]} { set perc $percent_hash($key) }
set perc [expr $perc + $percentage]
set percent_hash($key) [expr round(100.0 * $perc) / 100.0]
}
set hours 0.0
if {[info exists planned_hours_hash($key)]} { set hours $planned_hours_hash($key) }
set hours [expr $hours + $child_planned_hours / $child_duration_days]
set planned_hours_hash($key) $hours
}
}
# -----------------------------------------------------
# Get logged hours
#
set hours_sql "
set logged_hours_sql "
select sum(h.hours) as hours,
to_char(h.day::date, 'J') as day_julian
from im_hours h,
......@@ -172,23 +164,24 @@ set hours_sql "
group by h.day::date
order by h.day::date
"
# ad_return_complaint 1 "<pre>[join [db_list_of_lists h $hours_sql] "\n"]</pre>"
array set logged_hours_hash {}
db_foreach hours $hours_sql {
db_foreach hours $logged_hours_sql {
set key "$day_julian"
set logged_hours_hash($key) $hours
}
# Debugging
for {set i $diagram_start_julian} {$i < $diagram_end_julian} {incr i} {
if {![info exists logged_hours_hash($i)]} { set logged_hours_hash($i) 50 }
}
# --------------------------------------------------------------
# Determine audit values
# --------------------------------------------------------------
# Which attributes should be stored?
# set attribute_list { percent_completed cost_bills_cache cost_delivery_notes_cache cost_expense_logged_cache cost_invoices_cache cost_purchase_orders_cache cost_quotes_cache cost_timesheet_logged_cache reported_hours_cache reported_days_cache}
set attribute_list { percent_completed reported_hours_cache}
set attribute_list {percent_completed}
set audit_sql "
select to_char(a.audit_date, 'J') as audit_date_julian,
......@@ -205,46 +198,48 @@ db_foreach audit_loop $audit_sql {
set key_val [split $field "\t"]
set attribute_name [lindex $key_val 0]
set attribute_value [lrange $key_val 1 end]
if {[lsearch $attribute_list $attribute_name] < 0} { continue }
set key "$audit_date_julian"
set cmd "set ${attribute_name}_hash($key) \$attribute_value"
eval $cmd
}
}
# ad_return_complaint 1 [array get completed_hours_hash]
# --------------------------------------------------------------
# Calculate the aggregated values
# --------------------------------------------------------------
set accumulated_percent 0.0
set max_percent_completed 0.0
set accumulated_planned_hours 0.0
set accumulated_logged_hours 0.0
set max_percent_completed 0.0
for {set i $diagram_start_julian} {$i < $diagram_end_julian} {incr i} {
set key "$i"
set val 0
if {[info exists percent_hash($key)]} { set val $percent_hash($key) }
set accumulated_percent [expr $accumulated_percent + $val]
set accumulated_percent_hash($key) $accumulated_percent
if {[info exists planned_hours_hash($key)]} { set val $planned_hours_hash($key) }
set accumulated_planned_hours [expr $accumulated_planned_hours + $val]
set accumulated_planned_hours_hash($key) $accumulated_planned_hours
set val 0
if {[info exists logged_hours_hash($key)]} { set val $logged_hours_hash($key) }
set accumulated_logged_hours [expr $accumulated_logged_hours + $val]
set accumulated_logged_hours_hash($key) $accumulated_logged_hours
if {[info exists percent_completed_hash($key)] && "" ne $percent_completed_hash($key) } { set max_percent_completed $percent_completed_hash($key) }
set max_percent_completed_hash($key) $max_percent_completed
set percent_completed ""
if {[info exists percent_completed_hash($key)]} { set percent_completed $percent_completed_hash($key) }
if {"" ne $percent_completed} { set max_percent_completed $percent_completed }
set accumulated_completed_hours_hash($key) [expr $max_percent_completed * $total_planned_hours / 100.0 * 5.0]
}
#ad_return_complaint 1 $accumulated_percent
if {$accumulated_percent == 0.0} {
if {$accumulated_planned_hours == 0.0} {
set error_html [lang::message::lookup "" intranet-earned-management.No_resources_assigned "You didn't assign any resource percentages to any user in any task in this project"]
set show_diagram_p 0
}
# ad_return_complaint 1 [array get accumulated_logged_hours_hash]
# --------------------------------------------------------------
......@@ -262,15 +257,18 @@ for {set i $diagram_start_julian} {$i < $diagram_end_julian} {set i [expr $i + $
set key "$i"
set iso_date $julian_hash($i)
set data_line "{date: new Date('$iso_date')"
set v 0.0
if {0.0 != $accumulated_percent} { set v [expr 100.0 * $accumulated_percent_hash($key) / $accumulated_percent] }
append data_line ", 'planned_work': $v"
set v 0.0
if {0.0 != $accumulated_logged_hours} { set v [expr 100.0 * $accumulated_logged_hours_hash($key) / $accumulated_logged_hours] }
set v $accumulated_planned_hours_hash($key)
append data_line ", 'planned_hours': $v"
set v $accumulated_logged_hours_hash($key)
append data_line ", 'logged_hours': $v"
append data_line ", 'percent_completed': $max_percent_completed_hash($key)"
set v $accumulated_completed_hours_hash($key)
append data_line ", 'completed_hours': $v"
# Loop through all attributes and add attribute to the list of values
if {0} {
foreach att $attribute_list {
if {[info exists ${att}_hash($key)]} {
# Write the new value to the attribute named variable
......@@ -283,6 +281,7 @@ for {set i $diagram_start_julian} {$i < $diagram_end_julian} {set i [expr $i + $
set v [expr "\$${att}"]
append data_line ", '$att': $v"
}
}
append data_line "}"
lappend data_lines $data_line
......@@ -292,7 +291,7 @@ set data_json "\[\n"
append data_json [join $data_lines ",\n"]
append data_json "\n\]\n"
set fields_json "'planned_work', 'percent_completed'"
set fields_json "'date', 'planned_hours', 'logged_hours', 'completed_hours'"
# --------------------------------------------------------------
......@@ -305,3 +304,5 @@ foreach att $attribute_list {
}
# ad_return_complaint 1 "<pre>$fields_json<br><br>$data_json</pre>"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment