Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-invoices
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-invoices
Commits
909f72d2
Commit
909f72d2
authored
May 15, 2023
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cosine 5630: Added CSV export option, together with commit in intranet-core
parent
68deab25
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
1 deletion
+53
-1
list.tcl
www/list.tcl
+53
-1
No files found.
www/list.tcl
View file @
909f72d2
...
...
@@ -29,8 +29,11 @@ ad_page_contract {
{
how_many
""
}
{
view_name
"invoice_list"
}
{
letter:trim
""
}
{
format
"html"
}
}
# ---------------------------------------------------------------
# Invoice List Page
#
...
...
@@ -479,6 +482,12 @@ set filter_html "
<input type='textfield' name='end_date' id='end_date' value='
$end
_date' size='10'><input id=end_date_calendar style=
\"
height:20px; width:20px; background: url('/resources/acs-templating/calendar.gif');
\"
type=
\"
button
\"
>
</td>
</tr>
<tr>
<td class=form-label>
[
lang::message::lookup
""
intranet-reporting.Format
"Format"
]
</td>
<td class=form-widget>
[
im_report_output_format_select format
""
$format
]
</td>
</tr>
<tr>
<td></td>
<td><input type=submit value='
[
_ intranet-invoices.Go
]
' name=submit></td>
...
...
@@ -494,6 +503,7 @@ set filter_html "
set
colspan
[
expr
{[
llength
$column
_headers
]
+ 1
}]
set
table_header_html
""
set
table_header_csv
""
# Format the header names with links that modify the
# sort order of the SQL query.
...
...
@@ -510,11 +520,15 @@ foreach col $column_headers {
regsub -all
"#"
$col
_key
"hash_simbol"
col_key
set col_loc
[
lang::message::lookup
""
intranet-invoices.$col_key
$col
]
if
{
$order
_by eq
$col
||
[
regexp
{
input
}
$col
match
]}
{
if
{
$order
_by eq
$col
||
[
regexp
{
input
}
$col
match
]}
{
append table_header_html
" <td class=rowtitle>
$col
_loc</td>
\n
"
}
else
{
append table_header_html
" <td class=rowtitle><a href=
\"
${url}
order_by=
[
ns_urlencode
$col
]
\"
>
$col
_loc</a></td>
\n
"
}
# Output for CSV format
set csv_cell_cleaned
[
im_cvs_output_findoc_clean_cell -value
$col
_loc
]
append table_header_csv
"
$csv
_cell_cleaned
\t
"
}
# Add input field
...
...
@@ -594,8 +608,17 @@ db_foreach invoices_info_query $selection {
set cmd
"append table_body_html
$column
_var"
eval
$cmd
append table_body_html
"</td>
\n
"
# For CSV export
set cmd
"set csv_cell
$column
_var"
eval
$cmd
set csv_cell_cleaned
[
im_cvs_output_findoc_clean_cell -value
$csv
_cell
]
ns_log Notice
"list.tcl: cleaned=
$csv
_cell_cleaned, org=
$csv
_cell"
append table_body_csv
"
$csv
_cell_cleaned
\t
"
}
append table_body_html
"</tr>
\n
"
append table_body_csv
"
\n
"
# ----
...
...
@@ -666,6 +689,11 @@ set button_html "
</td>
</tr>"
# ---------------------------------------------------------------
# Navbars
# ---------------------------------------------------------------
set
sub_navbar
[
im_costs_navbar
"no_alpha"
"/intranet-invoices/list"
$next
_page_url
$previous
_page_url
[
list
invoice_status_id cost_type_id company_id start_idx order_by how_many view_name start_date end_date
]
$parent
_menu_label
]
set
left_navbar_html
"
...
...
@@ -691,3 +719,27 @@ if { "" != $new_document_menu } {
}
# ---------------------------------------------------------------
# Handle CSV export
# ---------------------------------------------------------------
switch
$format
{
"csv"
{
# Determine filename to write out
set report_name
"
${cost_type}
_list"
set report_key
[
string
tolower
$report
_name
]
regsub -all
{[
^a-zA-z0-9_
]}
$report
_key
"_"
report_key
regsub -all
{
_+
}
$report
_key
"_"
report_key
# Return the report contents
set outputheaders
[
ns_conn outputheaders
]
ns_set cput
$outputheaders
"Content-Disposition"
"attachment; filename=
${report_key}
.csv"
doc_return 200
"application/csv"
"
$table
_header_csv
\n
$table
_body_csv"
ad_script_abort
}
default
{
# just continue with the page to format output using template
}
}
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