X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=js%2Fkivi.CustomerVendor.js;h=02a2c2eb9c607efdb9b04d0d3a66af5a5505c155;hb=bfa674c9d4edc551afa6e27aac6f684a7b8cb656;hp=a641adc80ea4ef770058be878b387b9474a8ae08;hpb=bff364a0741fe8f0198d3fd5ac6f00b1cdf0e62d;p=kivitendo-erp.git diff --git a/js/kivi.CustomerVendor.js b/js/kivi.CustomerVendor.js index a641adc80..02a2c2eb9 100644 --- a/js/kivi.CustomerVendor.js +++ b/js/kivi.CustomerVendor.js @@ -21,6 +21,25 @@ namespace('kivi.CustomerVendor', function(ns) { }); }; + this.selectAdditionalBillingAddress = function(params) { + var additionalBillingAddressId = $('#additional_billing_address_id').val(); + var url = 'controller.pl?action=CustomerVendor/ajaj_get_additional_billing_address&id='+ $('#cv_id').val() +'&db='+ $('#db').val() +'&additional_billing_address_id='+ additionalBillingAddressId; + + $.getJSON(url, function(data) { + var additional_billing_address = data.additional_billing_address; + for (var key in additional_billing_address) + $('#additional_billing_address_'+ key).val(additional_billing_address[key]) + + if ( additionalBillingAddressId ) + $('#action_delete_additional_billing_address').show(); + else + $('#action_delete_additional_billing_address').hide(); + + if ( params.onFormSet ) + params.onFormSet(); + }); + }; + this.selectDelivery = function(fromDate, toDate) { var deliveryId = $('#delivery_id').val(); @@ -58,7 +77,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 +86,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 = [ @@ -208,6 +233,7 @@ namespace('kivi.CustomerVendor', function(ns) { }; this.inline_report = function(target, source, data){ +// alert("HALLO S " + source + " --T " + target + " tt D " + data); $.ajax({ url: source, success: function (rsp) { @@ -271,7 +297,7 @@ namespace('kivi.CustomerVendor', function(ns) { 'filter.all:substr:multi::ilike': term, 'filter.obsolete': 0, current: this.$real.val(), - type: this.o.type, + type: this.o.cv_type, }; }, set_item: function(item) { @@ -395,6 +421,9 @@ namespace('kivi.CustomerVendor', function(ns) { }, select: function(event, ui) { self.set_item(ui.item); + if (self.o.action.commit_one) { + self.run_action(self.o.action.commit_one); + } }, search: function(event, ui) { if ((event.which == KEY.SHIFT) || (event.which == KEY.CTRL) || (event.which == KEY.ALT)) @@ -439,7 +468,7 @@ namespace('kivi.CustomerVendor', function(ns) { $(elt).data('customer_vendor_picker', new kivi.CustomerVendor.Picker($(elt))); }); - $('#cv_phone,#shipto_shiptophone,#contact_cp_phone1,#contact_cp_phone2,#contact_cp_mobile1,#contact_cp_mobile2').each(function(idx, elt) { + $('#cv_phone,#shipto_shiptophone,#additional_billing_address_phone,#contact_cp_phone1,#contact_cp_phone2,#contact_cp_mobile1,#contact_cp_mobile2').each(function(idx, elt) { kivi.CustomerVendor.init_dial_action($(elt)); }); } @@ -448,7 +477,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(); }); });