From ce4c5d8f07c6338f0604e4c9fffaffcd60d3f51d Mon Sep 17 00:00:00 2001 From: chapal Date: Sun, 3 Nov 2024 12:31:54 +0600 Subject: [PATCH 1/2] Prod setup --- HRM.DA/DA/Bonus/ProductionBonusSetupDA.cs | 10 +++++----- HRM.UI/ClientApp/src/app/app.api.service.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/HRM.DA/DA/Bonus/ProductionBonusSetupDA.cs b/HRM.DA/DA/Bonus/ProductionBonusSetupDA.cs index 23e1b3f..a8117b8 100644 --- a/HRM.DA/DA/Bonus/ProductionBonusSetupDA.cs +++ b/HRM.DA/DA/Bonus/ProductionBonusSetupDA.cs @@ -23,10 +23,10 @@ namespace HRM.DA internal static void Insert(TransactionContext tc, ProductionBonusSetup item) { string sql = SQLParser.MakeSQL( - "INSERT INTO ProductionBonusSetup(ProductionBonusSetupID, ProgramName, AchivedPercent, OTHour, SalaryMonth, DesignNo, FromDate, ToDate, MaxPerson, CreatedBy, CreationDate, Status)" + - " VALUES(%n, %s, %n, %n, %d, %s, %d, %d, %n, %n, %d, %n)", item.ID, item.ProgramName, item.AchivedPercent, item.OTHour, + "INSERT INTO ProductionBonusSetup(ProductionBonusSetupID, ProgramName, AchivedPercent, OTHour, SalaryMonth, DesignNo, FromDate, ToDate, MaxPerson, CreatedBy, CreationDate, Status,ProductionBonusType)" + + " VALUES(%n, %s, %n, %n, %d, %s, %d, %d, %n, %n, %d, %n,%n)", item.ID, item.ProgramName, item.AchivedPercent, item.OTHour, item.SalaryMonth, item.DesignNo, item.FromDate, item.ToDate, item.MaxPerson, item.CreatedBy, item.CreatedDate, - item.Status); + item.Status, (int)item.ProductionBonusType); tc.ExecuteNonQuery(sql); } @@ -37,9 +37,9 @@ namespace HRM.DA internal static void Update(TransactionContext tc, ProductionBonusSetup item) { tc.ExecuteNonQuery( - "UPDATE ProductionBonusSetup SET ProgramName=%s, AchivedPercent=%n, OTHour=%n, SalaryMonth=%d, DesignNo=%s, FromDate=%d, ToDate=%d, MaxPerson=%n, Status=%n " + + "UPDATE ProductionBonusSetup SET ProgramName=%s, AchivedPercent=%n, OTHour=%n, SalaryMonth=%d, DesignNo=%s, FromDate=%d, ToDate=%d, MaxPerson=%n, Status=%n,ProductionBonusType=%n " + " WHERE ProductionBonusSetupID=%n", item.ProgramName, item.AchivedPercent, item.OTHour, item.SalaryMonth, item.DesignNo, - item.FromDate, item.ToDate, item.MaxPerson, item.Status, item.ID); + item.FromDate, item.ToDate, item.MaxPerson, item.Status,(int)item.ProductionBonusType, item.ID); } #endregion diff --git a/HRM.UI/ClientApp/src/app/app.api.service.ts b/HRM.UI/ClientApp/src/app/app.api.service.ts index 81a10fd..c6a1e4c 100644 --- a/HRM.UI/ClientApp/src/app/app.api.service.ts +++ b/HRM.UI/ClientApp/src/app/app.api.service.ts @@ -13,7 +13,7 @@ export class ApiService { public isSSO = false; public versionDeployement = false; - public versionNumber = `V-${GlobalfunctionExtension.generateVersionNumber(new Date(2024, 9, 31))}-`+"01"; + public versionNumber = `V-${GlobalfunctionExtension.generateVersionNumber(new Date(2024, 10, 3))}-`+"01"; public static BASE_URL = ''; public base_url = ''; // public currentLink = ''; From 133ec0b76c778a08fadb796982fa0ae664b74b0e Mon Sep 17 00:00:00 2001 From: "salauddin.shamim" Date: Thu, 14 Nov 2024 16:06:07 +0600 Subject: [PATCH 2/2] correction --- HRM.BO/Bonus/ProdBonusSupervisor.cs | 6 +- HRM.DA/DA/Bonus/ProdBonusWorkScheduleDA.cs | 14 + .../Bonus/ProdBonusWorkScheduleService.cs | 25 ++ .../ProductionBonus/prodBonusSupervisor.ts | 6 +- .../ProductionBonus/prodBonusWorkSchedule.js | 2 + .../prodBonusWorkSchedule.js.map | 2 +- .../ProductionBonus/prodBonusWorkSchedule.ts | 8 +- .../app/_services/payroll/bonus.service.ts | 4 + .../production-bonus-setup.component.html | 96 ++-- .../production-bonus-setup.component.ts | 415 ++++++++++-------- HRM.UI/Controllers/Payroll/BonusController.cs | 47 ++ 11 files changed, 392 insertions(+), 233 deletions(-) diff --git a/HRM.BO/Bonus/ProdBonusSupervisor.cs b/HRM.BO/Bonus/ProdBonusSupervisor.cs index 039054d..05fd5ef 100644 --- a/HRM.BO/Bonus/ProdBonusSupervisor.cs +++ b/HRM.BO/Bonus/ProdBonusSupervisor.cs @@ -78,8 +78,10 @@ namespace HRM.BO } #endregion - - public string EmployeeNo { get; set; } + public string devName { get; set; } + public string devParentName{ get; set; } + public string devGrantParentName{ get; set; } +public string EmployeeNo { get; set; } public string EmpName { get; set; } //public Employee Employee { get; set; } diff --git a/HRM.DA/DA/Bonus/ProdBonusWorkScheduleDA.cs b/HRM.DA/DA/Bonus/ProdBonusWorkScheduleDA.cs index 10224fe..c432f69 100644 --- a/HRM.DA/DA/Bonus/ProdBonusWorkScheduleDA.cs +++ b/HRM.DA/DA/Bonus/ProdBonusWorkScheduleDA.cs @@ -55,6 +55,20 @@ namespace HRM.DA { return tc.ExecuteReader("SELECT * FROM ProdBonusWorkSchedule where ProdBonusSetupID=%n", nSetupID); } + internal static DataTable GetschedulewithTime(TransactionContext tc, int lineID) + { + return tc.ExecuteDataTable(@"select a.*,bb.scheduleCount , (select max(ps.InTime) from ProdBonusAttn ps where ps.ProdBonusLineID =%n +and DATEADD(dd, 0, DATEDIFF(dd, 0, ps.InTime)) = bb.scheduleDate) as inTime, +(select max(ps.OutTime) from ProdBonusAttn ps where ps.ProdBonusLineID =%n +and DATEADD(dd, 0, DATEDIFF(dd, 0, ps.InTime)) = bb.scheduleDate) as outTime from +(SELECT * FROM ProdBonusWorkSchedule where ProdBonusLineID=%n) a, +( +select DATEADD(dd, 0, DATEDIFF(dd, 0, InTime)) scheduleDate,COUNT(*) scheduleCount from ProdBonusAttn where +ProdBonusLineID =%n group by DATEADD(dd, 0, DATEDIFF(dd, 0, InTime)) + ) bb +where bb.scheduleDate = DATEADD(dd, 0, DATEDIFF(dd, 0, a.StartDateTime)) ", lineID, lineID, lineID, lineID); + } + internal static IDataReader GetByLineID(TransactionContext tc, int lineID) { diff --git a/HRM.DA/Service/Bonus/ProdBonusWorkScheduleService.cs b/HRM.DA/Service/Bonus/ProdBonusWorkScheduleService.cs index 9be6cb1..fb0ba1f 100644 --- a/HRM.DA/Service/Bonus/ProdBonusWorkScheduleService.cs +++ b/HRM.DA/Service/Bonus/ProdBonusWorkScheduleService.cs @@ -129,6 +129,31 @@ namespace HRM.DA return ProdBonusWorkSchedules; } + + public DataTable GetschedulewithTime(int lineid) + { + DataTable items = null; + TransactionContext tc = null; + try + { + tc = TransactionContext.Begin(); + items = ProdBonusWorkScheduleDA.GetschedulewithTime(tc, lineid); + tc.End(); + } + catch (Exception e) + { + #region Handle Exception + + if (tc != null) + tc.HandleError(); + ExceptionLog.Write(e); + throw new ServiceException(e.Message, e); + + #endregion + } + + return items; + } public List GetWithSetupID(int nSetupID) { List ProdBonusWorkSchedules = null; diff --git a/HRM.UI/ClientApp/src/app/_models/Payroll/ProductionBonus/prodBonusSupervisor.ts b/HRM.UI/ClientApp/src/app/_models/Payroll/ProductionBonus/prodBonusSupervisor.ts index e0ea1f6..0b42686 100644 --- a/HRM.UI/ClientApp/src/app/_models/Payroll/ProductionBonus/prodBonusSupervisor.ts +++ b/HRM.UI/ClientApp/src/app/_models/Payroll/ProductionBonus/prodBonusSupervisor.ts @@ -11,7 +11,9 @@ export class ProdBonusSupervisor { employeeNo:string; // view purpose empName:string; // view purpose // employee: Employee; - + devName: string; + devParentName: string; + devGrantParentName: string; constructor() { // super(); this.id = 0; @@ -24,4 +26,4 @@ export class ProdBonusSupervisor { this.empName =''; // view purpose } -} \ No newline at end of file +} diff --git a/HRM.UI/ClientApp/src/app/_models/Payroll/ProductionBonus/prodBonusWorkSchedule.js b/HRM.UI/ClientApp/src/app/_models/Payroll/ProductionBonus/prodBonusWorkSchedule.js index cde4a45..04fe778 100644 --- a/HRM.UI/ClientApp/src/app/_models/Payroll/ProductionBonus/prodBonusWorkSchedule.js +++ b/HRM.UI/ClientApp/src/app/_models/Payroll/ProductionBonus/prodBonusWorkSchedule.js @@ -7,6 +7,8 @@ var ProdBonusWorkSchedule = /** @class */ (function () { this.prodBonusLineID = 0; this.startDateTime = new Date(); this.endDateTime = new Date(); + this.inTime = undefined; + this.outTime = undefined; } return ProdBonusWorkSchedule; }()); diff --git a/HRM.UI/ClientApp/src/app/_models/Payroll/ProductionBonus/prodBonusWorkSchedule.js.map b/HRM.UI/ClientApp/src/app/_models/Payroll/ProductionBonus/prodBonusWorkSchedule.js.map index 5166099..d14f45f 100644 --- a/HRM.UI/ClientApp/src/app/_models/Payroll/ProductionBonus/prodBonusWorkSchedule.js.map +++ b/HRM.UI/ClientApp/src/app/_models/Payroll/ProductionBonus/prodBonusWorkSchedule.js.map @@ -1 +1 @@ -{"version":3,"file":"prodBonusWorkSchedule.js","sourceRoot":"","sources":["prodBonusWorkSchedule.ts"],"names":[],"mappings":";;;AAEA;IAOI;QACI,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QACZ,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,IAAI,IAAI,EAAE,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;IAClC,CAAC;IACL,4BAAC;AAAD,CAAC,AAbD,IAaC;AAbY,sDAAqB"} \ No newline at end of file +{"version":3,"file":"prodBonusWorkSchedule.js","sourceRoot":"","sources":["prodBonusWorkSchedule.ts"],"names":[],"mappings":";;;AAEA;IASI;QACI,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QACZ,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,IAAI,IAAI,EAAE,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;IAC7B,CAAC;IACL,4BAAC;AAAD,CAAC,AAjBD,IAiBC;AAjBY,sDAAqB"} \ No newline at end of file diff --git a/HRM.UI/ClientApp/src/app/_models/Payroll/ProductionBonus/prodBonusWorkSchedule.ts b/HRM.UI/ClientApp/src/app/_models/Payroll/ProductionBonus/prodBonusWorkSchedule.ts index ebdfa53..6d834eb 100644 --- a/HRM.UI/ClientApp/src/app/_models/Payroll/ProductionBonus/prodBonusWorkSchedule.ts +++ b/HRM.UI/ClientApp/src/app/_models/Payroll/ProductionBonus/prodBonusWorkSchedule.ts @@ -6,11 +6,15 @@ export class ProdBonusWorkSchedule{ prodBonusLineID: number; startDateTime: Date; endDateTime: Date; - + inTime?: Date; + outTime?: Date; + totalCount?: number; constructor(){ this.id = 0; this.prodBonusLineID = 0; this.startDateTime = new Date(); this.endDateTime = new Date(); + this.inTime = undefined; + this.outTime = undefined; } -} \ No newline at end of file +} diff --git a/HRM.UI/ClientApp/src/app/_services/payroll/bonus.service.ts b/HRM.UI/ClientApp/src/app/_services/payroll/bonus.service.ts index 275319c..6199c35 100644 --- a/HRM.UI/ClientApp/src/app/_services/payroll/bonus.service.ts +++ b/HRM.UI/ClientApp/src/app/_services/payroll/bonus.service.ts @@ -111,6 +111,10 @@ export class BonusService { getLayoutDetails(setUpid: number) { return this.apiService.httpGet('/Bonus/getLayoutDetails/'+ setUpid); } + GetschedulewithTime(lineid: number) { + return this.apiService.httpGet('/Bonus/GetschedulewithTime/' + lineid); + } + getLines(setupid: number) { return this.apiService.httpGet('/Bonus/getLines/'+ setupid); } diff --git a/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.html b/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.html index b17ec76..58b3af5 100644 --- a/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.html +++ b/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.html @@ -181,50 +181,82 @@ - + [reorderable]="true"> + + + --> - + + --> - + + - + + + + + + + + + + + style="width: fit-content;" (click)="onClickRemoveSupervisors(dataItem)"> + Remove + - + + +
+
+ +
+
+ this will take around 30 Second or more. +
+
- - - {{dataItem.startDateTime | date: 'dd MMMM yyyy'}} - - - - -
-
- + + + + + {{dataItem.startDateTime | date: 'dd MMMM yyyy'}} + + + + + + {{dataItem?.inTime | date: 'hh:mm'}} + + + + + + {{dataItem?.outTime | date: 'hh:mm'}} + + + + + + + + @@ -238,4 +270,4 @@ - \ No newline at end of file + diff --git a/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.ts b/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.ts index 22fcca8..908e738 100644 --- a/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.ts +++ b/HRM.UI/ClientApp/src/app/payroll-ot/production-bonus-setup/production-bonus-setup.component.ts @@ -28,6 +28,7 @@ import { numberSymbols } from '@progress/kendo-angular-intl'; import { process, State } from '@progress/kendo-data-query'; import { DataStateChangeEvent } from '@progress/kendo-angular-grid'; import { noUndefined } from '@angular/compiler/src/util'; +import { EnumStatus } from '../../_models/enums'; @@ -70,7 +71,8 @@ export class ProductionBonusSetupComponent implements OnInit { prodBonusSupervisor: ProdBonusSupervisor; prodBonusParameter: ProdBonusParameter; - prodBonusAttn: ProdBonusAttn[]; + prodBonusAttn: ProdBonusAttn[]; + depts: Department[] = []; layoutNo: string; // programName: string; // maxPerson: number; @@ -104,7 +106,7 @@ export class ProductionBonusSetupComponent implements OnInit { department: Department; selectedRow: any; - + scheduleTime: any; editDetails: boolean = false; @@ -123,37 +125,39 @@ export class ProductionBonusSetupComponent implements OnInit { this.prodBonusSupervisor = new ProdBonusSupervisor(); this.prodBonusParameter = new ProdBonusParameter(); this.prodBonusWork = new ProdBonusWorkSchedule(); - this.getBonusType(); - // this.createForm(); + this.getBonusType(); + + + } - OnclickCheckbox() { - debugger; - if (this.isNewLayout === false) { - this.isNewLayout = true; - this.productionBonusSetup = new ProductionBonusSetup(); - this.prodBonusLine = new ProdBonusLine(); - this.prodBonusSupervisor = new ProdBonusSupervisor(); - this.prodBonusParameter = new ProdBonusParameter(); - this.prodBonusWork = new ProdBonusWorkSchedule(); - this.productionBonusSetup.fromDate = new Date(); - this.productionBonusSetup.toDate = new Date(); - } - else { - this.isNewLayout = false; - this.productionBonusSetup.fromDate = undefined; - this.productionBonusSetup.toDate = undefined; + OnclickCheckbox() { + debugger; + if (this.isNewLayout === false) { + this.isNewLayout = true; + this.productionBonusSetup = new ProductionBonusSetup(); + this.prodBonusLine = new ProdBonusLine(); + this.prodBonusSupervisor = new ProdBonusSupervisor(); + this.prodBonusParameter = new ProdBonusParameter(); + this.prodBonusWork = new ProdBonusWorkSchedule(); + this.productionBonusSetup.fromDate = new Date(); + this.productionBonusSetup.toDate = new Date(); + } + else { + this.isNewLayout = false; + this.productionBonusSetup.fromDate = undefined; + this.productionBonusSetup.toDate = undefined; + } + this.prodBSdata = undefined; + this.filteredProdBSdata = undefined; + this.selectedProdBSdata = undefined; + this.selectedBonusType = { + label: 'Select Bonus Type...', + value: null + } + this.editDetails = false; } - this.prodBSdata = undefined; - this.filteredProdBSdata = undefined; - this.selectedProdBSdata = undefined; - this.selectedBonusType = { - label: 'Select Bonus Type...', - value: null - } - this.editDetails = false; - } handleFilter(value) { this.filteredProdBSdata = this.prodBSdata.filter( @@ -268,74 +272,97 @@ export class ProductionBonusSetupComponent implements OnInit { this.bonusPercent = 0; } - onClickAddLine(): void { - debugger; - // this.onEdit = false; - this.isNewLine = true; - this.selectedRow = new ProdBonusLine(); + onClickAddLine(): void { + debugger; + // this.onEdit = false; + this.isNewLine = true; + this.selectedRow = new ProdBonusLine(); - this._departmentPicker = new DynamicPicker(EnumDynamicpickerType.Department, false); - this.prodBonusLine = new ProdBonusLine(); - this.prodBonusWork = new ProdBonusWorkSchedule(); - if (this.isNewLayout) {//Add Setup line + this._departmentPicker = new DynamicPicker(EnumDynamicpickerType.Department, false); + this.prodBonusLine = new ProdBonusLine(); + this.prodBonusWork = new ProdBonusWorkSchedule(); + if (this.isNewLayout) {//Add Setup line - if (this.selectedBonusType === undefined || this.selectedBonusType === null) { - return this.notificationService.showWarning('Please select Bonus Type'); - } - this.saveProductionBonusSetup(); - // console.log(this.productionBonusSetup); - debugger; - if (this.productionBonusSetup.designNo === '' || this.productionBonusSetup.programName === '' || this.productionBonusSetup.fromDate === undefined || - this.productionBonusSetup.toDate === undefined || this.productionBonusSetup.productionBonusType === null) { - this.notificationService.showWarning('Please fill up the information of production bonus setup'); - return; - } + if (this.selectedBonusType === undefined || this.selectedBonusType === null) { + return this.notificationService.showWarning('Please select Bonus Type'); + } + this.saveProductionBonusSetup(); + // console.log(this.productionBonusSetup); + debugger; + if (this.productionBonusSetup.designNo === '' || this.productionBonusSetup.programName === '' || this.productionBonusSetup.fromDate === undefined || + this.productionBonusSetup.toDate === undefined || this.productionBonusSetup.productionBonusType === null) { + this.notificationService.showWarning('Please fill up the information of production bonus setup'); + return; + } - this.prodBonusLine.prodBonusSupervisors = []; - this.prodBonusLine.prodBonusWorkSchedules = []; + this.prodBonusLine.prodBonusSupervisors = []; + this.prodBonusLine.prodBonusWorkSchedules = []; - // console.log(this.prodBonusLine); + // console.log(this.prodBonusLine); - // for (let j = 0; j < this.productionBonusSetup.productionBonusLines.length; j++) { - // for (let i = 0; i < this.productionBonusSetup.productionBonusLines[i].prodBonusSupervisors.length; i++) - // this.prodBonusLine.prodBonusSupervisors = this.productionBonusSetup.productionBonusLines[i].prodBonusSupervisors; - // } - } - else { //Edit Setup line - // console.log(this.productionBonusSetup); - debugger; - this.prodBonusLine.prodBonusSupervisors = []; - this.prodBonusLine.prodBonusWorkSchedules = []; - - } - this.opened = true; - // create schedule - this.loadingPanelService.ShowLoadingPanel = true; - debugger; - if (this.prodBonusLine.id !== 0) { - this.bonusService.getProdBonusAttenbyLineId(this.prodBonusLine.id).subscribe( - (resp) => { - this.prodBonusAttn = resp; - }, - (err: any) => { - this.notificationService.showError(err.error); - this.loadingPanelService.ShowLoadingPanel = false; - }, - () => { - - this.loadingPanelService.ShowLoadingPanel = false; + // for (let j = 0; j < this.productionBonusSetup.productionBonusLines.length; j++) { + // for (let i = 0; i < this.productionBonusSetup.productionBonusLines[i].prodBonusSupervisors.length; i++) + // this.prodBonusLine.prodBonusSupervisors = this.productionBonusSetup.productionBonusLines[i].prodBonusSupervisors; + // } } - ); + else { //Edit Setup line + // console.log(this.productionBonusSetup); + debugger; + this.prodBonusLine.prodBonusSupervisors = []; + this.prodBonusLine.prodBonusWorkSchedules = []; + + } + this.opened = true; + // create schedule + this.loadingPanelService.ShowLoadingPanel = true; + debugger; + if (this.prodBonusLine.id !== 0) { + + } + + + + } - } + GetScheduleTime(dataItem: any) { + console.log('line'); + console.log(this.prodBonusLine.prodBonusWorkSchedules); + this.loadingPanelService.ShowLoadingPanel = true; + this.bonusService.GetschedulewithTime(this.prodBonusLine.prodBonusWorkSchedules[0].prodBonusLineID).subscribe( + (resp) => { + this.scheduleTime = resp; + }, + (err: any) => { + this.notificationService.showError(err.error); + this.loadingPanelService.ShowLoadingPanel = false; + }, + () => { + console.log(this.scheduleTime); + if (this.prodBonusLine.prodBonusWorkSchedules != undefined) { + var pdrs = this.prodBonusLine.prodBonusWorkSchedules; + pdrs.forEach(x => { + var item = this.scheduleTime.find(y => y.startDateTime == x.startDateTime); + if (item != undefined) { + x.inTime = new Date( item.inTime); + x.outTime = new Date( item.outTime); + x.totalCount = item.scheduleCount; + } + } + ); + } + console.log(this.prodBonusLine.prodBonusWorkSchedules); + this.loadingPanelService.ShowLoadingPanel = false; + } + ); + } onCellClickEdit(dataItem: ProdBonusLine) { // console.log(dataItem); this.isNewLine = false; this.prodBonusLine = new ProdBonusLine(); - debugger; + // if (this.isNewLayout) { //ADD Line // this.prodBonusLine.prodBonusSupervisors = []; // this.prodBonusLine.prodBonusWorkSchedules = []; @@ -370,120 +397,120 @@ export class ProductionBonusSetupComponent implements OnInit { this.opened = true; } - newLine() { - if ((this._departmentPicker.selectedID === undefined || this._departmentPicker.selectedID === 0) && - (this.prodBonusLine.lineName === '' || this.prodBonusLine.lineName === undefined)) { - this.notificationService.showWarning('Please Select a Line'); - this.close(); - return; - } - if (this._employee === undefined || this._employee.id === 0) { - this.notificationService.showWarning('Please Select Supervisor'); - this.close(); - return; - } - // if (this.scheduledHours === undefined || this.scheduledHours === 0) { - // this.notificationService.showWarning('Please Select Scheduled Hours'); - // return; - // } - // if (this.bonusPercent === undefined || this.bonusPercent === 0) { - // this.notificationService.showWarning('Please Select Bonus Percentage'); - // return; - // } - - - debugger; - this._employee; - this.prodBonusLine.prodBonusSupervisors; - - - if (this.scheduledHours < 0 || this.bonusPercent < 0) { - this.notificationService.showWarning('Scheduled Hours and Bonus Percentage can\'t be negative'); - return; - } - // this.isNewLine = true; - - var newlineSupervisor: ProdBonusSupervisor = new ProdBonusSupervisor(); - var newlineParameter: ProdBonusParameter = new ProdBonusParameter(); - // var newLayoutWork: ProdBonusWorkSchedule = new ProdBonusWorkSchedule(); - - const index = this.prodBonusLine.prodBonusSupervisors.findIndex(sv=> sv.employeeID == this._employee.id); - if (index !== -1) { - this.prodBonusLine.prodBonusSupervisors.splice(index, 1); - } - //Supervisor - newlineSupervisor.employeeID = this._employee.id; - newlineSupervisor.employeeNo = this._employee.employeeNo; - newlineSupervisor.empName = this._employee.name; - newlineSupervisor.bonusPercent = this.bonusPercent; - newlineSupervisor.prodBonusSetupID = this.productionBonusSetup.id; - - if (this.isNewLine) { - newlineParameter.itemID = this._departmentPicker.selectedID; - newlineParameter.itemType = 0; - newlineParameter.prodBonusSetupID = this.productionBonusSetup.id; - - // var department; - this.basicService.getDepartmentByID(this._departmentPicker.selectedID).subscribe( - (resp) => { - this.department = resp; - }, - (err) => { - this.notificationService.showError(err.error); - }, - () => { - //newlineItem.amount - this.prodBonusLine.prodBonusSupervisors.push(newlineSupervisor); - this.prodBonusLine.prodBonusParameters.push(newlineParameter); - - this.prodBonusLine.scheduledHour = this.scheduledHours; - this.prodBonusLine.lineName = this.department.name; - // console.log(this.prodBonusLine); - this.clearProdbonusLine(); - // this.notificationService.showSuccess('Supervisor added to the line'); + newLine() { + if ((this._departmentPicker.selectedID === undefined || this._departmentPicker.selectedID === 0) && + (this.prodBonusLine.lineName === '' || this.prodBonusLine.lineName === undefined)) { + this.notificationService.showWarning('Please Select a Line'); + this.close(); + return; + } + if (this._employee === undefined || this._employee.id === 0) { + this.notificationService.showWarning('Please Select Supervisor'); + this.close(); + return; + } + // if (this.scheduledHours === undefined || this.scheduledHours === 0) { + // this.notificationService.showWarning('Please Select Scheduled Hours'); + // return; + // } + // if (this.bonusPercent === undefined || this.bonusPercent === 0) { + // this.notificationService.showWarning('Please Select Bonus Percentage'); + // return; + // } + + + debugger; + this._employee; + this.prodBonusLine.prodBonusSupervisors; + + + if (this.scheduledHours < 0 || this.bonusPercent < 0) { + this.notificationService.showWarning('Scheduled Hours and Bonus Percentage can\'t be negative'); + return; + } + // this.isNewLine = true; + + var newlineSupervisor: ProdBonusSupervisor = new ProdBonusSupervisor(); + var newlineParameter: ProdBonusParameter = new ProdBonusParameter(); + // var newLayoutWork: ProdBonusWorkSchedule = new ProdBonusWorkSchedule(); + + const index = this.prodBonusLine.prodBonusSupervisors.findIndex(sv => sv.employeeID == this._employee.id); + if (index !== -1) { + this.prodBonusLine.prodBonusSupervisors.splice(index, 1); + } + //Supervisor + newlineSupervisor.employeeID = this._employee.id; + newlineSupervisor.employeeNo = this._employee.employeeNo; + newlineSupervisor.empName = this._employee.name; + newlineSupervisor.bonusPercent = this.bonusPercent; + newlineSupervisor.prodBonusSetupID = this.productionBonusSetup.id; + + if (this.isNewLine) { + newlineParameter.itemID = this._departmentPicker.selectedID; + newlineParameter.itemType = 0; + newlineParameter.prodBonusSetupID = this.productionBonusSetup.id; + + // var department; + this.basicService.getDepartmentByID(this._departmentPicker.selectedID).subscribe( + (resp) => { + this.department = resp; + }, + (err) => { + this.notificationService.showError(err.error); + }, + () => { + //newlineItem.amount + this.prodBonusLine.prodBonusSupervisors.push(newlineSupervisor); + this.prodBonusLine.prodBonusParameters.push(newlineParameter); + + this.prodBonusLine.scheduledHour = this.scheduledHours; + this.prodBonusLine.lineName = this.department.name; + // console.log(this.prodBonusLine); + this.clearProdbonusLine(); + // this.notificationService.showSuccess('Supervisor added to the line'); + } + ); + + debugger; + //WorkSchedules + // newLayoutWork.prodBonusSetupID = this.productionBonusSetup.id; + // newLayoutWork.prodBonusLineID = this.selectedRow.id; + const currentDate = new Date(this.productionBonusSetup.fromDate); + // while (currentDate <= this.productionBonusSetup.toDate) { + // newLayoutWork.startDateTime = new Date(currentDate.setHours(0, 0, 0, 0)); + // newLayoutWork.endDateTime = new Date(currentDate.setHours(23, 59, 59, 999)); + // debugger; + // this.prodBonusLine.prodBonusWorkSchedules.push(newLayoutWork); + // currentDate.setDate(currentDate.getDate() + 1); + // } + for (let i = 0; currentDate <= this.productionBonusSetup.toDate; i++) { + let newLayoutWork: ProdBonusWorkSchedule = { + prodBonusSetupID: 0, + prodBonusLineID: 0, + id: 0, + startDateTime: new Date(currentDate.setHours(0, 0, 0, 0)), + endDateTime: new Date(currentDate.setHours(23, 59, 59, 999)) + }; + this.prodBonusLine.prodBonusWorkSchedules.push(newLayoutWork); + currentDate.setDate(currentDate.getDate() + 1); + } + } + else { + debugger; + newlineSupervisor.prodBonusLineID = this.selectedRow.id; + this.prodBonusLine.id = this.selectedRow.id; + this.prodBonusLine.lineName = this.selectedRow.lineName; + this.prodBonusLine.scheduledHour = this.selectedRow.scheduledHours; + this.prodBonusLine.prodBonusSupervisors.push(newlineSupervisor); + // this.prodBonusLine.prodBonusParameters.push(newlineParameter); + + + // console.log(this.prodBonusLine); + this.clearProdbonusLine(); + // this.notificationService.showSuccess('Supervisor added to the line'); } - ); - debugger; - //WorkSchedules - // newLayoutWork.prodBonusSetupID = this.productionBonusSetup.id; - // newLayoutWork.prodBonusLineID = this.selectedRow.id; - const currentDate = new Date(this.productionBonusSetup.fromDate); - // while (currentDate <= this.productionBonusSetup.toDate) { - // newLayoutWork.startDateTime = new Date(currentDate.setHours(0, 0, 0, 0)); - // newLayoutWork.endDateTime = new Date(currentDate.setHours(23, 59, 59, 999)); - // debugger; - // this.prodBonusLine.prodBonusWorkSchedules.push(newLayoutWork); - // currentDate.setDate(currentDate.getDate() + 1); - // } - for (let i = 0; currentDate <= this.productionBonusSetup.toDate; i++) { - let newLayoutWork: ProdBonusWorkSchedule = { - prodBonusSetupID: 0, - prodBonusLineID: 0, - id: 0, - startDateTime: new Date(currentDate.setHours(0, 0, 0, 0)), - endDateTime: new Date(currentDate.setHours(23, 59, 59, 999)) - }; - this.prodBonusLine.prodBonusWorkSchedules.push(newLayoutWork); - currentDate.setDate(currentDate.getDate() + 1); - } } - else { - debugger; - newlineSupervisor.prodBonusLineID = this.selectedRow.id; - this.prodBonusLine.id = this.selectedRow.id; - this.prodBonusLine.lineName = this.selectedRow.lineName; - this.prodBonusLine.scheduledHour = this.selectedRow.scheduledHours; - this.prodBonusLine.prodBonusSupervisors.push(newlineSupervisor); - // this.prodBonusLine.prodBonusParameters.push(newlineParameter); - - - // console.log(this.prodBonusLine); - this.clearProdbonusLine(); - // this.notificationService.showSuccess('Supervisor added to the line'); - } - - } saveProductionBonusSetup(): void { this.productionBonusSetup.salaryMonth = this.selectedSalaryDate; diff --git a/HRM.UI/Controllers/Payroll/BonusController.cs b/HRM.UI/Controllers/Payroll/BonusController.cs index 386fac8..ce5c1e8 100644 --- a/HRM.UI/Controllers/Payroll/BonusController.cs +++ b/HRM.UI/Controllers/Payroll/BonusController.cs @@ -22,6 +22,7 @@ using NPOI.SS.Formula.Eval; using System.Globalization; using Payroll.BO; using Ease.Core.Model; +using Microsoft.AspNetCore.Mvc.ViewFeatures; namespace HRM.UI.Controllers.Payroll { @@ -463,6 +464,7 @@ namespace HRM.UI.Controllers.Payroll CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); ProductionBonusSetup item = new ProductionBonusSetup(); //ProdBonusLine item = new ProdBonusLine(); + List detps = new DepartmentService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID); try { item = _productionBonusSetupService.Get(ID); @@ -474,7 +476,33 @@ namespace HRM.UI.Controllers.Payroll foreach (ProdBonusSupervisor prodSupervisor in prodLine.ProdBonusSupervisors) { oEmp = new EmployeeService().Get(prodSupervisor.EmployeeID); + if (oEmp.DepartmentID != null) + { + + var dev = detps.FirstOrDefault(x => x.ID == oEmp.DepartmentID); + prodSupervisor.devName = dev.Name; + if(dev.ParentsID !=null) + { + var pr = detps.FirstOrDefault(x => x.ID == dev.ParentID); + if (pr != null) + { + prodSupervisor.devParentName = pr.Name; + if (pr.ParentsID != null) + { + var gpr = detps.FirstOrDefault(x => x.ID == pr.ParentID); + if (gpr != null) + { + prodSupervisor.devGrantParentName = gpr.Name; + } + + } + + + } + + } + } prodSupervisor.EmpName = oEmp.Name; prodSupervisor.EmployeeNo = oEmp.EmployeeNo; @@ -496,6 +524,25 @@ namespace HRM.UI.Controllers.Payroll return StatusCode(StatusCodes.Status500InternalServerError, e.Message); } + return Ok(item); + } + + + [HttpGet("GetschedulewithTime/{lineid}")] + public ActionResult GetschedulewithTime(int lineid) + { + CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); + DataTable item =null; + try + { + item = new ProdBonusWorkScheduleService().GetschedulewithTime(lineid); + + } + catch (Exception e) + { + return StatusCode(StatusCodes.Status500InternalServerError, e.Message); + } + return Ok(item); }