<%# Form for invoices, bills and receipts %> <% @url = case document.class.to_s when 'InvoiceBar::Invoice' action_name != 'edit' ? invoices_path : invoice_path(number: document.number) when 'InvoiceBar::Receipt' action_name != 'edit' ? receipts_path : receipt_path(number: document.number) when 'InvoiceBar::InvoiceTemplate' action_name != 'edit' ? invoice_templates_path : invoice_template_path(document) when 'InvoiceBar::ReceiptTemplate' action_name != 'edit' ? receipt_templates_path : receipt_template_path(document) end @method = (action_name == 'edit') ? :patch : :post -%> <%= nested_form_for(document, url: @url, method: @method) do |f| %> <%= render 'invoice_bar/forms/errors', model: document %> <% if document.instance_of? InvoiceBar::Invoice or document.instance_of? InvoiceBar::Receipt %> <% end %>
<% if document.instance_of? InvoiceBar::Invoice or document.instance_of? InvoiceBar::Receipt %>
<% if document.instance_of? InvoiceBar::Invoice %> <%= f.label :number, I18n.t('attributes.invoice.number') %> <% else %> <%= f.label :number, I18n.t('attributes.receipt.number') %> <% end %> <%= f.text_field :number, placeholder: I18n.t('attributes.invoice.number'), class: 'suggested' %>
<% end %> <% if document.instance_of? InvoiceBar::InvoiceTemplate or document.instance_of? InvoiceBar::ReceiptTemplate %>
<%= f.label :name, I18n.t('attributes.invoice_template.name') %> <%= f.text_field :name, placeholder: I18n.t('attributes.invoice_template.name'), class: 'suggested' %>
<% end %> <% if document.instance_of? InvoiceBar::Invoice or document.instance_of? InvoiceBar::Receipt %> <% if (@invoice_templates && @invoice_templates.size != 0) || (@receipt_templates && @receipt_templates.size != 0) %>
<% end %> <% end %> <% if document.instance_of? InvoiceBar::Invoice %>
<% end %> <% if document.instance_of? InvoiceBar::Receipt %>
<% end %>
<%# Common form fields %>

Pro firmu

<%= render 'invoice_bar/forms/contact_main_fields', f: f %>

Na adresu

<%# Document's address %> <% document.address = document.build_address unless document.address %> <%= f.fields_for :address do |f| render 'invoice_bar/forms/address_fields', f: f end -%>

Platba

<%= render 'invoice_bar/forms/payment_fields', f: f, document: document %>
<%= f.hidden_field :user_id %>
<%# Document's items %>
<%= f.fields_for :items do |f| render 'invoice_bar/forms/item_fields', f: f end -%>
<%# Links and buttons %>
<%= f.link_to_add I18n.t('links.new_item'), :items %>
<%= f.text_field :note, placeholder: I18n.t('attributes.invoice.note') %>
<%# Links and buttons %>
<%= f.submit I18n.t('buttons.save'), class: 'btn btn-primary' %>
<% end %>