Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-timesheet2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-timesheet2
Commits
984f5076
Commit
984f5076
authored
Dec 20, 2023
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrating attendance management
parent
09881be9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
99 additions
and
70 deletions
+99
-70
index.tcl
www/hours/index.tcl
+99
-70
No files found.
www/hours/index.tcl
View file @
984f5076
...
...
@@ -108,22 +108,22 @@ set header_days_of_week "";
# Patch: http://sourceforge.net/projects/project-open/forums/forum/295937/topic/3324310
for {set i
$start
_day} {
$i
< 7} {incr i} {
if {
$i
==0} { append header_days_of_week "
[
_ intranet-timesheet2.Sunday
]
" }
if {
$i
==1} { append header_days_of_week "
[
_ intranet-timesheet2.Monday
]
" }
if {
$i
==2} { append header_days_of_week "
[
_ intranet-timesheet2.Tuesday
]
" }
if {
$i
==3} { append header_days_of_week "
[
_ intranet-timesheet2.Wednesday
]
" }
if {
$i
==4} { append header_days_of_week "
[
_ intranet-timesheet2.Thursday
]
" }
if {
$i
==5} { append header_days_of_week "
[
_ intranet-timesheet2.Friday
]
" }
if {
$i
==6} { append header_days_of_week "
[
_ intranet-timesheet2.Saturday
]
" }
if {
$i
==
0} { append header_days_of_week "
[
_ intranet-timesheet2.Sunday
]
" }
if {
$i
==
1} { append header_days_of_week "
[
_ intranet-timesheet2.Monday
]
" }
if {
$i
==
2} { append header_days_of_week "
[
_ intranet-timesheet2.Tuesday
]
" }
if {
$i
==
3} { append header_days_of_week "
[
_ intranet-timesheet2.Wednesday
]
" }
if {
$i
==
4} { append header_days_of_week "
[
_ intranet-timesheet2.Thursday
]
" }
if {
$i
==
5} { append header_days_of_week "
[
_ intranet-timesheet2.Friday
]
" }
if {
$i
==
6} { append header_days_of_week "
[
_ intranet-timesheet2.Saturday
]
" }
}
for {set i 0} {
$i
<
$start
_day} {incr i} {
if {
$i
==0} { append header_days_of_week "
[
_ intranet-timesheet2.Sunday
]
" }
if {
$i
==1} { append header_days_of_week "
[
_ intranet-timesheet2.Monday
]
" }
if {
$i
==2} { append header_days_of_week "
[
_ intranet-timesheet2.Tuesday
]
" }
if {
$i
==3} { append header_days_of_week "
[
_ intranet-timesheet2.Wednesday
]
" }
if {
$i
==4} { append header_days_of_week "
[
_ intranet-timesheet2.Thursday
]
" }
if {
$i
==5} { append header_days_of_week "
[
_ intranet-timesheet2.Friday
]
" }
if {
$i
==6} { append header_days_of_week "
[
_ intranet-timesheet2.Saturday
]
" }
if {
$i
==
0} { append header_days_of_week "
[
_ intranet-timesheet2.Sunday
]
" }
if {
$i
==
1} { append header_days_of_week "
[
_ intranet-timesheet2.Monday
]
" }
if {
$i
==
2} { append header_days_of_week "
[
_ intranet-timesheet2.Tuesday
]
" }
if {
$i
==
3} { append header_days_of_week "
[
_ intranet-timesheet2.Wednesday
]
" }
if {
$i
==
4} { append header_days_of_week "
[
_ intranet-timesheet2.Thursday
]
" }
if {
$i
==
5} { append header_days_of_week "
[
_ intranet-timesheet2.Friday
]
" }
if {
$i
==
6} { append header_days_of_week "
[
_ intranet-timesheet2.Saturday
]
" }
}
set weekly_logging_days
[
parameter::get_from_package_key -package_key intranet-timesheet2 -parameter TimesheetWeeklyLoggingDays -default
"0 1 2 3 4 5 6"
]
...
...
@@ -131,11 +131,11 @@ set weekly_logging_days [parameter::get_from_package_key -package_key intranet-t
# ---------------------------------
# Date Logic: We are working with "
YYYY-MM-DD
" dates in this page.
if {"" ==
$date
} {
if {"" ==
$date
} {
if {"" !=
$julian
_date} {
set date
[
db_string julian_date_select
"select to_char(
to_date(:julian_date,'J'), 'YYYY-MM-DD') from dual"
]
set date
[
db_string julian_date_select
"select to_char(to_date(:julian_date,'J'), 'YYYY-MM-DD') from dual"
]
} else {
set date
[
db_string ansi_date_select
"select to_char(
sysdate, 'YYYY-MM-DD') from dual"
]
set date
[
db_string ansi_date_select
"select to_char(sysdate, 'YYYY-MM-DD') from dual"
]
}
}
...
...
@@ -170,30 +170,49 @@ if {"" != [parameter::get -package_id [apm_package_id_from_key intranet-timeshee
if {!
[
im_column_exists im_hours conf_object_id
]
} { set confirm_timesheet_hours_p 0 }
# ---------------------------------------------------------------
# Render the Calendar widget
# ---------------------------------------------------------------
set calendar_details
[
ns_set create calendar_details
]
# figure out the first and last julian days in the month
# This call defines a whole set of variables in our environment
calendar_get_info_from_db
$date
# ---------------------------------------------------------------
# Attendance Management
# ---------------------------------------------------------------
if {
$attendance
_management_installed_p} {
set attendance_sql "
select ai.*,
to_char
(
ai.attendance_start, 'YYYY-MM-DD'
)
as attendance_start_date,
to_char
(
ai.attendance_start, 'J'
)
as attendance_start_julian,
im_category_from_id
(
ai.attendance_type_id
)
as type,
round
((
extract
(
epoch from attendance_end - attendance_start
)
/ 3600
)
::numeric, 2
)
as duration_hours
round
((
extract
(
epoch from attendance_end - attendance_start
)
/ 3600
)
::numeric, 2
)
as duration_hours,
coalesce
(
EXTRACT
(
EPOCH FROM ai.attendance_end - ai.attendance_start
)
/ 3600, 0
)
as attendance_duration_hours,
(
select sum
(
hours
)
from im_hours h where h.user_id = :user_id_from_search and h.day::date = ai.attendance_start::date
)
as ts_sum_per_user_day
from im_attendance_intervals ai
where ai.attendance_user_id = :current_user_id and
ai.attendance_start::date >= :first_day_of_month_ansi::date and
ai.attendance_id is not null and -- discard elements in process of completing
ai.attendance_end::date <= :last_day_of_month_ansi::date
where ai.attendance_user_id = :user_id_from_search and
ai.attendance_start::date >= to_date
(
:first_julian_date, 'J'
)
and
ai.attendance_end is not null and -- discard elements in process of completing
ai.attendance_end::date <= to_date
(
:last_julian_date, 'J'
)
order by
ai.attendance_start
"
# Sum up all attendances for all days of that month
# and store into att_work_hash and att_break_hash
set attendance_work 0.0
set attendance_break 0.0
db_foreach attendances
$attendance
_sql {
# -----------------------------------------------------------
# Sum up all attendances for all days of that month and store into att_work_hash and att_break_hash
set att_type
[
string
tolower
$type
]
switch
$attendance
_type_id {
92100 {
...
...
@@ -213,20 +232,27 @@ if {$attendance_management_installed_p} {
set attendance_break
[
expr
$attendance
_break +
$duration
_hours
;]
}
}
# -----------------------------------------------------------
# Check for consistence: Create a list of atts for each
$key
order by attendance_start
# Aggregate attendance data per day and user
# cell_hash: Temporary hash with the ordered list of attendances per day
# error_hash: List of all errors in atts per day
set key "
$attendance
_start_julian
"
set v
[
list
]
if {
[
info
exists cell_hash
(
$key
)]
} { set v
$cell
_hash(
$key
) }
# Write attendance data into hash-list
set list
[
list
]
set vars {attendance_id attendance_type_id attendance_start_date attendance_start attendance_end attendance_duration_hours ts_sum_per_user_day}
foreach var
$vars
{ lappend list
$var
[
set
$var
]
}
lappend v
$list
set cell_hash(
$key
)
$v
}
}
# ---------------------------------------------------------------
# Render the Calendar widget
# ---------------------------------------------------------------
set calendar_details
[
ns_set create calendar_details
]
# figure out the first and last julian days in the month
# This call defines a whole set of variables in our environment
calendar_get_info_from_db
$date
# ad_return_complaint 1 "
<pre>
[
join
[
array
get cell_hash
]
"
\n
"
]
\n\n\n
[
array
get error_hash
]
</pre>
"
# --------------------------------------------------------------
# Grab all the hours from im_hours
...
...
@@ -240,9 +266,7 @@ set sql "
group by
to_char
(
day, 'J'
)
"
db_foreach hours_logged
$sql
{
set users_hours(
$julian
_date)
$hours
}
db_foreach hours_logged
$sql
{ set users_hours(
$julian
_date)
$hours
}
# --------------------------------------------------------------
# Render the calendar
...
...
@@ -250,9 +274,6 @@ db_foreach hours_logged $sql {
set hours_for_this_week 0.0
set hours_for_this_month 0.0
set unconfirmed_hours_for_this_week 0.0
set unconfirmed_hours_for_this_month 0.0
set absence_list
[
absence_list_for_user_and_time_period
$user
_id_from_search
$first
_julian_date
$last
_julian_date
]
set absence_index 0
set curr_absence ""
...
...
@@ -271,14 +292,19 @@ if {1 == $start_day} {
# Helper to determine location of last WF confirm button -> last day shown or last day of month
set show_last_confirm_button_p 1
set timesheet_entry_blocked_p 0
# And now fill in information for every day of the month
for {set current_date
$first
_julian_date} {
$current
_date <=
$last
_julian_date} {incr current_date} {
# -------------------------------------------------------------------------
# Setup base variables
set current_date_ansi
[
dt_julian_to_ansi
$current
_date
]
# Unconfirmed hours in workflow
if {!
[
info
exists unconfirmed_hours
(
$current
_date
)]
} { set unconfirmed_hours(
$current
_date) "" }
if {"" ==
$unconfirmed
_hours(
$current
_date)} { set unconfirmed_hours(
$current
_date) 0 }
if {
$confirm
_timesheet_hours_p} {
set no_ts_approval_wf_sql "
select count
(
*
)
...
...
@@ -298,7 +324,7 @@ for {set current_date $first_julian_date} {$current_date <= $last_julian_date} {
# User's hours for the day
set hours ""
if {
[
info
exists users_hours
(
$current
_date
)]
&&
$users
_hours(
$current
_date) ne ""} {
set hours "
$users
_hours
(
$current
_date
)
[
lang::message::lookup
""
intranet-timesheet2.hours
"hours
"
]
"
set hours "
[
lang::message::lookup
""
intranet-timesheet2.Projects
"Projects"
]
:
$users
_hours
(
$current
_date
)[
lang::message::lookup
""
intranet-timesheet2.h
"h
"
]
"
set hours_for_this_week
[
expr
{
$hours
_for_this_week +
$users
_hours
(
$current
_date
)}]
# Sum today's hours to total month, if the month has actually started
...
...
@@ -306,24 +332,17 @@ for {set current_date $first_julian_date} {$current_date <= $last_julian_date} {
if {
$current
_date >=
$first
_day_of_month_julian} {
set hours_for_this_month
[
expr
{
$hours
_for_this_month +
$users
_hours
(
$current
_date
)}]
}
} else {
if {
$timesheet
_entry_blocked_p} {
set hours "
<span class='log_hours'>
[
lang::message::lookup
""
intranet-timesheet2.Nolog_Workflow_In_Progress
"0 hours"
]
</span>
"
# Fraber 2023-12-12: I'm quite sure that is unreachable code, because there are no hours for that day.
set hours "
<span class='log_hours'>
[
lang::message::lookup
""
intranet-timesheet2.Nolog_Workflow_In_Progress
"0 hours"
]
xxx </span>
"
} else {
if {
[
string
first
$week
_day
$weekly
_logging_days
]
!= -1} {
set hours "
<span class='log_hours'>
[
lang::message::lookup
""
intranet-timesheet2.Log_hours
"Log hours"
]
</span>
"
set hours "
<span class='log_hours'>
<nobr>
[
lang::message::lookup
""
intranet-timesheet2.Projects
"Projects"
]
:
[
lang::message::lookup
""
intranet-timesheet2.Log_hours
"Log hours"
]
</nobr>
</span>
"
}
}
}
if {!
[
info
exists unconfirmed_hours
(
$current
_date
)]
} { set unconfirmed_hours(
$current
_date) "" }
if {"" ==
$unconfirmed
_hours(
$current
_date)} { set unconfirmed_hours(
$current
_date) 0 }
# Sum up unconfirmed_hours - KH: 160624: This might be broken and it seems that vars are not being used.
set unconfirmed_hours_for_this_week
[
expr
{
$unconfirmed
_hours_for_this_week +
$unconfirmed
_hours
(
$current
_date
)}]
set unconfirmed_hours_for_this_month
[
expr
{
$unconfirmed
_hours_for_this_month +
$unconfirmed
_hours
(
$current
_date
)}]
# User's Absences for the day
set curr_absence
[
lindex
$absence
_list
$absence
_index
]
if {"" !=
$curr
_absence} { set curr_absence "
<br>$curr_absence
" }
...
...
@@ -338,8 +357,10 @@ for {set current_date $first_julian_date} {$current_date <= $last_julian_date} {
if {
$column
_ctr == 1 &&
$show
_link_log_hours_for_week_p} {
set log_hours_for_the_week_html "
<br>
<nobr>
<a href=
[
export_vars -base
"
$hours
_base_url/new"
{
user_id_from_search
{
julian_date
$current
_date
}
{
show_week_p 1
}
return_url
}]
><span class='log_hours'>
[
lang::message::lookup
""
intranet-timesheet2.Log_hours_for_the_week
"Log hours for the week"
]
</span></a>
><span class='log_hours'>
[
lang::message::lookup
""
intranet-timesheet2.Projects
"Projects"
]
:
[
lang::message::lookup
""
intranet-timesheet2.Log_for_the_week
"Log for the week"
]
</span></a></nobr>
"
} else {
set log_hours_for_the_week_html ""
...
...
@@ -366,8 +387,8 @@ for {set current_date $first_julian_date} {$current_date <= $last_julian_date} {
} else {
set html "
${hours}${curr_absence}
<br>
"
if {
$confirm
_timesheet_hours_p} {
append html "
[
lang::message::lookup
""
intranet-timesheet2.ToConfirm
"To confirm"
]
: 
;
"
append html "
<span id='hours_confirmed_red'>$
{
no_unconfirmed_hours
}
 
;[
_ intranet-timesheet2.hours
]
</span>
"
append html "
<nobr>
[
lang::message::lookup
""
intranet-timesheet2.ToConfirm
"To confirm"
]
: 
;
"
append html "
<span id='hours_confirmed_red'>$
{
no_unconfirmed_hours
}
 
;[
_ intranet-timesheet2.hours
]
</span>
</nobr>
"
}
append html "
$log
_hours_for_the_week_html
"
}
...
...
@@ -377,7 +398,8 @@ for {set current_date $first_julian_date} {$current_date <= $last_julian_date} {
} else {
set html "
${hours}${curr_absence}$log
_hours_for_the_week_html
"
}
# -------------------------------------------------------------------------
# Weekly total
if {(
$column
_ctr == 7 || 0 &&
$current
_date_ansi ==
$last
_day_of_month_ansi) &&
$show
_last_confirm_button_p} {
append html "
<br>
...
...
@@ -409,6 +431,7 @@ for {set current_date $first_julian_date} {$current_date <= $last_julian_date} {
}
# -------------------------------------------------------------------------
# Show monthly total
if {
$current
_date_ansi ==
$last
_day_of_month_ansi} {
append html "
<br>
...
...
@@ -418,6 +441,7 @@ for {set current_date $first_julian_date} {$current_date <= $last_julian_date} {
}
# -------------------------------------------------------------------------
# Attendance Management
if {
$attendance
_management_installed_p} {
# Get the URL and the ID of the portlet in order to show a direct link
...
...
@@ -444,34 +468,40 @@ for {set current_date $first_julian_date} {$current_date <= $last_julian_date} {
set break
[
expr
round
(
10.0 *
$att
_break_hash
(
$current
_date
))
/ 10.0
]
}
# Calculate color coding
set attendance_required
[
im_attendance_daily_attendance_hours -user_id
$current
_user_id
]
# -------------------------------------------------------------------------
# Call consistency checker
set v
[
list
]
if {
[
info
exists cell_hash
(
$current
_date
)]
} { set v
$cell
_hash(
$current
_date) }
ns_log Notice "
timesheet2/index: Before im_attendance_check_consistency:
$v
"
set attendance_errors
[
im_attendance_check_consistency -user_id
$user
_id_from_search -date
$current
_date_ansi -attendance_hashs
$v
]
set color_html ""
if {
$work
<
$attendance
_required} { set color_html "
<font color=red>
" }
set color_html_end ""
if {"" ne
$color
_html} { set color_html_end "
</font>
" }
# Write out lines for work and break
set line_items
[
list
]
if {"" ne
$work
} {
lappend line_items "
<
a href=$work_url target=_>$color_html
$work
_l10n:
${work}${hour_l10n}$color
_html_end</a
>
"
lappend line_items "
<
nobr><a href=$work_url target=_>$color_html
$work
_l10n:
${work}${hour_l10n}$color
_html_end</a></nobr
>
"
}
if {"" ne
$break
} {
lappend line_items "
$break
_l10n:
${break}${hour_l10n}
"
lappend line_items "
<nobr>$break_l10n:
${break}${hour_l10n}
</nobr>
"
}
if {
[
llength
$attendance
_errors
]
> 0} {
lappend line_items "
<font color=red><ul><li>
[
join
$attendance
_errors
"</li>
\n
<li>"
]
</ul></font></div
"
}
if {
[
llength
$line
_items
]
> 0} {
append html "
<br>
[
join
$line
_items
",<br> "
]
"
}
# Count workdays
# Comparison at the end of the month
if {
$current
_date_ansi ==
$last
_day_of_month_ansi} {
append html "
<br>
Attend. month
:
[
expr
round
(
10.0 *
$attendance
_work
)
/ 10.0
]
${hour_l10n}
"
append html "
<br>
Month work total
:
[
expr
round
(
10.0 *
$attendance
_work
)
/ 10.0
]
${hour_l10n}
"
}
}
...
...
@@ -493,7 +523,6 @@ for {set current_date $first_julian_date} {$current_date <= $last_julian_date} {
if {
$column
_ctr > 7} {
set column_ctr 1
set hours_for_this_week 0.0
set unconfirmed_hours_for_this_week 0.0
}
# Weekday needs to be in range
[
0..6
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment