Commit 3b8adb35 authored by Frank Bergmann's avatar Frank Bergmann

- Repeating Costs running

parent ca9a465c
......@@ -64,7 +64,7 @@ ad_proc im_employee_info_component { employee_id return_url {view_name ""} } {
# --------------- Security --------------------------
db_1row employee_info "
set employee_info_exists [db_0or1row employee_info "
select
pe.first_names||' '||pe.last_name as user_name,
p.email,
......@@ -77,17 +77,19 @@ ad_proc im_employee_info_component { employee_id return_url {view_name ""} } {
users u,
im_employees e,
im_repeating_costs rc,
im_costs ci,
parties p,
persons pe,
im_cost_centers cc
where
pe.person_id = u.user_id
and p.party_id = u.user_id
and u.user_id = rc.rep_cost_id(+)
and u.user_id = ci.cause_object_id(+)
and ci.cost_id = rc.rep_cost_id
and u.user_id = :employee_id
and u.user_id = e.employee_id(+)
and e.department_id = cc.cost_center_id(+)
"
"]
set view_id [db_string get_view "select view_id from im_views where view_name=:view_name" -default 0]
ns_log Notice "im_employee_info_component: view_id=$view_id"
......@@ -110,18 +112,20 @@ ad_proc im_employee_info_component { employee_id return_url {view_name ""} } {
</tr>\n"
set ctr 1
# if the row makes references to "private Note" and the user isn't
# adminstrator, this row don't appear in the browser.
db_foreach column_list_sql $column_sql {
if {1 || [eval $visible_for]} {
append employee_html "
if {$employee_info_exists} {
# if the row makes references to "private Note" and the user isn't
# adminstrator, this row don't appear in the browser.
db_foreach column_list_sql $column_sql {
if {1 || [eval $visible_for]} {
append employee_html "
<tr $td_class([expr $ctr % 2])>
<td>$column_name &nbsp;</td><td>"
set cmd "append employee_html $column_render_tcl"
eval $cmd
append employee_html "</td></tr>\n"
incr ctr
}
set cmd "append employee_html $column_render_tcl"
eval $cmd
append employee_html "</td></tr>\n"
incr ctr
}
}
}
if {$admin } {
......
......@@ -25,7 +25,8 @@ ad_page_contract {
# ------------------------------------------------------------------
set user_id [ad_maybe_redirect_for_registration]
set today [db_string birthday_today "select sysdate from dual"]
set today [db_string birthday_today "select to_char(sysdate,'YYYY-MM-DD') from dual"]
set end_century "2099-12-31"
set internal_id [im_customer_internal]
if {![im_permission $user_id view_users]} {
......@@ -135,7 +136,8 @@ ad_form \
{job_description:text(textarea),nospell,optional {label "Job Description"} {html {rows 5 cols 40}}}
{start_date:text(text),optional {label "Start date"} {html {size 10}} }
{end_date:text(text),optional {label "End date date"} {html {size 10}} }
{end_date:text(text),optional {label "End date"} {html {size 10}} }
{voluntary_termination_p:text(radio),optional {label "Voluntary Termination"} {options $voluntary_termination_options} }
{termination_reason:text(textarea),nospell,optional {label "Termination Reason"} {html {rows 5 cols 40}}}
{signed_nda_p:text(radio),optional {label "NDA Signed?"} {options $voluntary_termination_options} }
......@@ -164,8 +166,14 @@ ad_form -extend -name cost -on_request {
select
e.*,
rc.start_date,
rc.end_date,
CASE WHEN rc.start_date is null
THEN to_date(:today,'YYYY-MM-DD')
ELSE to_date(rc.start_date)
END as start_date,
CASE WHEN rc.end_date is null
THEN to_date(:end_century,'YYYY-MM-DD')
ELSE to_date(rc.end_date)
END as end_date,
ci.*
from parties p,
im_employees e,
......@@ -173,30 +181,26 @@ ad_form -extend -name cost -on_request {
im_costs ci
where
p.party_id = :employee_id
and p.party_id = rc.rep_cost_id(+)
and p.party_id = ci.cost_id(+)
and p.party_id = e.employee_id(+)
and p.party_id = e.employee_id
and p.party_id = ci.cause_object_id(+)
and ci.cost_id = rc.rep_cost_id(+)
} -after_submit {
set cost_name $employee_name
if {"" == $end_date} { set end_date "2099-12-31" }
if {"" == $start_date} { set start_date $today }
# im_repeating_costs (and it's im_costs superclass) superclass
# im_costs contains a "cause_object_id" field pointing to employee_id.
# The join between im_costs and im_repeating_costs is necessary
# in order to elimiate all the non-repeating cost items.
set rep_costs_exist [db_string rep_costs_exist "
select count(*)
set rep_cost_id [db_string rep_costs_exist "
select rc.rep_cost_id
from im_repeating_costs rc,
im_costs ci
where rc.rep_cost_id = ci.cost_id
and ci.cause_object_id = :employee_id
"]
if {!$rep_costs_exist} {
" -default 0]
if {!$rep_cost_id} {
if [catch {
set rep_cost_id [im_cost::new -cost_name $cost_name -cost_type_id [im_cost_type_repeating]]
db_dml insert_repeating_costs "
......@@ -291,8 +295,11 @@ ad_form -extend -name cost -on_request {
provider_id = :internal_id,
cost_type_id = [im_cost_type_employee],
cost_status_id = [im_cost_status_created],
cause_object_id = :employee_id,
amount = (:salary + :social_security + :insurance + :other_costs) * :salary_payments_per_year / 12,
currency = :currency
currency = :currency,
tax = :tax,
vat = :vat
where
cost_id = :rep_cost_id
"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment