X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/1bbcb32cff12865da20d6f2dabc85d7683dca31e..51072516787d639c5f8df4d487155b4a66b16d6f:/js/kivi.Inventory.js diff --git a/js/kivi.Inventory.js b/js/kivi.Inventory.js new file mode 100644 index 000000000..64e877fb0 --- /dev/null +++ b/js/kivi.Inventory.js @@ -0,0 +1,63 @@ +namespace('kivi.Inventory', function(ns) { + ns.reload_bin_selection = function() { + $.post("controller.pl", { action: 'Inventory/warehouse_changed', + warehouse_id: function(){ return $('#warehouse_id').val() } }, + kivi.eval_json_result); + }; + + ns.save_stocktaking = function(dont_check_already_counted) { + var data = $('#stocktaking_form').serializeArray(); + data.push({ name: 'action', value: 'Inventory/save_stocktaking' }); + data.push({ name: 'dont_check_already_counted', value: dont_check_already_counted }); + + $.post("controller.pl", data, kivi.eval_json_result); + }; + + ns.stocktaking_part_changed = function() { + var data = $('#stocktaking_form').serializeArray(); + data.push({ name: 'action', value: 'Inventory/stocktaking_part_changed' }); + $.post("controller.pl", data, kivi.eval_json_result); + $.post("controller.pl", { action: 'Inventory/mini_stock', + part_id: function(){ return $('#part_id').val() } }, + kivi.eval_json_result); + }; + + ns.reload_stocktaking_history = function(target, source) { + var data = $('#stocktaking_form').serializeArray(); + $.ajax({ + url: source, + data: data, + success: function (rsp) { + $(target).html(rsp); + $(target).find('a.paginate-link').click(function(event){ + event.preventDefault(); + kivi.Inventory.reload_stocktaking_history(target, event.target + '')}); + } + }); + }; + + ns.stocktaking_correct_counted = function() { + kivi.Inventory.close_already_counted_dialog(); + kivi.Inventory.save_stocktaking(1); + }; + + ns.stocktaking_add_counted = function(qty_to_add_to) { + resulting_qty = kivi.parse_amount($('#target_qty').val()) + 1.0*qty_to_add_to; + $('#target_qty').val(kivi.format_amount(resulting_qty, -2)); + kivi.Inventory.close_already_counted_dialog(); + kivi.Inventory.save_stocktaking(1); + }; + + ns.close_already_counted_dialog = function() { + $('#already_counted_dialog').dialog("close"); + }; + +}); + +$(function(){ + $('#part_id').change(kivi.Inventory.stocktaking_part_changed); + $('#warehouse_id').change(kivi.Inventory.reload_bin_selection); + $('#cutoff_date_as_date').change(function() {kivi.Inventory.reload_stocktaking_history('#stocktaking_history', 'controller.pl?action=Inventory/reload_stocktaking_history');}); + + kivi.Inventory.reload_stocktaking_history('#stocktaking_history', 'controller.pl?action=Inventory/reload_stocktaking_history'); +});