[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 /*+*********************************************************************************** 2 * The contents of this file are subject to the vtiger CRM Public License Version 1.0 3 * ("License"); You may not use this file except in compliance with the License 4 * The Original Code is: vtiger CRM Open Source 5 * The Initial Developer of the Original Code is vtiger. 6 * Portions created by vtiger are Copyright (C) vtiger. 7 * All Rights Reserved. 8 *************************************************************************************/ 9 10 Vtiger_Detail_Js("Accounts_Detail_Js",{ 11 12 //It stores the Account Hierarchy response data 13 accountHierarchyResponseCache : {}, 14 15 /* 16 * function to trigger Account Hierarchy action 17 * @param: Account Hierarchy Url. 18 */ 19 triggerAccountHierarchy : function(accountHierarchyUrl) { 20 Accounts_Detail_Js.getAccountHierarchyResponseData(accountHierarchyUrl).then( 21 function(data) { 22 Accounts_Detail_Js.displayAccountHierarchyResponseData(data); 23 } 24 ); 25 26 }, 27 28 /* 29 * function to get the AccountHierarchy response data 30 */ 31 getAccountHierarchyResponseData : function(params) { 32 var aDeferred = jQuery.Deferred(); 33 34 //Check in the cache 35 if(!(jQuery.isEmptyObject(Accounts_Detail_Js.accountHierarchyResponseCache))) { 36 aDeferred.resolve(Accounts_Detail_Js.accountHierarchyResponseCache); 37 } else { 38 AppConnector.request(params).then( 39 function(data) { 40 //store it in the cache, so that we dont do multiple request 41 Accounts_Detail_Js.accountHierarchyResponseCache = data; 42 aDeferred.resolve(Accounts_Detail_Js.accountHierarchyResponseCache); 43 } 44 ); 45 } 46 return aDeferred.promise(); 47 }, 48 49 /* 50 * function to display the AccountHierarchy response data 51 */ 52 displayAccountHierarchyResponseData : function(data) { 53 var callbackFunction = function(data) { 54 app.showScrollBar(jQuery('#hierarchyScroll'), { 55 height: '300px', 56 railVisible: true, 57 size: '6px' 58 }); 59 } 60 app.showModalWindow(data, function(data){ 61 62 if(typeof callbackFunction == 'function' && jQuery('#hierarchyScroll').height() > 300){ 63 callbackFunction(data); 64 } 65 }); 66 } 67 },{ 68 //Cache which will store account name and whether it is duplicate or not 69 accountDuplicationCheckCache : {}, 70 71 getDeleteMessageKey : function() { 72 return 'LBL_RELATED_RECORD_DELETE_CONFIRMATION'; 73 }, 74 75 isAccountNameDuplicate : function(params) { 76 var thisInstance = this; 77 var accountName = params.accountName; 78 var aDeferred = jQuery.Deferred(); 79 80 var analyzeResponse = function(response){ 81 if(response['success'] == true) { 82 aDeferred.reject(response['message']); 83 }else{ 84 aDeferred.resolve(); 85 } 86 } 87 88 if(accountName in thisInstance.accountDuplicationCheckCache) { 89 analyzeResponse(thisInstance.accountDuplicationCheckCache[accountName]); 90 }else{ 91 Vtiger_Helper_Js.checkDuplicateName(params).then( 92 function(response){ 93 thisInstance.accountDuplicationCheckCache[accountName] = response; 94 analyzeResponse(response); 95 }, 96 function(response) { 97 thisInstance.accountDuplicationCheckCache[accountName] = response; 98 analyzeResponse(response); 99 } 100 ); 101 } 102 return aDeferred.promise(); 103 }, 104 105 saveFieldValues : function (fieldDetailList) { 106 var thisInstance = this; 107 var targetFn = this._super; 108 109 var fieldName = fieldDetailList.field; 110 if(fieldName != 'accountname') { 111 return targetFn.call(thisInstance, fieldDetailList); 112 } 113 114 var aDeferred = jQuery.Deferred(); 115 fieldDetailList.accountName = fieldDetailList.value; 116 fieldDetailList.recordId = this.getRecordId(); 117 this.isAccountNameDuplicate(fieldDetailList).then( 118 function() { 119 targetFn.call(thisInstance, fieldDetailList).then( 120 function(data){ 121 aDeferred.resolve(data); 122 },function() { 123 aDeferred.reject(); 124 } 125 ); 126 }, 127 function(message) { 128 var form = thisInstance.getForm(); 129 var params = { 130 title: app.vtranslate('JS_DUPLICATE_RECORD'), 131 text: app.vtranslate(message), 132 width: '35%' 133 }; 134 Vtiger_Helper_Js.showPnotify(params); 135 form.find('[name="accountname"]').closest('td.fieldValue').trigger('click'); 136 aDeferred.reject(); 137 } 138 ) 139 return aDeferred.promise(); 140 }, 141 142 /** 143 * Function to register event for adding related record for module 144 */ 145 registerEventForAddingRelatedRecord : function(){ 146 var thisInstance = this; 147 var detailContentsHolder = this.getContentHolder(); 148 detailContentsHolder.on('click','[name="addButton"]',function(e){ 149 var element = jQuery(e.currentTarget); 150 var selectedTabElement = thisInstance.getSelectedTab(); 151 var relatedModuleName = thisInstance.getRelatedModuleName(); 152 var quickCreateNode = jQuery('#quickCreateModules').find('[data-name="'+ relatedModuleName +'"]'); 153 if(quickCreateNode.length <= 0) { 154 window.location.href = element.data('url'); 155 return; 156 } 157 158 var relatedController = new Vtiger_RelatedList_Js(thisInstance.getRecordId(), app.getModuleName(), selectedTabElement, relatedModuleName); 159 var postPopupViewController = function() { 160 var instance = new Contacts_Edit_Js(); 161 var data = new Object; 162 var container = jQuery("[name='QuickCreate']"); 163 data.source_module = app.getModuleName(); 164 data.record = thisInstance.getRecordId(); 165 data.selectedName = container.find("[name='account_id_display']").val(); 166 instance.referenceSelectionEventHandler(data,container); 167 } 168 if(relatedModuleName == 'Contacts') 169 relatedController.addRelatedRecord(element , postPopupViewController); 170 else 171 relatedController.addRelatedRecord(element); 172 }) 173 } 174 175 });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |