Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-timesheet2-tasks
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
0
Merge Requests
0
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-tasks
Commits
54115ba4
Commit
54115ba4
authored
Aug 09, 2007
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- GanttProject checking day
parent
0786344b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
114 additions
and
6 deletions
+114
-6
task-delete.tcl
www/task-delete.tcl
+114
-6
No files found.
www/task-delete.tcl
View file @
54115ba4
...
...
@@ -15,15 +15,123 @@ foreach old_id $task_id {
if
{[
info
exists assign_to
(
$old
_id
)]}
{
set new_id
$assign
_to
(
$old
_id
)
db_dml move_hours
"UPDATE im_hours SET project_id=:new_id WHERE project_id=:old_id"
db_dml
move_dependencies_one
"UPDATE im_timesheet_task_dependencies SET task_id_one=:new_id WHERE task_id_one=
:old_id"
db_dml
move_dependencies_two
"UPDATE im_timesheet_task_dependencies SET task_id_two=:new_id WHERE task_id_two=
:old_id"
# Delete dependencies. This may
"split"
the Gantt-network, but
# everything
else
would cause very funny results, probably.
db_dml
del_dependencies_one
"DELETE from im_timesheet_task_dependencies WHERE task_id_one =
:old_id"
db_dml
del_dependencies_two
"DELETE from im_timesheet_task_dependencies WHERE task_id_two =
:old_id"
db_dml move_children
"UPDATE im_projects SET parent_id=:new_id WHERE parent_id=:old_id"
# Join logged hours.
# This is complicated, because a user can only log 1 record per day and project.
# We start by getting all the hours to move and
then
we add them to the new
# ones. We need to get a list_of_lists first, because we're going to delete stuff
# inside the loop
then
.
set old_hours_list_list
[
db_list_of_lists old_hours
"
select h.user_id as old_user_id,
h.project_id as old_project_id,
h.day as old_day,
h.hours as old_hours,
h.billing_rate as old_billing_rate,
h.billing_currency as old_billing_currency,
h.note as old_note,
h.cost_id as old_cost_id
from im_hours h
where h.project_id = :old_id
"
]
foreach hours_tuple
$old
_hours_list_list
{
set old_user_id
[
lindex
$hours
_tuple 0
]
set old_project_id
[
lindex
$hours
_tuple 1
]
set old_day
[
lindex
$hours
_tuple 2
]
set old_hours
[
lindex
$hours
_tuple 3
]
set old_billing_rate
[
lindex
$hours
_tuple 4
]
set old_billing_currency
[
lindex
$hours
_tuple 5
]
set old_note
[
lindex
$hours
_tuple 6
]
set old_cost_id
[
lindex
$hours
_tuple 7
]
ns_log Notice
"task-delete: old_user_id=
$old
_user_id, old_project_id=
$old
_project_id, old_day=
$old
_day, old_hours=
$old
_hours, old_billing_rate=
$old
_billing_rate, old_billing_currency=
$old
_billing_currency, old_note=
$old
_note, old_cost_id=
$old
_cost_id"
# Reset the cost_id record of im_hours to null so that we can del the cost item
# and delete the cost item. The Timesheet sweeper will take care of it afterwards.
db_dml nul_cost_item
"
update im_hours
set cost_id = null
where user_id = :old_user_id
and project_id = :old_project_id
and day = :old_day
"
db_list del_cost_item
"select im_cost__delete(cost_id) from im_costs where cost_id = :old_cost_id"
# Get the logged hours of the new task
(
if
there were logged hours
)
set new_hours 0
set new_note
""
set new_cost_id 0
set new_exists_p 0
db_0or1row new_hours
"
select h.hours as new_hours,
h.note as new_note,
h.cost_id as new_cost_id,
1 as new_exists_p
from im_hours h
where h.user_id = :old_user_id
and h.project_id = :new_id
and h.day = :old_day
"
# Reset the cost_id record of im_hours to null so that we can del the cost item
# and delete the cost item. The Timesheet sweeper will take care of it afterwards.
db_dml nul_cost_item
"
update im_hours
set cost_id = null
where user_id = :old_user_id
and project_id = :new_id
and day = :old_day
"
db_list del_cost_item
"select im_cost__delete(cost_id) from im_costs where cost_id = :new_cost_id"
# Delete the
"new"
im_hours entries
(
if
exists
)
db_dml del_new_hours
"
delete from im_hours
where user_id = :old_user_id
and project_id = :old_project_id
and day = :old_day
"
set hours
[
expr
$old
_hours +
$new
_hours
]
set note
[
string
trim
[
join
[
list
$old
_note
$new
_note
]
" "
]]
# Insert a new im_hours entry with the summed up hours
db_dml insert
"
insert into im_hours (user_id, project_id, day, hours, billing_rate, billing_currency, note)
values (:old_user_id, :old_project_id, :old_day, :hours, :old_billing_rate, :old_billing_currency, :note)
"
}
# Delete the old im_hours entries.
db_dml del_hours
"delete from im_hours where project_id = :old_id"
# Move sub-projects and sub-tasks to the new project.
# Financial caches are updated automatically
(
nice test for the trigger, actually...
)
db_dml move_children
"UPDATE im_projects SET parent_id = :new_id WHERE parent_id = :old_id"
# Delete membership relationships
# The old task is gone, so user assignments to that task are also gone. Right?
set rel_ids
[
db_list rels
"select rel_id from acs_rels where object_id_one = :old_id"
]
foreach rel_id
$rel
_ids
{
ns_log Notice
"task-delete: acs_object__delete(
$rel
_id)"
db_string del_rel
"select acs_object__delete(:rel_id)"
}
# Move cost information
db_dml move_costs
"UPDATE im_costs SET project_id = :new_id WHERE project_id = :old_id"
# ToDo: cost-project relationships with acs_rels
db_dml move_resources
"UPDATE acs_rels SET object_id_one=:new_id WHERE object_id_one=:old_id"
}
# Create the necessary cost items for the timesheet hours
im_timesheet2_sync_timesheet_costs -project_id
$project
_id
}
#
...
...
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