first commit
This commit is contained in:
95
layouts/vlayout/modules/Settings/Currency/EditAjax.tpl
Normal file
95
layouts/vlayout/modules/Settings/Currency/EditAjax.tpl
Normal file
@@ -0,0 +1,95 @@
|
||||
{*<!--
|
||||
/*********************************************************************************
|
||||
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
********************************************************************************/
|
||||
-->*}
|
||||
{strip}
|
||||
{assign var=CURRENCY_MODEL_EXISTS value=true}
|
||||
{assign var=CURRENCY_ID value=$RECORD_MODEL->getId()}
|
||||
{if empty($CURRENCY_ID)}
|
||||
{assign var=CURRENCY_MODEL_EXISTS value=false}
|
||||
{/if}
|
||||
<div class="currencyModalContainer">
|
||||
<div class="modal-header contentsBackground">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
{if $CURRENCY_MODEL_EXISTS}
|
||||
<h3>{vtranslate('LBL_EDIT_CURRENCY', $QUALIFIED_MODULE)}</h3>
|
||||
{else}
|
||||
<h3>{vtranslate('LBL_ADD_NEW_CURRENCY', $QUALIFIED_MODULE)}</h3>
|
||||
{/if}
|
||||
</div>
|
||||
<form id="editCurrency" class="form-horizontal" method="POST">
|
||||
<input type="hidden" name="record" value="{$CURRENCY_ID}" />
|
||||
<div class="modal-body">
|
||||
<div class="row-fluid">
|
||||
<div class="control-group">
|
||||
<label class="muted control-label">
|
||||
<span class="redColor">*</span> {vtranslate('LBL_CURRENCY_NAME', $QUALIFIED_MODULE)}
|
||||
</label>
|
||||
<div class="controls row-fluid">
|
||||
<select class="select2 span6" name="currency_name">
|
||||
{foreach key=CURRENCY_ID item=CURRENCY_MODEL from=$ALL_CURRENCIES name=currencyIterator}
|
||||
{if !$CURRENCY_MODEL_EXISTS && $smarty.foreach.currencyIterator.first}
|
||||
{assign var=RECORD_MODEL value=$CURRENCY_MODEL}
|
||||
{/if}
|
||||
<option value="{$CURRENCY_MODEL->get('currency_name')}" data-code="{$CURRENCY_MODEL->get('currency_code')}"
|
||||
data-symbol="{$CURRENCY_MODEL->get('currency_symbol')}" {if $RECORD_MODEL->get('currency_name') == $CURRENCY_MODEL->get('currency_name')} selected {/if}>
|
||||
{vtranslate($CURRENCY_MODEL->get('currency_name'), $QUALIFIED_MODULE)} ({$CURRENCY_MODEL->get('currency_symbol')})</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="muted control-label"><span class="redColor">*</span> {vtranslate('LBL_CURRENCY_CODE', $QUALIFIED_MODULE)}</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="currency_code" readonly value="{$RECORD_MODEL->get('currency_code')}" data-validation-engine='validate[required]]' />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="muted control-label"><span class="redColor">*</span> {vtranslate('LBL_CURRENCY_SYMBOL', $QUALIFIED_MODULE)}</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="currency_symbol" readonly value="{$RECORD_MODEL->get('currency_symbol')}" data-validation-engine='validate[required]' />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="muted control-label"><span class="redColor">*</span> {vtranslate('LBL_CONVERSION_RATE', $QUALIFIED_MODULE)}</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="conversion_rate" placeholder="{vtranslate('LBL_ENTER_CONVERSION_RATE', $QUALIFIED_MODULE)}"
|
||||
value="{$RECORD_MODEL->get('conversion_rate')}" data-validation-engine='validate[required, funcCall[Vtiger_GreaterThanZero_Validator_Js.invokeValidation]]' />
|
||||
<br><span class="muted">({vtranslate('LBL_BASE_CURRENCY', $QUALIFIED_MODULE)} - {$BASE_CURRENCY_MODEL->get('currency_name')})</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="muted control-label">{vtranslate('LBL_STATUS', $QUALIFIED_MODULE)}</label>
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="hidden" name="currency_status" value="Inactive" />
|
||||
<input type="checkbox" name="currency_status" value="Active" class="currencyStatus alignBottom"
|
||||
{if !$CURRENCY_MODEL_EXISTS} checked {else}{$RECORD_MODEL->get('currency_status')}{if $RECORD_MODEL->get('currency_status') == 'Active'} checked {/if}{/if} />
|
||||
<span> {vtranslate('LBL_CURRENCY_STATUS_DESC', $QUALIFIED_MODULE)}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group transferCurrency hide">
|
||||
<label class="muted control-label"><span class="redColor">*</span>
|
||||
{vtranslate('LBL_TRANSFER_CURRENCY', $QUALIFIED_MODULE)} {vtranslate('LBL_TO', $QUALIFIED_MODULE)}</label>
|
||||
<div class="controls row-fluid">
|
||||
<select class="select2 span6" name="transform_to_id">
|
||||
{foreach key=CURRENCY_ID item=CURRENCY_MODEL from=$OTHER_EXISTING_CURRENCIES}
|
||||
<option value="{$CURRENCY_ID}">{vtranslate($CURRENCY_MODEL->get('currency_name'), $QUALIFIED_MODULE)}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{include file='ModalFooter.tpl'|@vtemplate_path:'Vtiger'}
|
||||
</form>
|
||||
</div>
|
||||
{/strip}
|
||||
105
layouts/vlayout/modules/Settings/Currency/ListViewContents.tpl
Normal file
105
layouts/vlayout/modules/Settings/Currency/ListViewContents.tpl
Normal file
@@ -0,0 +1,105 @@
|
||||
{*<!--
|
||||
/*********************************************************************************
|
||||
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
********************************************************************************/
|
||||
-->*}
|
||||
{strip}
|
||||
<input type="hidden" id="pageStartRange" value="{$PAGING_MODEL->getRecordStartRange()}" />
|
||||
<input type="hidden" id="pageEndRange" value="{$PAGING_MODEL->getRecordEndRange()}" />
|
||||
<input type="hidden" id="previousPageExist" value="{$PAGING_MODEL->isPrevPageExists()}" />
|
||||
<input type="hidden" id="nextPageExist" value="{$PAGING_MODEL->isNextPageExists()}" />
|
||||
<input type="hidden" id="totalCount" value="{$LISTVIEW_COUNT}" />
|
||||
<input type="hidden" value="{$ORDER_BY}" id="orderBy">
|
||||
<input type="hidden" value="{$SORT_ORDER}" id="sortOrder">
|
||||
<input type="hidden" id="totalCount" value="{$LISTVIEW_COUNT}" />
|
||||
<input type='hidden' value="{$PAGE_NUMBER}" id='pageNumber'>
|
||||
<input type='hidden' value="{$PAGING_MODEL->getPageLimit()}" id='pageLimit'>
|
||||
<input type="hidden" value="{$LISTVIEW_ENTRIES_COUNT}" id="noOfEntries">
|
||||
|
||||
<div class="listViewEntriesDiv" style='overflow-x:auto;'>
|
||||
<span class="listViewLoadingImageBlock hide modal" id="loadingListViewModal">
|
||||
<img class="listViewLoadingImage" src="{vimage_path('loading.gif')}" alt="no-image" title="{vtranslate('LBL_LOADING', $MODULE)}"/>
|
||||
<p class="listViewLoadingMsg">{vtranslate('LBL_LOADING_LISTVIEW_CONTENTS', $MODULE)}........</p>
|
||||
</span>
|
||||
{assign var="NAME_FIELDS" value=$MODULE_MODEL->getNameFields()}
|
||||
{assign var=WIDTHTYPE value=$CURRENT_USER_MODEL->get('rowheight')}
|
||||
<table class="table table-bordered table-condensed listViewEntriesTable">
|
||||
<thead>
|
||||
<tr class="listViewHeaders">
|
||||
<th width="1%" class="{$WIDTHTYPE}"></th>
|
||||
{assign var=WIDTH value={99/(count($LISTVIEW_HEADERS))}}
|
||||
{foreach item=LISTVIEW_HEADER from=$LISTVIEW_HEADERS}
|
||||
<th width="{$WIDTH}%" nowrap {if $LISTVIEW_HEADER@last}colspan="2" {/if} class="{$WIDTHTYPE}">
|
||||
<a {if !($LISTVIEW_HEADER->has('sort'))} class="listViewHeaderValues cursorPointer" data-nextsortorderval="{if $COLUMN_NAME eq $LISTVIEW_HEADER->get('name')}{$NEXT_SORT_ORDER}{else}ASC{/if}" data-columnname="{$LISTVIEW_HEADER->get('name')}" {/if}>{vtranslate($LISTVIEW_HEADER->get('label'), $QUALIFIED_MODULE)}
|
||||
{if $COLUMN_NAME eq $LISTVIEW_HEADER->get('name')}<img class="{$SORT_IMAGE} icon-white">{/if}</a>
|
||||
</th>
|
||||
{/foreach}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach item=LISTVIEW_ENTRY from=$LISTVIEW_ENTRIES}
|
||||
<tr class="listViewEntries" data-id="{$LISTVIEW_ENTRY->getId()}"
|
||||
{if method_exists($LISTVIEW_ENTRY,'getDetailViewUrl')}data-recordurl="{$LISTVIEW_ENTRY->getDetailViewUrl()}"{/if}
|
||||
>
|
||||
<td width="1%" nowrap class="{$WIDTHTYPE}">
|
||||
{if $MODULE eq 'CronTasks'}
|
||||
<img src="{vimage_path('drag.png')}" class="alignTop" title="{vtranslate('LBL_DRAG',$QUALIFIED_MODULE)}" />
|
||||
{/if}
|
||||
</td>
|
||||
{foreach item=LISTVIEW_HEADER from=$LISTVIEW_HEADERS}
|
||||
{assign var=LISTVIEW_HEADERNAME value=$LISTVIEW_HEADER->get('name')}
|
||||
{assign var=LAST_COLUMN value=$LISTVIEW_HEADER@last}
|
||||
<td class="listViewEntryValue {$WIDTHTYPE}" width="{$WIDTH}%" nowrap>
|
||||
{if $LISTVIEW_HEADERNAME eq 'currency_status' }
|
||||
{if {$LISTVIEW_ENTRY->getDisplayValue($LISTVIEW_HEADERNAME)} eq 'Active' }
|
||||
{vtranslate('LBL_ACTIVE',$QUALIFIED_MODULE)}
|
||||
{else}
|
||||
{vtranslate('LBL_INACTIVE',$QUALIFIED_MODULE)}
|
||||
{/if}
|
||||
{else}
|
||||
{$LISTVIEW_ENTRY->getDisplayValue($LISTVIEW_HEADERNAME)}
|
||||
{/if}
|
||||
{if $LAST_COLUMN && $LISTVIEW_ENTRY->getRecordLinks()}
|
||||
</td><td nowrap class="{$WIDTHTYPE}">
|
||||
<div class="pull-right actions">
|
||||
<span class="actionImages">
|
||||
{foreach item=RECORD_LINK from=$LISTVIEW_ENTRY->getRecordLinks()}
|
||||
{assign var="RECORD_LINK_URL" value=$RECORD_LINK->getUrl()}
|
||||
<a {if stripos($RECORD_LINK_URL, 'javascript:')===0} onclick="{$RECORD_LINK_URL|substr:strlen("javascript:")};if(event.stopPropagation){ldelim}event.stopPropagation();{rdelim}else{ldelim}event.cancelBubble=true;{rdelim}" {else} href='{$RECORD_LINK_URL}' {/if}>
|
||||
<i class="{$RECORD_LINK->getIcon()} alignMiddle" title="{vtranslate($RECORD_LINK->getLabel(), $QUALIFIED_MODULE)}"></i>
|
||||
</a>
|
||||
{if !$RECORD_LINK@last}
|
||||
|
||||
{/if}
|
||||
{/foreach}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
{/if}
|
||||
</td>
|
||||
{/foreach}
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!--added this div for Temporarily -->
|
||||
{if $LISTVIEW_ENTRIES_COUNT eq '0'}
|
||||
<table class="emptyRecordsDiv">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
{vtranslate('LBL_EQ_ZERO')} {vtranslate($MODULE, $QUALIFIED_MODULE)} {vtranslate('LBL_FOUND')}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{/if}
|
||||
</div>
|
||||
{/strip}
|
||||
44
layouts/vlayout/modules/Settings/Currency/TransformEdit.tpl
Normal file
44
layouts/vlayout/modules/Settings/Currency/TransformEdit.tpl
Normal file
@@ -0,0 +1,44 @@
|
||||
{*<!--
|
||||
/*********************************************************************************
|
||||
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
********************************************************************************/
|
||||
-->*}
|
||||
{strip}
|
||||
{assign var=CURRENCY_ID value=$RECORD_MODEL->getId()}
|
||||
<div class="currencyTransformModalContainer">
|
||||
<div class="modal-header contentsBackground">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3>{vtranslate('LBL_TRANSFER_CURRENCY', $QUALIFIED_MODULE)}</h3>
|
||||
</div>
|
||||
<form id="transformCurrency" class="form-horizontal" method="POST">
|
||||
<input type="hidden" name="record" value="{$CURRENCY_ID}" />
|
||||
<div class="modal-body">
|
||||
<div class="row-fluid">
|
||||
<div class="control-group">
|
||||
<label class="muted control-label">{vtranslate('LBL_CURRENT_CURRENCY', $QUALIFIED_MODULE)}</label>
|
||||
<div class="controls">
|
||||
<span>{vtranslate($RECORD_MODEL->get('currency_name'), $QUALIFIED_MODULE)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="muted control-label">{vtranslate('LBL_TRANSFER_CURRENCY', $QUALIFIED_MODULE)} {vtranslate('LBL_TO', $QUALIFIED_MODULE)}</label>
|
||||
<div class="controls row-fluid">
|
||||
<select class="select2 span6" name="transform_to_id">
|
||||
{foreach key=CURRENCY_ID item=CURRENCY_MODEL from=$CURRENCY_LIST}
|
||||
<option value="{$CURRENCY_ID}">{vtranslate($CURRENCY_MODEL->get('currency_name'), $QUALIFIED_MODULE)}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{include file='ModalFooter.tpl'|@vtemplate_path:'Vtiger'}
|
||||
</form>
|
||||
</div>
|
||||
{/strip}
|
||||
306
layouts/vlayout/modules/Settings/Currency/resources/Currency.js
Normal file
306
layouts/vlayout/modules/Settings/Currency/resources/Currency.js
Normal file
@@ -0,0 +1,306 @@
|
||||
/*+***********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*************************************************************************************/
|
||||
jQuery.Class('Settings_Currency_Js', {
|
||||
|
||||
//holds the currency instance
|
||||
currencyInstance : false,
|
||||
|
||||
/**
|
||||
* This function used to triggerAdd Currency
|
||||
*/
|
||||
triggerAdd : function(event) {
|
||||
event.stopPropagation();
|
||||
var instance = Settings_Currency_Js.currencyInstance;
|
||||
instance.showEditView();
|
||||
},
|
||||
|
||||
/**
|
||||
* This function used to trigger Edit Currency
|
||||
*/
|
||||
triggerEdit : function(event, id) {
|
||||
event.stopPropagation();
|
||||
var instance = Settings_Currency_Js.currencyInstance;
|
||||
instance.showEditView(id);
|
||||
},
|
||||
|
||||
/**
|
||||
* This function used to trigger Delete Currency
|
||||
*/
|
||||
triggerDelete : function(event, id) {
|
||||
event.stopPropagation();
|
||||
var currentTarget = jQuery(event.currentTarget);
|
||||
var currentTrEle = currentTarget.closest('tr');
|
||||
var instance = Settings_Currency_Js.currencyInstance;
|
||||
instance.transformEdit(id).then(
|
||||
function(data) {
|
||||
var callBackFunction = function(data) {
|
||||
var form = jQuery('#transformCurrency');
|
||||
|
||||
//register all select2 Elements
|
||||
app.showSelect2ElementView(form.find('select.select2'));
|
||||
|
||||
form.submit(function(e) {
|
||||
e.preventDefault();
|
||||
var transferCurrencyEle = form.find('select[name="transform_to_id"]');
|
||||
instance.deleteCurrency(id, transferCurrencyEle, currentTrEle);
|
||||
})
|
||||
}
|
||||
|
||||
app.showModalWindow(data,function(data){
|
||||
if(typeof callBackFunction == 'function'){
|
||||
callBackFunction(data);
|
||||
}
|
||||
}, {'width':'500px'});
|
||||
}, function(error, err) {
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}, {
|
||||
|
||||
//constructor
|
||||
init : function() {
|
||||
Settings_Currency_Js.currencyInstance = this;
|
||||
},
|
||||
|
||||
/*
|
||||
* function to show editView for Add/Edit Currency
|
||||
* @params: id - currencyId
|
||||
*/
|
||||
showEditView : function(id) {
|
||||
var thisInstance = this;
|
||||
var aDeferred = jQuery.Deferred();
|
||||
|
||||
var progressIndicatorElement = jQuery.progressIndicator({
|
||||
'position' : 'html',
|
||||
'blockInfo' : {
|
||||
'enabled' : true
|
||||
}
|
||||
});
|
||||
|
||||
var params = {};
|
||||
params['module'] = app.getModuleName();
|
||||
params['parent'] = app.getParentModuleName();
|
||||
params['view'] = 'EditAjax';
|
||||
params['record'] = id;
|
||||
|
||||
AppConnector.request(params).then(
|
||||
function(data) {
|
||||
var callBackFunction = function(data) {
|
||||
var form = jQuery('#editCurrency');
|
||||
var record = form.find('[name="record"]').val();
|
||||
|
||||
//register all select2 Elements
|
||||
app.showSelect2ElementView(form.find('select.select2'));
|
||||
var currencyStatus = form.find('[name="currency_status"]').is(':checked');
|
||||
if(record != '' && currencyStatus) {
|
||||
//While editing currency, register the status change event
|
||||
thisInstance.registerCurrencyStatusChangeEvent(form);
|
||||
}
|
||||
//If we change the currency name, change the code and symbol for that currency
|
||||
thisInstance.registerCurrencyNameChangeEvent(form);
|
||||
|
||||
var params = app.validationEngineOptions;
|
||||
params.onValidationComplete = function(form, valid){
|
||||
if(valid) {
|
||||
thisInstance.saveCurrencyDetails(form);
|
||||
return valid;
|
||||
}
|
||||
}
|
||||
form.validationEngine(params);
|
||||
|
||||
form.submit(function(e) {
|
||||
e.preventDefault();
|
||||
})
|
||||
}
|
||||
|
||||
progressIndicatorElement.progressIndicator({'mode' : 'hide'});
|
||||
app.showModalWindow(data,function(data){
|
||||
if(typeof callBackFunction == 'function'){
|
||||
callBackFunction(data);
|
||||
}
|
||||
}, {'width':'600px'});
|
||||
},
|
||||
function(error) {
|
||||
progressIndicatorElement.progressIndicator({'mode' : 'hide'});
|
||||
//TODO : Handle error
|
||||
aDeferred.reject(error);
|
||||
}
|
||||
);
|
||||
return aDeferred.promise();
|
||||
},
|
||||
|
||||
/**
|
||||
* Register Change event for currency status
|
||||
*/
|
||||
registerCurrencyStatusChangeEvent : function(form) {
|
||||
/*If the status changed to Inactive while editing currency,
|
||||
currency should transfer to other existing currencies */
|
||||
form.find('[name="currency_status"]').on('change', function(e) {
|
||||
var currentTarget = jQuery(e.currentTarget);
|
||||
if(currentTarget.is(':checked')) {
|
||||
form.find('div.transferCurrency').addClass('hide');
|
||||
} else {
|
||||
form.find('div.transferCurrency').removeClass('hide');
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Register Change event for currency Name
|
||||
*/
|
||||
registerCurrencyNameChangeEvent : function(form) {
|
||||
var currencyNameEle = form.find('select[name="currency_name"]');
|
||||
//on change of currencyName, update the currency code & symbol
|
||||
currencyNameEle.on('change', function() {
|
||||
var selectedCurrencyOption = currencyNameEle.find('option:selected');
|
||||
form.find('[name="currency_code"]').val(selectedCurrencyOption.data('code'));
|
||||
form.find('[name="currency_symbol"]').val(selectedCurrencyOption.data('symbol'));
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* This function will save the currency details
|
||||
*/
|
||||
saveCurrencyDetails : function(form) {
|
||||
var thisInstance = this;
|
||||
var progressIndicatorElement = jQuery.progressIndicator({
|
||||
'position' : 'html',
|
||||
'blockInfo' : {
|
||||
'enabled' : true
|
||||
}
|
||||
});
|
||||
|
||||
var data = form.serializeFormData();
|
||||
data['module'] = app.getModuleName();
|
||||
data['parent'] = app.getParentModuleName();
|
||||
data['action'] = 'SaveAjax';
|
||||
|
||||
AppConnector.request(data).then(
|
||||
function(data) {
|
||||
if(data['success']) {
|
||||
progressIndicatorElement.progressIndicator({'mode' : 'hide'});
|
||||
app.hideModalWindow();
|
||||
var params = {};
|
||||
params.text = app.vtranslate('JS_CURRENCY_DETAILS_SAVED');
|
||||
Settings_Vtiger_Index_Js.showMessage(params);
|
||||
thisInstance.loadListViewContents();
|
||||
}
|
||||
},
|
||||
function(error) {
|
||||
progressIndicatorElement.progressIndicator({'mode' : 'hide'});
|
||||
//TODO : Handle error
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* This function will load the listView contents after Add/Edit currency
|
||||
*/
|
||||
loadListViewContents : function() {
|
||||
var thisInstance = this;
|
||||
var progressIndicatorElement = jQuery.progressIndicator({
|
||||
'position' : 'html',
|
||||
'blockInfo' : {
|
||||
'enabled' : true
|
||||
}
|
||||
});
|
||||
|
||||
var params = {};
|
||||
params['module'] = app.getModuleName();
|
||||
params['parent'] = app.getParentModuleName();
|
||||
params['view'] = 'List';
|
||||
|
||||
AppConnector.request(params).then(
|
||||
function(data) {
|
||||
progressIndicatorElement.progressIndicator({'mode' : 'hide'});
|
||||
//replace the new list view contents
|
||||
jQuery('#listViewContents').html(data);
|
||||
//thisInstance.triggerDisplayTypeEvent();
|
||||
}, function(error, err) {
|
||||
progressIndicatorElement.progressIndicator({'mode' : 'hide'});
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* This function will show the Transform Currency view while delete the currency
|
||||
*/
|
||||
transformEdit : function(id) {
|
||||
var aDeferred = jQuery.Deferred();
|
||||
|
||||
var params = {};
|
||||
params['module'] = app.getModuleName();
|
||||
params['parent'] = app.getParentModuleName();
|
||||
params['view'] = 'TransformEditAjax';
|
||||
params['record'] = id;
|
||||
|
||||
AppConnector.request(params).then(
|
||||
function(data) {
|
||||
aDeferred.resolve(data);
|
||||
}, function(error, err) {
|
||||
aDeferred.reject();
|
||||
});
|
||||
return aDeferred.promise();
|
||||
},
|
||||
|
||||
/**
|
||||
* This function will delete the currency and save the transferCurrency details
|
||||
*/
|
||||
deleteCurrency : function(id, transferCurrencyEle, currentTrEle) {
|
||||
var transferCurrencyId = transferCurrencyEle.find('option:selected').val();
|
||||
var params = {};
|
||||
params['module'] = app.getModuleName();
|
||||
params['parent'] = app.getParentModuleName();
|
||||
params['action'] = 'DeleteAjax';
|
||||
params['record'] = id;
|
||||
params['transform_to_id'] = transferCurrencyId;
|
||||
|
||||
AppConnector.request(params).then(
|
||||
function(data) {
|
||||
app.hideModalWindow();
|
||||
var params = {};
|
||||
params.text = app.vtranslate('JS_CURRENCY_DELETED_SUEESSFULLY');
|
||||
Settings_Vtiger_Index_Js.showMessage(params);
|
||||
currentTrEle.fadeOut('slow').remove();
|
||||
}, function(error, err) {
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
triggerDisplayTypeEvent : function() {
|
||||
var widthType = app.cacheGet('widthType', 'narrowWidthType');
|
||||
if(widthType) {
|
||||
var elements = jQuery('.listViewEntriesTable').find('td,th');
|
||||
elements.attr('class', widthType);
|
||||
}
|
||||
},
|
||||
|
||||
registerRowClick : function() {
|
||||
var thisInstance = this;
|
||||
jQuery('#listViewContents').on('click','.listViewEntries',function(e) {
|
||||
var currentRow = jQuery(e.currentTarget);
|
||||
if(currentRow.find('.icon-pencil ').length <= 0) {
|
||||
return;
|
||||
}
|
||||
thisInstance.showEditView(currentRow.data('id'));
|
||||
})
|
||||
},
|
||||
|
||||
registerEvents : function() {
|
||||
this.registerRowClick();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
jQuery(document).ready(function(){
|
||||
var currencyInstance = new Settings_Currency_Js();
|
||||
currencyInstance.registerEvents();
|
||||
})
|
||||
Reference in New Issue
Block a user