';
$("." + Containerid).html(html);
}
load(Containerid) {
}
init(Containerid) {
let instance = this;
var jsfiles = ["platform/forms/components/formviewer/formviewer.js", 'libs/parsley/parsley.min.js'];
SelfDeclaration.Instance().fileCacheHelper.loadJsFiles(jsfiles, function () {
SelfDeclaration.Instance().loadhtml(Containerid);
$("#btn_Close").click(function () {
SelfDeclaration.Instance().navigationHelper.closePopUp();
});
var tenantname = "";
Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () {
Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().GetTenants(Number(Unibase.Platform.Membership.Infos.Identity.getCurrentUser().tenantId)).then(function (res) {
if (res.result != null) {
tenantname = res.result.TenantName;
$("#lblDistributorName1").text(tenantname.toString());
$("#lblDistributorName2").text(tenantname.toString());
}
});
});
$("#userName1").text(Unibase.Platform.Membership.Infos.Identity.getCurrentUser().name);
$("#lblDistributorName1").text(tenantname.toString());
$("#lblDistributorName2").text(tenantname.toString());
$("#userName2").text(Unibase.Platform.Membership.Infos.Identity.getCurrentUser().name);
var TotalDate = new Date();
var months = ["JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"];
var date = TotalDate.getDate();
var month = TotalDate.getMonth() + 1;
var year = TotalDate.getFullYear();
if (months[TotalDate.getMonth()] == "DECEMBER") {
year = year - 1;
}
$('#MonthAndYear1').text(months[TotalDate.getMonth()] + "-" + year);
$('#MonthAndYear2').text(months[TotalDate.getMonth()] + "-" + year);
$('#CurrentDate').text(date + "/" + month + "/" + year);
$('#DeclarationMonthI_e_PreviousMonth').text(months[TotalDate.getMonth()]);
var todayDate = new Date($.now());
var serverdate = instance._dateTimeHelper.formatServerDate(todayDate);
var OnlyDate = serverdate.split("/");
if (Number(OnlyDate[2]) >= 1 && Number(OnlyDate[2]) <= 10) {
$("#btnSubmit").prop('disabled', false);
}
else {
$("#btnSubmit").prop('disabled', true);
}
if (Number(OnlyDate[2]) > 10) {
$("#btnSubmit").hide();
$("#isSelfDeclared").hide();
$("#description").hide();
}
SelfDeclaration.Instance().Enable();
$('#btnSubmit').click(function () {
SelfDeclaration.Instance().save();
});
});
}
Enable() {
let instance = this;
var da = new Date($.now());
var date = instance._dateTimeHelper.formatServerDate(da);
date = date.replace('/', '-').replace('/', '-');
var month = $('#DeclarationMonthI_e_PreviousMonth').text();
Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () {
Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getSelfDeclarationByDate(date, month).then(function (response) {
if (response.result == "Record not Found") {
$("#btnSubmit").prop("disabled", false);
}
else {
$("#btnSubmit").prop("disabled", true);
$('#btnSubmit').prop('value', 'Submitted');
$("#isSelfDeclared").prop('checked', true);
$("#isSelfDeclared").prop("disabled", true);
}
});
});
}
save() {
var date = Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate();
var IsDeclared = $("#isSelfDeclared").prop('checked');
if (IsDeclared == false) {
MessageHelper.Instance().showError('Please Check Declaration', 'bizgaze_CreateErrorMessages');
return false;
}
var data = {
PciDeclared: IsDeclared,
UserId: Unibase.Platform.Membership.Infos.Identity.getCurrentUser().userId,
DeclarationDate: new Date(),
MonthOfDeclaration: $('#DeclarationMonthI_e_PreviousMonth').text(),
PartitionId: Unibase.Platform.Membership.Infos.Identity.getCurrentUser().partitionId
};
Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().saveSelfDeclaration(data).then(function (response) {
MessageHelper.Instance().showSuccess(response.message, '');
$("#isSelfDeclared").prop('checked', true);
$("#isSelfDeclared").prop("disabled", true);
$('#btnSubmit').prop('value', 'Submitted');
});
}
static Instance() {
if (this.instance === undefined) {
this.instance = new SelfDeclaration();
}
return this.instance;
}
}
Components.SelfDeclaration = SelfDeclaration;
})(Components = Crm.Components || (Crm.Components = {}));
})(Crm = Apps.Crm || (Apps.Crm = {}));
})(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
})(Bizgaze || (Bizgaze = {}));