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
b8c44cf5
Commit
b8c44cf5
authored
Jan 02, 2024
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented warnings for attendance management
parent
b712aecb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
58 deletions
+81
-58
index.tcl
www/hours/index.tcl
+81
-58
No files found.
www/hours/index.tcl
View file @
b8c44cf5
...
...
@@ -57,7 +57,7 @@ set base_url_confirm_wf "/intranet-timesheet2-workflow/conf-objects/new-timeshee
set work_l10n
[
lang::message::lookup
""
intranet-attendance-management.Work
"Work"
]
set break_l10n
[
lang::message::lookup
""
intranet-attendance-management.Break
"Break"
]
set hour_l10n
[
lang::message::lookup
""
intranet-
core
.Hour_abbrev
"h"
]
set hour_l10n
[
lang::message::lookup
""
intranet-
timesheet2
.Hour_abbrev
"h"
]
switch
$user
_id_from_search {
"" - all - mine - direct_reports - employees - customers - providers {
...
...
@@ -249,6 +249,22 @@ if {$attendance_management_installed_p} {
lappend v
$list
set cell_hash(
$key
)
$v
}
# -----------------------------------------------------------
# Calculate link to Attendance management widget
if {
[
catch
{
db_1row portlet_props
"
select plugin_id, page_url
from im_component_plugins
where plugin_name = 'Attendance Management' and
package_name = 'intranet-attendance-management'
"
}
err_msg
]
} {
ad_return_complaint 1 "
<b>Error locating the attendance portlet</b>:
There is no portlet named 'Attendance Management' of package 'intranet-attendance-management'.<br>
"
}
set attendance_portlet_url
[
export_vars -base
$page
_url
{{
view_name
"component"
}
plugin_id
}]
}
...
...
@@ -294,6 +310,10 @@ if {1 == $start_day} {
set show_last_confirm_button_p 1
set timesheet_entry_blocked_p 0
set monthly_work_total 0.0
set monthly_break_total 0.0
set monthly_expected_total 0.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} {
...
...
@@ -324,7 +344,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 "
[
lang::message::lookup
""
intranet-timesheet2.Projects
"Projects"
]
:
$users
_hours
(
$current
_date
)[
lang::message::lookup
""
intranet-timesheet2.
h
"h"
]
"
set hours "
[
lang::message::lookup
""
intranet-timesheet2.Projects
"Projects"
]
:
$users
_hours
(
$current
_date
)[
lang::message::lookup
""
intranet-timesheet2.
Hour_abbrev
"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
...
...
@@ -338,7 +358,7 @@ for {set current_date $first_julian_date} {$current_date <= $last_julian_date} {
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'
><nobr>
[
lang::message::lookup
""
intranet-timesheet2.Projects
"Projects"
]
:
[
lang::message::lookup
""
intranet-timesheet2.Log_hours
"Log hours"
]
</nobr></span>
"
set hours "
<span><nobr>
[
lang::message::lookup
""
intranet-timesheet2.Projects
"Projects"
]
:
[
lang::message::lookup
""
intranet-timesheet2.Log_hours
"Log hours"
]
</nobr></span>
"
}
}
}
...
...
@@ -399,65 +419,21 @@ for {set current_date $first_julian_date} {$current_date <= $last_julian_date} {
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>
<a href=
[
export_vars -base
"week"
{{
julian_date
$current
_date
}
user_id_from_search
}]
>
[
_ intranet-timesheet2.Week_total_1
]
[
format
"%.2f"
[
expr
{
double
(
round
(
100*$hours_for_this_week
))
/100
}]]
</a>
"
if {
$current
_date_ansi ==
$last
_day_of_month_ansi} { set show_last_confirm_button_p 0 }
# Include link for weekly TS confirmation
# Monthly confirmation_period not supported yet, always assume weekly
# if {
$confirmation
_period eq "
weekly
" &&
$confirm
_timesheet_hours_p} {}
if {
$confirm
_timesheet_hours_p} {
if {!
$fill
_up_first_last_row_p} {
set start_date_julian_wf
[
eval_wf_start_date
$current
_date
$column
_ctr
]
set end_date_julian_wf
$current
_date
} else {
set start_date_julian_wf
[
expr
{
$current
_date - 6
}]
set end_date_julian_wf
$current
_date
}
set no_unconfirmed_hours
[
get_unconfirmed_hours_for_period
$user
_id_from_search
$start
_date_julian_wf
$end
_date_julian_wf
]
if {
$confirm
_timesheet_hours_p && (0 <
$no
_unconfirmed_hours || "" !=
$no
_unconfirmed_hours) && ("
weekly
" in
$confirmation
_period)} {
set conf_url
[
export_vars -base
$base
_url_confirm_wf
{{
user_id
$user
_id_from_search
}
{
start_date_julian
$start
_date_julian_wf
}
{
end_date_julian
$end
_date_julian_wf
}
return_url
}]
set button_txt
[
lang::message::lookup
""
intranet-timesheet2.Confirm_weekly_hours
"Confirm hours for this week"
]
append html "
<p> 
;
</p><a href='$conf_url' class=button>$button_txt</a>
"
}
}
}
# -------------------------------------------------------------------------
# Show monthly total
if {
$current
_date_ansi ==
$last
_day_of_month_ansi} {
append html "
<br>
<a href=
[
export_vars -base
"month"
{{
julian_date
$current
_date
}
user_id_from_search
}
]
>
[
lang::message::lookup
""
intranet-timesheet2.Month_total
"Month total:"
]
[
format
"%.2f"
[
expr
{
double
(
round
(
100*$hours_for_this_month
))
/100
}]]
</a>
"
set monthly_total_url
[
export_vars -base
"month"
{{
julian_date
$current
_date
}
user_id_from_search
}]
set monthly_total_l10n
[
lang::message::lookup
""
intranet-timesheet2.Project_month
"Projects month"
]
set monthly_total_pretty
[
format
"%.2f"
[
expr
round
(
100.0 *
$hours
_for_this_month
)
/100.0
]]
append html "
<br><a href=$monthly_total_url>$monthly_total_l10n:
$monthly
_total_pretty</a>
"
}
# -------------------------------------------------------------------------
# Attendance Management
if {
$attendance
_management_installed_p} {
# Get the URL and the ID of the portlet in order to show a direct link
if {
[
catch
{
db_1row portlet_props
"
select plugin_id, page_url
from im_component_plugins
where plugin_name = 'Attendance Management' and
package_name = 'intranet-attendance-management'
"
}
err_msg
]
} {
ad_return_complaint 1 "
<b>Error locating the attendance portlet</b>:
There is no portlet named 'Attendance Management' of package 'intranet-attendance-management'.<br>
"
}
set work_url
[
export_vars -base
$page
_url
{{
view_name
"component"
}
plugin_id
{
julian
$current
_date
}}]
# Calculate the actual work/break time
set work 0
if {
[
info
exists att_work_hash
(
$current
_date
)]
} {
...
...
@@ -467,10 +443,28 @@ for {set current_date $first_julian_date} {$current_date <= $last_julian_date} {
if {
[
info
exists att_break_hash
(
$current
_date
)]
} {
set break
[
expr
round
(
10.0 *
$att
_break_hash
(
$current
_date
))
/ 10.0
]
}
# Hours to be expected for today
set expected_hours
[
im_attendance_daily_attendance_hours -user_id
$current
_user_id -date
$current
_date_ansi
]
# Calculate the monthly sum of all three types of hours
set monthly_work_total
[
expr
$monthly
_work_total +
$work
]
if {"" ne
$break
} { set monthly_break_total
[
expr
$monthly
_break_total +
$break
]
}
set monthly_expected_total
[
expr
$monthly
_expected_total +
$expected
_hours
]
# -------------------------------------------------------------------------
# Comparison at the end of the month
if {
$current
_date_ansi ==
$last
_day_of_month_ansi} {
if {
$attendance
_work <
$monthly
_expected_total} {
set font_html "
color=red
"
} else {
set font_html ""
}
append html "
<br><font
$font
_html>Month work total:
[
expr
round
(
10.0 *
$attendance
_work
)
/ 10.0
]
${hour_l10n}
, expected
$monthly
_expected_total$
{
hour_l10n
}
</font>
"
}
# Calculate color coding
# -------------------------------------------------------------------------
# Call consistency checker
set v
[
list
]
...
...
@@ -484,7 +478,9 @@ for {set current_date $first_julian_date} {$current_date <= $last_julian_date} {
# Write out lines for work and break
set line_items
[
list
]
if {"" ne
$work
} {
lappend line_items "
<nobr><a href=$work_url target=_>$color_html
$work
_l10n:
${work}${hour_l10n}$color
_html_end</a></nobr>
"
# Get the URL of a portlet with right julian date to enter attendances
set attendance_portlet_julian_url
[
export_vars -base
$attendance
_portlet_url
{{
julian
$current
_date
}}]
lappend line_items "
<nobr><a href=$attendance_portlet_julian_url target=_>$color_html
$work
_l10n:
${work}${hour_l10n}$color
_html_end</a></nobr>
"
}
if {"" ne
$break
} {
lappend line_items "
<nobr>$break_l10n:
${break}${hour_l10n}
</nobr>
"
...
...
@@ -498,13 +494,40 @@ for {set current_date $first_julian_date} {$current_date <= $last_julian_date} {
append html "
<br>
[
join
$line
_items
",<br> "
]
"
}
# Comparison at the end of the month
if {
$current
_date_ansi ==
$last
_day_of_month_ansi} {
append html "
<br>Month work total:
[
expr
round
(
10.0 *
$attendance
_work
)
/ 10.0
]
${hour_l10n}
"
}
}
# -------------------------------------------------------------------------
# Weekly total
if {(
$column
_ctr == 7 || 0 &&
$current
_date_ansi ==
$last
_day_of_month_ansi) &&
$show
_last_confirm_button_p} {
set weekly_total_url
[
export_vars -base
"week"
{{
julian_date
$current
_date
}
user_id_from_search
}]
set weekly_total_l10n
[
lang::message::lookup
""
intranet-timesheet2.Project_week
"Projects week"
]
set weekly_total_pretty
[
format
"%.2f"
[
expr
round
(
100.0 *
$hours
_for_this_week
)
/100.0
]]
append html "
<br><a href=$weekly_total_url>$weekly_total_l10n:
$weekly
_total_pretty</a>
"
if {
$current
_date_ansi ==
$last
_day_of_month_ansi} { set show_last_confirm_button_p 0 }
# Include link for weekly TS confirmation
# Monthly confirmation_period not supported yet, always assume weekly
# if {
$confirmation
_period eq "
weekly
" &&
$confirm
_timesheet_hours_p} {}
if {
$confirm
_timesheet_hours_p} {
if {!
$fill
_up_first_last_row_p} {
set start_date_julian_wf
[
eval_wf_start_date
$current
_date
$column
_ctr
]
set end_date_julian_wf
$current
_date
} else {
set start_date_julian_wf
[
expr
{
$current
_date - 6
}]
set end_date_julian_wf
$current
_date
}
set no_unconfirmed_hours
[
get_unconfirmed_hours_for_period
$user
_id_from_search
$start
_date_julian_wf
$end
_date_julian_wf
]
if {
$confirm
_timesheet_hours_p && (0 <
$no
_unconfirmed_hours || "" !=
$no
_unconfirmed_hours) && ("
weekly
" in
$confirmation
_period)} {
set conf_url
[
export_vars -base
$base
_url_confirm_wf
{{
user_id
$user
_id_from_search
}
{
start_date_julian
$start
_date_julian_wf
}
{
end_date_julian
$end
_date_julian_wf
}
return_url
}]
set button_txt
[
lang::message::lookup
""
intranet-timesheet2.Confirm_weekly_hours
"Confirm hours for this week"
]
append html "
<p> 
;
</p><a href='$conf_url' class=button>$button_txt</a>
"
}
}
}
# -------------------------------------------------------------------------
# Monthly hour approval request
if {
$current
_date_ansi ==
$last
_day_of_month_ansi && ("
monthly
" in
$confirmation
_period)} {
set start_date_month_julian
[
dt_ansi_to_julian_single_arg
$first
_day_of_month_ansi
]
...
...
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