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
fa14ed5b
Commit
fa14ed5b
authored
Mar 01, 2006
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Added code to check absences for Timesheet2
parent
03631a5a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
119 additions
and
9 deletions
+119
-9
intranet-timesheet2-procs.tcl
tcl/intranet-timesheet2-procs.tcl
+32
-6
new.adp
www/hours/new.adp
+7
-0
new.tcl
www/hours/new.tcl
+80
-3
No files found.
tcl/intranet-timesheet2-procs.tcl
View file @
fa14ed5b
...
...
@@ -70,6 +70,7 @@ ad_proc -public im_timesheet_home_component {user_id} {
set num_hours
[
hours_sum_for_user
$user
_id
""
$num
_days
]
}
err_msg
]
}
{
set num_hours 0
ad_return_complaint 1
"<pre>
$err
_msg</pre>"
}
if
{
$num
_hours <
$expected
_hours &&
$add
_hours
}
{
...
...
@@ -250,10 +251,15 @@ where
}
ad_proc hours_sum_for_user
{
user_id
{
project_id
""
}
{
number_days
""
}
}
{
ad_proc hours_sum_for_user
{
user_id
{
project_id
""
}
{
number_days
"
7
"
}
}
{
Returns the total number of hours the specified user logged for
whatever
else
is included in the arg list
whatever
else
is included in the arg list.
Also counts absences with 8 hours.
}
{
set hours_per_absence
[
parameter::get -package_id
[
im_package_timesheet2_id
]
-parameter
"TimesheetHoursPerAbsence"
-default 8
]
# --------------------------------------------------------
# Count the number of hours in the last days.
set criteria
[
list
"user_id=:user_id"
]
if
{
!
[
empty_string_p
$project
_id
]
}
{
...
...
@@ -263,11 +269,31 @@ ad_proc hours_sum_for_user { user_id { project_id "" } { number_days "" } } {
lappend criteria
"day >= to_date(to_char(sysdate,'yyyymmdd'),'yyyymmdd') -
$number
_days"
}
set where_clause
[
join
$criteria
"
\n
and "
]
set num
[
db_string hours_sum
\
"select sum(hours) from im_hours, dual where
$where
_clause"
]
set num_hours
[
db_string hours_sum
"
select sum(hours)
from im_hours, dual
where
$where
_clause
"
-default 0
]
if
{
""
==
$num
_hours
}
{
set num 0
}
if
{
""
==
$num
}
{
set num 0
}
return
$num
# --------------------------------------------------------
# Count the absences in the last days
set num_absences
[
db_string absences_sum
"
select
count(*)
from
im_user_absences a,
im_day_enumerator(now()::date - '7'::integer, now()::date) d
where
owner_id = :user_id
and a.start_date <= d.d
and a.end_date >= d.d
"
-default 0
]
# ad_return_complaint 1 [expr $num_hours + $num_absences * $hours_per_absence
]
return
[
expr
$num
_hours +
$num
_absences *
$hours
_per_absence
]
}
ad_proc hours_sum
{
project_id
{
number_days
""
}
}
{
...
...
www/hours/new.adp
View file @
fa14ed5b
...
...
@@ -38,6 +38,13 @@
<a href=@different_date_url;noquote@>
#intranet-timesheet2.lt_Log_hours_for_a_diffe#
</a>
<li>
<a href=@absences_url;noquote@>
@absences_link_text@
</a>
<% if {[im_permission $user_id view_projects_all]} { %>
<li>
<a href=@different_project_url;noquote@>
...
...
www/hours/new.tcl
View file @
fa14ed5b
...
...
@@ -51,6 +51,11 @@ set different_date_url "index?[export_ns_set_vars url [list julian_date]]"
# "Log hours for a different project"
set
different_project_url
"other-projects?
[
export_url_vars julian_date
]
"
# Log Absences
set
absences_url
[
export_vars -base
"/intranet-timesheet2/absences/new"
{
return_url
}]
set
absences_link_text
[
lang::message::lookup
""
intranet-timesheet2.Log_Absences
"Log Absences"
]
db_1row user_name_and_date
"
select
im_name_from_user_id(user_id) as user_name,
...
...
@@ -62,6 +67,67 @@ 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
]
"
]
# ---------------------------------------------------------
# Check for registered hours
# ---------------------------------------------------------
# These are the hours and notes captured from the intranet-timesheet2-task-popup
# modules, if it's there. The module allows the user to capture notes during the
# day on what task she is working.
array
set popup_hours
[
list
]
array
set popup_notes
[
list
]
set
timesheet_popup_installed_p
[
db_table_exists im_timesheet_popups
]
if
{
$timesheet
_popup_installed_p
}
{
set timesheet_popup_sql
"
select
p.log_time,
round(to_char(min(q.log_time) - p.log_time, 'HH24')::integer
+ to_char(min(q.log_time) - p.log_time, 'MI')::integer / 60.0
+ to_char(min(q.log_time) - p.log_time, 'SS')::integer / 3600.0
, 3) as log_hours,
p.task_id,
p.note
from
im_timesheet_popups p,
im_timesheet_popups q
where
1=1
and p.log_time::date = now()::date
and q.log_time::date = now()::date
and q.log_time > p.log_time
and p.user_id = :user_id
and q.user_id = :user_id
group by
p.log_time,
p.task_id,
p.note
order by
p.log_time
"
db_foreach timesheet_popup
$timesheet
_popup_sql
{
set p_hours
""
if
{[
info
exists popup_hours
(
$task
_id
)]}
{
set p_hours
$popup
_hours
(
$task
_id
)
}
set p_notes
""
if
{[
info
exists popup_notes
(
$task
_id
)]}
{
set p_notes
$popup
_notes
(
$task
_id
)
}
append p_hours
"
[
expr
$log
_hours+0
]
<br>"
if
{
""
!=
[
string
trim
$note
]
&& !
[
string
equal
"Timesheet"
[
string
tolower
$note
]]}
{
append p_notes
"
$note
<br>"
}
set popup_hours
(
$task
_id
)
$p
_hours
set popup_notes
(
$task
_id
)
$p
_notes
}
}
# ad_return_complaint 1 [array get popup_hours
]
# ---------------------------------------------------------
# Build the SQL Subquery, determining the (parent
)
# projects to be displayed
...
...
@@ -219,6 +285,15 @@ db_foreach $statement_name $sql {
set level
[
expr
$level-1
]
}
# These are the hours and notes captured from the intranet-timesheet2-task-popup
# modules, if it's there. The module allows the user to capture notes during the
# day on what task she is working.
set p_hours
""
set p_notes
""
if
{[
info
exists popup_hours
(
$task
_id
)]}
{
set p_hours
$popup
_hours
(
$task
_id
)
}
if
{[
info
exists popup_notes
(
$task
_id
)]}
{
set p_notes
$popup
_notes
(
$task
_id
)
}
# Insert intermediate header for every new project
if
{
$old
_project_id !=
$project
_id
}
{
...
...
@@ -255,9 +330,7 @@ db_foreach $statement_name $sql {
<td>
<INPUT NAME=notes.
$ctr
size=60 value=
\"
[
ns_quotehtml
[
value_if_exists note
]]
\"
>
</td>
</tr>
"
</tr>
\n
"
}
else
{
append results
"
<td></td>
...
...
@@ -290,9 +363,11 @@ db_foreach $statement_name $sql {
<td>
$material
_name</td>
<td>
<INPUT NAME=hours.
$ctr
size=5 MAXLENGTH=5 value=
\"
$hours
\"
>
$p
_hours
</td>
<td>
<INPUT NAME=notes.
$ctr
size=60 value=
\"
[
ns_quotehtml
[
value_if_exists note
]]
\"
>
$p
_notes
</td>
</tr>
"
...
...
@@ -312,3 +387,5 @@ if { [empty_string_p $results] } {
}
set
export_form_vars
[
export_form_vars julian_date return_url
]
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