From: Moritz Bunkus Date: Mon, 30 Jan 2017 11:57:51 +0000 (+0100) Subject: Kontoauszug verbuchen: JavaScript-Code in eigene js-Datei ausgelagert X-Git-Tag: release-3.5.4~1606 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=96c33451796e314aa0ec0e48fecdd76674c94796;p=kivitendo-erp.git Kontoauszug verbuchen: JavaScript-Code in eigene js-Datei ausgelagert --- diff --git a/SL/Controller/BankTransaction.pm b/SL/Controller/BankTransaction.pm index 98975e9d2..f413b736e 100644 --- a/SL/Controller/BankTransaction.pm +++ b/SL/Controller/BankTransaction.pm @@ -252,7 +252,7 @@ sub action_list { $bank_transactions = [ sort { $a->{agreement} <=> $b->{agreement} } @{ $bank_transactions } ] if $::form->{sort_by} eq 'proposal' and $::form->{sort_dir} == 1; $bank_transactions = [ sort { $b->{agreement} <=> $a->{agreement} } @{ $bank_transactions } ] if $::form->{sort_by} eq 'proposal' and $::form->{sort_dir} == 0; - + $::request->layout->add_javascripts("kivi.BankTransaction.js"); $self->render('bank_transactions/list', title => t8('Bank transactions MT940'), BANK_TRANSACTIONS => $bank_transactions, @@ -337,7 +337,7 @@ sub action_ajax_payment_suggestion { value_key => 'payment_type', title_key => 'display' ) if @select_options; - $html .= 'x'; + $html .= 'x'; $html = SL::Presenter->html_tag('div', $html, id => $::form->{bt_id} . '.' . $::form->{prop_id}); $self->render(\ SL::JSON::to_json( { 'html' => $html } ), { layout => 0, type => 'json', process => 0 }); diff --git a/js/kivi.BankTransaction.js b/js/kivi.BankTransaction.js new file mode 100644 index 000000000..730e07a4b --- /dev/null +++ b/js/kivi.BankTransaction.js @@ -0,0 +1,74 @@ +namespace('kivi.BankTransaction', function(ns) { + "use strict"; + + ns.assign_invoice = function(bank_transaction_id) { + kivi.popup_dialog({ + url: 'controller.pl?action=BankTransaction/assign_invoice', + data: '&bt_id=' + bank_transaction_id, + type: 'POST', + id: 'assign_invoice_window', + dialog: { title: kivi.t8('Assign invoice') } + }); + return true; + }; + + ns.add_invoices = function(bank_transaction_id, proposal_id) { + $('[name=' + proposal_id + ']').remove(); + + $.ajax({ + url: 'controller.pl?action=BankTransaction/ajax_payment_suggestion&bt_id=' + bank_transaction_id + '&prop_id=' + proposal_id, + success: function(data) { + $('#assigned_invoices_' + bank_transaction_id).append(data.html); + } + }); + }; + + ns.delete_invoice = function(bank_transaction_id, proposal_id) { + $( "#" + bank_transaction_id + "\\." + proposal_id ).remove(); + }; + + ns.create_invoice = function(bank_transaction_id) { + kivi.popup_dialog({ + url: 'controller.pl?action=BankTransaction/create_invoice', + data: '&bt_id=' + bank_transaction_id + "&filter.bank_account=" + $('#filter_bankaccount').val() + '&filter.fromdate=' + $('#filter_fromdate').val() + '&filter.todate=' + $('#filter_todate').val(), + type: 'POST', + id: 'create_invoice_window', + dialog: { title: kivi.t8('Create invoice') } + }); + return true; + }; + + + ns.filter_invoices = function() { + var url="controller.pl?action=BankTransaction/ajax_add_list&" + $("#assign_invoice_window form").serialize(); + $.ajax({ + url: url, + success: function(data) { + $("#record_list_filtered_list").html(data.html); + } + }); + } + + ns.add_selected_invoices = function() { + var bank_transaction_id = $("#assign_invoice_window_form").data("bank-transaction-id"); + var url ="controller.pl?action=BankTransaction/ajax_accept_invoices&bt_id=" + bank_transaction_id + '&' + $("#assign_invoice_window form").serialize(); + + $.ajax({ + url: url, + success: function(new_html) { + $('#assigned_invoices_' + bank_transaction_id).append(new_html); + $('#assign_invoice_window').dialog('close'); + } + }); + } + + ns.init_list = function(ui_tab) { + $('#check_all').checkall('INPUT[name^="proposal_ids"]'); + $('.sort_link').each(function() { + var _href = $(this).attr("href"); + $(this).attr("href", _href + "&filter.fromdate=" + $('#filter_fromdate').val() + "&filter.todate=" + $('#filter_todate').val()); + }); + + $.cookie('jquery_ui_tab_bt_tabs', ui_tab); + }; +}); diff --git a/templates/webpages/bank_transactions/assign_invoice.html b/templates/webpages/bank_transactions/assign_invoice.html index 967a1eaf1..d169c352c 100644 --- a/templates/webpages/bank_transactions/assign_invoice.html +++ b/templates/webpages/bank_transactions/assign_invoice.html @@ -2,7 +2,7 @@ [% SET debug = 0 %] -
+ [%- LxERP.t8("Bank transaction") %]: @@ -55,7 +55,7 @@

[% L.submit_tag('', LxERP.t8("Search")) %] - [% L.button_tag('add_selected_invoices()', LxERP.t8("Add invoices"), id='add_selected_record_links_button') %] + [% L.button_tag('kivi.BankTransaction.add_selected_invoices()', LxERP.t8("Add invoices"), id='add_selected_record_links_button') %] [% L.button_tag('$("#assign_invoice_window_form").resetForm()', LxERP.t8('Reset')) %] [% LxERP.t8("Cancel") %]

@@ -68,33 +68,6 @@ diff --git a/templates/webpages/bank_transactions/tabs/all.html b/templates/webpages/bank_transactions/tabs/all.html index 8b7efdfd6..04287be9a 100644 --- a/templates/webpages/bank_transactions/tabs/all.html +++ b/templates/webpages/bank_transactions/tabs/all.html @@ -83,8 +83,8 @@ [%- FOREACH bt = BANK_TRANSACTIONS %] - - + + [% IF debug %] @@ -92,7 +92,7 @@
[% 'Assign invoice' | $T8 %][% 'Create invoice' | $T8 %][% 'Assign invoice' | $T8 %][% 'Create invoice' | $T8 %] [% bt.agreement %] [% FOREACH prop = bt.proposals %] [% END %]