X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=js%2Fkivi.CustomerVendor.js;h=59c07354edf70ab6df6d9f6823df01bf57b5ecc7;hb=99bbf349b825fc48cdb71288e0979ab687770227;hp=928c6736c1896ec3277bf25439ec149835f8441c;hpb=90e9523a36cf7a739995f55594e33e98c725e510;p=kivitendo-erp.git
diff --git a/js/kivi.CustomerVendor.js b/js/kivi.CustomerVendor.js
index 928c6736c..59c07354e 100644
--- a/js/kivi.CustomerVendor.js
+++ b/js/kivi.CustomerVendor.js
@@ -44,32 +44,25 @@ namespace('kivi.CustomerVendor', function(ns) {
this.selectContact = function(params) {
var contactId = $('#contact_cp_id').val();
- if( contactId ) {
- 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;
- for(var key in contact)
- $(document.getElementById('contact_'+ key)).val(contact[key])
+ $.getJSON(url, function(data) {
+ var contact = data.contact;
+ for(var key in contact)
+ $(document.getElementById('contact_'+ key)).val(contact[key])
- var cvars = data.contact_cvars;
- for(var key in cvars)
- $(document.getElementById('contact_cvar_'+ key)).val(cvars[key]);
+ var cvars = data.contact_cvars;
+ for(var key in cvars)
+ $(document.getElementById('contact_cvars_'+ key)).val(cvars[key]);
+ if ( contactId )
$('#action_delete_contact').show();
+ else
+ $('#action_delete_contact').hide();
- if( params.onFormSet )
- params.onFormSet();
- });
- }
- else {
- $('#contacts :input').not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected');
-
- $('#action_delete_contact').hide();
-
- if( params.onFormSet )
+ if ( params.onFormSet )
params.onFormSet();
- }
+ });
$('#contact_cp_title_select, #contact_cp_abteilung_select').val('');
};
@@ -84,78 +77,80 @@ namespace('kivi.CustomerVendor', function(ns) {
'#country'
];
- this.showMapWidget = function(prefix, widgetWrapper) {
- var result = {
- };
-
- $(function(){
+ this.MapWidget = function(prefix)
+ {
+ var $mapSearchElements = [];
+ var $widgetWrapper;
- widgetWrapper = $(widgetWrapper);
+ var init = function() {
+ if( $mapSearchElements.length > 0 )
+ return;
- var mapSearchElements = [];
for(var i in mapSearchStmts) {
var stmt = mapSearchStmts[i];
if( stmt.charAt(0) == '#' ) {
- var elem = $('#'+ prefix + stmt.substring(1));
- if( elem )
- mapSearchElements.push(elem);
+ var $elem = $('#'+ prefix + stmt.substring(1));
+ if( $elem )
+ $mapSearchElements.push($elem);
}
}
+ };
- var isNotEmpty = function() {
- for(var i in mapSearchElements)
- if( mapSearchElements[i].val() == '' )
- return false;
- return true;
- };
+ var isNotEmpty = function() {
+ for(var i in $mapSearchElements)
+ if( ($mapSearchElements[i].attr('id') != prefix + 'country') && ($mapSearchElements[i].val() == '') )
+ return false;
+ return true;
+ };
- widgetWrapper
- .html('
')
- .click(function(){
- ns.showMap(prefix);
- });
+ var showMap = function() {
+ var searchString = "";
- var testInputs = function() {
- if( isNotEmpty() )
- widgetWrapper.show();
+ for(var i in mapSearchStmts) {
+ var stmt = mapSearchStmts[i];
+ if( stmt.charAt(0) == '#' ) {
+ var val = $('#'+ prefix + stmt.substring(1)).val();
+ if( val )
+ searchString += val;
+ }
else
- widgetWrapper.hide();
- };
+ searchString += stmt;
+ }
- result.testInputs = testInputs;
+ var url = 'https://maps.google.com/maps?q='+ encodeURIComponent(searchString);
- $(mapSearchElements)
- .map(function() {
- return this.toArray();
- })
- .keyup(testInputs)
+ window.open(url, '_blank');
+ window.focus();
+ };
- if( !isNotEmpty() )
- widgetWrapper.hide();
+ var render = function(widgetWrapper) {
+ init();
- });
+ $widgetWrapper = $(widgetWrapper);
- return result;
- };
+ $widgetWrapper
+ .html('
')
+ .click(function() {
+ showMap();
+ });
+ for(var i in $mapSearchElements)
+ $mapSearchElements[i].keyup(function() {
+ testInputs();
+ });
+ this.testInputs();
+ };
- this.showMap = function(prefix) {
- var searchString = "";
+ var testInputs = function() {
+ init();
- for(var i in mapSearchStmts) {
- var stmt = mapSearchStmts[i];
- if( stmt.charAt(0) == '#' ) {
- var val = $('#'+ prefix + stmt.substring(1)).val();
- if( val )
- searchString += val;
- }
+ if( isNotEmpty() )
+ $widgetWrapper.show();
else
- searchString += stmt;
- }
-
- var url = 'https://maps.google.com/maps?q='+ encodeURIComponent(searchString);
+ $widgetWrapper.hide();
+ };
- window.open(url, '_blank');
- window.focus();
+ this.render = render;
+ this.testInputs = testInputs;
};
this.showHistoryWindow = function(id) {