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
a7ca5b0f
Commit
a7ca5b0f
authored
Oct 05, 2005
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Changes @ Opus5
parent
3bfb140e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
171 additions
and
42 deletions
+171
-42
new-2-postgresql.xql
www/hours/new-2-postgresql.xql
+117
-0
new-2.tcl
www/hours/new-2.tcl
+54
-42
No files found.
www/hours/new-2-postgresql.xql
0 → 100644
View file @
a7ca5b0f
<?xml version="1.0"?>
<!DOCTYPE queryset PUBLIC "-//OpenACS//DTD XQL 1.0//EN" "/usr/share/emacs/DTDs/xql.dtd">
<!-- packages/intranet-timesheet2/www/hours/new-2-postgresql.xql -->
<!-- @author Frank Bergmann (frank.bergmann@project-open.com) -->
<!-- @creation-date 2004-09-09 -->
<!-- @arch-tag 761b5534-d01b-4538-bd3d-4b3df8f10419 -->
<!-- @cvs-id $Id: intranet-biz-object-procs-postgresql.xql,v 1.1 2004/09/09 16:58:19 cvs Exp \
$ -->
<queryset>
<rdbms>
<type>
postgresql
</type>
<version>
7.2
</version>
</rdbms>
<fullquery
name=
"task_insert"
>
<querytext>
BEGIN
PERFORM im_timesheet_task__new (
:task_id, -- p_task_id
'im_timesheet_task', -- object_type
now(), -- creation_date
null, -- creation_user
null, -- creation_ip
null, -- context_id
:task_nr,
:task_name,
:project_id,
:material_id,
:cost_center_id,
:uom_id,
:task_type_id,
:task_status_id,
:description
);
return 0;
END;
</querytext>
</fullquery>
<fullquery
name=
"task_delete"
>
<querytext>
BEGIN
PERFORM im_task__delete (:task_id);
return 0;
END;
</querytext>
</fullquery>
<fullquery
name=
"task_update"
>
<querytext>
update im_timesheet_tasks set
task_name = :task_name,
task_nr = :task_nr,
project_id = :project_id,
material_id = :material_id,
cost_center_id = :cost_center_id,
task_type_id = :task_type_id,
task_status_id = :task_status_id,
uom_id = :uom_id,
planned_units = :planned_units,
billable_units = :billable_units,
description = :description
where
task_id = :task_id;
</querytext>
</fullquery>
<fullquery
name=
"delete_timesheet_costs"
>
<querytext>
DECLARE
row RECORD;
BEGIN
for row in
select cost_id
from im_costs
where cost_type_id = [im_cost_type_timesheet]
and project_id = :project_id
and effective_date = to_date(:julian_date, 'J')
and cause_object_id = :timesheet_task_id
loop
PERFORM im_cost__delete(row.cost_id);
end loop;
return 0;
END;
</querytext>
</fullquery>
<fullquery
name=
"update_timesheet_task"
>
<querytext>
update im_timesheet_tasks
set reported_units_cache = (
select sum(h.hours)
from im_hours h
where h.timesheet_task_id = task_id
)
where task_id = :timesheet_task_id
</querytext>
</fullquery>
</queryset>
www/hours/new-2.tcl
View file @
a7ca5b0f
# /www/intranet/hours/new-2.tcl
# /www/intranet
-timesheet2
/hours/new-2.tcl
#
# Copyright (C
)
1998-2004 various parties
# The code is based on ArsDigita ACS 3.4
...
...
@@ -39,8 +39,6 @@ ad_page_contract {
set
user_id
[
ad_maybe_redirect_for_registration
]
set
user_name
[
db_string user_name
"select first_names || ' ' || last_name from cc_users where user_id=:user_id"
-default
"User
$user
_id"
]
set
date_format
"YYYY-MM-DD"
set
currency
[
ad_parameter -package_id
[
im_package_cost_id
]
"DefaultCurrency"
""
"EUR"
]
set
billing_rate 0
# Please note "_" instead of "-". This is because we use
# underscores in the invoices and other costs. So the
...
...
@@ -50,6 +48,34 @@ set timesheet_log_date_format "YYYY_MM_DD"
set
item_nrs
[
array
names hours
]
ns_log Notice
"timesheet2-tasks/new-2: items_nrs=
$item
_nrs"
# ----------------------------------------------------------
# Determine Billing Rate
# ----------------------------------------------------------
set
billing_rate 0
set
billing_currency
""
db_0or1row get_billing_rate
"
select
hourly_cost as billing_rate,
currency as billing_currency
from
im_employees
where
employee_id = :user_id
"
if
{
""
==
$billing
_currency
}
{
set billing_currency
[
ad_parameter -package_id
[
im_package_cost_id
]
"DefaultCurrency"
""
"EUR"
]
}
# ----------------------------------------------------------
# Update items
# ----------------------------------------------------------
foreach
item_nr
$item
_nrs
{
ns_log Notice
"timesheet2-tasks/new-2: item_nr=
$item
_nr"
...
...
@@ -72,10 +98,10 @@ foreach item_nr $item_nrs {
}
set note
[
string
trim
$note
]
if
{
$hours
_worked == 0
&&
[
empty_string_p
$note
]
}
{
if
{
$hours
_worked == 0
}
{
# Delete a timesheet entry
ns_log Notice
"timesheet2-tasks/new-2: Delete timesheet entry for task_id=
$timesheet
_task_id"
db_dml hours_delete
"
delete from im_hours
where
...
...
@@ -85,34 +111,19 @@ foreach item_nr $item_nrs {
and day = to_date(:julian_date, 'J')
"
# Also delete the cost_item if there was a change
if
{
[
db_resultrows
]
=
= 0
}
{
ns_log Notice
"timesheet2-tasks/new-2: Delete cost items of timesheet task"
if
{
[
db_resultrows
]
!
= 0
}
{
db_dml costs_delete
"
delete from im_costs
where
cost_type_id =
[
im_cost_type_timesheet
]
and project_id = :project_id
and effective_date = to_date(:julian_date, 'J')
and cause_object_id = :timesheet_task_id
"
db_exec_plsql delete_timesheet_costs
{}
db_dml update_timesheet_task
{}
db_dml update_timesheet_task
"
update im_timesheet_tasks
set reported_units_cache = (
select sum(h.hours)
from im_hours h
where h.timesheet_task_id = task_id
)
where task_id = :timesheet_task_id
"
}
}
else
{
# Create or update a timesheet entry
ns_log Notice
"timesheet2-tasks/new-2: Create"
if
{
[
regexp
{([
0-9
]
+
)(
\,
([
0-9
]
+
))
?
}
$hours
_worked
]
}
{
regsub
","
$hours
_worked
"."
hours_worked
regsub
"'"
$hours
_worked
"."
hours_worked
...
...
@@ -150,8 +161,9 @@ foreach item_nr $item_nrs {
db_exec_plsql task_insert
""
set timesheet_task_id
$task
_id
}
# Update the hours table
#
...
...
@@ -167,42 +179,42 @@ foreach item_nr $item_nrs {
and day = to_date(:julian_date, 'J')
"
# Add a new im_hour record if there wasn't one before...
if
{
[
db_resultrows
]
== 0
}
{
db_dml hours_insert
"
insert into im_hours (
user_id, project_id, timesheet_task_id,
day, hours, billing_rate, note
day, hours,
billing_rate, billing_currency,
note
) values (
:user_id, :project_id, :timesheet_task_id,
to_date(:julian_date,'J'), :hours_worked, :billing_rate, :note
to_date(:julian_date,'J'), :hours_worked,
:billing_rate, :billing_currency,
:note
)"
}
db_dml update_timesheet_task
"
update im_timesheet_tasks
set reported_units_cache = (
select sum(h.hours)
from im_hours h
where h.timesheet_task_id = task_id
)
where task_id = :timesheet_task_id
"
# Update the reported hours on the timesheet task
db_dml update_timesheet_task
""
ns_log Notice
"timesheet2-tasks/new-2: Determine the cost-item related to task"
set cost_id
[
db_string costs_id_exist
"
select
cost_id
min(cost_id)
from
im_costs
where
cost_type_id =
[
im_cost_type_timesheet
]
and project_id = :project_id
and effective_date = to_date(:julian_date, 'J')
and cause_object_id = :
user
_id
"
-default
0
]
and cause_object_id = :
timesheet_task
_id
"
-default
""
]
set day
[
db_string day
"select to_char(to_date(:julian_date, 'J'), :timesheet_log_date_format) from dual"
]
set cost_name
"
$day
$user
_name"
if
{
!
$cost_id
}
{
if
{
""
==
$cost
_id
}
{
set cost_id
[
im_cost::new -cost_name
$cost
_name -cost_type_id
[
im_cost_type_timesheet
]]
}
...
...
@@ -217,7 +229,7 @@ foreach item_nr $item_nrs {
customer_id = :customer_id,
effective_date = to_date(:julian_date, 'J'),
amount = :billing_rate * cast(:hours_worked as numeric),
currency = :currency,
currency = :
billing_
currency,
payment_days = 0,
vat = 0,
tax = 0,
...
...
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