var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var Bizgaze; (function (Bizgaze) { let Apps; (function (Apps) { let Hrms; (function (Hrms) { let Components; (function (Components) { class ShiftCalender extends Unibase.Platform.Core.BaseComponent { constructor() { super(...arguments); this.holidaycalendar = new Array(); this.firstweekcheckedarray = []; this.secondweekcheckedarray = []; this.thirdweekcheckedarray = []; this.fourthweekcheckedarray = []; this.fifththweekcheckedarray = []; } init(formpropertyid, prop, callback) { var instance = this; this.holidaycalendar = []; this.firstweekcheckedarray = []; this.secondweekcheckedarray = []; this.thirdweekcheckedarray = []; this.fourthweekcheckedarray = []; this.fifththweekcheckedarray = []; $('#SelectAllSunday').change(function () { let checkelemnt = $(this).is(':checked'); if (checkelemnt == true) { $(".Sunday").prop("checked", true); } else { $(".Sunday").prop("checked", false); } }); $(".Sunday").click(function () { let checkelemnt = $(this).is(':checked'); if (checkelemnt == true) { $(this).prop("checked", true); } else { $(this).prop("checked", false); } }); $('#SelectAllMonday').change(function () { let checkelemnt = $(this).is(':checked'); if (checkelemnt == true) { $(".Monday").prop("checked", true); } else { $(".Monday").prop("checked", false); } }); $(".Monday").click(function () { let checkelemnt = $(this).is(':checked'); if (checkelemnt == true) { $(this).prop("checked", true); } else { $(this).prop("checked", false); } }); $('#SelectAllTuesday').change(function () { let checkelemnt = $(this).is(':checked'); if (checkelemnt == true) { $(".Tuesday").prop("checked", true); } else { $(".Tuesday").prop("checked", false); } }); $(".Tuesday").click(function () { let checkelemnt = $(this).is(':checked'); if (checkelemnt == true) { $(this).prop("checked", true); } else { $(this).prop("checked", false); } }); $('#SelectAllWednesday').change(function () { let checkelemnt = $(this).is(':checked'); if (checkelemnt == true) { $(".Wednesday").prop("checked", true); } else { $(".Wednesday").prop("checked", false); } }); $(".Wednesday").click(function () { let checkelemnt = $(this).is(':checked'); if (checkelemnt == true) { $(this).prop("checked", true); } else { $(this).prop("checked", false); } }); $('#SelectAllThursday').change(function () { let checkelemnt = $(this).is(':checked'); if (checkelemnt == true) { $(".Thursday").prop("checked", true); } else { $(".Thursday").prop("checked", false); } }); $(".Thursday").click(function () { let checkelemnt = $(this).is(':checked'); if (checkelemnt == true) { $(this).prop("checked", true); } else { $(this).prop("checked", false); } }); $('#SelectAllFriday').change(function () { let checkelemnt = $(this).is(':checked'); if (checkelemnt == true) { $(".Friday").prop("checked", true); } else { $(".Friday").prop("checked", false); } }); $(".Friday").click(function () { let checkelemnt = $(this).is(':checked'); if (checkelemnt == true) { $(this).prop("checked", true); } else { $(this).prop("checked", false); } }); $('#SelectAllSaturday').change(function () { let checkelemnt = $(this).is(':checked'); if (checkelemnt == true) { $(".Saturday").prop("checked", true); } else { $(".Saturday").prop("checked", false); } }); $(".Saturday").click(function () { let checkelemnt = $(this).is(':checked'); if (checkelemnt == true) { $(this).prop("checked", true); } else { $(this).prop("checked", false); } }); $(".fifthweek").click(function () { let checkelemnt = $(this).is(':checked'); let day = $(this).val(); var splt = day.toString().split(':'); let dayname = splt[0]; let dayval = Boolean(splt[1]); let weekday = { [dayname]: dayval }; if (checkelemnt == true) { $(this).prop("checked", true); instance.fifththweekcheckedarray.push({ [dayname]: dayval }); console.log(instance.fifththweekcheckedarray); } else { $(this).prop("checked", false); let newArray = []; for (let i = 0; i < instance.fifththweekcheckedarray.length; i++) { if (JSON.stringify(instance.fifththweekcheckedarray[i]) !== JSON.stringify(weekday)) { newArray.push(instance.fifththweekcheckedarray[i]); } } instance.fifththweekcheckedarray = []; instance.fifththweekcheckedarray = newArray; console.log(instance.fifththweekcheckedarray); } }); $(".firstweek").click(function () { let checkelemnt = $(this).is(':checked'); let day = $(this).val(); var splt = day.toString().split(':'); let dayname = splt[0]; let dayval = Boolean(splt[1]); let weekday = { [dayname]: dayval }; if (checkelemnt == true) { $(this).prop("checked", true); instance.firstweekcheckedarray.push({ [dayname]: dayval }); console.log(instance.firstweekcheckedarray); } else { $(this).prop("checked", false); let newArray = []; for (let i = 0; i < instance.firstweekcheckedarray.length; i++) { if (JSON.stringify(instance.firstweekcheckedarray[i]) != JSON.stringify(weekday)) { newArray.push(instance.firstweekcheckedarray[i]); } } instance.firstweekcheckedarray = []; instance.firstweekcheckedarray = newArray; console.log(instance.firstweekcheckedarray); } }); $(".secondweek").click(function () { let checkelemnt = $(this).is(':checked'); let day = $(this).val(); var splt = day.toString().split(':'); let dayname = splt[0]; let dayval = Boolean(splt[1]); let weekday = { [dayname]: dayval }; if (checkelemnt == true) { $(this).prop("checked", true); instance.secondweekcheckedarray.push({ [dayname]: dayval }); console.log(instance.secondweekcheckedarray); } else { $(this).prop("checked", false); let newArray = []; for (let i = 0; i < instance.secondweekcheckedarray.length; i++) { if (JSON.stringify(instance.secondweekcheckedarray[i]) !== JSON.stringify(weekday)) { newArray.push(instance.secondweekcheckedarray[i]); } } instance.secondweekcheckedarray = []; instance.secondweekcheckedarray = newArray; console.log(instance.secondweekcheckedarray); } }); $(".thirdweek").click(function () { let checkelemnt = $(this).is(':checked'); let day = $(this).val(); var splt = day.toString().split(':'); let dayname = splt[0]; let dayval = Boolean(splt[1]); let weekday = { [dayname]: dayval }; if (checkelemnt == true) { $(this).prop("checked", true); instance.thirdweekcheckedarray.push({ [dayname]: dayval }); console.log(instance.thirdweekcheckedarray); } else { $(this).prop("checked", false); let newArray = []; for (let i = 0; i < instance.thirdweekcheckedarray.length; i++) { if (JSON.stringify(instance.thirdweekcheckedarray[i]) !== JSON.stringify(weekday)) { newArray.push(instance.thirdweekcheckedarray[i]); } } instance.thirdweekcheckedarray = []; instance.thirdweekcheckedarray = newArray; console.log(instance.thirdweekcheckedarray); } }); $(".fourthweek").click(function () { let checkelemnt = $(this).is(':checked'); let day = $(this).val(); var splt = day.toString().split(':'); let dayname = splt[0]; let dayval = Boolean(splt[1]); let weekday = { [dayname]: dayval }; if (checkelemnt == true) { $(this).prop("checked", true); instance.fourthweekcheckedarray.push({ [dayname]: dayval }); console.log(instance.fourthweekcheckedarray); } else { $(this).prop("checked", false); let newArray = []; for (let i = 0; i < instance.fourthweekcheckedarray.length; i++) { if (JSON.stringify(instance.fourthweekcheckedarray[i]) !== JSON.stringify(weekday)) { newArray.push(instance.fourthweekcheckedarray[i]); } } instance.fourthweekcheckedarray = []; instance.fourthweekcheckedarray = newArray; console.log(instance.fourthweekcheckedarray); } }); if (callback != null) { callback(); } } loadControl(containerid, prop) { $("." + containerid).empty(); let html = `
Weekend Definition
Days Weeks
All 1st 2nd 3rd 4th 5th
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
`; $("#" + containerid).html(html); } loadControlSettings(controlsettingjson, formpropertyid) { return null; } loadPropertySettings(propertysettings, formpropertyid, DocPropertyName) { return null; } bindEditFormDetails(formpropertyid, propval, DocPropertyName) { var id = Number(propval); var instance = this; var jsfiles = ['apps/hrms/managers/holidaymanager.js']; instance.fileCacheHelper.loadJsFiles(jsfiles, function (response) { Bizgaze.Apps.Hrms.Managers.HolidayManager.Instance().getHolidayCalendar(id).then(function (response) { if (response.result.length > 0) { var data = response.result; var everysunday = data[0].everysunday; var everymonday = data[0].everymonday; var everytuesday = data[0].everytuesday; var everywednesday = data[0].everywednesday; var everythursday = data[0].everythursday; var everyfriday = data[0].everyfriday; var everysaturday = data[0].everysaturday; if (everysunday == true) { $(".Sunday").prop("checked", true); $("#SelectAllSunday").prop("checked", true); } else { $(".Sunday").prop("checked", false); $("#SelectAllSunday").prop("checked", false); } if (everymonday == true) { $(".Monday").prop("checked", true); $("#SelectAllMonday").prop("checked", true); } else { $(".Monday").prop("checked", false); $("#SelectAllMonday").prop("checked", false); } if (everytuesday == true) { $(".Tuesday").prop("checked", true); $("#SelectAllTuesday").prop("checked", true); } else { $(".Tuesday").prop("checked", false); $("#SelectAllTuesday").prop("checked", false); } if (everywednesday == true) { $(".Wednesday").prop("checked", true); $("#SelectAllWednesday").prop("checked", true); } else { $(".Wednesday").prop("checked", false); $("#SelectAllWednesday").prop("checked", false); } if (everythursday == true) { $(".Thursday").prop("checked", true); $("#SelectAllThursday").prop("checked", true); } else { $(".Thursday").prop("checked", false); $("#SelectAllThursday").prop("checked", false); } if (everyfriday == true) { $(".Friday").prop("checked", true); $("#SelectAllFriday").prop("checked", true); } else { $(".Friday").prop("checked", false); $("#SelectAllFriday").prop("checked", false); } if (everysaturday == true) { $(".Saturday").prop("checked", true); $("#SelectAllSaturday").prop("checked", true); } else { $(".Saturday").prop("checked", false); $("#SelectAllSaturday").prop("checked", false); } } instance.getCalenderWeekItems(id); }); }); } getCalenderWeekItems(id) { return __awaiter(this, void 0, void 0, function* () { let instance = this; yield Bizgaze.Apps.Hrms.Managers.HolidayManager.Instance().getCalendarWeekItems(id).then(function (response) { if (response.result.length > 0) { for (var i = 0; i < response.result.length; i++) { var data = response.result[i]; let weekid = data.weekid; var sunday = data.sunday; var monday = data.monday; var tuesday = data.tuesday; var wednesday = data.wednesday; var thursday = data.thursday; var friday = data.friday; var saturday = data.saturday; if (weekid == 1) { if (sunday == true) { $("#1stSunday").prop("checked", true); instance.firstweekcheckedarray.push({ Sunday: true }); } if (monday == true) { $("#1stMonday").prop("checked", true); instance.firstweekcheckedarray.push({ Monday: true }); } if (tuesday == true) { $("#1stTuesday").prop("checked", true); instance.firstweekcheckedarray.push({ Tuesday: true }); } if (wednesday == true) { $("#1stWednesday").prop("checked", true); instance.firstweekcheckedarray.push({ Wednesday: true }); } if (thursday == true) { $("#1stThursday").prop("checked", true); instance.firstweekcheckedarray.push({ Thursday: true }); } if (friday == true) { $("#1stFriday").prop("checked", true); instance.firstweekcheckedarray.push({ Friday: true }); } if (saturday == true) { $("#1stSaturday").prop("checked", true); instance.firstweekcheckedarray.push({ Saturday: true }); } } else if (weekid == 2) { if (sunday == true) { $("#2ndSunday").prop("checked", true); instance.secondweekcheckedarray.push({ Sunday: true }); } if (monday == true) { $("#2ndMonday").prop("checked", true); instance.secondweekcheckedarray.push({ Monday: true }); } if (tuesday == true) { $("#2ndTuesday").prop("checked", true); instance.secondweekcheckedarray.push({ Tuesday: true }); } if (wednesday == true) { $("#2ndWednesday").prop("checked", true); instance.secondweekcheckedarray.push({ Wednesday: true }); } if (thursday == true) { $("#2ndThursday").prop("checked", true); instance.secondweekcheckedarray.push({ Thursday: true }); } if (friday == true) { $("#2ndFriday").prop("checked", true); instance.secondweekcheckedarray.push({ Friday: true }); } if (saturday == true) { $("#2ndSaturday").prop("checked", true); instance.secondweekcheckedarray.push({ Saturday: true }); } } else if (weekid == 3) { if (sunday == true) { $("#3rdSunday").prop("checked", true); instance.thirdweekcheckedarray.push({ Sunday: true }); } if (monday == true) { $("#3rdMonday").prop("checked", true); instance.thirdweekcheckedarray.push({ Monday: true }); } if (tuesday == true) { $("#3rdTuesday").prop("checked", true); instance.thirdweekcheckedarray.push({ Tuesday: true }); } if (wednesday == true) { $("#3rdWednesday").prop("checked", true); instance.thirdweekcheckedarray.push({ Wednesday: true }); } if (thursday == true) { $("#3rdThursday").prop("checked", true); instance.thirdweekcheckedarray.push({ Thursday: true }); } if (friday == true) { $("#3rdFriday").prop("checked", true); instance.thirdweekcheckedarray.push({ Friday: true }); } if (saturday == true) { $("#3rdSaturday").prop("checked", true); instance.thirdweekcheckedarray.push({ Saturday: true }); } } else if (weekid == 4) { if (sunday == true) { $("#4thSunday").prop("checked", true); instance.fourthweekcheckedarray.push({ Sunday: true }); } if (monday == true) { $("#4thMonday").prop("checked", true); instance.fourthweekcheckedarray.push({ Monday: true }); } if (tuesday == true) { $("#4thTuesday").prop("checked", true); instance.fourthweekcheckedarray.push({ Tuesday: true }); } if (wednesday == true) { $("#4thWednesday").prop("checked", true); instance.fourthweekcheckedarray.push({ Wednesday: true }); } if (thursday == true) { $("#4thThursday").prop("checked", true); instance.fourthweekcheckedarray.push({ Thursday: true }); } if (friday == true) { $("#4thFriday").prop("checked", true); instance.fourthweekcheckedarray.push({ Friday: true }); } if (saturday == true) { $("#4thSaturday").prop("checked", true); instance.fourthweekcheckedarray.push({ Saturday: true }); } } else if (weekid == 5) { if (sunday == true) { $("#5thSunday").prop("checked", true); instance.fifththweekcheckedarray.push({ Sunday: true }); } if (monday == true) { $("#5thMonday").prop("checked", true); instance.fifththweekcheckedarray.push({ Monday: true }); } if (tuesday == true) { $("#5thTuesday").prop("checked", true); instance.fifththweekcheckedarray.push({ Tuesday: true }); } if (wednesday == true) { $("#5thWednesday").prop("checked", true); instance.fifththweekcheckedarray.push({ Wednesday: true }); } if (thursday == true) { $("#5thThursday").prop("checked", true); instance.fifththweekcheckedarray.push({ Thursday: true }); } if (friday == true) { $("#5thFriday").prop("checked", true); instance.fifththweekcheckedarray.push({ Friday: true }); } if (saturday == true) { $("#5thSaturday").prop("checked", true); instance.fifththweekcheckedarray.push({ Saturday: true }); } } } } }); }); } HolidayCalendarobj() { let instance = this; var allsundays; var allmondays; var alltuesdays; var allwednesdays; var allthursdays; var allfridays; var allsaturdays; if ($("#SelectAllSunday").is(':checked')) { allsundays = true; } else { allsundays = false; } if ($("#SelectAllMonday").is(':checked')) { allmondays = true; } else { allmondays = false; } if ($("#SelectAllTuesday").is(':checked')) { alltuesdays = true; } else { alltuesdays = false; } if ($("#SelectAllWednesday").is(':checked')) { allwednesdays = true; } else { allwednesdays = false; } if ($("#SelectAllThursday").is(':checked')) { allthursdays = true; } else { allthursdays = false; } if ($("#SelectAllFriday").is(':checked')) { allfridays = true; } else { allfridays = false; } if ($("#SelectAllSaturday").is(':checked')) { allsaturdays = true; } else { allsaturdays = false; } instance.holidaycalendar.push({ AllSundays: allsundays, AllMondays: allmondays, AllTuesdays: alltuesdays, AllWednesdays: allwednesdays, AllThursdays: allthursdays, AllFridays: allfridays, AllSaturdays: allsaturdays }); } HolidayCalendarobjitems() { let instance = this; instance.HolidayCalendarobj(); var holidaycalendaritems = new Array(); holidaycalendaritems.push({ AllWeeks: instance.holidaycalendar, FirstWeek: instance.firstweekcheckedarray, SecondWeek: instance.secondweekcheckedarray, ThirdWeek: instance.thirdweekcheckedarray, FourthWeek: instance.fourthweekcheckedarray, FifthWeek: instance.fifththweekcheckedarray }); return holidaycalendaritems; } static Instance() { if (this.instance === undefined) { this.instance = new ShiftCalender(); } return this.instance; } } Components.ShiftCalender = ShiftCalender; })(Components = Hrms.Components || (Hrms.Components = {})); })(Hrms = Apps.Hrms || (Apps.Hrms = {})); })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {})); })(Bizgaze || (Bizgaze = {}));