diff --git a/layouts/v7/modules/Vtiger/uitypes/PhoneDetailView.tpl b/layouts/v7/modules/Vtiger/uitypes/PhoneDetailView.tpl index 55437ec13feef9f3fbc3c07eab286c48d2a24c8e..14b2b51368c364ec052b7fe22ee482a7f8f3d3ec 100644 --- a/layouts/v7/modules/Vtiger/uitypes/PhoneDetailView.tpl +++ b/layouts/v7/modules/Vtiger/uitypes/PhoneDetailView.tpl @@ -7,5 +7,18 @@ * All Rights Reserved. ************************************************************************************} +{assign var=MODULE value='PBXManager'} +{assign var=MODULEMODEL value=Vtiger_Module_Model::getInstance($MODULE)} {assign var=FIELD_VALUE value=$FIELD_MODEL->get('fieldvalue')} -{$FIELD_MODEL->getDisplayValue($FIELD_MODEL->get('fieldvalue'), $RECORD->getId(), $RECORD)} +{if $MODULEMODEL and $MODULEMODEL->isActive() and $FIELD_VALUE} + {assign var=PERMISSION value=PBXManager_Server_Model::checkPermissionForOutgoingCall()} + {if $PERMISSION} + {assign var=PHONE_FIELD_VALUE value=$FIELD_VALUE} + {assign var=PHONE_NUMBER value=$PHONE_FIELD_VALUE|regex_replace:"/[-()\s]/":""} + <a class="phoneField" data-value="{$PHONE_NUMBER}" record="{$RECORD->getId()}" onclick="Vtiger_PBXManager_Js.registerPBXOutboundCall('{$PHONE_NUMBER}',{$RECORD->getId()})">{$FIELD_MODEL->get('fieldvalue')}</a> + {else} + {$FIELD_MODEL->getDisplayValue($FIELD_MODEL->get('fieldvalue'), $RECORD->getId(), $RECORD)} + {/if} +{else} + {$FIELD_MODEL->getDisplayValue($FIELD_MODEL->get('fieldvalue'), $RECORD->getId(), $RECORD)} +{/if} diff --git a/packages/vtiger/mandatory/PBXManager.zip b/packages/vtiger/mandatory/PBXManager.zip index 9abbeec05099b55d9cd76bebf328db8677271715..79b3782b7ecf6f3465664e260eec7be2da4ed7bc 100644 Binary files a/packages/vtiger/mandatory/PBXManager.zip and b/packages/vtiger/mandatory/PBXManager.zip differ diff --git a/pkg/vtiger/modules/PBXManager/modules/PBXManager/resources/PBXManagerJS.js b/pkg/vtiger/modules/PBXManager/modules/PBXManager/resources/PBXManagerJS.js index 68a3b6b39ed38a40295896ea542c1a2270b4741b..d7de2d9a01c49cdca96fd8bb2a4f4016dc0386af 100644 --- a/pkg/vtiger/modules/PBXManager/modules/PBXManager/resources/PBXManagerJS.js +++ b/pkg/vtiger/modules/PBXManager/modules/PBXManager/resources/PBXManagerJS.js @@ -26,8 +26,8 @@ var Vtiger_PBXManager_Js = { */ requestPBXgetCalls : function() { var url = 'index.php?module=PBXManager&action=IncomingCallPoll&mode=searchIncomingCalls'; - app.request.get(url).then(function(data){ - if(data.success && data.result) { + app.request.get(url).then(function(e, data){ + if(data && data.success && data.result) { for(i=0; i< data.result.length; i++) { var record = data.result[i]; if(jQuery('#pbxcall_'+record.pbxmanagerid+'').size()== 0 ) @@ -103,8 +103,8 @@ var Vtiger_PBXManager_Js = { var number = jQuery('#caller','#pbxcall_'+pbxmanagerid+'').attr("value"); var url = 'index.php?module=PBXManager&action=IncomingCallPoll&mode=createRecord&number='+encodeURIComponent(number)+'&email='+encodeURIComponent(email)+'&callid='+record.sourceuuid+'&modulename='+moduleName; - app.request.get(url).then(function(data){ - if(data.success && data.result) { + app.request.get(url).then(function(e, data){ + if(data && data.success && data.result) { jQuery('#contactsave_'+pbxmanagerid+'').hide(); } }); @@ -113,8 +113,9 @@ var Vtiger_PBXManager_Js = { checkIfRelatedModuleRecordExist: function(record) { switch(record.callername){ case null: var url = 'index.php?module=PBXManager&action=IncomingCallPoll&mode=checkModuleViewPermission&view=EditView'; - app.request.get(url).then(function(data){ - var responsedata = JSON.parse(data); + app.request.get(url).then(function(e, data){ + if (e) return; + var responsedata = (typeof data == 'object') ? data : JSON.parse(data); var showSaveOption = false; var moduleList = responsedata.result.modules; var contents = jQuery('#module_'+record.pbxmanagerid+''); @@ -166,8 +167,8 @@ var Vtiger_PBXManager_Js = { for(var i=0; i<pbxcall.length;i++){ callid = pbxcall[i].getAttribute('callid'); var url = 'index.php?module=PBXManager&action=IncomingCallPoll&mode=getCallStatus&callid='+encodeURIComponent(callid)+''; - app.request.get(url).then(function(data){ - if(data.result){ + app.request.get(url).then(function(e, data){ + if(data && data.result){ if(data.result!='in-progress' && data.result!='ringing'){ Vtiger_PBXManager_Js.removeCallPopup(callid); } @@ -203,8 +204,8 @@ var Vtiger_PBXManager_Js = { 'module' : 'PBXManager', 'action' : 'OutgoingCall' } - app.request.get(params).then(function(data){ - if(data.result){ + app.request.get(params).then(function(e, data){ + if(data && data.result){ params = { 'text' : app.vtranslate('JS_PBX_OUTGOING_SUCCESS'), 'type' : 'info' @@ -226,7 +227,7 @@ var Vtiger_PBXManager_Js = { var thisInstance = this; //for polling var url = 'index.php?module=PBXManager&action=IncomingCallPoll&mode=checkPermissionForPolling'; - app.request.get(url).then(function(data){ + app.request.get(url).then(function(e, data){ if(data && data.result) { Vtiger_PBXManager_Js.registerPBXCall(); setInterval("Vtiger_PBXManager_Js.registerPBXCall()", 3000);