Amit Kumar

Amit Kumar

  • NA
  • 6
  • 1.1k

Reason for error in code

Nov 15 2018 10:39 AM
_lastSelectedClient = null;
objBLL.SetMandatoryFundsOnApplication();
//Setting combos blank on application change before re-filling of combos
SetBlankCombo(objControls.cmbClient, objControls.hdnClient);
SetBlankCombo(objControls.cmbReportModule, objControls.hdnReportModule);
SetBlankCombo(objControls.cmbReportLevel, objControls.hdnReportLevel);
SetBlankCombo(objControls.cmbReportsCategory, objControls.hdnReportsCategory);
//clearing data from grids
objControls.tblClientReportGrid.jqGrid('clearGridData');
_ModifiedPageRows = [];
objBLL.FillClientCombo();
//Filling Report Module,Category and level based on application id
objBLL.FillReportModuleCombo(selectedApplication);
objBLL.FillReportLevelCombo(selectedApplication);
objBLL.FillReportCategoryCombo(selectedApplication);
}
PageControls.prototype.ApplicationComboFailedCallback = function (event, ui) {
}
PageControls.prototype.ApplicationComboSelectBlankCallback = function (event, ui) {
KillCombo(objControls.cmbClient);
KillCombo(objControls.cmbBroker);
KillCombo(objControls.cmbTraderFOF);
KillCombo(objControls.cmbBrokerAccount);
KillCombo(objControls.cmbReportModule);
KillCombo(objControls.cmbReportLevel);
KillCombo(objControls.cmbReportsCategory);
}
PageControls.prototype.ClientComboSelectCallback = function (event, ui) {
if (_lastSelectedClient != window.atob(ui.item.value)) {
objBLL.ResetVariables();
_lastSelectedClient = window.atob(ui.item.value);
objNotifications.Clear();
SetBlankCombo(objControls.cmbBroker, objControls.hdnBroker);
SetBlankCombo(objControls.cmbTraderFOF, objControls.hdnTraderFOF);
SetBlankCombo(objControls.cmbBrokerAccount, objControls.hdnBrokerAccount);
if (window.atob(ui.item.value) == addValueInCombo.Select) {
KillCombo(objControls.cmbBroker);
KillCombo(objControls.cmbTraderFOF);
KillCombo(objControls.cmbBrokerAccount);
}
else {
_globalClientID = window.atob(objControls.hdnClient.val());
objBLL.FillBrokerCombo();
objBLL.FillTraderFOFCombo();
objBLL.FillBrokerAccountCombo();
}
}
}
PageControls.prototype.ClientComboFailedCallback = function (event, ui) {
}
PageControls.prototype.BrokerComboSelectCallback = function (event, ui) {
if (_lastSelectedBroker != window.atob(ui.item.value)) {
_lastSelectedBroker = window.atob(ui.item.value);
if (window.atob(ui.item.value) != addValueInCombo.All) {
_globalBrokerID = window.atob(objControls.hdnBroker.val());
}
else {
_globalBrokerID = null;
}
SetBlankCombo(objControls.cmbTraderFOF, objControls.hdnTraderFOF);
SetBlankCombo(objControls.cmbBrokerAccount, objControls.hdnBrokerAccount);
objBLL.FillTraderFOFCombo();
objBLL.FillBrokerAccountCombo();
}
}
PageControls.prototype.BrokerAccountComboSelectCallback = function (event, ui) {
if (window.atob(ui.item.value) != addValueInCombo.All) {
_accountID = window.atob(objControls.hdnBrokerAccount.val());
}
else {
_accountID = null;
}
}
PageControls.prototype.BrokerComboFailedCallback = function (event, ui) {
}
PageControls.prototype.TraderFOFComboSelectCallback = function (event, ui) {
if (_lastSelectedTrader != window.atob(ui.item.value)) {
_lastSelectedTrader = window.atob(ui.item.value);
SetBlankCombo(objControls.cmbBrokerAccount, objControls.hdnBrokerAccount);
objBLL.FillBrokerAccountCombo();
if (window.atob(ui.item.value) != addValueInCombo.All && window.atob(ui.item.value) != addValueInCombo.Select) {
_globalFundID = window.atob(objControls.hdnTraderFOF.val());
}
else {
_globalFundID = null;
}
}
}
PageControls.prototype.TraderFOFComboFailedCallback = function (event, ui) {
}
function PageBLL() {
this.Init();
}
// Dom ready event (like we have in windows page load event).
PageBLL.prototype.Init = function () {
objNotifications = new Notification();
this.AddActiveClass();
this.FillApplicationCombo();
}
// to make a menu active, add this method.
PageBLL.prototype.AddActiveClass = function () {
$('.admin').addClass('active');
}
PageBLL.prototype.FillApplicationCombo = function () {
var autoCompleteCombos = new AutoCompleteCombos();
var objAutoComplete = autoCompleteCombos.FillApplication(applicationJSON, objControls.cmbApplication, objControls.hdnApplication, objControls.ApplicationComboSelectCallback, objControls.ApplicationComboFailedCallback, userID, objControls.ApplicationComboSelectBlankCallback);
objAutoComplete.cube_auto();
}
PageBLL.prototype.FillClientCombo = function () {
var autoCompleteCombos = new AutoCompleteCombos();
var objAutoComplete = autoCompleteCombos.FillClients(objControls.cmbClient, objControls.hdnClient, objControls.ClientComboSelectCallback, objControls.ClientComboFailedCallback);
objAutoComplete.cube_auto();
if (_clients != '' && !_IsDefaultDataSet) {
SetComboVal(objControls.cmbClient, _clients);
if (_fund == '')
_IsDefaultDataSet = true;
}
else
_IsDefaultDataSet = true;
}
PageBLL.prototype.FillBrokerCombo = function () {
var autoCompleteCombos = new AutoCompleteCombos();
var objAutoComplete = autoCompleteCombos.FillBrokers(objControls.cmbBroker, objControls.hdnBroker, objControls.BrokerComboSelectCallback, objControls.BrokerComboFailedCallback, objControls.hdnClient.val());
if (objAutoComplete != null)
objAutoComplete.cube_auto();
}
PageBLL.prototype.FillTraderFOFCombo = function () {
KillCombo(objControls.cmbTraderFOF);
var autoCompleteCombos = new AutoCompleteCombos();
if(_isFundMandatory)
_lastSelectedTrader = addValueInCombo.Select;
else
_lastSelectedTrader = addValueInCombo.All;
var objAutoComplete = autoCompleteCombos.FillTraders_FOF(objControls.cmbTraderFOF, objControls.hdnTraderFOF, objControls.TraderFOFComboSelectCallback,
objControls.TraderFOFComboFailedCallback, objControls.hdnClient.val(), objControls.hdnBroker.val(), null
, (_isFundMandatory) ? addValueInCombo.Select : addValueInCombo.All);
if (objAutoComplete != null)
objAutoComplete.cube_auto();
if (_fund != '' && !_IsDefaultDataSet) {
SetComboVal(objControls.cmbTraderFOF, _fund);
_IsDefaultDataSet = true;
}
}
PageBLL.prototype.FillBrokerAccountCombo = function () {
var autoCompleteCombos = new AutoCompleteCombos();
var objAutoComplete = autoCompleteCombos.FillAccounts(objControls.cmbBrokerAccount, objControls.hdnBrokerAccount, objControls.BrokerAccountComboSelectCallback, null, objAccountType.BROKERACCOUNT, objControls.hdnClient.val(), objControls.hdnBroker.val(), objControls.hdnTraderFOF.val());
objAutoComplete.cube_auto();
}
//Filling Report Module based on application id
PageBLL.prototype.FillReportModuleCombo = function (applicationID) {
var autoCompleteCombos = new AutoCompleteCombos();
var objAutoComplete = autoCompleteCombos.FillReportModules(objControls.cmbReportModule, objControls.hdnReportModule, null, null, null,
applicationID,objCommonEnums.ReportModuleFillingInfo.AllApplicationModules);
objAutoComplete.cube_auto();
}
//Filling Report Level based on application id
PageBLL.prototype.FillReportLevelCombo = function (applicationID) {
var autoCompleteCombos = new AutoCompleteCombos();
var objAutoComplete = autoCompleteCombos.FillReportLevels(objControls.cmbReportLevel, objControls.hdnReportLevel, function (event, ui) {
if (window.atob(ui.item.value) != addValueInCombo.All) {
_selectedLevelID = window.atob(objControls.hdnReportLevel.val());
}
else {
_selectedLevelID = null;
}
}, null, null, objCommonEnums.ReportLevelFillingInfo.OtherThanSystemLevel, applicationID);
objAutoComplete.cube_auto();
}
//Filling Report Category based on application id
PageBLL.prototype.FillReportCategoryCombo = function (applicationID) {
var autoCompleteCombos = new AutoCompleteCombos();
var objAutoComplete = autoCompleteCombos.FillReportCategories(objControls.cmbReportsCategory, objControls.hdnReportsCategory,
null, null, applicationID, null,objCommonEnums.ReportCategoryFillingInfo.AllApplicationCategories);
objAutoComplete.cube_auto();
}
PageBLL.prototype.FillClientTemplateTypeCombo = function () {
var autoCompleteCombos = new AutoCompleteCombos();
var objAutoComplete = autoCompleteCombos.FillClientTemplateTypes(objControls.cmbClientTemplateType, objControls.hdnClientTemplateType, null, null);
objAutoComplete.cube_auto();
}
PageBLL.prototype.FillExportFormatsCombo = function () {
var autoCompleteCombos = new AutoCompleteCombos();
var objAutoComplete = autoCompleteCombos.FillExportFormats(objControls.cmbFormat, objControls.hdnFormat, null, null);
objAutoComplete.cube_auto();
}
PageBLL.prototype.Load = function () {
objNotifications.Clear();
_isCallForEmpty = false;
objDAL.LoadClientReportConfigData();
}
PageBLL.prototype.Save = function () {
if (permission != false) {
objNotifications.Clear();
objDAL.SaveClientReportConfigData();
}
}
PageBLL.prototype.AddNewMergeReport = function () {
objNotifications.Clear();
objDAL.OpenAddNewMergeReport();
}
PageBLL.prototype.RowSelect = function (id) {
var pageNo = parseInt(objControls.tblClientReportGrid.getGridParam('page')) - 1;
var rows = parseInt(objControls.tblClientReportGrid.getGridParam('reccount'));
var rowObj = cube_GetRowJsonByID(objControls.tblClientReportGrid, id);
rowObj.id = parseInt(id) + (pageNo * rows);
if ($('#tblClientReportGrid_frozen').find('tr#' + id).find(':checkbox:first').is(':checked'))
rowObj.IsConfigured = objConstants.Yes;
else
rowObj.IsConfigured = objConstants.No;
if ($('#tblClientReportGrid_frozen').find('tr#' + id).find(':checkbox:eq(1)').is(':checked'))
rowObj.IsExport = objConstants.Yes;
else
rowObj.IsExport = objConstants.No;
var obj = commonBll.GetArrayItemsByID(_ModifiedPageRows, 'id', rowObj.id);
if (obj.length == 0)
_ModifiedPageRows.push(rowObj);
else {
obj[0].IsConfigured = rowObj.IsConfigured;
obj[0].IsExport = rowObj.IsExport;
}
}
PageBLL.prototype.RetainDataAfterPaging = function (id) {
if (_ModifiedPageRows.length == 0)
return;
var pageNo = parseInt(objControls.tblClientReportGrid.getGridParam('page')) - 1;
var rows = parseInt(objControls.tblClientReportGrid.getGridParam('reccount'));
var rowObj = cube_GetRowJsonByID(objControls.tblClientReportGrid, id);
var rowid = parseInt(id) + (pageNo * rows);
var obj = commonBll.GetArrayItemsByID(_ModifiedPageRows, 'id', rowid);
if (obj.length > 0) {
if (obj[0].IsConfigured.toUpperCase() == objConstants.Yes.toUpperCase()) {
$('#' + id).find(':checkbox:first').prop('checked', true);
$('#tblClientReportGrid_frozen').find('tr#' + id).find(':checkbox:first').prop('checked', true);
}
if (obj[0].IsExport.toUpperCase() == objConstants.Yes.toUpperCase()) {
$('#' + id).find(':checkbox:eq(1)').prop('checked', true);
$('#tblClientReportGrid_frozen').find('tr#' + id).find(':checkbox:eq(1)').prop('checked', true);
}
}
}
PageBLL.prototype.SetMandatoryFundsOnApplication = function () {
_isFundMandatory = commonBll.isApplicationAvailable(_fundMandatoryApps, objControls.hdnApplication.val());
if (!_isFundMandatory) {
objControls.lblFunds.removeClass('required');
objControls.cmbTraderFOF.removeClass('ns');
$('#cmbTraderFOF').rules('add', {
required: false // overwrite an existing rule
});
}
else {
objControls.lblFunds.addClass('required');
objControls.cmbTraderFOF.addClass('ns');
$('#cmbTraderFOF').rules('add', {
required: true, // overwrite an existing rule
messages: {
required: "Fund is required."
}
});
}
}
PageBLL.prototype.ValidateReportLevel = function () {
var levelID = addValueInCombo.All;
if (window.atob(objControls.hdnReportLevel.val()) == levelID || objControls.hdnReportLevel.val()=='') {
return true;
}
if (_accountID != null || _globalFundID != null || _globalBrokerID != null) {
if (_accountID != null) {
levelID = objCommonReportLevel.BrokerAccount.LevelID;
}
else if (_globalFundID != null) {
var accountDetails = commonBll.fileCache.AccountDetails;
var accountArr = commonBll.GetArrayItemsByID(accountDetails, 'GlobalFundID', _globalFundID);
var accountTypeArr = commonBll.GetArrayItemsOtherThenID(accountArr, 'AccountType', objAccountType.BROKERACCOUNT);
var accountType = null;
if (accountTypeArr.length > 0)
accountType = accountTypeArr[0].AccountType;
if (accountType != null) {
if (accountType.toUpperCase() == objAccountType.FOF) {
levelID = objCommonReportLevel.FundOfFund.LevelID;
}
else if (accountType.toUpperCase() == objAccountType.FUND) {
levelID = objCommonReportLevel.TraderOrFund.LevelID;
}
else if (accountType.toUpperCase() == objAccountType.PRORATA) {
levelID = objCommonReportLevel.ProRata.LevelID;
}
}
else {
return false;
}
}
else if (_globalBrokerID != null) {
levelID = objCommonReportLevel.Broker.LevelID;
}
}
else {
return true;
}
if (window.atob(objControls.hdnReportLevel.val()) == levelID) {
return true;
}
else {
if (levelID == objCommonReportLevel.TraderOrFund.LevelID && _isFundMandatory) {
return true;
}
else {
objControls.cmbReportLevel.addClass('input-validation-error');
return false;
}
}
}
PageBLL.prototype.ResetVariables = function () {
_globalClientID = null;
_globalFundID = null;
_globalBrokerID = null;
_accountID = null;
_lastSelectedBroker = addValueInCombo.All;
_lastSelectedTrader = null;
_lastSelectedClient = null;
}
function PageDAL() {
this.Init();
}
PageDAL.prototype.Init = function () {
InitalizeSystemInfo(userID, function () {
//Need to set application id here as this method "Initialize System Info" is a ajax method.
//and after getting system data such as modules, level, categories, we can apply application ID from session
//which in turn will filter modules, categories, level etc.
//If we use below code outside this Initialize System Info method, we wont be having modules/Categories/Level.
if (sessionApplicationID > 0) {
SetComboVal(objControls.cmbApplication, sessionApplicationID);
}
objBLL.FillExportFormatsCombo();
objBLL.FillClientTemplateTypeCombo();
});
}
PageDAL.prototype.SaveClientReportConfigData = function () {
if ($('#frmClientReportManage').valid())
SaveClientReportConfig();
}
PageDAL.prototype.LoadClientReportConfigData = function () {
//Todo: implement custom validation for dropdown select
if ($('#frmClientReportManage').valid()) {
if (objBLL.ValidateReportLevel()) {
loaderOn();
LoadGrid();
}
else {
objNotifications.Info('Report level should be same as least entity selected.');
}
}
}
PageDAL.prototype.OpenAddNewMergeReport = function () {
//Todo: implement custom validation for dropdown select
if ($('#frmClientReportManage').valid())
OpenMergeReportPopUp('Add');
}
$(function () {
objControls = new PageControls();
objBLL = new PageBLL();
objDAL = new PageDAL();
objControls.InitEvents();
_isCallForEmpty = true;
LoadGrid();
InitGridCheckBoxEvents();
});
//Function to load JQ Grid with configured and unconfigured reports of clients
function LoadGrid() {
if (!_isJqgridLoaded) {
$("#tblClientReportGrid").jqGrid('GridUnload');
_ModifiedPageRows = [];
objControls.tblClientReportGrid = $("#tblClientReportGrid");
var objGrid = new JqGrid();
objGrid.autoencode = true;
objGrid.$tbl = $("#tblClientReportGrid");
objGrid.caption = "Reports Configuration";
objGrid.url = 'LoadClientReportTemplates';
objGrid.datatype = 'json';
objGrid.postData = {
formData: $('form').serialize(), isCallForEmpty: _isCallForEmpty, isPagination: false, isFundMandatory : _isFundMandatory
};
objGrid.colNames = ['id', 'Configured', 'Enable For Export', 'Edit', 'Add', 'Report Name', 'ClientReportTemplateID', 'ReportTemplateID', 'ExportOldValue', 'ReportID', 'Data Sources',
'ModuleID', 'Report Module', 'LevelID', 'Report Level', 'Template Name', 'GlobalClientID', 'Client Name', 'EntityID', 'Entity Value', 'HardcodeType', 'Export Path', 'File Name',
'Zip Path', 'Zip File Name', 'Heading', 'IsMultipleBrokerAccountAllowed', 'AccountIDs', 'Client Template Type', 'Password', 'DefaultExportFormats',
'AvailableExportFormats', 'Format(s)', 'Zip (Exclude Formats)', 'Report Type', 'ReportTypeCode', 'HasPermission', 'Custom Attributes', 'Last Modified By', 'Last Modified Date'];
objGrid.colModel = [
{ name: 'id', index: 'id', width: 0, hidden: true, frozen: true },
{ name: 'IsConfigured', index: 'IsConfigured', align: 'center', width: 70, frozen: true, formatter: "checkbox", formatoptions: { disabled: false }, cellattr: AddNoClassToGridCells },
{ name: 'IsExport', index: 'IsExport', align: 'center', width: 115, frozen: true, formatter: "checkbox", formatoptions: { disabled: false }, cellattr: AddNoClassToGridCells },
{ name: 'Edit', index: 'Edit', width: 45, align: 'center', frozen: true, formatter: function () { return ""; }, cellattr: AddNoClassToGridCells },
{ name: 'Add', index: 'Add', width: 45, align: 'center', frozen: true, formatter: function () { return ""; }, cellattr: AddNoClassToGridCells },
{ name: 'ReportName', index: 'ReportName', width: 340, frozen: true, sortable: true },
{ name: 'ClientReportTemplateID', index: 'ClientReportTemplateID', width: 0, hidden: true },
{ name: 'ReportTemplateID', index: 'ReportTemplateID', width: 0, hidden: true },
{ name: 'ExportOldValue', index: 'ExportOldValue', width: 0, hidden: true },
{ name: 'ReportID', index: 'ReportID', width: 0, hidden: true },
{ name: 'DataSourceNames', index: 'DataSourceNames', width: 100 },
{ name: 'ModuleID', index: 'ModuleID', width: 0, hidden: true },
{ name: 'ReportModule', index: 'ReportModule', width: 130 },
{ name: 'LevelID', index: 'LevelID', width: 0, hidden: true },
{ name: 'ReportLevel', index: 'ReportLevel', width: 120 },
{ name: 'TemplateName', index: 'TemplateName', width: 350 },
{ name: 'GlobalClientID', index: 'GlobalClientID', width: 0, hidden: true },
{ name: 'ClientName', index: 'ClientName', width: 185 },
{ name: 'EntityID', index: 'EntityID', width: 0, hidden: true },
{ name: 'EntityValue', index: 'EntityValue', width: 200 },
{ name: 'HardcodeType', index: 'HardcodeType', width: 0, hidden: true },
{ name: 'FilePath', index: 'FilePath', width: 350, formatter: htmlFmatter },
{ name: 'FileName', index: 'FileName', width: 300, formatter: htmlFmatter },
{ name: 'ZipPath', index: 'ZipPath', width: 300, formatter: htmlFmatter, hidden: true },
{ name: 'ZipFileName', index: 'ZipFileName', width: 250, formatter: htmlFmatter, hidden: true },
{ name: 'Heading', index: 'Heading', width: 100 },
{ name: 'IsMultipleBrokerAccountAllowed', index: 'IsMultipleBrokerAccountAllowed', width: 0, hidden: true },
{ name: 'AccountIDs', index: 'AccountIDs', width: 0, hidden: true },
{ name: 'ClientTemplateType', index: 'ClientTemplateType', width: 140 },
{ name: 'Password', index: 'Password', width: 100 },
{ name: 'DefaultExportFormats', index: 'DefaultExportFormats', width: 0, hidden: true },
{ name: 'AvailableExportFormats', index: 'AvailableExportFormats', width: 0, hidden: true },
{ name: 'ExportFormats', index: 'ExportFormats', width: 130 },
{ name: 'ExcludeFormatsFromZip', index: 'ExcludeFormatsFromZip', width: 150 },
{ name: 'ReportType', index: 'ReportType', width: 120 },
{ name: 'ReportTypeCode', index: 'ReportTypeCode', width: 0, hidden: true },
{ name: 'HasPermission', index: 'HasPermission', width: 0, hidden: true },
{ name: 'CustomAttributes', index: 'CustomAttributes', width: 0, hidden: true },
{ name: 'LastModifiedBy', index: 'LastModifiedBy', width: 150 },
{ name: 'LastModifiedDate', index: 'LastModifiedDate', width: 150 }
];
objGrid.rowNum = 22;
objGrid.height = 505;
objGrid.pager = '#pjopt';
objGrid.emptyrecords = '';
objGrid.sortname = '';
objGrid.sortorder = '';
objGrid.width = null;
objGrid.shrinkToFit = false;
objGrid.viewrecords = true;
objGrid.onPaging = function () {
objControls.tblClientReportGrid.setGridParam({
postData: {
isPagination: true
}
});
};
objGrid.loadComplete = function () {
//If empty grid is called, show static empty grid with empty div msg
if (_isCallForEmpty)
return;
_isJqgridLoaded = true;
var $this = $(this), ids = $this.jqGrid('getDataIDs'), i, l = ids.length;
if (l === 0) {
$(this).hide();
emptyMsgDiv.show();
}
else {
$(this).show();
emptyMsgDiv.hide();
}
var $freezeTable = $('#tblClientReportGrid_frozen');
for (i = 0; i < l; i++) {
var rowId = ids[i], rowData = objControls.tblClientReportGrid.jqGrid('getRowData', rowId);
//Getting Report Module from Module ID
var module = commonBll.GetArrayItemsByID(commonBll.systemInfo.ModulesInfo, objConstants.ModuleID, rowData.ModuleID);
objControls.tblClientReportGrid.jqGrid('setCell', rowId, objConstants.ReportModule, module[0].ModuleDescription);
//Getting Report Level from Level ID
var level = commonBll.GetArrayItemsByID(commonBll.systemInfo.LevelInfo, objConstants.LevelID, rowData.LevelID);
objControls.tblClientReportGrid.jqGrid('setCell', rowId, objConstants.ReportLevel, level[0].LevelDescription);
//Getting Reporting Display Name from System Info
var reportingDisplayName = commonBll.GetArrayItemsByID(commonBll.systemInfo.SystemInfo, objConstants.Type, objConstants.ReportingDisplayName);
var clientID = rowData.GlobalClientID;
//Getting Client Name
var clientDetails = commonBll.GetArrayItemsByID(commonBll.fileCache.ClientDetails, commonBll.GetClientIDColumn(), clientID);
objControls.tblClientReportGrid.jqGrid('setCell', rowId, objConstants.ClientName, clientDetails[0].ClientName);
//Getting Entity Value
objControls.tblClientReportGrid.jqGrid('setCell', rowId, objConstants.EntityValue, commonBll.GetEntityValue(rowData.LevelID, rowData.EntityID, window.atob(objControls.hdnApplication.val())));
//Updating ClientTemplatetype value in grid
var rowClientTemplateType = rowData.ClientTemplateType;
if (rowClientTemplateType == 1) {
objControls.tblClientReportGrid.jqGrid('setCell', rowId, objConstants.ClientTemplateType, objConstants.Individual);
}
else if (rowClientTemplateType == 2) {
objControls.tblClientReportGrid.jqGrid('setCell', rowId, objConstants.ClientTemplateType, objConstants.Merged);
//For ClientTemplateType Merge, Disabling Add button on the grid
$(this).jqGrid('setColProp', 'Add', { editable: false });
}
//Changing row color if report is already configured
var ClientReportTemplateIDForGridRow = rowData.ClientReportTemplateID;
if (ClientReportTemplateIDForGridRow > 0) {
$('#' + $.jgrid.jqID(rowId)).addClass('rowcolor');
$freezeTable.find('#' + $.jgrid.jqID(rowId)).addClass('rowcolor');
}
//if hardcoded, then changed fore color of row to red
if (rowData.HardcodeType != objConstants.NoHardCoded) {
$('#' + $.jgrid.jqID(rowId)).addClass('forecolor');
$freezeTable.find('#' + $.jgrid.jqID(rowId)).addClass('forecolor');
}
//Filling Report Type from Report Type Code on each row in grid
if (rowData.ReportTypeCode == objCommonEnums.ReportType.ClientExternalReports.Code)
{
objControls.tblClientReportGrid.jqGrid('setCell', rowId, 'ReportType', objCommonEnums.ReportType.ClientExternalReports.Name);
}
else if (rowData.ReportTypeCode == objCommonEnums.ReportType.ClientInternalReports.Code)
{
objControls.tblClientReportGrid.jqGrid('setCell', rowId, 'ReportType', objCommonEnums.ReportType.ClientInternalReports.Name);
}
//If the formats are selected then show selected formats otherwise show default formats as selected formats
var formatSelected = (rowData.ExportFormats != '') ? rowData.ExportFormats : rowData.DefaultExportFormats;
objControls.tblClientReportGrid.jqGrid('setCell', rowId, 'ExportFormats', formatSelected);
if (rowData.IsMultipleBrokerAccountAllowed.toUpperCase() == 'TRUE') {
var labels = commonBll.GetBrokerAccountsNameWithIDs(rowData, clientID);
objControls.tblClientReportGrid.jqGrid('setCell', rowId, objConstants.EntityValue, labels);
}
if (rowData.HasPermission.toUpperCase() == 'FALSE') {
$('#' + $.jgrid.jqID(rowId)).removeClass('rowcolor').addClass('disable');
$freezeTable.find('#' + $.jgrid.jqID(rowId)).removeClass('rowcolor').addClass('disable');
$freezeTable.find('#' + $.jgrid.jqID(rowId)).find('.no-tooltip').html('');
}
objBLL.RetainDataAfterPaging(rowId);
}
objControls.tblClientReportGrid.find('tr').not('.jqgfirstrow').each(function (loopIdx, loopObj) {
$('#tblClientReportGrid_frozen').find('#' + $(this).prop('id')).height($(this).height());
});
loaderOff();
commonBll.AttachTooltipToGridCell();
}
objGrid.Init();
emptyMsgDiv.insertAfter(objControls.tblClientReportGrid.parent());
}
else {
ReloadGrid();
}
objControls.tblClientReportGrid.jqGrid('setFrozenColumns');
}
function htmlFmatter(cellvalue, options, rowObject) {
var curVal = $.trim(cellvalue).replace(/ /g, ' ');
return commonBll.HtmlToRawText(curVal);
}
//Reloading Grid
function ReloadGrid() {
_ModifiedPageRows = [];
objControls.tblClientReportGrid.GridDestroy();
objControls.tblClientReportGridContainer.html('
');
_isJqgridLoaded = false;
LoadGrid();
}
function OpenClientReportPopUp(me, formmode) {
var id = $(me).closest('tr').prop('id');
var selectedApplicationName = objControls.cmbApplication.val();
var selectedApplicationID = objControls.hdnApplication.val();
selectedRowJson = cube_GetRowJsonByID(objControls.tblClientReportGrid, id);
selectedRowJson.selectedApplicationName = selectedApplicationName;
selectedRowJson.selectedApplicationID = selectedApplicationID;
selectedRowJson.formmode = formmode;
selectedRowJson.permission = permission;
if (formmode.toUpperCase() == objConstants.Edit.toUpperCase()) {
//Open Client Add Edit form
if (selectedRowJson.ClientTemplateType.toUpperCase() == objConstants.Individual.toUpperCase()) {
selectedRowJson.Action = (selectedRowJson.ClientReportTemplateID != 0) ? window.btoa(objConstants.ActionUpdate) : window.btoa(objConstants.ActionInsert);
$('#iframePopUp').prop('src', '../Admin/ClientReportAddEdit?globalClientID=' + (selectedRowJson.GlobalClientID == null ? null : window.btoa(selectedRowJson.GlobalClientID)) +
'&applicationID=' + objControls.hdnApplication.val() +
'&reportID=' + (selectedRowJson.ReportID == null ? null : window.btoa(selectedRowJson.ReportID)) +
'&levelID=' + (selectedRowJson.LevelID == null ? null : window.btoa(selectedRowJson.LevelID)));
$('#popDiv').fadeIn(500);
}
else if (selectedRowJson.ClientTemplateType.toUpperCase() == objConstants.Merged.toUpperCase()) {
//Open Merge Form
OpenMergeReportPopUp(objConstants.Edit);
}
}
else if (formmode.toUpperCase() == objConstants.Add.toUpperCase()) {
if (selectedRowJson.ClientTemplateType.toUpperCase() == objConstants.Individual.toUpperCase()) {
selectedRowJson.Action = window.btoa(objConstants.ActionInsert);
$('#iframePopUp').prop('src', '../Admin/ClientReportAddEdit?globalClientID=' + (selectedRowJson.GlobalClientID == null ? null : window.btoa(selectedRowJson.GlobalClientID)) +
'&applicationID=' + objControls.hdnApplication.val() +
'&reportID=' + (selectedRowJson.ReportID == null ? null : window.btoa(selectedRowJson.ReportID)) +
'&levelID=' + (selectedRowJson.LevelID == null ? null : window.btoa(selectedRowJson.LevelID)));
$('#popDiv').fadeIn(500);
}
}
}
function OpenMergeReportPopUp(formMode) {
jsonForMergeReport = [];
var globalClientID = null;
var applicationName = objControls.cmbApplication.val();
var clientName = objControls.cmbClient.val();
var applicationID = objControls.hdnApplication.val();
var clientReportTemplateID = null;
var mergeAction = window.btoa('I');
if (formMode.toUpperCase() == objConstants.Edit.toUpperCase()) {
if (selectedRowJson != '' || selectedRowJson != null) {
clientReportTemplateID = selectedRowJson.ClientReportTemplateID;
}
mergeAction = window.btoa(objConstants.ActionUpdate);
}
globalClientID = objControls.hdnClient.val();
tempdata = {
globalClientID: globalClientID,
applicationName: applicationName,
clientName: clientName,
applicationID: applicationID,
clientReportTemplateID: (clientReportTemplateID == null || clientReportTemplateID == '') ? null : window.btoa(clientReportTemplateID),
Action: mergeAction,
formMode: formMode,
permission: permission
}
jsonForMergeReport.push(tempdata);
// We can't pass null in query string as it raise the MVC validation controller on DOM ready.
var qsGlobalFundID = 0;
if (_globalFundID != null)
qsGlobalFundID = _globalFundID;
$('#iframePopUpMerge').prop('src', '../Admin/MergedReportAddEdit?&clientReportTemplateID=' + ((clientReportTemplateID == null || clientReportTemplateID == '') ? null : window.btoa(clientReportTemplateID)) + "&applicationID=" + applicationID + "&globalClientID=" + _globalClientID + "&globalFundID=" + qsGlobalFundID);
$('#popDivMerge').fadeIn(500);
}
function SaveClientReportConfig() {
var clientReportTemplateJsonSave = [];
var applicationID = window.atob(objControls.hdnApplication.val());
for (var i = 0; i < _ModifiedPageRows.length; i++) {
var row = _ModifiedPageRows[i];
var rowAction = SetAction(row);
if (!IsConfigurationValid(row, applicationID)) {
return;
}
if (rowAction != null) {
var exportValue = false;
if (row.IsExport.toUpperCase() == objConstants.Yes.toUpperCase()) {
exportValue = true;
}
clientReportTemplateJsonSave.push({
ClientReportTemplateID: parseInt(row.ClientReportTemplateID),
ReportTemplateID: parseInt(row.ReportTemplateID),
Action: rowAction,
IsExport: exportValue,
ApplicationID: parseInt(applicationID),
GlobalClientID: parseInt(row.GlobalClientID),
LevelID: row.LevelID,
EntityID: row.EntityID
});
}
}
if (clientReportTemplateJsonSave.length == 0) {
objNotifications.Info('No changes have been made on Configured column to be saved', null);
return;
}
objNotifications.Confirmation('Do you want to Save?', function () {
//Call Method to Post data for export
var ajax = new Ajax();
ajax.url = 'SaveClientReportConfig';
ajax.httpMethod = 'POST';
ajax.isAngular = false;
ajax.isXHR = true;
ajax.param = { clientReportsCol: clientReportTemplateJsonSave, promptToDeleteFromPackage: objConstants.Yes, globalClientID: _globalClientID, globalFundID: _globalFundID, globalBrokerID: _globalBrokerID, accountID: _accountID, formLevelID: _selectedLevelID };
ajax.Success = function (returnedData) {
if (returnedData.returnValue == -2 && returnedData.errorMessage != null && returnedData.errorMessage != '') {
objNotifications.Confirmation(returnedData.errorMessage + 'Do you want to continue?', function () {
var ajaxConfirm = new Ajax();
ajaxConfirm.url = 'SaveClientReportConfig';
ajaxConfirm.httpMethod = 'POST';
ajaxConfirm.isAngular = false;
ajaxConfirm.isXHR = true;
ajaxConfirm.param = { clientReportsCol: clientReportTemplateJsonSave, promptToDeleteFromPackage: objConstants.No, globalClientID: _globalClientID, globalFundID: _globalFundID, globalBrokerID: _globalBrokerID, accountID: _accountID, formLevelID: _selectedLevelID };
ajaxConfirm.Success = function (dataAfterConfirm) {
if (dataAfterConfirm.returnValue == -1 && dataAfterConfirm.errorMessage != null && dataAfterConfirm.errorMessage != '') {
objNotifications.Error(dataAfterConfirm.errorMessage, null);
}
else if (dataAfterConfirm.returnValue == 0) {
objNotifications.Info('Report Configuration successfully saved.', null);
ReloadGrid();
}
else if (dataAfterConfirm.returnValue > objConstants.ErrorCodeNumber_50000 && dataAfterConfirm.returnValue < ErrorCodeNumber_50100) {
objNotifications.Error(dataAfterConfirm.errorMessage, null);
}
};
ajaxConfirm.Error = function (dataAfterConfirm) {
//objNotifications.Error(dataAfterConfirm.errorMessage, null);
};
ajaxConfirm.Init();
}, null);
}
else if (returnedData.returnValue == -1 && returnedData.errorMessage != null && returnedData.errorMessage != '') {
objNotifications.Error(returnedData.errorMessage, null);
}
else if (returnedData.returnValue == 0) {
objNotifications.Info('Report Configuration successfully saved.', null);
ReloadGrid();
}
};
ajax.Error = function (returnedData) {
// Test case : Return Value : Msg
// success : 0 : none
// failure : -1 : dynamic system msg
// confirmation : -2 : validation out
// raise error : 50001-50100 : set error msg
//objNotifications.Error(returnedData.errorMessage, null);
};
ajax.Init();
}, null);
}
//Validate all validation on save
function IsConfigurationValid(rowData, applicationID) {
var clientReportTemplateID = rowData.ClientReportTemplateID, isConfigured = rowData.IsConfigured.replace(/\s/g, "").toUpperCase(), exportValue = rowData.IsExport, hardcodeType = rowData.HardcodeType;
//if any report row is updated and export is On and configured is off
if (clientReportTemplateID == 0 && isConfigured == objConstants.No.toUpperCase() && exportValue.replace(/\s/g, "").toUpperCase() == objConstants.Yes.toUpperCase()) {
objNotifications.Error('User can not set \"Enable for Export\" On, if report is not configured in system', null);
return false;
}
//if any report row is hardcoded
if (clientReportTemplateID == 0 && isConfigured == objConstants.Yes.toUpperCase() && hardcodeType != objConstants.NoHardCoded) {
objNotifications.Error('User can not set \"Configure\" On, if report is hardcoded in system', null);
return false;
}
//Tags validations
//1. We only need to validate tags when user wants to configure report, not when user is unconfiguring configured reports
if (isConfigured == objConstants.Yes.toUpperCase()) {
if (!ValidateReportPathFileNameAndTagsInGrid(rowData, applicationID)) {
return false;
}
}
return true;
}
//Validate tags and path for report configuration
function ValidateReportPathFileNameAndTagsInGrid(rowData, applicationID) {
//Extracting useful data from each row
var zipPath = $.trim(rowData.ZipPath), zipFileName = $.trim(rowData.ZipFileName), fileName = $.trim(rowData.FileName), filePath = $.trim(rowData.FilePath);
var reportLevel = rowData.ReportLevel.replace(/\s/g, "").toUpperCase(), levelID = rowData.LevelID, reportTypeCode = rowData.ReportTypeCode, isReportTypeExternal = true;
var validMessageForGrid = '';
//1. Getting Report Type of each report row and passing it to validate tags method to check whether tag should be made mandatory or not.
//2. If Report Type is Client Internal, database will give internal path kept at application level.
//3. hence , we don't need tag to be mandatory
//4. For Client External, and for Only NAV RTA, tag is mandatory.
if(reportTypeCode != objCommonEnums.ReportType.ClientExternalReports.Code)
isReportTypeExternal = false;
//If user has entered only zip file path, show error
if (zipPath.length > 0) {
if (zipFileName.length <= 0) {
validMessageForGrid += 'Report Zip File Name cannot be blank, if Zip path is available.';
}
}
//If user has entered only zip file name, show error
if (zipFileName.length > 0) {
if (zipPath.length <= 0) {
validMessageForGrid += 'Report Zip path cannot be blank, if Zip File Name is available.';
}
}
//Validating Tags for File Path
validMessageForGrid += validateTextBoxTags(filePath, 'txtFilePath', reportLevel, 'ClientReportManage');
//Validating Tags for File Name
validMessageForGrid += validateTextBoxTags(fileName, 'txtFileName', reportLevel, 'ClientReportManage');
//Validating Tags for ZIP Path
validMessageForGrid += validateTextBoxTags(zipPath, 'txtZipPath', reportLevel, 'ClientReportManage');
//Validating Tags for ZIP File Name
validMessageForGrid += validateTextBoxTags(zipFileName, 'txtZipFileName', reportLevel, 'ClientReportManage');
//Validating File Path
validMessageForGrid += PathValidation(filePath, 'txtFilePath', 'ClientReportManage', applicationID, levelID, isReportTypeExternal);
//Validating ZIP File Path
validMessageForGrid += PathValidation(zipPath, 'txtZipPath', 'ClientReportManage', applicationID);
//If any validation fails, then break and show msg for that template
if (validMessageForGrid.length > 0) {
var validationMessage = '
';
validationMessage += '
Check below validation for Template: ' + rowData.TemplateName + '
' + validMessageForGrid + '';
objNotifications.Error(validationMessage);
return false;
}
return true;
}
function SetAction(selectedRowJson) {
var clientReportTemplateID = 0;
var action;
var ExportOldValue = objConstants.No;
if (selectedRowJson.ExportOldValue.toUpperCase() == objConstants.True.toUpperCase()) {
ExportOldValue = objConstants.Yes;
}
if (selectedRowJson.ClientReportTemplateID != 0) {
clientReportTemplateID = selectedRowJson.ClientReportTemplateID;
}
if (selectedRowJson.ClientReportTemplateID == 0 && selectedRowJson.IsConfigured.toUpperCase() == objConstants.No.toUpperCase()) {
action = null;
}
else if (clientReportTemplateID == 0 && selectedRowJson.IsConfigured.toUpperCase() == objConstants.Yes.toUpperCase()) {
action = objConstants.ActionInsert;
}
else if (clientReportTemplateID > 0 && selectedRowJson.IsConfigured.toUpperCase() == objConstants.No.toUpperCase()) {
action = objConstants.ActionDelete;
}
else if (clientReportTemplateID > 0 && selectedRowJson.IsConfigured.toUpperCase() == objConstants.Yes.toUpperCase() && ExportOldValue.toUpperCase() != selectedRowJson.IsExport.toUpperCase()) {
action = objConstants.ActionUpdate;
}
else {
action = null;
}
return action;
}
function CloseiFrameClientReportAddEditPopup(SentFrom) {
$('iframePopUp').hide();
$('#popDiv').fadeOut(500);
ReloadClientReportManageGrid(SentFrom);
}
function CloseiFrameMergeReportPopup(SentFrom) {
$('iframePopUpMerge').hide();
$('#popDivMerge').fadeOut(500);
ReloadClientReportManageGrid(SentFrom);
}
function ReloadClientReportManageGrid(value) {
if (value.replace(/\s/g, "").toUpperCase() == objConstants.Save.toUpperCase()) {
LoadGrid1();
}
}
function InitGridCheckBoxEvents() {
$('body').on('change', '#tblClientReportGrid_frozen input', function () {
objBLL.RowSelect(parseInt($(this).closest('tr').prop('id')));
});
}
function AddNoClassToGridCells(rowId, val, rawObject, cm, p, randomClass) {
return ' class="no-tooltip"';
}
=========================================================
function Ajax() {
this.httpMethod = 'GET';
this.param = [];
this.url = null;
this.Success = function () {
};
this.Error = function () {
};
this.isGoforCombos = false;
this.isAngular = true;
this.removeLoaderManual = false;
this.isXHR = false;
this.async = true;
this.dataType = 'json';
this.contentType = 'application/json; charset=utf-8';
this.isFormData = false;
}
var isAutoOff = true;
function loaderOn(isAutoMate) {
if (isAutoMate == false)
isAutoOff = false;
if ($('#loader').length == 0)
$('body').append('
');
}
function loaderOff(isAutoMate) {
if (isAutoMate)
isAutoOff = true;
if (isAutoOff) {
$('#loader').remove();
}
}
Ajax.prototype.Init = function ($http, isLoaderOff) {
var self = this;
if ($('#loader').length == 0 && typeof isLoaderOff == _commonEnum.undefined)
loaderOn();
if (xhr && self.isXHR) {
xhr.abort();
}
self.param.isCalledFromJquery = true;
xhr = $.ajax({
url: self.url,
type: self.httpMethod,
data: (!self.isFormData) ? JSON.stringify(self.param) : self.param,
async: self.async,
success: function (data, textStatus, c) {
if (!self.removeLoaderManual && !commonBll.IsNotEmpty(isLoaderOff))
loaderOff();
if (commonBll.IsNotEmpty(data.errorCode)
&& data.errorCode == 230) {
var objNotification = new Notification();
if (data.errorType.toUpperCase() == "EXCEPTION")
objNotification.Error(data.error, null);
else
objNotification.Info(data.error, null);
}
else {
self.Success(data);
}
},
error: function (a, b, c) {
if (a.status == 230)
$('body').html(' 230 ' + a.responseText);
else if (a.status != 200 && a.statusText.toUpperCase() != 'ABORT') {
var objNotification = new Notification();
objNotification.Error(a.responseJSON.error, null);
loaderOff(true);
}
else if (a.status == 200) {
loaderOff(true);
}
if (!self.removeLoaderManual && typeof isLoaderOff == _commonEnum.undefined)
loaderOff();
self.Error(a);
},
dataType: (!self.isFormData) ? self.dataType : false,
cache: (self.isFormData) ? false : null,
contentType: (!self.isFormData) ? self.contentType : false,
processData: (self.isFormData) ? false : null
});
}

Answers (1)