Revision 759e7200
Von Bernd Bleßmann vor mehr als 6 Jahren hinzugefügt
js/kivi.Order.js | ||
---|---|---|
381 | 381 |
$.post("controller.pl", data, kivi.eval_json_result); |
382 | 382 |
}; |
383 | 383 |
|
384 |
ns.setup_multi_items_dialog = function() { |
|
385 |
$('#multi_items_filter_table input, #multi_items_filter_table select').keydown(function(event) { |
|
386 |
if (event.keyCode == 13) { |
|
387 |
event.preventDefault(); |
|
388 |
ns.multi_items_dialog_update_result(); |
|
389 |
return false; |
|
390 |
} |
|
391 |
}); |
|
392 |
|
|
393 |
$('#multi_items_filter_all_substr_multi_ilike').focus(); |
|
394 |
}; |
|
395 |
|
|
384 | 396 |
ns.show_multi_items_dialog = function() { |
385 | 397 |
if (!ns.check_cv()) return; |
386 | 398 |
|
387 | 399 |
$('#row_table_id thead a img').remove(); |
388 | 400 |
|
389 | 401 |
kivi.popup_dialog({ |
390 |
url: 'controller.pl?action=Order/show_multi_items_dialog', |
|
391 |
data: { type: $('#type').val(), |
|
392 |
callback: 'Order/add_multi_items', |
|
393 |
callback_data_id: 'order_form' }, |
|
394 |
id: 'jq_multi_items_dialog', |
|
402 |
url: 'controller.pl?action=Order/show_multi_items_dialog', |
|
403 |
data: { type: $('#type').val() }, |
|
404 |
id: 'jq_multi_items_dialog', |
|
405 |
load: kivi.Order.setup_multi_items_dialog, |
|
395 | 406 |
dialog: { |
396 | 407 |
title: kivi.t8('Add multiple items'), |
397 | 408 |
width: 800, |
... | ... | |
405 | 416 |
$('#jq_multi_items_dialog').dialog('close'); |
406 | 417 |
}; |
407 | 418 |
|
419 |
ns.multi_items_dialog_update_result = function() { |
|
420 |
var data = $('#multi_items_form').serializeArray(); |
|
421 |
data.push({ name: 'type', value: $('#type').val() }); |
|
422 |
$.ajax({ |
|
423 |
url: 'controller.pl?action=Order/multi_items_update_result', |
|
424 |
data: data, |
|
425 |
method: 'post', |
|
426 |
success: function(data) { |
|
427 |
$('#multi_items_result').html(data); |
|
428 |
ns.multi_items_dialog_enable_continue(); |
|
429 |
ns.multi_items_result_setup_events(); |
|
430 |
} |
|
431 |
}); |
|
432 |
}; |
|
433 |
|
|
434 |
ns.multi_items_dialog_disable_continue = function() { |
|
435 |
// disable keydown-event and continue button to prevent |
|
436 |
// impatient users to add parts multiple times |
|
437 |
$('#multi_items_result input').off("keydown"); |
|
438 |
$('#multi_items_dialog_continue_button').prop('disabled', true); |
|
439 |
}; |
|
440 |
|
|
441 |
ns.multi_items_dialog_enable_continue = function() { |
|
442 |
$('#multi_items_result input').keydown(function(event) { |
|
443 |
if(event.keyCode == 13) { |
|
444 |
event.preventDefault(); |
|
445 |
ns.add_multi_items(); |
|
446 |
return false; |
|
447 |
} |
|
448 |
}); |
|
449 |
$('#multi_items_dialog_continue_button').prop('disabled', false); |
|
450 |
}; |
|
451 |
|
|
452 |
ns.multi_items_result_setup_events = function() { |
|
453 |
$('#multi_items_all_qty').change(ns.reformat_number); |
|
454 |
$('#multi_items_all_qty').change(function(event) { |
|
455 |
$('.multi_items_qty').val($(event.target).val()); |
|
456 |
}); |
|
457 |
$('.multi_items_qty').change(ns.reformat_number); |
|
458 |
} |
|
459 |
|
|
460 |
ns.add_multi_items = function() { |
|
461 |
// rows at all |
|
462 |
var n_rows = $('.multi_items_qty').length; |
|
463 |
if (n_rows == 0) return; |
|
464 |
|
|
465 |
// filled rows |
|
466 |
n_rows = $('.multi_items_qty').filter(function() { |
|
467 |
return $(this).val().length > 0; |
|
468 |
}).length; |
|
469 |
if (n_rows == 0) return; |
|
470 |
|
|
471 |
ns.multi_items_dialog_disable_continue(); |
|
472 |
|
|
473 |
var data = $('#order_form').serializeArray(); |
|
474 |
data = data.concat($('#multi_items_form').serializeArray()); |
|
475 |
data.push({ name: 'action', value: 'Order/add_multi_items' }); |
|
476 |
$.post("controller.pl", data, kivi.eval_json_result); |
|
477 |
}; |
|
478 |
|
|
479 |
ns.set_input_to_one = function(clicked) { |
|
480 |
if ($(clicked).val() == '') { |
|
481 |
$(clicked).val(kivi.format_amount(1.00, -2)); |
|
482 |
} |
|
483 |
$(clicked).select(); |
|
484 |
}; |
|
485 |
|
|
408 | 486 |
ns.delete_order_item_row = function(clicked) { |
409 | 487 |
var row = $(clicked).parents("tbody").first(); |
410 | 488 |
$(row).remove(); |
Auch abrufbar als: Unified diff
Auftrags-Controller: multi items dialog: JavaScript aus html-Template raus