Commit 7bc47c38 authored by Frank Bergmann's avatar Frank Bergmann

- added a "Delete" button to invoices

- fixed the "return_url" chain for invoices
parent 5610c8e8
<?xml version="1.0"?>
<!DOCTYPE queryset PUBLIC "-//OpenACS//DTD XQL 1.0//EN" "/usr/share/emacs/DTDs/xql.dtd">
<!-- packages/intranet-invoices/www/view-postgresql.xql -->
<!-- @author Juanjo Ruiz (juanjoruizx@yahoo.es) -->
<!-- @creation-date 2004-10-08 -->
<!-- @arch-tag ffe2b337-c79b-4b45-bfcb-41a371866d36 -->
<!-- @cvs-id $Id$ -->
<queryset>
<rdbms>
<type>postgresql</type>
<version>7.2</version>
</rdbms>
<fullquery name = "delete_cost_item">
<querytext>
select ${otype}__delete(:cost_id);
</querytext>
</fullquery>
</queryset>
# /packages/intranet-invoices/www/delete.tcl
#
# Copyright (C) 2003-2004 Project/Open
#
# All rights reserved. Please check
# http://www.project-open.com/license/ for details.
ad_page_contract {
Purpose: Delete a single invoice
@param return_url the url to return to
@author frank.bergmann@project-open.com
} {
{ return_url "/intranet-invoices/list" }
invoice_id:integer
}
set cost_id $invoice_id
set user_id [ad_maybe_redirect_for_registration]
if {![im_permission $user_id add_invoices]} {
ad_return_complaint 1 "<li>You have insufficient privileges to see this page"
return
}
# Need to go through object type, because we may
# have to delete a "translation invoice", which
# requires different cleanup then "im_invoice".
#
set otype [db_string object_type "select object_type from acs_objects where object_id=:invoice_id"]
db_string delete_cost_item ""
ad_returnredirect $return_url
return
......@@ -30,22 +30,29 @@ ad_page_contract {
{ project_id:integer 0}
{ invoice_currency ""}
{ create_invoice_from_template ""}
{ return_url "/intranet-invoice/"}
{ return_url "/intranet-invoices/list"}
del_invoice:optional
}
# ---------------------------------------------------------------
# 2. Defaults & Security
# ---------------------------------------------------------------
set user_id [ad_maybe_redirect_for_registration]
# Check if we have to forward to "new-copy":
if {"" != $create_invoice_from_template} {
ad_returnredirect [export_vars -base "new-copy" {invoice_id cost_type_id}]
ad_script_abort
}
# Check if we need to delete the invoice.
# We get there because the "Delete" button in view.tcl can
# only send to one target, which is this file...
if {[info exists del_invoice]} {
ad_returnredirect [export_vars -base delete {invoice_id return_url}]
}
# User id already verified by filters
set user_id [ad_maybe_redirect_for_registration]
#ns_log notice "**************** $user_id permission [im_permission $user_id view_invoices]**********"
#if {![im_permission $user_id view_invoices]} {
......@@ -247,8 +254,7 @@ if {[string equal $invoice_mode "new"]} {
</td>
<td align=left>
<input type=text name=item_rate.$ctr size=7 value='$price_per_unit'>
<input type=hidden name=item_currency.$ctr value='$currency'>
$currency
[im_currency_select item_currency.$ctr $currency]
</td>
</tr>
<input type=hidden name=item_project_id.$ctr value='$project_id'>
......
......@@ -101,6 +101,7 @@
<form action=new method=POST>
<%= [export_form_vars return_id invoice_id cost_type_id] %>
<input type=submit name=edit_invoice value='#intranet-invoices.Edit#'>
<input type=submit name=del_invoice value='#intranet-core.Delete#'>
</form>
</if>
</td></tr>
......
......@@ -482,9 +482,16 @@ if {0 != $render_template_id} {
# format using a template
set invoice_template_path [ad_parameter -package_id [im_package_invoices_id] InvoiceTemplatePathUnix "" "/tmp/templates/"]
append invoice_template_path "/"
append invoice_template_path [db_string sel_invoice "select category from im_categories where category_id=:render_template_id"]
set invoice_template_body [db_string sel_invoice "select category from im_categories where category_id=:render_template_id" -default ""]
append invoice_template_path $invoice_template_body
if {![file isfile $invoice_template_path] || ![file readable $invoice_template_path]} {
if {"" == $invoice_template_body} {
ad_return_complaint "$cost_type Template not specified" "
<li>You haven't specified a template for your $cost_type."
return
}
if {![file isfile $invoice_template_path] || ![file readable $invoice_template_path]} {
ad_return_complaint "Unknown $cost_type Template" "
<li>$cost_type template '$invoice_template_path' doesn't exist or is not readable
for the web server. Please notify your system administrator."
......
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