Commit cc4960cf authored by cosine's avatar cosine

- Finished prices with valid_from and valid_through

parent 1a87c2c0
...@@ -55,10 +55,11 @@ ad_proc im_timesheet_price_component { user_id company_id return_url} { ...@@ -55,10 +55,11 @@ ad_proc im_timesheet_price_component { user_id company_id return_url} {
set bgcolor(0) " class=roweven " set bgcolor(0) " class=roweven "
set bgcolor(1) " class=rowodd " set bgcolor(1) " class=rowodd "
# set price_format "000.00"
set price_format "%0.2f" set price_format "%0.2f"
set colspan 7 set colspan 7
set return_url [im_url_with_query]
set price_list_html " set price_list_html "
<form action=/intranet-timesheet2-invoices/price-lists/price-action method=POST> <form action=/intranet-timesheet2-invoices/price-lists/price-action method=POST>
[export_vars -form {company_id return_url}] [export_vars -form {company_id return_url}]
...@@ -107,7 +108,7 @@ ad_proc im_timesheet_price_component { user_id company_id return_url} { ...@@ -107,7 +108,7 @@ ad_proc im_timesheet_price_component { user_id company_id return_url} {
append price_rows_html "<tr><td colspan=$colspan>&nbsp;</td></tr>\n" append price_rows_html "<tr><td colspan=$colspan>&nbsp;</td></tr>\n"
} }
set url [export_vars -base "/intranet-timesheet2-invoices/price-lists/new" {price_id}] set url [export_vars -base "/intranet-timesheet2-invoices/price-lists/new" {price_id return_url}]
append price_rows_html " append price_rows_html "
<tr $bgcolor([expr {$ctr % 2}]) nobreak> <tr $bgcolor([expr {$ctr % 2}]) nobreak>
......
...@@ -39,7 +39,7 @@ if {![im_permission $user_id add_finance]} { ...@@ -39,7 +39,7 @@ if {![im_permission $user_id add_finance]} {
} }
# Get the company_id if the price_id exists # Get the company_id if the price_id exists
if {[info exists price_id]} { if {[info exists price_id] && ![info exists company_id]} {
db_1row price_info " db_1row price_info "
select company_id select company_id
from im_timesheet_prices from im_timesheet_prices
...@@ -87,8 +87,8 @@ ad_form \ ...@@ -87,8 +87,8 @@ ad_form \
{task_type_id:text(im_category_tree),optional {label "[_ intranet-timesheet2-invoices.Task_Type]"} {custom {category_type "Intranet Project Type" translate_p 1 include_empty_p 1}} } {task_type_id:text(im_category_tree),optional {label "[_ intranet-timesheet2-invoices.Task_Type]"} {custom {category_type "Intranet Project Type" translate_p 1 include_empty_p 1}} }
{material_id:text(select),optional {label "[_ intranet-timesheet2-invoices.Material]"} {options $material_options} } {material_id:text(select),optional {label "[_ intranet-timesheet2-invoices.Material]"} {options $material_options} }
{project_id:text(select),optional {label "[_ intranet-core.Project]"} {options $project_options} } {project_id:text(select),optional {label "[_ intranet-core.Project]"} {options $project_options} }
{valid_from:date(date),optional {label "[_ intranet-timesheet2.Start_Date]"} {after_html {<input type="button" style="height:23px; width:23px; background: url('/resources/acs-templating/calendar.gif');" onclick ="return showCalendarWithDateWidget('start_date', 'y-m-d');" >}} } {valid_from:date(date),optional {label "[_ intranet-timesheet2.Start_Date]"} {after_html {<input type="button" style="height:23px; width:23px; background: url('/resources/acs-templating/calendar.gif');" onclick ="return showCalendarWithDateWidget('valid_from', 'y-m-d');" >}} }
{valid_through:date(date),optional {label "[_ intranet-timesheet2.End_Date]"} {after_html {<input type="button" style="height:23px; width:23px; background: url('/resources/acs-templating/calendar.gif');" onclick ="return showCalendarWithDateWidget('end_date', 'y-m-d');" >}} } {valid_through:date(date),optional {label "[_ intranet-timesheet2.End_Date]"} {after_html {<input type="button" style="height:23px; width:23px; background: url('/resources/acs-templating/calendar.gif');" onclick ="return showCalendarWithDateWidget('valid_through', 'y-m-d');" >}} }
{price:text(text) {label "[_ intranet-timesheet2-invoices.Price]"} {html {size 10}}} {price:text(text) {label "[_ intranet-timesheet2-invoices.Price]"} {html {size 10}}}
{currency:text(select) {label "[_ intranet-timesheet2-invoices.Currency]"} {options $currency_options} } {currency:text(select) {label "[_ intranet-timesheet2-invoices.Currency]"} {options $currency_options} }
} }
...@@ -101,6 +101,10 @@ ad_form -extend -name price -on_request { ...@@ -101,6 +101,10 @@ ad_form -extend -name price -on_request {
from im_timesheet_prices p from im_timesheet_prices p
where p.price_id = :price_id where p.price_id = :price_id
} -new_data { } -new_data {
set valid_from_sql [template::util::date get_property sql_date $valid_from]
set valid_through_sql [template::util::date get_property sql_timestamp $valid_through]
db_dml price_insert " db_dml price_insert "
insert into im_timesheet_prices ( insert into im_timesheet_prices (
price_id, price_id,
...@@ -108,6 +112,9 @@ ad_form -extend -name price -on_request { ...@@ -108,6 +112,9 @@ ad_form -extend -name price -on_request {
company_id, company_id,
task_type_id, task_type_id,
material_id, material_id,
project_id,
valid_from,
valid_through,
currency, currency,
price price
) values ( ) values (
...@@ -116,19 +123,29 @@ ad_form -extend -name price -on_request { ...@@ -116,19 +123,29 @@ ad_form -extend -name price -on_request {
:company_id, :company_id,
:task_type_id, :task_type_id,
:material_id, :material_id,
:project_id,
$valid_from_sql,
$valid_through_sql,
:currency, :currency,
:price :price
) )
" "
} -edit_data { } -edit_data {
set valid_from_sql [template::util::date get_property sql_date $valid_from]
set valid_through_sql [template::util::date get_property sql_timestamp $valid_through]
db_dml price_update " db_dml price_update "
update im_prices set update im_timesheet_prices set
package_name = :package_name, uom_id = :uom_id,
label = :label, company_id = :company_id,
name = :name, task_type_id = :task_type_id,
url = :url, material_id = :material_id,
sort_order = :sort_order, project_id = :project_id,
parent_price_id = :parent_price_id valid_from = $valid_from_sql,
valid_through = $valid_through_sql,
currency = :currency,
price = :price
where where
price_id = :price_id price_id = :price_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