Commit 199d1a8f authored by Frank Bergmann's avatar Frank Bergmann

- started to add tasks to the timesheet entry page

parent 2c2003e5
...@@ -46,6 +46,7 @@ create table im_hours ( ...@@ -46,6 +46,7 @@ create table im_hours (
create index im_hours_project_id_idx on im_hours(project_id); create index im_hours_project_id_idx on im_hours(project_id);
create index im_hours_user_id_idx on im_hours(user_id); create index im_hours_user_id_idx on im_hours(user_id);
create index im_hours_day_idx on im_hours(day);
-- specified how many units of what material are planned for -- specified how many units of what material are planned for
......
...@@ -31,6 +31,10 @@ ad_page_contract { ...@@ -31,6 +31,10 @@ ad_page_contract {
{ return_url "" } { return_url "" }
} }
# ---------------------------------------------------------
# Default & Security
# ---------------------------------------------------------
set user_id [ad_maybe_redirect_for_registration] set user_id [ad_maybe_redirect_for_registration]
set bgcolor(0) " class=roweven " set bgcolor(0) " class=roweven "
set bgcolor(1) " class=rowodd " set bgcolor(1) " class=rowodd "
...@@ -46,16 +50,21 @@ set different_date_url "index?[export_ns_set_vars url [list julian_date]]" ...@@ -46,16 +50,21 @@ set different_date_url "index?[export_ns_set_vars url [list julian_date]]"
# "Log hours for a different project" # "Log hours for a different project"
set different_project_url "other-projects?[export_url_vars julian_date]" set different_project_url "other-projects?[export_url_vars julian_date]"
db_1row user_name_and_date " db_1row user_name_and_date "
select select
im_name_from_user_id(user_id) as user_name, im_name_from_user_id(user_id) as user_name,
to_char(to_date(:julian_date, 'J'), 'fmDay fmMonth fmDD, YYYY') as pretty_date to_char(to_date(:julian_date, 'J'), 'fmDay fmMonth fmDD, YYYY') as pretty_date
from from users
users where user_id = :user_id"
where
user_id = :user_id" set page_title "[_ intranet-timesheet2.lt_Hours_for_pretty_date]"
set context_bar [im_context_bar [list index "[_ intranet-timesheet2.Hours]"] "[_ intranet-timesheet2.Add_hours]"]
# ---------------------------------------------------------
# Build the SQL Subquery, determining the (parent)
# projects to be displayed
# ---------------------------------------------------------
if {0 != $project_id} { if {0 != $project_id} {
...@@ -63,32 +72,33 @@ if {0 != $project_id} { ...@@ -63,32 +72,33 @@ if {0 != $project_id} {
set one_project_only_p 1 set one_project_only_p 1
set statement_name "hours_for_one_group" set statement_name "hours_for_one_group"
set sql " set project_sql "
select select
p.project_name, p.project_id
p.project_id from
from im_projects p
im_projects p where
where p.project_id = :project_id
p.project_id = :project_id order by
order by upper(project_name)
upper(project_name)" "
} elseif {"" != $project_id_list} { } elseif {"" != $project_id_list} {
# An entire list of project has been selected
set one_project_only_p 0 set one_project_only_p 0
set statement_name "hours_for_one_group" set statement_name "hours_for_one_group"
set sql " set project_sql "
select select
p.project_name, p.project_id
p.project_id from
from im_projects p
im_projects p where
where p.project_id in ([join $project_id_list ","])
p.project_id in ([join $project_id_list ","]) order by
order by upper(project_name)
upper(project_name)" "
} else { } else {
...@@ -96,108 +106,161 @@ order by ...@@ -96,108 +106,161 @@ order by
set one_project_only_p 0 set one_project_only_p 0
set statement_name "hours_for_groups" set statement_name "hours_for_groups"
set sql " set project_sql "
select select
p.project_name, p.project_id
p.project_id from
from
im_projects p,
( select
r.object_id_one as project_id
from
im_projects p, im_projects p,
acs_rels r, ( select
im_categories psc r.object_id_one as project_id
where from
r.object_id_one = p.project_id im_projects p,
and object_id_two = :user_id acs_rels r,
and p.project_status_id = psc.category_id im_categories psc
and upper(psc.category) not in ( where
'CLOSED','INVOICED','PARTIALLY PAID', r.object_id_one = p.project_id
'DECLINED','DELIVERED','PAID','DELETED','CANCELED' and object_id_two = :user_id
) and p.project_status_id = psc.category_id
and upper(psc.category) not in (
UNION 'CLOSED','INVOICED','PARTIALLY PAID',
select 'DECLINED','DELIVERED','PAID','DELETED','CANCELED'
project_id )
from UNION
im_hours h select
where project_id
h.user_id = :user_id from
and h.day = to_date(:julian_date, 'J') im_hours h
) r where
where h.user_id = :user_id
r.project_id = p.project_id and h.day = to_date(:julian_date, 'J')
order by ) r
upper(p.project_name)" where
r.project_id = p.project_id
order by
upper(p.project_name)
"
} }
set extra_sql "
and p.group_id in (
select map.group_id
from user_group_map map
where map.user_id = :user_id
UNION
select h.project_id
from im_hours h
where h.user_id = :user_id
and (h.hours is not null OR h.note is not null)
and h.day = to_date(:julian_date, 'J')
)
"
# ---------------------------------------------------------
# Build the main hierarchical SQL
# ---------------------------------------------------------
set sql "
select
h.hours,
h.note,
h.billing_rate,
t.task_id,
t.task_nr,
t.task_name,
t.material_id,
t.uom_id,
t.planned_units,
t.reported_units_cache,
children.project_id as project_id,
children.project_nr as project_nr,
children.project_name as project_name,
parent.project_id as parent_project_id,
parent.project_nr as parent_project_nr,
parent.project_name as parent_project_name,
tree_level(children.tree_sortkey) - tree_level(parent.tree_sortkey) as subproject_level
from
im_projects parent,
im_projects children
left outer join (
select *
from im_hours h
where h.day = to_date(:julian_date, 'J')
and h.user_id = :user_id
) h on (children.project_id = h.project_id)
left outer join im_timesheet_tasks t on (children.project_id = t.project_id)
where
children.tree_sortkey between
parent.tree_sortkey and
tree_right(parent.tree_sortkey)
and parent.project_id in (
$project_sql
)
and children.project_status_id not in (
[im_project_status_deleted],
[im_project_status_canceled],
[im_project_status_closed]
)
order by
children.tree_sortkey
"
set page_title "[_ intranet-timesheet2.lt_Hours_for_pretty_date]" # ---------------------------------------------------------
set context_bar [im_context_bar [list index "[_ intranet-timesheet2.Hours]"] "[_ intranet-timesheet2.Add_hours]"] # Execute query and format results
# ---------------------------------------------------------
set results "" set results ""
set ctr 0 set ctr 0
set nbsps "      "
set old_project_id 0
db_foreach $statement_name $sql { db_foreach $statement_name $sql {
set hours_sql "select h.hours,
h.note, set indent ""
h.billing_rate while {$subproject_level > 0} {
from set indent "$nbsps$indent"
im_hours h set subproject_level [expr $subproject_level-1]
where
h.project_id = :project_id
and h.day = to_date(:julian_date, 'J')
and h.user_id = :user_id"
if {![db_0or1row "get hours info" $hours_sql]} {
set hours ""
set note ""
set billing_rate ""
} }
# Insert intermediate header for every new project
if {$old_project_id != $project_id} {
append results "
<tr $bgcolor([expr $ctr % 2])>
<td valign=top>
<nobr>
$indent
<A href=/intranet/projects/view?project_id=$project_id>
<B>$project_name</B>
</A>
</nobr>
</td>
<td valign=top>
<INPUT NAME=hours.${project_id}.hours size=5 MAXLENGTH=5 value=\"$hours\"]>
</td>
<td valign=top>
<INPUT NAME=hours.${project_id}.note size=60 value=\"[ns_quotehtml [value_if_exists note]]\">
</td>
</tr>\n"
set old_project_id $project_id
incr ctr
}
append results " append results "
<tr $bgcolor([expr $ctr % 2])> <tr $bgcolor([expr $ctr % 2])>
<td valign=top> <td valign=top>
<A href=/intranet/projects/view?project_id=$project_id> <nobr>
$project_name $indent$nbsps
</A> <A href=/intranet-timesheet2-tasks/view?[export_url_vars task_id]>
$task_name
</A>
</nobr>
</td> </td>
<td valign=top> <td valign=top>
<INPUT NAME=hours.${project_id}.hours size=5 MAXLENGTH=5 value=\"$hours\"]> <INPUT NAME=hours.${project_id}.hours size=5 MAXLENGTH=5 value=\"$hours\"]>
</td> </td>
<td valign=top> <td valign=top>
<TEXTAREA NAME=hours.${project_id}.note WRAP=SOFT COLS=30 ROWS=2>[ns_quotehtml [value_if_exists note]]</TEXTAREA> <INPUT NAME=hours.${project_id}.note size=60 value=\"[ns_quotehtml [value_if_exists note]]\">
</td> </td>
<!-- </tr>
<td valign=top>\$<INPUT NAME=hours.${project_id}.billing_rate size=6 MAXLENGTH=6 billing_rate=\"$billing_rate\"]> "
</td>
-->
</tr>\n"
incr ctr incr ctr
} }
if { [empty_string_p $results] } { if { [empty_string_p $results] } {
append results " append results "
<tr><td align=center><b> <tr>
[_ intranet-timesheet2.lt_There_are_currently_n_1]<br> <td align=center><b>
[_ intranet-timesheet2.lt_Please_notify_your_ma] [_ intranet-timesheet2.lt_There_are_currently_n_1]<br>
</b></td></tr>\n" [_ intranet-timesheet2.lt_Please_notify_your_ma]
</b></td>
</tr>\n"
} }
set export_form_vars [export_form_vars julian_date return_url] set export_form_vars [export_form_vars julian_date return_url]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment