kivitendo/js/kivi.PriceRule.js @ 6403dbcb
9589ecd7 | Sven Schöling | namespace('kivi.PriceRule', function(ns) {
|
||
7a3ee8d6 | Moritz Bunkus | "use strict";
|
||
9589ecd7 | Sven Schöling | |||
ns.add_new_row = function (type) {
|
||||
var data = {
|
||||
action: 'PriceRule/add_item_row',
|
||||
type: type
|
||||
};
|
||||
$.post('controller.pl', data, kivi.eval_json_result);
|
||||
7a3ee8d6 | Moritz Bunkus | };
|
||
9589ecd7 | Sven Schöling | |||
bc8c26f3 | Sven Schöling | ns.open_price_type_help_popup = function() {
|
||
kivi.popup_dialog({
|
||||
url: 'controller.pl?action=PriceRule/price_type_help',
|
||||
dialog: { title: kivi.t8('Price Types') },
|
||||
});
|
||||
7a3ee8d6 | Moritz Bunkus | };
|
||
bc8c26f3 | Sven Schöling | |||
c383fc0b | Sven Schöling | ns.on_change_filter_type = function() {
|
||
var val = $('#price_rule_filter_type').val();
|
||||
if (val == 'vendor') {
|
||||
$('#price_rule_filter_customer').data('customer_vendor_picker').set_item({});
|
||||
$('#price_rule_filter_customer_tr').hide();
|
||||
$('#price_rule_filter_vendor_tr').show();
|
||||
}
|
||||
if (val == 'customer') {
|
||||
$('#price_rule_filter_vendor').data('customer_vendor_picker').set_item({});
|
||||
$('#price_rule_filter_vendor_tr').hide();
|
||||
$('#price_rule_filter_customer_tr').show();
|
||||
}
|
||||
7a3ee8d6 | Moritz Bunkus | if (val === '') {
|
||
c383fc0b | Sven Schöling | $('#price_rule_filter_customer_tr').show();
|
||
$('#price_rule_filter_vendor_tr').show();
|
||||
}
|
||||
7a3ee8d6 | Moritz Bunkus | };
|
||
c383fc0b | Sven Schöling | |||
cb0ae4e4 | Sven Schöling | ns.inline_report = function(target, source, data){
|
||
$.ajax({
|
||||
url: source,
|
||||
success: function (rsp) {
|
||||
$(target).html(rsp);
|
||||
$(target).find('.paginate').find('a').click(function(event){ ns.redirect_event(event, target) });
|
||||
$(target).find('a.report-generator-header-link').click(function(event){ ns.redirect_event(event, target) });
|
||||
},
|
||||
data: data,
|
||||
});
|
||||
};
|
||||
ns.redirect_event = function(event, target){
|
||||
event.preventDefault();
|
||||
ns.inline_report(target, event.target + '', {});
|
||||
};
|
||||
ns.load_price_rules_for_part = function(id) {
|
||||
window.setTimeout(function(){
|
||||
ns.inline_report('#price_rules_customer_report', 'controller.pl', { action: 'PriceRule/list', 'filter.item_type_matches[].part': id, 'filter.type': 'customer', inline: 1 });
|
||||
ns.inline_report('#price_rules_vendor_report', 'controller.pl', { action: 'PriceRule/list', 'filter.item_type_matches[].part': id, 'filter.type': 'vendor', inline: 1 });
|
||||
}, 200);
|
||||
7a3ee8d6 | Moritz Bunkus | };
|
||
cb0ae4e4 | Sven Schöling | |||
9589ecd7 | Sven Schöling | $(function() {
|
||
$('#price_rule_item_add').click(function() {
|
||||
ns.add_new_row($('#price_rules_empty_item_select').val());
|
||||
});
|
||||
$('#price_rule_items').on('click', 'a.price_rule_remove_line', function(){
|
||||
24123093 | Sven Schöling | $(this).closest('.price_rule_item').remove();
|
||
9589ecd7 | Sven Schöling | })
|
||
bc8c26f3 | Sven Schöling | $('#price_rule_price_type_help').click(ns.open_price_type_help_popup);
|
||
c383fc0b | Sven Schöling | $('#price_rule_filter_type').change(ns.on_change_filter_type);
|
||
9589ecd7 | Sven Schöling | });
|
||
cb0ae4e4 | Sven Schöling | |||
9589ecd7 | Sven Schöling | });
|