2013-02-11 03:57:33 +01:00
|
|
|
- title t('.title')
|
2011-06-09 21:35:05 +02:00
|
|
|
|
2012-11-10 16:44:05 +01:00
|
|
|
- content_for :javascript do
|
2011-06-09 21:35:05 +02:00
|
|
|
:javascript
|
2016-03-06 11:53:31 +01:00
|
|
|
var ordergroup = $($.parseHTML("#{escape_javascript(render('ordergroup'))}"));
|
2019-11-11 12:18:00 +01:00
|
|
|
var ordergroups = #{raw @ordergroups.to_json};
|
2011-06-09 21:35:05 +02:00
|
|
|
|
|
|
|
$(function() {
|
2014-01-25 15:19:50 +01:00
|
|
|
$(document).on('touchclick', 'a[data-remove-transaction]', function() {
|
2011-06-09 21:35:05 +02:00
|
|
|
$(this).parents('tr').remove();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2014-01-25 15:19:50 +01:00
|
|
|
$(document).on('touchclick', 'a[data-add-transaction]', function() {
|
2016-03-06 11:53:31 +01:00
|
|
|
ordergroup.clone().appendTo('#ordergroups');
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('touchclick', 'a[data-add-all-ordergroups]', function() {
|
2019-11-11 12:18:00 +01:00
|
|
|
var customField = $(this).data('custom-field');
|
|
|
|
var value;
|
|
|
|
if (!customField) {
|
|
|
|
value = prompt("#{escape_javascript(heading_helper(FinancialTransaction, :amount))}:");
|
|
|
|
if (value === null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2016-03-06 11:53:31 +01:00
|
|
|
$('#ordergroups > tbody > tr').remove();
|
2019-11-11 12:18:00 +01:00
|
|
|
for (var id in ordergroups) {
|
|
|
|
if (!ordergroups.hasOwnProperty(id)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (customField) {
|
|
|
|
value = ordergroups[id][customField];
|
|
|
|
}
|
2016-03-06 11:53:31 +01:00
|
|
|
var row = ordergroup.clone();
|
|
|
|
row.find('td > input').val(value);
|
2019-11-11 12:18:00 +01:00
|
|
|
row.find('td > select').val(id);
|
2016-03-06 11:53:31 +01:00
|
|
|
row.appendTo('#ordergroups');
|
2019-11-11 12:18:00 +01:00
|
|
|
}
|
2011-06-09 21:35:05 +02:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2012-11-10 16:44:05 +01:00
|
|
|
- content_for :sidebar do
|
2013-02-11 03:57:33 +01:00
|
|
|
.well.well-small= t('.sidebar')
|
2012-11-10 16:44:05 +01:00
|
|
|
|
|
|
|
= form_tag finance_create_transaction_collection_path do
|
2017-03-04 14:15:18 +01:00
|
|
|
- if FinancialTransactionType.has_multiple_types
|
|
|
|
%p
|
|
|
|
%b= heading_helper FinancialTransaction, :financial_transaction_type
|
2018-12-10 15:32:56 +01:00
|
|
|
= select_tag :type_id, options_for_select(FinancialTransactionType.order(:name).map { |t| [ t.name, t.id ] }, params[:type_id])
|
2011-06-09 21:35:05 +02:00
|
|
|
%p
|
2013-11-23 12:05:29 +01:00
|
|
|
%b= heading_helper FinancialTransaction, :note
|
2012-11-10 16:44:05 +01:00
|
|
|
= text_field_tag :note, params[:note], class: 'input-xlarge', required: 'required'
|
2018-12-30 03:43:48 +01:00
|
|
|
%p
|
|
|
|
%label
|
|
|
|
= check_box_tag :set_balance, true, params[:set_balance]
|
|
|
|
= t('.set_balance')
|
2011-06-09 21:35:05 +02:00
|
|
|
%p
|
|
|
|
%table#ordergroups{:style => "width:20em"}
|
2016-03-06 11:53:31 +01:00
|
|
|
%thead
|
|
|
|
%tr
|
|
|
|
%th= heading_helper FinancialTransaction, :ordergroup
|
|
|
|
%th= heading_helper FinancialTransaction, :amount
|
|
|
|
%tbody
|
|
|
|
= render :partial => 'ordergroup', :collection => [1, 2, 3]
|
2011-06-09 21:35:05 +02:00
|
|
|
%p
|
2013-02-11 03:57:33 +01:00
|
|
|
= link_to t('.new_ordergroup'), '#', 'data-add-transaction' => true, class: 'btn'
|
2016-03-06 11:53:31 +01:00
|
|
|
= link_to t('.add_all_ordergroups'), '#', 'data-add-all-ordergroups' => true, class: 'btn'
|
2019-11-01 17:29:07 +01:00
|
|
|
- if FinancialTransaction.where(ordergroup: nil).any?
|
|
|
|
%p
|
|
|
|
%label
|
|
|
|
= check_box_tag :create_foodcoop_transaction, true, params[:create_foodcoop_transaction]
|
|
|
|
= t('.create_foodcoop_transaction')
|
2019-10-30 22:27:18 +01:00
|
|
|
- if BankAccount.any?
|
|
|
|
%p
|
|
|
|
%label
|
|
|
|
= check_box_tag :create_financial_link, true, params[:create_financial_link]
|
|
|
|
= t('.create_financial_link')
|
2019-11-11 12:18:00 +01:00
|
|
|
%p
|
|
|
|
- Ordergroup.custom_fields.each do |f|
|
|
|
|
- if f[:financial_transaction_source]
|
|
|
|
= link_to t('.add_all_ordergroups_custom_field', label: f[:label]), '#', 'data-custom-field' => f[:name], 'data-add-all-ordergroups' => true, class: 'btn'
|
2012-11-10 16:44:05 +01:00
|
|
|
.form-actions
|
2013-02-11 03:57:33 +01:00
|
|
|
= submit_tag t('.save'), class: 'btn btn-primary'
|
2013-04-04 02:49:52 +02:00
|
|
|
= link_to t('ui.or_cancel'), finance_ordergroups_path
|