set query_first_day_of_month "to_char(trunc(to_date(:the_date, 'yyyy-mm-dd'), 'Month'), 'D') as first_day_of_month,"
set query_first_day_of_month "to_char(trunc(to_date(:the_date, 'yyyy-mm-dd'), 'Month'), 'D') as first_day_of_month,"
if {$start_day > 0 && $start_day < 7}{
if {$start_day > 0 && $start_day < 7}{
set add [expr7 - $start_day]
set add [expr{7 - $start_day}]
set query_first_day_of_month "mod(cast(extract(dow from trunc(to_date(:the_date, 'yyyy-mm-dd'), 'Month')) as numeric)+$add,7)+1 as first_day_of_month,"
set query_first_day_of_month "mod(cast(extract(dow from trunc(to_date(:the_date, 'yyyy-mm-dd'), 'Month')) as numeric)+$add,7)+1 as first_day_of_month,"
}
}
# If no date was passed in, let's set it to today
# If no date was passed in, let's set it to today
if {$the_date ==""}{
if {$the_date eq""}{
set the_date [db_string sysdate_from_dual "select trunc(sysdate) from dual"]
set the_date [db_string sysdate_from_dual "select trunc(sysdate) from dual"]
ad_return_complaint 1 [lang::message::lookup "" intranet-timesheet2.Not_Allowed "You are not allowed to log hours for this day due to configuration restrictions. (Parameter: 'TimesheetWeeklyLoggingDays') "]
ad_return_complaint 1 [lang::message::lookup "" intranet-timesheet2.Not_Allowed "You are not allowed to log hours for this day due to configuration restrictions. (Parameter: 'TimesheetWeeklyLoggingDays') "]
}
}
...
@@ -122,15 +122,15 @@ if {$show_week_p} {
...
@@ -122,15 +122,15 @@ if {$show_week_p} {
# for the current week by adding or subtracting days depending on the weekday (to_char(.., 'D'))
# for the current week by adding or subtracting days depending on the weekday (to_char(.., 'D'))
## set day_of_week [db_string dow "select to_char(to_date(:julian_date, 'J'), 'D')"]
## set day_of_week [db_string dow "select to_char(to_date(:julian_date, 'J'), 'D')"]
# set julian_week_start [expr$julian_date + 1 - $day_of_week]
# set julian_week_start [expr{$julian_date + 1 - $day_of_week}]
# set julian_week_end [expr$julian_date + (7-$day_of_week)]
# set julian_week_end [expr{$julian_date + (7-$day_of_week)}]
## Reset the day to the start of the week.
## Reset the day to the start of the week.
# set julian_date $julian_week_start
# set julian_date $julian_week_start
# 1st day shown should be julian_date passed to this page
# 1st day shown should be julian_date passed to this page
set julian_week_start $julian_date
set julian_week_start $julian_date
set julian_week_end [expr$julian_date + [expr[llength$weekly_logging_days]-1]]
set julian_week_end [expr$julian_date + [expr{[llength$weekly_logging_days]-1}]]
# Condition to check for hours this week:
# Condition to check for hours this week:
set h_day_in_dayweek "h.day between to_date(:julian_week_start, 'J') and to_date(:julian_week_end, 'J')"
set h_day_in_dayweek "h.day between to_date(:julian_week_start, 'J') and to_date(:julian_week_end, 'J')"
...
@@ -172,7 +172,7 @@ if {$internal_note_exists_p} {
...
@@ -172,7 +172,7 @@ if {$internal_note_exists_p} {
if {$closed_p && (!$user_is_project_member_p && $project_is_task_p)}{
if {$closed_p && (!$user_is_project_member_p && $project_is_task_p)}{
append help_text [lang::message::lookup "" intranet-timesheet2.Nolog_closed_p "The project or one of its parents has been closed or requires membership. "]
append help_text [lang::message::lookup "" intranet-timesheet2.Nolog_closed_p "The project or one of its parents has been closed or requires membership. "]
}
}
if {![string eq "t"$edit_hours_p]}{ append help_text [lang::message::lookup "" intranet-timesheet2.Nolog_edit_hours_p "The time period has been closed for editing. "]}
if {"t" ne $edit_hours_p }{ append help_text [lang::message::lookup "" intranet-timesheet2.Nolog_edit_hours_p "The time period has been closed for editing. "]}
if {!$log_on_parent_p}{ append help_text [lang::message::lookup "" intranet-timesheet2.Nolog_log_on_parent_p "This project has sub-projects or tasks. "]}
if {!$log_on_parent_p}{ append help_text [lang::message::lookup "" intranet-timesheet2.Nolog_log_on_parent_p "This project has sub-projects or tasks. "]}
if {$solitary_main_project_p}{
if {$solitary_main_project_p}{
append help_text [lang::message::lookup "" intranet-timesheet2.Nolog_solitary_main_project_p "This is a 'solitary' main project. Your system is configured in such a way, that you can't log hours on it. "]
append help_text [lang::message::lookup "" intranet-timesheet2.Nolog_solitary_main_project_p "This is a 'solitary' main project. Your system is configured in such a way, that you can't log hours on it. "]
set sql_from_imhours "select day, user_id, sum(hours) as val, 'h' as type, '' as descr from im_hours where project_id = :project_id group by user_id, day"
set sql_from_imhours "select day, user_id, sum(hours) as val, 'h' as type, '' as descr from im_hours where project_id = :project_id group by user_id, day"
}else{
}else{
set sql_from_imhours "select day, user_id, sum(hours) as val, 'h' as type, '' as descr from im_hours group by user_id, day"
set sql_from_imhours "select day, user_id, sum(hours) as val, 'h' as type, '' as descr from im_hours group by user_id, day"
...
@@ -637,12 +637,12 @@ db_foreach get_hours $sql {
...
@@ -637,12 +637,12 @@ db_foreach get_hours $sql {
}
}
# Set hours
# Set hours
if {$type=="h"}{
if {$typeeq"h"}{
set user_days($curr_day)$val
set user_days($curr_day)$val
}
}
# Set absences
# Set absences
if {$type=="a"}{
if {$typeeq"a"}{
set user_absences($curr_day)$val
set user_absences($curr_day)$val
set user_ab_descr($val)$descr
set user_ab_descr($val)$descr
}
}
...
@@ -650,14 +650,14 @@ db_foreach get_hours $sql {
...
@@ -650,14 +650,14 @@ db_foreach get_hours $sql {
incr ctr
incr ctr
}
}
set colspan [expr[llength$days]+1]
set colspan [expr{[llength$days]+1}]
if{$ctr > 0 }{
if{$ctr > 0 }{
# Writing last record
# Writing last record
ns_log notice "weekly_report: left loop, now writing last record"
ns_log notice "weekly_report: left loop, now writing last record"
append table_body_html [im_do_row [array get bgcolor]$ctr$curr_owner_id $owner_name $days[array get user_days][array get user_absences]$holydays$today_date [array get user_ab_descr]$workflow_key ]
append table_body_html [im_do_row [array get bgcolor]$ctr$curr_owner_id $owner_name $days[array get user_days][array get user_absences]$holydays$today_date [array get user_ab_descr]$workflow_key ]
}elseif {[empty_string_p $table_body_html]}{
}elseif {$table_body_html eq ""}{
# Show a reasonable message when there are no result rows:
# Show a reasonable message when there are no result rows:
set table_body_html "
set table_body_html "
<tr><td colspan=$colspan><ul><li><b>
<tr><td colspan=$colspan><ul><li><b>
...
@@ -677,7 +677,7 @@ set navig_sql "
...
@@ -677,7 +677,7 @@ set navig_sql "
dual"
dual"
db_1row get_navig_dates $navig_sql
db_1row get_navig_dates $navig_sql
set switch_link_html "<a href=\"weekly_report?[export_vars -url {owner_id project_id duration display}]"
set switch_link_html "<a href=\[export_vars -base weekly_report {owner_id project_id duration display}]
set switch_past_html "$switch_link_html&start_at=$past_date&cost_center_id=$cost_center_id&department_id=$department_id&workflow_key=$workflow_key\">«</a>"
set switch_past_html "$switch_link_html&start_at=$past_date&cost_center_id=$cost_center_id&department_id=$department_id&workflow_key=$workflow_key\">«</a>"
set switch_future_html "$switch_link_html&start_at=$future_date&cost_center_id=$cost_center_id&department_id=$department_id&workflow_key=$workflow_key\">»"
set switch_future_html "$switch_link_html&start_at=$future_date&cost_center_id=$cost_center_id&department_id=$department_id&workflow_key=$workflow_key\">»"