Commit dd170f9b authored by Frank Bergmann's avatar Frank Bergmann

- timsheet task progress tracking started

parent 713a83ee
......@@ -53,10 +53,14 @@ create table im_timesheet_tasks (
invoice_id integer
constraint im_timesheet_tasks_invoice_fk
references im_costs,
description varchar(4000)
description varchar(4000),
percent_completed numeric(6,2)
constraint im_timesheet_tasks_perc_ck
check(percent_completed >= 0 and percent_completed <= 100)
);
create unique index im_timesheet_tasks_task_nr_idx on im_timesheet_tasks (project_id, task_nr);
create unique index im_timesheet_tasks_task_nr_idx
on im_timesheet_tasks (project_id, task_nr);
---------------------------------------------------------
......@@ -304,6 +308,8 @@ where category_type = 'Intranet Timesheet Task Status'
--
-- Wide View in "Tasks" page, including Description
--
delete from im_views where view_id = 910;
--
insert into im_views (view_id, view_name, visible_for) values (910, 'im_timesheet_task_list', 'view_projects');
delete from im_view_columns where column_id >= 91000 and column_id < 91099;
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
......@@ -339,7 +345,11 @@ extra_select, extra_where, sort_order, visible_for) values (91018,910,NULL,'Stat
'$task_status','','',18,'');
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (91020,910,NULL, 'Description',
'[string_truncate -len 80 $description]', '','',20,'');
'[string_truncate -len 80 " $description"]', '','',20,'');
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (91021,910,NULL, 'Done',
'"<input type=textbox size=6 name=percent_completed.$task_id value=$percent_completed>"',
'','',21,'');
insert into im_view_columns (column_id, view_id, group_id, column_name, column_render_tcl,
extra_select, extra_where, sort_order, visible_for) values (91022,910,NULL,
'"[im_gif del "Delete"]"',
......
......@@ -17,7 +17,9 @@
select
t.*,
p.*,
p.project_id,
p.project_name,
p.project_nr,
cc.cost_center_name,
cc.cost_center_code,
im_category_from_id(t.task_type_id) as task_type,
......
......@@ -347,6 +347,7 @@ ad_proc -public im_timesheet_task_list_component {
$previous_page_html
$next_page_html
<select name=action>
<option value=save>[lang::message::lookup "" intranet-timesheet2-tasks.Save_Changes "Save Changes"]</option>
<option value=delete>[_ intranet-timesheet2-tasks.Delete]</option>
</select>
<input type=submit name=submit value='[_ intranet-timesheet2-tasks.Apply]'>
......
......@@ -20,29 +20,81 @@ ad_page_contract {
action
project_id:integer
task_id:array,optional
percent_completed:array,float,optional
return_url
}
set user_id [ad_maybe_redirect_for_registration]
# ----------------------------------------------------------------------
# Permissions
# ---------------------------------------------------------------------
set task_list [array names task_id]
ns_log Notice "task-action: task_list=$task_list"
# ToDo: Permissions on hierarchical projects
if {0 == [llength $task_list]} {
ad_returnredirect $return_url
set current_user_id [ad_maybe_redirect_for_registration]
im_project_permissions $current_user_id $project_id view read write admin
if {!$read} {
ad_return_complaint 1 "<li>[_ intranet-core.lt_You_have_insufficient_6]"
return
}
# Convert the list of selected tasks into a
# "task_id in (1,2,3,4...)" clause
#
set task_in_clause "and task_id in ([join $task_list ", "])\n"
ns_log Notice "task-action: task_in_clause=$task_in_clause"
# ----------------------------------------------------------------------
# Batch-process the tasks
# ---------------------------------------------------------------------
set error_list [list]
switch $action {
save {
set perc_list [array names percent_completed]
foreach task_id $perc_list {
set completed $percent_completed($task_id)
if {"" != $completed} {
if {$completed > 100 || $completed < 0} {
ad_return_complaint 1 "<li>[lang::message::lookup "" intranet-timesheet2-tasks.Percent_completed_between_0_and_100 "Completion percentage must be a value between 0 and 100"]"
return
}
if {[catch {
set sql "
update im_timesheet_tasks
set percent_completed = :completed
where
task_id = :task_id
"
db_dml save_tasks $sql
} errmsg]} {
ad_return_complaint 1 "<li>[lang::message::lookup "" intranet-timesheet2-tasks.Unable_Update_Task "Unable to update task"]"
return
}
}
}
# Update the total advance of the project
}
delete {
set task_list [array names task_id]
ns_log Notice "task-action: delete: task_list=$task_list"
if {0 == [llength $task_list]} {
ad_returnredirect $return_url
}
# Convert the list of selected tasks into a
# "task_id in (1,2,3,4...)" clause
#
set task_in_clause "and task_id in ([join $task_list ", "])\n"
ns_log Notice "task-action: delete: task_in_clause=$task_in_clause"
if {[catch {
set sql "
delete from im_timesheet_tasks
......
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