Index: openacs-4/packages/tasks/tasks.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/tasks.info,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/tasks.info 27 Jul 2005 13:44:58 -0000 1.1 @@ -0,0 +1,25 @@ + + + + + Tasks + Tasks + f + f + + + Matthew Geddert + Keep track of tasks to do. + This package uses project manager tcl and sql as the base for a simple task program without project manager's complexity. + + + + + + + + + + + + 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/catalog/tasks.en_US.ISO-8859-1.xml 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,23 @@ + + + + Add Task + Assign Process + Cancel + Cancel, do not delete + Created By + Date + Delete + Done + Due + Are you sure you want to delete this process: %one_line% + more + No, Cancel + Not Done + Priority + Process + Select process: + Task + Tasks + Yes + Index: openacs-4/packages/tasks/lib/task-chunk.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/lib/task-chunk.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/lib/task-chunk.adp 27 Jul 2005 13:44:58 -0000 1.1 @@ -0,0 +1,5 @@ +

Completed Task @title@

+ +

@content;noquote@

+
+ Index: openacs-4/packages/tasks/lib/task-chunk.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/lib/task-chunk.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/lib/task-chunk.tcl 27 Jul 2005 13:44:58 -0000 1.1 @@ -0,0 +1,3 @@ +set title [lindex $content 0] +set content [lindex $content 1] +set task_url [export_vars -base "/tasks/task" -url {{task_id $object_id} party_id}] Index: openacs-4/packages/tasks/lib/tasks-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/lib/tasks-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/lib/tasks-postgresql.xql 27 Jul 2005 13:44:58 -0000 1.1 @@ -0,0 +1,56 @@ + + +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] + [template::list::orderby_clause -orderby -name tasks] + + + + Index: openacs-4/packages/tasks/lib/tasks.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/lib/tasks.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/lib/tasks.adp 27 Jul 2005 13:44:58 -0000 1.1 @@ -0,0 +1,18 @@ + +
+

#tasks.Tasks#

+
+ + class="first">@tasks.end_date@ +
+ +
+
+
+
+
+ Index: openacs-4/packages/tasks/lib/tasks.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/lib/tasks.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/lib/tasks.tcl 27 Jul 2005 13:44:58 -0000 1.1 @@ -0,0 +1,61 @@ +if { ![exists_and_not_null party_id] } { + error "you must supply a party_id" +} +set mine_p "f" +set status_id "1" +set role_id "2" +set orderby "priority,desc" + + +# \ +# -orderby_name orderby + +# \ +# -html { +# width 100% +# } + +#set user_id [ad_conn user_id] + +#set project_id [tasks::project_id] +set project_id "26798" + + + + +template::multirow create tasks task_url title end_date overdue_p + +set new_num 1 +db_foreach get_tasks " + select pt.task_id, + tasks__relative_date(ptr.end_date) as end_date, + cr.title, + ptr.priority, + CASE WHEN ptr.end_date < now() THEN '1' ELSE '0' END as overdue_p + from cr_items ci, + pm_tasks_revisions ptr, + pm_tasks pt, + cr_revisions cr + 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 pt.deleted_p = 'f' + and task_id in ( select task_id from pm_task_assignment where party_id = :party_id and role_id = '1' ) + and ptr.end_date is not null + and ptr.percent_complete < 100 + order by ptr.end_date asc, ptr.priority, upper(cr.title) +" { + + if { !$overdue_p } { + if { $new_num > 3 } { + break + } + incr new_num + } + set task_url [export_vars -base "/tasks/task" -url { party_id task_id }] + template::multirow append tasks $task_url $title $end_date $overdue_p +} +# [template::list::filter_where_clauses -and -name tasks] +#set fred [template::list::orderby_clause -orderby -name tasks] 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/sql/postgresql/tasks-create.sql 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,114 @@ +----------------------------------------------------- +-- +-- Create the data model for the timecard application +-- Author: Matthew Geddert geddert@yahoo.com +-- Creation Date: 2004-02-16 +-- +----------------------------------------------------- + +create table tasks_pm_process_task ( + 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, + due_date timestamptz, + priority integer default 0 +); + +create or replace function tasks__relative_date ( + timestamptz -- date_comparative +) returns varchar +as ' +declare + p_date alias for $1; + v_date varchar; +begin + v_date := CASE WHEN to_char(p_date,''YYYY'') = to_char(now(),''YYYY'') THEN + CASE WHEN to_char(p_date,''YYYY-MM-DD'') = to_char(now(),''YYYY-MM-DD'') THEN ''Today'' + WHEN to_char(p_date,''YYYY-MM-DD'') = to_char((now() - ''1 day''::interval),''YYYY-MM-DD'') THEN ''Yesterday'' + WHEN to_char(p_date,''YYYY-MM-DD'') = to_char((now() - ''2 day''::interval),''YYYY-MM-DD'') THEN ''Two Days Ago'' + WHEN to_char(p_date,''YYYY-MM-DD'') = to_char((now() + ''1 day''::interval),''YYYY-MM-DD'') THEN ''Tomorrow'' + WHEN to_char(p_date,''YYYY-MM-DD'') = to_char((now() + ''2 day''::interval),''YYYY-MM-DD'') THEN CASE WHEN to_char(p_date,''FMDay'') not in ( ''Sunday'', ''Saturday'', ''Monday'', ''Tuesday'') THEN to_char(p_date,''Day'') ELSE to_char(p_date,''Mon DD (Dy)'') END + WHEN to_char(p_date,''YYYY-MM-DD'') = to_char((now() + ''3 day''::interval),''YYYY-MM-DD'') THEN CASE WHEN to_char(p_date,''FMDay'') not in ( ''Sunday'', ''Saturday'', ''Monday'', ''Tuesday'') THEN to_char(p_date,''Day'') ELSE to_char(p_date,''Mon DD (Dy)'') END + WHEN to_char(p_date,''YYYY-MM-DD'') = to_char((now() + ''4 day''::interval),''YYYY-MM-DD'') THEN CASE WHEN to_char(p_date,''FMDay'') not in ( ''Sunday'', ''Saturday'', ''Monday'', ''Tuesday'') THEN to_char(p_date,''Day'') ELSE to_char(p_date,''Mon DD (Dy)'') END + ELSE to_char(p_date,''Mon DD (Dy)'') END + ELSE to_char(p_date,''Mon DD, YYYY'') END; + + + return v_date; +end;' language 'plpgsql'; + +create or replace function tasks__completion_date ( + integer +) returns timestamptz +as ' +declare + p_task_id alias for $1; + v_complete_p boolean; + v_date varchar; + v_previous_p boolean; + revision record; +begin + v_complete_p := ''1'' from pm_tasks where task_id = p_task_id and status = ''2''; + v_date := NULL; + + IF v_complete_p THEN + v_previous_p := ''t''; + FOR revision IN + select ptr.percent_complete, ao.creation_date + from cr_revisions cr, pm_tasks_revisions ptr, acs_objects ao + where cr.item_id = p_task_id + and cr.revision_id = ao.object_id + and cr.revision_id = ptr.task_revision_id + order by ao.creation_date desc + LOOP + IF revision.percent_complete = ''100'' AND v_previous_p THEN + v_date := revision.creation_date; + ELSE + v_previous_p := ''f''; + EXIT; + END IF; + END LOOP; + + END IF; + + return v_date; +end;' language 'plpgsql'; + + +create or replace function tasks__completion_user ( + integer +) returns integer +as ' +declare + p_task_id alias for $1; + v_complete_p boolean; + v_user varchar; + v_previous_p boolean; + revision record; +begin + v_complete_p := ''1'' from pm_tasks where task_id = p_task_id and status = ''2''; + v_user := NULL; + + IF v_complete_p THEN + v_previous_p := ''t''; + FOR revision IN + select ptr.percent_complete, ao.creation_user + from cr_revisions cr, pm_tasks_revisions ptr, acs_objects ao + where cr.item_id = p_task_id + and cr.revision_id = ao.object_id + and cr.revision_id = ptr.task_revision_id + order by ao.creation_date desc + LOOP + IF revision.percent_complete = ''100'' AND v_previous_p THEN + v_user := revision.creation_user; + ELSE + v_previous_p := ''f''; + EXIT; + END IF; + END LOOP; + + END IF; + + return v_user; +end;' language 'plpgsql'; 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/tcl/tasks-callback-procs.tcl 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,59 @@ +# packages/tasks/tcl/tasks-callback-procs.tcl + +ad_library { + + Callback procs for Tasks + + @author Matthew Geddert (openacs@geddert.com) + @creation-date 2005-06-15 + @arch-tag: 200d82ba-f8e7-4f19-9740-39117474766f + @cvs-id $Id: tasks-callback-procs.tcl,v 1.1 2005/07/27 13:44:59 maltes Exp $ +} + +ad_proc -public -callback contact::history -impl tasks { + {-party_id:required} + {-multirow:required} + {-trunacte_len ""} +} { + Add task history to this party. Return as list +} { + set project_id "26798" + set tasks [list] + db_foreach get_tasks { + select pt.task_id, + tasks__completion_date(ci.item_id) as completion_date, + tasks__completion_user(ci.item_id) as completion_user, + cr.title, + cr.description as content + 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.status = '2' + 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' ) + } { + if { [exists_and_not_null truncate_len] } { + set content_html [ad_html_text_convert -truncate_len $truncate_len -from "text/plain" -to "text/html" $content] + } else { + set content_html [ad_html_text_convert -from "text/plain" -to "text/html" $content] + } + ::template::multirow append $multirow $completion_date $task_id $completion_user [list $title $content_html] "/packages/tasks/lib/task-chunk" + } +} + + +ad_proc -public -callback contacts::bulk_actions -impl tasks { + {-multirow:required} +} { + Add task history to this party. Return as list +} { + ::template::multirow append $multirow "Add Task" "/tasks/task" "Add a task to the selected contacts" +} 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/tcl/tasks-procs.tcl 27 Jul 2005 13:44:58 -0000 1.1 @@ -0,0 +1,55 @@ +ad_library { + + Tasks Library + + @creation-date 2003-12-18 + @author Matthew Geddert + @cvs-id $Id: tasks-procs.tcl,v 1.1 2005/07/27 13:44:58 maltes Exp $ + +} + +namespace eval tasks {} + + +ad_proc -public tasks::project_id { + {-package_id ""} +} { + Returns this tasks instance project_id +} { + if { [string is false [exists_and_not_null package_id]] } { + set package_id [ad_conn package_id] + } + set project_id [db_string get_project_id { + select pm_projectsx.item_id + from pm_projectsx, + cr_folders cf + where pm_projectsx.parent_id = cf.folder_id + and cf.package_id = :package_id + } -default {}] + if { [string is false [exists_and_not_null project_id]] } { + tasks::initialize -package_id $package_id + set project_id [tasks::project_id -package_id $package_id] + } + return $project_id +} + +ad_proc -public tasks::initialize { + {-package_id ""} +} { + Returns this tasks instance project_id +} { + if { [string is false [exists_and_not_null package_id]] } { + set package_id [ad_conn package_id] + } + if { [string is false [db_0or1row project_exists_p { select 1 from cr_folders where package_id = :package_id and label = 'Projects' }]] } { + pm::project::new -project_name "Tasks Instance $package_id" \ + -status_id "1" \ + -organization_id "" \ + -creation_user [ad_conn user_id] \ + -creation_ip [ad_conn peeraddr] \ + -ongoing_p "t" \ + -package_id $package_id + } +} + + Index: openacs-4/packages/tasks/www/contact.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/contact.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/contact.adp 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,10 @@ + +@party_id@ + +

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

+ + + Index: openacs-4/packages/tasks/www/contact.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/contact.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/contact.tcl 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,230 @@ +ad_page_contract { + + Main view page for tasks. + + @author jader@bread.com + @creation-date 2003-12-03 + @cvs-id $Id: contact.tcl,v 1.1 2005/07/27 13:45:00 maltes Exp $ + + @return title Page title. + @return context Context bar. + @return tasks Multirow data set of tasks + @return task_term Terminology for tasks + @return task_term_lower Terminology for tasks (lower case) + @return project_term Terminology for projects + @return project_term_lower Terminology for projects (lower case) + + @param mine_p is used to make the default be the user, but + still allow people to view everyone. + +} { + {orderby ""} + {party_id ""} + {searchterm ""} + {mine_p "t"} + {status_id "1"} + {role_id "2"} + {process_instance:integer,optional} +} -properties { + task_term:onevalue + context:onevalue + tasks:multirow + hidden_vars:onevalue +} + +set user_id [ad_conn user_id] + +if { ![contact::exists_p -party_id $party_id] } { + set party_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 "./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 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 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 \ + -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 { + label "[_ tasks.Process]" + display_template { + @tasks.process@ + + + « @tasks.process@ » + + + } + } + date { + label "[_ tasks.Date]" + display_template { + @tasks.completed_date;noquote@ + + + « @tasks.end_date;noquote@ » + + + } + } + creation_user { + label "[_ tasks.Created_By]" + display_template { + class="done">@tasks.creation_name@ + } + } + } \ + -sub_class { + narrow + } \ + -filters { + party_id {} + } -orderby { + default_value $orderby + 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)" + 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)" + 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" + default_direction asc + } + process { + 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" + 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)" + 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, + 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' ) + [template::list::orderby_clause -orderby -name tasks] +" { + set creation_user_url [contact::url -party_id $creation_user] + 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_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}] + set process_minus_url [export_vars -base process-interval -url {{action minus} {days 7} party_id process_instance status_id orderby return_url}] + + regsub -all "\r|\n" $description {LiNeBrEaK} description + + set description_html [ad_html_text_convert \ + -from "text/plain" \ + -to "text/html" \ + -truncate_len "400" \ + -more "[_ tasks.more]" \ + -- $description] + regsub -all {LiNeBrEaKLiNeBrEaK} $description_html {LiNeBrEaK} description_html +# regsub -all {LiNeBrEaKLiNeBrEaK} $description_html {LiNeBrEaK} description_html +# regsub -all {LiNeBrEaKLiNeBrEaK} $description_html {LiNeBrEaK} description_html +# 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 " " $completed_date {\ } completed_date +} + +# [template::list::filter_where_clauses -and -name tasks] +#set fred [template::list::orderby_clause -orderby -name tasks] Index: openacs-4/packages/tasks/www/delete.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/delete.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/delete.adp 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,9 @@ + + @title@ + @context@ + +

@question@

+

+ #tasks.Yes# - #tasks.No_Cancel# +

+ Index: openacs-4/packages/tasks/www/delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/delete.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/delete.tcl 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,70 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: delete.tcl,v 1.1 2005/07/27 13:45:00 maltes Exp $ + +} { + {task_id:integer,multiple} + {confirm_p:boolean 1} + {return_url:notnull} +} + + +set num_entries [llength $task_id] +set user_id [ad_conn user_id] + +if { [string is false $confirm_p] } { + + if { $num_entries == 0 } { + ad_returnredirect ./ + return + } + set title "Delete [ad_decode $num_entries 1 "a Task" "Tasks"]" + set context [list $title] + set question "Are you sure you want to delete [ad_decode $num_entries 1 "this task" "these $num_entries tasks"]?" + set yes_url "delete?[export_vars { task_id:multiple { confirm_p 1 } return_url}]" + set no_url "${return_url}" + return +} + + +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 + + }] + db_dml mark_delete "update pm_tasks set deleted_p = 't' where task_id = :task_id" +} + +if { $num_entries > 1 } { + set task_list "" + set num 1 + foreach task_title $task_titles { + if { $num == $num_entries } { + append task_list " and " + } elseif { $num != 1 } { + append task_list ", " + } + append task_list "\"${task_title}\"" + incr num + } + util_user_message -html -message "The tasks ${task_list} were deleted" +} else { + util_user_message -html -message "The task \"[lindex $task_titles 0]\" was deleted" +} + +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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/index-postgresql.xql 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,56 @@ + + +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] + [template::list::orderby_clause -orderby -name tasks] + + + + Index: openacs-4/packages/tasks/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/index.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/index.adp 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,7 @@ + + +

+ + + + Index: openacs-4/packages/tasks/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/index.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/index.tcl 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,186 @@ +ad_page_contract { + List and manage contacts. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: index.tcl,v 1.1 2005/07/27 13:44:59 maltes Exp $ +} { + {orderby "end_date,asc"} + {format "normal"} + {search_id:integer ""} + {query ""} + {page:optional} + {page_size:integer "25"} + {tasks_interval:integer "7"} + {page_flush_p "f"} +} + + +set title "Tasks" +set context {} +set project_id [tasks::project_id] +set user_id [ad_conn user_id] + +set return_url [export_vars -base "/tasks/" -url {orderby format search_id query page page_size tasks_interval {page_flush_p t}}] + + +if { $orderby == "contact_name,asc" } { + set name_order 0 +} elseif { $orderby == "contact_name,desc" } { + set name_order 1 +} else { + set name_order 0 +} + + + + +set first_p 1 +foreach page_s [list 25 50 100 500] { + if { [string is false $first_p] } { + append name_label " | " + } + if { $page_size == $page_s } { + append name_label $page_s + } else { + append name_label "$page_s" + } + 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 context {} + +template::list::create \ + -name tasks \ + -multirow tasks \ + -key task_id \ + -page_size "50" \ + -page_flush_p $page_flush_p \ + -page_query_name tasks_pagination \ + -elements { + priority { + label "Priority" + } + contact_name { + label "Contact" + link_url_eval $contact_url + } + title { + label "Task" + display_template { + @tasks.title@ + } + } + process { + label "Process" + } + end_date { + label "Due" + display_template { + + @tasks.end_date@ + + + @tasks.end_date@ + + } + } + } \ + -bulk_actions [list \ + "Mark Completed" "mark-completed" "Mark Completed" \ + "Delete" "delete" "Delete" \ + "[_ contacts.Mail_Merge]" "mail-merge" "[_ contacts.lt_E-mail_or_Mail_the_se]" \ + ]\ + -bulk_action_export_vars { + {return_url} + } \ + -sub_class { + narrow + } \ + -filters { + search_id {} + query {} + page_size {} + tasks_interval {} + process_instance {} + } \ + -orderby { + default_value $orderby + end_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)" + 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)" + 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" + 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" + default_direction asc + } + process { + 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" + default_direction asc + } + } + +db_multirow -extend { contact_url } -unclobber tasks tasks_select {} { + set contact_url "/contacts/${party_id}/" +} + + +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 +} +set search_options [concat [list [list [_ contacts.All_Contacts] ""]] [db_list_of_lists dbqd.contacts.www.index.public_searches {}]] + +set searchcount 1 +db_foreach dbqd.contacts.www.index.my_recent_searches {} { + lappend search_options [list "${searchcount}) ${recent_title}" ${recent_search_id}] + incr searchcount +} + +set form_elements { + {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')"}}} +} + +if { [parameter::get -boolean -parameter "ForceSearchBeforeAdd" -default "0"] } { + if { [exists_and_not_null query] && $search_id == "" } { + append form_elements { + {add_person:text(submit) {label {[_ contacts.Add_Person]}} {value "1"}} + {add_organization:text(submit) {label {[_ contacts.Add_Organization]}} {value "1"}} + } + } +} + +ad_form -name "search" -method "GET" -export {orderby page_size format} -form $form_elements \ + -on_request { + } -edit_request { + } -on_refresh { + } -on_submit { + } -after_submit { + } + Index: openacs-4/packages/tasks/www/index.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/index.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/index.xql 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,105 @@ + + + + + + select pt.task_id + 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, + ( select task_id, party_id + from pm_task_assignment + where party_id in ( select parties.party_id + from parties left join cr_items on (parties.party_id = cr_items.item_id) left join cr_revisions on (cr_items.latest_revision = cr_revisions.revision_id ) , group_distinct_member_map + where parties.party_id = group_distinct_member_map.member_id + and group_distinct_member_map.group_id = '11428599' + [contact::search_clause -and -search_id $search_id -query $query -party_id "parties.party_id" -revision_id "revision_id"] ) + and role_id = '1' ) assigned_tasks + where ci.parent_id = '$project_id' + and ci.item_id = pt.task_id + and ci.live_revision = ptr.task_revision_id + and ci.live_revision = cr.revision_id + and pt.status = 1 + and ptr.end_date is not null + and pt.deleted_p = 'f' + and pt.task_id = assigned_tasks.task_id + and pt.task_id = ao.object_id + and CASE WHEN ao.creation_user = assigned_tasks.party_id THEN + CASE WHEN assigned_tasks.party_id = '$user_id' THEN 'f'::boolean ELSE 't'::boolean END + ELSE 't'::boolean END + and ptr.end_date < ( now() + '$tasks_interval days'::interval ) + [template::list::orderby_clause -orderby -name tasks] + + + + + + select count(*) + 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, + ( select task_id, party_id + from pm_task_assignment + where party_id in ( select parties.party_id + from parties left join cr_items on (parties.party_id = cr_items.item_id) left join cr_revisions on (cr_items.latest_revision = cr_revisions.revision_id ) , group_distinct_member_map + where parties.party_id = group_distinct_member_map.member_id + and group_distinct_member_map.group_id = '11428599' + [contact::search_clause -and -search_id $search_id -query $query -party_id "parties.party_id" -revision_id "revision_id"] ) + and role_id = '1' ) assigned_tasks + where ci.parent_id = '$project_id' + and ci.item_id = pt.task_id + and ci.live_revision = ptr.task_revision_id + and ci.live_revision = cr.revision_id + and pt.status = 1 + and ptr.end_date is not null + and pt.deleted_p = 'f' + and pt.task_id = assigned_tasks.task_id + and pt.task_id = ao.object_id + and CASE WHEN ao.creation_user = assigned_tasks.party_id THEN + CASE WHEN assigned_tasks.party_id = '$user_id' THEN 'f'::boolean ELSE 't'::boolean END + ELSE 't'::boolean END + and ptr.end_date < ( now() + '$tasks_interval days'::interval ) + + + + + + select pt.task_id, + tasks__relative_date(ptr.end_date) as end_date, + CASE WHEN ptr.end_date < now() THEN 't'::boolean ELSE 'f'::boolean END as overdue_p, + cr.title, + ptr.priority, + contact__name(assigned_tasks.party_id,:name_order) as contact_name, + assigned_tasks.party_id, + ppi.name as process, + ppi.process_id as process_id + 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, + pm_task_assignment as assigned_tasks + where ci.parent_id = :project_id + and ci.item_id = pt.task_id + and ci.live_revision = ptr.task_revision_id + and ci.live_revision = cr.revision_id + and pt.status = 1 + and ptr.end_date is not null + and pt.deleted_p = 'f' + and pt.task_id = assigned_tasks.task_id + and pt.task_id = ao.object_id + and CASE WHEN ao.creation_user = assigned_tasks.party_id THEN + CASE WHEN assigned_tasks.party_id = :user_id THEN 'f'::boolean ELSE 't'::boolean END + ELSE 't'::boolean END + and ptr.end_date < ( now() + '$tasks_interval days'::interval ) + [template::list::page_where_clause -and -name tasks -key pt.task_id] + [template::list::orderby_clause -orderby -name tasks] + + + + + Index: openacs-4/packages/tasks/www/mail-merge.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/mail-merge.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/mail-merge.tcl 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,23 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: mail-merge.tcl,v 1.1 2005/07/27 13:44:59 maltes Exp $ + +} { + {task_id:integer,multiple} + {return_url:notnull} +} + +set party_ids [db_list get_party_ids " + select distinct party_id + from pm_task_assignment + where task_id in ('[join $task_id {','}]') +"] + +ad_returnredirect [export_vars -base "/contacts/message" -url {return_url party_ids}] +ad_script_abort + + + + Index: openacs-4/packages/tasks/www/mark-completed.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/mark-completed.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/mark-completed.adp 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,9 @@ + +@title@ +@context@ + +

@question@

+

+ #tasks.Yes# - #tasks.No_Cancel# +

+ 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/mark-completed.tcl 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,75 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: mark-completed.tcl,v 1.1 2005/07/27 13:45:00 maltes Exp $ + +} { + {task_id:integer,multiple} + {confirm_p:boolean 1} + {status_id:integer ""} + {orderby ""} + {return_url:notnull} +} +# {party_id:integer,notnull} + +set num_entries [llength $task_id] + +if { [string is false $confirm_p] } { + + if { $num_entries == 0 } { + ad_returnredirect ./ + return + } + set title "Mark [ad_decode $num_entries 1 "Task" "Tasks"] as 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 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" +} + + +if { $num_entries > 1 } { + set task_list "" + set num 1 + foreach task_title $task_titles { + if { $num == $num_entries } { + append task_list " and " + } elseif { $num != 1 } { + append task_list ", " + } + append task_list "\"${task_title}\"" + incr num + } + util_user_message -html -message "The tasks ${task_list} were marked done" +} else { + util_user_message -html -message "The task \"[lindex $task_titles 0]\" was marked done" +} +#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/old-process-assign.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/old-process-assign.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/old-process-assign.adp 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,9 @@ + +@title@ +@context_bar;noquote@ + +@form_definition_beg;noquote@ + @select_widget;noquote@ + +@form_definition_end;noquote@ + Index: openacs-4/packages/tasks/www/process-add-edit-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/process-add-edit-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-add-edit-oracle.xql 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,47 @@ + + + + + select sysdate 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 + WHERE process_id = :process_id + + + + 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-add-edit-postgresql.xql 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,49 @@ + + + + + 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 + where process_id = :process_id + + + + Index: openacs-4/packages/tasks/www/process-add-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/process-add-edit.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-add-edit.adp 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,8 @@ + +@context@ +@title@ +add_edit.one_line + +
+ +
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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-add-edit.tcl 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,87 @@ +ad_page_contract { + + Simple add/edit form for processs + + @author jader@bread.com + @creation-date 2003-09-15 + @cvs-id $Id: process-add-edit.tcl,v 1.1 2005/07/27 13:44:59 maltes Exp $ + + @return context_bar Context bar. + @return title Page title. + +} { + + process_id:integer,optional + {one_line ""} + {description ""} + {number_of_tasks:integer ""} + +} -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 title "Edit: $process" + set context [list [list "processes" Processes] [list [export_vars -base "process" -url {process_id}] $process] "Edit"] + # permissions + permission::require_permission -party_id $user_id -object_id $package_id -privilege write +} else { + set title "Add a Process" + set context [list [list "processes" Processes] $title] + # permissions + permission::require_permission -party_id $user_id -object_id $package_id -privilege create +} + + +ad_form -name add_edit -form { + process_id:key + + {one_line:text + {label "Process"} + {value $one_line} + {html {size 40}} + } + + {description:text(textarea),optional + {label "Description"} + {value $description} + {html { rows 5 cols 40 wrap soft}}} + +} -select_query_name process_query -on_submit { + + set party_id [ad_conn user_id] + set creation_date [db_string get_today { }] + +} -new_data { + set process_id [db_nextval pm_process_seq] + + db_dml new_process { *SQL* } + + ad_returnredirect -message "Process added. Now add a process task." [export_vars -base process-task -url { process_id}] + ad_script_abort + +} -edit_data { + + db_dml edit_process { *SQL* } + +} -after_submit { + + ad_returnredirect -message "Process changes saved." [export_vars -base process -url {process_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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-assign.tcl 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,69 @@ +ad_page_contract { + + Page to get the process if one is missing for task creation + + @author jader@bread.com + @creation-date 2003-10-08 + @cvs-id $Id: process-assign.tcl,v 1.1 2005/07/27 13:45:00 maltes Exp $ + + @return context_bar Context bar. + @return title Page title. + @return projects A multirow containing the list of projects + + @param process_id The process we're using to create this task +} { + {process_id:integer,notnull} + {assignee_id:integer,notnull} +} -properties { + + context_bar:onevalue + title:onevalue + select_widget:onevalue + select_widget_name:onevalue + form_definition_beg:onevalue + form_definition_end:onevalue + +} -validate { +} -errors { +} + + +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_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 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 + + 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" + +} +} + + +ad_returnredirect [export_vars -base "contact" -url {{party_id $assignee_id}}] Index: openacs-4/packages/tasks/www/process-delete.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/process-delete.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-delete.adp 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,17 @@ + + @title@ + @context@ + +

+ #tasks.lt_Are_you_sure_you_want# + +

+ @description@ +
+ +

+ #tasks.Delete# +     + #tasks.Cancel_do_not_delete# +

+ 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-delete.tcl 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,44 @@ +# + +ad_page_contract { + + Delete a process + + @author Jade Rubick (jader@bread.com) + @creation-date 2004-06-25 + @arch-tag: e4153029-2cda-462d-b429-8f2b24999580 + @cvs-id $Id: process-delete.tcl,v 1.1 2005/07/27 13:45:00 maltes Exp $ +} { + process_id:integer + {confirm_p:boolean 0} + {return_url "processes"} +} -properties { +} -validate { +} -errors { +} + +set package_id [ad_conn package_id] + + +if {[string is false $confirm_p]} { + + db_1row get_name "select one_line, description from pm_process where process_id = :process_id" + + set title "Delete process: $one_line" + set context [list "Delete: $one_line"] + + set yes_url "process-delete?[export_vars {process_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 +} +ad_returnredirect -message "Process deleted" $return_url Index: openacs-4/packages/tasks/www/process-instances.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/process-instances.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-instances.adp 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,6 @@ + + @title@ + @header_stuff@ + @context@ + + Index: openacs-4/packages/tasks/www/process-instances.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/process-instances.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-instances.tcl 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,73 @@ +# + +ad_page_contract { + + Lists all the process instances of a given process_id + + @author (ibr@test) + @creation-date 2004-11-05 + @arch-tag: 57bfd18d-a3e5-4047-8185-06707c42f058 + @cvs-id $Id: process-instances.tcl,v 1.1 2005/07/27 13:45:00 maltes Exp $ +} { + process_id:integer,notnull +} -properties { +} -validate { +} -errors { +} + + +# set up context bar +set title "Process Instances" +set context [list [list "Processes" processes] $title] +set header_stuff "" + +# the unique identifier for this package +set package_id [ad_conn package_id] +set user_id [ad_maybe_redirect_for_registration] + +# permissions +permission::require_permission -party_id $user_id -object_id $package_id -privilege read + +# Processes, using list-builder --------------------------------- + +template::list::create \ + -name instances \ + -multirow instances \ + -key instance_id \ + -elements { + edit { + display_template { + + Edit + + } + } + instance_id { + label "ID" + } + name { + label "Name" + } + project_item_id { + label "Project" + display_template { + @instances.project_name@ + } + } + active_tasks { + label "Active tasks" + } + } \ + -main_class { + narrow + } \ + -html { + width 100% + } + + +db_multirow -extend { delete_url creation_date } instances instances_query { +} { + set delete_url [export_vars -base "process-delete" {process_id}] +} + Index: openacs-4/packages/tasks/www/process-instances.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/process-instances.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-instances.xql 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,38 @@ + + + + + + + + + + + + SELECT + i.name, + i.instance_id, + i.project_item_id, + projectr.title as project_name, + (select count(*) + from + pm_tasks_active t, + pm_task_status s + where + t.status = s.status_id and + s.status_type = 'o' and + t.process_instance = i.instance_id) as active_tasks + FROM + pm_process_instance i, + cr_items projecti, + cr_revisions projectr + WHERE + i.process_id = :process_id and + i.project_item_id = projecti.item_id and + projecti.live_revision = projectr.revision_id + ORDER BY + i.instance_id desc + + + + Index: openacs-4/packages/tasks/www/process-interval.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/process-interval.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-interval.adp 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,6 @@ + + +@title@ +@context@ + +done. Index: openacs-4/packages/tasks/www/process-interval.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/process-interval.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-interval.tcl 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,126 @@ +ad_page_contract { + + Simple add/edit form for projects + + @author jader@bread.com, ncarroll@ee.usyd.edu.au + @creation-date 2003-05-15 + @cvs-id $Id: process-interval.tcl,v 1.1 2005/07/27 13:44:59 maltes Exp $ + + @return context_bar Context bar. + @return title Page title. + +} { + {party_id:integer,notnull} + process_instance:integer,optional + status_id:integer,optional + orderby:optional + {return_url ""} + action + days:integer +} -properties { +} + +if { $days != "7" } { + set days 7 +} + + +if { ![exists_and_not_null return_url] } { + set return_url [export_vars -base "contact" -url {party_id orderby status_id}] +} +if { $action == "minus" } { + set operand "-" +} else { + set operand "+" +} + +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] + +set interval_number 1 +db_foreach get_tasks { + select pt.task_id + from pm_tasks pt, cr_items ci, cr_revisions cr, pm_tasks_revisions ptr + where pt.process_instance = :process_instance + and pt.deleted_p != 't' + and pt.status = '1' + and pt.task_id = ci.item_id + and ci.live_revision = cr.revision_id + and cr.revision_id = ptr.task_revision_id + and ptr.end_date is not null + order by ptr.end_date +} { + + db_1row get_task_info " + select ci.item_id as task_id, + cr.title as task, + to_char((ptr.end_date $operand '[expr $days * $interval_number] 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 + " + 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) + " + + incr interval_number + + +} + +if { $action == "minus" } { + util_user_message -html -message "The process interval was decreased by $days days" +} else { + util_user_message -html -message "The process interval was increased by $days days" +} + +ad_returnredirect $return_url +ad_script_abort Index: openacs-4/packages/tasks/www/process-one-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/process-one-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-one-oracle.xql 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,22 @@ + + + + + + SELECT t.process_task_id, + t.one_line, + t.description, + t.estimated_hours_work, + t.estimated_hours_work_min, + t.estimated_hours_work_max, + d.dependency_type, + t.ordering + FROM pm_process_task t , + pm_process_task_dependency d + WHERE t.process_task_id = d.process_task_id (+) and + t.process_id = :process_id + [template::list::orderby_clause -orderby -name tasks] + + + + Index: openacs-4/packages/tasks/www/process-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/process-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-oracle.xql 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,17 @@ + + +postgresql7.3 + + + + SELECT p.process_id, + p.one_line, + p.description, + p.party_id, + to_char(p.creation_date,'YYYY-MM-DD') as creation_date_ansi + FROM pm_process p + ORDER BY p.one_line + + + + Index: openacs-4/packages/tasks/www/process-reminder.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/process-reminder.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-reminder.tcl 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,25 @@ +# + +ad_page_contract { + + Sends out a process status update + + @author (jader-ibr@bread.com) + @creation-date 2004-11-18 + @arch-tag: 1a2152ed-1746-4d03-b191-b00c3fb32731 + @cvs-id $Id: process-reminder.tcl,v 1.1 2005/07/27 13:44:59 maltes Exp $ +} { + instance_id:integer,notnull + project_item_id:integer,notnull + return_url:notnull +} -properties { +} -validate { +} -errors { +} + +pm::process::email_alert \ + -process_instance_id $instance_id \ + -project_item_id $project_item_id \ + -new_p f + +ad_returnredirect -message "Status update sent" $return_url Index: openacs-4/packages/tasks/www/process-task-delete.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/process-task-delete.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-task-delete.adp 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,9 @@ + +@title@ +@context@ + +

@question@

+

+ #tasks.Yes# - #tasks.No_Cancel# +

+ 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-task-delete.tcl 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,80 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: process-task-delete.tcl,v 1.1 2005/07/27 13:45:00 maltes Exp $ + +} { + {process_task_id:integer,multiple} + {confirm_p:boolean 0} + {status_id:integer ""} + {process_id:integer,notnull} + {orderby ""} +} + + +set num_entries [llength $process_task_id] + + +if { [string is false $confirm_p] } { + + if { $num_entries == 0 } { + ad_returnredirect ./ + return + } + 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 }] + return +} + +set user_id [ad_conn user_id] + +set task_titles [list] + +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 + and process_id = :process_id + }] + db_dml mark_delete { + delete + from tasks_pm_process_task + where process_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 } { + set task_list "" + set num 1 + foreach task_title $task_titles { + if { $num == $num_entries } { + append task_list " and " + } elseif { $num != 1 } { + append task_list ", " + } + append task_list "\"${task_title}\"" + incr num + } + util_user_message -html -message "The process tasks ${task_list} were deleted" +} else { + 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_script_abort + + + + Index: openacs-4/packages/tasks/www/process-task.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/process-task.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-task.adp 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,7 @@ + + +@context@ +@title@ +add_edit.task + + 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-task.tcl 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,223 @@ +ad_page_contract { + + Simple add/edit form for projects + + @author jader@bread.com, ncarroll@ee.usyd.edu.au + @creation-date 2003-05-15 + @cvs-id $Id: process-task.tcl,v 1.1 2005/07/27 13:44:59 maltes Exp $ + + @return context_bar Context bar. + @return title Page title. + +} { + process_id:integer,notnull + process_task_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}] } { + 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}] + +if { [ad_form_new_p -key process_task_id] } { + set title "Add Process Task" + set edit_buttons { + {Save save} + {{Save and Add Another} save_add_another} + } +} 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 + }] + 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] + + + +if { [ns_queryget "formbutton:delete"] != "" } { + ad_returnredirect [export_vars -base "process-task-delete" -url {process_id process_task_id status_id orderby}] + ad_script_abort +} + +ad_form -name add_edit \ + -cancel_url [export_vars -base "process" -url {process_id}] \ + -cancel_label "Cancel" \ + -edit_buttons $edit_buttons \ + -form { + process_task_id:key + process_id:integer(hidden) + + status_id:integer(hidden),optional + orderby:text(hidden),optional + + + {task:text(text) + {label "Process Task"} + {html { size 28 maxlength 50}} + } + + {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}} + } + + {priority:integer(select),optional + {label "Priority"} + {options {{{3 - Very Important} 3} {{2 - Important} 2} {{1 - Normal} 1} {{0 - Not Important} 0}}} + } + + {description:text(textarea),optional,nospell + {label "Notes"} + {html { rows 5 cols 50 wrap soft}}} + + } \ + -new_request { + + set status_id "1" + set priority "1" + + } -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 + } + 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}] + } -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' ) + } + 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 ) + } + 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" + } + + } -after_submit { + + if { [ns_queryget "formbutton:save_add_another"] != "" } { + set return_url [export_vars -url -base "process-task" {process_id}] + } else { + set return_url [export_vars -url -base "process" {process_id}] + } + ad_returnredirect $return_url + ad_script_abort + + } + Index: openacs-4/packages/tasks/www/process-use-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/process-use-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-use-oracle.xql 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,13 @@ + + + + + + SELECT process_id, + one_line + FROM pm_process + ORDER BY one_line + + + + Index: openacs-4/packages/tasks/www/process-use-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/process-use-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-use-postgresql.xql 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,14 @@ + + + + + + SELECT + process_id, + one_line + FROM pm_process + ORDER BY one_line + + + + Index: openacs-4/packages/tasks/www/process-use.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/process-use.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-use.adp 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,9 @@ + +@title@ +@context_bar;noquote@ + +@form_definition_beg;noquote@ + @select_widget;noquote@ + +@form_definition_end;noquote@ + Index: openacs-4/packages/tasks/www/process-use.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/process-use.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process-use.tcl 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,64 @@ +ad_page_contract { + + Page to get the process if one is missing for task creation + + @author jader@bread.com + @creation-date 2003-10-08 + @cvs-id $Id: process-use.tcl,v 1.1 2005/07/27 13:45:00 maltes Exp $ + + @return context_bar Context bar. + @return title Page title. + @return projects A multirow containing the list of projects + + @param process_id The process we're using to create this task +} { + + project_item_id:integer,notnull + +} -properties { + + context_bar:onevalue + title:onevalue + select_widget:onevalue + select_widget_name:onevalue + form_definition_beg:onevalue + form_definition_end:onevalue + +} -validate { +} -errors { +} + +# --------------------------------------------------------------- # + +set user_id [ad_maybe_redirect_for_registration] +set package_id [ad_conn package_id] + +# terminology +set project_term [parameter::get -parameter "ProjectName" -default "Project"] +set task_term [parameter::get -parameter "TaskName" -default "Task"] +set task_term_lower [parameter::get -parameter "taskname" -default "task"] +set use_uncertain_completion_times_p [parameter::get -parameter "UseUncertainCompletionTimesP" -default "1"] + + +set title "Use a process" +set context_bar [ad_context_bar [list "processes" "Processes"] "Use"] + + +# need to change this to show all the projects you're on by +# default, and then give you the option of selecting all projects +# as an option. + +set select_widget_name process_id +set select_widget "" + +set form_definition_beg "
" + +append form_definition_beg [export_vars -form {project_item_id}] +set form_definition_end "
" + Index: openacs-4/packages/tasks/www/process.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/process.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process.adp 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,6 @@ + +@title@ +@context@ + + + Index: openacs-4/packages/tasks/www/process.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/process.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process.tcl 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,114 @@ +ad_page_contract { + Main view page for one process + + @author jader@bread.com + @creation-date 2003-09-25 + @cvs-id $Id: process.tcl,v 1.1 2005/07/27 13:44:59 maltes Exp $ + + @param process_id The process we're looking at. + + @return process_id the id for the process + @return context_bar Context bar. + @return use_link the link to use this process + +} { + + process_id:integer,notnull + orderby:optional + {project_item_id ""} + +} -properties { + process_id:onevalue + context_bar:onevalue + use_link:onevalue +} -validate { +} -errors { + process_id:notnull {You must specify a process to use. Please back up and select a process} +} + +# --------------------------------------------------------------- + +# the unique identifier for this package +set package_id [ad_conn package_id] +set user_id [ad_maybe_redirect_for_registration] + +# permissions +permission::require_permission -party_id $user_id -object_id $package_id -privilege read + +set write_p [permission::permission_p -object_id $package_id -privilege write] +set create_p [permission::permission_p -object_id $package_id -privilege create] + +set use_uncertain_completion_times_p [parameter::get -parameter "UseUncertainCompletionTimesP" -default "1"] + +# 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 +set context [list [list processes "Processes"] $title] + +set use_link "" + + +set elements \ + [list \ + priority { + label "Priority" + } \ + one_line { + label "Subject" + display_template {@tasks.task@ + } + } \ + deadline { + label "Due" + display_template { + @tasks.due_interval@ after assignment + @tasks.pretty_due_date@ + } + } \ + ] + + +# Process tasks, using list-builder --------------------------------- +template::list::create \ + -name tasks \ + -multirow tasks \ + -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" \ + ] \ + -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)" + default_direction desc + } + } \ + -bulk_actions { + "Delete" "process-task-delete" "Delete tasks" + } \ + -bulk_action_export_vars { + process_id + project_item_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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/process.xql 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,21 @@ + + + + + + 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 + [template::list::orderby_clause -orderby -name tasks] + + + + Index: openacs-4/packages/tasks/www/processes-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/processes-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/processes-oracle.xql 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,17 @@ + + +oracle8.0 + + + + SELECT p.process_id, + p.one_line, + p.description, + p.party_id, + to_char(p.creation_date,'YYYY-MM-DD') as creation_date_ansi + FROM pm_process p + ORDER BY p.one_line + + + + 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/processes-postgresql.xql 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,23 @@ + + +postgresql7.3 + + + + 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 + + + + Index: openacs-4/packages/tasks/www/processes.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/processes.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/processes.adp 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,14 @@ + + +@assignee_id@ + + + + + +

#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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/processes.tcl 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,174 @@ +ad_page_contract { + + Main view page for projects. + + @author jader@bread.com, ncarroll@ee.usyd.edu.au + @creation-date 2003-05-15 + @cvs-id $Id: processes.tcl,v 1.1 2005/07/27 13:45:00 maltes Exp $ + + @return title Page title. + @return context Context bar. + @return projects Multirow data set of projects. + @return task_term Terminology for tasks + @return task_term_lower Terminology for tasks (lower case) + @return project_term Terminology for projects + @return project_term_lower Terminology for projects (lower case) +} { + {assignee_id:integer ""} +} -properties { + context:onevalue + processes:multirow + 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"] + +# the unique identifier for this package +set package_id [ad_conn package_id] +set user_id [ad_maybe_redirect_for_registration] + +# permissions +permission::require_permission -party_id $user_id -object_id $package_id -privilege read + +set write_p [permission::permission_p -object_id $package_id -privilege write] +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')"] + +# 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 "" +} else { + set mode "manage" + set title "Manage Processes" + set context [list $title] + set actions [list "Add Process" "process-add-edit" "Add a Process"] +} + +set elements "" + + + +template::list::create \ + -name processes \ + -multirow processes \ + -key item_id \ + -selected_format $mode \ + -elements { + assign { + label "" + display_template { + Assign + } + } + one_line { + label "Subject" + display_template { + + @processes.one_line@ + + } + } + description { + label "Description" + } + instances { + label "Times used" + display_template { + @processes.instances@ + } + } + owner_name { + label "Manager" + link_url_eval $owner_url + } + edit { + display_template { + + } + } + delete { + display_template { + + } + } + } -actions $actions \ + -filters { + orderby_process {} + } \ + -orderby { + one_line {orderby one_line} + default_value one_line,desc + } \ + -orderby_name orderby_project \ + -sub_class { + narrow + } \ + -html { + width 100% + } -formats { + assign { + label "Assign Layout" + layout table + row { + assign {} + one_line {} + description {} + owner_name {} + } + } + manage { + label "Assign Layout" + layout table + row { + edit {} + one_line {} + description {} + owner_name {} + instances {} + delete {} + } + } + } + +set mode_carryover $mode +db_multirow -extend { delete_url creation_date owner_url process_url assign_url mode } processes process_query { +} { + set mode $mode_carryover + set delete_url [export_vars -base "process-delete" {process_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}] + 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/query.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/query.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/query.xql 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,94 @@ + + + + + +select parties.party_id + from parties left join cr_items on (parties.party_id = cr_items.item_id) left join cr_revisions on (cr_items.latest_revision = cr_revisions.revision_id ) , group_distinct_member_map + where parties.party_id = group_distinct_member_map.member_id + and group_distinct_member_map.group_id = '11428599' +$search_clause +[template::list::orderby_clause -orderby -name "contacts"] + + + + + +select count(*) + from parties left join cr_items on (parties.party_id = cr_items.item_id) left join cr_revisions on (cr_items.latest_revision = cr_revisions.revision_id ) , group_distinct_member_map + where parties.party_id = group_distinct_member_map.member_id + and group_distinct_member_map.group_id = '11428599' +$search_clause + + + + + + + select admin_role.pretty_name as admin_role_pretty, + member_role.pretty_name as member_role_pretty + from acs_rel_roles admin_role, acs_rel_roles member_role + where admin_role.role = 'admin' + and member_role.role = 'member' + + + + + + + select title, search_id + from contact_searches + where owner_id = :owner_id + and title is not null + order by lower(title) + + + + + + + select arr.pretty_plural, + art.rel_type as relation_type, + ( select count(distinct gmm.member_id) from group_approved_member_map gmm where gmm.group_id = :group_id and gmm.rel_type = art.rel_type ) as member_count + from acs_rel_types art, + acs_rel_roles arr + where art.rel_type in ( select distinct gmm.rel_type from group_approved_member_map gmm where gmm.group_id = :group_id ) + and art.role_two = arr.role + + + + + + +select contact__name(parties.party_id), + parties.party_id, + cr_revisions.revision_id, + contact__name(parties.party_id,:name_order) as name, + parties.email, + ( select first_names from persons where person_id = party_id ) as first_names, + ( select last_name from persons where person_id = party_id ) as last_name, + ( select name from organizations where organization_id = party_id ) as organization + from parties left join cr_items on (parties.party_id = cr_items.item_id) left join cr_revisions on (cr_items.latest_revision = cr_revisions.revision_id ) , group_distinct_member_map + where parties.party_id = group_distinct_member_map.member_id + and group_distinct_member_map.group_id = '11428599' +$search_clause +[template::list::page_where_clause -and -name "contacts" -key "party_id"] +[template::list::orderby_clause -orderby -name "contacts"] + + + + + + + select mr.member_state as state, + count(mr.rel_id) as num_contacts + from membership_rels mr, acs_rels r + where r.rel_id = mr.rel_id + and r.object_id_one = :group_id + and r.rel_type = 'membership_rel' + group by mr.member_state + + + + + 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/task-interval.tcl 27 Jul 2005 13:44:59 -0000 1.1 @@ -0,0 +1,110 @@ +ad_page_contract { + + Simple add/edit form for projects + + @author jader@bread.com, ncarroll@ee.usyd.edu.au + @creation-date 2003-05-15 + @cvs-id $Id: task-interval.tcl,v 1.1 2005/07/27 13:44:59 maltes Exp $ + + @return context_bar Context bar. + @return title Page title. + +} { + {party_id:integer,notnull} + task_id:integer + status_id:integer,optional + orderby:optional + {return_url ""} + action + days:integer +} -properties { +} + +if { $days != "7" } { + set days 7 +} + + +if { ![exists_and_not_null return_url] } { + set return_url [export_vars -base "contact" -url {party_id orderby status_id}] +} +if { $action == "minus" } { + set operand "-" +} else { + set operand "+" +} + +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 + " +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_url [export_vars -base task -url {task_id status_id orderby}] + +if { $action == "minus" } { + util_user_message -html -message "The task $title moved up 7 days" +} else { + util_user_message -html -message "The task $title delayed 7 days" +} + + +ad_returnredirect $return_url +ad_script_abort Index: openacs-4/packages/tasks/www/task.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/task.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/task.adp 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,9 @@ + + + + + +@party_id@ + + + Index: openacs-4/packages/tasks/www/task.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/task.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/task.tcl 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,307 @@ +ad_page_contract { + + Simple add/edit form for projects + + @author jader@bread.com, ncarroll@ee.usyd.edu.au + @creation-date 2003-05-15 + @cvs-id $Id: task.tcl,v 1.1 2005/07/27 13:45:00 maltes Exp $ + + @return context_bar Context bar. + @return title Page title. + +} { + {party_id:integer,notnull,multiple} + {other_party_ids ""} + task_id:integer,optional + status_id:integer,optional + orderby:optional + {return_url ""} +} -properties { +} + +set party_count [expr [llength $party_id] + [llength $other_party_ids]] +if { $party_count > 1 && ![ad_form_new_p -key "task_id"] } { + ad_return_error "Not Allowed" "You are not allowed to bulk edit a task for multiple contacts" +} + +if { [llength $party_id] > 1 } { + set real_party_id [lindex $party_id 0] + set other_party_ids [list] + foreach party_id $party_id { + if { $party_id != $real_party_id } { + lappend other_party_ids $party_id + } + } + set party_id $real_party_id +} +set all_parties [concat $party_id $other_party_ids] +set names [list] +foreach party $all_parties { + lappend names [contact::link -party_id $party] +} +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 package_id [ad_conn package_id] +set user_id [ad_maybe_redirect_for_registration] +set project_id [tasks::project_id] + +set title "Add/Edit" +set context [list $title] + +if { ![ad_form_new_p -key task_id] } { + append edit_buttons { + {Update save} + {{Update and Add New Task} save_add_another} + {{Delete} delete} + } +} else { + set edit_buttons { + {{Add Task} save} + {{Add Task and Add Another} save_add_another} + } +} + +if { [ns_queryget "formbutton:delete"] != "" } { + ad_returnredirect [export_vars -base "delete" -url {task_id status_id orderby return_url}] + ad_script_abort +} + + +ad_form -name add_edit \ + -cancel_url $return_url \ + -cancel_label "Cancel" \ + -edit_buttons $edit_buttons \ + -form { + task_id:key + return_url:text(hidden),optional + status_id:integer(hidden),optional + orderby:text(hidden),optional + party_id:integer(hidden) + other_party_ids:text(hidden),optional + {names:text(hidden),optional {label {Add Task To}}} + + {task_prescribed:text(select),optional + {label "Standard Task"} + {options { + {{} {}} + {{Delete from Recruiting System} {Delete from Recruiting System}} + {{Follow Up Call} {Follow Up Call}} + {{Follow Up Email} {Follow Up Email}} + {{Have they responded?} {Have they responded?}} + {{Provide Promotional Information} {Provide Promotional Information}} + {{Send Letter} {Send Letter}} + {{Send Birthday Card} {Send Birthday Card}} + {{Send Class Schedule} {Send Class Schedule}} + {{Send Personal Note/Letter} {Send Personal Note/Letter}} + {{Send Web Info Card} {Send Web Info Card}} + }} + } + + {task:text(text),optional + {label "Custom Task"} + {html { maxlength 1000 size 35 }} + {help_text {You can either use a standard task or a custom task, but not both}} + } + + {end_date:text(text) + {label "Due"} + {html {id date1 size 10 maxlength 10}} + {help_text {if blank there is no due date}} + {after_html { + + + }} + } + + {completed_p:text(checkbox),optional + {label "Status"} + {options {{Completed 1}}} + } + + {priority:integer(select),optional + {label "Priority"} + {options {{{3 - Very Important} 3} {{2 - Important} 2} {{1 - Normal} 1} {{0 - Not Important} 0}}} + } + + {description:text(textarea),optional,nospell + {label "Notes"} + {html { rows 6 cols 60 wrap soft}}} + + } -new_request { + + set title "Add Task" + set context [list $title] + set status_id "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 + + } + if { $percent_complete >= "100" } { + set completed_p "1" + } + 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] { + if { [lindex $task_prescribed_option 0] == $task } { + set task_prescribed_p 1 + } + } + if { $task_prescribed_p } { + set task_prescribed $task + 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}} + } -on_submit { + set task_prescribed [string trim $task_prescribed] + set task [string trim $task] + if { [exists_and_not_null task_prescribed] && [exists_and_not_null task] } { + template::element set_error add_edit task_prescribed "Standard tasks are cannot be used in conjunction with custom tasks" + template::element set_error add_edit task "Standard tasks are cannot be used in conjunction with custom tasks" + } elseif { ![exists_and_not_null task_prescribed] && ![exists_and_not_null task] } { + template::element set_error add_edit task_prescribed "Either a custom task or standard task is required" + template::element set_error add_edit task "Either a custom task or standard task is required" + } elseif { [exists_and_not_null task_prescribed] } { + set task $task_prescribed + } + if { [string is false [::template::form::is_valid add_edit]] } { + 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} \ + -title ${task} \ + -description ${description} \ + -mime_type "text/plain" \ + -end_date ${end_date} \ + -percent_complete ${percent_complete} \ + -creation_user ${user_id} \ + -creation_ip ${peeraddr} \ + -package_id ${package_id} \ + -priority ${priority}] + + pm::task::assign -task_item_id $task_id -party_id $party + + } + + if { [llength $all_parties] == 1 } { + set task_url [export_vars -base task -url {task_id status_id orderby party_id}] + util_user_message -html -message "The task $task was added" + } else { + util_user_message -html -message "The task \"$task\" was added to $names" + } + + } -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 + + 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 "The task $title was updated" + + + } -after_submit { + if { ![exists_and_not_null return_url] } { + set return_url [export_vars -url -base "contact" {party_id}] + } + if { [ns_queryget "formbutton:save_add_another"] != "" } { + set return_url [export_vars -url -base "task" {orderby status_id party_id return_url}] + } + ad_returnredirect $return_url + ad_script_abort + + } + +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 }] + template::element::create add_edit creator \ + -datatype "text" \ + -widget "inform" \ + -label "" \ + -value "Originally created by [contact::name -party_id $creation_id]" \ + -optional +} else { + if { $party_count > 1 } { + template::element::set_properties add_edit names widget inform + } +} Index: openacs-4/packages/tasks/www/works-task.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tasks/www/Attic/works-task.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tasks/www/works-task.tcl 27 Jul 2005 13:45:00 -0000 1.1 @@ -0,0 +1,269 @@ +ad_page_contract { + + Simple add/edit form for projects + + @author jader@bread.com, ncarroll@ee.usyd.edu.au + @creation-date 2003-05-15 + @cvs-id $Id: works-task.tcl,v 1.1 2005/07/27 13:45:00 maltes Exp $ + + @return context_bar Context bar. + @return title Page title. + +} { + {party_id:integer,notnull,multiple} + task_id:integer,optional + status_id:integer,optional + orderby:optional + {return_url ""} +} -properties { +} + +if { ![exists_and_not_null return_url] } { + set return_url [export_vars -base "contact" -url {party_id orderby status_id}] +} + +set package_id [ad_conn package_id] +set user_id [ad_maybe_redirect_for_registration] +set project_id [tasks::project_id] + +set title "Add/Edit" +set context [list $title] + +if { ![ad_form_new_p -key task_id] } { + append edit_buttons { + {Update save} + {{Update and Add New Task} save_add_another} + {{Delete} delete} + } +} else { + set edit_buttons { + {{Add Task} save} + {{Add Task and Add Another} save_add_another} + } +} + +if { [ns_queryget "formbutton:delete"] != "" } { + ad_returnredirect [export_vars -base "delete" -url {task_id status_id orderby return_url}] + ad_script_abort +} + + +ad_form -name add_edit \ + -cancel_url $return_url \ + -cancel_label "Cancel" \ + -edit_buttons $edit_buttons \ + -form { + task_id:key + return_url:text(hidden),optional + status_id:integer(hidden),optional + orderby:text(hidden),optional + party_id:integer(hidden) + + {task_prescribed:text(select),optional + {label "Standard Task"} + {options { + {{} {}} + {{Delete from Recruiting System} {Delete from Recruiting System}} + {{Follow Up Call} {Follow Up Call}} + {{Follow Up Email} {Follow Up Email}} + {{Have they responded?} {Have they responded?}} + {{Provide Promotional Information} {Provide Promotional Information}} + {{Send Letter} {Send Letter}} + {{Send Birthday Card} {Send Birthday Card}} + {{Send Class Schedule} {Send Class Schedule}} + {{Send Personal Note/Letter} {Send Personal Note/Letter}} + {{Send Web Info Card} {Send Web Info Card}} + }} + } + + {task:text(text),optional + {label "Custom Task"} + {html { maxlength 1000 size 35 }} + {help_text {You can either use a standard task or a custom task, but not both}} + } + + {end_date:text(text) + {label "Due"} + {html {id date1 size 10 maxlength 10}} + {help_text {if blank there is no due date}} + {after_html { + + + }} + } + + {completed_p:text(checkbox),optional + {label "Status"} + {options {{Completed 1}}} + } + + {priority:integer(select),optional + {label "Priority"} + {options {{{3 - Very Important} 3} {{2 - Important} 2} {{1 - Normal} 1} {{0 - Not Important} 0}}} + } + + {description:text(textarea),optional,nospell + {label "Notes"} + {html { rows 6 cols 60 wrap soft}}} + + } -new_request { + + set title "Add Task" + set context [list $title] + set status_id "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 + + } + if { $percent_complete >= "100" } { + set completed_p "1" + } + 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] { + if { [lindex $task_prescribed_option 0] == $task } { + set task_prescribed_p 1 + } + } + if { $task_prescribed_p } { + set task_prescribed $task + 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}} + } -on_submit { + set task_prescribed [string trim $task_prescribed] + set task [string trim $task] + if { [exists_and_not_null task_prescribed] && [exists_and_not_null task] } { + template::element set_error add_edit task_prescribed "Standard tasks are cannot be used in conjunction with custom tasks" + template::element set_error add_edit task "Standard tasks are cannot be used in conjunction with custom tasks" + } elseif { ![exists_and_not_null task_prescribed] && ![exists_and_not_null task] } { + template::element set_error add_edit task_prescribed "Either a custom task or standard task is required" + template::element set_error add_edit task "Either a custom task or standard task is required" + } elseif { [exists_and_not_null task_prescribed] } { + set task $task_prescribed + } + if { [string is false [::template::form::is_valid add_edit]] } { + 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 { + + set task_id [pm::task::new -project_id ${project_id} \ + -title ${task} \ + -description ${description} \ + -mime_type "text/plain" \ + -end_date ${end_date} \ + -percent_complete ${percent_complete} \ + -creation_user ${user_id} \ + -creation_ip ${peeraddr} \ + -package_id ${package_id} \ + -priority ${priority}] + pm::task::assign -task_item_id $task_id -party_id $party_id + + set task_url [export_vars -base task -url {task_id status_id orderby party_id}] + util_user_message -html -message "The task $task was added" + + } -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 + + 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 "The task $title was updated" + + + } -after_submit { + if { ![exists_and_not_null return_url] } { + set return_url [export_vars -url -base "contact" {party_id}] + } + if { [ns_queryget "formbutton:save_add_another"] != "" } { + set return_url [export_vars -url -base "task" {orderby status_id party_id return_url}] + } + ad_returnredirect $return_url + ad_script_abort + + } + +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 }] + template::element::create add_edit creator \ + -datatype "text" \ + -widget "inform" \ + -label "" \ + -value "Originally created by [contact::name -party_id $creation_id]" \ + -optional +}