Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-timesheet2-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-timesheet2-invoices
Commits
201f7e51
Commit
201f7e51
authored
Feb 07, 2024
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added pricelist CSV export suitable to be imported again
parent
ee007de7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
1 deletion
+75
-1
intranet-timesheet2-invoices-procs.tcl
tcl/intranet-timesheet2-invoices-procs.tcl
+8
-1
pricelist.csv.tcl
www/price-lists/pricelist.csv.tcl
+67
-0
No files found.
tcl/intranet-timesheet2-invoices-procs.tcl
View file @
201f7e51
...
...
@@ -150,10 +150,17 @@ ad_proc im_timesheet_price_component { user_id company_id return_url} {
<li>
[
_ intranet-core.Note
]
:
[
lang::message::lookup
""
intranet-timesheet2-invoices.From_and_Through_overlap_bla
"
From and Through dates are time points at 0:00 midnight of their specific date,<br>
so sequential prices should have first.valid_through = second.valid_from."
]
which is equivlent to say that the from date is inclusive and the through date is exclusive.<br>
Sequential prices should have first.through = second.from,<br>
for example 2024-01-01 to 2025-01-01 and 2025-01-01 to 2026-01-01."
]
</ul>
<h4>
[
_ intranet-core.Admin
]
</h4>
<ul>
<li>
<a href='
[
export_vars -base
"/intranet-timesheet2-invoices/price-lists/pricelist.csv"
{
company_id return_url
}]
' target=_>
[
lang::message::lookup
""
intranet-timesheet2-invoices.Download_prices
"Download prices"
]
</a>
[
lang::message::lookup
""
intranet-timesheet2-invoices.for_this_company_via_CSV
"for this company via a CSV file."
]
<li>
<a href=/intranet-timesheet2-invoices/price-lists/
[
export_vars -base upload-prices
{
company_id return_url
}]
>
[
_ intranet-timesheet2-invoices.Upload_prices
]
</A>
...
...
www/price-lists/pricelist.csv.tcl
0 → 100644
View file @
201f7e51
# /packages/intranet-timesheet2-invoices/download-prices.tcl
#
# Copyright (C
)
2003 - 2009
]
project-open
[
#
# All rights reserved. Please check
# https://www.project-open.com/license/ for details.
ad_page_contract
{
Export the current priclist of a company in CSV format
suitable to be re-imported via upload.
Let's pray that neither company_path, material_nr nor project_nr
contain the
";"
(
or
","
, LibreOffice messes up CSV!
)
CSV separator.
@author frank.bergmann@project-open.com
}
{
return_url:notnull
company_id:integer
{
mime_type
"application/csv"
}
}
set
user_id
[
auth::require_login
]
set
company
[
db_string company_path
"select c.company_path from im_companies c where c.company_id = :company_id"
]
set
price_sql
"
select
tp.*,
im_category_from_id(tp.uom_id) as uom,
to_char(tp.valid_from, 'YYYY-MM-DD') as valid_from,
to_char(tp.valid_through, 'YYYY-MM-DD') as valid_through,
to_char(tp.valid_from, 'J') as valid_from_julian,
to_char(tp.valid_through, 'J') as valid_through_julian,
im_material_nr_from_id(tp.material_id) as material,
(select p.project_nr from im_projects p where p.project_id = tp.project_id) as project,
im_category_from_id(tp.task_type_id) as task_type
from
im_timesheet_prices tp
where
tp.company_id = :company_id
order by
tp.currency,
coalesce(tp.uom_id, 0),
coalesce(tp.project_id, 0),
coalesce(tp.material_id, 0),
coalesce(tp.valid_from, '2000-01-01'::date),
coalesce(tp.valid_through, '2100-01-01'::date),
coalesce(tp.task_type_id, 0),
tp.price_id
"
# List of columns, also used to calculate the value lines
set
var_list
{
uom company project material task_type price currency valid_from valid_through
}
# The header of the CSV
set
csv_header_line
[
list
]
foreach
var
$var
_list
{
lappend csv_header_line
$var
}
set
csv_lines
[
list
[
join
$csv
_header_line
";"
]
""
]
db_foreach prices
$price
_sql
{
set csv_line_vals
[
list
]
foreach var
$var
_list
{
lappend csv_line_vals
[
set
$var
]
}
lappend csv_lines
[
join
$csv
_line_vals
";"
]
}
set
csv
[
join
$csv
_lines
"
\n
"
]
doc_return 200
$mime
_type
$csv
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