Check and show a delete button if an invoice file is present

This commit is contained in:
Paul van Tilburg 2014-10-31 21:55:04 +01:00
parent f831580c3d
commit 236729be6c
1 changed files with 12 additions and 2 deletions

View File

@ -1161,15 +1161,16 @@ module StopTime::Controllers
@vat = @invoice.vat_summary
@period = @invoice.period
tex_file = PUBLIC_DIR + "invoices/#{@number}.tex"
pdf_file = PUBLIC_DIR + "invoices/#{@number}.pdf"
if @format == "html"
@input = @invoice.attributes
@invoice_file_present = tex_file.exist?
render :invoice_form
elsif @format == "tex"
tex_file = PUBLIC_DIR + "invoices/#{@number}.tex"
_generate_invoice_tex(@number) unless tex_file.exist?
redirect R(Static, "") + "invoices/#{tex_file.basename}"
elsif @format == "pdf"
pdf_file = PUBLIC_DIR + "invoices/#{@number}.pdf"
_generate_invoice_pdf(@number) unless pdf_file.exist?
redirect R(Static, "") + "invoices/#{pdf_file.basename}"
end
@ -2209,6 +2210,15 @@ module StopTime::Views
a.btn "» View company info",
:href => R(Company, :revision => @company.revision)
end
div.alert.alert_danger do
form.form_inline :action => R(CustomersNInvoicesX,
@customer.id, @invoice.number),
:method => :delete do
button.btn.btn_danger "» Remove old", :type => "submit"
text! "An invoice has already been generated!"
end
end if @invoice_file_present
end
end
end