1 namespace('kivi.CustomerVendor', function() {
3 this.selectShipto = function() {
4 var shiptoId = $('#shipto_shipto_id').val();
7 var url = 'controller.pl?action=CustomerVendor/ajaj_get_shipto&id='+ $('#cv_id').val() +'&db='+ $('#db').val() +'&shipto_id='+ shiptoId;
9 $.getJSON(url, function(data) {
11 $(document.getElementById('shipto_'+ key)).val(data[key]);
13 $('#action_delete_shipto').show();
17 $('#shipto :input').not(':button, :submit, :reset, :hidden').val('');
19 $('#action_delete_shipto').hide();
23 this.selectDelivery = function(fromDate, toDate) {
24 var deliveryId = $('#delivery_id').val();
27 $("#delivery").empty();
29 var url = 'controller.pl?action=CustomerVendor/get_delivery&id='+ $('#cv_id').val() +'&db='+ $('#db').val() +'&shipto_id='+ $('#delivery_id').val();
31 if( fromDate && toDate )
32 url += '&delivery_from='+ fromDate +'&delivery_to='+ toDate;
34 $('#delivery').load(url);
38 this.selectContact = function() {
39 var contactId = $('#contact_cp_id').val();
42 var url = 'controller.pl?action=CustomerVendor/ajaj_get_contact&id='+ $('#cv_id').val() +'&db='+ $('#db').val() +'&contact_id='+ contactId;
44 $.getJSON(url, function(data) {
45 var contact = data.contact;
46 for(var key in contact)
47 $(document.getElementById('contact_'+ key)).val(contact[key]);
49 var cvars = data.contact_cvars;
51 $(document.getElementById('contact_cvar_'+ key)).val(cvars[key]);
53 $('#action_delete_contact').show();
57 $('#contacts :input').not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected');
59 $('#action_delete_contact').hide();
62 $('#contact_cp_title_select, #contact_cp_abteilung_select').val('');
66 this.showMap = function(prefix) {
77 var searchString = "";
79 for(var i in searchStmts) {
80 var stmt = searchStmts[i];
81 if( stmt.charAt(0) == '#' ) {
82 var val = $('#'+ prefix + stmt.substring(1)).val();
90 var url = 'https://maps.google.com/maps?q='+ encodeURIComponent(searchString);
92 window.open(url, '_blank');
96 this.showHistoryWindow = function(id) {
97 var xPos = (screen.width - 800) / 2;
98 var yPos = (screen.height - 500) / 2;
99 var parm = "left="+ xPos +",top="+ yPos +",width=800,height=500,status=yes,scrollbars=yes";
100 var url = "common.pl?INPUT_ENCODING=UTF-8&action=show_history&longdescription=&input_name="+ encodeURIComponent(id);
101 window.open(url, "_new_generic", parm);