From 236729be6c6b72c82f66eefd357058eda14b9d6a Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Fri, 31 Oct 2014 21:55:04 +0100 Subject: [PATCH] Check and show a delete button if an invoice file is present --- stoptime.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 7221dd7..858fae3 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -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