You are on page 1of 2

const userData= await employeeService.

getEmpByPhone('8876233088');
const manager= await employeeService.getEmpById(userData.manager_id);
const user={
e_name: userData.e_name,
e_id: userData.e_id,
email_id: userData.email_id,
contact_number: userData.contact_number,
pod_id: userData.pod_id,
managerName: manager.e_name
}
const month="DECEMBER";
const year="2025";
const ArrayOfDates=getMonthDates('2022', '01' )
const shiftPlan = await shiftPlanService.getAllByPod(ArrayOfDates,
user.pod_id);
const WeekDay={
0:"Su",
1:"Mo",
2:"Tu",
3:"We",
4:"Th",
5:"Fr",
6:"Sa"
}
let monthDay=[];
let monthDate=[];
for(let i=0; i<ArrayOfDates.length; i++)
{
let d=new Date(`${ArrayOfDates[i]}`)
monthDay.push(WeekDay[d.getDay()])
monthDate.push(ArrayOfDates[i].slice(8,10))
}
// generate();
// console.log("user", shiftPlan)
const empByPod=await employeeService.getAllEmpByPodId(user.pod_id)
const empIds= empByPod.map(data=>data.e_id)
let empIdNameObj={}
let schedule=[];
for(let i=0; i<empByPod.length; i++)
{
let empShiftRow=[];
empShiftRow.push(empIds[i]);
schedule.push(empShiftRow)

empIdNameObj[empByPod[i].e_id]=empByPod[i].e_name
}

// const empNames= empByPod.map(data=>data.e_name)


//
for(let i=0; i<shiftPlan.length; i++)
{
const empIndex=empIds.indexOf(shiftPlan[i].e_id)

schedule[empIndex].push(shiftPlan[i].shift_code)

}
for(let i=0; i<schedule.length; i++)
{
schedule[i][0]=empIdNameObj[schedule[i][0]]
}

You might also like