Index: openacs-4/packages/tasks/tasks.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/tasks.info,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/tasks.info 27 Jul 2005 13:44:58 -0000 1.1 +++ openacs-4/packages/tasks/tasks.info 25 Sep 2005 23:49:22 -0000 1.2 @@ -14,8 +14,11 @@ + + + Index: openacs-4/packages/tasks/catalog/tasks.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/catalog/tasks.en_US.ISO-8859-1.xml,v diff -u -r1.2 -r1.3 --- openacs-4/packages/tasks/catalog/tasks.en_US.ISO-8859-1.xml 27 Jul 2005 14:29:51 -0000 1.2 +++ openacs-4/packages/tasks/catalog/tasks.en_US.ISO-8859-1.xml 25 Sep 2005 23:49:23 -0000 1.3 @@ -7,11 +7,14 @@ Assign Process Cancel Cancel, do not delete + Comment + Are you sure you want to mark %pretty_entries% as done? + Contact Created By Custom Task Date Delete - Delete $task_pretty + Delete %task_pretty% Done Due Follow Up Call @@ -21,21 +24,23 @@ Add Task} save} {{<#_ Add Task and Add Another Are you sure you want to delete this process: %one_line% - Are you sure you want to delete $task2_pretty ? + Are you sure you want to delete %task2_pretty% ? Delete from Recruiting System Either a custom task or standard task is required - Originally created by <a href=\"[contact::url -party_id $creation_id]\">[contact::name -party_id $creation_id]</a> + Originally created by <a href=\"%creator_url%\">%creator_name%</a> Provide Promotional Information Send Personal Note/Letter Standard tasks are cannot be used in conjunction with custom tasks - The task <a href=\"/tasks/${task_url}\">$task</a> was added - The task <a href=\"/tasks/${task_url}\">$title</a> was updated - The task \"[lindex $task_titles 0]\" was deleted - The task \"$task\" was added to $names - The tasks ${task_list} were deleted - these $num_entries tasks + The task <a href="/tasks/%task_url%">%task%</a> was added + The task <a href="/tasks/%task_url%">%title%</a> was updated + The task "%task_title%" was deleted + The task "%task%" was added to %names% + The tasks %task_list% were deleted + these %num_entries% tasks Update and Add New Task You are not allowed to bulk edit a task for multiple contacts + Mark Completed + Mark %pretty_task% as Done more No, Cancel Not Allowed @@ -51,8 +56,14 @@ Standard Task Status Task + The task "%task_title%" was marked done + The task <a href="%task_url%">%task%</a> delayed 7 days + The task <a href="%task_url%">%task%</a> moved up 7 days Tasks + The tasks %task_list% were marked done + these %num_entries% tasks this task Update + View next Yes Index: openacs-4/packages/tasks/lib/contact-tasks.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/lib/contact-tasks.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/lib/contact-tasks.adp 25 Sep 2005 23:49:23 -0000 1.1 @@ -0,0 +1,6 @@ +

+#tasks.Add_Task# +#tasks.Assign_Process# +

+ + Index: openacs-4/packages/tasks/lib/contact-tasks.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/lib/contact-tasks.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/lib/contact-tasks.tcl 25 Sep 2005 23:49:23 -0000 1.1 @@ -0,0 +1,181 @@ +set user_id [ad_conn user_id] +set party_id $user_id +set tasks_url "/tasks/" + +if { ![contact::exists_p -party_id $contact_id] } { + set contact_id $user_id +} +if { ![exists_and_not_null orderby] } { + set orderby "priority,desc" +} +if { ![exists_and_not_null status_id] } { + set status_id "1" +} +set done_url [export_vars -url -base "${tasks_url}contact" {orderby {status_id 2} party_id}] +set not_done_url [export_vars -url -base "${tasks_url}contact" {orderby {status_id 1} party_id}] +set return_url "[ad_conn url]?[ad_conn query]" +set add_url [export_vars -base "${tasks_url}task" {return_url orderby status_id {object_id $contact_id} party_id}] + +set package_id [apm_package_id_from_key tasks] + +template::list::create \ + -name tasks \ + -multirow tasks \ + -key task_id \ + -elements { + deleted_p { + label {[_ tasks.Not_Done]} + display_template { + [_ tasks.Done] + [_ tasks.Not_Done] + } + } + priority { + label "[_ tasks.Priority]" + display_template { + @tasks.priority@@tasks.priority@ + } + } + title { + label "[_ tasks.Task]" + display_template { + class="done">@tasks.title@ + +
+

+ @tasks.description_html;noquote@ +

+
+
+ } + } + process_title { + label "[_ tasks.Process]" + display_template { + @tasks.process_title@ + + @tasks.process_title@ + + } + } + contact { + label "[_ tasks.Contact]" + display_template { + @tasks.contact@ + } + } + date { + label "[_ tasks.Date]" + display_template { + @tasks.completed_date;noquote@ + + + « @tasks.due_date;noquote@ » + + + } + } + creation_user { + label "[_ tasks.Created_By]" + display_template { + class="done">@tasks.creation_name@ + } + } + } \ + -sub_class { + narrow + } \ + -filters { + contact_id {} + } -orderby { + default_value "priority,desc" + date { + label "[_ tasks.Due]" + orderby_desc "CASE WHEN t.status_id = 1 THEN t.due_date ELSE t.completed_date END desc, t.priority, lower(t.title)" + orderby_asc "CASE WHEN t.status_id = 1 THEN t.due_date ELSE t.completed_date END asc, t.priority, lower(t.title)" + default_direction desc + } + priority { + label "[_ tasks.Priority]" + orderby_desc "t.status_id, t.priority desc, CASE WHEN t.status_id = 1 THEN t.due_date ELSE t.completed_date END desc, lower(t.title)" + orderby_asc "t.status_id, t.priority asc, CASE WHEN t.status_id = 1 THEN t.due_date ELSE t.completed_date END asc, lower(t.title)" + default_direction desc + } + title { + label "[_ tasks.Task]" + orderby_desc "lower(t.title) desc, t.priority desc, t.due_date asc" + orderby_asc "lower(t.title) asc, t.priority desc, t.due_date asc" + default_direction asc + } + process_title { + label "[_ tasks.Process]" + orderby_desc "lower(p.title) desc, t.priority desc, t.due_date asc" + orderby_asc "lower(p.title) asc, t.priority desc, t.due_date asc" + default_direction asc + } + contact { + label "[_ tasks.Contact]" + orderby_desc "lower(contact__name(t.object_id)) desc, t.due_date asc, t.priority, lower(t.title)" + orderby_asc "lower(contact__name(t.object_id)) asc, t.due_date asc, t.priority, lower(t.title)" + default_direction asc + } + creation_user { + label "[_ tasks.Created_By]" + orderby_desc "lower(contact__name(ao.creation_user)) desc, t.due_date asc, t.priority, lower(t.title)" + orderby_asc "lower(contact__name(ao.creation_user)) asc, t.due_date asc, t.priority, lower(t.title)" + default_direction asc + } + } + + +db_multirow -extend {creation_user_url contact_url complete_url done_p task_plus_url task_minus_url description_html task_url} -unclobber tasks get_tasks " + select t.task_id, t.title, t.description, t.mime_type, t.priority, + t.party_id, p.title as process_title, p.process_id, + tasks__relative_date(t.due_date) as due_date, + tasks__relative_date(t.completed_date) as completed_date, + ao.creation_user, t.status_id, t.process_instance_id, + contact__name(ao.creation_user) as creation_name, + CASE WHEN t.due_date < now() THEN 't' ELSE 'f' END as due_date_passed_p, + s.title as status, t.object_id, + contact__name(t.object_id) as contact + from t_task_status s, acs_objects ao, t_tasks t + left outer join t_process_instances pi + on (pi.process_instance_id = t.process_instance_id) + left outer join t_processes p + on (p.process_id = pi.process_id) + where s.status_id = t.status_id + and ao.object_id = t.task_id + and ao.package_id = :package_id + and t.object_id = :contact_id + and t.start_date < now() + [template::list::orderby_clause -orderby -name tasks] +" { + set creation_user_url [contact::url -party_id $creation_user] + if {![empty_string_p $object_id]} { + set contact_url [contact::url -party_id $object_id] + } + regsub -all "/tasks/" $creation_user_url "/contacts/" creation_user_url + set complete_url [export_vars -base "${tasks_url}mark-completed" -url {task_id orderby party_id return_url}] + if { $status_id == "2" } { + set done_p 1 + } else { + set done_p 0 + } + set task_url [export_vars -base "${tasks_url}task" -url {party_id orderby status_id task_id}] + set task_plus_url [export_vars -base "${tasks_url}task-interval" -url {{action plus} {days 7} party_id task_id status_id orderby return_url}] + set task_minus_url [export_vars -base "${tasks_url}task-interval" -url {{action minus} {days 7} party_id task_id status_id orderby return_url}] + + regsub -all "\r|\n" $description {LiNeBrEaK} description + + set description_html [ad_html_text_convert \ + -from $mime_type \ + -to "text/html" \ + -truncate_len "400" \ + -more "[_ tasks.more]" \ + -- $description] + regsub -all {LiNeBrEaKLiNeBrEaK} $description_html {LiNeBrEaK} description_html + regsub -all {LiNeBrEaK} $description_html {\ \ \¶\ } description_html + + regsub -all " " $due_date {\ } due_date + regsub -all " " $completed_date {\ } completed_date +} Index: openacs-4/packages/tasks/sql/postgresql/tasks-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/sql/postgresql/tasks-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/sql/postgresql/tasks-create.sql 27 Jul 2005 13:44:59 -0000 1.1 +++ openacs-4/packages/tasks/sql/postgresql/tasks-create.sql 25 Sep 2005 23:49:23 -0000 1.2 @@ -6,15 +6,204 @@ -- ----------------------------------------------------- -create table tasks_pm_process_task ( +create table t_processes ( + process_id integer + constraint t_process_id_pk + primary key + constraint t_process_id_fk + references acs_objects, + title varchar(1000), + description text, + mime_type varchar(200) default 'text/plain', + workflow_id integer + constraint t_process_workflow_fk + references workflows +); + +create table t_process_instances ( + process_instance_id integer + constraint t_process_instances_id_pk + primary key + constraint t_process_instances_id_fk + references acs_objects, + process_id integer + constraint t_process_instances_process_fk + references t_processes, + case_id integer, + party_id integer + constraint t_process_instances_party_fk + references parties, + object_id integer + constraint t_process_instances_tasks_object_fk + references acs_objects +); + + +create sequence t_task_status_seq start 3; + +create table t_task_status ( + status_id integer + constraint t_task_status_pk + primary key, + short_name varchar(100), + title varchar(100), + -- closed or open + status_type char(1) default 'c' + constraint t_task_status_type_ck + check (status_type in ('c', 'o')) +); + +insert into t_task_status (status_id, short_name, title, status_type) values +(1, 'open', '#acs-kernel.common_Open#', 'o'); +insert into t_task_status (status_id, short_name, title, status_type) values +(2, 'closed', '#acs-kernel.common_Closed#', 'c'); + + +create table t_process_tasks ( + task_id integer + constraint t_process_tasks_task_pk + primary key + constraint t_process_tasks_task_fk + references acs_objects, + process_id integer + constraint t_process_tasks_process_fk + references t_processes, + -- action creating this task + open_action_id integer + constraint t_process_tasks_open_action_fk + references workflow_actions, + -- action when closing task + closing_action_id integer + constraint t_process_tasks_close_action_fk + references workflow_actions, + party_id integer + constraint t_process_tasks_party_fk + references parties, + object_id integer + constraint t_process_tasks_object_fk + references acs_objects, + title varchar(1000), + description text, + mime_type varchar(200) default 'text/plain', + comment text, + status_id integer + constraint t_process_tasks_status_fk + references t_task_status, + priority integer, + -- start date relative to current date + start numeric, + -- due date relative to current date + due numeric +); + + +create table t_tasks ( + task_id integer + constraint t_tasks_task_pk + primary key + constraint t_tasks_task_fk + references acs_objects, + process_instance_id integer + constraint t_tasks_instance_fk + references t_process_instances, process_task_id integer - constraint tasks_pm_process_task_id_fk references pm_process_task(process_task_id) - constraint tasks_pm_process_task_id_pk primary key, - due_interval interval, + constraint t_tasks_process_task_fk + references t_process_tasks, + party_id integer + constraint t_tasks_party_fk + references parties, + object_id integer + constraint t_tasks_object_fk + references acs_objects, + title varchar(1000), + description text, + mime_type varchar(200) default 'text/plain', + comment text, + status_id integer + constraint t_tasks_status_fk + references t_task_status, + priority integer, + start_date timestamptz, due_date timestamptz, - priority integer default 0 + completed_date timestamptz ); + + + + + +CREATE FUNCTION inline_0() +RETURNS integer +AS 'declare + begin + PERFORM + acs_object_type__create_type( + ''tasks_task'', -- object_type + ''Task'', -- pretty_name + ''Tasks'', -- pretty_plural + ''acs_object'', -- supertype + ''t_tasks'', -- table_name + ''task_id'', -- id_column + ''tasks_task'', -- package_name + ''f'', -- abstract_p + null, -- type_extension_table + null -- name_method + ); + + PERFORM + acs_object_type__create_type( + ''tasks_process'', -- object_type + ''Task Process'', -- pretty_name + ''Task Processes'', -- pretty_plural + ''acs_object'', -- supertype + ''t_processes'', -- table_name + ''process_id'', -- id_column + ''tasks_process'', -- package_name + ''f'', -- abstract_p + null, -- type_extension_table + null -- name_method + ); + + PERFORM + acs_object_type__create_type( + ''tasks_process_instance'', -- object_type + ''Task Process Instance'', -- pretty_name + ''Task Process Instances'', -- pretty_plural + ''acs_object'', -- supertype + ''t_process_instances'', -- table_name + ''process_instance_id'', -- id_column + ''tasks_process_instance'', -- package_name + ''f'', -- abstract_p + null, -- type_extension_table + null -- name_method + ); + + PERFORM + acs_object_type__create_type( + ''tasks_process_task'', -- object_type + ''Process Task'', -- pretty_name + ''Process Tasks'', -- pretty_plural + ''acs_object'', -- supertype + ''t_process_tasks'', -- table_name + ''task_id'', -- id_column + ''tasks_process_task'', -- package_name + ''f'', -- abstract_p + null, -- type_extension_table + null -- name_method + ); + + return 0; + + end;' +LANGUAGE 'plpgsql'; + +SELECT inline_0(); + +DROP function inline_0(); + + + create or replace function tasks__relative_date ( timestamptz -- date_comparative ) returns varchar @@ -112,3 +301,189 @@ return v_user; end;' language 'plpgsql'; + + +----------------------------- + +select define_function_args('tasks_task__new','task_id,process_instance_id,process_task_id,party_id,object_id,title,description,mime_type,comment,status_id,priority,start_date,due_date,package_id,creation_user,creation_ip,context_id'); + +create or replace function tasks_task__new (integer,integer,integer,integer,integer,varchar,text,varchar,text,integer,integer,timestamptz,timestamptz,integer,integer,varchar,integer) +returns integer as ' +declare + p_task_id alias for $1; + p_process_instance_id alias for $2; + p_process_task_id alias for $3; + p_party_id alias for $4; + p_object_id alias for $5; + p_title alias for $6; + p_description alias for $7; + p_mime_type alias for $8; + p_comment alias for $9; + p_status_id alias for $10; + p_priority alias for $11; + p_start_date alias for $12; + p_due_date alias for $13; + p_package_id alias for $14; + p_creation_user alias for $15; + p_creation_ip alias for $16; + p_context_id alias for $17; + v_task_id integer; + v_start_date timestamptz; +begin + v_task_id:= acs_object__new( + p_task_id, + ''tasks_task'', + now(), + p_creation_user, + p_creation_ip, + coalesce(p_context_id, p_package_id), + ''t'', + p_title, + p_package_id + ); + + if p_start_date is null then + v_start_date := now(); + else + v_start_date := p_start_date; + end if; + + insert into t_tasks + (task_id, process_instance_id, process_task_id, party_id, object_id, + title, description, mime_type, comment, status_id, priority, + start_date, due_date) + values + (v_task_id, p_process_instance_id, p_process_task_id, p_party_id, + p_object_id, p_title, p_description, p_mime_type, p_comment, + p_status_id, p_priority, v_start_date, p_due_date); + + return v_task_id; +end; +' language 'plpgsql'; + + +select define_function_args('tasks_process_task__new','task_id,process_id,open_action_id,closing_action_id,party_id,object_id,title,description,mime_type,comment,status_id,priority,start,due,package_id,creation_user,creation_ip,context_id'); + +create or replace function tasks_process_task__new (integer,integer,integer,integer,integer,integer,varchar,text,varchar,text,integer,integer,numeric,numeric,integer,integer,varchar,integer) +returns integer as ' +declare + p_task_id alias for $1; + p_process_id alias for $2; + p_open_action_id alias for $3; + p_closing_action_id alias for $4; + p_party_id alias for $5; + p_object_id alias for $6; + p_title alias for $7; + p_description alias for $8; + p_mime_type alias for $9; + p_comment alias for $10; + p_status_id alias for $11; + p_priority alias for $12; + p_start alias for $13; + p_due alias for $14; + p_package_id alias for $15; + p_creation_user alias for $16; + p_creation_ip alias for $17; + p_context_id alias for $18; + v_task_id integer; +begin + v_task_id:= acs_object__new( + p_task_id, + ''tasks_process_task'', + now(), + p_creation_user, + p_creation_ip, + coalesce(p_context_id, p_package_id), + ''t'', + p_title, + p_package_id + ); + + insert into t_process_tasks + (task_id, process_id, open_action_id, closing_action_id, party_id, + object_id, title, description, mime_type, comment, status_id, + priority, start, due) + values + (v_task_id, p_process_id, p_open_action_id, p_closing_action_id, + p_party_id, p_object_id, p_title, p_description, p_mime_type, + p_comment, p_status_id, p_priority, p_start, p_due); + + return v_task_id; +end; +' language 'plpgsql'; + + +select define_function_args('tasks_process__new','process_id,title,description,mime_type,workflow_id,package_id,creation_user,creation_ip,context_id'); + +create or replace function tasks_process__new (integer,varchar,text,varchar,integer,integer,integer,varchar,integer) +returns integer as ' +declare + p_process_id alias for $1; + p_title alias for $2; + p_description alias for $3; + p_mime_type alias for $4; + p_workflow_id alias for $5; + p_package_id alias for $6; + p_creation_user alias for $7; + p_creation_ip alias for $8; + p_context_id alias for $9; + v_process_id integer; +begin + v_process_id:= acs_object__new( + p_process_id, + ''tasks_process'', + now(), + p_creation_user, + p_creation_ip, + coalesce(p_context_id, p_package_id), + ''t'', + p_title, + p_package_id + ); + + insert into t_processes + (process_id, title, description, mime_type, workflow_id) + values + (v_process_id, p_title, p_description, p_mime_type, p_workflow_id); + + return v_process_id; +end; +' language 'plpgsql'; + + +select define_function_args('tasks_process_instance__new','process_instance_id,process_id,case_id,party_id,object_id,package_id,creation_user,creation_ip,context_id'); + +create or replace function tasks_process_instance__new (integer,integer,integer,integer,integer,integer,integer,varchar,integer) +returns integer as ' +declare + p_process_instance_id alias for $1; + p_process_id alias for $2; + p_case_id alias for $3; + p_party_id alias for $4; + p_object_id alias for $5; + p_package_id alias for $6; + p_creation_user alias for $7; + p_creation_ip alias for $8; + p_context_id alias for $9; + v_process_instance_id integer; +begin + v_process_instance_id:= acs_object__new( + p_process_instance_id, + ''tasks_process_instance'', + now(), + p_creation_user, + p_creation_ip, + coalesce(p_context_id, p_package_id), + ''t'', + ''process instance of process '' || p_process_id || '' for object '' || p_object_id, + p_package_id + ); + + insert into t_process_instances + (process_instance_id, process_id, case_id, party_id, object_id) + values + (v_process_instance_id, p_process_id, p_case_id, p_party_id, p_object_id); + + return v_process_instance_id; +end; +' language 'plpgsql'; Index: openacs-4/packages/tasks/sql/postgresql/tasks-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/sql/postgresql/tasks-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/sql/postgresql/tasks-drop.sql 25 Sep 2005 23:49:23 -0000 1.1 @@ -0,0 +1,7 @@ +drop table t_process_tasks; +drop table t_tasks; +drop table t_task_status; +drop table t_process_instances; +drop table t_processes; + +drop sequence t_task_status_seq; Index: openacs-4/packages/tasks/tcl/tasks-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/tcl/tasks-callback-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/tcl/tasks-callback-procs.tcl 27 Jul 2005 13:44:59 -0000 1.1 +++ openacs-4/packages/tasks/tcl/tasks-callback-procs.tcl 25 Sep 2005 23:49:23 -0000 1.2 @@ -5,11 +5,16 @@ Callback procs for Tasks @author Matthew Geddert (openacs@geddert.com) + @author Timo Hentschel (timo@timohentschel.de) @creation-date 2005-06-15 @arch-tag: 200d82ba-f8e7-4f19-9740-39117474766f @cvs-id $Id$ } +namespace eval tasks::workflow {} +namespace eval tasks::workflow::impl {} +namespace eval tasks::workflow::impl::action_side_effect {} + ad_proc -public -callback contact::history -impl tasks { {-party_id:required} {-multirow:required} @@ -57,3 +62,58 @@ } { ::template::multirow append $multirow "Add Task" "/tasks/task" "Add a task to the selected contacts" } + + +ad_proc -public tasks::workflow::impl::action_side_effect::do { + case_id + object_id + action_id + entry_id +} { + create new tasks linked to this action +} { + db_1row process_id { + select process_instance_id, process_id, party_id + from t_process_instances + where case_id = :case_id + } + + set tasks [db_list_of_lists process_tasks { + select task_id, title, description, + mime_type, comment, status_id, priority, + to_char((now()+ (start::varchar || ' days')::interval), 'YYYY-MM-DD') as start_date, + to_char((now()+ (due::varchar || ' days')::interval), 'YYYY-MM-DD') as due_date + from t_process_tasks + where open_action_id = :action_id + }] + + foreach task $tasks { + util_unlist $task process_task_id title description mime_type comment status_id priority start_date due_date + + set new_task_id [tasks::task::new \ + -process_instance_id $process_instance_id \ + -process_task_id $process_task_id \ + -party_id $party_id \ + -object_id $object_id \ + -title $title \ + -description $description \ + -mime_type $mime_type \ + -comment $comment \ + -status_id $status_id \ + -priority $priority \ + -start_date $start_date \ + -due_date $due_date] + } +} + +ad_proc -public tasks::workflow::impl::action_side_effect::object_type {} { + Get the object type for which this implementation is valid. +} { + return "acs_object" +} + +ad_proc -public tasks::workflow::impl::action_side_effect::pretty_name {} { + Get the pretty name of this implementation. +} { + return "tasks" +} Index: openacs-4/packages/tasks/tcl/tasks-install-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/tcl/tasks-install-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/tcl/tasks-install-procs.tcl 25 Sep 2005 23:49:23 -0000 1.1 @@ -0,0 +1,44 @@ +ad_library { + + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2005-09-21 + @arch-tag: 81868d37-99f5-48b1-8336-88e22c0e9001 + @cvs-id $Id: +} + +namespace eval tasks::install {} + +ad_proc -public tasks::install::package_install { +} { + Procedure to install certain information right after startup + + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2005-09-21 + +} { + set spec { + name "Tasks_Action_SideEffect" + aliases { + GetObjectType tasks::workflow::impl::action_side_effect::object_type + GetPrettyName tasks::workflow::impl::action_side_effect::pretty_name + DoSideEffect tasks::workflow::impl::action_side_effect::do + } + } + + lappend spec contract_name [workflow::service_contract::action_side_effect] + lappend spec owner tasks + + acs_sc::impl::new_from_spec -spec $spec +} + + +ad_proc -public tasks::install::after_upgrade { + {-from_version_name:required} + {-to_version_name:required} +} { + apm_upgrade_logic \ + -from_version_name $from_version_name \ + -to_version_name $to_version_name \ + -spec { + } +} Index: openacs-4/packages/tasks/tcl/tasks-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/tcl/tasks-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/tcl/tasks-procs.tcl 27 Jul 2005 13:44:58 -0000 1.1 +++ openacs-4/packages/tasks/tcl/tasks-procs.tcl 25 Sep 2005 23:49:23 -0000 1.2 @@ -9,6 +9,10 @@ } namespace eval tasks {} +namespace eval tasks::task {} +namespace eval tasks::process {} +namespace eval tasks::process::task {} +namespace eval tasks::process::instance {} ad_proc -public tasks::project_id { @@ -53,3 +57,169 @@ } +ad_proc -public tasks::task::new { + {-task_id ""} + {-process_instance_id ""} + {-process_task_id ""} + {-party_id ""} + {-object_id ""} + -title:required + {-description ""} + {-mime_type "text/plain"} + {-comment ""} + {-status_id 1} + {-priority 0} + {-start_date ""} + {-due_date ""} + {-package_id ""} +} { + if { [empty_string_p $package_id] } { + set package_id [ad_conn package_id] + } + set extra_vars [ns_set create] + set context_id $package_id + + oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {task_id process_instance_id process_task_id party_id object_id title description mime_type comment status_id priority start_date due_date package_id context_id} + + set task_id [package_instantiate_object -extra_vars $extra_vars tasks_task] + + return $task_id +} + +ad_proc -public tasks::task::edit { + -task_id:required + -title:required + {-description ""} + {-mime_type "text/plain"} + {-comment ""} + {-status_id 1} + {-priority 0} + {-due_date ""} +} { + set modifying_user [ad_conn user_id] + set modifying_ip [ad_conn peeraddr] + + db_dml update_task {} + db_dml update_object {} +} + +ad_proc -public tasks::task::complete { + -task_id:required +} { + db_transaction { + db_dml set_status_done {} + + if {[db_0or1row closing_action {}]} { + workflow::case::action::execute -case_id $case_id -action_id $closing_action_id -no_perm_check -no_notification + } + } +} + + +ad_proc -public tasks::process::task::new { + {-task_id ""} + -process_id:required + -open_action_id:required + -closing_action_id:required + {-party_id ""} + {-object_id ""} + -title:required + {-description ""} + {-mime_type "text/plain"} + {-comment ""} + {-status_id 1} + {-priority 0} + {-start 0} + {-due 0} + {-package_id ""} +} { + if { [empty_string_p $package_id] } { + set package_id [ad_conn package_id] + } + set extra_vars [ns_set create] + set context_id $package_id + + oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {task_id process_id open_action_id closing_action_id party_id object_id title description mime_type comment status_id priority start due package_id context_id} + + set task_id [package_instantiate_object -extra_vars $extra_vars tasks_process_task] + + return $task_id +} + +ad_proc -public tasks::process::task::edit { + -task_id:required + -open_action_id:required + {-party_id ""} + {-object_id ""} + -title:required + {-description ""} + {-mime_type "text/plain"} + {-comment ""} + {-status_id 1} + {-priority 0} + {-start 0} + {-due 0} +} { + set modifying_user [ad_conn user_id] + set modifying_ip [ad_conn peeraddr] + + db_dml update_process_task {} + db_dml update_object {} +} + + +ad_proc -public tasks::process::new { + {-process_id ""} + -title:required + {-description ""} + {-mime_type "text/plain"} + {-workflow_id ""} + {-package_id ""} +} { + if { [empty_string_p $package_id] } { + set package_id [ad_conn package_id] + } + set extra_vars [ns_set create] + set context_id $package_id + + oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {process_id title description mime_type workflow_id package_id context_id} + + set task_id [package_instantiate_object -extra_vars $extra_vars tasks_process] + + return $task_id +} + +ad_proc -public tasks::process::edit { + -process_id:required + -title:required + {-description ""} + {-mime_type "text/plain"} +} { + set modifying_user [ad_conn user_id] + set modifying_ip [ad_conn peeraddr] + + db_dml update_process {} + db_dml update_object {} +} + + +ad_proc -public tasks::process::instance::new { + {-process_instance_id ""} + -process_id:required + -case_id:required + {-party_id ""} + {-object_id ""} + {-package_id ""} +} { + if { [empty_string_p $package_id] } { + set package_id [ad_conn package_id] + } + set extra_vars [ns_set create] + set context_id $package_id + + oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {process_instance_id process_id case_id party_id object_id package_id context_id} + + set task_id [package_instantiate_object -extra_vars $extra_vars tasks_process_instance] + + return $task_id +} Index: openacs-4/packages/tasks/tcl/tasks-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/tcl/tasks-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/tcl/tasks-procs.xql 25 Sep 2005 23:49:23 -0000 1.1 @@ -0,0 +1,111 @@ + + + + + + + update t_tasks + set status_id = 2, + completed_date = now() + where task_id = :task_id + + + + + + + + select pt.closing_action_id, pi.case_id + from t_process_tasks pt, t_tasks t, t_process_instances pi + where pt.task_id = t.process_task_id + and pi.process_instance_id = t.process_instance_id + and t.task_id = :task_id + + + + + + + + update t_tasks + set title = :title, + description = :description, + mime_type = :mime_type, + comment = :comment, + status_id = :status_id, + priority = :priority, + due_date = :due_date + where task_id = :task_id + + + + + + + + update acs_objects + set modifying_user = :modifying_user, + modifying_ip = :modifying_ip, + last_modified = now() + where object_id = :task_id + + + + + + + + update t_process_tasks + set open_action_id = :open_action_id, + party_id = :party_id, + object_id = :object_id, + title = :title, + description = :description, + mime_type = :mime_type, + comment = :comment, + status_id = :status_id, + priority = :priority, + start = :start, + due = :due + where task_id = :task_id + + + + + + + + update acs_objects + set modifying_user = :modifying_user, + modifying_ip = :modifying_ip, + last_modified = now() + where object_id = :task_id + + + + + + + + update t_processes + set title = :title, + description = :description, + mime_type = :mime_type + where process_id = :process_id + + + + + + + + update acs_objects + set modifying_user = :modifying_user, + modifying_ip = :modifying_ip, + last_modified = now() + where object_id = :process_id + + + + + Index: openacs-4/packages/tasks/www/contact.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/contact.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/www/contact.tcl 27 Jul 2005 13:45:00 -0000 1.1 +++ openacs-4/packages/tasks/www/contact.tcl 25 Sep 2005 23:49:23 -0000 1.2 @@ -23,7 +23,6 @@ {searchterm ""} {mine_p "t"} {status_id "1"} - {role_id "2"} {process_instance:integer,optional} } -properties { task_term:onevalue @@ -43,25 +42,17 @@ if { ![exists_and_not_null status_id] } { set status_id "1" } -set done_url [export_vars -url -base "./contact" {orderby {status_id 2} party_id}] -set not_done_url [export_vars -url -base "./contact" {orderby {status_id 1} party_id}] -set return_url [export_vars -base "/tasks/contact" -url {orderby status_id party_id}] +set done_url [export_vars -url -base "contact" {orderby {status_id 2} party_id}] +set not_done_url [export_vars -url -base "contact" {orderby {status_id 1} party_id}] +set return_url [export_vars -base [ad_conn url] -url {orderby status_id party_id}] set add_url [export_vars -base task {return_url orderby status_id party_id}] set add_event_url [export_vars -base "/calendar/cal-item-new" -url {return_url party_id}] -set admin_p [permission::permission_p -object_id [ad_conn package_id] -privilege admin] -set task_term [ad_conn instance_name] +set package_id [ad_conn package_id] +set admin_p [permission::permission_p -object_id $package_id -privilege admin] set context {} -# -bulk_actions { -# "Mark Completed" "mark-completed" "Mark Completed" -# "Delete" "delete" "Delete" -# } \ -# -bulk_action_export_vars { -# {return_url} {orderby} {party_id} -# } \ - template::list::create \ -name tasks \ -multirow tasks \ @@ -93,24 +84,28 @@ } } - process { + process_title { label "[_ tasks.Process]" display_template { - @tasks.process@ + @tasks.process_title@ - - « @tasks.process@ » - + @tasks.process_title@ } } + contact { + label "[_ tasks.Contact]" + display_template { + @tasks.contact@ + } + } date { label "[_ tasks.Date]" display_template { @tasks.completed_date;noquote@ - - « @tasks.end_date;noquote@ » + + « @tasks.due_date;noquote@ » } @@ -128,81 +123,80 @@ -filters { party_id {} } -orderby { - default_value $orderby + default_value "priority,desc" date { label "[_ tasks.Due]" - orderby_desc "CASE WHEN pt.status = 1 THEN ptr.end_date ELSE tasks__completion_date(ci.item_id) END desc, ptr.priority, upper(cr.title)" - orderby_asc "CASE WHEN pt.status = 1 THEN ptr.end_date ELSE tasks__completion_date(ci.item_id) END asc, ptr.priority, upper(cr.title)" + orderby_desc "CASE WHEN t.status_id = 1 THEN t.due_date ELSE t.completed_date END desc, t.priority, lower(t.title)" + orderby_asc "CASE WHEN t.status_id = 1 THEN t.due_date ELSE t.completed_date END asc, t.priority, lower(t.title)" default_direction desc } priority { label "[_ tasks.Priority]" - orderby_desc "pt.status, ptr.priority desc, CASE WHEN pt.status = 1 THEN ptr.end_date ELSE tasks__completion_date(ci.item_id) END desc, upper(cr.title)" - orderby_asc "pt.status, ptr.priority asc, CASE WHEN pt.status = 1 THEN ptr.end_date ELSE tasks__completion_date(ci.item_id) END asc, upper(cr.title)" + orderby_desc "t.status_id, t.priority desc, CASE WHEN t.status_id = 1 THEN t.due_date ELSE t.completed_date END desc, lower(t.title)" + orderby_asc "t.status_id, t.priority asc, CASE WHEN t.status_id = 1 THEN t.due_date ELSE t.completed_date END asc, lower(t.title)" default_direction desc } title { label "[_ tasks.Task]" - orderby_desc "upper(cr.title) desc, ptr.priority desc, ptr.end_date asc" - orderby_asc "upper(cr.title) asc, ptr.priority desc, ptr.end_date asc" + orderby_desc "lower(t.title) desc, t.priority desc, t.due_date asc" + orderby_asc "lower(t.title) asc, t.priority desc, t.due_date asc" default_direction asc } - process { + process_title { label "[_ tasks.Process]" - orderby_desc "upper(ppi.name) desc, ptr.priority desc, ptr.end_date asc" - orderby_asc "upper(ppi.name) asc, ptr.priority desc, ptr.end_date asc" + orderby_desc "lower(p.title) desc, t.priority desc, t.due_date asc" + orderby_asc "lower(p.title) asc, t.priority desc, t.due_date asc" default_direction asc } + contact { + label "[_ tasks.Contact]" + orderby_desc "lower(contact__name(t.object_id)) desc, t.due_date asc, t.priority, lower(t.title)" + orderby_asc "lower(contact__name(t.object_id)) asc, t.due_date asc, t.priority, lower(t.title)" + default_direction asc + } creation_user { label "[_ tasks.Created_By]" - orderby_desc "upper(contact__name(ao.creation_user)) desc, ptr.end_date asc, ptr.priority, upper(cr.title)" - orderby_asc "upper(contact__name(ao.creation_user)) asc, ptr.end_date asc, ptr.priority, upper(cr.title)" + orderby_desc "lower(contact__name(ao.creation_user)) desc, t.due_date asc, t.priority, lower(t.title)" + orderby_asc "lower(contact__name(ao.creation_user)) asc, t.due_date asc, t.priority, lower(t.title)" default_direction asc } } - -set project_id [tasks::project_id] -db_multirow -extend {creation_user_url complete_url done_p process_plus_url process_minus_url task_plus_url task_minus_url description_html task_url} -unclobber tasks get_tasks " - select pt.task_id, - tasks__relative_date(ptr.end_date) as end_date, - tasks__relative_date(tasks__completion_date(ci.item_id)) as completed_date, - cr.title, - cr.description, - ptr.priority, - :party_id as party_id, - ppi.name as process, - ppi.process_id as process_id, - ao.creation_user, +db_multirow -extend {creation_user_url contact_url complete_url done_p process_plus_url process_minus_url task_plus_url task_minus_url description_html task_url} -unclobber tasks get_tasks " + select t.task_id, t.title, t.description, t.mime_type, t.priority, + t.party_id, p.title as process_title, p.process_id, + tasks__relative_date(t.due_date) as due_date, + tasks__relative_date(t.completed_date) as completed_date, + ao.creation_user, t.status_id, t.process_instance_id, contact__name(ao.creation_user) as creation_name, - pt.status as status_id, - pt.process_instance, - CASE WHEN ptr.end_date < now() THEN 't' ELSE 'f' END as end_date_passed_p - from cr_items ci, - pm_tasks_revisions ptr, - pm_tasks pt left join pm_process_instance ppi on (pt.process_instance = ppi.instance_id ), - cr_revisions cr, - acs_objects ao - where ci.parent_id = :project_id - and ci.item_id = pt.task_id - and ci.latest_revision = ptr.task_revision_id - and ci.live_revision = ptr.task_revision_id - and ptr.task_revision_id = cr.revision_id - and cr.revision_id = ao.object_id - and pt.deleted_p = 'f' - and task_id in ( select task_id from pm_task_assignment where party_id = :party_id and role_id = '1' ) + CASE WHEN t.due_date < now() THEN 't' ELSE 'f' END as due_date_passed_p, + s.title as status, t.object_id, + contact__name(t.object_id) as contact + from t_task_status s, acs_objects ao, t_tasks t + left outer join t_process_instances pi + on (pi.process_instance_id = t.process_instance_id) + left outer join t_processes p + on (p.process_id = pi.process_id) + where s.status_id = t.status_id + and ao.object_id = t.task_id + and ao.package_id = :package_id + and t.party_id = :party_id + and t.start_date < now() [template::list::orderby_clause -orderby -name tasks] " { set creation_user_url [contact::url -party_id $creation_user] + if {![empty_string_p $object_id]} { + set contact_url [contact::url -party_id $object_id] + } regsub -all "/tasks/" $creation_user_url "/contacts/" creation_user_url set complete_url [export_vars -base "mark-completed" -url {task_id orderby party_id return_url}] if { $status_id == "2" } { set done_p 1 } else { set done_p 0 } - set task_url [export_vars -base task -url {party_id orderby status task_id}] + set task_url [export_vars -base task -url {party_id orderby status_id task_id}] set task_plus_url [export_vars -base task-interval -url {{action plus} {days 7} party_id task_id status_id orderby return_url}] set task_minus_url [export_vars -base task-interval -url {{action minus} {days 7} party_id task_id status_id orderby return_url}] set process_plus_url [export_vars -base process-interval -url {{action plus} {days 7} party_id process_instance status_id orderby return_url}] @@ -211,7 +205,7 @@ regsub -all "\r|\n" $description {LiNeBrEaK} description set description_html [ad_html_text_convert \ - -from "text/plain" \ + -from $mime_type \ -to "text/html" \ -truncate_len "400" \ -more "[_ tasks.more]" \ @@ -222,7 +216,7 @@ # 167 is the actual paragraph standard internationally but 182 is more common in the US regsub -all {LiNeBrEaK} $description_html {\ \ \¶\ } description_html - regsub -all " " $end_date {\ } end_date + regsub -all " " $due_date {\ } due_date regsub -all " " $completed_date {\ } completed_date } Index: openacs-4/packages/tasks/www/delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/delete.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/tasks/www/delete.tcl 27 Jul 2005 14:29:51 -0000 1.2 +++ openacs-4/packages/tasks/www/delete.tcl 25 Sep 2005 23:49:23 -0000 1.3 @@ -20,10 +20,11 @@ ad_returnredirect ./ return } - set task_pretty [ad_decode $num_entries 1 "[_ tasks.a_Task]" "[_ tasks.Tasks]"] + set task_pretty [ad_decode $num_entries 1 "[_ tasks.Task]" "[_ tasks.Tasks]"] set title "[_ tasks.Delete_task_pretty]" set context [list $title] - set task2_pretty [ad_decode $num_entries 1 "[_ tasks.this_task]" "[_ tasks.lt_these_num_entries_tas]"] + set task2_pretty [ad_decode $num_entries 1 "[_ tasks.this_task]" "[_ tasks.these_tasks]"] + set context [list $title] set question "[_ tasks.lt_Are_you_sure_you_want_1]" set yes_url "delete?[export_vars { task_id:multiple { confirm_p 1 } return_url}]" set no_url "${return_url}" @@ -34,17 +35,15 @@ set task_titles [list] foreach task_id $task_id { lappend task_titles [db_string get_task_title { - select cr.title as task - from pm_tasks_revisions ptr, - cr_revisions cr, - cr_items ci - where ci.item_id = :task_id - and ci.latest_revision = ptr.task_revision_id - and ci.live_revision = ptr.task_revision_id - and ptr.task_revision_id = cr.revision_id - + select t.title + from t_tasks + where t.task_id = :task_id }] - db_dml mark_delete "update pm_tasks set deleted_p = 't' where task_id = :task_id" + db_dml mark_delete { + update t_tasks + set status_id = null + where task_id = :task_id + } } if { $num_entries > 1 } { @@ -61,12 +60,9 @@ } util_user_message -html -message "[_ tasks.lt_The_tasks_task_list_w]" } else { + set task_title [lindex $task_titles 0] util_user_message -html -message "[_ tasks.lt_The_task_lindex_task_]" } ad_returnredirect $return_url ad_script_abort - - - - Index: openacs-4/packages/tasks/www/index-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/index-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/www/index-postgresql.xql 27 Jul 2005 13:44:59 -0000 1.1 +++ openacs-4/packages/tasks/www/index-postgresql.xql 25 Sep 2005 23:49:23 -0000 1.2 @@ -2,55 +2,60 @@ postgresql7.2 - + - SELECT - ts.task_id as task_item_id, - ts.task_number, - t.task_revision_id, - t.title, - t.description, - t.parent_id as project_item_id, - proj_rev.logger_project, - proj_rev.title as project_name, - to_char(t.earliest_start,'J') as earliest_start_j, - to_char(current_timestamp,'J') as today_j, - to_char(t.latest_start,'J') as latest_start_j, - to_char(t.latest_start,'YYYY-MM-DD HH24:MI') as latest_start, - to_char(t.latest_finish,'YYYY-MM-DD HH24:MI') as latest_finish, - t.percent_complete, - t.estimated_hours_work, - t.estimated_hours_work_min, - t.estimated_hours_work_max, - case when t.actual_hours_worked is null then 0 - else t.actual_hours_worked end as actual_hours_worked, - to_char(t.earliest_start,'YYYY-MM-DD HH24:MI') as earliest_start, - to_char(t.earliest_finish,'YYYY-MM-DD HH24:MI') as earliest_finish, - to_char(t.latest_start,'YYYY-MM-DD HH24:MI') as latest_start, - to_char(t.latest_finish,'YYYY-MM-DD HH24:MI') as latest_finish, - p.first_names || ' ' || p.last_name as full_name, - r.one_line as role - FROM - pm_tasks_active ts, - cr_items i, - pm_tasks_revisionsx t - LEFT JOIN pm_task_assignment ta - ON t.item_id = ta.task_id - LEFT JOIN persons p - ON ta.party_id = p.person_id - LEFT JOIN pm_roles r - ON ta.role_id = r.role_id, - cr_items proj, - pm_projectsx proj_rev - WHERE - ts.task_id = t.item_id and - i.item_id = t.item_id and - t.task_revision_id = i.live_revision and - t.parent_id = proj.item_id and - proj.live_revision = proj_rev.revision_id - [template::list::filter_where_clauses -and -name tasks] + select t.task_id, t.title, t.party_id, t.priority, s.title as status, + tasks__relative_date(t.due_date) as due_date, + CASE WHEN t.due_date < now() THEN 't'::boolean ELSE 'f'::boolean END as overdue_p, + to_char(t.due_date,'YYYY-MM-DD HH24:MI') as due_date, + contact__name(t.party_id, :name_order) as contact_name, + p.title as process_title, p.process_id + from t_task_status s, acs_objects ot, t_tasks t + left outer join t_process_instances pi + on (pi.process_instance_id = t.process_instance_id) + left outer join t_processes p + on (p.process_id = pi.process_id) + where s.status_id = t.status_id + and ot.object_id = t.task_id + and ot.package_id = :package_id + and t.start_date > now() + and t.due_date < ( now() + '$tasks_interval days'::interval ) + [template::list::page_where_clause -and -name tasks -key t.task_id] [template::list::orderby_clause -orderby -name tasks] + + + select t.task_id + from t_task_status s, acs_objects ot, t_tasks t + left outer join t_process_instances pi + on (pi.process_instance_id = t.process_instance_id) + left outer join t_processes p + on (p.process_id = pi.process_id) + where s.status_id = t.status_id + and ot.object_id = t.task_id + and ot.package_id = :package_id + and t.start_date > now() + and t.due_date < ( now() + '$tasks_interval days'::interval ) + [template::list::orderby_clause -orderby -name tasks] + + + + + + select count(*) + from t_task_status s, acs_objects ot, t_tasks t + left outer join t_process_instances pi + on (pi.process_instance_id = t.process_instance_id) + left outer join t_processes p + on (p.process_id = pi.process_id) + where s.status_id = t.status_id + and ot.object_id = t.task_id + and ot.package_id = :package_id + and t.start_date > now() + and t.due_date < ( now() + '$tasks_interval days'::interval ) + + + Index: openacs-4/packages/tasks/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/index.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/www/index.tcl 27 Jul 2005 13:44:59 -0000 1.1 +++ openacs-4/packages/tasks/www/index.tcl 25 Sep 2005 23:49:23 -0000 1.2 @@ -5,7 +5,7 @@ @creation-date 2004-07-28 @cvs-id $Id$ } { - {orderby "end_date,asc"} + {orderby "due_date,asc"} {format "normal"} {search_id:integer ""} {query ""} @@ -16,12 +16,14 @@ } -set title "Tasks" +set title "[_ tasks.Tasks]" set context {} set project_id [tasks::project_id] set user_id [ad_conn user_id] +set package_id [ad_conn package_id] +set url [ad_conn url] -set return_url [export_vars -base "/tasks/" -url {orderby format search_id query page page_size tasks_interval {page_flush_p t}}] +set return_url [export_vars -base $url -url {orderby format search_id query page page_size tasks_interval {page_flush_p t}}] if { $orderby == "contact_name,asc" } { @@ -33,8 +35,6 @@ } - - set first_p 1 foreach page_s [list 25 50 100 500] { if { [string is false $first_p] } { @@ -48,8 +48,7 @@ set first_p 0 } -set admin_p [permission::permission_p -object_id [ad_conn package_id] -privilege admin] -set task_term [ad_conn instance_name] +set admin_p [permission::permission_p -object_id $package_id -privilege admin] set context {} template::list::create \ @@ -61,41 +60,41 @@ -page_query_name tasks_pagination \ -elements { priority { - label "Priority" + label "[_ tasks.Priority]" } contact_name { - label "Contact" + label "[_ tasks.Contact]" link_url_eval $contact_url } title { - label "Task" + label "[_ tasks.Task]" display_template { - @tasks.title@ + @tasks.title@ } } - process { - label "Process" + process_title { + label "[_ tasks.Process]" } - end_date { - label "Due" + due_date { + label "[_ tasks.Due]" display_template { - @tasks.end_date@ + @tasks.due_date@ - @tasks.end_date@ + @tasks.due_date@ } } } \ -bulk_actions [list \ - "Mark Completed" "mark-completed" "Mark Completed" \ - "Delete" "delete" "Delete" \ + "[_ tasks.Mark_Completed]" "mark-completed" "[_ tasks.Mark_Completed]" \ + "[_ tasks.Delete]" "delete" "[_ tasks.Delete]" \ "[_ contacts.Mail_Merge]" "mail-merge" "[_ contacts.lt_E-mail_or_Mail_the_se]" \ ]\ -bulk_action_export_vars { {return_url} - } \ + } -pass_properties { } \ -sub_class { narrow } \ @@ -108,34 +107,34 @@ } \ -orderby { default_value $orderby - end_date { + due_date { label "Due" - orderby_desc "ptr.end_date desc, ptr.priority, upper(cr.title)" - orderby_asc "ptr.end_date asc, ptr.priority, upper(cr.title)" + orderby_desc "t.due_date desc, t.priority, lower(t.title)" + orderby_asc "t.due_date asc, t.priority, lower(t.title)" default_direction asc } priority { label "Priority" - orderby_desc "ptr.priority desc, ptr.end_date asc, upper(cr.title)" - orderby_asc "ptr.priority asc, ptr.end_date asc, upper(cr.title)" + orderby_desc "t.priority desc, t.due_date asc, lower(t.title)" + orderby_asc "t.priority asc, t.due_date asc, lower(t.title)" default_direction desc } title { label "Task" - orderby_desc "upper(cr.title) desc, ptr.priority desc, ptr.end_date asc" - orderby_asc "upper(cr.title) asc, ptr.priority desc, ptr.end_date asc" + orderby_desc "lower(t.title) desc, t.priority desc, t.due_date asc" + orderby_asc "lower(t.title) asc, t.priority desc, t.due_date asc" default_direction asc } contact_name { label "Contact" - orderby_asc "lower(contact__name(assigned_tasks.party_id,'1'::boolean)) asc" - orderby_desc "lower(contact__name(assigned_tasks.party_id,'0'::boolean)) asc" + orderby_asc "lower(contact__name(t.party_id,'1'::boolean)) asc" + orderby_desc "lower(contact__name(t.party_id,'0'::boolean)) asc" default_direction asc } - process { + process_title { label "Process" - orderby_desc "upper(ppi.name) desc, ptr.priority desc, ptr.end_date asc" - orderby_asc "upper(ppi.name) asc, ptr.priority desc, ptr.end_date asc" + orderby_desc "lower(p.title) desc, t.priority desc, t.due_date asc" + orderby_asc "lower(p.title) asc, t.priority desc, t.due_date asc" default_direction asc } } @@ -148,7 +147,6 @@ set tasks_count [db_string tasks_count {} -default {0}] -set package_id "11426862" if { [exists_and_not_null search_id] } { contact::search::log -search_id $search_id } @@ -164,7 +162,7 @@ {search_id:integer(select),optional {label ""} {options $search_options} {html {onChange "javascript:acs_FormRefresh('search')"}}} {query:text(text),optional {label ""} {html {size 20 maxlength 255}}} {save:text(submit) {label {[_ contacts.Search]}} {value "go"}} - {tasks_interval:integer(text),optional {label "  View next"} {after_html "days    Results: $tasks_count"} {html {size 2 maxlength 3 onChange "javascript:acs_FormRefresh('search')"}}} + {tasks_interval:integer(text),optional {label "  [_ tasks.View_next]"} {after_html "days    Results: $tasks_count"} {html {size 2 maxlength 3 onChange "javascript:acs_FormRefresh('search')"}}} } if { [parameter::get -boolean -parameter "ForceSearchBeforeAdd" -default "0"] } { Index: openacs-4/packages/tasks/www/index.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/index.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/www/index.xql 27 Jul 2005 13:44:59 -0000 1.1 +++ openacs-4/packages/tasks/www/index.xql 25 Sep 2005 23:49:23 -0000 1.2 @@ -1,7 +1,7 @@ - + select pt.task_id from cr_items ci, @@ -34,7 +34,7 @@ - + select count(*) from cr_items ci, @@ -66,7 +66,7 @@ - + select pt.task_id, tasks__relative_date(ptr.end_date) as end_date, Index: openacs-4/packages/tasks/www/mark-completed.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/mark-completed.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/www/mark-completed.tcl 27 Jul 2005 13:45:00 -0000 1.1 +++ openacs-4/packages/tasks/www/mark-completed.tcl 25 Sep 2005 23:49:23 -0000 1.2 @@ -11,7 +11,6 @@ {orderby ""} {return_url:notnull} } -# {party_id:integer,notnull} set num_entries [llength $task_id] @@ -21,31 +20,30 @@ ad_returnredirect ./ return } - set title "Mark [ad_decode $num_entries 1 "Task" "Tasks"] as Done" + set pretty_task [ad_decode $num_entries 1 "[_ tasks.Task]" "[_ tasks.Tasks]"] + set title "[_ tasks.Mark_Done]" set context [list $title] - set question "Are you sure you want to mark [ad_decode $num_entries 1 "this task" "these $num_entries tasks"] as done?" - set yes_url "mark-done?[export_vars { task_id:multiple { confirm_p 1 } status_id orderby party_id}]" + set pretty_entries [ad_decode $num_entries 1 "[_ tasks.this_task]" "[_ tasks.these_tasks]"] + set question "[_ tasks.completed_sure]" + set yes_url "mark-completed?[export_vars { task_id:multiple { confirm_p 1 } status_id orderby party_id}]" set no_url "./?[export_vars { status_id orderby party_id}]" return } set user_id [ad_conn user_id] -set task_titles [list] -foreach task_id $task_id { - set task_title [db_string get_task_title { - select cr.title as task - from pm_tasks_revisions ptr, - cr_revisions cr, - cr_items ci - where ci.item_id = :task_id - and ci.latest_revision = ptr.task_revision_id - and ci.live_revision = ptr.task_revision_id - and ptr.task_revision_id = cr.revision_id - - }] - lappend task_titles "${task_title}" - pm::task::update_percent -task_item_id $task_id -percent_complete "100" +db_transaction { + set task_titles [list] + foreach task_id $task_id { + set task_title [db_string get_task_title { + select t.title + from t_tasks t + where t.task_id = :task_id + }] + lappend task_titles "${task_title}" + + tasks::task::complete -task_id $task_id + } } @@ -61,15 +59,11 @@ append task_list "\"${task_title}\"" incr num } - util_user_message -html -message "The tasks ${task_list} were marked done" + util_user_message -html -message "[_ tasks.tasks_completed]" } else { - util_user_message -html -message "The task \"[lindex $task_titles 0]\" was marked done" + set task_title [lindex $task_titles 0] + util_user_message -html -message "[_ tasks.task_completed]" } -#util_user_message -message "[ad_decode $num_entries 1 "One task" "$num_entries tasks"] marked done." ad_returnredirect $return_url ad_script_abort - - - - Index: openacs-4/packages/tasks/www/process-add-edit-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/process-add-edit-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/www/process-add-edit-postgresql.xql 27 Jul 2005 13:44:59 -0000 1.1 +++ openacs-4/packages/tasks/www/process-add-edit-postgresql.xql 25 Sep 2005 23:49:23 -0000 1.2 @@ -1,47 +1,10 @@ - - - select current_timestamp from dual; - - - - - insert into pm_process - (process_id, - one_line, - description, - party_id, - creation_date) - values - (:process_id, - :one_line, - :description, - :party_id, - :creation_date) - - - - - - update pm_process - set one_line = :one_line, - description = :description, - party_id = :party_id - - - - select - process_id, - one_line, - description, - party_id, - creation_date - from - pm_process + select title, description, workflow_id + from t_processes where process_id = :process_id Index: openacs-4/packages/tasks/www/process-add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/process-add-edit.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/www/process-add-edit.tcl 27 Jul 2005 13:44:59 -0000 1.1 +++ openacs-4/packages/tasks/www/process-add-edit.tcl 25 Sep 2005 23:49:23 -0000 1.2 @@ -8,33 +8,19 @@ @return context_bar Context bar. @return title Page title. - } { - process_id:integer,optional - {one_line ""} - {description ""} - {number_of_tasks:integer ""} - + assignee_id:integer,optional } -properties { - context_bar:onevalue title:onevalue - } - -# --------------------------------------------------------------- # -# the unique identifier for this package set package_id [ad_conn package_id] set user_id [ad_maybe_redirect_for_registration] -# terminology and parameters -set project_term [parameter::get -parameter "ProjectName" -default "Project"] -set project_term_lower [parameter::get -parameter "projectname" -default "project"] - if { ![ad_form_new_p -key process_id] } { - set process [db_string process_get { select one_line from pm_process where process_id = :process_id}] + set process [db_string process_get { select title from t_processes where process_id = :process_id}] set title "Edit: $process" set context [list [list "processes" Processes] [list [export_vars -base "process" -url {process_id}] $process] "Edit"] # permissions @@ -49,39 +35,60 @@ ad_form -name add_edit -form { process_id:key + assignee_id:text(hidden),optional + workflow_id:text(hidden),optional - {one_line:text + {title:text {label "Process"} - {value $one_line} - {html {size 40}} + {html {size 80}} } {description:text(textarea),optional {label "Description"} - {value $description} {html { rows 5 cols 40 wrap soft}}} -} -select_query_name process_query -on_submit { +} -select_query_name process_query -new_data { - set party_id [ad_conn user_id] - set creation_date [db_string get_today { }] + db_transaction { + set workflow_id [workflow::new \ + -short_name "tasks_process_$process_id" \ + -pretty_name "tasks process $process_id" \ + -package_key tasks] -} -new_data { - set process_id [db_nextval pm_process_seq] + set state_id [workflow::state::fsm::new \ + -workflow_id $workflow_id \ + -short_name new \ + -pretty_name New] - db_dml new_process { *SQL* } + workflow::action::fsm::new \ + -workflow_id $workflow_id \ + -short_name new \ + -pretty_name New \ + -new_state_id $state_id \ + -callbacks "tasks.Tasks_Action_SideEffect" \ + -initial_action_p t - ad_returnredirect -message "Process added. Now add a process task." [export_vars -base process-task -url { process_id}] + set process_id [tasks::process::new \ + -process_id $process_id \ + -title $title \ + -description $description \ + -mime_type "text/plain" \ + -workflow_id $workflow_id] + } + + ad_returnredirect -message "Process added. Now add a process task." [export_vars -base process-task -url {process_id assignee_id}] ad_script_abort } -edit_data { - db_dml edit_process { *SQL* } + tasks::process::edit \ + -process_id $process_id \ + -title $title \ + -description $description \ + -mime_type "text/plain" } -after_submit { - ad_returnredirect -message "Process changes saved." [export_vars -base process -url {process_id}] + ad_returnredirect -message "Process changes saved." [export_vars -base process -url {process_id assignee_id}] ad_script_abort } - - Index: openacs-4/packages/tasks/www/process-assign.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/process-assign.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/www/process-assign.tcl 27 Jul 2005 13:45:00 -0000 1.1 +++ openacs-4/packages/tasks/www/process-assign.tcl 25 Sep 2005 23:49:23 -0000 1.2 @@ -14,6 +14,7 @@ } { {process_id:integer,notnull} {assignee_id:integer,notnull} + {object_id:integer,optional ""} } -properties { context_bar:onevalue @@ -28,42 +29,25 @@ } -set process [db_string get_rpocess { select one_line from pm_process where process_id = :process_id }] -set project_id [tasks::project_id] -set instance_id [pm::process::instantiate -process_id $process_id -project_item_id $project_id -name $process] +db_1row get_process { + select title as process, workflow_id + from t_processes + where process_id = :process_id +} db_transaction { -db_foreach task_in_process { - select *, - CASE WHEN due_date is null and due_interval is null THEN ''::varchar ELSE - CASE WHEN due_date is not null THEN to_char(due_date,'YYYY-MM-DD') ELSE - to_char((now()+due_interval),'YYYY-MM-DD') - END - END as end_date - from pm_process_task, tasks_pm_process_task - where process_id = :process_id - and pm_process_task.process_task_id = tasks_pm_process_task.process_task_id -} { + set case_id [db_nextval acs_object_id_seq] - set task_id [pm::task::new -project_id ${project_id} \ - -process_instance_id $instance_id \ - -title ${one_line} \ - -description ${description} \ - -mime_type ${mime_type} \ - -end_date ${end_date} \ - -percent_complete "0" \ - -creation_user [ad_conn user_id] \ - -creation_ip [ad_conn peeraddr] \ - -package_id [ad_conn package_id] \ - -priority ${priority}] - pm::task::assign -task_item_id $task_id -party_id $assignee_id + tasks::process::instance::new \ + -process_id $process_id \ + -case_id $case_id \ + -object_id $object_id - set task_url [export_vars -base task -url {task_id status_id orderby {party_id $assignee_id}}] - util_user_message -html -message "The task $one_line was added with a due date of $end_date" - + workflow::case::new -no_notification \ + -case_id $case_id \ + -workflow_id $workflow_id \ + -object_id $object_id } -} - ad_returnredirect [export_vars -base "contact" -url {{party_id $assignee_id}}] Index: openacs-4/packages/tasks/www/process-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/process-delete.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/www/process-delete.tcl 27 Jul 2005 13:45:00 -0000 1.1 +++ openacs-4/packages/tasks/www/process-delete.tcl 25 Sep 2005 23:49:23 -0000 1.2 @@ -10,6 +10,7 @@ @cvs-id $Id$ } { process_id:integer + assignee_id:integer,optional {confirm_p:boolean 0} {return_url "processes"} } -properties { @@ -18,27 +19,30 @@ } set package_id [ad_conn package_id] +permission::require_permission -object_id $package_id -privilege delete - if {[string is false $confirm_p]} { - db_1row get_name "select one_line, description from pm_process where process_id = :process_id" + db_1row get_name { + select title, description + from t_processes + where process_id = :process_id + } - set title "Delete process: $one_line" - set context [list "Delete: $one_line"] + set title "Delete process: $title" + set context [list "Delete: $title"] - set yes_url "process-delete?[export_vars {process_id {confirm_p 1} return_url}]" + set yes_url [export_vars -base process-delete {process_id assignee_id {confirm_p 1} return_url}] set no_url $return_url return } -permission::require_permission -object_id $package_id -privilege delete -db_transaction { - db_dml delete_extra_stuff { - delete from tasks_pm_process_task where process_task_id in ( select process_task_id from pm_process_task where process_id = :process_id ) - } - pm::process::delete -process_id $process_id +db_dml delete_process { + update t_processes + set workflow_id = null + where process_id = :process_id } + ad_returnredirect -message "Process deleted" $return_url Index: openacs-4/packages/tasks/www/process-task-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/process-task-delete.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/www/process-task-delete.tcl 27 Jul 2005 13:45:00 -0000 1.1 +++ openacs-4/packages/tasks/www/process-task-delete.tcl 25 Sep 2005 23:49:23 -0000 1.2 @@ -8,6 +8,7 @@ {process_task_id:integer,multiple} {confirm_p:boolean 0} {status_id:integer ""} + {assignee_id:integer,optional} {process_id:integer,notnull} {orderby ""} } @@ -25,8 +26,8 @@ set title "Delete [ad_decode $num_entries 1 "a Process Task" "Process Tasks"]" set context [list $title] set question "Are you sure you want to delete [ad_decode $num_entries 1 "this process task" "these $num_entries process tasks"]?" - set yes_url [export_vars -base process-task-delete -url { process_task_id:multiple { confirm_p 1 } status_id orderby process_id }] - set no_url [export_vars -base process -url { process_id status_id orderby }] + set yes_url [export_vars -base process-task-delete -url { process_task_id:multiple { confirm_p 1 } assignee_id status_id orderby process_id }] + set no_url [export_vars -base process -url { process_id assignee_id status_id orderby }] return } @@ -37,22 +38,16 @@ db_transaction { foreach process_task_id $process_task_id { lappend task_titles [db_string get_task_title { - select one_line - from pm_process_task - where process_task_id = :process_task_id + select title + from t_process_tasks + where task_id = :process_task_id and process_id = :process_id }] db_dml mark_delete { - delete - from tasks_pm_process_task - where process_task_id = :process_task_id + update t_process_tasks + set status_id = null + where task_id = :process_task_id } - db_dml mark_delete { - delete - from pm_process_task - where process_task_id = :process_task_id - and process_id = :process_id - } } } if { $num_entries > 1 } { @@ -72,9 +67,5 @@ util_user_message -html -message "The process task \"[lindex $task_titles 0]\" was deleted" } -ad_returnredirect [export_vars -base process -url { process_id status_id orderby }] +ad_returnredirect [export_vars -base process -url { process_id assignee_id status_id orderby }] ad_script_abort - - - - Index: openacs-4/packages/tasks/www/process-task.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/process-task.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/www/process-task.tcl 27 Jul 2005 13:44:59 -0000 1.1 +++ openacs-4/packages/tasks/www/process-task.tcl 25 Sep 2005 23:49:23 -0000 1.2 @@ -12,29 +12,26 @@ } { process_id:integer,notnull process_task_id:integer,optional + assignee_id:integer,optional status_id:integer,optional orderby:optional } -properties { } -validate { valid_process_id -requires process_id { - if { ![db_0or1row process_exists_p { select 1 from pm_process where process_id = :process_id}] } { + if { ![db_0or1row process_exists_p { select 1 from t_processes where process_id = :process_id}] } { ad_complain "The process_id specified is not valid" } } - valid_party_id -requires process_id { - set process_owner [db_string process_manager { select party_id from pm_process where process_id = :process_id}] - if { $process_owner != [ad_conn user_id] || ![permission::permission_p -object_id [ad_conn package_id] -privilege admin] } { - ad_complain "The process specified belongs to [db_string process_manager { select person__name(party_id) from pm_process where process_id = :process_id}]. Please ask that person or a website administrator to edit tasks on this process or assign it to you so you can manage it." - } - } } - set package_id [ad_conn package_id] set user_id [ad_maybe_redirect_for_registration] -set project_id [tasks::project_id] -set process [db_string process_get { select one_line from pm_process where process_id = :process_id}] +db_1row process_get { + select title as process, workflow_id + from t_processes + where process_id = :process_id +} if { [ad_form_new_p -key process_task_id] } { set title "Add Process Task" @@ -45,176 +42,171 @@ } else { set title "Edit: " append title [db_string get_task_name { - select pm.one_line - from pm_process_task pm - where pm.process_task_id = :process_task_id - and pm.process_id = :process_id + select title + from t_process_tasks + where task_id = :process_task_id }] append edit_buttons { {Update save} {{Update and Add New Task} save_add_another} {{Delete} delete} } } -set context [list [list "processes" Processes] [list [export_vars -base "process" -url {process_id}] $process] $title] +set context [list [list "processes" Processes] [list [export_vars -base "process" -url {process_id assignee_id}] $process] $title] +set status_options [db_list_of_lists status_options { + select title, status_id + from t_task_status + order by status_id +}] +set status_options [lang::util::localize $status_options] +set open_options [db_list_of_lists open_action_options { + select title, closing_action_id + from t_process_tasks + where process_id = :process_id + and status_id is not null + order by lower(title) +}] +set open_options [concat [list [list "-- new --" ""]] $open_options] if { [ns_queryget "formbutton:delete"] != "" } { - ad_returnredirect [export_vars -base "process-task-delete" -url {process_id process_task_id status_id orderby}] + ad_returnredirect [export_vars -base "process-task-delete" -url {process_id process_task_id assignee_id status_id orderby}] ad_script_abort } ad_form -name add_edit \ - -cancel_url [export_vars -base "process" -url {process_id}] \ + -cancel_url [export_vars -base "process" -url {process_id assignee_id}] \ -cancel_label "Cancel" \ -edit_buttons $edit_buttons \ -form { process_task_id:key process_id:integer(hidden) + workflow_id:integer(hidden) + assignee_id:integer(hidden),optional status_id:integer(hidden),optional orderby:text(hidden),optional - {task:text(text) {label "Process Task"} - {html { size 28 maxlength 50}} + {html { size 80 maxlength 200}} } - {due_date:text(text),optional - {label "Default Hard Deadline"} - {html {id date1 size 10 maxlength 10}} - {help_text {if blank there is no default deadline}} - {after_html { - - - }}} - - - {due_days:integer(text),optional - {label "Default Variable Deadline"} - {html {size 3 maxlength 3}} - {help_text {Variable deadlines that fall on Saturday or Sunday will automatically be pushed to the next Monday}} - {after_html {days after assignment}} + {status:text(select) + {label "[_ tasks.Status]"} + {options $status_options} } {priority:integer(select),optional {label "Priority"} {options {{{3 - Very Important} 3} {{2 - Important} 2} {{1 - Normal} 1} {{0 - Not Important} 0}}} } + {open_action_id:integer(select),optional + {label "After"} + {options $open_options} + } + {description:text(textarea),optional,nospell {label "Notes"} {html { rows 5 cols 50 wrap soft}}} + {comment:text(textarea),optional,nospell + {label "[_ tasks.Comment]"} + {html { rows 5 cols 50 wrap soft}}} + + {start:integer(text),optional + {label "Variable Start"} + {html {size 3 maxlength 3}} + {help_text {Variable start that fall on Saturday or Sunday will automatically be pushed to the next Monday}} + {after_html {days after assignment}} + } + + {due:integer(text),optional + {label "Variable Deadline"} + {html {size 3 maxlength 3}} + {help_text {Variable deadlines that fall on Saturday or Sunday will automatically be pushed to the next Monday}} + {after_html {days after assignment}} + } + } \ -new_request { - set status_id "1" + set status "1" set priority "1" + set start 0 + set due 0 } -edit_request { db_1row get_task_info { - select pm.one_line as task, - pm.description, - tp.due_interval, - tp.due_date, - tp.priority - from pm_process_task pm, - tasks_pm_process_task tp - where pm.process_task_id = :process_task_id - and pm.process_id = :process_id - and pm.process_task_id = tp.process_task_id + select title as task, description, status_id as status, priority, + start, due, comment, open_action_id + from t_process_tasks + where task_id = :process_task_id + and process_id = :process_id } - set due_days [lindex $due_interval 0] - } -validate { - {due_date - {[calendar::date_valid_p -date $due_date]} - {This is not a valid date. Either the date doesn't exist or it is not formatted correctly. Correct formatting is: YYYY-MM-DD or YYYYMMDD} - } - {due_date - { [expr \ - [expr [string equal $due_date ""] == 1 && [string equal [string trim $due_days] ""] == 1] || \ - [expr [string equal $due_date ""] == 1 && [string equal [string trim $due_days] ""] == 0] || \ - [expr [string equal $due_date ""] == 0 && [string equal [string trim $due_days] ""] == 1] - ]} - {You may either use a Hard Deadline, a Variable Deadline or neither but not both} - } - {due_days - { [expr \ - [expr [string equal $due_date ""] == 1 && [string equal [string trim $due_days] ""] == 1] || \ - [expr [string equal $due_date ""] == 1 && [string equal [string trim $due_days] ""] == 0] || \ - [expr [string equal $due_date ""] == 0 && [string equal [string trim $due_days] ""] == 1] - ]} - {You may either use a Hard Deadline, a Variable Deadline or neither but not both} - } } -on_submit { - set user_id [ad_conn user_id] - set peeraddr [ad_conn peeraddr] - if { [exists_and_not_null due_days] } { - set due_interval "${due_days} days" - } else { - set due_interval "" - } - set process_task_url [export_vars -base "/tasks/process-task" -url {process_id process_task_id}] + set process_task_url [export_vars -base "/tasks/process-task" -url {process_id process_task_id assignee_id}] } -new_data { db_transaction { - db_dml insert_pm_process_task { - insert into pm_process_task - ( process_task_id, process_id, one_line, description, mime_type ) - values - ( :process_task_id, :process_id, :task, :description, 'text/plain' ) + + set state_id [workflow::state::fsm::get_id -workflow_id $workflow_id -short_name new] + + set closing_action_id [workflow::action::fsm::new \ + -workflow_id $workflow_id \ + -short_name "tasks_action_$process_task_id" \ + -pretty_name "task action $process_task_id" \ + -enabled_state_ids $state_id \ + -new_state_id $state_id \ + -callbacks "tasks.Tasks_Action_SideEffect"] + + if {[empty_string_p $open_action_id]} { + set open_action_id [workflow::action::get_id -workflow_id $workflow_id -short_name new] } - db_dml insert_tasks_pm_process_task { - insert into tasks_pm_process_task - ( process_task_id, due_interval, due_date, priority ) - values - ( :process_task_id, :due_interval, :due_date, :priority ) - } + + set process_task_id [tasks::process::task::new \ + -task_id $process_task_id \ + -process_id $process_id \ + -open_action_id $open_action_id \ + -closing_action_id $closing_action_id \ + -title $task \ + -description $description \ + -mime_type "text/plain" \ + -comment $comment \ + -status_id $status \ + -priority $priority \ + -start $start \ + -due $due] + util_user_message -html -message "The process task $task was added" } } -edit_data { - db_transaction { - db_dml update_pm_process_task { - update pm_process_task - set one_line = :task, - description = :description - where process_task_id = :process_task_id - and process_id = :process_id - } - db_dml update_tasks_pm_process_task { - update tasks_pm_process_task - set due_interval = :due_interval, - due_date = :due_date, - priority = :priority - where process_task_id = :process_task_id - } - util_user_message -html -message "The process task $task was updated" - } + tasks::process::task::edit \ + -task_id $process_task_id \ + -open_action_id $open_action_id \ + -title $task \ + -description $description \ + -mime_type "text/plain" \ + -comment $comment \ + -status_id $status \ + -priority $priority \ + -start $start \ + -due $due + + util_user_message -html -message "The process task $task was updated" + } -after_submit { if { [ns_queryget "formbutton:save_add_another"] != "" } { - set return_url [export_vars -url -base "process-task" {process_id}] + set return_url [export_vars -url -base "process-task" {process_id assignee_id}] } else { - set return_url [export_vars -url -base "process" {process_id}] + set return_url [export_vars -url -base "process" {process_id assignee_id}] } ad_returnredirect $return_url ad_script_abort Index: openacs-4/packages/tasks/www/process.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/process.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/www/process.tcl 27 Jul 2005 13:44:59 -0000 1.1 +++ openacs-4/packages/tasks/www/process.tcl 25 Sep 2005 23:49:23 -0000 1.2 @@ -12,11 +12,10 @@ @return use_link the link to use this process } { - process_id:integer,notnull + {assignee_id:integer,optional ""} orderby:optional {project_item_id ""} - } -properties { process_id:onevalue context_bar:onevalue @@ -42,8 +41,11 @@ # set up context bar, needs parent_id -db_1row get_process_info { select * from pm_process where process_id = :process_id } -set title $one_line +db_1row get_process_info { + select title + from t_processes + where process_id = :process_id +} set context [list [list processes "Processes"] $title] set use_link "" @@ -54,18 +56,20 @@ priority { label "Priority" } \ - one_line { + title { label "Subject" - display_template {@tasks.task@ + display_template {@tasks.task@ } } \ - deadline { + start { + label "Start" + } \ + due { label "Due" - display_template { - @tasks.due_interval@ after assignment - @tasks.pretty_due_date@ - } } \ + after_task { + label "After" + } \ ] @@ -76,17 +80,17 @@ -key process_task_id \ -elements $elements \ -actions [list \ - "Add Process Task" [export_vars -base process-task -url {process_id}] "Add Process Task" \ - "Edit Process" [export_vars -base process-add-edit -url {process_id}] "Edit Process Title/Description" \ - "Delete Process" [export_vars -base process-delete -url {process_id}] "Delete this Process" \ - "Cancel" "processes" "Return to all processes" \ + "Add Process Task" [export_vars -base process-task -url {process_id assignee_id}] "Add Process Task" \ + "Edit Process" [export_vars -base process-add-edit -url {process_id assignee_id}] "Edit Process Title/Description" \ + "Delete Process" [export_vars -base process-delete -url {process_id assignee_id}] "Delete this Process" \ + "Cancel" [export_vars -base processes -url {assignee_id}] "Return to all processes" \ ] \ -orderby { default_value ordering,desc ordering { label "Order" - orderby_asc "tp.priority asc, tp.due_date, tp.due_interval, upper(pm.one_line)" - orderby_desc "tp.priority desc, tp.due_date, tp.due_interval, upper(pm.one_line)" + orderby_asc "tp.priority asc, tp.due, lower(tp.title)" + orderby_desc "tp.priority desc, tp.due, lower(tp.title)" default_direction desc } } \ @@ -95,20 +99,16 @@ } \ -bulk_action_export_vars { process_id - project_item_id + assignee_id } \ -sub_class { narrow } \ -filters { process_id {} - } \ - -html { - width 100% } db_multirow -extend { item_url } tasks task_query { } { } - Index: openacs-4/packages/tasks/www/process.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/process.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/www/process.xql 27 Jul 2005 13:44:59 -0000 1.1 +++ openacs-4/packages/tasks/www/process.xql 25 Sep 2005 23:49:23 -0000 1.2 @@ -3,17 +3,14 @@ - select pm.process_task_id, - pm.one_line as task, - pm.description, - tp.due_interval, - tp.due_date, - CASE WHEN to_char(tp.due_date,'YYYY') = to_char(now(),'YYYY') THEN to_char(tp.due_date,'Mon DD (Dy)') ELSE to_char(tp.due_date,'Mon DD, YYYY (Dy') END as pretty_due_date, - tp.priority - from pm_process_task pm, - tasks_pm_process_task tp - where pm.process_id = :process_id - and pm.process_task_id = tp.process_task_id + select tp.task_id as process_task_id, tp.title as task, + tp.description, tp.priority, tp.due, tp.start, + tp2.title as after_task, tp2.task_id as after_task_id + from t_process_tasks tp + left outer join t_process_tasks tp2 + on (tp2.closing_action_id = tp.open_action_id) + where tp.process_id = :process_id + and tp.status_id is not null [template::list::orderby_clause -orderby -name tasks] Index: openacs-4/packages/tasks/www/processes-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/processes-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/www/processes-postgresql.xql 27 Jul 2005 13:44:59 -0000 1.1 +++ openacs-4/packages/tasks/www/processes-postgresql.xql 25 Sep 2005 23:49:23 -0000 1.2 @@ -4,19 +4,16 @@ - SELECT - p.process_id, - p.one_line, - p.description, - p.party_id, - to_char(p.creation_date,'YYYY-MM-DD') as creation_date_ansi, - (select count(*) from pm_process_instance i where i.process_id = - p.process_id) as instances, - person__name(party_id) as owner_name - FROM - pm_process_active p - ORDER BY - p.one_line + select p.process_id, p.title, o.creation_user, + person__name(o.creation_user) as creator_name, p.description, + to_char(o.creation_date, 'YYYY-MM-DD') as creation_date_ansi, + (select count(*) + from t_process_instances pi + where pi.process_id = p.process_id) as instances + from t_processes p, acs_objects o + where p.process_id = o.object_id + and p.workflow_id is not null + order by lower(p.title) Index: openacs-4/packages/tasks/www/processes.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/processes.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/www/processes.adp 27 Jul 2005 13:45:00 -0000 1.1 +++ openacs-4/packages/tasks/www/processes.adp 25 Sep 2005 23:49:23 -0000 1.2 @@ -5,9 +5,7 @@ - -

#tasks.Cancel#

-
+ Index: openacs-4/packages/tasks/www/processes.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/processes.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/www/processes.tcl 27 Jul 2005 13:45:00 -0000 1.1 +++ openacs-4/packages/tasks/www/processes.tcl 25 Sep 2005 23:49:23 -0000 1.2 @@ -21,23 +21,13 @@ write_p:onevalue create_p:onevalue admin_p:onevalue - task_term:onevalue - task_term_lower:onevalue - project_term:onevalue - project_term_lower:onevalue } if { [exists_and_not_null assignee_id] } { set cancel_url [export_vars -base "/tasks/contact" -url {{party_id $assignee_id}}] } # --------------------------------------------------------------- # -# terminology -set task_term [parameter::get -parameter "TaskName" -default "Task"] -set task_term_lower [parameter::get -parameter "taskname" -default "task"] -set project_term [parameter::get -parameter "ProjectName" -default "Project"] -set project_term_lower [parameter::get -parameter "projectname" -default "project"] - # set up context bar set context_bar [list "Processes"] @@ -52,31 +42,25 @@ set create_p [permission::permission_p -object_id $package_id -privilege create] set admin_p [permission::permission_p -object_id $package_id -privilege admin] -# root CR folder -# set root_folder [db_string get_root "select pm_project__get_root_folder (:package_id, 'f')"] +set title "Manage Processes" +set context [list $title] +set actions [list "Add Process" [export_vars -base process-add-edit {assignee_id}] "Add a Process"] +if {[exists_and_not_null assignee_id]} { + lappend actions "Cancel" "$cancel_url" "Cancel" +} -# Processes, using list-builder --------------------------------- -if { [exists_and_not_null assignee_id] } { - set mode "assign" - set title "Assing Process" - set content [list $title] -# set actions [list "Manage Processes" "processes" "Manage Processes"] - set actions "" + +if {$admin_p} { + set mode admin } else { - set mode "manage" - set title "Manage Processes" - set context [list $title] - set actions [list "Add Process" "process-add-edit" "Add a Process"] + set mode normal } -set elements "" - - - template::list::create \ -name processes \ -multirow processes \ -key item_id \ + -pass_properties { admin_p } \ -selected_format $mode \ -elements { assign { @@ -85,12 +69,12 @@ Assign } } - one_line { - label "Subject" + title { + label "Title" display_template { - - @processes.one_line@ - + + @processes.title@ + } } description { @@ -102,9 +86,9 @@ @processes.instances@ } } - owner_name { + creator_name { label "Manager" - link_url_eval $owner_url + link_url_eval $creator_url } edit { display_template { @@ -121,54 +105,47 @@ orderby_process {} } \ -orderby { - one_line {orderby one_line} - default_value one_line,desc + title {orderby title} + default_value title,desc } \ -orderby_name orderby_project \ -sub_class { narrow - } \ - -html { - width 100% } -formats { - assign { + normal { label "Assign Layout" layout table row { assign {} - one_line {} + title {} description {} - owner_name {} + creator_name {} } } - manage { - label "Assign Layout" + admin { + label "Admin Layout" layout table row { - edit {} - one_line {} + assign {} + title {} description {} - owner_name {} + creator_name {} instances {} + edit {} delete {} } } } -set mode_carryover $mode -db_multirow -extend { delete_url creation_date owner_url process_url assign_url mode } processes process_query { +db_multirow -extend { delete_url creation_date creator_url process_url assign_url} processes process_query { } { - set mode $mode_carryover - set delete_url [export_vars -base "process-delete" {process_id}] + set delete_url [export_vars -base "process-delete" {process_id assignee_id}] set creation_date [lc_time_fmt $creation_date_ansi "%x"] - set owner_url [acs_community_member_url -user_id $party_id] - set process_url [export_vars -base process -url {process_id}] + set creator_url [acs_community_member_url -user_id $creation_user] + set process_url [export_vars -base process -url {process_id assignee_id}] if { [exists_and_not_null assignee_id] } { set assign_url [export_vars -base process-assign -url {assignee_id process_id}] } else { set assign_url $process_url } } - - -# ------------------------- END OF FILE ------------------------- # Index: openacs-4/packages/tasks/www/task-interval.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/task-interval.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tasks/www/task-interval.tcl 27 Jul 2005 13:44:59 -0000 1.1 +++ openacs-4/packages/tasks/www/task-interval.tcl 25 Sep 2005 23:49:23 -0000 1.2 @@ -35,74 +35,33 @@ } set package_id [ad_conn package_id] -set user_id [ad_maybe_redirect_for_registration] -set peeraddr [ad_conn peeraddr] -set project_id [tasks::project_id] - set title "Add/Edit" set context [list $title] db_1row get_task_info " - select ci.item_id as task_id, - cr.title as task, - to_char((ptr.end_date $operand '$days days'::interval),'YYYY-MM-DD') as end_date, - ptr.percent_complete, - ptr.priority, - cr.description - from pm_tasks_revisions ptr, - cr_revisions cr, - cr_items ci - where ci.item_id = :task_id - and ci.latest_revision = ptr.task_revision_id - and ci.live_revision = ptr.task_revision_id - and ptr.task_revision_id = cr.revision_id + select t.title as task, t.description, t.mime_type, t.priority, + to_char((t.due_date $operand '$days days'::interval),'YYYY-MM-DD') as due_date, + t.status_id as status, t.comment + from t_tasks t + where t.task_id = :task_id " -if { $percent_complete >= "100" } { - set completed_p "1" -} -if {$percent_complete >= 100} { - set task_status_id [pm::task::default_status_closed] -} elseif {$percent_complete < 100} { - set task_status_id [pm::task::default_status_open] -} -set task_item_id $task_id -set project_item_id $project_id -set title $task -set mime_type "text/plain" -set estimated_hours_work "" -set estimated_hours_work_min "" -set estimated_hours_work_max "" -set actual_hours_worked "" -set update_user $user_id -set update_ip $peeraddr -db_exec_plsql new_task_revision " - select pm_task__new_task_revision ( - :task_item_id, - :project_item_id, - :title, - :description, - :mime_type, - [pm::util::datenvl -value $end_date -value_if_null "null" -value_if_not_null ":end_date"], - :percent_complete, - :estimated_hours_work, - :estimated_hours_work_min, - :estimated_hours_work_max, - :actual_hours_worked, - :task_status_id, - current_timestamp, - :update_user, - :update_ip, - :package_id, - :priority) -" +set task_id [tasks::task::edit \ + -task_id ${task_id} \ + -title ${task} \ + -description ${description} \ + -mime_type $mime_type \ + -comment ${comment} \ + -due_date ${due_date} \ + -status_id ${status} \ + -priority ${priority}] -set task_url [export_vars -base task -url {task_id status_id orderby}] +set task_url [export_vars -base "/tasks/task" -url {task_id status_id orderby}] if { $action == "minus" } { - util_user_message -html -message "The task $title moved up 7 days" + util_user_message -html -message "[_ tasks.task_moved_up]" } else { - util_user_message -html -message "The task $title delayed 7 days" + util_user_message -html -message "[_ tasks.task_delayed]" } Index: openacs-4/packages/tasks/www/task.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/task.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/tasks/www/task.tcl 27 Jul 2005 14:29:51 -0000 1.2 +++ openacs-4/packages/tasks/www/task.tcl 25 Sep 2005 23:49:23 -0000 1.3 @@ -42,12 +42,11 @@ set names [join $names ", "] if { ![exists_and_not_null return_url] } { - set return_url [export_vars -base "contact" -url {party_id orderby status_id}] + set return_url [export_vars -base "contact" -url {party_id status_id orderby}] } set package_id [ad_conn package_id] set user_id [ad_maybe_redirect_for_registration] -set project_id [tasks::project_id] set title "[_ tasks.AddEdit]" set context [list $title] @@ -66,20 +65,37 @@ } if { [ns_queryget "formbutton:delete"] != "" } { - ad_returnredirect [export_vars -base "delete" -url {task_id status_id orderby return_url}] + ad_returnredirect [export_vars -base "delete" -url {task_id orderby status_id return_url}] ad_script_abort } +set contact_options [db_list_of_lists contact_options { + select CASE WHEN o.name is null THEN p.first_names || ' ' || p.last_name ELSE o.name END as name, y.party_id + from parties y + left join persons p on (y.party_id = p.person_id) + left join organizations o on (y.party_id = o.organization_id) + where (p.person_id is not null or o.organization_id is not null) + and y.party_id > 0 + order by 1 +}] +set contact_options [concat [list [list "" ""]] $contact_options] +set status_options [db_list_of_lists status_options { + select title, status_id + from t_task_status + order by status_id +}] +set status_options [lang::util::localize $status_options] + ad_form -name add_edit \ -cancel_url $return_url \ -cancel_label "[_ tasks.Cancel]" \ -edit_buttons $edit_buttons \ -form { task_id:key return_url:text(hidden),optional - status_id:integer(hidden),optional orderby:text(hidden),optional + status_id:integer(hidden),optional party_id:integer(hidden) other_party_ids:text(hidden),optional {names:text(hidden),optional {label {Add Task To}}} @@ -103,35 +119,25 @@ {task:text(text),optional {label "[_ tasks.Custom_Task]"} - {html { maxlength 1000 size 35 }} + {html { maxlength 1000 size 80 }} {help_text {You can either use a standard task or a custom task, but not both}} } - {end_date:text(text) + {object_id:text(select),optional + {label "[_ tasks.Contact]"} + {options $contact_options} + } + + {due_date:text {label "[_ tasks.Due]"} {html {id date1 size 10 maxlength 10}} {help_text {if blank there is no due date}} - {after_html { - - - }} + {after_html { \[y-m-d \]}} } - {completed_p:text(checkbox),optional + {status:text(select) {label "[_ tasks.Status]"} - {options {{Completed 1}}} + {options $status_options} } {priority:integer(select),optional @@ -143,35 +149,27 @@ {label "[_ tasks.Notes]"} {html { rows 6 cols 60 wrap soft}}} + {comment:text(textarea),optional,nospell + {label "[_ tasks.Comment]"} + {html { rows 6 cols 60 wrap soft}}} + } -new_request { set title "[_ tasks.Add_Task]" set context [list $title] - set status_id "1" + set status "1" set priority "1" } -edit_request { db_1row get_task_info { - select ci.item_id as task_id, - cr.title as task, - to_char(ptr.end_date,'YYYY-MM-DD') as end_date, - ptr.percent_complete, - ptr.priority, - cr.description - from pm_tasks_revisions ptr, - cr_revisions cr, - cr_items ci - where ci.item_id = :task_id - and ci.latest_revision = ptr.task_revision_id - and ci.live_revision = ptr.task_revision_id - and ptr.task_revision_id = cr.revision_id - + select t.title as task, t.description, t.comment, + to_char(t.due_date,'YYYY-MM-DD') as due_date, + t.priority, t.status_id as status, t.object_id + from t_tasks t + where t.task_id = :task_id } - if { $percent_complete >= "100" } { - set completed_p "1" - } - set title ${task} + set title $task set context [list $title] set task_prescribed_p 0 foreach task_prescribed_option [template::element::get_property add_edit task_prescribed options] { @@ -184,7 +182,6 @@ set task "" } else { set task_prescribed "" - set task $task } } -validate { # {end_date {[calendar::date_valid_p -date $end_date]} {This is not a valid date. Either the date doesn't exist or it is not formatted correctly. Correct formatting is: YYYY-MM-DD or YYYYMMDD}} @@ -204,30 +201,21 @@ break } - set user_id [ad_conn user_id] - set peeraddr [ad_conn peeraddr] - if { $completed_p == "1" } { - set percent_complete "100" - } else { - set percent_complete "0" - } } -new_data { foreach party $all_parties { - set task_id [pm::task::new -project_id ${project_id} \ + set task_id [tasks::task::new \ -title ${task} \ -description ${description} \ -mime_type "text/plain" \ - -end_date ${end_date} \ - -percent_complete ${percent_complete} \ - -creation_user ${user_id} \ - -creation_ip ${peeraddr} \ + -comment ${comment} \ + -party_id ${party} \ + -object_id $object_id \ + -due_date ${due_date} \ + -status_id ${status} \ -package_id ${package_id} \ -priority ${priority}] - - pm::task::assign -task_item_id $task_id -party_id $party - } if { [llength $all_parties] == 1 } { @@ -239,43 +227,17 @@ } -edit_data { - if {$percent_complete >= 100} { - set task_status_id [pm::task::default_status_closed] - } elseif {$percent_complete < 100} { - set task_status_id [pm::task::default_status_open] - } - set task_item_id $task_id - set project_item_id $project_id - set title $task - set mime_type "text/plain" - set estimated_hours_work "" - set estimated_hours_work_min "" - set estimated_hours_work_max "" - set actual_hours_worked "" - set update_user $user_id - set update_ip $peeraddr + set task_id [tasks::task::edit \ + -task_id ${task_id} \ + -title ${task} \ + -description ${description} \ + -mime_type "text/plain" \ + -comment ${comment} \ + -object_id $object_id \ + -due_date ${due_date} \ + -status_id ${status} \ + -priority ${priority}] - db_exec_plsql new_task_revision " - select pm_task__new_task_revision ( - :task_item_id, - :project_item_id, - :title, - :description, - :mime_type, - [pm::util::datenvl -value $end_date -value_if_null "null" -value_if_not_null ":end_date"], - :percent_complete, - :estimated_hours_work, - :estimated_hours_work_min, - :estimated_hours_work_max, - :actual_hours_worked, - :task_status_id, - current_timestamp, - :update_user, - :update_ip, - :package_id, - :priority) - " - set task_url [export_vars -base task -url {task_id status_id orderby party_id}] util_user_message -html -message "[_ tasks.lt_The_task_a_hreftaskst_1]" @@ -294,6 +256,8 @@ if { ![ad_form_new_p -key task_id] } { set creation_id [db_string get_it { select creation_user from acs_objects where object_id = :task_id }] + set creator_url [contact::url -party_id $creation_id] + set creator_name [contact::name -party_id $creation_id] template::element::create add_edit creator \ -datatype "text" \ -widget "inform" \