Commit 534b9aca authored by Frank Bergmann's avatar Frank Bergmann

- Gustaf changes

parent 180a7835
......@@ -99,12 +99,12 @@ order by
set old_currency ""
db_foreach prices $price_sql {
if {"" != $old_currency && ![string equal $old_currency $currency]} {
if {"" != $old_currency && $old_currency ne $currency } {
append price_rows_html "<tr><td colspan=$colspan>&nbsp;</td></tr>\n"
}
append price_rows_html "
<tr $bgcolor([expr $ctr % 2]) nobreak>
<tr $bgcolor([expr {$ctr % 2}]) nobreak>
<td>$uom</td>
<td>$task_type</td>
<td>$material</td>
......@@ -115,7 +115,7 @@ order by
set old_currency $currency
}
if {$price_rows_html != ""} {
if {$price_rows_html ne ""} {
append price_list_html $price_rows_html
} else {
append price_list_html "<tr><td colspan=$colspan align=center><i>[_ intranet-timesheet2-invoices.No_prices_found]</i></td></tr>\n"
......@@ -134,7 +134,7 @@ order by
</form>
<ul>
<li>
<a href=/intranet-timesheet2-invoices/price-lists/upload-prices?[export_vars -url {company_id return_url}]>
<a href=/intranet-timesheet2-invoices/price-lists/[export_vars -base upload-prices {company_id return_url}]>
[_ intranet-timesheet2-invoices.Upload_prices]</A>
[_ intranet-timesheet2-invoices.lt_for_this_company_via_]
<li>
......@@ -338,7 +338,7 @@ ad_proc im_timesheet_invoicing_project_hierarchy {
}
append task_table_rows "
<tr $bgcolor([expr $ctr % 2])>
<tr $bgcolor([expr {$ctr % 2}])>
<td align=middle><input type=checkbox name=include_task value=$project_id $task_disabled $task_checked></td>
<td align=left><nobr>$indent <A href=/intranet/projects/view?project_id=$project_id>$project_name</a></nobr></td>
<td align=left>$material_name</td>
......@@ -354,7 +354,7 @@ ad_proc im_timesheet_invoicing_project_hierarchy {
incr ctr
}
if {[string equal "" $task_table_rows]} {
if {$task_table_rows eq ""} {
set task_table_rows "<tr><td colspan=$colspan align=center>[lang::message::lookup "" intranet-timesheet2-invoices.No_tasks_found "No tasks found"]</td></tr>"
}
......
......@@ -2,26 +2,26 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<master src="../../../intranet-core/www/master">
<property name="title"></property>
<property name="doc(title)"></property>
<property name="main_navbar_label">finance</property>
<property name="sub_navbar">@sub_navbar;noquote@</property>
<property name="sub_navbar">@sub_navbar;literal@</property>
<table cellspacing=5 cellpadding=0>
<tr valign=top>
<table cellspacing="5" cellpadding="0">
<tr valign="top">
<td>
<table cellspacing=0 cellpadding=1>
<table cellspacing="0" cellpadding="1">
<tr class=rowtitle>
<td class=rowtitle>Filter Reported Hours</td>
</tr>
<tr valign=top>
<tr valign="top">
<td><formtemplate id=filter></formtemplate></td>
</tr>
</table>
</td>
<td>
<table cellspacing=0 cellpadding=1>
<table cellspacing="0" cellpadding="1">
<tr>
<td>
<h4><%= [lang::message::lookup "" intranet-timesheet2-invoices.Timesheet_Invoicing_Wizard "Timesheet Invoicing Wizard"] %></h4>
......@@ -44,15 +44,15 @@
<form action=new-3 method=POST>
<%= [export_vars -form {company_id invoice_currency cost_center_id target_cost_type_id return_url select_project start_date end_date}] %>
<table cellpadding=1 cellspacing=1 border=0>
<table cellpadding="1" cellspacing="1" border="0">
@task_table_rows;noquote@
<tr>
<td colspan=10 align=right>
<input type=checkbox name=aggregate_tasks_p value=1 checked>
<td colspan="10" align="right">
<input type="checkbox" name="aggregate_tasks_p" value="1" checked>
<%= [lang::message::lookup "" intranet-timesheet2-invoices.Aggregate_tasks_of_the_same_material "Aggregate tasks of the same Material"] %>
<input type=submit name=submit value='<%= [lang::message::lookup "" intranet-timesheet2-invoices.lt_Select_Tasks_for_Invo "Select Tasks for Invoicing"] %>'>
<input type="submit" name="submit" value='<%= [lang::message::lookup "" intranet-timesheet2-invoices.lt_Select_Tasks_for_Invo "Select Tasks for Invoicing"] %>'>
</td>
</tr>
......
......@@ -30,7 +30,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 current_user_id $user_id
set current_url [im_url_with_query]
set page_focus "im_header_form.keywords"
......@@ -51,7 +51,7 @@ if {![im_permission $user_id add_invoices]} {
# Do we need the cost_center_id for creating a new invoice?
# This is necessary if the invoice_nr depends on the cost_center_id (profit center).
set cost_center_required_p [parameter::get_from_package_key -package_key "intranet-invoices" -parameter "NewInvoiceRequiresCostCenterP" -default 0]
if {$cost_center_required_p && ($cost_center_id == "" || $cost_center_id == 0)} {
if {$cost_center_required_p && ($cost_center_id eq "" || $cost_center_id == 0)} {
ad_returnredirect [export_vars -base "/intranet-invoices/new-cost-center-select" {
{pass_through_variables {cost_type_id customer_id provider_id project_id invoice_currency create_invoice_from_template select_project source_cost_type_id target_cost_type_id start_date end_date}}
select_project
......@@ -73,7 +73,7 @@ if {$cost_center_required_p && ($cost_center_id == "" || $cost_center_id == 0)}
set target_cost_type [im_category_from_id $target_cost_type_id]
set allowed_cost_type [im_cost_type_write_permissions $current_user_id]
if {[lsearch -exact $allowed_cost_type $target_cost_type_id] == -1} {
if {$target_cost_type_id ni $allowed_cost_type} {
ad_return_complaint "Insufficient Privileges" "
<li>You can't create documents of type \#$target_cost_type_id."
ad_script_abort
......
......@@ -3,10 +3,10 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<master src="../../../intranet-core/www/master">
<property name="title">@page_title@</property>
<property name="context">@context_bar@</property>
<property name="doc(title)">@page_title;literal@</property>
<property name="context">@context_bar;literal@</property>
<property name="main_navbar_label">finance</property>
<property name="sub_navbar">@sub_navbar;noquote@</property>
<property name="sub_navbar">@sub_navbar;literal@</property>
<form action=new-4 method=POST>
<%= [export_vars -form {customer_id provider_id invoice_id cost_status_id start_date end_date select_project return_url invoice_hour_type}] %>
......@@ -14,29 +14,29 @@
@include_task_html;noquote@
<!-- Invoice Data and Receipient Tables -->
<table cellpadding=0 cellspacing=0 bordercolor=#6699CC border=0>
<tr valign=top>
<table cellpadding="0" cellspacing="0" bordercolor="#6699CC" border="0">
<tr valign="top">
<td>
<table border=0 cellPadding=0 cellspacing=2>
<table border="0" cellPadding=0 cellspacing="2">
<!-- Invoice Data -->
<tr>
<td align=middle class=rowtitle colspan=2>
<td align=middle class=rowtitle colspan="2">
#intranet-timesheet2-invoices.Invoice_Data#
</td>
</tr>
<tr>
<td class=rowodd>#intranet-timesheet2-invoices.Invoice_nr#:</td>
<td class=rowodd>
<input type=text name=invoice_nr size=15 value='@invoice_nr@'>
<input type="text" name="invoice_nr" size="15" value='@invoice_nr@'>
</td>
</tr>
<tr>
<td class=roweven>#intranet-timesheet2-invoices.Invoice_date#:</td>
<td class=roweven>
<input type=text name=invoice_date size=15 value='@invoice_date@'>
<input type="text" name="invoice_date" size="15" value='@invoice_date@'>
</td>
</tr>
<tr>
......@@ -56,7 +56,7 @@
<tr>
<td class=roweven>#intranet-timesheet2-invoices.Payment_terms#</td>
<td class=roweven>
<input type=text name=payment_days size=5 value='@default_payment_days@'>
<input type="text" name="payment_days" size="5" value='@default_payment_days@'>
days date of invoice</td>
</tr>
<tr>
......@@ -79,10 +79,10 @@
</td>
<td></td>
<td align=left>
<table border=0 cellspacing=2 cellpadding=0 >
<td align="left">
<table border="0" cellspacing="2" cellpadding="0" >
<tr>
<td align=center valign=top class=rowtitle colspan=2>
<td align="center" valign="top" class=rowtitle colspan="2">
#intranet-timesheet2-invoices.Recipient#
</td>
</tr>
......@@ -118,8 +118,8 @@
</table>
<br/><br/>
<!-- the list of tasks (invoicable items) -->
<div align=left>
<table cellpadding=2 cellspacing=2 border=0>
<div align="left">
<table cellpadding="2" cellspacing="2" border="0">
<%= [im_timesheet_invoicing_project_hierarchy \
-select_project $select_project \
-start_date $invoicing_start_date \
......@@ -135,7 +135,7 @@
<!-- the list of task sums, distinguised by type and UOM -->
<table width="100%">
<tr>
<td align=left><table border=0 cellspacing=2 cellpadding=1>
<td align="left"><table border="0" cellspacing="2" cellpadding="1">
@task_sum_html;noquote@
......@@ -148,11 +148,11 @@
<if @project_type_enabled_p@>
<td></td>
</if>
<td colspan=4 align=right>
<table border=0 cellspacing=1 cellpadding=0>
<td colspan="4" align="right">
<table border="0" cellspacing="1" cellpadding="0">
<tr>
<td>#intranet-timesheet2-invoices.VAT#</td>
<td><input type=text name=vat value='@default_vat@' size=4> % &nbsp;</td>
<td><input type="text" name="vat" value='@default_vat@' size="4"> % &nbsp;</td>
</tr>
</table>
</td>
......@@ -168,24 +168,24 @@
<if @project_type_enabled_p@>
<td></td>
</if>
<td colspan=4 align=right>
<table border=0 cellspacing=1 cellpadding=0>
<td colspan="4" align="right">
<table border="0" cellspacing="1" cellpadding="0">
<tr>
<td>#intranet-timesheet2-invoices.TAX#</td>
<td><input type=text name=tax value='@default_tax@' size=4> % &nbsp;</td>
<td><input type="text" name="tax" value='@default_tax@' size="4"> % &nbsp;</td>
</tr>
</table>
</td>
</tr>
</if>
<else>
<input type=hidden name=tax value='@default_tax@'>
<input type="hidden" name="tax" value='@default_tax@'>
</else>
<tr>
<td>&nbsp; </td>
<td colspan=6 align=right>
<input type=submit name=submit value='@button_text@'>
<td colspan="6" align="right">
<input type="submit" name="submit" value='@button_text@'>
</td>
</tr>
......
......@@ -39,7 +39,7 @@ ad_page_contract {
# Defaults & Security
# ---------------------------------------------------------------
set user_id [ad_maybe_redirect_for_registration]
set user_id [auth::require_login]
set org_company_id $company_id
set number_format "99990.099"
......@@ -66,7 +66,7 @@ if {![im_permission $user_id add_invoices]} {
}
set allowed_cost_type [im_cost_type_write_permissions $user_id]
if {[lsearch -exact $allowed_cost_type $target_cost_type_id] == -1} {
if {$target_cost_type_id ni $allowed_cost_type} {
ad_return_complaint "Insufficient Privileges" "
<li>You can't create documents of type \#$target_cost_type_id."
ad_script_abort
......@@ -525,13 +525,13 @@ order by
append reference_price_html "
<tr>
<td class=$bgcolor([expr $price_list_ctr % 2])>$price_company_name</td>
<td class=$bgcolor([expr $price_list_ctr % 2])>$price_uom</td>
<td class=$bgcolor([expr $price_list_ctr % 2])>$price_task_type</td>
<td class=$bgcolor([expr $price_list_ctr % 2])>$price_material</td>
<!-- <td class=$bgcolor([expr $price_list_ctr % 2])>$valid_from</td> -->
<!-- <td class=$bgcolor([expr $price_list_ctr % 2])>$valid_through</td> -->
<td class=$bgcolor([expr $price_list_ctr % 2])>$price $invoice_currency</td>
<td class=$bgcolor([expr {$price_list_ctr % 2}])>$price_company_name</td>
<td class=$bgcolor([expr {$price_list_ctr % 2}])>$price_uom</td>
<td class=$bgcolor([expr {$price_list_ctr % 2}])>$price_task_type</td>
<td class=$bgcolor([expr {$price_list_ctr % 2}])>$price_material</td>
<!-- <td class=$bgcolor([expr {$price_list_ctr % 2}])>$valid_from</td> -->
<!-- <td class=$bgcolor([expr {$price_list_ctr % 2}])>$valid_through</td> -->
<td class=$bgcolor([expr {$price_list_ctr % 2}])>$price $invoice_currency</td>
</tr>\n"
incr price_list_ctr
......@@ -541,7 +541,7 @@ order by
append reference_price_html "<tr><td colspan=$price_colspan>&nbsp;</td></tr>\n"
append task_sum_html "
<tr $bgcolor([expr $ctr % 2])>
<tr $bgcolor([expr {$ctr % 2}])>
<td>
<input type=text name=item_sort_order.$ctr size=2 value='$ctr'>
</td>
......
......@@ -51,7 +51,7 @@ ad_page_contract {
# Defaults & Security
# ---------------------------------------------------------------
set user_id [ad_maybe_redirect_for_registration]
set user_id [auth::require_login]
set current_user_id $user_id
if {![im_permission $user_id add_invoices]} {
......
<master>
<property name="title">@page_title@</property>
<property name="context">@context_bar@</property>
<property name="doc(title)">@page_title;literal@</property>
<property name="context">@context_bar;literal@</property>
<property name="main_navbar_label">finance</property>
<property name="sub_navbar">@costs_navbar_html;noquote@</property>
<property name="left_navbar">@left_navbar_html;noquote@</property>
<property name="sub_navbar">@costs_navbar_html;literal@</property>
<property name="left_navbar">@left_navbar_html;literal@</property>
<form method=POST action='new-2'>
<%= [export_vars -form {target_cost_type_id}] %>
<table class="table_list_page" width="100%" cellpadding=2 cellspacing=2 border=0>
<table class="table_list_page" width="100%" cellpadding="2" cellspacing="2" border="0">
@table_header_html;noquote@
@table_body_html;noquote@
@table_continuation_html;noquote@
......
......@@ -76,7 +76,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 current_user_id $user_id
set today [lindex [split [ns_localsqltimestamp] " "] 0]
set subproject_types [list "t" "[_ intranet-timesheet2-invoices.Yes]" "f" "[_ intranet-timesheet2-invoices.No]"]
......@@ -93,7 +93,7 @@ if {![im_permission $user_id add_invoices]} {
}
set allowed_cost_type [im_cost_type_write_permissions $current_user_id]
if {[lsearch -exact $allowed_cost_type $target_cost_type_id] == -1} {
if {$target_cost_type_id ni $allowed_cost_type} {
ad_return_complaint "Insufficient Privileges" "
<li>You can't create documents of type \#$target_cost_type_id."
ad_script_abort
......@@ -106,18 +106,18 @@ if {"" == $target_cost_type_id} {
set target_cost_type_id [im_cost_type_invoice]
}
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 "" 100]
}
set end_idx [expr $start_idx + $how_many - 1]
set end_idx [expr {$start_idx + $how_many - 1}]
# We don't need to show the select screen if only a single project
# has been selected...
if { ![empty_string_p $project_id] && $project_id != 0 } {
if { $project_id ne "" && $project_id != 0 } {
set invoice_currency $default_currency
ad_returnredirect "/intranet-timesheet2-invoices/invoices/new-2?select_project=$project_id&[export_vars -url {target_cost_type_id invoice_currency}]"
ad_returnredirect "/intranet-timesheet2-invoices/invoices/new-2?select_project=$project_id&[export_vars {target_cost_type_id invoice_currency}]"
set page_body ""
return
}
......@@ -156,20 +156,20 @@ db_foreach column_list_sql $column_sql {
# ---------------------------------------------------------------
set criteria [list]
if { ![empty_string_p $project_status_id] && $project_status_id > 0 } {
if { $project_status_id ne "" && $project_status_id > 0 } {
lappend criteria "p.project_status_id in ([join [im_sub_categories $project_status_id] ","])"
}
if { ![empty_string_p $project_type_id] && $project_type_id != 0 } {
if { $project_type_id ne "" && $project_type_id != 0 } {
# Select the specified project type and its subtypes
lappend criteria "p.project_type_id in ([join [im_sub_categories $project_type_id] ","])"
}
if { ![empty_string_p $filter_company_id] && $filter_company_id != 0 } {
if { $filter_company_id ne "" && $filter_company_id != 0 } {
lappend criteria "p.company_id = :filter_company_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 "upper(im_first_letter_default_to_a(p.project_name))=:letter"
}
if { $include_subprojects_p == "f" } {
......@@ -208,7 +208,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"
}
......@@ -264,7 +264,7 @@ where
# Limit the search results to N data sets only
# to be able to manage large sites
#
if {[string compare $letter "ALL"]} {
if {$letter ne "ALL" } {
# Set these limits to negative values to deactivate them
set total_in_limited -1
set how_many -1
......@@ -287,7 +287,7 @@ if {[string compare $letter "ALL"]} {
# ---------------------------------------------------------------
# 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 ""
......@@ -296,7 +296,7 @@ set table_header_html ""
#
set url "new?"
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&"
}
......@@ -305,7 +305,7 @@ set ctr 0
foreach col $column_headers {
set col_txt [lang::util::suggest_key $col]
set col_l10n [lang::message::lookup "" intranet-timesheet2-invoices.$col_txt $col]
if {0 == $ctr || [string compare $order_by $col] == 0 } {
if {0 == $ctr || $order_by eq $col } {
append table_header_html " <td class=rowtitle>$col_l10n</td>\n"
} else {
append table_header_html " <td class=rowtitle><a href=\"${url}order_by=[ns_urlencode $col]\">$col_l10n</a></td>\n"
......@@ -328,13 +328,13 @@ set old_company_name ""
db_foreach projects_info_query $selection {
# insert intermediate headers for every company if the list is sorted by company.
if {[string equal $order_by "Client"] && ![string equal $company_name $old_company_name] } {
if {$order_by eq "Client" && $company_name ne $old_company_name } {
append table_body_html "<tr><td colspan=$colspan>&nbsp;</td></tr>\n"
set old_company_name $company_name
}
# 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"
......@@ -351,7 +351,7 @@ db_foreach projects_info_query $selection {
}
# 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-timesheet2-invoices.lt_There_are_currently_n_1]
......@@ -362,7 +362,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 "new?start_idx=$next_start_idx&[export_ns_set_vars url [list start_idx]]"
} else {
set next_page_url ""
......@@ -372,7 +372,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 "new?start_idx=$previous_start_idx&[export_ns_set_vars url [list start_idx]]"
} else {
......@@ -387,7 +387,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=new?start_idx=$next_start_idx&[export_ns_set_vars url [list start_idx]]>[_ intranet-timesheet2-invoices.Next_Page]</a>"
} else {
set next_page ""
......@@ -398,7 +398,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=new?start_idx=$previous_start_idx&[export_ns_set_vars url [list start_idx]]>[_ intranet-timesheet2-invoices.Previous_Page]</a>"
} else {
......
<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="price"></formtemplate>
......@@ -29,7 +29,7 @@ set focus "price.var_name"
set page_title "[_ intranet-timesheet2-invoices.New_Price]"
set context [im_context_bar $page_title]
set user_id [ad_maybe_redirect_for_registration]
set user_id [auth::require_login]
# Check permissions. "See details" is an additional check for
# critical information
......
......@@ -21,10 +21,10 @@ ad_page_contract {
{return_url ""}
}
set user_id [ad_maybe_redirect_for_registration]
set user_id [auth::require_login]
set page_body "<PRE>\n"
if {$return_url == ""} {
if {$return_url eq ""} {
set return_url "/intranet/"
}
......@@ -32,7 +32,7 @@ if {$return_url == ""} {
# "Add New" button pressed?
# => Redirect to new.tcl page
if {"" != $add_new} {
ad_returnredirect "new?[export_vars -url {company_id return_url}]"
ad_returnredirect [export_vars -base new {company_id return_url}]
return
}
......
......@@ -3,8 +3,8 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<master src="../../../intranet-core/www/master">
<property name="title">@page_title@</property>
<property name="context">@context_bar@</property>
<property name="doc(title)">@page_title;literal@</property>
<property name="context">@context_bar;literal@</property>
<property name="main_navbar_label">finance</property>
@page_body;noquote@
\ No newline at end of file
......@@ -15,7 +15,7 @@ ad_page_contract {
upload_file
}
set current_user_id [ad_maybe_redirect_for_registration]
set current_user_id [auth::require_login]
set page_title "<#_ Upload New File/URL#>"
set page_body "<PRE>\n<A HREF=$return_url><#_ Return to Company Page#></A>\n"
set context_bar [im_context_bar [list "/intranet/cusomers/" "<#_ Clients#>"] "<#_ Upload CSV#>"]
......@@ -31,14 +31,14 @@ if { $max_n_bytes && ([file size $tmp_filename] > $max_n_bytes) } {
}
# strip off the C:\directories... crud and just get the file name
if ![regexp {([^//\\]+)$} $upload_file match company_filename] {
if {![regexp {([^//\\]+)$} $upload_file match company_filename]} {
# couldn't find a match
set company_filename $upload_file
}
if {[regexp {\.\.} $company_filename]} {
set error "<#_ Filename contains forbidden characters#>"
ad_returnredirect "/error.tcl?[export_vars -url {error}]"
ad_returnredirect [export_vars -base /error.tcl {error}]
}
if {![file readable $tmp_filename]} {
......@@ -72,8 +72,8 @@ for {set i 1} {$i < $csv_files_len} {incr i} {
append page_body "<#_ Line #%i%#>: $csv_line\n"
# Skip empty lines or line starting with "#"
if {[string equal "" [string trim $csv_line]]} { continue }
if {[string equal "#" [string range $csv_line 0 0]]} { continue }
if {"" eq [string trim $csv_line]} { continue }
if {"#" eq [string range $csv_line 0 0]} { continue }
# Preset values, defined by CSV sheet:
......@@ -109,23 +109,23 @@ for {set i 1} {$i < $csv_files_len} {incr i} {
set material_id ""
set errmsg ""
if {![string equal "" $uom]} {
if {$uom ne ""} {
set uom_id [db_string get_uom_id "select category_id from im_categories where category_type='Intranet UoM' and category=:uom" -default 0]
if {$uom_id == 0} { append errmsg "<li>Didn't find UoM '$uom'\n" }
}
if {![string equal "" $company]} {
if {$company ne ""} {
set price_company_id [db_string get_company_id "select company_id from im_companies where company_path = :company" -default 0]
if {$price_company_id == 0} { append errmsg "<li>Didn't find Company '$company'\n" }
if {$price_company_id != $company_id} { append errmsg "<li>Uploading prices for the wrong company ('$price_company_id' instead of '$company_id')" }
}
if {![string equal "" $task_type]} {
if {$task_type ne ""} {
set task_type_id [db_string get_uom_id "select category_id from im_categories where category_type='Intranet Project Type' and category=:task_type" -default 0]
if {$task_type_id == 0} { append errmsg "<li>Didn't find Task Type '$task_type'\n" }
}
if {![string equal "" $material]} {
if {$material ne ""} {
set material_id [db_string matid "select material_id from im_materials where lower(trim(material_name)) = lower(trim(:material))" -default ""]
if {"" == $material_id} {
set material_id [db_string matid "select material_id from im_materials where lower(trim(material_nr)) = lower(trim(:material))" -default ""]
......@@ -153,7 +153,7 @@ for {set i 1} {$i < $csv_files_len} {incr i} {
:valid_from, :valid_through, :currency, :price
)"
if {[string equal "" $errmsg]} {
if {$errmsg eq ""} {
if { [catch {
db_dml insert_price $insert_price_sql
} err_msg] } {
......
......@@ -3,8 +3,8 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<master src="../../../intranet-core/www/master">
<property name="title">@page_title@</property>
<property name="context">@context_bar@</property>
<property name="doc(title)">@page_title;literal@</property>
<property name="context">@context_bar;literal@</property>
<property name="main_navbar_label">finance</property>
@page_body;noquote@
\ No newline at end of file
......@@ -14,7 +14,7 @@ ad_page_contract {
company_id:integer
}
set user_id [ad_maybe_redirect_for_registration]
set user_id [auth::require_login]
set page_title "[_ intranet-timesheet2-invoices.lt_Upload_Client_Prices_]"
set context_bar [im_context_bar [list "/intranet/companies/" "[_ intranet-timesheet2-invoices.Clients]"] "[_ intranet-timesheet2-invoices.Upload_CSV]"]
......
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