var Bizgaze;
(function (Bizgaze) {
let Apps;
(function (Apps) {
let Transact;
(function (Transact) {
let Controls;
(function (Controls) {
class BalanceSheetIndexing extends Unibase.Platform.Core.BaseComponent {
cssFiles() {
return [];
}
jsFiles() {
return ["apps/transact/controls/ledgers/balancesheetindexing.js"];
}
html(id, containerid) {
var instance = this;
let formid = 0, configrationid = 0;
var _installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
Unibase.Platform.Apps.Managers.AppManager.Instance().getFormAppConfigurations(Number(_installedAppId)).then(function (response) {
if (response.result != null) {
var d = response.result;
}
});
let html = '
' +
'' +
'';
return html;
}
load(id, containerid, callback) {
var instance = this;
instance.fileCacheHelper.loadJsFile('apps/transact/managers/ledgers/ledgermanager.js', function () {
var _installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
var reporttypeid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + _installedAppId + "_reporttypeid").Value);
Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().AllBalanceSheetIndexes(reporttypeid).then(function (response) {
var reporttypeid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + _installedAppId + "_reporttypeid").Value);
instance.loadlist(response);
});
});
instance.navigationHelper.popup("", "", Bizgaze.Apps.Transact.Controls.BalanceSheetIndexing.Instance(), function () {
}, Unibase.Platform.Helpers.Size.Large);
}
init() {
var instance = this;
instance.load(0, "", null);
}
loadlist(response) {
var html1 = '';
var instance = this;
$('.balance_indexing').append(html1);
var _installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
Bizgaze.Apps.Transact.Controls.BalanceSheetIndexing.Instance().ledgertypeAutoComplete(0);
$('#txt_Ledgertype_TRN20').change(function () {
Bizgaze.Apps.Transact.Controls.BalanceSheetIndexing.Instance().ledgerGroupAutoComplete(0);
$("#txt_Groups_TRN0").text("");
});
$(".btn_BalanceSheetClose").click(function () {
instance.navigationHelper.closePopUp();
});
$('#ul_BalanceSheets').sortable({
update: function (event, ui) {
$("#ul_BalanceSheets").each(function () {
let ul = $("#ul_BalanceSheets li");
for (var i = 0; i < ul.length; i++) {
let id = $(ul[i]).attr("id");
$("#" + id + " .BS_Index").text(i + 1);
$("#" + id).attr("data-id", i + 1);
}
});
}
});
$(".btn_AddBalSheetS").off().click(function () {
for (var inc = 1; inc <= 1; inc++) {
$('#form_balancesheetindexing select').each(function (i, e) {
let controlId = $(e).attr('id');
let result = Unibase.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation(controlId);
if (result == false) {
return false;
}
});
var balsheetids = [];
var i = $("#ul_BalanceSheets").find(".list-group-item").length + 1;
var groupid = $('#txt_Groups_TRN0').val();
var typeid = $('#txt_Ledgertype_TRN20').val();
var _installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
var identity = "";
var reporttypeid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + _installedAppId + "_reporttypeid").Value.toString();
if (groupid == null && typeid == null) {
MessageHelper.Instance().showError('Group and Type are mandatory ', 'Balancesheet_errormsg');
}
else {
balsheetids.push({
Groupid: groupid,
Typeid: typeid,
reportypeid: reporttypeid,
index: i.toString(),
installedappid: _installedAppId,
identity: identity
});
if (groupid != null && typeid != null) {
Bizgaze.Apps.Transact.Controls.BalanceSheetIndexing.Instance().SaveBalSheetIndex(balsheetids);
$('#txt_Groups_TRN0').text(null);
$('#txt_Groups_TRN0').val(null);
$('#txt_Ledgertype_TRN20').val(null);
$('#txt_Ledgertype_TRN20').text(null);
$('#txtsheetidentity').val(null);
}
}
}
});
$(".btn_BalSheetSave").click(function () {
var balsheetids = [];
$("#ul_BalanceSheets").find(".list-group-item").each(function () {
var balsheetid = $(this).find("#hfBalSheetId").val();
if (balsheetid != 0) {
balsheetids.push(balsheetid);
}
});
var postdata = {
Ids: balsheetids
};
instance.UpdateBalSheetIndex(postdata);
});
let BalanceSheetHeaderHeight = $(".BalanceSheetHeader").outerHeight(true);
let BalanceSheetFooterHeight = $(".BalanceSheetFooter").outerHeight(true);
let BalanceSheetBodyPaddingHeight = parseInt($('.BalanceSheetBody').css('padding-top')) + parseInt($('.BalanceSheetBody').css('padding-bottom'));
let BalanceSheetFormHeight = $('#form_balancesheetindexing').outerHeight(true);
let totalBalanceSheetsHeight = BalanceSheetHeaderHeight + BalanceSheetFooterHeight + BalanceSheetBodyPaddingHeight + BalanceSheetFormHeight;
$("#ul_BalanceSheets").css({ 'height': `${$(window).innerHeight() - totalBalanceSheetsHeight}px`, 'overflow-y': 'overlay' }).attr('data-deductheight', `${totalBalanceSheetsHeight}`);
}
SaveBalSheetIndex(postdata) {
var instance = this;
instance.fileCacheHelper.loadJsFile('apps/transact/managers/ledgers/ledgermanager.js', function () {
Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().SaveBalSheetIndex(postdata).then(function (response) {
var info = response.result;
if (info != null) {
$('.balance_indexing').empty();
Bizgaze.Apps.Transact.Controls.BalanceSheetIndexing.Instance().loadlist(response);
}
else {
MessageHelper.Instance().showError(response.message, 'Balancesheet_errormsg');
}
});
});
}
UpdateBalSheetIndex(postdata) {
var instance = this;
instance.fileCacheHelper.loadJsFile('apps/transact/managers/ledgers/ledgermanager.js', function () {
Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().UpdateBalanceSheetIndexes(postdata).then(function (response) {
Unibase.Platform.Helpers.NavigationHelper.Instance().closePopUp();
var detail_instance = Unibase.Themes.Compact.Components.Details.Instance();
var containerid = $("._bizgaze_detail_container:visible").attr("id");
var _installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
var portletid = detail_instance.unibase_core_activeportletid;
detail_instance.loadWidgets(_installedAppId, portletid, "#" + containerid + "");
MessageHelper.Instance().showSuccess(response.message, '');
});
});
}
ledgerGroupAutoComplete(LedgerGroupId) {
var ledgertypeid = Number($('#txt_Ledgertype_TRN20').val());
var url = _appsettings.server_url() + '/apis/v4/bizgaze/transact/ledgers/ledgergroupautocomplete/ledgertypeid/' + ledgertypeid;
AutoCompleteHelper.getHelper().Create("#txt_Groups_TRN0", "#hf_LedgerGroupIdSelected_TRN0", url, function (response) {
var data = response;
});
}
ledgertypeAutoComplete(LedgertypeId) {
var url = _appsettings.server_url() + '/apis/v4/bizgaze/transact/ledgers/ledgertypeautocomplete';
AutoCompleteHelper.getHelper().Create("#txt_Ledgertype_TRN20", "#hf_LedgerGroupIdSelected_TRN0", url, function (response) {
var data = response;
});
}
static Instance() {
if (this.instance === undefined) {
this.instance = new BalanceSheetIndexing();
}
return this.instance;
}
}
Controls.BalanceSheetIndexing = BalanceSheetIndexing;
})(Controls = Transact.Controls || (Transact.Controls = {}));
})(Transact = Apps.Transact || (Apps.Transact = {}));
})(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
})(Bizgaze || (Bizgaze = {}));