1 namespace('kivi.CustomerVendor', function(ns) {
3 this.selectShipto = function(params) {
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();
15 if( params.onFormSet )
20 $('#shipto :input').not(':button, :submit, :reset, :hidden').val('');
22 $('#action_delete_shipto').hide();
24 if( params.onFormSet )
29 this.selectDelivery = function(fromDate, toDate) {
30 var deliveryId = $('#delivery_id').val();
33 $("#delivery").empty();
35 var url = 'controller.pl?action=CustomerVendor/get_delivery&id='+ $('#cv_id').val() +'&db='+ $('#db').val() +'&shipto_id='+ $('#delivery_id').val();
37 if( fromDate && toDate )
38 url += '&delivery_from='+ fromDate +'&delivery_to='+ toDate;
40 $('#delivery').load(url);
44 this.selectContact = function(params) {
45 var contactId = $('#contact_cp_id').val();
48 var url = 'controller.pl?action=CustomerVendor/ajaj_get_contact&id='+ $('#cv_id').val() +'&db='+ $('#db').val() +'&contact_id='+ contactId;
50 $.getJSON(url, function(data) {
51 var contact = data.contact;
52 for(var key in contact)
53 $(document.getElementById('contact_'+ key)).val(contact[key])
55 var cvars = data.contact_cvars;
57 $(document.getElementById('contact_cvar_'+ key)).val(cvars[key]);
59 $('#action_delete_contact').show();
61 if( params.onFormSet )
66 $('#contacts :input').not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected');
68 $('#action_delete_contact').hide();
70 if( params.onFormSet )
74 $('#contact_cp_title_select, #contact_cp_abteilung_select').val('');
77 var mapSearchStmts = [
87 this.MapWidget = function(prefix)
89 var $mapSearchElements = [];
92 var init = function() {
93 if( $mapSearchElements.length > 0 )
96 for(var i in mapSearchStmts) {
97 var stmt = mapSearchStmts[i];
98 if( stmt.charAt(0) == '#' ) {
99 var $elem = $('#'+ prefix + stmt.substring(1));
101 $mapSearchElements.push($elem);
106 var isNotEmpty = function() {
107 for(var i in $mapSearchElements)
108 if( $mapSearchElements[i].val() == '' )
113 var showMap = function() {
114 var searchString = "";
116 for(var i in mapSearchStmts) {
117 var stmt = mapSearchStmts[i];
118 if( stmt.charAt(0) == '#' ) {
119 var val = $('#'+ prefix + stmt.substring(1)).val();
124 searchString += stmt;
127 var url = 'https://maps.google.com/maps?q='+ encodeURIComponent(searchString);
129 window.open(url, '_blank');
133 var render = function(widgetWrapper) {
136 $widgetWrapper = $(widgetWrapper);
139 .html('<img src="image/map.png" alt="'+ kivi.t8("Map") +'" title="'+ kivi.t8("Map") +'" />')
143 for(var i in $mapSearchElements)
144 $mapSearchElements[i].keyup(function() {
150 var testInputs = function() {
154 $widgetWrapper.show();
156 $widgetWrapper.hide();
159 this.render = render;
160 this.testInputs = testInputs;
163 this.showHistoryWindow = function(id) {
164 var xPos = (screen.width - 800) / 2;
165 var yPos = (screen.height - 500) / 2;
166 var parm = "left="+ xPos +",top="+ yPos +",width=800,height=500,status=yes,scrollbars=yes";
167 var url = "common.pl?INPUT_ENCODING=UTF-8&action=show_history&longdescription=&input_name="+ encodeURIComponent(id);
168 window.open(url, "_new_generic", parm);