X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=js%2Fkivi.CustomerVendor.js;h=e8cd9236da45291a017b861efbc33b5def017fbe;hb=502a10d47975bb857364282ac2bfe7f995b21a86;hp=d489d07d327d5772794958dbb7f8753206d41715;hpb=9508e215c78bc172721e14d41d21858abb23672e;p=kivitendo-erp.git diff --git a/js/kivi.CustomerVendor.js b/js/kivi.CustomerVendor.js index d489d07d3..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,16 +67,22 @@ 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 + $("#contact_cp_main").prop("disabled", false); if ( params.onFormSet ) params.onFormSet(); }); - $('#contact_cp_title_select, #contact_cp_abteilung_select').val(''); }; var mapSearchStmts = [ @@ -452,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(); }); });