Commit d9ca8dec authored by Frank Bergmann's avatar Frank Bergmann

- Gustaf changes

parent 151c68a6
......@@ -5,7 +5,7 @@ ad_page_contract {
@date 2012-03-30
}
set current_user_id [ad_maybe_redirect_for_registration]
set current_user_id [auth::require_login]
im_company_permissions $current_user_id $company_id view read write admin
set default_currency [im_parameter -package_id [im_package_cost_id] "DefaultCurrency" "" "EUR"]
set max_project_name 40
......@@ -47,14 +47,14 @@ foreach project_id [array names project_hash] {
if {![info exists costs($key)]} { set costs($key) 0 }
}
if {[catch {
set est_profit [expr $costs($project_id-3702) - $costs($project_id-3706) - $costs($project_id-3726) - $costs($project_id-3728)]
set est_profit [expr {$costs($project_id-3702) - $costs($project_id-3706) - $costs($project_id-3726) - $costs($project_id-3728)}]
} err_msg]} {
ns_log Error "$err_msg"
set est_profit [lang::message::lookup "" intranet-cost.UnableToCalculateEstimatedProfit "Unable to calculate 'Estimated Profit'"]
}
if {[catch {
set profit [expr $costs($project_id-3700) - $costs($project_id-3704) - $costs($project_id-3718) - $costs($project_id-3722)]
set profit [expr {$costs($project_id-3700) - $costs($project_id-3704) - $costs($project_id-3718) - $costs($project_id-3722)}]
set profit_pretty [lc_numeric $profit "%.2f" [lang::user::locale]]
} err_msg]} {
ns_log Error "$err_msg"
......
......@@ -54,13 +54,13 @@ ad_proc -public im_cost_center_permissions {user_id cost_center_id view_var read
set user_is_admin_p [im_is_user_site_wide_or_intranet_admin $user_id]
set cc_admin_id [util_memoize [list db_string cc_admin "select manager_id from im_cost_centers where cost_center_id = $cost_center_id" -default ""]]
set user_is_cc_admin_p [expr $user_id == $cc_admin_id]
set user_is_cc_admin_p [expr {$user_id == $cc_admin_id}]
# -----------------------------------------------------
# Set the permission as the OR-conjunction of provider and customer
set view 1
set read 1
set write [expr $user_is_admin_p || $user_is_cc_admin_p]
set write [expr {$user_is_admin_p || $user_is_cc_admin_p}]
set admin $write
}
......@@ -250,15 +250,15 @@ ad_proc -public template::widget::im_cost_center_tree {
set include_empty_pos [lsearch $params include_empty_p]
if { $include_empty_pos >= 0 } {
set include_empty_p [lindex $params [expr $include_empty_pos + 1]]
set include_empty_p [lindex $params $include_empty_pos+1]
}
set department_only_p_pos [lsearch $params department_only_p]
if { $department_only_p_pos >= 0 } {
set department_only_p [lindex $params [expr $department_only_p_pos + 1]]
set department_only_p [lindex $params $department_only_p_pos+1]
}
set translate_p_pos [lsearch $params translate_p]
if { $translate_p_pos >= 0 } {
set translate_p [lindex $params [expr $translate_p_pos + 1]]
set translate_p [lindex $params $translate_p_pos+1]
}
}
......
This diff is collapsed.
......@@ -17,7 +17,7 @@ ad_page_contract {
{return_url "/intranet-cost/cost-centers/index"}
}
set user_id [ad_maybe_redirect_for_registration]
set user_id [auth::require_login]
set user_is_admin_p [im_is_user_site_wide_or_intranet_admin $user_id]
if {!$user_is_admin_p} {
ad_return_complaint 1 "You have insufficient privileges to use this page"
......
<master src="/packages/intranet-core/www/admin/master">
<property name="title">@page_title;noquote@</property>
<property name="doc(title)">@page_title;literal@</property>
<property name="main_navbar_label">admin</property>
<property name="admin_navbar_label">admin_cost_centers</property>
<property name="left_navbar">@left_navbar_html;noquote@</property>
<property name="left_navbar">@left_navbar_html;literal@</property>
<h1>@page_title@</h1>
......
......@@ -17,7 +17,7 @@ ad_page_contract {
# Defaults & Security
# ------------------------------------------------------
set user_id [ad_maybe_redirect_for_registration]
set user_id [auth::require_login]
set user_is_admin_p [im_is_user_site_wide_or_intranet_admin $user_id]
if {!$user_is_admin_p} {
......@@ -126,7 +126,7 @@ db_foreach cost_centers $main_sql {
}
append table "
<tr$bgcolor([expr $ctr % 2])>
<tr$bgcolor([expr {$ctr % 2}])>
<td><input type=checkbox name=cost_center_id.$cost_center_id></td>
<td><nobr>$sub_indent <a href=$cost_center_url?cost_center_id=$cost_center_id&return_url=$return_url>$cost_center_name</a></nobr></td>
<td>$cost_center_code</td>
......@@ -139,7 +139,7 @@ db_foreach cost_centers $main_sql {
"
if {{} != $employee_list} {
append table "
<tr$bgcolor([expr $ctr % 2])><td colspan=2 align=right>&nbsp;</td><td colspan=6>
<tr$bgcolor([expr {$ctr % 2}])><td colspan=2 align=right>&nbsp;</td><td colspan=6>
[join $employee_list ", "]
</td></tr>
"
......@@ -156,7 +156,7 @@ append left_navbar_html "
<div class='filter-block'>
<div class='filter-title'>#intranet-cost.AdminCostCenter#</div>
<ul>
<li><a href=new?[export_vars -url { return_url}]>[lang::message::lookup "" intranet-cost.CreateNewCostCenter "Create new Cost Center"]</a</li>
<li><a href=[export_vars -base new { return_url}]>[lang::message::lookup "" intranet-cost.CreateNewCostCenter "Create new Cost Center"]</a</li>
</ul>
</div>
"
<master src="../../../intranet-core/www/master">
<property name="title">@page_title@</property>
<property name="context">@context;noquote@</property>
<property name="doc(title)">@page_title;literal@</property>
<property name="context">@context;literal@</property>
<property name="main_navbar_label">finance</property>
<property name="left_navbar">@left_navbar_html;noquote@</property>
<property name="left_navbar">@left_navbar_html;literal@</property>
<h2>@page_title@</h2>
......@@ -10,6 +10,6 @@
<div class="general-message">@message@</div>
</if>
<property name="focus">@focus;noquote@</property>
<property name="focus">@focus;literal@</property>
<formtemplate id="cost_center"></formtemplate>
......@@ -24,7 +24,7 @@ ad_page_contract {
# Default & Security
# ------------------------------------------------------------------
set user_id [ad_maybe_redirect_for_registration]
set user_id [auth::require_login]
set user_is_admin_p [im_is_user_site_wide_or_intranet_admin $user_id]
if {!$user_is_admin_p} {
ad_return_complaint 1 "You have insufficient privileges to use this page"
......
<master>
<property name="title">@page_title@</property>
<property name="context">@context@</property>
<property name="doc(title)">@page_title;literal@</property>
<property name="context">@context;literal@</property>
<include src="/packages/acs-subsite/www/permissions/perm-user-add-include">
......@@ -22,7 +22,7 @@ ad_page_contract {
{submit_save ""}
}
set user_id [ad_maybe_redirect_for_registration]
set user_id [auth::require_login]
if {![im_permission $user_id add_costs]} {
ad_return_complaint 1 "<li>You have insufficient privileges to see this page"
......@@ -56,9 +56,9 @@ if {"" != $submit_del} {
set otype $object_type($cost_id)
# ToDo: Security
if [catch {
if {[catch {
im_exec_dml del_cost_item "${otype}__delete(:cost_id)"
} errmsg] {
} errmsg]} {
ad_return_complaint 1 "<li>Error deleting cost item #$cost_id of type '$otype':<br>
<pre>$errmsg</pre>"
return
......
<master src="../../../intranet-core/www/master">
<property name="title">@page_title@</property>
<property name="focus">@focus;noquote@</property>
<property name="context">@context;noquote@</property>
<property name="doc(title)">@page_title;literal@</property>
<property name="focus">@focus;literal@</property>
<property name="context">@context;literal@</property>
<property name="main_navbar_label">finance</property>
<if @message@ not nil>
<div class="general-message">@message@</div>
</if>
<table cellspacing=1 cellpadding=1 border=0>
<table cellspacing="1" cellpadding="1" border="0">
<tr>
<td valign=top>
<td valign="top">
<table cellspacing=1 cellpadding=1 border=0>
<table cellspacing="1" cellpadding="1" border="0">
<tr>
<td class=rowtitle align=center>@page_title@</td>
<td class=rowtitle align="center">@page_title@</td>
</tr>
<tr>
<td>
......@@ -24,12 +24,12 @@
</table>
</td>
<td valign=top>
<td valign="top">
<if "" ne @admin_html@>
<table cellspacing=1 cellpadding=1 border=0>
<table cellspacing="1" cellpadding="1" border="0">
<tr>
<td class=rowtitle align=center>#intranet-cost.Administration#</td>
<td class=rowtitle align="center">#intranet-cost.Administration#</td>
</tr>
<tr>
<td>
......
......@@ -24,7 +24,7 @@ ad_page_contract {
# Default & Security
# ------------------------------------------------------------------
set user_id [ad_maybe_redirect_for_registration]
set user_id [auth::require_login]
set page_title "[_ intranet-cost.Edit_Cost]"
set context [im_context_bar $page_title]
......@@ -34,7 +34,7 @@ set context [im_context_bar $page_title]
# Redirect to sub-type
# ------------------------------------------------------------------
if {[info exists cost_id] && $cost_id != "" && $cost_id != 0 && $form_mode == "display"} {
if {[info exists cost_id] && $cost_id ne "" && $cost_id != 0 && $form_mode eq "display"} {
set subtype_sql "
select bou.*
from acs_objects o,
......@@ -80,7 +80,7 @@ set admin_html ""
# Get everything about the cost
# ------------------------------------------------------------------
if {![exists_and_not_null cost_id]} {
if {(![info exists cost_id] || $cost_id eq "")} {
# New variable: setup some reasonable defaults
set page_title "[_ intranet-cost.New_Cost_Item]"
......
<master>
<property name="title">@page_title;noquote@</property>
<property name="doc(title)">@page_title;literal@</property>
<property name="main_navbar_label">finance</property>
<property name="sub_navbar">@sub_navbar;noquote@</property>
<property name="left_navbar">@left_navbar_html;noquote@</property>
<property name="sub_navbar">@sub_navbar;literal@</property>
<property name="left_navbar">@left_navbar_html;literal@</property>
<table cellpadding=0 cellspacing=0 border=0 width="100%">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr><td>
<%= [im_component_bay top] %>
</td></tr>
</table>
<table cellpadding=0 cellspacing=0 border=0 width="100%">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td valign=top>
<td valign="top">
<%= [im_component_bay left] %>
</td>
<td valign=top>
<td valign="top">
<%= [im_component_bay right] %>
</td>
</tr>
</table>
<table cellpadding=0 cellspacing=0 border=0 width="100%">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr><td>
<%= [im_component_bay bottom] %>
</td></tr>
......
......@@ -14,7 +14,7 @@ ad_page_contract {
{ project_id 0 }
{ company_id 0 }
}
set user_id [ad_maybe_redirect_for_registration]
set user_id [auth::require_login]
set page_title "[_ intranet-cost.Finance_Home]"
set context_bar [im_context_bar $page_title]
set return_url [im_url_with_query]
......
<master>
<property name="title">@page_title;noquote@</property>
<property name="doc(title)">@page_title;literal@</property>
<property name="main_navbar_label">finance</property>
<property name="sub_navbar">@sub_navbar;noquote@</property>
<property name="left_navbar">@left_navbar_html;noquote@</property>
<property name="sub_navbar">@sub_navbar;literal@</property>
<property name="left_navbar">@left_navbar_html;literal@</property>
<form action="/intranet-cost/costs/cost-action" method="POST">
<%= [export_vars -form {company_id cost_id return_url}] %>
<table width="100%" cellpadding=2 cellspacing=2 border=0>
<table width="100%" cellpadding="2" cellspacing="2" border="0">
@table_header_html;noquote@
@table_body_html;noquote@
@table_continuation_html;noquote@
......
......@@ -63,7 +63,7 @@ ad_page_contract {
# ---------------------------------------------------------------
# User id already verified by filters
set user_id [ad_maybe_redirect_for_registration]
set user_id [auth::require_login]
set page_title "[_ intranet-cost.Cost_Items]"
set context_bar [im_context_bar $page_title]
set page_focus "im_header_form.keywords"
......@@ -79,10 +79,10 @@ if {![im_permission $user_id view_costs]} {
return
}
if { [empty_string_p $how_many] || $how_many < 1 } {
if { $how_many eq "" || $how_many < 1 } {
set how_many [im_parameter -package_id [im_package_core_id] NumberResultsPerPage "" 50]
}
set end_idx [expr $start_idx + $how_many - 1]
set end_idx [expr {$start_idx + $how_many - 1}]
if {0 != $project_id && "" != $project_id} {
set company_id [db_string company_from_project "select company_id from im_projects where project_id = :project_id" -default 0]
......@@ -130,10 +130,10 @@ db_foreach column_list_sql $column_sql {
# ---------------------------------------------------------------
set criteria [list]
if { ![empty_string_p $cost_status_id] && $cost_status_id > 0 } {
if { $cost_status_id ne "" && $cost_status_id > 0 } {
lappend criteria "c.cost_status_id in ([join [im_sub_categories $cost_status_id] ","])"
}
if { ![empty_string_p $cost_type_id] && $cost_type_id != 0 } {
if { $cost_type_id ne "" && $cost_type_id != 0 } {
lappend criteria "c.cost_type_id in ([join [im_sub_categories $cost_type_id] ","])"
}
if {$customer_id} {
......@@ -174,7 +174,7 @@ if {"" != $project_id && 0 != $project_id} {
if { ![empty_string_p $letter] && [string compare $letter "ALL"] != 0 && [string compare $letter "SCROLL"] != 0 } {
if { $letter ne "" && $letter ne "ALL" && $letter ne "SCROLL" } {
lappend criteria "im_first_letter_default_to_a(cust.company_name)=:letter"
}
......@@ -217,7 +217,7 @@ switch $order_by {
}
set where_clause [join $criteria " and\n "]
if { ![empty_string_p $where_clause] } {
if { $where_clause ne "" } {
set where_clause " and $where_clause"
}
......@@ -314,7 +314,7 @@ set filter_html "
# ---------------------------------------------------------------
# Set up colspan to be the number of headers + 1 for the # column
set colspan [expr [llength $column_headers] + 1]
set colspan [expr {[llength $column_headers] + 1}]
set table_header_html ""
#<tr>
......@@ -328,13 +328,13 @@ set table_header_html ""
#
set url "$local_url?"
set query_string [export_ns_set_vars url [list order_by]]
if { ![empty_string_p $query_string] } {
if { $query_string ne "" } {
append url "$query_string&"
}
append table_header_html "<tr>\n"
foreach col $column_headers {
if { [string compare $order_by $col] == 0 } {
if { $order_by eq $col } {
append table_header_html " <td class=rowtitle>$col</td>\n"
} else {
append table_header_html " <td class=rowtitle><a href=\"${url}order_by=[ns_urlencode $col]\">$col</a></td>\n"
......@@ -354,7 +354,7 @@ set ctr 0
set idx $start_idx
db_foreach costs_info_query {} {
set url [im_maybe_prepend_http $url]
if { [empty_string_p $url] } {
if { $url eq "" } {
set url_string "&nbsp;"
} else {
set url_string "<a href=\"$url\">$url</a>"
......@@ -364,7 +364,7 @@ db_foreach costs_info_query {} {
if {"" == $amount} { set currency "" }
# Append together a line of data based on the "column_vars" parameter list
append table_body_html "<tr$bgcolor([expr $ctr % 2])>\n"
append table_body_html "<tr$bgcolor([expr {$ctr % 2}])>\n"
foreach column_var $column_vars {
append table_body_html "\t<td valign=top>"
set cmd "append table_body_html $column_var"
......@@ -381,7 +381,7 @@ db_foreach costs_info_query {} {
}
# Show a reasonable message when there are no result rows:
if { [empty_string_p $table_body_html] } {
if { $table_body_html eq "" } {
set table_body_html "
<tr><td colspan=$colspan><ul><li><b>
[_ intranet-cost.lt_There_are_currently_n]
......@@ -391,7 +391,7 @@ if { [empty_string_p $table_body_html] } {
if { $ctr == $how_many && $end_idx < $total_in_limited } {
# This means that there are rows that we decided not to return
# Include a link to go to the next page
set next_start_idx [expr $end_idx + 1]
set next_start_idx [expr {$end_idx + 1}]
set next_page_url "$local_url?start_idx=$next_start_idx&[export_ns_set_vars url [list start_idx]]"
} else {
set next_page_url ""
......@@ -400,7 +400,7 @@ if { $ctr == $how_many && $end_idx < $total_in_limited } {
if { $start_idx > 0 } {
# This means we didn't start with the first row - there is
# at least 1 previous row. add a previous page link
set previous_start_idx [expr $start_idx - $how_many]
set previous_start_idx [expr {$start_idx - $how_many}]
if { $previous_start_idx < 0 } { set previous_start_idx 0 }
set previous_page_url "$local_url?start_idx=$previous_start_idx&[export_ns_set_vars url [list start_idx]]"
} else {
......@@ -415,7 +415,7 @@ if { $start_idx > 0 } {
# => include a link to go to the next page
#
if {$ctr==$how_many && $total_in_limited > 0 && $end_idx < $total_in_limited} {
set next_start_idx [expr $end_idx + 1]
set next_start_idx [expr {$end_idx + 1}]
set next_page "<a href=$local_url?start_idx=$next_start_idx&[export_ns_set_vars url [list start_idx]]>[_ intranet-cost.Next_Page]</a>"
} else {
set next_page ""
......@@ -426,7 +426,7 @@ if {$ctr==$how_many && $total_in_limited > 0 && $end_idx < $total_in_limited} {
# => add a previous page link
#
if { $start_idx > 0 } {
set previous_start_idx [expr $start_idx - $how_many]
set previous_start_idx [expr {$start_idx - $how_many}]
if { $previous_start_idx < 0 } { set previous_start_idx 0 }
set previous_page "<a href=$local_url?start_idx=$previous_start_idx&[export_ns_set_vars url [list start_idx]]>[_ intranet-cost.Previous_Page]</a>"
} else {
......@@ -442,7 +442,7 @@ set table_continuation_html "
set button_html "
<tr>
<td colspan=[expr $colspan - 3]></td>
<td colspan=[expr {$colspan - 3}]></td>
<td align=center>
<input type=submit name=submit_save value='[_ intranet-cost.Save]'>
</td>
......
<master src="../../../intranet-core/www/master">
<property name="title">#intranet-cost.Absences#</property>
<property name="doc(title)">#intranet-cost.Absences#</property>
<property name="context">#intranet-cost.context#</property>
<property name="main_navbar_label">finance</property>
<br>
<%= [im_costs_navbar "none" "/intranet/invoices/index" "" "" [list] "costs_rep"] %>
<table width="100%" cellpadding=2 cellspacing=2 border=0>
<table width="100%" cellpadding="2" cellspacing="2" border="0">
<%= $table_header_html %>
<%= $table_body_html %>
<%= $table_continuation_html %>
......
......@@ -26,7 +26,7 @@ ad_page_contract {
# Defaults & Security
# ---------------------------------------------------------------
set user_id [ad_maybe_redirect_for_registration]
set user_id [auth::require_login]
set subsite_id [ad_conn subsite_id]
set bgcolor(0) " class=roweven "
set bgcolor(1) " class=rowodd "
......@@ -95,7 +95,7 @@ where start_block >= rc.start_date
db_foreach all_start_blocks $all_start_blocks_sql {
set key "$rep_cost_id:$start_block"
# Fill the field with a link to create a new cost item
set blocks($key) "<a href='$cost_create_url?[export_vars -url { rep_cost_id start_block return_url}]'>([_ intranet-cost.create])</a>"
set blocks($key) "<a href='[export_vars -base $cost_create_url { rep_cost_id start_block return_url}]'>([_ intranet-cost.create])</a>"
ns_log Notice "/intranet-cos/rep-costs/index: key=$key"
}
......@@ -145,7 +145,7 @@ foreach cost_tuple $repeating_cost_ids {
set cost_id [lindex $cost_tuple 0]
set cost_name [lindex $cost_tuple 1]
append table_body_html "<tr $bgcolor([expr $ctr % 2])>\n"
append table_body_html "<tr $bgcolor([expr {$ctr % 2}])>\n"
append table_body_html "<td><a href=new?rep_cost_id=$rep_cost_id&form_mode=display>$cost_name</a></td>\n"
for {set month 1} {$month <= $report_months} {incr month} {
......
<master src="../../../intranet-core/www/master">
<property name="title">@page_title@</property>
<property name="context">@context;noquote@</property>
<property name="doc(title)">@page_title;literal@</property>
<property name="context">@context;literal@</property>
<property name="main_navbar_label">finance</property>
<h2>@page_title@</h2>
......@@ -9,6 +9,6 @@
<div class="general-message">@message@</div>
</if>
<property name="focus">@focus;noquote@</property>
<property name="focus">@focus;literal@</property>
<formtemplate id="cost"></formtemplate>
......@@ -20,7 +20,7 @@ ad_page_contract {
# Default & Security
# ------------------------------------------------------------------
set user_id [ad_maybe_redirect_for_registration]
set user_id [auth::require_login]
set page_title [lang::message::lookup "" intranet-cost.Create_Repeating_Cost_Item "Create Repeating Cost Item"]
set context [im_context_bar $page_title]
set today [db_string birthday_today "select to_char(sysdate,'YYYY-MM-DD') from dual"]
......@@ -72,9 +72,9 @@ append cost_name " - $start_block"
set cost_id [im_new_object_id]
set cause_object_id $rep_cost_id
set effective_date $start_block
if {![exists_and_not_null payment_days]} { set payment_days 0 }
if {![exists_and_not_null tax]} { set tax 0 }
if {![exists_and_not_null vat]} { set vat 0 }
if {(![info exists payment_days] || $payment_days eq "")} { set payment_days 0 }
if {(![info exists tax] || $tax eq "")} { set tax 0 }
if {(![info exists vat] || $vat eq "")} { set vat 0 }
set project_options [im_project_options]
set customer_options [im_company_options -include_empty_p 0 -status "Active" -type "CustOrIntl"]
......
<master src="../../../intranet-core/www/master">
<property name="title">@page_title@</property>
<property name="context">@context;noquote@</property>
<property name="doc(title)">@page_title;literal@</property>
<property name="context">@context;literal@</property>
<property name="main_navbar_label">finance</property>
<h2>@page_title@</h2>
......@@ -9,6 +9,6 @@
<div class="general-message">@message@</div>
</if>
<property name="focus">@focus;noquote@</property>
<property name="focus">@focus;literal@</property>
<formtemplate id="cost"></formtemplate>
......@@ -24,7 +24,7 @@ ad_page_contract {
# Default & Security
# ------------------------------------------------------------------
set user_id [ad_maybe_redirect_for_registration]
set user_id [auth::require_login]
set page_title "<#_ Edit Repeating Cost#>"
set context [im_context_bar $page_title]
set today [db_string birthday_today "select sysdate from dual"]
......@@ -42,7 +42,7 @@ set focus "cost.var_name"
# Get everything about the cost
# ------------------------------------------------------------------
if {![exists_and_not_null rep_cost_id]} {
if {(![info exists rep_cost_id] || $rep_cost_id eq "")} {
# New variable: setup some reasonable defaults
set page_title "<#_ New Repeating Cost Item#>"
......
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