X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=js%2Fkivi.CustomerVendor.js;h=e8cd9236da45291a017b861efbc33b5def017fbe;hb=502a10d47975bb857364282ac2bfe7f995b21a86;hp=f809e3498fbbb441d90a73d690c63018e64dedda;hpb=564b5410a5b4913215b53e659be6ee2a9cf259be;p=kivitendo-erp.git diff --git a/js/kivi.CustomerVendor.js b/js/kivi.CustomerVendor.js index f809e3498..e8cd9236d 100644 --- a/js/kivi.CustomerVendor.js +++ b/js/kivi.CustomerVendor.js @@ -58,7 +58,7 @@ namespace('kivi.CustomerVendor', function(ns) { this.selectContact = function(params) { var contactId = $('#contact_cp_id').val(); - var url = 'controller.pl?action=CustomerVendor/ajaj_get_contact&id='+ $('#cv_id').val() +'&db='+ $('#db').val() +'&contact_id='+ contactId; + var url = 'controller.pl?action=CustomerVendor/ajaj_get_contact&id='+ $('#cv_id').val() +'&db='+ $('#db').val() +'&contact_id='+ contactId; $.getJSON(url, function(data) { var contact = data.contact; @@ -67,10 +67,14 @@ namespace('kivi.CustomerVendor', function(ns) { kivi.CustomerVendor.setCustomVariablesFromAJAJ(data.contact_cvars, 'contact_cvars_'); - if ( contactId ) + if ( contactId ) { $('#action_delete_contact').show(); - else + $('#contact_cp_title_select').val(contact['cp_title']); + $('#contact_cp_abteilung_select').val(contact['cp_abteilung']); + } else { $('#action_delete_contact').hide(); + $('#contact_cp_title_select, #contact_cp_abteilung_select').val(''); + } if (data.contact.disable_cp_main === 1) $("#contact_cp_main").prop("disabled", true); else @@ -79,7 +83,6 @@ namespace('kivi.CustomerVendor', function(ns) { params.onFormSet(); }); - $('#contact_cp_title_select, #contact_cp_abteilung_select').val(''); }; var mapSearchStmts = [ @@ -455,7 +458,39 @@ namespace('kivi.CustomerVendor', function(ns) { ns.reinit_widgets(); } + ns.get_price_report = function(target, source, data) { + $.ajax({ + url: source, + success: function (rsp) { + $(target).html(rsp); + $(target).find('a.report-generator-header-link').click(function(event){ ns.price_report_redirect_event(event, target) }); + }, + }); + }; + + ns.price_report_redirect_event = function (event, target) { + event.preventDefault(); + ns.get_price_report(target, event.target + ''); + }; + + ns.price_list_init = function () { + $("#customer_vendor_tabs").on('tabsbeforeactivate', function(event, ui){ + if (ui.newPanel.attr('id') == 'price_list') { + ns.get_price_report('#price_list', "controller.pl?action=CustomerVendor/ajax_list_prices&id=" + $('#cv_id').val() + "&db=" + $('#db').val() + "&callback=" + $('#callback').val()); + } + return 1; + }); + + $("#customer_vendor_tabs").on('tabscreate', function(event, ui){ + if (ui.panel.attr('id') == 'price_list') { + ns.get_price_report('#price_list', "controller.pl?action=CustomerVendor/ajax_list_prices&id=" + $('#cv_id').val() + "&db=" + $('#db').val() + "&callback=" + $('#callback').val()); + } + return 1; + }); + } + $(function(){ ns.init(); + ns.price_list_init(); }); });