X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=js%2Fkivi.CustomerVendor.js;h=67820bea511b7d668b2609c26a920585108183e4;hb=6d74ac0e2ebea572fdd7a03588bc3c821676d6f1;hp=59c07354edf70ab6df6d9f6823df01bf57b5ecc7;hpb=efb9a24f2252104ab4af5c25334119d7c5c70a8c;p=kivitendo-erp.git
diff --git a/js/kivi.CustomerVendor.js b/js/kivi.CustomerVendor.js
index 59c07354e..67820bea5 100644
--- a/js/kivi.CustomerVendor.js
+++ b/js/kivi.CustomerVendor.js
@@ -41,6 +41,27 @@ namespace('kivi.CustomerVendor', function(ns) {
}
};
+ this.setCustomVariablesFromAJAJ = function(cvars) {
+ for (var key in cvars) {
+ var cvar = cvars[key];
+ var $ctrl = $('#contact_cvars_'+ key);
+
+ console.log($ctrl, cvar);
+
+ if (cvar.type == 'bool')
+ $ctrl.prop('checked', cvar.value == 1 ? 'checked' : '');
+
+ else if ((cvar.type == 'customer') || (cvar.type == 'vendor'))
+ kivi.CustomerVendorPicker($ctrl).set_item({ id: cvar.id, name: cvar.value });
+
+ else if (cvar.type == 'part')
+ kivi.PartPicker($ctrl).set_item({ id: cvar.id, name: cvar.value });
+
+ else
+ $ctrl.val(cvar.value);
+ }
+ };
+
this.selectContact = function(params) {
var contactId = $('#contact_cp_id').val();
@@ -51,9 +72,7 @@ namespace('kivi.CustomerVendor', function(ns) {
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_cvars_'+ key)).val(cvars[key]);
+ kivi.CustomerVendor.setCustomVariablesFromAJAJ(data.contact_cvars);
if ( contactId )
$('#action_delete_contact').show();
@@ -77,7 +96,7 @@ namespace('kivi.CustomerVendor', function(ns) {
'#country'
];
- this.MapWidget = function(prefix)
+ this.MapWidget = function(prefix, source_address)
{
var $mapSearchElements = [];
var $widgetWrapper;
@@ -117,7 +136,9 @@ namespace('kivi.CustomerVendor', function(ns) {
searchString += stmt;
}
- var url = 'https://maps.google.com/maps?q='+ encodeURIComponent(searchString);
+ source_address = source_address || '';
+ var query = source_address != '' ? 'saddr=' + encodeURIComponent(source_address) + '&daddr=' : 'q=';
+ var url = 'https://maps.google.com/maps?' + query + encodeURIComponent(searchString);
window.open(url, '_blank');
window.focus();
@@ -160,4 +181,44 @@ namespace('kivi.CustomerVendor', function(ns) {
var url = "common.pl?INPUT_ENCODING=UTF-8&action=show_history&longdescription=&input_name="+ encodeURIComponent(id);
window.open(url, "_new_generic", parm);
};
+
+ this.update_dial_action = function($input) {
+ var $action = $('#' + $input.prop('id') + '-dial-action');
+
+ if (!$action)
+ return true;
+
+ var number = $input.val().replace(/\s+/g, '');
+ if (number == '')
+ $action.hide();
+ else
+ $action.prop('href', 'controller.pl?action=CTI/call&number=' + encodeURIComponent(number)).show();
+
+ return true;
+ };
+
+ this.init_dial_action = function(input) {
+ if ($('#_cti_enabled').val() != 1)
+ return false;
+
+ var $input = $(input);
+ var action_id = $input.prop('id') + '-dial-action';
+
+ if (!$('#' + action_id).size()) {
+ var $action = $('');
+ $input.wrap('').after($action);
+
+ $input.change(function() { kivi.CustomerVendor.update_dial_action($input); });
+ }
+
+ kivi.CustomerVendor.update_dial_action($input);
+
+ return true;
+ };
});
+
+function local_reinit_widgets() {
+ $('#cv_phone,#shipto_shiptophone,#contact_cp_phone1,#contact_cp_phone2,#contact_cp_mobile1,#contact_cp_mobile2').each(function(idx, elt) {
+ kivi.CustomerVendor.init_dial_action($(elt));
+ });
+}