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();
47 var url = 'controller.pl?action=CustomerVendor/ajaj_get_contact&id='+ $('#cv_id').val() +'&db='+ $('#db').val() +'&contact_id='+ contactId;
49 $.getJSON(url, function(data) {
50 var contact = data.contact;
51 for(var key in contact)
52 $(document.getElementById('contact_'+ key)).val(contact[key])
54 var cvars = data.contact_cvars;
56 $(document.getElementById('contact_cvars_'+ key)).val(cvars[key]);
59 $('#action_delete_contact').show();
61 $('#action_delete_contact').hide();
63 if ( params.onFormSet )
67 $('#contact_cp_title_select, #contact_cp_abteilung_select').val('');
70 var mapSearchStmts = [
80 this.MapWidget = function(prefix)
82 var $mapSearchElements = [];
85 var init = function() {
86 if( $mapSearchElements.length > 0 )
89 for(var i in mapSearchStmts) {
90 var stmt = mapSearchStmts[i];
91 if( stmt.charAt(0) == '#' ) {
92 var $elem = $('#'+ prefix + stmt.substring(1));
94 $mapSearchElements.push($elem);
99 var isNotEmpty = function() {
100 for(var i in $mapSearchElements)
101 if( ($mapSearchElements[i].attr('id') != prefix + 'country') && ($mapSearchElements[i].val() == '') )
106 var showMap = function() {
107 var searchString = "";
109 for(var i in mapSearchStmts) {
110 var stmt = mapSearchStmts[i];
111 if( stmt.charAt(0) == '#' ) {
112 var val = $('#'+ prefix + stmt.substring(1)).val();
117 searchString += stmt;
120 var url = 'https://maps.google.com/maps?q='+ encodeURIComponent(searchString);
122 window.open(url, '_blank');
126 var render = function(widgetWrapper) {
129 $widgetWrapper = $(widgetWrapper);
132 .html('<img src="image/map.png" alt="'+ kivi.t8("Map") +'" title="'+ kivi.t8("Map") +'" />')
136 for(var i in $mapSearchElements)
137 $mapSearchElements[i].keyup(function() {
143 var testInputs = function() {
147 $widgetWrapper.show();
149 $widgetWrapper.hide();
152 this.render = render;
153 this.testInputs = testInputs;
156 this.showHistoryWindow = function(id) {
157 var xPos = (screen.width - 800) / 2;
158 var yPos = (screen.height - 500) / 2;
159 var parm = "left="+ xPos +",top="+ yPos +",width=800,height=500,status=yes,scrollbars=yes";
160 var url = "common.pl?INPUT_ENCODING=UTF-8&action=show_history&longdescription=&input_name="+ encodeURIComponent(id);
161 window.open(url, "_new_generic", parm);