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
f9bd93f1
Commit
f9bd93f1
authored
Feb 01, 2024
by
stage
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://gitlab.project-open.net/project-open/intranet-timesheet2
parents
a7ef47ed
6cb381bc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
325 additions
and
128 deletions
+325
-128
.gitignore
.gitignore
+12
-0
intranet-timesheet2.de_DE.ISO-8859-1.xml
catalog/intranet-timesheet2.de_DE.ISO-8859-1.xml
+8
-0
intranet-timesheet2.en_US.ISO-8859-1.xml
catalog/intranet-timesheet2.en_US.ISO-8859-1.xml
+8
-0
intranet-timesheet2-procs.tcl
tcl/intranet-timesheet2-procs.tcl
+11
-11
index.tcl
www/hours/index.tcl
+286
-117
No files found.
.gitignore
0 → 100644
View file @
f9bd93f1
# Temporary files
*.log
*.orig
*~
.\#*
.~*
\#*\#
# Helpers
emacs.bash
catalog/intranet-timesheet2.de_DE.ISO-8859-1.xml
View file @
f9bd93f1
...
...
@@ -134,7 +134,9 @@
<msg
key=
"go"
>
los
</msg>
<msg
key=
"Grand_Total"
>
Gesamtsumme
</msg>
<msg
key=
"H"
>
H
</msg>
<msg
key=
"h"
>
h
</msg>
<msg
key=
"here"
>
hier
</msg>
<msg
key=
"Hour_abbrev"
>
h
</msg>
<msg
key=
"Hour_logging__Casex"
>
Erfasste Stunden
</msg>
<msg
key=
"Hours"
>
Stunden
</msg>
<msg
key=
"hours"
>
Stunden
</msg>
...
...
@@ -166,7 +168,9 @@
<msg
key=
"Log_Absences"
>
Abwesenheiten melden
</msg>
<msg
key=
"Log_Absences_for_user_name"
>
Abwesenheiten erfassen fr %user_name%
</msg>
<msg
key=
"log_dedication"
>
Stunden erfassen
</msg>
<msg
key=
"Log_for_the_week"
>
Fr die Woche loggen
</msg>
<msg
key=
"Log_Hours"
>
Stunden erfassen
</msg>
<msg
key=
"Log_hours"
>
Stunden loggen
</msg>
<msg
key=
"log_hours"
>
Stunden fr den Tag erfassen
</msg>
<msg
key=
"Log_hours_for_the_week"
>
Stunden fr die Woche erfassen
</msg>
<msg
key=
"Log_hours_for_user"
>
Stunden fr Benutzer erfassen
</msg>
...
...
@@ -270,6 +274,7 @@
<msg
key=
"Mine"
>
Meine
</msg>
<msg
key=
"Monday"
>
Montag
</msg>
<msg
key=
"Month"
>
Monat
</msg>
<msg
key=
"Month_total"
>
Monat gesamt
</msg>
<msg
key=
"More_currencies"
>
Weitere Whrungen
</msg>
<msg
key=
"N"
>
N
</msg>
<msg
key=
"Name"
>
Name
</msg>
...
...
@@ -325,9 +330,12 @@
<msg
key=
"Project"
>
Projekt
</msg>
<msg
key=
"Project_br_Name"
>
Projekt-
<
br
>
Name
</msg>
<msg
key=
"Project_History"
>
Projekthistorie
</msg>
<msg
key=
"Project_month"
>
Projekte Monat
</msg>
<msg
key=
"Project_name"
>
Aufgabenname
</msg>
<msg
key=
"Project_Summaries"
>
Projektzusammenfassung
</msg>
<msg
key=
"Project_units"
>
Projekteinheiten
</msg>
<msg
key=
"Project_week"
>
Projekte Woche
</msg>
<msg
key=
"Projects"
>
Projekte
</msg>
<msg
key=
"Providers"
>
Lieferanten
</msg>
<msg
key=
"Q"
>
Q
</msg>
<msg
key=
"R"
>
R
</msg>
...
...
catalog/intranet-timesheet2.en_US.ISO-8859-1.xml
View file @
f9bd93f1
...
...
@@ -137,7 +137,9 @@
<msg
key=
"go"
>
go
</msg>
<msg
key=
"Grand_Total"
>
Grand Total
</msg>
<msg
key=
"H"
>
H
</msg>
<msg
key=
"h"
>
h
</msg>
<msg
key=
"here"
>
here
</msg>
<msg
key=
"Hour_abbrev"
>
h
</msg>
<msg
key=
"Hour_logging__Casex"
>
Hour logging
&
Casex
</msg>
<msg
key=
"Hours"
>
Hours
</msg>
<msg
key=
"hours"
>
hours
</msg>
...
...
@@ -169,7 +171,9 @@
<msg
key=
"Log_Absences"
>
Log Absences
</msg>
<msg
key=
"Log_Absences_for_user_name"
>
Log absences for %user_name%
</msg>
<msg
key=
"log_dedication"
>
log dedication
</msg>
<msg
key=
"Log_for_the_week"
>
Log for the week
</msg>
<msg
key=
"Log_Hours"
>
Log Hours
</msg>
<msg
key=
"Log_hours"
>
Log hours
</msg>
<msg
key=
"log_hours"
>
log hours
</msg>
<msg
key=
"Log_hours_for_the_week"
>
Log hours for the week
</msg>
<msg
key=
"Log_hours_for_user"
>
Log for:
</msg>
...
...
@@ -282,6 +286,7 @@ of those units were billed hourly, for a total amount of</msg>
<msg
key=
"Mine"
>
Mine
</msg>
<msg
key=
"Monday"
>
Monday
</msg>
<msg
key=
"Month"
>
Month
</msg>
<msg
key=
"Month_total"
>
Month total
</msg>
<msg
key=
"More_currencies"
>
More currencies
</msg>
<msg
key=
"N"
>
N
</msg>
<msg
key=
"Name"
>
Name
</msg>
...
...
@@ -337,9 +342,12 @@ of those units were billed hourly, for a total amount of</msg>
<msg
key=
"Project"
>
Project
</msg>
<msg
key=
"Project_br_Name"
>
Project
<
br
>
Name
</msg>
<msg
key=
"Project_History"
>
Project History
</msg>
<msg
key=
"Project_month"
>
Projects month
</msg>
<msg
key=
"Project_name"
>
Project name
</msg>
<msg
key=
"Project_Summaries"
>
Project Summaries
</msg>
<msg
key=
"Project_units"
>
Project units
</msg>
<msg
key=
"Project_week"
>
Projects week
</msg>
<msg
key=
"Projects"
>
Projects
</msg>
<msg
key=
"Providers"
>
Providers
</msg>
<msg
key=
"Q"
>
Q
</msg>
<msg
key=
"R"
>
R
</msg>
...
...
tcl/intranet-timesheet2-procs.tcl
View file @
f9bd93f1
...
...
@@ -288,12 +288,17 @@ ad_proc -public im_timesheet_home_component {user_id} {
set expected_hours
[
parameter::get -package_id
[
im_package_timesheet2_id
]
-parameter
"TimesheetRedirectNumHoursInDays"
-default 32
]
set available_perc
[
util_memoize
[
list
db_string percent_available
"select availability from im_employees where employee_id =
$user
_id"
-default 100
]
60
]
if
{
""
==
$available
_perc
}
{
set available_perc 100
}
set expected_hours
[
expr
{
$expected
_hours *
$available
_perc / 100
}
]
set expected_hours
[
expr
$expected
_hours *
$available
_perc / 100
]
set hours_html
""
set log_them_now_link
"<a href=/intranet-timesheet2/hours/index>"
set num_hours
[
im_timesheet_hours_sum -user_id
$user
_id -number_days
$num
_days
]
set absences_hours
[
im_timesheet_absences_sum -user_id
$user
_id -number_days
$num
_days
]
set absence_hours
[
im_timesheet_absences_sum -user_id
$user
_id -number_days
$num
_days
]
set absences_hours_message
""
if
{
$absence
_hours > 0
}
{
set absences_hours_message
[
lang::message::lookup
""
intranet-timesheet2.and_absence_hours
"and %absence_hours% hours of absences"
]
}
if
{
$num
_hours == 0
}
{
set message
"<b>
[
_ intranet-timesheet2.lt_You_havent_logged_you
]
</a></b>
\n
"
...
...
@@ -301,20 +306,15 @@ ad_proc -public im_timesheet_home_component {user_id} {
set message
"
[
_ intranet-timesheet2.lt_You_logged_num_hours_
]
"
}
set absences_hours_message
""
if
{
[
expr
{
$num
_hours +
$absences
_hours
}]
<
$expected
_hours &&
$add
_hours
}
{
if
{[
expr
$num
_hours +
$absence
_hours
]
<
$expected
_hours &&
$add
_hours
}
{
if
{
$absences
_hours > 0
}
{
set absences_hours_message
[
lang::message::lookup
""
\
intranet-timesheet2.and_absences_hours
\
"and %absences_hours% hours of absences"
]
}
set default_message
"
You have only logged
%num_hours% hours %absences_hours_message%
in the last
%num_days% days out of %expected_hours%
expected hours.
You have only logged
$num
_hours hours of project work
$absences
_hours_message
in the last
$num
_days days out of
$expected
_hours
expected hours.
"
set message
"<b>
[
lang::message::lookup
""
intranet-timesheet2.You_need_to_log_hours
$default
_message
]
</b>"
# Only redirect if it's not the admin...
if
{
$redirect
_p && !$admin_p
}
{
set header
[
lang::message::lookup
""
intranet-timesheet2.Please_Log_Your_Hours
"Please Log Your Hours"
]
ad_returnredirect
[
export_vars -base
"/intranet-timesheet2/hours/index"
{
header message
}]
...
...
www/hours/index.tcl
View file @
f9bd93f1
...
...
@@ -15,7 +15,7 @@
ad_page_contract
{
Calendar format display of user's hours with links
Calendar format display of user's hours with links
to log more hours, if the user is looking at him/
herself
...
...
@@ -25,7 +25,7 @@ ad_page_contract {
@param user_id the user for whom we're viewing hours. Defaults to currently logged in user.
@param project_id The user group for which we're viewing hours. Defaults to all groups.
@param return_url Return URL
@author Michael Bryzek
(
mbryzek@arsdigita.com
)
@author Frank Bergmann
(
frank.bergmann@project-open.com
)
@author Klaus Hofeditz
(
klaus.hofeditz@project-open.com
)
...
...
@@ -41,7 +41,7 @@ ad_page_contract {
}
# Decision FB on 160624: Disregard for now:
# Clean up data in case WF cases have been
OCdeleted in WF Admin Panel.
# Clean up data in case WF cases have been
deleted in WF Admin Panel.
# conf_object will not be removed and hours are shown as 'to be confirmed'.
# db_dml sql "update im_hours set conf_object_id = null where conf_object_id not in (select object_id from wf_cases
)
"
# db_dml sql "
delete from im_timesheet_conf_objects where conf_id not in
(
select object_id from wf_cases
)
"
...
...
@@ -55,9 +55,13 @@ set add_hours_all_p [im_permission $current_user_id "add_hours_all"]
set add_hours_direct_reports_p
[
im_permission
$current
_user_id
"add_hours_direct_reports"
]
set base_url_confirm_wf "
/intranet-timesheet2-workflow/conf-objects/new-timesheet-workflow
"
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-timesheet2.Hour_abbrev
"h"
]
switch
$user
_id_from_search {
"" - all - mine - direct_reports - employees - customers - providers {
set user_id_from_search
$current
_user_id
"" - all - mine - direct_reports - employees - customers - providers {
set user_id_from_search
$current
_user_id
}
default {
# Is the user allowed to log hours for another user?
...
...
@@ -66,11 +70,11 @@ switch $user_id_from_search {
set reportees
[
im_user_direct_reports_ids -user_id
$current
_user_id
]
if {
[
lsearch
$reportees
$user
_id_from_search
]
< 0} {
# User not in reportees - reset to current user
set user_id_from_search
$current
_user_id
set user_id_from_search
$current
_user_id
}
} else {
# The user has no permission to log hours for others
set user_id_from_search
$current
_user_id
set user_id_from_search
$current
_user_id
}
}
}
...
...
@@ -98,29 +102,28 @@ set fill_up_first_last_row_p [parameter::get -package_id [apm_package_id_from_ke
set start_day
[
parameter::get -package_id
[
apm_package_id_from_key intranet-timesheet2
]
-parameter
"WeekStartDay"
-default 0
]
set show_link_log_hours_for_week_p
[
parameter::get -package_id
[
apm_package_id_from_key intranet-timesheet2
]
-parameter
"ShowLinkToWeeklyTimesheetP"
-default 0
]
set hours_base_url
[
parameter::get -package_id
[
apm_package_id_from_key intranet-timesheet2
]
-parameter
"HourURL"
-default
"/intranet-timesheet2/hours"
]
set attendance_management_installed_p
[
im_table_exists im_attendance_intervals
]
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
]
" }
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
]
" }
}
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
]
" }
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
]
" }
}
set weekly_logging_days
[
parameter::get_from_package_key -package_key intranet-timesheet2 -parameter TimesheetWeeklyLoggingDays -default
"0 1 2 3 4 5 6"
]
...
...
@@ -128,20 +131,21 @@ 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"
]
}
}
set julian_date
[
db_string conv
"select to_char(:date::date, 'J')"
]
# Set last day of month:
# Set last day of month:
set last_day_of_month_ansi
[
db_string get_last_day_month
"select date_trunc('month',add_months(:date,1))::date - 1"
-default 0
]
set first_day_of_month_ansi
[
db_string get_first_day_month
"select date_trunc('month', '
$date
'::DATE)::date"
-default 0
]
set first_day_of_month_julian
[
db_string fdom_julian
"select to_char(:first_day_of_month_ansi::date, 'J')"
]
set today_ansi
[
db_string today
"select now()::date"
]
set project_id_for_default
[
lindex
$project
_id 0
]
set show_left_functional_menu_p
[
parameter::get_from_package_key -package_key
"intranet-core"
-parameter
"ShowLeftFunctionalMenupP"
-default 0
]
...
...
@@ -160,12 +164,15 @@ set menu_links_html [im_menu_ul_list -no_uls 1 "timesheet_hours_new_admin" $bind
# Enable the functionality to confirm timesheet hours?
set confirm_timesheet_hours_p 0
if {
"" !=
[
parameter::get -package_id
[
apm_package_id_from_key intranet-timesheet2-workflow
]
-parameter
"DefaultWorkflowKey"
-default
""
]
} {
if {
"" !=
[
parameter::get -package_id
[
apm_package_id_from_key intranet-timesheet2-workflow
]
-parameter
"DefaultWorkflowKey"
-default
""
]
} {
set confirm_timesheet_hours_p 1
}
if {!
[
im_column_exists im_hours conf_object_id
]
} { set confirm_timesheet_hours_p 0 }
# Rounding by two digits
set rounding_factor 100.0
# ---------------------------------------------------------------
# Render the Calendar widget
...
...
@@ -175,24 +182,111 @@ 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,
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 = :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
"
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 {
# Work Attendance
set v 0.0
if {
[
info
exists att_work_hash
(
$attendance
_start_julian
)]
} { set v
$att
_work_hash(
$attendance
_start_julian)}
set v
[
expr
$v
+
$duration
_hours
]
set att_work_hash(
$attendance
_start_julian)
$v
set attendance_work
[
expr
$attendance
_work +
$duration
_hours
;]
}
92110 {
# Break
set v 0.0
if {
[
info
exists att_break_hash
(
$attendance
_start_julian
)]
} { set v
$att
_break_hash(
$attendance
_start_julian)}
set v
[
expr
$v
+
$duration
_hours
]
set att_break_hash(
$attendance
_start_julian)
$v
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
}
# -----------------------------------------------------------
# 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
}]
}
# 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
set sql "
select to_char
(
day, 'J'
)
as julian_date,
select to_char
(
day, 'J'
)
as julian_date,
sum
(
hours
)
as hours
from im_hours
where user_id = :user_id_from_search
and day between to_date
(
:first_julian_date, 'J'
)
and to_date
(
:last_julian_date, 'J'
)
and day between to_date
(
:first_julian_date, 'J'
)
and to_date
(
:last_julian_date, 'J'
)
$project
_restriction
group by
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
...
...
@@ -200,54 +294,61 @@ 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 ""
# Column counter runs from 1 to 7
# Column counter runs from 1 to 7
set column_ctr 1
# Counter for weekday -> need to correspond with weekly_logging_days
if {
1 ==
$start
_day
} {
# Week starts with Monday
set week_day 1
if {
1 ==
$start
_day
} {
# Week starts with Monday
set week_day 1
} else {
# Week starts with Sunday
set week_day 0
# Week starts with Sunday
set week_day 0
}
# Helper to determine location of last WF confirm button -> last day shown or last day of month
# 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
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 } {
set current_date_ansi
[
dt_julian_to_ansi
$current
_date
]
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
} {
if {
$confirm
_timesheet_hours_p
} {
set no_ts_approval_wf_sql "
select count
(
*
)
from im_hours
where conf_object_id is not null
and day::text like '%
[
string
range
$current
_date_ansi 0 9
]
%'
select count
(
*
)
from im_hours
where conf_object_id is not null
and day::text like '%
[
string
range
$current
_date_ansi 0 9
]
%'
and user_id = :current_user_id
"
set no_ts_approval_wf
[
db_string workflow_started_p
$no
_ts_approval_wf_sql -default
"0"
]
if {
$confirm
_timesheet_hours_p && ("
monthly
" in
$confirmation
_period || "
weekly
" in
$confirmation
_period) && 0 !=
$no
_ts_approval_wf
} {
if {
$confirm
_timesheet_hours_p && ("
monthly
" in
$confirmation
_period || "
weekly
" in
$confirmation
_period) && 0 !=
$no
_ts_approval_wf
} {
# ns_log Notice "
TS: Entry blocked: Date:
$current
_date_ansi
;
Number:
$no
_ts_approval_wf
;
$no
_ts_approval_wf_sql
"
set timesheet_entry_blocked_p 1
set timesheet_entry_blocked_p 1
}
}
# -------------------------------------------------------------------------
# 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
"
]
"
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.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
...
...
@@ -255,48 +356,43 @@ 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>
"
if {
$timesheet
_entry_blocked_p} {
# 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'>
[
_ intranet-timesheet2.log_hours
]
</span>
"
if {
[
string
first
$week
_day
$weekly
_logging_days
]
!= -1
} {
set hours "
<span
><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
" }
set hours_url
[
export_vars -base
"
$hours
_base_url/new"
{
user_id_from_search
{
julian_date
$current
_date
}
show_week_p return_url project_id project_id
}]
if {
[
string
first
$week
_day
$weekly
_logging_days
]
!= -1
} {
if {
[
string
first
$week
_day
$weekly
_logging_days
]
!= -1
} {
set hours "
<a href=$hours_url>$hours</a>
"
} else {
set hours "
$hours
"
}
if {
$column
_ctr == 1 &&
$show
_link_log_hours_for_week_p
} {
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 ""
}
if {
[
info
exists users_hours
(
$current
_date
)]
} {
if {
[
info
exists unconfirmed_hours
(
$current
_date
)]
&&
$confirm
_timesheet_hours_p
} {
set no_unconfirmed_hours
[
get_unconfirmed_hours_for_period
$user
_id_from_search
$current
_date
$current
_date
]
if {
[
info
exists users_hours
(
$current
_date
)]
} {
if {
[
info
exists unconfirmed_hours
(
$current
_date
)]
&&
$confirm
_timesheet_hours_p
} {
set no_unconfirmed_hours
[
get_unconfirmed_hours_for_period
$user
_id_from_search
$current
_date
$current
_date
]
if {0 ==
$no
_unconfirmed_hours || "" ==
$no
_unconfirmed_hours} {
set wf_actice_case_sql "
select count
(
*
)
...
...
@@ -307,16 +403,16 @@ for { set current_date $first_julian_date} { $current_date <= $last_julian_date
h.user_id = :user_id_from_search
"
set no_wf_cases
[
db_string no_wf_cases
$wf
_actice_case_sql
]
if {
$no
_wf_cases > 0
} {
if {
$no
_wf_cases > 0
} {
set html "
<span id='hours_confirmed_yellow'>$hours</span>$curr_absence$log_hours_for_the_week_html
"
} else {
set html "
<span id='hours_confirmed_green'>$hours</span>$curr_absence$log_hours_for_the_week_html
"
}
} else {
set html "
${hours}${curr_absence}
<br>
"
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
"
}
...
...
@@ -326,72 +422,146 @@ for { set current_date $first_julian_date} { $current_date <= $last_julian_date
} else {
set html "
${hours}${curr_absence}$log
_hours_for_the_week_html
"
}
# -------------------------------------------------------------------------
# Show monthly total
if {
$current
_date_ansi ==
$last
_day_of_month_ansi} {
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} {
# Calculate the actual work/break time
set work 0
if {
[
info
exists att_work_hash
(
$current
_date
)]
} {
set work
[
expr
round
(
$rounding
_factor *
$att
_work_hash
(
$current
_date
))
/
$rounding
_factor
]
}
set break ""
if {
[
info
exists att_break_hash
(
$current
_date
)]
} {
set break
[
expr
round
(
$rounding
_factor *
$att
_break_hash
(
$current
_date
))
/
$rounding
_factor
]
}
# Hours to be expected for today
set expected_hours
[
im_attendance_daily_attendance_hours -user_id
$current
_user_id -date
$current
_date_ansi
]
if {
$current
_date_ansi <
$first
_day_of_month_ansi} { set expected_hours 0.0 }
if {
$current
_date_ansi >
$last
_day_of_month_ansi} { set expected_hours 0.0 }
if {
$current
_date_ansi >
$today
_ansi} { set expected_hours 0.0 }
# 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
]
ns_log Notice "
intranet-timesheet2/hours/index: date=$current_date_ansi, expected=$expected_hours, xxx
"
# -------------------------------------------------------------------------
# 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
(
$rounding
_factor *
$attendance
_work
)
/
$rounding
_factor
]
${hour_l10n}
, expected
$monthly
_expected_total$
{
hour_l10n
}
</font>
"
}
# -------------------------------------------------------------------------
# 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 ""
set color_html_end ""
# Write out lines for work and break
set line_items
[
list
]
if {"" ne
$work
} {
# 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
}}]
set work_formatted
[
format
"%.2f"
$work
]
lappend line_items "
<nobr><a href=$attendance_portlet_julian_url target=_>$color_html
$work
_l10n:
${work_formatted}${hour_l10n}$color
_html_end</a></nobr>
"
}
if {"" ne
$break
} {
set break_formatted
[
format
"%.2f"
$break
]
lappend line_items "
<nobr>$break_l10n:
${break_formatted}${hour_l10n}
</nobr>
"
}
# ds_comment "
$column
_ctr, current_date_ansi:
$current
_date_ansi, last_day_of_month_ansi:
$last
_day_of_month_ansi, show_last_confirm_button_p:
$show
_last_confirm_button_p
"
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> "
]
"
}
}
# -------------------------------------------------------------------------
# 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 {(
$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 }
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 {
$confirmation
_period eq "
weekly
" &&
$confirm
_timesheet_hours_p
} {}
if {
$confirm
_timesheet_hours_p} {
if {
!
$fill
_up_first_last_row_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 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
}]
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>
"
}
# -------------------------------------------------------------------------
# Monthly hour approval request
if {
$current
_date_ansi ==
$last
_day_of_month_ansi && ("
monthly
" in
$confirmation
_period)
} {
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
]
set end_date_month_julian
[
dt_ansi_to_julian_single_arg
$last
_day_of_month_ansi
]
set conf_url
[
export_vars -base
$base
_url_confirm_wf
{
{
user_id
$user
_id_from_search
}
{
start_date_julian
$start
_date_month_julian
}
{
end_date_julian
$end
_date_month_julian
}
return_url
}
]
set conf_url
[
export_vars -base
$base
_url_confirm_wf
{
{
user_id
$user
_id_from_search
}
{
start_date_julian
$start
_date_month_julian
}
{
end_date_julian
$end
_date_month_julian
}
return_url
}
]
set button_txt
[
lang::message::lookup
""
intranet-timesheet2.Confirm_monthly_hours
"Confirm hours for this month"
]
append html "
<p> 
;
</p><a href='$conf_url' class=button>$button_txt</a>
"
}
}
ns_set put
$calendar
_details
$current
_date "
$html
<br> 
;
"
# we keep track of the day of the week we are on
incr column_ctr
incr week_day
incr week_day
if {
$column
_ctr > 7
} {
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
]
if {
$week
_day > 6
} {
set week_day 0
if {
$week
_day > 6
} {
set week_day 0
}
set curr_absence ""
...
...
@@ -400,14 +570,14 @@ for { set current_date $first_julian_date} { $current_date <= $last_julian_date
}
set prev_month_template "
<font color=white><
;
</font>
<font color=white><
;
</font>
<a href=
\"
[
export_vars -base index
{
user_id_from_search
}]
&date=
\$
ansi_date
\"
>
<font color=white>
\[
_ intranet-timesheet2.$prev_month_name
]
</font>
</a>
"
set next_month_template "
<a href=
\"
[
export_vars -base index
{
user_id_from_search
}]
&date=
\$
ansi_date
\"
>
<font color=white>
\[
_ intranet-timesheet2.$next_month_name
]
</font>
</a>
</a>
<font color=white>>
;
</font>
"
set day_bgcolor "
#efefef
"
...
...
@@ -461,7 +631,7 @@ set left_navbar_html "
</div>
<form action='$hours_base_url/index' method=GET>
[
export_vars -form
{
show_week_p
}]
[
export_vars -form
{
show_week_p
}]
<table border=0 cellpadding=1 cellspacing=1>
<tr>
<td>
[
lang::message::lookup
""
intranet-core.Date
"Date"
]
</td>
...
...
@@ -544,4 +714,3 @@ if {"" ne $admin_html} {
</div><ul>$admin_html</ul></div>
"
}
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