Prod Bonus Attn stable grid modified

This commit is contained in:
mashfiq 2024-12-12 11:45:37 +06:00
parent a0474a12b3
commit 6063bf6cf9
3 changed files with 106 additions and 95 deletions

View File

@ -66,7 +66,7 @@
<label>Schedule Date</label> <label>Schedule Date</label>
</div> </div>
<div class="p-col-6 p-md-2"> <div class="p-col-6 p-md-2">
<kendo-datepicker [(ngModel)]="selectedDate" [format]="'dd MMMM yyyy'" style="width:100%"></kendo-datepicker> <kendo-datepicker [(ngModel)]="selectedDate" [format]="'dd MMMM yyyy'" style="width:100%" (valueChange)="scheduleDateChange($event)" ></kendo-datepicker>
</div> </div>
<div class="p-col-6 p-md-1 label-ailgn"> <div class="p-col-6 p-md-1 label-ailgn">

View File

@ -43,7 +43,8 @@ export class ProductionBonusAttendanceComponent implements OnInit {
prodBonusAttn: ProdBonusAttn[]; prodBonusAttn: ProdBonusAttn[];
selectedDate: Date = new Date; // selectedDate: Date = new Date;
selectedDate: Date;
startTime: Date = new Date(); startTime: Date = new Date();
endTime: Date = new Date(); endTime: Date = new Date();
@ -160,6 +161,7 @@ export class ProductionBonusAttendanceComponent implements OnInit {
loadLines(value: any) { loadLines(value: any) {
// console.log('Selected value changed:', newValue); // console.log('Selected value changed:', newValue);
// debugger; // debugger;
this.selectedDate = undefined;
this.loadingPanelService.ShowLoadingPanel = true; this.loadingPanelService.ShowLoadingPanel = true;
debugger; debugger;
// this.bonusService.getLines(this.selectedProdBSdata.id).subscribe( // this.bonusService.getLines(this.selectedProdBSdata.id).subscribe(
@ -189,33 +191,34 @@ export class ProductionBonusAttendanceComponent implements OnInit {
onClickLoad() { onClickLoad() {
// debugger; // debugger;
const fromDate = new Date(this.productionBonusSetup.fromDate.setHours(0, 0, 0, 0)); // const fromDate = new Date(this.productionBonusSetup.fromDate.setHours(0, 0, 0, 0));
const toDate = new Date(this.productionBonusSetup.toDate.setHours(0, 0, 0, 0)); // const toDate = new Date(this.productionBonusSetup.toDate.setHours(0, 0, 0, 0));
const selectedDate = new Date(this.selectedDate.setHours(0, 0, 0, 0)); // const selectedDate = new Date(this.selectedDate.setHours(0, 0, 0, 0));
if (selectedDate >= fromDate && selectedDate <= toDate) { // if (selectedDate >= fromDate && selectedDate <= toDate) {
var dataForAttn = { // var dataForAttn = {
setupId: this.productionBonusSetup.id, // setupId: this.productionBonusSetup.id,
lineId: this.selectedLine.id, // lineId: this.selectedLine.id,
date: this.selectedDate // date: this.selectedDate
} // }
// console.log(dataForAttn); // // console.log(dataForAttn);
this.loadingPanelService.ShowLoadingPanel = true; // this.loadingPanelService.ShowLoadingPanel = true;
this.bonusService.getProdBonusAtten(dataForAttn).subscribe( // this.bonusService.getProdBonusAtten(dataForAttn).subscribe(
(resp) => { // (resp) => {
this.prodBonusAttn = resp; // this.prodBonusAttn = resp;
// console.log('Attn List', this.prodBonusAttn); // // console.log('Attn List', this.prodBonusAttn);
// console.log(this.prodBonusAttn); // // console.log(this.prodBonusAttn);
}, // },
(err) => { // (err) => {
this.notificationService.showError(err.error); // this.notificationService.showError(err.error);
this.loadingPanelService.ShowLoadingPanel = false; // this.loadingPanelService.ShowLoadingPanel = false;
}, // },
() => { // () => {
this.loadingPanelService.ShowLoadingPanel = false; // this.loadingPanelService.ShowLoadingPanel = false;
this.employeeList = []; // this.employeeList = [];
// debugger; // debugger;
if (this.prodBonusAttn.length <= 0 && (this.productionBonusSetup.productionBonusType == EnumProductionBonusType.Cutting || if (this.prodBonusAttn.length <= 0 && (this.productionBonusSetup.productionBonusType == EnumProductionBonusType.Cutting ||
this.productionBonusSetup.productionBonusType == EnumProductionBonusType.Finishing)) { this.productionBonusSetup.productionBonusType == EnumProductionBonusType.Finishing)) {
this.employeeList = [];
let data = { let data = {
prodLine: this.selectedLine, prodLine: this.selectedLine,
date: this.selectedDate date: this.selectedDate
@ -235,21 +238,12 @@ export class ProductionBonusAttendanceComponent implements OnInit {
this.loadingPanelService.ShowLoadingPanel = false; this.loadingPanelService.ShowLoadingPanel = false;
} }
); );
// if (this.selectedLine.prodBonusParameters !== null && this.selectedLine.prodBonusParameters.length > 0) {
// var desigparam: ProdBonusParameter;
// desigparam = this.selectedLine.prodBonusParameters.find(o => o.itemType == EnumBonusItemType.Designation);
// // var pbp: ProdBonusParameter;
// for (let pbp in this.selectedLine.prodBonusParameters) {
// if (pbp['itemType'] == EnumBonusItemType.Department) {
// oTempEmployees: Employee[] = this.employeeList.filter(e1 => e1.DepartmentID === pbp['itemID'] && e1.DesignationID !== 2);
// }
// }
// }
} }
//New For Swing And Printig //New For Swing And Printig
if (this.prodBonusAttn.length <= 0 && (this.productionBonusSetup.productionBonusType == EnumProductionBonusType.Sewing || if (this.prodBonusAttn.length <= 0 && (this.productionBonusSetup.productionBonusType == EnumProductionBonusType.Sewing ||
this.productionBonusSetup.productionBonusType == EnumProductionBonusType.Printing)) { this.productionBonusSetup.productionBonusType == EnumProductionBonusType.Printing)) {
this.employeeList = [];
let data = { let data = {
prodLine: this.selectedLine, prodLine: this.selectedLine,
date: this.selectedDate date: this.selectedDate
@ -271,25 +265,25 @@ export class ProductionBonusAttendanceComponent implements OnInit {
); );
} }
if (this.prodBonusAttn.length > 0) { // if (this.prodBonusAttn.length > 0) {
debugger; // debugger;
for (let i = 0; i < this.prodBonusAttn.length; i++) { // this.employeeList = [];
this.AddEmployeebyId(this.prodBonusAttn[i].employeeID); // for (let i = 0; i < this.prodBonusAttn.length; i++) {
} // this.AddEmployeebyId(this.prodBonusAttn[i].employeeID);
let inTime = new Date(this.prodBonusAttn[0].inTime); // }
let outTime = new Date(this.prodBonusAttn[0].outTime); // let inTime = new Date(this.prodBonusAttn[0].inTime);
this.startTime = this.setTime(inTime, inTime.getHours(), inTime.getMinutes(), inTime.getSeconds()); // let outTime = new Date(this.prodBonusAttn[0].outTime);
this.endTime = this.setTime(outTime, outTime.getHours(), outTime.getMinutes(), outTime.getSeconds()); // this.startTime = this.setTime(inTime, inTime.getHours(), inTime.getMinutes(), inTime.getSeconds());
} // this.endTime = this.setTime(outTime, outTime.getHours(), outTime.getMinutes(), outTime.getSeconds());
} // }
); // }
} // );
else { // }
this.notificationService.showWarning('Date did not match with Work Schedule','Schedule not matched!'); // else {
} // this.notificationService.showWarning('Date did not match with Work Schedule','Schedule not matched!');
// }
} }
onClickAdd() { onClickAdd() {
// console.log(this.employeeSelection);
debugger; debugger;
if (this.selectedEmps === undefined) { if (this.selectedEmps === undefined) {
this.notificationService.showWarning('Please Select an Employee'); this.notificationService.showWarning('Please Select an Employee');
@ -297,11 +291,6 @@ export class ProductionBonusAttendanceComponent implements OnInit {
} }
if (this.employeeSelection === 'commonEmployee') { if (this.employeeSelection === 'commonEmployee') {
if (this.selectedEmps !== null || this.selectedEmps !== undefined) { if (this.selectedEmps !== null || this.selectedEmps !== undefined) {
// console.log(this.selectedEmps);
// console.log(this.employeeList);
// for (let i = 0; i < this.selectedEmps.length; i++) {
// this.AddEmployeebyId(this.selectedEmps[i].employeeID);
// }
for (let i = 0, isNew = true; i < this.selectedEmps.length; i++, isNew = true) { for (let i = 0, isNew = true; i < this.selectedEmps.length; i++, isNew = true) {
for (let j = 0; j < this.employeeList.length; j++) { for (let j = 0; j < this.employeeList.length; j++) {
if (this.selectedEmps[i].employeeID == this.employeeList[j].id) { if (this.selectedEmps[i].employeeID == this.employeeList[j].id) {
@ -350,21 +339,6 @@ export class ProductionBonusAttendanceComponent implements OnInit {
} }
} }
AddEmployeebyId(empId: number) { AddEmployeebyId(empId: number) {
// this.loadingPanelService.ShowLoadingPanel = true;
// this.employeeService.getEmployeeByID(empId).subscribe(
// (resp) => {
// this.employeeList.push(resp);
// },
// (err) => {
// this.notificationService.showError(err.error);
// this.loadingPanelService.ShowLoadingPanel = false;
// },
// () => {
// // this.AddEmployeeGridData(empId, isCommonValue);
// // console.log(this.prodBonusAttn);
// this.loadingPanelService.ShowLoadingPanel = false;
// }
// );
this.employeeList.push(this.allEmps.find(e => e.id == empId)); this.employeeList.push(this.allEmps.find(e => e.id == empId));
} }
AddEmployeeGridData(empId: number, isCommonValue: boolean) { AddEmployeeGridData(empId: number, isCommonValue: boolean) {
@ -381,29 +355,9 @@ export class ProductionBonusAttendanceComponent implements OnInit {
isCommon: false isCommon: false
}; };
this.prodBonusAttn.push(newProdBonusAttn); this.prodBonusAttn.push(newProdBonusAttn);
// console.log('emplist ' + this.employeeList.length + '\n PbAttn ' + this.prodBonusAttn.length);
// this.selectedEmps = undefined; // this.selectedEmps = undefined;
} }
// GetSelectedEmployee(sremployee: SearchEmployee) {
// if (sremployee === undefined) {
// this._employee = new Employee();
// return;
// }
// this.loadingPanelService.ShowLoadingPanel = true;
// this.employeeService.getEmployeeByID(sremployee.employeeID).subscribe(
// (resp: any) => {
// this._employee = resp;
// },
// (err: any) => {
// this.loadingPanelService.ShowLoadingPanel = false;
// },
// () => {
// this.loadingPanelService.ShowLoadingPanel = false;
// }
// );
// }
onClickSubmit() { onClickSubmit() {
// console.log(this.prodBonusAttn);
debugger; debugger;
if (this.startTime == undefined || this.endTime == undefined) { if (this.startTime == undefined || this.endTime == undefined) {
this.notificationService.showWarning('Please Select In/Out Time'); this.notificationService.showWarning('Please Select In/Out Time');
@ -466,6 +420,8 @@ export class ProductionBonusAttendanceComponent implements OnInit {
this.productionBonusSetup = new ProductionBonusSetup(); this.productionBonusSetup = new ProductionBonusSetup();
this.employeeList = []; this.employeeList = [];
this.selectedLine = undefined; this.selectedLine = undefined;
this.selectedProdBSdata = undefined;
this.selectedDate = undefined;
} }
public onKeyDown(pressedKey) { public onKeyDown(pressedKey) {
@ -496,5 +452,52 @@ export class ProductionBonusAttendanceComponent implements OnInit {
date.setSeconds(sec); date.setSeconds(sec);
return date; return date;
} }
public scheduleDateChange(date: any){
debugger;
date;
if(this.selectedProdBSdata != undefined && this.selectedLine != undefined ){
const fromDate = new Date(this.productionBonusSetup.fromDate.setHours(0, 0, 0, 0));
const toDate = new Date(this.productionBonusSetup.toDate.setHours(0, 0, 0, 0));
const selectedDate = new Date(this.selectedDate.setHours(0, 0, 0, 0));
if (selectedDate >= fromDate && selectedDate <= toDate) {
var dataForAttn = {
setupId: this.productionBonusSetup.id,
lineId: this.selectedLine.id,
date: this.selectedDate
}
this.loadingPanelService.ShowLoadingPanel = true;
this.bonusService.getProdBonusAtten(dataForAttn).subscribe(
(resp) => {
this.prodBonusAttn = resp;
},
(err) => {
this.notificationService.showError(err.error);
this.loadingPanelService.ShowLoadingPanel = false;
},
() => {
this.loadingPanelService.ShowLoadingPanel = false;
if (this.prodBonusAttn.length > 0) {
debugger;
this.employeeList = [];
for (let i = 0; i < this.prodBonusAttn.length; i++) {
this.AddEmployeebyId(this.prodBonusAttn[i].employeeID);
}
let inTime = new Date(this.prodBonusAttn[0].inTime);
let outTime = new Date(this.prodBonusAttn[0].outTime);
this.startTime = this.setTime(inTime, inTime.getHours(), inTime.getMinutes(), inTime.getSeconds());
this.endTime = this.setTime(outTime, outTime.getHours(), outTime.getMinutes(), outTime.getSeconds());
}
else{
this.employeeList.forEach(x => this.AddEmployeeGridData(x.id, false));
}
}
);
}
else {
this.notificationService.showWarning('Date did not match with Work Schedule','Schedule not matched!');
}
}
}
} }

View File

@ -666,7 +666,9 @@ namespace HRM.UI.Controllers.Payroll
ProdBonusLine _oProdBonusLine = (ProdBonusLine)item["prodLine"].ToObject<ProdBonusLine>(); ProdBonusLine _oProdBonusLine = (ProdBonusLine)item["prodLine"].ToObject<ProdBonusLine>();
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User); CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<Employee> _oEmployees = new EmployeeService().Get(EnumEmployeeStatus.Live, (int)currentUser.PayrollTypeID); //List<Employee> _oEmployees = new EmployeeService().Get(EnumEmployeeStatus.Live, (int)currentUser.PayrollTypeID);
DataTable EmployeeDT = new EmployeeService().GetEmployeeNameAndNo((int)currentUser.PayrollTypeID);
List<Employee> _oFinalEmployees = new List<Employee>(); List<Employee> _oFinalEmployees = new List<Employee>();
List<ProdBonusParameter> _oProdBonusParameters = new List<ProdBonusParameter>(); List<ProdBonusParameter> _oProdBonusParameters = new List<ProdBonusParameter>();
List<ProdBonusSupervisor> _oProdBonusSupervisors = new List<ProdBonusSupervisor>(); List<ProdBonusSupervisor> _oProdBonusSupervisors = new List<ProdBonusSupervisor>();
@ -684,7 +686,13 @@ namespace HRM.UI.Controllers.Payroll
{ {
foreach (var pda in _oProdBonusAttns) foreach (var pda in _oProdBonusAttns)
{ {
Employee emp = _oEmployees.Find(o => o.ID == pda.EmployeeID); //Employee emp = _oEmployees.Find(o => o.ID == pda.EmployeeID);
DataRow[] foundRows = EmployeeDT.Select($"id = {pda.EmployeeID}");
Employee emp = new Employee();
emp.ID = Convert.ToInt32(foundRows[0]["id"]);
emp.EmployeeNo = Convert.ToString(foundRows[0]["EmployeeNo"]);
emp.Name = Convert.ToString(foundRows[0]["Name"]);
if (emp != null) _oFinalEmployees.Add(emp); if (emp != null) _oFinalEmployees.Add(emp);
} }