Commit dd4563d6 authored by Frank Bergmann's avatar Frank Bergmann

- Added new cost type "Customer Purchase Order" to intranet-cost package

- In invoices/view.tcl showing the related customer purchase orders
- Allowing to promote a normal invoice to a timesheet invoice, so that
  the report period is shown
parent 9279cdcb
# /packages/intranet-timesheet2-invoices/www/invoices/promote-invoice-to-timesheet-invoice.tcl
#
# Copyright (c) 2003-2020 ]project-open[
#
# All rights reserved. Please check
# http://www.project-open.com/license/ for details.
ad_page_contract {
Takes a normal invoice and adds the meta-information to make it
a timesheet invoice (which contains service start- and end).
@author frank.bergmann@project-open.com
} {
invoice_id:integer
{ return_url "/intranet-invoices/" }
}
# ---------------------------------------------------------------
# Defaults & Security
# ---------------------------------------------------------------
set current_user_id [auth::require_login]
set outline_number_enabled_p [im_column_exists im_invoice_items item_outline_number]
im_invoice_permissions $current_user_id $invoice_id view read write admin
if {!$write} {
ad_return_complaint 1 "<li>[_ intranet-timesheet2-invoices.lt_You_dont_have_suffici]"
ad_script_abort
}
# ---------------------------------------------------------------
# Promote
# ---------------------------------------------------------------
set count [db_string count "select count(*) from im_timesheet_invoices where invoice_id = :invoice_id"]
if {$count < 1} {
db_dml insert "insert into im_timesheet_invoices (
invoice_id,
invoice_period_start,
invoice_period_end
) values (
:invoice_id,
now() - '1 month'::interval,
now()
)"
db_dml up "update acs_objects set object_type = 'im_timesheet_invoice' where object_id = :invoice_id"
}
# ---------------------------------------------------------------
# Where do you want to go now?
# ---------------------------------------------------------------
ad_returnredirect "/intranet-invoices/view?invoice_id=$invoice_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