Commit c8931b7f authored by vikram singh's avatar vikram singh

"Added Service for Account by billability."

parent a3ec008a
package com.nisum.myteam.controller; package com.nisum.myteam.controller;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.group; import static org.springframework.data.mongodb.core.aggregation.Aggregation.group;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.newAggregation; import static org.springframework.data.mongodb.core.aggregation.Aggregation.newAggregation;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.project; import static org.springframework.data.mongodb.core.aggregation.Aggregation.project;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.sort; import static org.springframework.data.mongodb.core.aggregation.Aggregation.sort;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.nisum.myteam.service.IReportService; import com.nisum.myteam.service.IReportService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.aggregation.Aggregation; import org.springframework.data.mongodb.core.aggregation.Aggregation;
import org.springframework.data.mongodb.core.aggregation.AggregationResults; import org.springframework.data.mongodb.core.aggregation.AggregationResults;
import org.springframework.data.mongodb.core.aggregation.MatchOperation; import org.springframework.data.mongodb.core.aggregation.MatchOperation;
import org.springframework.data.mongodb.core.aggregation.ProjectionOperation; import org.springframework.data.mongodb.core.aggregation.ProjectionOperation;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.nisum.myteam.exception.handler.MyTeamException; import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.BillableEmployee; import com.nisum.myteam.model.Reports;
import com.nisum.myteam.model.ColumnChartData; import com.nisum.myteam.model.ColumnChartData;
import com.nisum.myteam.model.GroupByCount; import com.nisum.myteam.model.GroupByCount;
import com.nisum.myteam.model.ReportSeriesRecord; import com.nisum.myteam.model.ReportSeriesRecord;
import com.nisum.myteam.model.dao.Account; import com.nisum.myteam.model.dao.Account;
import com.nisum.myteam.model.dao.Employee; import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.Resource; import com.nisum.myteam.model.dao.Resource;
import com.nisum.myteam.model.vo.ReportVo; import com.nisum.myteam.model.vo.ReportVo;
import com.nisum.myteam.model.vo.ResourceVO; import com.nisum.myteam.model.vo.ResourceVO;
import com.nisum.myteam.service.IAccountService; import com.nisum.myteam.service.IAccountService;
import com.nisum.myteam.service.IEmployeeService; import com.nisum.myteam.service.IEmployeeService;
import com.nisum.myteam.service.IResourceService; import com.nisum.myteam.service.IResourceService;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
//import com.nisum.myteam.model.dao.Resource; //import com.nisum.myteam.model.dao.Resource;
@RestController @RestController
@RequestMapping("/reports") @RequestMapping("/reports")
public class ReportsController { public class ReportsController {
@Autowired @Autowired
private MongoTemplate mongoTemplate; private MongoTemplate mongoTemplate;
@Autowired @Autowired
private IEmployeeService employeeService; private IEmployeeService employeeService;
@Autowired @Autowired
private IResourceService resourceService; private IResourceService resourceService;
@Autowired @Autowired
private IAccountService accountService; private IAccountService accountService;
@Autowired @Autowired
private IReportService reportService; private IReportService reportService;
//Ok Response //Ok Response
@RequestMapping(value = "/getEmployeesByFunctionalGroup1", @RequestMapping(value = "/getEmployeesByFunctionalGroup1",
method = RequestMethod.GET, method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<GroupByCount>> getEmployeesByFunctionalGroup() public ResponseEntity<List<GroupByCount>> getEmployeesByFunctionalGroup()
throws MyTeamException { throws MyTeamException {
ProjectionOperation projectToMatchModel = project() ProjectionOperation projectToMatchModel = project()
.andExpression("functionalGroup").as("name").andExpression("y") .andExpression("functionalGroup").as("name").andExpression("y")
.as("y"); .as("y");
Aggregation agg = newAggregation( Aggregation agg = newAggregation(
// match(Criteria.where("employeeId").gt(10)), // match(Criteria.where("employeeId").gt(10)),
group("functionalGroup").count().as("y"), group("functionalGroup").count().as("y"),
project("y").and("functionalGroup").previousOperation(), project("y").and("functionalGroup").previousOperation(),
projectToMatchModel, projectToMatchModel,
sort(Sort.Direction.DESC, "y") sort(Sort.Direction.DESC, "y")
); );
// Convert the aggregation result into a List // Convert the aggregation result into a List
AggregationResults<GroupByCount> groupResults = mongoTemplate AggregationResults<GroupByCount> groupResults = mongoTemplate
.aggregate(agg, Employee.class, GroupByCount.class); .aggregate(agg, Employee.class, GroupByCount.class);
List<GroupByCount> result = groupResults.getMappedResults(); List<GroupByCount> result = groupResults.getMappedResults();
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
//Ok Response //Ok Response
@RequestMapping(value = "/getEmployeesByFunctionalGroupForReport", @RequestMapping(value = "/getEmployeesByFunctionalGroupForReport",
method = RequestMethod.GET, method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ColumnChartData> getEmployeesByFunctionalGroupForReport() public ResponseEntity<ColumnChartData> getEmployeesByFunctionalGroupForReport()
throws MyTeamException { throws MyTeamException {
ProjectionOperation projectToMatchModel = project() ProjectionOperation projectToMatchModel = project()
.andExpression("functionalGroup").as("name").andExpression("y") .andExpression("functionalGroup").as("name").andExpression("y")
.as("y"); .as("y");
MatchOperation matchStage = Aggregation MatchOperation matchStage = Aggregation
.match(new Criteria("empStatus").is("Active")); .match(new Criteria("empStatus").is("Active"));
Aggregation agg = newAggregation( Aggregation agg = newAggregation(
// match(Criteria.where("employeeId").gt(10)), // match(Criteria.where("employeeId").gt(10)),
matchStage, group("functionalGroup").count().as("y"), matchStage, group("functionalGroup").count().as("y"),
project("y").and("functionalGroup").previousOperation(), project("y").and("functionalGroup").previousOperation(),
projectToMatchModel, projectToMatchModel,
sort(Sort.Direction.DESC, "y") sort(Sort.Direction.DESC, "y")
); );
// Convert the aggregation result into a List // Convert the aggregation result into a List
AggregationResults<GroupByCount> groupResults = mongoTemplate AggregationResults<GroupByCount> groupResults = mongoTemplate
.aggregate(agg, Employee.class, GroupByCount.class); .aggregate(agg, Employee.class, GroupByCount.class);
List<GroupByCount> result = groupResults.getMappedResults(); List<GroupByCount> result = groupResults.getMappedResults();
ColumnChartData reportData = new ColumnChartData(); ColumnChartData reportData = new ColumnChartData();
reportData.setCategories("data"); reportData.setCategories("data");
reportData.setSeriesDataList(result); reportData.setSeriesDataList(result);
return new ResponseEntity<>(reportData, HttpStatus.OK); return new ResponseEntity<>(reportData, HttpStatus.OK);
} }
//ok response //ok response
@RequestMapping(value = "/getBillabilityDetailsByMonth", @RequestMapping(value = "/getBillabilityDetailsByMonth",
method = RequestMethod.GET, method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ColumnChartData> getBillabilityDetailsByMonth() public ResponseEntity<ColumnChartData> getBillabilityDetailsByMonth()
throws MyTeamException { throws MyTeamException {
Date reportDate = new Date(); Date reportDate = new Date();
Map m = new HashMap(); Map m = new HashMap();
ReportSeriesRecord reportSeriesRecordBillable = new ReportSeriesRecord(); ReportSeriesRecord reportSeriesRecordBillable = new ReportSeriesRecord();
reportSeriesRecordBillable.setName("Billable"); reportSeriesRecordBillable.setName("Billable");
reportSeriesRecordBillable.setData(new long[12]); reportSeriesRecordBillable.setData(new long[12]);
m.put("Billable", reportSeriesRecordBillable); m.put("Billable", reportSeriesRecordBillable);
ReportSeriesRecord reportSeriesRecordShadow = new ReportSeriesRecord(); ReportSeriesRecord reportSeriesRecordShadow = new ReportSeriesRecord();
reportSeriesRecordShadow.setName("Shadow"); reportSeriesRecordShadow.setName("Shadow");
reportSeriesRecordShadow.setData(new long[12]); reportSeriesRecordShadow.setData(new long[12]);
m.put("Shadow", reportSeriesRecordShadow); m.put("Shadow", reportSeriesRecordShadow);
ReportSeriesRecord reportSeriesRecordReserved = new ReportSeriesRecord(); ReportSeriesRecord reportSeriesRecordReserved = new ReportSeriesRecord();
reportSeriesRecordReserved.setName("Reserved"); reportSeriesRecordReserved.setName("Reserved");
reportSeriesRecordReserved.setData(new long[12]); reportSeriesRecordReserved.setData(new long[12]);
m.put("Reserved", reportSeriesRecordReserved); m.put("Reserved", reportSeriesRecordReserved);
ReportSeriesRecord reportSeriesRecordNBillable = new ReportSeriesRecord(); ReportSeriesRecord reportSeriesRecordNBillable = new ReportSeriesRecord();
reportSeriesRecordNBillable.setName("Non-Billable"); reportSeriesRecordNBillable.setName("Non-Billable");
reportSeriesRecordNBillable.setData(new long[12]); reportSeriesRecordNBillable.setData(new long[12]);
m.put("Non-Billable", reportSeriesRecordNBillable); m.put("Non-Billable", reportSeriesRecordNBillable);
List<String> catagories = new ArrayList(); List<String> catagories = new ArrayList();
for (int i = 0; i < 12; i++) { for (int i = 0; i < 12; i++) {
reportDate = new Date(); reportDate = new Date();
reportDate.setDate(1); reportDate.setDate(1);
reportDate.setMonth(i); reportDate.setMonth(i);
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(reportDate); calendar.setTime(reportDate);
int lastDate = calendar.getActualMaximum(Calendar.DATE); int lastDate = calendar.getActualMaximum(Calendar.DATE);
reportDate.setDate(lastDate); reportDate.setDate(lastDate);
String pattern = "MM-dd-yyyy"; String pattern = "MM-dd-yyyy";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
String date = simpleDateFormat.format(reportDate); String date = simpleDateFormat.format(reportDate);
catagories.add(date); catagories.add(date);
Criteria criteriaV1 = Criteria.where("billingStartDate") Criteria criteriaV1 = Criteria.where("billingStartDate")
.lt(reportDate); .lt(reportDate);
Criteria criteriaV21 = Criteria.where("billingEndDate").is(null); Criteria criteriaV21 = Criteria.where("billingEndDate").is(null);
Criteria criteriaV22 = Criteria.where("billingEndDate") Criteria criteriaV22 = Criteria.where("billingEndDate")
.gt(reportDate); .gt(reportDate);
Criteria criteriaV221 = criteriaV1.orOperator(criteriaV21, Criteria criteriaV221 = criteriaV1.orOperator(criteriaV21,
criteriaV22); criteriaV22);
/* /*
* MatchOperation matchStage = Aggregation.match(new Criteria() * MatchOperation matchStage = Aggregation.match(new Criteria()
* .andOperator(criteriaV1).andOperator(criteriaV221)); * .andOperator(criteriaV1).andOperator(criteriaV221));
*/ */
MatchOperation matchStage = Aggregation.match(criteriaV221); MatchOperation matchStage = Aggregation.match(criteriaV221);
Aggregation agg1 = newAggregation(matchStage, Aggregation agg1 = newAggregation(matchStage,
group("billableStatus").count().as("count"), group("billableStatus").count().as("count"),
project("count").and("billableStatus").previousOperation()); project("count").and("billableStatus").previousOperation());
// Convert the aggregation result into a List // Convert the aggregation result into a List
AggregationResults<ColumnChartData> groupResults1 = mongoTemplate AggregationResults<ColumnChartData> groupResults1 = mongoTemplate
.aggregate(agg1, Resource.class, .aggregate(agg1, Resource.class,
ColumnChartData.class); ColumnChartData.class);
List<ColumnChartData> result1 = groupResults1.getMappedResults(); List<ColumnChartData> result1 = groupResults1.getMappedResults();
List<String> statusList = new ArrayList(); List<String> statusList = new ArrayList();
statusList.add("Billable"); statusList.add("Billable");
statusList.add("Shadow"); statusList.add("Shadow");
statusList.add("Reserved"); statusList.add("Reserved");
statusList.add("Non-Billable"); statusList.add("Non-Billable");
for (String status : statusList) { for (String status : statusList) {
for (ColumnChartData columnChartData : result1) { for (ColumnChartData columnChartData : result1) {
if (columnChartData.getBillableStatus() != null if (columnChartData.getBillableStatus() != null
&& columnChartData.getBillableStatus() && columnChartData.getBillableStatus()
.equalsIgnoreCase(status)) { .equalsIgnoreCase(status)) {
ReportSeriesRecord record = (ReportSeriesRecord) m ReportSeriesRecord record = (ReportSeriesRecord) m
.get(status); .get(status);
record.getData()[i] = columnChartData.getCount(); record.getData()[i] = columnChartData.getCount();
} }
} }
} }
} }
ColumnChartData reportData = new ColumnChartData(); ColumnChartData reportData = new ColumnChartData();
System.out.println("catagories" + catagories); System.out.println("catagories" + catagories);
System.out.println("m.values()" + m.values()); System.out.println("m.values()" + m.values());
reportData.setCategoriesList(catagories); reportData.setCategoriesList(catagories);
reportData.setSeriesDataList(new ArrayList<String>(m.values())); reportData.setSeriesDataList(new ArrayList<String>(m.values()));
return new ResponseEntity<>(reportData, HttpStatus.OK); return new ResponseEntity<>(reportData, HttpStatus.OK);
} }
//ok response //ok response
@RequestMapping(value = "/getEmployeesByFunctionalGroup", @RequestMapping(value = "/getEmployeesByFunctionalGroup",
method = RequestMethod.GET, method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, List<GroupByCount>>>> getEmployeesByFunctionalGroup1() public ResponseEntity<List<Map<String, List<GroupByCount>>>> getEmployeesByFunctionalGroup1()
throws MyTeamException { throws MyTeamException {
ProjectionOperation projectToMatchModel = project() ProjectionOperation projectToMatchModel = project()
.andExpression("functionalGroup").as("name").andExpression("y") .andExpression("functionalGroup").as("name").andExpression("y")
.as("y"); .as("y");
MatchOperation matchStage = Aggregation MatchOperation matchStage = Aggregation
.match(new Criteria("empStatus").is("Active")); .match(new Criteria("empStatus").is("Active"));
Aggregation agg = newAggregation( Aggregation agg = newAggregation(
// match(Criteria.where("employeeId").gt(10)), // match(Criteria.where("employeeId").gt(10)),
matchStage, group("functionalGroup").count().as("y"), matchStage, group("functionalGroup").count().as("y"),
project("y").and("functionalGroup").previousOperation(), project("y").and("functionalGroup").previousOperation(),
projectToMatchModel, projectToMatchModel,
sort(Sort.Direction.DESC, "y") sort(Sort.Direction.DESC, "y")
); );
// Convert the aggregation result into a List // Convert the aggregation result into a List
AggregationResults<GroupByCount> groupResults = mongoTemplate AggregationResults<GroupByCount> groupResults = mongoTemplate
.aggregate(agg, Employee.class, GroupByCount.class); .aggregate(agg, Employee.class, GroupByCount.class);
List<GroupByCount> result = groupResults.getMappedResults(); List<GroupByCount> result = groupResults.getMappedResults();
Map<String, List<GroupByCount>> map = new HashMap<String, List<GroupByCount>>(); Map<String, List<GroupByCount>> map = new HashMap<String, List<GroupByCount>>();
map.put("data", result); map.put("data", result);
List<Map<String, List<GroupByCount>>> list = new ArrayList<Map<String, List<GroupByCount>>>(); List<Map<String, List<GroupByCount>>> list = new ArrayList<Map<String, List<GroupByCount>>>();
list.add(map); list.add(map);
return new ResponseEntity<>(list, HttpStatus.OK); return new ResponseEntity<>(list, HttpStatus.OK);
} }
@RequestMapping(value = "/fetchEmployeeDetailsByFGAndBillability", @RequestMapping(value = "/fetchEmployeeDetailsByFGAndBillability",
method = RequestMethod.GET, method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<BillableEmployee>> getEmployeesByFGAndBillability( public ResponseEntity<List<Reports>> getEmployeesByFGAndBillability(
@RequestParam("fGroup") String fGroup , @RequestParam("billableStatus") String billableStatus) throws MyTeamException { @RequestParam("fGroup") String fGroup , @RequestParam("billableStatus") String billableStatus) throws MyTeamException {
List<BillableEmployee> empList = new ArrayList<>(); List<Reports> empList=null;
empList = employeeService.getEmployeeDetailsByFGAndBillability(fGroup,billableStatus); empList = reportService.getEmployeeDetailsByFGAndBillability(fGroup,billableStatus);
return new ResponseEntity<>(empList, HttpStatus.OK);
return new ResponseEntity<>(empList, HttpStatus.OK); }
}
// @RequestMapping(value = "/fetchEmployeeDetailsByAccountBillability",
@RequestMapping(value = "/fetchEmployeeDetailsByAccountBillability", // method = RequestMethod.GET,
method = RequestMethod.GET, // produces = MediaType.APPLICATION_JSON_VALUE)
produces = MediaType.APPLICATION_JSON_VALUE) // public ResponseEntity<List<ResourceVO>> fetchEmployeeDetailsByAccountBillability(
public ResponseEntity<List<ResourceVO>> fetchEmployeeDetailsByAccountBillability( // @RequestParam("account") String account,
@RequestParam("account") String account, // @RequestParam("billabilityStatus") String billabilityStatus)
@RequestParam("billabilityStatus") String billabilityStatus) // throws MyTeamException {
throws MyTeamException { // List<ResourceVO> resourcesList = new ArrayList<>();
List<ResourceVO> resourcesList = new ArrayList<>(); // if (account != null && !account.isEmpty()) {
if (account != null && !account.isEmpty()) { // resourcesList = resourceService.getAllResourcesVO();
//
resourcesList = resourceService.getAllResourcesVO(); // }
// return new ResponseEntity<>(resourcesList, HttpStatus.OK);
} // }
return new ResponseEntity<>(resourcesList, HttpStatus.OK);
}
@RequestMapping(value = "/fetchEmployeeDetailsByDateBillability",
method = RequestMethod.GET,
@RequestMapping(value = "/fetchEmployeeDetailsByDateBillability", produces = MediaType.APPLICATION_JSON_VALUE)
method = RequestMethod.GET, public ResponseEntity<List<Resource>> fetchEmployeeDetailsByDateBillability(
produces = MediaType.APPLICATION_JSON_VALUE) @RequestParam("billabilityStatus") String billabilityStatus,
public ResponseEntity<List<Resource>> fetchEmployeeDetailsByDateBillability( @RequestParam("reportDate") String reportDateString)
@RequestParam("billabilityStatus") String billabilityStatus, throws MyTeamException {
@RequestParam("reportDate") String reportDateString) List<Resource> empList = new ArrayList<>();
throws MyTeamException { if (reportDateString != null && !reportDateString.isEmpty()) {
List<Resource> empList = new ArrayList<>(); String pattern = "MM-dd-yyyy";
if (reportDateString != null && !reportDateString.isEmpty()) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
String pattern = "MM-dd-yyyy"; Date reportDateValue = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); try {
Date reportDateValue = new Date(); reportDateValue = simpleDateFormat.parse(reportDateString);
try { } catch (ParseException e) {
reportDateValue = simpleDateFormat.parse(reportDateString); // TODO Auto-generated catch block
} catch (ParseException e) { e.printStackTrace();
// TODO Auto-generated catch block }
e.printStackTrace();
} Criteria status = Criteria.where("billableStatus")
.is(billabilityStatus);
Criteria status = Criteria.where("billableStatus") Criteria criteriaV1 = Criteria.where("billingStartDate")
.is(billabilityStatus); .lt(reportDateValue);
Criteria criteriaV1 = Criteria.where("billingStartDate") Criteria criteriaV21 = Criteria.where("billingEndDate").is(null);
.lt(reportDateValue); Criteria criteriaV22 = Criteria.where("billingEndDate")
Criteria criteriaV21 = Criteria.where("billingEndDate").is(null); .gt(reportDateValue);
Criteria criteriaV22 = Criteria.where("billingEndDate") Criteria criteriaV221 = status.andOperator(
.gt(reportDateValue); criteriaV1.orOperator(criteriaV21, criteriaV22));
Criteria criteriaV221 = status.andOperator( Query query = new Query();
criteriaV1.orOperator(criteriaV21, criteriaV22)); query.addCriteria(criteriaV221);
Query query = new Query(); empList = mongoTemplate.find(query, Resource.class);
query.addCriteria(criteriaV221); }
empList = mongoTemplate.find(query, Resource.class); return new ResponseEntity<>(empList, HttpStatus.OK);
} }
return new ResponseEntity<>(empList, HttpStatus.OK);
} @RequestMapping(value = "/getBarChartReport",
method = RequestMethod.GET,
@RequestMapping(value = "/getBarChartReport", produces = MediaType.APPLICATION_JSON_VALUE)
method = RequestMethod.GET, public ReportVo billabilityReportByFunctionalGroup(@RequestParam("byType") String byType) throws MyTeamException {
produces = MediaType.APPLICATION_JSON_VALUE)
public ReportVo billabilityReportByFunctionalGroup(@RequestParam("byType") String byType) throws MyTeamException {
return reportService.getBarChartReport(byType);
}
return reportService.getBarChartReport(byType);
}
//Not Ok Response
@RequestMapping(value = "/getBillabilityDetailsByAccount",
//Not Ok Response method = RequestMethod.GET,
@RequestMapping(value = "/getBillabilityDetailsByAccount", produces = MediaType.APPLICATION_JSON_VALUE)
method = RequestMethod.GET, public ResponseEntity<ColumnChartData> getBillabilityDetailsByAccount()
produces = MediaType.APPLICATION_JSON_VALUE) throws MyTeamException {
public ResponseEntity<ColumnChartData> getBillabilityDetailsByAccount()
throws MyTeamException {
ProjectionOperation projectToMatchModel = project()
.andExpression("account").as("categories")
ProjectionOperation projectToMatchModel = project() .andExpression("billableStatus").as("seriesName")
.andExpression("account").as("categories") .andExpression("count").as("count");
.andExpression("billableStatus").as("seriesName")
.andExpression("count").as("count"); MatchOperation matchStage = Aggregation
.match(new Criteria("active").is(true));
MatchOperation matchStage = Aggregation Aggregation aggregate = Aggregation.newAggregation(matchStage,
.match(new Criteria("active").is(true)); Aggregation.group("account", "billableStatus").count()
Aggregation aggregate = Aggregation.newAggregation(matchStage, .as("count"),
Aggregation.group("account", "billableStatus").count() projectToMatchModel);
.as("count"),
projectToMatchModel);
// Convert the aggregation result into a List
AggregationResults<ColumnChartData> groupResults = mongoTemplate.aggregate(aggregate, Resource.class,
// Convert the aggregation result into a List ColumnChartData.class);
AggregationResults<ColumnChartData> groupResults = mongoTemplate.aggregate(aggregate, Resource.class, List<ColumnChartData> result = groupResults.getMappedResults();
ColumnChartData.class); List<String> statusList = new ArrayList();
List<ColumnChartData> result = groupResults.getMappedResults(); statusList.add("Billable");
List<String> statusList = new ArrayList(); statusList.add("Shadow");
statusList.add("Billable"); statusList.add("Reserved");
statusList.add("Shadow"); statusList.add("Non-Billable");
statusList.add("Reserved"); List<String> catagories = new ArrayList();
statusList.add("Non-Billable"); List<ReportSeriesRecord> seriesDetails = new ArrayList<ReportSeriesRecord>();
List<String> catagories = new ArrayList();
List<ReportSeriesRecord> seriesDetails = new ArrayList<ReportSeriesRecord>(); List<Account> accounts = accountService.getAllAccounts();
//List<Account> accounts = employeeService.getAccounts(); ColumnChartData reportData = new ColumnChartData();
for (String status : statusList) {
List<Account> accounts = accountService.getAllAccounts(); catagories = new ArrayList();
long seriesData[] = new long[accounts.size()];
int i = 0;
ColumnChartData reportData = new ColumnChartData(); for (Account acct : accounts) {
for (String status : statusList) { boolean seriesDataExists = false;
catagories = new ArrayList(); catagories.add(acct.getAccountName());
long seriesData[] = new long[accounts.size()]; for (ColumnChartData columnChartData : result) {
int i = 0; if (columnChartData.getCategories() != null
for (Account acct : accounts) { && columnChartData.getSeriesName() != null
boolean seriesDataExists = false; & columnChartData.getCategories()
catagories.add(acct.getAccountName()); .equalsIgnoreCase(
for (ColumnChartData columnChartData : result) { acct.getAccountName())
if (columnChartData.getCategories() != null && columnChartData.getSeriesName()
&& columnChartData.getSeriesName() != null .equalsIgnoreCase(status)) {
& columnChartData.getCategories() seriesDataExists = true;
.equalsIgnoreCase( seriesData[i] = columnChartData.getCount();
acct.getAccountName()) }
&& columnChartData.getSeriesName() }
.equalsIgnoreCase(status)) { if (!seriesDataExists) {
seriesDataExists = true; // seriesData[i] = 0;
seriesData[i] = columnChartData.getCount(); }
} i++;
} }
if (!seriesDataExists) { ReportSeriesRecord reportSeriesRecord = new ReportSeriesRecord();
// seriesData[i] = 0; reportSeriesRecord.setName(status);
} reportSeriesRecord.setData(seriesData);
i++; seriesDetails.add(reportSeriesRecord);
}
ReportSeriesRecord reportSeriesRecord = new ReportSeriesRecord(); }
reportSeriesRecord.setName(status); reportData.setCategoriesList(catagories);
reportSeriesRecord.setData(seriesData); reportData.setSeriesDataList(seriesDetails);
seriesDetails.add(reportSeriesRecord); return new ResponseEntity<>(reportData, HttpStatus.OK);
}
}
reportData.setCategoriesList(catagories); @RequestMapping(value = "/fetchEmployeeDetailsByAccountBillability",
reportData.setSeriesDataList(seriesDetails); method = RequestMethod.GET,
return new ResponseEntity<>(reportData, HttpStatus.OK); produces = MediaType.APPLICATION_JSON_VALUE)
} public ResponseEntity<List<Reports>> fetchEmployeeDetailsByAccountBillability(
@RequestParam("account") String account,
@RequestParam("billabilityStatus") String billabilityStatus)
throws MyTeamException {
} List<Reports> resourcesList = new ArrayList<>();
if (account != null && !account.isEmpty()) {
resourcesList = reportService.getEmployeeDetailsByAccountBillability(account,billabilityStatus);
}
return new ResponseEntity<>(resourcesList, HttpStatus.OK);
}
}
package com.nisum.myteam.model;
import java.io.Serializable;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Reports implements Serializable {
private static final long serialVersionUID = 1L;
private String employeeId;
private String employeeName;
private String emailId;
private String projectName;
private String billableStatus;
private Date billingStartDate;
private Date billingEndDate;
private String functionalGroup;
}
package com.nisum.myteam.service; package com.nisum.myteam.service;
import com.nisum.myteam.exception.handler.MyTeamException; import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.BillableEmployee;
import com.nisum.myteam.model.dao.Account; import com.nisum.myteam.model.dao.Account;
import com.nisum.myteam.model.dao.Employee; import com.nisum.myteam.model.dao.Employee;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -53,6 +52,4 @@ public interface IEmployeeService { ...@@ -53,6 +52,4 @@ public interface IEmployeeService {
public List<Employee> getEmployeesByEmpStatusAndShift(String empStatus, String shift); public List<Employee> getEmployeesByEmpStatusAndShift(String empStatus, String shift);
List<BillableEmployee> getEmployeeDetailsByFGAndBillability(String fGroup, String billableStatus);
} }
package com.nisum.myteam.service; package com.nisum.myteam.service;
import com.nisum.myteam.exception.handler.MyTeamException; import java.util.List;
import com.nisum.myteam.model.vo.ReportVo;
import com.nisum.myteam.exception.handler.MyTeamException;
public interface IReportService { import com.nisum.myteam.model.Reports;
import com.nisum.myteam.model.vo.ReportVo;
public ReportVo getBarChartReport(String byType) throws MyTeamException; import com.nisum.myteam.model.vo.ResourceVO;
}
public interface IReportService {
public ReportVo getBarChartReport(String byType) throws MyTeamException;
public List<Reports> getEmployeeDetailsByFGAndBillability(String fGroup, String billableStatus) throws MyTeamException;
public List<Reports> getEmployeeDetailsByAccountBillability(String account, String billabilityStatus)throws MyTeamException;
}
\ No newline at end of file
...@@ -20,7 +20,6 @@ import org.springframework.data.mongodb.core.query.Update; ...@@ -20,7 +20,6 @@ import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.nisum.myteam.exception.handler.MyTeamException; import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.BillableEmployee;
import com.nisum.myteam.model.dao.Account; import com.nisum.myteam.model.dao.Account;
import com.nisum.myteam.model.dao.Domain; import com.nisum.myteam.model.dao.Domain;
import com.nisum.myteam.model.dao.Employee; import com.nisum.myteam.model.dao.Employee;
...@@ -343,40 +342,4 @@ public class EmployeeService implements IEmployeeService { ...@@ -343,40 +342,4 @@ public class EmployeeService implements IEmployeeService {
} }
@Override
public List<BillableEmployee> getEmployeeDetailsByFGAndBillability(String fGroup, String billableStatus) {
BillableEmployee billableEmployee=new BillableEmployee();
List<BillableEmployee> resultantEmployees=new ArrayList<BillableEmployee>();
List<Employee> employeesByFG=employeeRepo.findByEmpStatusAndFunctionalGroup(ResourceStatus.ACTIVE.getStatus(), fGroup);
for(Employee employee:employeesByFG) {
Resource resourceObj=resourceService.getLatestResourceByEmpId(employee.getEmployeeId());
if(resourceObj!=null && resourceObj.getBillableStatus().equals(billableStatus)) {
Project project=projectService.getProjectByProjectId(resourceObj.getProjectId());
billableEmployee.setEmployeeId(resourceObj.getEmployeeId());
billableEmployee.setEmployeeName(employee.getEmployeeName());
billableEmployee.setEmailId(employee.getEmailId());
billableEmployee.setProjectName(project.getProjectName());
billableEmployee.setBillingStartDate(resourceObj.getBillingStartDate());
billableEmployee.setBillableStatus(resourceObj.getBillableStatus());
billableEmployee.setBillingEndDate(resourceObj.getBillingEndDate());
billableEmployee.setFunctionalGroup(fGroup);
resultantEmployees.add(billableEmployee );
}
// else if(resourceObj==null ) {
// billableEmployee.setEmployeeId(employee.getEmployeeId());
// billableEmployee.setEmployeeName(employee.getEmployeeName());
// billableEmployee.setEmailId(employee.getEmailId());
// billableEmployee.setFunctionalGroup(fGroup);
// resultantEmployees.add(billableEmployee);
//
// }
}
return resultantEmployees;
//Map<String,Resource> resourceMap=resourceService.findByBillableStatus(billableStatus).stream().collect(Collectors.toMap(e->e.getEmployeeId(), e->e));
//return employeeRepo.findByEmpStatusAndFunctionalGroup(ResourceStatus.ACTIVE.getStatus(), fGroup).stream().filter(e->resourceMap.keySet().contains(e.getEmployeeId())).map(e-> mappingBillableEmployee(e,fGroup,resourceMap)).collect(Collectors.toList());
}
} }
package com.nisum.myteam.service.impl; package com.nisum.myteam.service.impl;
import com.nisum.myteam.exception.handler.MyTeamException; import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.dao.Employee; import com.nisum.myteam.model.Reports;
import com.nisum.myteam.model.dao.Project; import com.nisum.myteam.model.dao.Account;
import com.nisum.myteam.model.dao.Resource; import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.vo.ReportVo; import com.nisum.myteam.model.dao.Project;
import com.nisum.myteam.service.IReportService; import com.nisum.myteam.model.dao.Resource;
import org.springframework.beans.factory.annotation.Autowired; import com.nisum.myteam.model.vo.ReportVo;
import org.springframework.stereotype.Service; import com.nisum.myteam.model.vo.ResourceVO;
import com.nisum.myteam.service.IReportService;
import java.util.*; import com.nisum.myteam.statuscodes.ResourceStatus;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
@Service import org.springframework.stereotype.Service;
public class ReportService implements IReportService {
import java.util.*;
import java.util.stream.Collectors;
@Autowired
private EmployeeService employeeService; @Service
public class ReportService implements IReportService {
@Autowired
private ResourceService resourceService; private static final String Shadow = "Shadow";
@Autowired private static final String Reserved = "Reserved";
private AccountService accountService;
@Autowired
@Autowired private EmployeeService employeeService;
private ProjectService projectService;
@Autowired
@Autowired private ResourceService resourceService;
private FunctionalGroupService functionalGroupService;
@Autowired
public ReportVo getBarChartReport(String byType) throws MyTeamException { private AccountService accountService;
ReportVo reportVo = new ReportVo();
@Autowired
if(byType.equals("FunctionalGroup")) { private ProjectService projectService;
functionalGroupService.getAllFunctionalGroups().forEach(f -> reportVo.getCategoriesList().add(f.getName()));
} else { @Autowired
accountService.getAllAccounts().forEach(a -> reportVo.getCategoriesList().add(a.getAccountName())); private FunctionalGroupService functionalGroupService;
}
public ReportVo getBarChartReport(String byType) throws MyTeamException {
Map<String,Object> billableData = new HashMap(); ReportVo reportVo = new ReportVo();
Map<String,Object> nonBillableData = new HashMap();
Map<String,Object> traineeData = new HashMap(); if(byType.equals("FunctionalGroup")) {
List<Object> billableCount = new ArrayList<>(); functionalGroupService.getAllFunctionalGroups().forEach(f -> reportVo.getCategoriesList().add(f.getName()));
List<Object> nonBillableCount = new ArrayList<>(); } else {
List<Object> traineeCount = new ArrayList<>(); accountService.getAllAccounts().forEach(a -> reportVo.getCategoriesList().add(a.getAccountName()));
billableData.put("name","Billable"); }
nonBillableData.put("name","Non-Billable");
traineeData.put("name", "Trainee"); Map<String,Object> billableData = new HashMap();
for(String category:reportVo.getCategoriesList()){ Map<String,Object> nonBillableData = new HashMap();
Map<String,Object> billableObj = new HashMap(); Map<String,Object> traineeData = new HashMap();
Map<String,Object> nonbillableObj = new HashMap(); List<Object> billableCount = new ArrayList<>();
// Map<String,Object> traineeObj = new HashMap(); List<Object> nonBillableCount = new ArrayList<>();
Integer billableC=0; List<Object> traineeCount = new ArrayList<>();
Integer nonBillableC=0; billableData.put("name","Billable");
Integer traineeC=0; nonBillableData.put("name","Non-Billable");
// float traineePer; traineeData.put("name", "Trainee");
float billper; for(String category:reportVo.getCategoriesList()){
float nonBillPer; Map<String,Object> billableObj = new HashMap();
List<Employee> employeeList = new ArrayList<>(); Map<String,Object> nonbillableObj = new HashMap();
if(byType.equals("FunctionalGroup")) { // Map<String,Object> traineeObj = new HashMap();
employeeList = getEmployeesByFunctionalGroup(category); Integer billableC=0;
} else { Integer nonBillableC=0;
employeeList = getEmployeeByAccounts(category); Integer traineeC=0;
} // float traineePer;
// .getAllEmployees().stream(). float billper;
// filter(e -> e.getFunctionalGroup().equals(functionalGroup)).collect(Collectors.toList()); float nonBillPer;
for(Employee employee:employeeList){ List<Employee> employeeList = new ArrayList<>();
Resource resource = resourceService.getLatestResourceByEmpId(employee.getEmployeeId()); if(byType.equals("FunctionalGroup")) {
if(resource!=null && resource.getBillableStatus().equals("Billable")){ employeeList = getEmployeesByFunctionalGroup(category);
billableC++; } else {
}else if(resource!=null && resource.getBillableStatus().equals("Trainee")) { employeeList = getEmployeeByAccounts(category);
traineeC++; }
} else{ // .getAllEmployees().stream().
nonBillableC++; // filter(e -> e.getFunctionalGroup().equals(functionalGroup)).collect(Collectors.toList());
} for(Employee employee:employeeList){
} Resource resource = resourceService.getLatestResourceByEmpId(employee.getEmployeeId());
billper = ((billableC / (float)(employeeList.size() - traineeC))*100); if(resource!=null && resource.getBillableStatus().equals("Billable")){
nonBillPer = nonBillableC /(float) (employeeList.size()-traineeC)*100; billableC++;
// traineePer = traineeC / (float) employeeList.size()*100; }else if(resource!=null && resource.getBillableStatus().equals("Trainee")) {
billableObj.put("percent", billper); traineeC++;
billableObj.put("y", billableC); } else{
nonbillableObj.put("percent", nonBillPer); nonBillableC++;
nonbillableObj.put("y", nonBillableC); }
// traineeObj.put("percent", traineePer); }
// traineeObj.put("y", traineeC); billper = ((billableC / (float)(employeeList.size() - traineeC))*100);
billableCount.add(billableObj); nonBillPer = nonBillableC /(float) (employeeList.size()-traineeC)*100;
nonBillableCount.add(nonbillableObj); // traineePer = traineeC / (float) employeeList.size()*100;
traineeCount.add(traineeC); billableObj.put("percent", billper);
} billableObj.put("y", billableC);
billableData.put("data",billableCount); nonbillableObj.put("percent", nonBillPer);
nonBillableData.put("data",nonBillableCount); nonbillableObj.put("y", nonBillableC);
traineeData.put("data", traineeCount); // traineeObj.put("percent", traineePer);
reportVo.getSeriesDataList().add(billableData); // traineeObj.put("y", traineeC);
reportVo.getSeriesDataList().add(nonBillableData); billableCount.add(billableObj);
reportVo.getSeriesDataList().add(traineeData); nonBillableCount.add(nonbillableObj);
return reportVo; traineeCount.add(traineeC);
} }
billableData.put("data",billableCount);
private List<Employee> getEmployeesByFunctionalGroup(String functionalGroup){ nonBillableData.put("data",nonBillableCount);
return employeeService.getEmployeesByFunctionalGrp(functionalGroup); traineeData.put("data", traineeCount);
} reportVo.getSeriesDataList().add(billableData);
reportVo.getSeriesDataList().add(nonBillableData);
private List<Employee> getEmployeeByAccounts(String accountName){ reportVo.getSeriesDataList().add(traineeData);
List<Employee> employeeList = new ArrayList<>(); return reportVo;
List<Project> projects = projectService.getProjectsByAccountId(accountService.getAccountByName(accountName).getAccountId()); }
projects.stream().forEach(p -> {
resourceService.getResourceByProjectId(p.getProjectId()).stream().filter(r -> r.getBillingEndDate().after(new Date())). private List<Employee> getEmployeesByFunctionalGroup(String functionalGroup){
forEach(r ->employeeList.add(employeeService.getEmployeeById(r.getEmployeeId()))); return employeeService.getEmployeesByFunctionalGrp(functionalGroup);
}); }
return employeeList;
} private List<Employee> getEmployeeByAccounts(String accountName){
List<Employee> employeeList = new ArrayList<>();
} List<Project> projects = projectService.getProjectsByAccountId(accountService.getAccountByName(accountName).getAccountId());
projects.stream().forEach(p -> {
resourceService.getResourceByProjectId(p.getProjectId()).stream().filter(r -> r.getBillingEndDate().after(new Date())).
forEach(r ->employeeList.add(employeeService.getEmployeeById(r.getEmployeeId())));
});
return employeeList;
}
@Override
public List<Reports> getEmployeeDetailsByFGAndBillability(String fGroup, String billableStatus)
throws MyTeamException {
List<Employee> employeesByFG=employeeService.getEmployeesByFunctionalGrp(fGroup);
return resultantEmployeeWithBillability(employeesByFG,billableStatus);
}
@Override
public List<Reports> getEmployeeDetailsByAccountBillability(String accountName, String billabilityStatus)
throws MyTeamException {
return resultantEmployeeWithBillability(getEmployeeByAccounts(accountName),billabilityStatus);
}
private List<Reports> resultantEmployeeWithBillability(List<Employee> employees,
String billableStatus) {
List<Reports> resultantEmployees=new ArrayList<Reports>();
for(Employee employee:employees) {
Resource resourceObj=resourceService.getLatestResourceByEmpId(employee.getEmployeeId());
if(resourceObj.getBillableStatus().equals(billableStatus) ||( billableStatus.equals("Non-Billable") && (resourceObj.getBillableStatus().equals(Shadow)||resourceObj.getBillableStatus().equals(Reserved)))) {
resultantEmployees.add(mappingReports(employee,resourceObj) );
}
}
return resultantEmployees;
}
private Reports mappingReports(Employee employee,Resource resourceObj){
Reports Reports=new Reports();
Project project=projectService.getProjectByProjectId(resourceObj.getProjectId());
Reports.setEmployeeId(resourceObj.getEmployeeId());
Reports.setEmployeeName(employee.getEmployeeName());
Reports.setEmailId(employee.getEmailId());
Reports.setProjectName(project.getProjectName());
Reports.setBillingStartDate(resourceObj.getBillingStartDate());
Reports.setBillableStatus(resourceObj.getBillableStatus());
Reports.setBillingEndDate(resourceObj.getBillingEndDate());
Reports.setFunctionalGroup(employee.getFunctionalGroup());
return Reports;
}
}
package com.nisum.myteam.service.impl; package com.nisum.myteam.service.impl;
import com.nisum.myteam.exception.handler.MyTeamException; import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.dao.*; import com.nisum.myteam.model.dao.*;
import com.nisum.myteam.model.vo.*; import com.nisum.myteam.model.vo.*;
import com.nisum.myteam.repository.ResourceRepo; import com.nisum.myteam.repository.ResourceRepo;
import com.nisum.myteam.service.*; import com.nisum.myteam.service.*;
import com.nisum.myteam.statuscodes.ResourceAllocationStatus; import com.nisum.myteam.statuscodes.ResourceAllocationStatus;
import com.nisum.myteam.statuscodes.ResourceStatus; import com.nisum.myteam.statuscodes.ResourceStatus;
import com.nisum.myteam.utils.MyTeamDateUtils; import com.nisum.myteam.utils.MyTeamDateUtils;
import com.nisum.myteam.utils.MyTeamUtils; import com.nisum.myteam.utils.MyTeamUtils;
import com.nisum.myteam.utils.constants.Shifts; import com.nisum.myteam.utils.constants.Shifts;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
public class ResourceService implements IResourceService { public class ResourceService implements IResourceService {
@Autowired @Autowired
private MongoTemplate mongoTemplate; private MongoTemplate mongoTemplate;
@Autowired @Autowired
private ResourceRepo resourceRepo; private ResourceRepo resourceRepo;
@Autowired @Autowired
private IAccountService accountService; private IAccountService accountService;
@Autowired @Autowired
private IDomainService domainService; private IDomainService domainService;
@Autowired @Autowired
private IProjectService projectService; private IProjectService projectService;
@Autowired @Autowired
private IEmployeeService employeeService; private IEmployeeService employeeService;
@Autowired @Autowired
private IEmployeeShiftService empShiftService; private IEmployeeShiftService empShiftService;
public HashMap<String, Object> respMap = new HashMap<>(); public HashMap<String, Object> respMap = new HashMap<>();
private Resource getLatestAllocation(List<Resource> resourceAllocList) { private Resource getLatestAllocation(List<Resource> resourceAllocList) {
Resource latestAlloc = null; Resource latestAlloc = null;
if (!resourceAllocList.isEmpty()) { if (!resourceAllocList.isEmpty()) {
latestAlloc = resourceAllocList.get(0); latestAlloc = resourceAllocList.get(0);
for (Resource resource : resourceAllocList) { for (Resource resource : resourceAllocList) {
if (latestAlloc.getBillingEndDate().before(resource.getBillingEndDate())) if (latestAlloc.getBillingEndDate().before(resource.getBillingEndDate()))
latestAlloc = resource; latestAlloc = resource;
} }
} }
return latestAlloc; return latestAlloc;
} }
public List<Resource> getResourcesByEmployeeId(String employeeId) { public List<Resource> getResourcesByEmployeeId(String employeeId) {
return resourceRepo.findByEmployeeId(employeeId); return resourceRepo.findByEmployeeId(employeeId);
} }
public Resource addResource(Resource resourceReq, String loginEmpId) throws MyTeamException { public Resource addResource(Resource resourceReq, String loginEmpId) throws MyTeamException {
List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId()); List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId());
Resource prevAllocation = this.getLatestAllocation(resourceAllocList); Resource prevAllocation = this.getLatestAllocation(resourceAllocList);
if (prevAllocation != null) { if (prevAllocation != null) {
if (prevAllocation.getBillingEndDate().compareTo(new Date()) == 0) { if (prevAllocation.getBillingEndDate().compareTo(new Date()) == 0) {
prevAllocation.setBillingEndDate(new Date()); prevAllocation.setBillingEndDate(new Date());
} else { } else {
prevAllocation.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate())); //adding resource. prevAllocation.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate())); //adding resource.
} }
this.updateExistedResource(prevAllocation); this.updateExistedResource(prevAllocation);
} }
if (resourceAllocList.isEmpty()) { if (resourceAllocList.isEmpty()) {
List<Resource> resourceBenchList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), MyTeamUtils.BENCH_PROJECT_ID); List<Resource> resourceBenchList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), MyTeamUtils.BENCH_PROJECT_ID);
if (!resourceBenchList.isEmpty()) { if (!resourceBenchList.isEmpty()) {
Resource resourceBench = resourceBenchList.get(0); Resource resourceBench = resourceBenchList.get(0);
resourceBench.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate())); resourceBench.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate()));
resourceRepo.save(resourceBench); resourceRepo.save(resourceBench);
} }
} }
return resourceRepo.save(resourceReq); return resourceRepo.save(resourceReq);
} }
public boolean isResourceExistsForProject(String employeeId, String projectId) { public boolean isResourceExistsForProject(String employeeId, String projectId) {
boolean isExists = false; boolean isExists = false;
List<Resource> resourceList = resourceRepo.findByEmployeeIdAndProjectId(employeeId, projectId); List<Resource> resourceList = resourceRepo.findByEmployeeIdAndProjectId(employeeId, projectId);
if (resourceList != null && resourceList.size() > 0) { if (resourceList != null && resourceList.size() > 0) {
isExists = true; isExists = true;
respMap.put("message", "Resourse is already in the project"); respMap.put("message", "Resourse is already in the project");
return isExists; return isExists;
} }
respMap.put("statusCode", 810); respMap.put("statusCode", 810);
respMap.put("message", "Resource Not Found"); respMap.put("message", "Resource Not Found");
return isExists; return isExists;
} }
public void updateResourceDetails(Resource resourceReq, String loginEmpId) throws MyTeamException { public void updateResourceDetails(Resource resourceReq, String loginEmpId) throws MyTeamException {
// List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId()); // List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId());
// //
// List<Resource> resourceListWithLatestRecord = resourceAllocList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) >= 0).collect(Collectors.toList()); // List<Resource> resourceListWithLatestRecord = resourceAllocList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) >= 0).collect(Collectors.toList());
// //
// if (resourceListWithLatestRecord != null && resourceListWithLatestRecord.size() > 0) { // if (resourceListWithLatestRecord != null && resourceListWithLatestRecord.size() > 0) {
// //
// Resource resourcePrev = resourceListWithLatestRecord.get(0); //latest resource record. // Resource resourcePrev = resourceListWithLatestRecord.get(0); //latest resource record.
// log.info("Requsting Resource Allocation BillingStart Date::::"+resourceReq.getBillingStartDate()); // log.info("Requsting Resource Allocation BillingStart Date::::"+resourceReq.getBillingStartDate());
// log.info("The before date is::" + MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate())); // log.info("The before date is::" + MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate()));
// if(!resourcePrev.getBillableStatus().equals(resourceReq.getBillableStatus())) { // if(!resourcePrev.getBillableStatus().equals(resourceReq.getBillableStatus())) {
// if (resourcePrev.getBillingEndDate().compareTo(new Date()) == 0) { // if (resourcePrev.getBillingEndDate().compareTo(new Date()) == 0) {
// resourcePrev.setBillingEndDate(new Date()); // resourcePrev.setBillingEndDate(new Date());
// } else { // } else {
// resourcePrev.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate())); //adding resource. // resourcePrev.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate())); //adding resource.
// } // }
// insertNewResourceWithNewStatus(resourceReq,loginEmpId); // insertNewResourceWithNewStatus(resourceReq,loginEmpId);
// }else { // }else {
// resourcePrev.setResourceRole(resourceReq.getResourceRole()); // resourcePrev.setResourceRole(resourceReq.getResourceRole());
// resourcePrev.setBillingStartDate(resourceReq.getBillingStartDate()); // resourcePrev.setBillingStartDate(resourceReq.getBillingStartDate());
// resourcePrev.setBillingEndDate(resourceReq.getBillingEndDate()); // resourcePrev.setBillingEndDate(resourceReq.getBillingEndDate());
// //resourceAllocPrev.setBillingEndDate(); //adding resource. // //resourceAllocPrev.setBillingEndDate(); //adding resource.
// } // }
// log.info("After setting the date:::before saving the Resource::" + resourcePrev); // log.info("After setting the date:::before saving the Resource::" + resourcePrev);
// this.updateExistedResource(resourcePrev); // this.updateExistedResource(resourcePrev);
// } // }
Resource resource = resourceRepo.findById(resourceReq.getId()); Resource resource = resourceRepo.findById(resourceReq.getId());
if (resource != null) { if (resource != null) {
this.updateExistedResource(resourceReq); this.updateExistedResource(resourceReq);
} else { } else {
respMap.put("statusCode", 801); respMap.put("statusCode", 801);
respMap.put("message", "Record Not Found"); respMap.put("message", "Record Not Found");
} }
} }
public void updateExistedResource(Resource resource) { public void updateExistedResource(Resource resource) {
if (resource != null) { if (resource != null) {
Resource resourcePers = resourceRepo.save(resource); Resource resourcePers = resourceRepo.save(resource);
respMap.put("statusCode", 801); respMap.put("statusCode", 801);
respMap.put("message", "Resource updated successfully"); respMap.put("message", "Resource updated successfully");
respMap.put("resourceObj", resourcePers); respMap.put("resourceObj", resourcePers);
} }
} }
public void insertNewResourceWithNewStatus(Resource resourceReq, String loginEmpId) throws MyTeamException { public void insertNewResourceWithNewStatus(Resource resourceReq, String loginEmpId) throws MyTeamException {
resourceReq.setId(null); resourceReq.setId(null);
Resource resourcePers = resourceRepo.insert(resourceReq); Resource resourcePers = resourceRepo.insert(resourceReq);
respMap.put("statusCode", 801); respMap.put("statusCode", 801);
respMap.put("message", "Resource updated successfully"); respMap.put("message", "Resource updated successfully");
respMap.put("resourceObj", resourcePers); respMap.put("resourceObj", resourcePers);
} }
public boolean validateAllocationAgainstPrevAllocation(Resource resourceReq) { public boolean validateAllocationAgainstPrevAllocation(Resource resourceReq) {
boolean isValid = true; boolean isValid = true;
List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId()); List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId());
Resource prevAllocation = this.getLatestAllocation(resourceAllocList); Resource prevAllocation = this.getLatestAllocation(resourceAllocList);
if (prevAllocation != null) { if (prevAllocation != null) {
if (!prevAllocation.getBillingStartDate().before(resourceReq.getBillingStartDate())) { if (!prevAllocation.getBillingStartDate().before(resourceReq.getBillingStartDate())) {
respMap.put("statusCode", 811); respMap.put("statusCode", 811);
respMap.put("message", "Billing start date should be after previous allocation start date"); respMap.put("message", "Billing start date should be after previous allocation start date");
isValid = false; isValid = false;
} }
if (prevAllocation.getBillableStatus().equalsIgnoreCase(resourceReq.getBillableStatus())) { if (prevAllocation.getBillableStatus().equalsIgnoreCase(resourceReq.getBillableStatus())) {
respMap.put("statusCode", 811); respMap.put("statusCode", 811);
respMap.put("message", "Resource is already in " + prevAllocation.getBillableStatus() + " status only"); respMap.put("message", "Resource is already in " + prevAllocation.getBillableStatus() + " status only");
isValid = false; isValid = false;
} }
} }
return isValid; return isValid;
} }
public boolean validateBillingStartEndDateAgainstProjectStartEndDate(Resource resource, String loginEmpId) throws MyTeamException { public boolean validateBillingStartEndDateAgainstProjectStartEndDate(Resource resource, String loginEmpId) throws MyTeamException {
boolean isValid = true; boolean isValid = true;
Project project = projectService.getProjectByProjectId(resource.getProjectId()); Project project = projectService.getProjectByProjectId(resource.getProjectId());
log.info("Project::" + project); log.info("Project::" + project);
if (!resource.getBillingStartDate().after(project.getProjectStartDate())) { if (!resource.getBillingStartDate().after(project.getProjectStartDate())) {
log.info("Billing start date should be after Project start date"); log.info("Billing start date should be after Project start date");
respMap.put("statusCode", 811); respMap.put("statusCode", 811);
respMap.put("message", "Billing start date should be after Project start date"); respMap.put("message", "Billing start date should be after Project start date");
isValid = false; isValid = false;
} }
if (!resource.getBillingStartDate().before(resource.getBillingEndDate())) { if (!resource.getBillingStartDate().before(resource.getBillingEndDate())) {
log.info("Billing start date should be before Billing End Date."); log.info("Billing start date should be before Billing End Date.");
respMap.put("statusCode", 812); respMap.put("statusCode", 812);
respMap.put("message", "Billing start date should be before Billing End Date."); respMap.put("message", "Billing start date should be before Billing End Date.");
isValid = false; isValid = false;
} }
log.info("ResourceALloc Req::" + resource); log.info("ResourceALloc Req::" + resource);
log.info("" + project.getProjectEndDate().toString()); log.info("" + project.getProjectEndDate().toString());
//if (!resourceAllocation.getBillingEndDate().before(project.getProjectEndDate())|| !resourceAllocation.getBillingEndDate().equals(project.getProjectEndDate())) { //if (!resourceAllocation.getBillingEndDate().before(project.getProjectEndDate())|| !resourceAllocation.getBillingEndDate().equals(project.getProjectEndDate())) {
if (!(resource.getBillingEndDate().compareTo(project.getProjectEndDate()) <= 0)) { if (!(resource.getBillingEndDate().compareTo(project.getProjectEndDate()) <= 0)) {
log.info("Billing end date should be on or before Project End Date."); log.info("Billing end date should be on or before Project End Date.");
respMap.put("statusCode", 813); respMap.put("statusCode", 813);
respMap.put("message", "Billing end date should be before Project End Date."); respMap.put("message", "Billing end date should be before Project End Date.");
isValid = false; isValid = false;
} }
respMap.put("resourceObj", resource); respMap.put("resourceObj", resource);
return isValid; return isValid;
} }
public boolean validateBillingStartDateAgainstDOJ(Resource resource) { public boolean validateBillingStartDateAgainstDOJ(Resource resource) {
String message = ""; String message = "";
boolean isValid = true; boolean isValid = true;
Employee employee = employeeService.getEmployeeById(resource.getEmployeeId()); Employee employee = employeeService.getEmployeeById(resource.getEmployeeId());
Date empDoj = employeeService.getEmployeeById(resource.getEmployeeId()).getDateOfJoining(); Date empDoj = employeeService.getEmployeeById(resource.getEmployeeId()).getDateOfJoining();
if (resource.getBillingStartDate().compareTo(empDoj) < 0) { if (resource.getBillingStartDate().compareTo(empDoj) < 0) {
message = "Resource Billing Start Date (" + resource.getBillingStartDate() + " ) in " message = "Resource Billing Start Date (" + resource.getBillingStartDate() + " ) in "
+ projectService.getProjectByProjectId(resource.getProjectId()).getProjectName() + projectService.getProjectByProjectId(resource.getProjectId()).getProjectName()
+ " project should not be before Date of Joining ( " + empDoj + ")."; + " project should not be before Date of Joining ( " + empDoj + ").";
isValid = false; isValid = false;
respMap.put("statusCode", 814); respMap.put("statusCode", 814);
respMap.put("message", message); respMap.put("message", message);
} }
return isValid; return isValid;
} }
public boolean isResourceAssignedToAnyProject(Resource resourceReq) { public boolean isResourceAssignedToAnyProject(Resource resourceReq) {
boolean isAssigned = false; boolean isAssigned = false;
String message = ""; String message = "";
//List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceAllocReq.getEmployeeId(), resourceAllocReq.getProjectId()); //List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceAllocReq.getEmployeeId(), resourceAllocReq.getProjectId());
List<Resource> resourceAllocList = resourceRepo.findByEmployeeId(resourceReq.getEmployeeId()); List<Resource> resourceAllocList = resourceRepo.findByEmployeeId(resourceReq.getEmployeeId());
List<Resource> resourceListWithLatestRecord = resourceAllocList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) >= 0).collect(Collectors.toList()); List<Resource> resourceListWithLatestRecord = resourceAllocList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) >= 0).collect(Collectors.toList());
if (resourceListWithLatestRecord != null && resourceListWithLatestRecord.size() > 0) { if (resourceListWithLatestRecord != null && resourceListWithLatestRecord.size() > 0) {
Resource resourcePrev = resourceListWithLatestRecord.get(0);//latest resource record. Resource resourcePrev = resourceListWithLatestRecord.get(0);//latest resource record.
if (!resourcePrev.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID) && !resourceReq.getProjectId().equalsIgnoreCase(resourcePrev.getProjectId())) { if (!resourcePrev.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID) && !resourceReq.getProjectId().equalsIgnoreCase(resourcePrev.getProjectId())) {
message = "Resource " + resourcePrev.getEmployeeId() + " already Assigned to the " message = "Resource " + resourcePrev.getEmployeeId() + " already Assigned to the "
+ projectService.getProjectByProjectId(resourcePrev.getProjectId()).getProjectName() + projectService.getProjectByProjectId(resourcePrev.getProjectId()).getProjectName()
+ " Project" + " from " + resourcePrev.getBillingStartDate() + "to " + resourcePrev.getBillingEndDate(); + " Project" + " from " + resourcePrev.getBillingStartDate() + "to " + resourcePrev.getBillingEndDate();
isAssigned = true; isAssigned = true;
respMap.put("statusCode", 815); respMap.put("statusCode", 815);
respMap.put("message", message); respMap.put("message", message);
} }
} }
return isAssigned; return isAssigned;
} }
public void deleteResource(Resource resourceReq, String loginEmpId) { public void deleteResource(Resource resourceReq, String loginEmpId) {
List<Resource> resourcesList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId()); List<Resource> resourcesList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId());
resourcesList.forEach(resource -> resourceRepo.delete(resource)); resourcesList.forEach(resource -> resourceRepo.delete(resource));
} }
@Override @Override
public List<Resource> getAllResources() { public List<Resource> getAllResources() {
return resourceRepo.findAll(); return resourceRepo.findAll();
} }
public List<ResourceVO> getAllResourcesVO() { public List<ResourceVO> getAllResourcesVO() {
return getAllResources().stream().map(resource -> { return getAllResources().stream().map(resource -> {
ResourceVO resourceVO = new ResourceVO(); ResourceVO resourceVO = new ResourceVO();
resourceVO.setId(resource.getId()); resourceVO.setId(resource.getId());
resourceVO.setProjectId(resource.getProjectId()); resourceVO.setProjectId(resource.getProjectId());
resourceVO.setEmployeeId(resource.getEmployeeId()); resourceVO.setEmployeeId(resource.getEmployeeId());
Employee employee = employeeService.getEmployeeById(resource.getEmployeeId()); Employee employee = employeeService.getEmployeeById(resource.getEmployeeId());
if (employee != null) { if (employee != null) {
resourceVO.setEmployeeName(employee.getEmployeeName()); resourceVO.setEmployeeName(employee.getEmployeeName());
resourceVO.setDesignation(employee.getDesignation()); resourceVO.setDesignation(employee.getDesignation());
resourceVO.setEmailId(employee.getEmailId()); resourceVO.setEmailId(employee.getEmailId());
resourceVO.setMobileNo(employee.getMobileNumber()); resourceVO.setMobileNo(employee.getMobileNumber());
} }
Project project = projectService.getProjectByProjectId(resource.getProjectId()); Project project = projectService.getProjectByProjectId(resource.getProjectId());
if (project != null) { if (project != null) {
resourceVO.setProjectName(project.getProjectName()); resourceVO.setProjectName(project.getProjectName());
resourceVO.setProjectStartDate(project.getProjectStartDate()); resourceVO.setProjectStartDate(project.getProjectStartDate());
resourceVO.setProjectEndDate(project.getProjectEndDate()); resourceVO.setProjectEndDate(project.getProjectEndDate());
resourceVO.setProjectStatus(project.getStatus()); resourceVO.setProjectStatus(project.getStatus());
if (project.getAccountId() != null) { if (project.getAccountId() != null) {
Account account = accountService.getAccountById(project.getAccountId()); Account account = accountService.getAccountById(project.getAccountId());
if (account != null) { if (account != null) {
resourceVO.setAccountName(account.getAccountName()); resourceVO.setAccountName(account.getAccountName());
} }
} }
} }
//Account account=accountService.getAccountById(domainService.getDomainById(project.getProjectId()).getAccountId()); //Account account=accountService.getAccountById(domainService.getDomainById(project.getProjectId()).getAccountId());
resourceVO.setBillableStatus(resource.getBillableStatus()); resourceVO.setBillableStatus(resource.getBillableStatus());
resourceVO.setBillingStartDate(resource.getBillingStartDate()); resourceVO.setBillingStartDate(resource.getBillingStartDate());
resourceVO.setBillingEndDate(resource.getBillingEndDate()); resourceVO.setBillingEndDate(resource.getBillingEndDate());
resourceVO.setResourceRole(resource.getResourceRole()); resourceVO.setResourceRole(resource.getResourceRole());
if (resource.getBillingEndDate().compareTo(new Date()) > 0) { if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
resourceVO.setResourceStatus(ResourceStatus.ACTIVE.getStatus()); resourceVO.setResourceStatus(ResourceStatus.ACTIVE.getStatus());
} else { } else {
resourceVO.setResourceStatus(ResourceStatus.IN_ACTIVE.getStatus()); resourceVO.setResourceStatus(ResourceStatus.IN_ACTIVE.getStatus());
} }
return resourceVO; return resourceVO;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
public List<Resource> getResourcesSortByBillingStartDate(String employeeId) { public List<Resource> getResourcesSortByBillingStartDate(String employeeId) {
Query query = prepareQuery(employeeId, MyTeamUtils.BILLING_START_DATE); Query query = prepareQuery(employeeId, MyTeamUtils.BILLING_START_DATE);
return mongoTemplate.find(query, Resource.class); return mongoTemplate.find(query, Resource.class);
} }
private Query prepareQuery(String employeeId, String dateColumn) { private Query prepareQuery(String employeeId, String dateColumn) {
Query query = new Query(); Query query = new Query();
query.addCriteria(Criteria.where(MyTeamUtils.EMPLOYEE_ID).is(employeeId)); query.addCriteria(Criteria.where(MyTeamUtils.EMPLOYEE_ID).is(employeeId));
query.limit(MyTeamUtils.ONE); query.limit(MyTeamUtils.ONE);
query.with(new Sort(Sort.Direction.DESC, dateColumn)); query.with(new Sort(Sort.Direction.DESC, dateColumn));
return query; return query;
} }
@Override @Override
public List<ResourceVO> getActiveResources(String empId) { public List<ResourceVO> getActiveResources(String empId) {
List<ResourceVO> resourcesList = new ArrayList<>(); List<ResourceVO> resourcesList = new ArrayList<>();
for (Resource resource : resourceRepo.findByEmployeeId(empId)) { for (Resource resource : resourceRepo.findByEmployeeId(empId)) {
if (resource.getBillingEndDate().compareTo(new Date()) > 0) { if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
resourcesList.addAll(prepareProjectTeamMembersList(resource.getProjectId())); resourcesList.addAll(prepareProjectTeamMembersList(resource.getProjectId()));
} }
} }
return resourcesList; return resourcesList;
} }
public List<ResourceVO> prepareProjectTeamMembersList(String projectId) { public List<ResourceVO> prepareProjectTeamMembersList(String projectId) {
List<ResourceVO> finalResourcesList = new ArrayList<>(); List<ResourceVO> finalResourcesList = new ArrayList<>();
Employee employee = null; Employee employee = null;
for (Resource resource : getAllResourcesForProject(projectId)) { for (Resource resource : getAllResourcesForProject(projectId)) {
ResourceVO resourceVO = new ResourceVO(); ResourceVO resourceVO = new ResourceVO();
resourceVO.setId(resource.getId()); resourceVO.setId(resource.getId());
resourceVO.setProjectId(resource.getProjectId()); resourceVO.setProjectId(resource.getProjectId());
resourceVO.setEmployeeId(resource.getEmployeeId()); resourceVO.setEmployeeId(resource.getEmployeeId());
employee = employeeService.getEmployeeById(resource.getEmployeeId()); employee = employeeService.getEmployeeById(resource.getEmployeeId());
resourceVO.setEmployeeName(employee.getEmployeeName()); resourceVO.setEmployeeName(employee.getEmployeeName());
resourceVO.setDesignation(employee.getDesignation()); resourceVO.setDesignation(employee.getDesignation());
resourceVO.setEmailId(employee.getEmailId()); resourceVO.setEmailId(employee.getEmailId());
resourceVO.setMobileNo(employee.getMobileNumber()); resourceVO.setMobileNo(employee.getMobileNumber());
resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName()); resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
resourceVO.setBillableStatus(resource.getBillableStatus()); resourceVO.setBillableStatus(resource.getBillableStatus());
resourceVO.setBillingStartDate(resource.getBillingStartDate()); resourceVO.setBillingStartDate(resource.getBillingStartDate());
resourceVO.setBillingEndDate(resource.getBillingEndDate()); resourceVO.setBillingEndDate(resource.getBillingEndDate());
resourceVO.setResourceRole(resource.getResourceRole()); resourceVO.setResourceRole(resource.getResourceRole());
if (resource.getBillingEndDate().compareTo(new Date()) > 0) { if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
resourceVO.setResourceStatus(ResourceStatus.ACTIVE.getStatus()); resourceVO.setResourceStatus(ResourceStatus.ACTIVE.getStatus());
} else { } else {
resourceVO.setResourceStatus(ResourceStatus.IN_ACTIVE.getStatus()); resourceVO.setResourceStatus(ResourceStatus.IN_ACTIVE.getStatus());
} }
finalResourcesList.add(resourceVO); finalResourcesList.add(resourceVO);
} }
return finalResourcesList; return finalResourcesList;
} }
public List<Resource> getAllResourcesForProject(String projectId) { public List<Resource> getAllResourcesForProject(String projectId) {
return resourceRepo.findByProjectId(projectId); return resourceRepo.findByProjectId(projectId);
} }
@Override @Override
public List<Resource> getAllResourcesForAllActiveProjects() { public List<Resource> getAllResourcesForAllActiveProjects() {
List<Resource> resourceList = new ArrayList<>(); List<Resource> resourceList = new ArrayList<>();
for (Project activeProject : projectService.getOnlyActiveProjects()) { for (Project activeProject : projectService.getOnlyActiveProjects()) {
resourceList.addAll(getAllResourcesForProject(activeProject.getProjectId())); resourceList.addAll(getAllResourcesForProject(activeProject.getProjectId()));
} }
return resourceList; return resourceList;
} }
@Override @Override
public List<ResourceVO> getResourcesForProject(String projectId, String statusFlag) { public List<ResourceVO> getResourcesForProject(String projectId, String statusFlag) {
List<ResourceVO> resourcesList = new ArrayList<>(); List<ResourceVO> resourcesList = new ArrayList<>();
for (Resource resource : resourceRepo.findByProjectId(projectId)) { for (Resource resource : resourceRepo.findByProjectId(projectId)) {
Date billingEndDate = resource.getBillingEndDate(); Date billingEndDate = resource.getBillingEndDate();
if (billingEndDate != null) { if (billingEndDate != null) {
ResourceVO resourceVO = new ResourceVO(); ResourceVO resourceVO = new ResourceVO();
resourceVO.setId(resource.getId()); resourceVO.setId(resource.getId());
resourceVO.setProjectId(resource.getProjectId()); resourceVO.setProjectId(resource.getProjectId());
resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName()); resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
resourceVO.setResourceRole(resource.getResourceRole()); resourceVO.setResourceRole(resource.getResourceRole());
resourceVO.setBillingStartDate(resource.getBillingStartDate()); resourceVO.setBillingStartDate(resource.getBillingStartDate());
resourceVO.setBillingEndDate(resource.getBillingEndDate()); resourceVO.setBillingEndDate(resource.getBillingEndDate());
resourceVO.setBillableStatus(resource.getBillableStatus()); resourceVO.setBillableStatus(resource.getBillableStatus());
resourceVO.setEmployeeId(resource.getEmployeeId()); resourceVO.setEmployeeId(resource.getEmployeeId());
Employee employee = employeeService.getEmployeeById(resource.getEmployeeId()); Employee employee = employeeService.getEmployeeById(resource.getEmployeeId());
resourceVO.setEmailId(employee.getEmailId()); resourceVO.setEmailId(employee.getEmailId());
resourceVO.setEmployeeName(employee.getEmployeeName()); resourceVO.setEmployeeName(employee.getEmployeeName());
resourceVO.setDesignation(employee.getDesignation()); resourceVO.setDesignation(employee.getDesignation());
// Active // Active
if (statusFlag.equals(ResourceStatus.ACTIVE.getStatus()) && billingEndDate.compareTo(new Date()) >= 0) { if (statusFlag.equals(ResourceStatus.ACTIVE.getStatus()) && billingEndDate.compareTo(new Date()) >= 0) {
resourceVO.setResourceStatus(ResourceStatus.ACTIVE.getStatus()); resourceVO.setResourceStatus(ResourceStatus.ACTIVE.getStatus());
resourcesList.add(resourceVO); resourcesList.add(resourceVO);
} else if (statusFlag.equals(ResourceStatus.IN_ACTIVE.getStatus()) && billingEndDate.compareTo(new Date()) < 0) { } else if (statusFlag.equals(ResourceStatus.IN_ACTIVE.getStatus()) && billingEndDate.compareTo(new Date()) < 0) {
resourceVO.setResourceStatus(ResourceStatus.IN_ACTIVE.getStatus()); resourceVO.setResourceStatus(ResourceStatus.IN_ACTIVE.getStatus());
resourcesList.add(resourceVO); resourcesList.add(resourceVO);
} else if (statusFlag.equals(MyTeamUtils.BOTH)) } else if (statusFlag.equals(MyTeamUtils.BOTH))
resourcesList.add(resourceVO); resourcesList.add(resourceVO);
} }
} }
return resourcesList; return resourcesList;
} }
@Override @Override
public List<MyProjectAllocationVO> getWorkedProjectsForResource(String empId) { public List<MyProjectAllocationVO> getWorkedProjectsForResource(String empId) {
Project project = null; Project project = null;
Account account = null; Account account = null;
Domain domain = null; Domain domain = null;
Employee employee = null; Employee employee = null;
List<MyProjectAllocationVO> myProjectList = new ArrayList<>(); List<MyProjectAllocationVO> myProjectList = new ArrayList<>();
List<Resource> resourcesAllocatedList = resourceRepo.findByEmployeeId(empId); List<Resource> resourcesAllocatedList = resourceRepo.findByEmployeeId(empId);
if (null != resourcesAllocatedList && !resourcesAllocatedList.isEmpty() && MyTeamUtils.INT_ZERO < resourcesAllocatedList.size()) { if (null != resourcesAllocatedList && !resourcesAllocatedList.isEmpty() && MyTeamUtils.INT_ZERO < resourcesAllocatedList.size()) {
for (Resource resourceAlloc : resourcesAllocatedList) { for (Resource resourceAlloc : resourcesAllocatedList) {
project = projectService.getProjectByProjectId(resourceAlloc.getProjectId()); project = projectService.getProjectByProjectId(resourceAlloc.getProjectId());
account = accountService.getAccountById(project.getAccountId()); account = accountService.getAccountById(project.getAccountId());
domain = domainService.getDomainById(project.getDomainId()); domain = domainService.getDomainById(project.getDomainId());
employee = employeeService.getEmployeeById(resourceAlloc.getEmployeeId()); employee = employeeService.getEmployeeById(resourceAlloc.getEmployeeId());
MyProjectAllocationVO myProject = new MyProjectAllocationVO(); MyProjectAllocationVO myProject = new MyProjectAllocationVO();
myProject.setProjectId(project.getProjectId()); myProject.setProjectId(project.getProjectId());
myProject.setProjectName(project.getProjectName()); myProject.setProjectName(project.getProjectName());
myProject.setProjectStartDate(project.getProjectStartDate()); myProject.setProjectStartDate(project.getProjectStartDate());
myProject.setProjectEndDate(project.getProjectEndDate()); myProject.setProjectEndDate(project.getProjectEndDate());
myProject.setProjectStatus(project.getStatus()); myProject.setProjectStatus(project.getStatus());
myProject.setAccountName(account.getAccountName()); myProject.setAccountName(account.getAccountName());
myProject.setBillableStatus(resourceAlloc.getBillableStatus()); myProject.setBillableStatus(resourceAlloc.getBillableStatus());
myProject.setBillingStartDate(resourceAlloc.getBillingStartDate()); myProject.setBillingStartDate(resourceAlloc.getBillingStartDate());
myProject.setBillingEndDate(resourceAlloc.getBillingEndDate()); myProject.setBillingEndDate(resourceAlloc.getBillingEndDate());
myProject.setShift(employee.getShift()); myProject.setShift(employee.getShift());
if (resourceAlloc.getBillingEndDate().compareTo(new Date()) > 0) { if (resourceAlloc.getBillingEndDate().compareTo(new Date()) > 0) {
myProject.setResourceStatus(ResourceStatus.ACTIVE.getStatus()); myProject.setResourceStatus(ResourceStatus.ACTIVE.getStatus());
} else { } else {
myProject.setResourceStatus(ResourceStatus.IN_ACTIVE.getStatus()); myProject.setResourceStatus(ResourceStatus.IN_ACTIVE.getStatus());
} }
if (project.getDeliveryLeadIds() != null) { if (project.getDeliveryLeadIds() != null) {
myProject.setDeliveryLeadIds(employeeService.getDeliveryManagerMap(project.getDeliveryLeadIds())); myProject.setDeliveryLeadIds(employeeService.getDeliveryManagerMap(project.getDeliveryLeadIds()));
} }
myProjectList.add(myProject); myProjectList.add(myProject);
} }
} }
return myProjectList; return myProjectList;
} }
@Override @Override
public List<Resource> getResourcesUnderDeliveryLead(String deliveryLeadId) { public List<Resource> getResourcesUnderDeliveryLead(String deliveryLeadId) {
List<String> projectIdsList = new ArrayList<>(); List<String> projectIdsList = new ArrayList<>();
List<Resource> resourcesList = new ArrayList<>(); List<Resource> resourcesList = new ArrayList<>();
for (Project project : projectService.getProjectsForDeliveryLead(deliveryLeadId)) for (Project project : projectService.getProjectsForDeliveryLead(deliveryLeadId))
projectIdsList.add(project.getProjectId()); projectIdsList.add(project.getProjectId());
Query query = new Query(Criteria.where("projectId").in(projectIdsList)); Query query = new Query(Criteria.where("projectId").in(projectIdsList));
List<Resource> resourcesListPersisted = mongoTemplate.find(query, Resource.class); List<Resource> resourcesListPersisted = mongoTemplate.find(query, Resource.class);
for (Resource resourceAlloc : resourcesListPersisted) { for (Resource resourceAlloc : resourcesListPersisted) {
if (!resourceAlloc.getEmployeeId().equals(deliveryLeadId)) if (!resourceAlloc.getEmployeeId().equals(deliveryLeadId))
resourcesList.add(resourceAlloc); resourcesList.add(resourceAlloc);
} }
return resourcesList; return resourcesList;
} }
@Override @Override
public List<ResourceVO> getBillingsForEmployee(String empId) { public List<ResourceVO> getBillingsForEmployee(String empId) {
List<ResourceVO> finalList = new ArrayList<>(); List<ResourceVO> finalList = new ArrayList<>();
List<Resource> resourcesList = resourceRepo.findByEmployeeId(empId); List<Resource> resourcesList = resourceRepo.findByEmployeeId(empId);
if (resourcesList != null && resourcesList.size() > 0) { if (resourcesList != null && resourcesList.size() > 0) {
log.info("The resources billing list before sorting::" + resourcesList); log.info("The resources billing list before sorting::" + resourcesList);
//return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList()); //return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
List<Resource> sortedList = resourcesList.stream().sorted(Comparator.comparing(Resource::getBillingStartDate).reversed()).collect(Collectors.toList()); List<Resource> sortedList = resourcesList.stream().sorted(Comparator.comparing(Resource::getBillingStartDate).reversed()).collect(Collectors.toList());
finalList = convertResourcesToResourcesVO(sortedList); finalList = convertResourcesToResourcesVO(sortedList);
} }
return finalList; return finalList;
} }
@Override @Override
public List<Resource> getBillingsForProject(String empId, String projectId) { public List<Resource> getBillingsForProject(String empId, String projectId) {
List<Resource> resourcesList = resourceRepo.findByEmployeeIdAndProjectId(empId, projectId); List<Resource> resourcesList = resourceRepo.findByEmployeeIdAndProjectId(empId, projectId);
if (resourcesList == null || resourcesList.size() == 0) { if (resourcesList == null || resourcesList.size() == 0) {
return resourcesList; return resourcesList;
} else { } else {
//return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList()); //return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
return resourcesList.stream().sorted(Comparator.comparing(Resource::getBillingStartDate).reversed()).collect(Collectors.toList()); return resourcesList.stream().sorted(Comparator.comparing(Resource::getBillingStartDate).reversed()).collect(Collectors.toList());
} }
} }
@Override @Override
public List<Employee> getUnAssignedEmployees() { public List<Employee> getUnAssignedEmployees() {
List<Employee> notAssignedEmployees = new ArrayList<>(); List<Employee> notAssignedEmployees = new ArrayList<>();
List<String> resourceIdsList = new ArrayList<>(); List<String> resourceIdsList = new ArrayList<>();
for (Resource resource : this.getAllResources()) { for (Resource resource : this.getAllResources()) {
Project project = projectService.getProjectByProjectId(resource.getProjectId()); Project project = projectService.getProjectByProjectId(resource.getProjectId());
if (project != null && project.getStatus() != null && !"Completed".equalsIgnoreCase(project.getStatus())) { if (project != null && project.getStatus() != null && !"Completed".equalsIgnoreCase(project.getStatus())) {
resourceIdsList.add(resource.getEmployeeId()); resourceIdsList.add(resource.getEmployeeId());
} }
} }
for (Employee employee : employeeService.getAllEmployees()) { for (Employee employee : employeeService.getAllEmployees()) {
if (!resourceIdsList.contains(employee.getEmployeeId())) { if (!resourceIdsList.contains(employee.getEmployeeId())) {
notAssignedEmployees.add(employee); notAssignedEmployees.add(employee);
} }
} }
return notAssignedEmployees; return notAssignedEmployees;
} }
public void deleteResourcesUnderProject(String projectId) { public void deleteResourcesUnderProject(String projectId) {
Query query = new Query(Criteria.where("projectId").is(projectId)); Query query = new Query(Criteria.where("projectId").is(projectId));
List<Resource> list = mongoTemplate.find(query, Resource.class); List<Resource> list = mongoTemplate.find(query, Resource.class);
resourceRepo.delete(list); resourceRepo.delete(list);
} }
private List<ResourceVO> convertResourcesToResourcesVO(List<Resource> resourcesList) { private List<ResourceVO> convertResourcesToResourcesVO(List<Resource> resourcesList) {
List<ResourceVO> finalList = new ArrayList<>(); List<ResourceVO> finalList = new ArrayList<>();
if (resourcesList != null && resourcesList.size() > 0) { if (resourcesList != null && resourcesList.size() > 0) {
finalList = resourcesList.stream().map(resource -> { finalList = resourcesList.stream().map(resource -> {
ResourceVO resourceVO = new ResourceVO(); ResourceVO resourceVO = new ResourceVO();
resourceVO.setId(resource.getId()); resourceVO.setId(resource.getId());
resourceVO.setProjectId(resource.getProjectId()); resourceVO.setProjectId(resource.getProjectId());
resourceVO.setEmployeeId(resource.getEmployeeId()); resourceVO.setEmployeeId(resource.getEmployeeId());
Employee employee = employeeService.getEmployeeById(resource.getEmployeeId()); Employee employee = employeeService.getEmployeeById(resource.getEmployeeId());
if (employee != null) { if (employee != null) {
resourceVO.setEmployeeName(employee.getEmployeeName()); resourceVO.setEmployeeName(employee.getEmployeeName());
resourceVO.setDesignation(employee.getDesignation()); resourceVO.setDesignation(employee.getDesignation());
resourceVO.setEmailId(employee.getEmailId()); resourceVO.setEmailId(employee.getEmailId());
resourceVO.setMobileNo(employee.getMobileNumber()); resourceVO.setMobileNo(employee.getMobileNumber());
} }
Project project = projectService.getProjectByProjectId(resource.getProjectId()); Project project = projectService.getProjectByProjectId(resource.getProjectId());
if (project != null) { if (project != null) {
resourceVO.setProjectName(project.getProjectName()); resourceVO.setProjectName(project.getProjectName());
resourceVO.setProjectStartDate(project.getProjectStartDate()); resourceVO.setProjectStartDate(project.getProjectStartDate());
resourceVO.setProjectEndDate(project.getProjectEndDate()); resourceVO.setProjectEndDate(project.getProjectEndDate());
resourceVO.setProjectStatus(project.getStatus()); resourceVO.setProjectStatus(project.getStatus());
if (project.getAccountId() != null) { if (project.getAccountId() != null) {
Account account = accountService.getAccountById(project.getAccountId()); Account account = accountService.getAccountById(project.getAccountId());
if (account != null) { if (account != null) {
resourceVO.setAccountName(account.getAccountName()); resourceVO.setAccountName(account.getAccountName());
} }
} }
} }
//Account account=accountService.getAccountById(domainService.getDomainById(project.getProjectId()).getAccountId()); //Account account=accountService.getAccountById(domainService.getDomainById(project.getProjectId()).getAccountId());
resourceVO.setBillableStatus(resource.getBillableStatus()); resourceVO.setBillableStatus(resource.getBillableStatus());
resourceVO.setBillingStartDate(resource.getBillingStartDate()); resourceVO.setBillingStartDate(resource.getBillingStartDate());
resourceVO.setBillingEndDate(resource.getBillingEndDate()); resourceVO.setBillingEndDate(resource.getBillingEndDate());
resourceVO.setResourceRole(resource.getResourceRole()); resourceVO.setResourceRole(resource.getResourceRole());
if (resource.getBillingEndDate().compareTo(new Date()) > 0) { if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
resourceVO.setResourceStatus(ResourceStatus.ACTIVE.getStatus()); resourceVO.setResourceStatus(ResourceStatus.ACTIVE.getStatus());
} else { } else {
resourceVO.setResourceStatus(ResourceStatus.IN_ACTIVE.getStatus()); resourceVO.setResourceStatus(ResourceStatus.IN_ACTIVE.getStatus());
} }
return resourceVO; return resourceVO;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
return finalList; return finalList;
} }
@Override @Override
public Resource addResourceToBenchProject(Employee employee, String loginEmpId) throws MyTeamException { public Resource addResourceToBenchProject(Employee employee, String loginEmpId) throws MyTeamException {
Resource resourcePersisted = null; Resource resourcePersisted = null;
Resource resourceBench = new Resource(); Resource resourceBench = new Resource();
resourceBench.setProjectId(MyTeamUtils.BENCH_PROJECT_ID); resourceBench.setProjectId(MyTeamUtils.BENCH_PROJECT_ID);
resourceBench.setEmployeeId(employee.getEmployeeId()); resourceBench.setEmployeeId(employee.getEmployeeId());
resourceBench.setResourceRole(employee.getRole()); resourceBench.setResourceRole(employee.getRole());
resourceBench.setBillingStartDate(employee.getDateOfJoining() != null ? employee.getDateOfJoining() : new Date()); resourceBench.setBillingStartDate(employee.getDateOfJoining() != null ? employee.getDateOfJoining() : new Date());
resourceBench.setBillableStatus(MyTeamUtils.BENCH_BILLABILITY_STATUS); resourceBench.setBillableStatus(MyTeamUtils.BENCH_BILLABILITY_STATUS);
resourceBench.setEmployeeId(employee.getEmployeeId()); resourceBench.setEmployeeId(employee.getEmployeeId());
resourceBench.setBillingEndDate(projectService.getProjectByProjectId(MyTeamUtils.BENCH_PROJECT_ID).getProjectEndDate()); resourceBench.setBillingEndDate(projectService.getProjectByProjectId(MyTeamUtils.BENCH_PROJECT_ID).getProjectEndDate());
resourcePersisted = addResource(resourceBench, loginEmpId); resourcePersisted = addResource(resourceBench, loginEmpId);
return resourcePersisted; return resourcePersisted;
} }
@Override @Override
public List<EmployeeShiftsVO> getResourcesForShift(String shift) { public List<EmployeeShiftsVO> getResourcesForShift(String shift) {
List<Resource> resourcesListPers = null; List<Resource> resourcesListPers = null;
List<EmployeeShiftsVO> resourcesList = new ArrayList<>(); List<EmployeeShiftsVO> resourcesList = new ArrayList<>();
List<Project> projects = projectService.getAllProjects(); List<Project> projects = projectService.getAllProjects();
for (Project project : projects) { for (Project project : projects) {
if ("Active".equalsIgnoreCase(project.getStatus())) { if ("Active".equalsIgnoreCase(project.getStatus())) {
resourcesListPers = getAllResourcesForProject(project.getProjectId()); resourcesListPers = getAllResourcesForProject(project.getProjectId());
for (Resource resource : resourcesListPers) { for (Resource resource : resourcesListPers) {
// EmployeeShift empShift = empShiftService.getEmployeeShift(resource.getEmployeeId()); // EmployeeShift empShift = empShiftService.getEmployeeShift(resource.getEmployeeId());
// if (empShift != null) { // if (empShift != null) {
// if (empShift.getShift() != null && empShift.getShift().equalsIgnoreCase(shift)) // if (empShift.getShift() != null && empShift.getShift().equalsIgnoreCase(shift))
// resourcesList.add(resource); // resourcesList.add(resource);
// else if (empShift.getShift() == null && Shifts.SHIFT1.getShiftType().equalsIgnoreCase(shift)) // else if (empShift.getShift() == null && Shifts.SHIFT1.getShiftType().equalsIgnoreCase(shift))
// resourcesList.add(resource); // resourcesList.add(resource);
// //
// } // }
if (resource.getBillingEndDate().compareTo(new Date()) >= 0) { if (resource.getBillingEndDate().compareTo(new Date()) >= 0) {
Employee employee = employeeService.getEmployeeById(resource.getEmployeeId()); Employee employee = employeeService.getEmployeeById(resource.getEmployeeId());
EmployeeShiftsVO shiftsVO = new EmployeeShiftsVO(); EmployeeShiftsVO shiftsVO = new EmployeeShiftsVO();
shiftsVO.setEmployeeId(employee.getEmployeeId()); shiftsVO.setEmployeeId(employee.getEmployeeId());
shiftsVO.setEmployeeName(employee.getEmployeeName()); shiftsVO.setEmployeeName(employee.getEmployeeName());
shiftsVO.setEmailId(employee.getEmailId()); shiftsVO.setEmailId(employee.getEmailId());
shiftsVO.setMobileNo(employee.getMobileNumber()); shiftsVO.setMobileNo(employee.getMobileNumber());
shiftsVO.setProjectName(project.getProjectName()); shiftsVO.setProjectName(project.getProjectName());
if (employee != null) { if (employee != null) {
if (shift.equalsIgnoreCase(employee.getShift())) if (shift.equalsIgnoreCase(employee.getShift()))
resourcesList.add(shiftsVO); resourcesList.add(shiftsVO);
else if (employee.getShift() == null && Shifts.SHIFT1.getShiftType().equalsIgnoreCase(shift)) else if (employee.getShift() == null && Shifts.SHIFT1.getShiftType().equalsIgnoreCase(shift))
resourcesList.add(shiftsVO); resourcesList.add(shiftsVO);
} }
} }
}//for }//for
} }
} }
return resourcesList; return resourcesList;
} }
@Override @Override
public Resource getLatestResourceByEmpId(String employeeId) { public Resource getLatestResourceByEmpId(String employeeId) {
List<Resource> resourceList = resourceRepo.findByEmployeeId(employeeId).stream(). return getLatestAllocation(resourceRepo.findByEmployeeId(employeeId));
filter(r -> r.getBillingEndDate().after(new Date())).collect(Collectors.toList());
if (!resourceList.isEmpty()) }
return resourceList.get(0);
else
return null; @Override
} public List<Resource> getResourcesByBillingStatus(String resourceStatus) {
return resourceRepo.findByBillableStatus(resourceStatus);
}
@Override
public List<Resource> getResourcesByBillingStatus(String resourceStatus) { @Override
return resourceRepo.findByBillableStatus(resourceStatus); public List<ReserveReportsVO> getResourceReportsByBillingStatus(String resourceStatus) {
} return prepareReserveReports(getResourcesByBillingStatus(resourceStatus));
}
@Override
public List<ReserveReportsVO> getResourceReportsByBillingStatus(String resourceStatus) { @Override
return prepareReserveReports(getResourcesByBillingStatus(resourceStatus)); public List<ReserveReportsVO> prepareReserveReports(List<Resource> resourcesList) {
}
List<ReserveReportsVO> reserveReportsList = new ArrayList<>();
@Override if (resourcesList != null && resourcesList.size() > 0) {
public List<ReserveReportsVO> prepareReserveReports(List<Resource> resourcesList) { Project project = null;
for (Resource resource : resourcesList) {
List<ReserveReportsVO> reserveReportsList = new ArrayList<>(); ReserveReportsVO reserveReportsVO = new ReserveReportsVO();
if (resourcesList != null && resourcesList.size() > 0) { reserveReportsVO.setEmployeeId(resource.getEmployeeId());
Project project = null; reserveReportsVO.setEmployeeName(employeeService.getEmployeeById(resource.getEmployeeId()).getEmployeeName());
for (Resource resource : resourcesList) { if (StringUtils.isNotBlank(resource.getProjectId())) {
ReserveReportsVO reserveReportsVO = new ReserveReportsVO(); project = projectService.getProjectByProjectId(resource.getProjectId());
reserveReportsVO.setEmployeeId(resource.getEmployeeId()); if (project != null) {
reserveReportsVO.setEmployeeName(employeeService.getEmployeeById(resource.getEmployeeId()).getEmployeeName()); reserveReportsVO.setProjectName(project.getProjectName());
if (StringUtils.isNotBlank(resource.getProjectId())) { reserveReportsVO.setAccountName(accountService.getAccountById(project.getAccountId()).getAccountName());
project = projectService.getProjectByProjectId(resource.getProjectId()); }
if (project != null) {
reserveReportsVO.setProjectName(project.getProjectName()); }
reserveReportsVO.setAccountName(accountService.getAccountById(project.getAccountId()).getAccountName()); reserveReportsVO.setBillingStartDate(resource.getBillingStartDate());
} reserveReportsVO.setBillingEndDate(resource.getBillingEndDate());
} reserveReportsList.add(reserveReportsVO);
reserveReportsVO.setBillingStartDate(resource.getBillingStartDate()); }
reserveReportsVO.setBillingEndDate(resource.getBillingEndDate()); }
reserveReportsList.add(reserveReportsVO); return reserveReportsList;
}
} }
return reserveReportsList; @Override
public List<Resource> getResourceByProjectId(String projectId){
} return resourceRepo.findByProjectId(projectId);
}
@Override
public List<Resource> getResourceByProjectId(String projectId){
return resourceRepo.findByProjectId(projectId); public List<ChangedResourceVO> getChangedResourceByDate(String fromDatestr, String toDatestr) {
} // List<ChangedResourceVO> changedResourceVOList = new ArrayList();
// SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
//
public List<ChangedResourceVO> getChangedResourceByDate(String fromDatestr, String toDatestr) { // try {
// List<ChangedResourceVO> changedResourceVOList = new ArrayList(); // final Date fromDate = format.parse(fromDatestr);
// SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy"); // final Date toDate = format.parse(toDatestr);
// // resourceRepo.findAll().stream().
// try { // filter(r -> r.getBillingStartDate().before(toDate)&&r.getBillingEndDate().after(fromDate)).forEach(r -> {
// final Date fromDate = format.parse(fromDatestr); // ChangedResourceVO crv = new ChangedResourceVO();
// final Date toDate = format.parse(toDatestr); // Project project = projectService.getProjectByProjectId(r.getProjectId());
// resourceRepo.findAll().stream(). // Employee emp = employeeService.getEmployeeById(r.getEmployeeId());
// filter(r -> r.getBillingStartDate().before(toDate)&&r.getBillingEndDate().after(fromDate)).forEach(r -> { // Account account = accountService.getAccountById(project.getAccountId());
// ChangedResourceVO crv = new ChangedResourceVO(); //
// Project project = projectService.getProjectByProjectId(r.getProjectId()); //
// Employee emp = employeeService.getEmployeeById(r.getEmployeeId()); // if(changedResourceVOList.isEmpty()){
// Account account = accountService.getAccountById(project.getAccountId()); // crv.setEmplyeeId(r.getEmployeeId());
// // crv.setEmployeeName(emp.getEmployeeName());
// // crv.setPrevBillingStatus(r.getBillableStatus());
// if(changedResourceVOList.isEmpty()){ // crv.setPrevBillingStartingDate(r.getBillingStartDate());
// crv.setEmplyeeId(r.getEmployeeId()); // crv.setPrevBillingEndDate(r.getBillingEndDate());
// crv.setEmployeeName(emp.getEmployeeName()); // crv.setPrevClient(account.getAccountName());
// crv.setPrevBillingStatus(r.getBillableStatus()); // crv.setPrevProject(project.getProjectName());
// crv.setPrevBillingStartingDate(r.getBillingStartDate()); // }else {
// crv.setPrevBillingEndDate(r.getBillingEndDate()); //
// crv.setPrevClient(account.getAccountName()); // if(!crvList.isEmpty()){
// crv.setPrevProject(project.getProjectName()); //
// }else { // }else{
// //
// if(!crvList.isEmpty()){ // }
// // }
// }else{ // changedResourceVOList.add(crv);
// // });
// } //
// } // }catch (Exception e){}
// changedResourceVOList.add(crv); //
// });
//
// }catch (Exception e){} return null;
// }
return null; public boolean validateResourceAllocationStatus(ResourceAllocationStatus resourceStatus) {
} boolean isValidStatus = false;
switch (resourceStatus) {
public boolean validateResourceAllocationStatus(ResourceAllocationStatus resourceStatus) { case TRAINEE:
boolean isValidStatus = false;
switch (resourceStatus) { case BILLABLE:
case TRAINEE: case NON_BILLABLE:
case BILLABLE: case RESERVED:
isValidStatus = true;
case NON_BILLABLE: break;
}
case RESERVED:
isValidStatus = true; return isValidStatus;
break; }
}
return isValidStatus; public List<Resource> getResourcesGreaterThanBillingStartDate(Date billingStartDate) {
} return resourceRepo.findByBillingStartDateGreaterThan(billingStartDate);
}
public List<Resource> getResourcesGreaterThanBillingStartDate(Date billingStartDate) { public List<Resource> getResourcesBetweenBillingStartDates(Date fromDate, Date toDate) {
return resourceRepo.findByBillingStartDateGreaterThan(billingStartDate); return resourceRepo.findByBillingStartDateBetween(fromDate, toDate);
} }
public List<Resource> getResourcesBetweenBillingStartDates(Date fromDate, Date toDate) { public List<AllocationChangeVO> getAllocationReports(Date fromDate, Date toDate) {
return resourceRepo.findByBillingStartDateBetween(fromDate, toDate);
} return getResourcesBetweenBillingStartDates(fromDate, toDate).stream()
.filter(resource -> resource.getBillingEndDate().compareTo(new Date()) >= 0).map(resource -> {
public List<AllocationChangeVO> getAllocationReports(Date fromDate, Date toDate) {
Project project = null;
return getResourcesBetweenBillingStartDates(fromDate, toDate).stream()
.filter(resource -> resource.getBillingEndDate().compareTo(new Date()) >= 0).map(resource -> { //Setting Current Billing details.
AllocationChangeVO allocationVO = new AllocationChangeVO();
Project project = null; allocationVO.setEmployeeId(resource.getEmployeeId());
allocationVO.setEmployeeName(employeeService.getEmployeeById(resource.getEmployeeId()).getEmployeeName());
//Setting Current Billing details.
AllocationChangeVO allocationVO = new AllocationChangeVO(); if (StringUtils.isNotBlank(resource.getProjectId())) {
allocationVO.setEmployeeId(resource.getEmployeeId()); project = projectService.getProjectByProjectId(resource.getProjectId());
allocationVO.setEmployeeName(employeeService.getEmployeeById(resource.getEmployeeId()).getEmployeeName()); if (project != null) {
allocationVO.setCurrentProjectName(project.getProjectName());
if (StringUtils.isNotBlank(resource.getProjectId())) { allocationVO.setCurrentAccountName(accountService.getAccountById(project.getAccountId()).getAccountName());
project = projectService.getProjectByProjectId(resource.getProjectId()); }
if (project != null) { }
allocationVO.setCurrentProjectName(project.getProjectName()); allocationVO.setCurrentBillingStatus(resource.getBillableStatus());
allocationVO.setCurrentAccountName(accountService.getAccountById(project.getAccountId()).getAccountName()); allocationVO.setCurrentBillingStartDate(resource.getBillingStartDate());
} allocationVO.setCurrentBillingEndDate(resource.getBillingEndDate());
}
allocationVO.setCurrentBillingStatus(resource.getBillableStatus()); Resource prevBilling = resourceRepo.findOneByEmployeeIdAndBillingEndDate(resource.getEmployeeId(), MyTeamDateUtils.getDayLessThanDate(resource.getBillingStartDate()));
allocationVO.setCurrentBillingStartDate(resource.getBillingStartDate()); log.info("\n\n\n The prev billing info is::" + prevBilling);
allocationVO.setCurrentBillingEndDate(resource.getBillingEndDate());
if (prevBilling != null) {
Resource prevBilling = resourceRepo.findOneByEmployeeIdAndBillingEndDate(resource.getEmployeeId(), MyTeamDateUtils.getDayLessThanDate(resource.getBillingStartDate())); if (StringUtils.isNotBlank(prevBilling.getProjectId())) {
log.info("\n\n\n The prev billing info is::" + prevBilling); project = projectService.getProjectByProjectId(prevBilling.getProjectId());
if (project != null) {
if (prevBilling != null) { allocationVO.setPrevProjectName(project.getProjectName());
if (StringUtils.isNotBlank(prevBilling.getProjectId())) { allocationVO.setPrevAccountName(accountService.getAccountById(project.getAccountId()).getAccountName());
project = projectService.getProjectByProjectId(prevBilling.getProjectId()); }
if (project != null) { }
allocationVO.setPrevProjectName(project.getProjectName()); allocationVO.setPrevBillingStatus(prevBilling.getBillableStatus());
allocationVO.setPrevAccountName(accountService.getAccountById(project.getAccountId()).getAccountName()); allocationVO.setPrevBillingStartDate(prevBilling.getBillingStartDate());
} allocationVO.setPrevBillingEndDate(prevBilling.getBillingEndDate());
} }
allocationVO.setPrevBillingStatus(prevBilling.getBillableStatus()); return allocationVO;
allocationVO.setPrevBillingStartDate(prevBilling.getBillingStartDate()); }).collect(Collectors.toList());
allocationVO.setPrevBillingEndDate(prevBilling.getBillingEndDate());
} }
return allocationVO;
}).collect(Collectors.toList()); public List<AllocationChangeVO> prepareAllocationResources(List<Resource> resourcesList) {
List<AllocationChangeVO> allocationList = new ArrayList<>();
}
if (resourcesList != null && resourcesList.size() > 0) {
public List<AllocationChangeVO> prepareAllocationResources(List<Resource> resourcesList) { Project project = null;
List<AllocationChangeVO> allocationList = new ArrayList<>(); for (Resource resource : resourcesList) {
if (resourcesList != null && resourcesList.size() > 0) { AllocationChangeVO allocationVO = new AllocationChangeVO();
Project project = null; allocationVO.setEmployeeId(resource.getEmployeeId());
for (Resource resource : resourcesList) { allocationVO.setEmployeeName(employeeService.getEmployeeById(resource.getEmployeeId()).getEmployeeName());
AllocationChangeVO allocationVO = new AllocationChangeVO(); if (StringUtils.isNotBlank(resource.getProjectId())) {
allocationVO.setEmployeeId(resource.getEmployeeId()); project = projectService.getProjectByProjectId(resource.getProjectId());
allocationVO.setEmployeeName(employeeService.getEmployeeById(resource.getEmployeeId()).getEmployeeName()); if (project != null) {
allocationVO.setCurrentProjectName(project.getProjectName());
if (StringUtils.isNotBlank(resource.getProjectId())) { allocationVO.setCurrentAccountName(accountService.getAccountById(project.getAccountId()).getAccountName());
project = projectService.getProjectByProjectId(resource.getProjectId()); }
if (project != null) {
allocationVO.setCurrentProjectName(project.getProjectName()); }
allocationVO.setCurrentAccountName(accountService.getAccountById(project.getAccountId()).getAccountName()); allocationVO.setCurrentBillingStatus(resource.getBillableStatus());
} allocationVO.setCurrentBillingStartDate(resource.getBillingStartDate());
allocationVO.setCurrentBillingEndDate(resource.getBillingEndDate());
}
allocationVO.setCurrentBillingStatus(resource.getBillableStatus()); allocationList.add(allocationVO);
allocationVO.setCurrentBillingStartDate(resource.getBillingStartDate()); }
allocationVO.setCurrentBillingEndDate(resource.getBillingEndDate());
}
allocationList.add(allocationVO);
} return allocationList;
}
}
return allocationList; @Override
} public Set<Resource> findByBillableStatus(String billableStatus) {
return resourceRepo.findByBillableStatus(billableStatus).stream().filter(r -> r.getBillingEndDate().after(new Date())).collect(Collectors.toSet());
}
@Override
public Set<Resource> findByBillableStatus(String billableStatus) {
return resourceRepo.findByBillableStatus(billableStatus).stream().filter(r -> r.getBillingEndDate().after(new Date())).collect(Collectors.toSet());
}
}//class
}//class
/*
@Override
public List<ResourceVO> getActiveResources(String empId) {
List<ResourceVO> finalResourcesList = new ArrayList<>();
/*
@Override List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
public List<ResourceVO> getActiveResources(String empId) { if (resourceList != null && resourceList.size() > 0) {
List<ResourceVO> finalResourcesList = new ArrayList<>();
Resource resourceAlloc=resourceList.get(0);
List<Resource> resourceList = resourceRepo.findByEmployeeId(empId); }
if (resourceList != null && resourceList.size() > 0) {
for (Resource resource : resourceRepo.findByEmployeeId(empId)) {
Resource resourceAlloc=resourceList.get(0);
} ResourceVO resourceVO=new ResourceVO();
resourceVO.setEmployeeId(resource.getEmployeeId());
for (Resource resource : resourceRepo.findByEmployeeId(empId)) {
Employee employee=employeeService.getEmployeeById(resource.getEmployeeId());
ResourceVO resourceVO=new ResourceVO(); resourceVO.setEmployeeName(employee.getEmployeeName());
resourceVO.setEmployeeId(resource.getEmployeeId()); resourceVO.setDesignation(employee.getDesignation());
resourceVO.setEmailId(employee.getEmailId());
Employee employee=employeeService.getEmployeeById(resource.getEmployeeId()); resourceVO.setMobileNo(employee.getMobileNumber());
resourceVO.setEmployeeName(employee.getEmployeeName());
resourceVO.setDesignation(employee.getDesignation()); resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
resourceVO.setEmailId(employee.getEmailId());
resourceVO.setMobileNo(employee.getMobileNumber());
if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName()); finalResourcesList.addAll(getAllResourcesForProject(resource.getProjectId()));
}
if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
finalResourcesList.addAll(getAllResourcesForProject(resource.getProjectId())); }
} return finalResourcesList;
}
} */
return finalResourcesList;
} /*
*/ @Override
public List<ResourceVO> getActiveResources(String empId) {
/* List<ResourceVO> finalResourcesList = new ArrayList<>();
Employee employee = null;
@Override
public List<ResourceVO> getActiveResources(String empId) { List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
List<ResourceVO> finalResourcesList = new ArrayList<>(); Optional<Resource> optionalResource = resourceList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) > 0).findAny();
Employee employee = null; if (optionalResource.isPresent()) {
finalResourcesList = prepareProjectTeamMembersList(optionalResource.get().getProjectId());
List<Resource> resourceList = resourceRepo.findByEmployeeId(empId); }
Optional<Resource> optionalResource = resourceList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) > 0).findAny(); return finalResourcesList;
if (optionalResource.isPresent()) { }
finalResourcesList = prepareProjectTeamMembersList(optionalResource.get().getProjectId());
} */
return finalResourcesList;
}
*/
myApp.directive('hcPieChart', function () { myApp.directive('hcPieChart', function () {
return { return {
restrict: 'E', restrict: 'E',
template: '<div></div>', template: '<div></div>',
link: function (scope, element) { link: function (scope, element) {
//getEmployeeDetails(scope,element[0].baseURI+'reports/billabilityByFunctionalGroup','column',element,"Billability By Functional Group"); //getEmployeeDetails(scope,element[0].baseURI+'reports/billabilityByFunctionalGroup','column',element,"Billability By Functional Group");
//getEmployeeDetails(scope,element[0].baseURI+'reports/getBillabilityDetailsByAccount','column',element,"Billability By Account"); //getEmployeeDetails(scope,element[0].baseURI+'reports/getBillabilityDetailsByAccount','column',element,"Billability By Account");
scope.clickMe= function(value) { scope.clickMe= function(value) {
console.log(value); console.log(value);
console.log(value.Name); console.log(value.Name);
if(value.Id== 1) { if(value.Id== 1) {
uri = 'Account'; uri = 'Account';
chart = 'column'; chart = 'column';
} else if(value.Id == 2){ } else if(value.Id == 2){
uri = 'FunctionalGroup'; uri = 'FunctionalGroup';
chart = 'column'; chart = 'column';
} }
else if(value.Id == 3){ else if(value.Id == 3){
uri = 'Month'; uri = 'Month';
chart = 'line'; chart = 'line';
} }
desc = value.Name; desc = value.Name;
console.log(desc); console.log(desc);
getEmployeeDetails(scope,element[0].baseURI+'reports/getBarChartReport?byType='+uri,chart,element,desc); getEmployeeDetails(scope,element[0].baseURI+'reports/getBarChartReport?byType='+uri,chart,element,desc);
//alert(value); //alert(value);
// if(scope.reportId == 1){ // if(scope.reportId == 1){
// getEmployeeDetails(scope,element[0].baseURI+'reports/getBillabilityDetailsByAccount','column',element," Billability By Account"); // getEmployeeDetails(scope,element[0].baseURI+'reports/getBillabilityDetailsByAccount','column',element," Billability By Account");
// }else if(scope.reportId == 2){ // }else if(scope.reportId == 2){
// getEmployeeDetails(scope,element[0].baseURI+'reports/billabilityByFunctionalGroup','column',element,"Billability By Functional Group"); // getEmployeeDetails(scope,element[0].baseURI+'reports/billabilityByFunctionalGroup','column',element,"Billability By Functional Group");
// }else if(scope.reportId == 3){ // }else if(scope.reportId == 3){
// getEmployeeDetails(scope,element[0].baseURI+'reports/getBillabilityDetailsByMonth','line',element," Billability Monthly Trends"); // getEmployeeDetails(scope,element[0].baseURI+'reports/getBillabilityDetailsByMonth','line',element," Billability Monthly Trends");
// } // }
} }
} }
}; };
}).controller('chartsController', function ($scope, $http, myFactory,exportUiGridService, $mdDialog, appConfig) { }).controller('chartsController', function ($scope, $http, myFactory,exportUiGridService, $mdDialog, appConfig) {
$scope.name = []; $scope.name = [];
$scope.records = []; $scope.records = [];
$scope.empSearchId = ""; $scope.empSearchId = "";
$scope.reportId = "1" $scope.reportId = "1"
//$scope.reportId = "2" //$scope.reportId = "2"
$scope.reports = $scope.reportId; $scope.reports = $scope.reportId;
$scope.reports=[ {Name:"Billability By Account",Id:"1"},{Name:"Billability By Functional Group",Id:"2"},{Name:"Billability Monthly Trends",Id:"3"}]; $scope.reports=[ {Name:"Billability By Account",Id:"1"},{Name:"Billability By Functional Group",Id:"2"},{Name:"Billability Monthly Trends",Id:"3"}];
$scope.employees = []; $scope.employees = [];
$scope.projects = []; $scope.projects = [];
$scope.gridOptions = { $scope.gridOptions = {
paginationPageSizes : [ 10, 20, 30, 40, 50, 100], paginationPageSizes : [ 10, 20, 30, 40, 50, 100],
paginationPageSize : 10, paginationPageSize : 10,
pageNumber: 1, pageNumber: 1,
enableFiltering:true, enableFiltering:true,
pageSize:10, pageSize:10,
columnDefs : [ columnDefs : [
{field : 'employeeId',displayName: 'Employee ID', enableColumnMenu: true, enableSorting: true, enableFiltering:true, width:120}, {field : 'employeeId',displayName: 'Employee ID', enableColumnMenu: true, enableSorting: true, enableFiltering:true, width:120},
{field : 'employeeName',displayName: 'Employee Name', enableColumnMenu: false, enableSorting: false, enableFiltering:true}, {field : 'employeeName',displayName: 'Employee Name', enableColumnMenu: false, enableSorting: false, enableFiltering:true},
{field : 'emailId',displayName: 'Email', enableColumnMenu: false, enableSorting: false, enableFiltering:true}, {field : 'emailId',displayName: 'Email', enableColumnMenu: false, enableSorting: false, enableFiltering:true},
{field : 'projectName',displayName: 'Project Name', enableColumnMenu: false, enableSorting: false, enableFiltering:true}, {field : 'projectName',displayName: 'Project Name', enableColumnMenu: false, enableSorting: false, enableFiltering:true},
{field : 'billableStatus',displayName: 'Billable Status', enableColumnMenu: false, enableSorting: false, enableFiltering:false}, {field : 'billableStatus',displayName: 'Billable Status', enableColumnMenu: false, enableSorting: false, enableFiltering:false},
{field : 'billingStartDate',displayName: 'Billing Start Data', enableColumnMenu: false, enableSorting: false,cellFilter: 'date:"dd-MMM-yyyy"',enableFiltering:false}, {field : 'billingStartDate',displayName: 'Billing Start Data', enableColumnMenu: false, enableSorting: false,cellFilter: 'date:"dd-MMM-yyyy"',enableFiltering:false},
{field : 'billingEndDate',displayName: 'Billing End Data', enableColumnMenu: false, enableSorting: false,cellFilter: 'date:"dd-MMM-yyyy"',enableFiltering:false}, {field : 'billingEndDate',displayName: 'Billing End Data', enableColumnMenu: false, enableSorting: false,cellFilter: 'date:"dd-MMM-yyyy"',enableFiltering:false},
{field : 'functionalGroup',displayName: 'Functional Group', enableColumnMenu: false, enableSorting: false, enableFiltering:false} {field : 'functionalGroup',displayName: 'Functional Group', enableColumnMenu: false, enableSorting: false, enableFiltering:false}
], ],
enableGridMenu: true, enableGridMenu: true,
enableSelectAll: true, enableSelectAll: true,
exporterMenuExcel:false, exporterMenuExcel:false,
exporterMenuCsv:false, exporterMenuCsv:false,
exporterCsvFilename: 'EmployeeDetails.csv', exporterCsvFilename: 'EmployeeDetails.csv',
exporterExcelFilename:'EmployeeDetails', exporterExcelFilename:'EmployeeDetails',
exporterPdfDefaultStyle: {fontSize: 9}, exporterPdfDefaultStyle: {fontSize: 9},
exporterPdfTableStyle: {margin: [30, 30, 30, 30]}, exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'}, exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
exporterPdfHeader: { text: "Employee Details", style: 'headerStyle' }, exporterPdfHeader: { text: "Employee Details", style: 'headerStyle' },
exporterPdfFooter: function ( currentPage, pageCount ) { exporterPdfFooter: function ( currentPage, pageCount ) {
return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' }; return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
}, },
exporterPdfCustomFormatter: function ( docDefinition ) { exporterPdfCustomFormatter: function ( docDefinition ) {
docDefinition.styles.headerStyle = { fontSize: 22, bold: true }; docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
docDefinition.styles.footerStyle = { fontSize: 10, bold: true }; docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
return docDefinition; return docDefinition;
}, },
exporterPdfOrientation: 'portrait', exporterPdfOrientation: 'portrait',
exporterPdfPageSize: 'LETTER', exporterPdfPageSize: 'LETTER',
exporterPdfMaxGridWidth: 500, exporterPdfMaxGridWidth: 500,
exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")), exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
onRegisterApi: function(gridApi){ onRegisterApi: function(gridApi){
$scope.gridApi = gridApi; $scope.gridApi = gridApi;
}, },
gridMenuCustomItems: [{ gridMenuCustomItems: [{
title: 'Export all data as EXCEL', title: 'Export all data as EXCEL',
action: function ($event) { action: function ($event) {
exportUiGridService.exportToExcel('sheet 1', $scope.gridApi, 'all', 'all'); exportUiGridService.exportToExcel('sheet 1', $scope.gridApi, 'all', 'all');
}, },
order: 110 order: 110
}, },
{ {
title: 'Export visible data as EXCEL', title: 'Export visible data as EXCEL',
action: function ($event) { action: function ($event) {
exportUiGridService.exportToExcel('sheet 1', $scope.gridApi, 'visible', 'visible'); exportUiGridService.exportToExcel('sheet 1', $scope.gridApi, 'visible', 'visible');
}, },
order: 111 order: 111
} }
] ]
}; };
$scope.gridOptions.data = $scope.records; $scope.gridOptions.data = $scope.records;
$scope.gridOptions.enablePaginationControls = false; $scope.gridOptions.enablePaginationControls = false;
$scope.getMyTeamDetails = function(seriesName, category, optionName,title){ $scope.getMyTeamDetails = function(seriesName, category, optionName,title){
if(title.trim() == 'Billability By Functional Group'){ if(title.trim() == 'Billability By Functional Group'){
if(category=='I&A'){ if(category=='I&A'){
category = 'I%26A'; category = 'I%26A';
} }
$http({ $http({
method : "GET", method : "GET",
url : appConfig.appUri + "reports/fetchEmployeeDetailsByFGAndBillability?fGroup="+category+"&billableStatus="+seriesName url : appConfig.appUri + "reports/fetchEmployeeDetailsByFGAndBillability?fGroup="+category+"&billableStatus="+seriesName
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
$scope.gridOptions.data = response.data; $scope.gridOptions.data = response.data;
if(response.data.length > 10){ if(response.data.length > 10){
$scope.gridOptions.enablePaginationControls = true; $scope.gridOptions.enablePaginationControls = true;
} }
else{ else{
$scope.gridOptions.enablePaginationControls = false; $scope.gridOptions.enablePaginationControls = false;
} }
}, function myError(response) { }, function myError(response) {
showAlert("Something went wrong while fetching data!!!"); showAlert("Something went wrong while fetching data!!!");
$scope.gridOptions.data = []; $scope.gridOptions.data = [];
}); });
}else if(title.trim() == 'Billability By Account'){ }else if(title.trim() == 'Billability By Account'){
$http({ $http({
method : "GET", method : "GET",
url : appConfig.appUri + "/reports/fetchEmployeeDetailsByAccountBillability?account="+category+"&billabilityStatus="+seriesName url : appConfig.appUri + "/reports/fetchEmployeeDetailsByAccountBillability?account="+category+"&billabilityStatus="+seriesName
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
$scope.gridOptions.data = response.data; $scope.gridOptions.data = response.data;
if(response.data.length > 10){ if(response.data.length > 10){
$scope.gridOptions.enablePaginationControls = true; $scope.gridOptions.enablePaginationControls = true;
} }
else{ else{
$scope.gridOptions.enablePaginationControls = false; $scope.gridOptions.enablePaginationControls = false;
} }
}, function myError(response) { }, function myError(response) {
showAlert("Something went wrong while fetching data!!!"); showAlert("Something went wrong while fetching data!!!");
$scope.gridOptions.data = []; $scope.gridOptions.data = [];
}); });
}else if(title.trim() == 'Billability Monthly Trends'){ }else if(title.trim() == 'Billability Monthly Trends'){
$http({ $http({
method : "GET", method : "GET",
url : appConfig.appUri + "/reports/fetchEmployeeDetailsByDateBillability?billabilityStatus="+seriesName+"&reportDate="+category url : appConfig.appUri + "/reports/fetchEmployeeDetailsByDateBillability?billabilityStatus="+seriesName+"&reportDate="+category
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
$scope.gridOptions.data = response.data; $scope.gridOptions.data = response.data;
if(response.data.length > 10){ if(response.data.length > 10){
$scope.gridOptions.enablePaginationControls = true; $scope.gridOptions.enablePaginationControls = true;
} }
else{ else{
$scope.gridOptions.enablePaginationControls = false; $scope.gridOptions.enablePaginationControls = false;
} }
}, function myError(response) { }, function myError(response) {
showAlert("Something went wrong while fetching data!!!"); showAlert("Something went wrong while fetching data!!!");
$scope.gridOptions.data = []; $scope.gridOptions.data = [];
}); });
} }
}; };
function showAlert(message) { function showAlert(message) {
$mdDialog.show($mdDialog.alert().parent( $mdDialog.show($mdDialog.alert().parent(
angular.element(document.querySelector('#popupContainer'))) angular.element(document.querySelector('#popupContainer')))
.clickOutsideToClose(true).textContent(message).ariaLabel( .clickOutsideToClose(true).textContent(message).ariaLabel(
'Alert Dialog').ok('Ok')); 'Alert Dialog').ok('Ok'));
} }
$scope.drawChart = function(element,chartName,result,title,categoriesList){ $scope.drawChart = function(element,chartName,result,title,categoriesList){
Highcharts.chart(element[0], { Highcharts.chart(element[0], {
chart: { chart: {
type: chartName, type: chartName,
height: (9 / 16 * 100) + '%' height: '300px'
}, },
title: { title: {
text: title text: title
}, },
credits: { credits: {
enabled: false enabled: false
}, },
xAxis: { xAxis: {
categories: categoriesList, categories: categoriesList,
labels:{ labels:{
formatter: function() { formatter: function() {
if (chartName != 'pie' || chartName != 'line') { if (chartName != 'pie' || chartName != 'line') {
return this.value; return this.value;
} else{ } else{
return '(Not Designated)'; return '(Not Designated)';
} }
} }
}, },
}, },
legend: { legend: {
align: 'right', align: 'right',
x: -30, x: -30,
verticalAlign: 'top', verticalAlign: 'top',
y: 25, y: 25,
floating: true, floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white', backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
borderColor: '#CCC', borderColor: '#CCC',
borderWidth: 1, borderWidth: 1,
shadow: false shadow: false
}, },
tooltip: { tooltip: {
formatter: function() { formatter: function() {
return '<b>'+this.x+'</b><br/>'+ return '<b>'+this.x+'</b><br/>'+
(this.point.percent ? this.series.name + ':' + this.point.y + ' ( '+this.point.percent.toFixed(2)+' % )' : this.series.name + ':' + this.point.y); (this.point.percent ? this.series.name + ':' + this.point.y + ' ( '+this.point.percent.toFixed(2)+' % )' : this.series.name + ':' + this.point.y);
} }
}, },
plotOptions: { plotOptions: {
pie: { pie: {
allowPointSelect: true, allowPointSelect: true,
cursor: 'pointer', cursor: 'pointer',
dataLabels: { dataLabels: {
enabled: true, enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %', format: '<b>{point.name}</b>: {point.percentage:.1f} %',
style: { style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black' color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
} }
} }
}, },
series:{ series:{
events:{ events:{
click: function(event) { click: function(event) {
$scope.getMyTeamDetails(event.point.series.name,event.point.category,event.point.options.name,title); $scope.getMyTeamDetails(event.point.series.name,event.point.category,event.point.options.name,title);
} }
} }
} }
}, },
series: result series: result
}); });
} }
}); });
function getEmployeeDetails(scope,uri,chart,element,title){ function getEmployeeDetails(scope,uri,chart,element,title){
var result = []; var result = [];
var categoriesList = []; var categoriesList = [];
Highcharts.ajax({ Highcharts.ajax({
url: uri, url: uri,
success: function(data) { success: function(data) {
if(chart=='line' || chart == 'column'){ if(chart=='line' || chart == 'column'){
result = data.seriesDataList; result = data.seriesDataList;
categoriesList = data.categoriesList; categoriesList = data.categoriesList;
}else if(chart == 'pie'){ }else if(chart == 'pie'){
result = data; result = data;
categoriesList = data; categoriesList = data;
} }
scope.drawChart(element,chart,result,title,categoriesList); scope.drawChart(element,chart,result,title,categoriesList);
} }
}); });
} }
\ No newline at end of file
/* File Name : custom-theme.css /* File Name : custom-theme.css
Date : 03/09/2018 Date : 03/09/2018
Author : Vanavaraju Adabala Author : Vanavaraju Adabala
*/ */
/* ===== Common Styles ===== */ /* ===== Common Styles ===== */
body { body {
background: #ffffff; background: #ffffff;
/* overflow: hidden; */ /* overflow: hidden; */
} }
.left { .left {
float: left; float: left;
} }
.right { .right {
float: right; float: right;
} }
.hide { .hide {
display: none; display: none;
} }
.no-padding { .no-padding {
padding: 0; padding: 0;
} }
.scroll-content { .scroll-content {
height: 100%; height: 100%;
max-height: 500px; max-height: 500px;
overflow: auto; overflow: auto;
} }
/* For Scroll bar color */ /* For Scroll bar color */
::-webkit-scrollbar { ::-webkit-scrollbar {
width: 6px; width: 6px;
} }
/* Track */ /* Track */
::-webkit-scrollbar-track { ::-webkit-scrollbar-track {
background: #f1f1f1; background: #f1f1f1;
} }
/* Handle */ /* Handle */
::-webkit-scrollbar-thumb { ::-webkit-scrollbar-thumb {
background: #666666; background: #666666;
} }
/* Handle on hover */ /* Handle on hover */
::-webkit-scrollbar-thumb:hover { ::-webkit-scrollbar-thumb:hover {
background: #999; background: #999;
} }
/* For Refersh icon rotate */ /* For Refersh icon rotate */
i.fa.fa-refresh { i.fa.fa-refresh {
cursor: pointer; cursor: pointer;
transition: transform 1s ease-in-out; transition: transform 1s ease-in-out;
} }
i.fa.fa-refresh:hover { i.fa.fa-refresh:hover {
transform:rotate(2700deg); transform:rotate(2700deg);
-ms-transform:rotate(270deg); -ms-transform:rotate(270deg);
-webkit-transform:rotate(270deg); -webkit-transform:rotate(270deg);
} }
/* ===== Header Styles ===== */ /* ===== Header Styles ===== */
#header { #header {
background: #eeeef6; background: #eeeef6;
height: 52px; height: 52px;
} }
#header .navbar-header { #header .navbar-header {
background: #ffffff; background: #ffffff;
position: relative; position: relative;
width: 215px; width: 215px;
} }
#header .navbar-header img { #header .navbar-header img {
margin: 0 0 0 10px; margin: 0 0 0 10px;
} }
#header .navbar-header:after { #header .navbar-header:after {
content: ""; content: "";
border-left: 50px solid #fff; border-left: 50px solid #fff;
border-bottom: 50px solid transparent; border-bottom: 50px solid transparent;
position: absolute; position: absolute;
right: -50px; right: -50px;
top: 0; top: 0;
} }
#header .navbar-inverse { #header .navbar-inverse {
background: #eeeef6; background: #eeeef6;
border-bottom: 2px solid #00b4e5; border-bottom: 2px solid #00b4e5;
height: 53px; height: 53px;
} }
#header .navbar-inverse a.menu-icon { #header .navbar-inverse a.menu-icon {
color: #34495e; color: #34495e;
font-size: 22px; font-size: 22px;
margin: 14px 0 0 40px; margin: 14px 0 0 40px;
display: none; /* Need to enable once we check the functionality */ display: none; /* Need to enable once we check the functionality */
} }
#header .dropdown-toggle { #header .dropdown-toggle {
padding: 12px; padding: 12px;
} }
#header .dropdown-toggle .caret { #header .dropdown-toggle .caret {
color: #000; color: #000;
margin: -10px 0 0 10px; margin: -10px 0 0 10px;
} }
#header .navbar-inverse .navbar-nav>.active>a:hover .dropdown.active.open { #header .navbar-inverse .navbar-nav>.active>a:hover .dropdown.active.open {
background: blue; background: blue;
display: block; display: block;
-webkit-transition: max-height 1s; -webkit-transition: max-height 1s;
-moz-transition: max-height 1s; -moz-transition: max-height 1s;
-ms-transition: max-height 1s; -ms-transition: max-height 1s;
-o-transition: max-height 1s; -o-transition: max-height 1s;
transition: max-height 1s; transition: max-height 1s;
max-height: 300px; max-height: 300px;
} }
/* My Account */ /* My Account */
.my-account { .my-account {
overflow: hidden; overflow: hidden;
padding: 0; padding: 0;
} }
.my-account .card.hovercard .info .desc { .my-account .card.hovercard .info .desc {
border-top: solid 1px #ccc; border-top: solid 1px #ccc;
font-size: 13px; font-size: 13px;
line-height: 28px; line-height: 28px;
} }
.my-account .card.hovercard .info .desc, .my-account .card.hovercard .info .title { .my-account .card.hovercard .info .desc, .my-account .card.hovercard .info .title {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
width: 215px; width: 215px;
} }
.my-account .card.hovercard .info .desc:last-child { .my-account .card.hovercard .info .desc:last-child {
line-height: normal; line-height: normal;
} }
.my-account .card.hovercard .info .desc a { .my-account .card.hovercard .info .desc a {
color: #ff0000; color: #ff0000;
} }
.my-account .card.hovercard .info .desc i, .my-account .card.hovercard .info .desc a i { .my-account .card.hovercard .info .desc i, .my-account .card.hovercard .info .desc a i {
font-size: 14px; font-size: 14px;
margin: 5px 5px 0px 0; margin: 5px 5px 0px 0;
} }
/* .card.hovercard .info { /* .card.hovercard .info {
} */ } */
/* Menu Navigation */ /* Menu Navigation */
.navbar-inverse .navbar-nav>.active>a, .navbar-inverse .navbar-nav>.active>a:hover, .navbar-inverse .navbar-nav>.active>a:focus { .navbar-inverse .navbar-nav>.active>a, .navbar-inverse .navbar-nav>.active>a:hover, .navbar-inverse .navbar-nav>.active>a:focus {
background: none; background: none;
color: #34495e; color: #34495e;
line-height: normal; line-height: normal;
} }
.navbar-nav>li>.dropdown-menu { .navbar-nav>li>.dropdown-menu {
/* height: 0px; */ /* height: 0px; */
border: 1px solid #00b4e5; border: 1px solid #00b4e5;
padding: 10px; padding: 10px;
width: 350px; width: 350px;
} }
/* Left Section */ /* Left Section */
#sidebar-left { #sidebar-left {
float: left; float: left;
transition: width 0.4s ease-out; transition: width 0.4s ease-out;
/* margin: 0 15px 0 0; */ /* margin: 0 15px 0 0; */
width: 215px; width: 215px;
} }
#sidebar-wrapper { #sidebar-wrapper {
background: #00b4e5 !important; background: #00b4e5 !important;
height: 100%; height: 100%;
overflow: auto; overflow: auto;
width: 100% !important; width: 100% !important;
} }
#sidebar-wrapper .sidebar-nav { #sidebar-wrapper .sidebar-nav {
list-style: none; list-style: none;
padding: 0; padding: 0;
} }
#sidebar-wrapper .sidebar-nav li { #sidebar-wrapper .sidebar-nav li {
border-bottom: 1px dotted #34495e; border-bottom: 1px dotted #34495e;
line-height: normal; line-height: normal;
list-style: none; list-style: none;
} }
#sidebar-wrapper .sidebar-nav li ul.manageGroup { #sidebar-wrapper .sidebar-nav li ul.manageGroup {
max-height: 165px; max-height: 165px;
overflow: hidden; overflow: hidden;
height: auto; height: auto;
padding: 0; padding: 0;
transition: max-height 0.5s ease-out; transition: max-height 0.5s ease-out;
} }
#sidebar-wrapper .sidebar-nav li ul.manageGroup.ng-hide { #sidebar-wrapper .sidebar-nav li ul.manageGroup.ng-hide {
max-height: 0; max-height: 0;
} }
#sidebar-wrapper .sidebar-nav li ul.manageGroup li a { #sidebar-wrapper .sidebar-nav li ul.manageGroup li a {
padding-left: 35px; padding-left: 35px;
} }
#sidebar-wrapper .sidebar-nav li ul.manageGroup:hover { #sidebar-wrapper .sidebar-nav li ul.manageGroup:hover {
background: transparent; background: transparent;
} }
#sidebar-wrapper .sidebar-nav li ul.reportsGroup { #sidebar-wrapper .sidebar-nav li ul.reportsGroup {
max-height: 291px; max-height: 291px;
height: auto; height: auto;
overflow: hidden; overflow: hidden;
padding: 0; padding: 0;
transition: max-height 0.5s ease-out; transition: max-height 0.5s ease-out;
} }
#sidebar-wrapper .sidebar-nav li ul.reportsGroup.ng-hide { #sidebar-wrapper .sidebar-nav li ul.reportsGroup.ng-hide {
max-height: 0; max-height: 0;
} }
#sidebar-wrapper .sidebar-nav li ul.reportsGroup li a { #sidebar-wrapper .sidebar-nav li ul.reportsGroup li a {
padding-left: 35px; padding-left: 35px;
} }
#sidebar-wrapper .sidebar-nav li ul.reportsGroup:hover { #sidebar-wrapper .sidebar-nav li ul.reportsGroup:hover {
background: transparent; background: transparent;
} }
#sidebar-wrapper .sidebar-nav li:last-child { #sidebar-wrapper .sidebar-nav li:last-child {
border: none; border: none;
} }
#sidebar-wrapper .sidebar-nav li a { #sidebar-wrapper .sidebar-nav li a {
color: #34495e; color: #34495e;
display: block; display: block;
font-size: 13px; font-size: 13px;
padding: 12px; padding: 12px;
text-decoration: none; text-decoration: none;
} }
/* For Small Menu Styles */ /* For Small Menu Styles */
#sidebar-left.small-menu #sidebar-wrapper .sidebar-nav li a span { #sidebar-left.small-menu #sidebar-wrapper .sidebar-nav li a span {
display: none; display: none;
} }
#sidebar-left.small-menu #sidebar-wrapper .sidebar-nav li a { #sidebar-left.small-menu #sidebar-wrapper .sidebar-nav li a {
padding-left: 10px; padding-left: 10px;
text-align: center; text-align: center;
} }
#sidebar-left.small-menu #sidebar-wrapper .sidebar-nav li ul { #sidebar-left.small-menu #sidebar-wrapper .sidebar-nav li ul {
background: #fafafc; background: #fafafc;
} }
#sidebar-wrapper .sidebar-nav li a i { #sidebar-wrapper .sidebar-nav li a i {
transition: all .5s ease-in-out 0s; transition: all .5s ease-in-out 0s;
-moz-transition: all .5s ease-in-out 0s; -moz-transition: all .5s ease-in-out 0s;
-webkit-transition: all .5s ease-in-out 0s; -webkit-transition: all .5s ease-in-out 0s;
-o-transition: all .5s ease-in-out 0s; -o-transition: all .5s ease-in-out 0s;
} }
#sidebar-wrapper .sidebar-nav li a:hover i { #sidebar-wrapper .sidebar-nav li a:hover i {
margin: 0 12px 0 0; margin: 0 12px 0 0;
transform: scale(1.4); transform: scale(1.4);
-moz-transform: scale(1.4); -moz-transform: scale(1.4);
-webkit-transform: scale(1.4); -webkit-transform: scale(1.4);
-o-transform: scale(1.4); -o-transform: scale(1.4);
} }
#sidebar-wrapper .sidebar-nav li a.activeMenu { #sidebar-wrapper .sidebar-nav li a.activeMenu {
background-color: #34495e; background-color: #34495e;
color: #ffffff; color: #ffffff;
} }
#sidebar-wrapper .sidebar-nav li a i { #sidebar-wrapper .sidebar-nav li a i {
font-size: 16px; font-size: 16px;
margin: 0 5px 0 0; margin: 0 5px 0 0;
} }
#sidebar-wrapper .sidebar-nav li>:hover, #sidebar-wrapper .sidebar-nav li a>:hover { #sidebar-wrapper .sidebar-nav li>:hover, #sidebar-wrapper .sidebar-nav li a>:hover {
background: #34495e; background: #34495e;
color: #fff; color: #fff;
} }
#sidebar-left.small-menu { #sidebar-left.small-menu {
transition: width 0.4s ease-out; transition: width 0.4s ease-out;
width: 85px; width: 85px;
} }
/* ===== Main Container ===== */ /* ===== Main Container ===== */
.main-container { .main-container {
display: flex; display: flex;
/* height: calc(100% - 105px); need to test and enable*/ /* height: calc(100% - 105px); need to test and enable*/
overflow: hidden; overflow: hidden;
height: calc(100% - 102px); height: calc(100% - 102px);
} }
/* .main-container #sidebar-left, .main-container #main { /* .main-container #sidebar-left, .main-container #main {
flex: 1; flex: 1;
} */ } */
#main { #main {
/* flex: 1; */ /* flex: 1; */
float: left; float: left;
height: 100%; height: 100%;
width: calc(100% - 215px); width: calc(100% - 215px);
} }
#main h1 { #main h1 {
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
font-size: 22px; font-size: 22px;
margin: 0 0 16px 0; margin: 0 0 16px 0;
padding-bottom: 10px; padding-bottom: 10px;
} }
#main i.fa-refresh { #main i.fa-refresh {
color: #333333; color: #333333;
font-size: 17px; font-size: 17px;
} }
.add-emp { .add-emp {
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
margin-left: -15px; margin-left: -15px;
text-align: right; text-align: right;
} }
.add-emp button, .add-btn { .add-emp button, .add-btn {
font-size: 11px; font-size: 11px;
height: auto; height: auto;
line-height: normal; line-height: normal;
min-height: auto; min-height: auto;
margin: 0 8px 5px 8px; margin: 0 8px 5px 8px;
padding: 8px; padding: 8px;
} }
.add-emp button i { .add-emp button i {
font-size: 12px; font-size: 12px;
} }
.add-emp .state-select { .add-emp .state-select {
display: inline-block; display: inline-block;
margin: 4px 10px; margin: 4px 10px;
} }
.add-emp .state-select type["radio"] { .add-emp .state-select type["radio"] {
margin: 0 10px 0 0; margin: 0 10px 0 0;
} }
/* ===== Button Styles ===== */ /* ===== Button Styles ===== */
.primary.md-raised { .primary.md-raised {
background: green; background: green;
} }
.form-group button { .form-group button {
cursor: pointer; cursor: pointer;
margin: 0; margin: 0;
padding: 0px 15px 0 10px; padding: 0px 15px 0 10px;
} }
.form-group button i { .form-group button i {
font-size: 16px; font-size: 16px;
margin: 0 5px 0 0; margin: 0 5px 0 0;
} }
.form-group button.md-primary { .form-group button.md-primary {
background: #f8f8f8; background: #f8f8f8;
border: 1px solid #ccc; border: 1px solid #ccc;
border-radius: 3px; border-radius: 3px;
} }
.form-group button.submit { .form-group button.submit {
background-color: #bfd630; background-color: #bfd630;
border-color: #bfd630; border-color: #bfd630;
border-radius: 3px; border-radius: 3px;
color: #333333; color: #333333;
} }
/* ===== Footer Styles ===== */ /* ===== Footer Styles ===== */
#footer { #footer {
clear: both; clear: both;
height: 40px; height: 40px;
} }
#footer .navbar-inverse, #footer .navbar-inverse { #footer .navbar-inverse, #footer .navbar-inverse {
background: #eeeef6; background: #eeeef6;
border-top: 2px solid #00b4e5; border-top: 2px solid #00b4e5;
position: fixed; position: fixed;
} }
#footer .navbar-inverse .copyrights { #footer .navbar-inverse .copyrights {
/* background: #fff; /* background: #fff;
width: 215px; */ width: 215px; */
padding-right: 0px; padding-right: 0px;
} }
#footer .navbar-inverse .copyrights:after { #footer .navbar-inverse .copyrights:after {
content: ""; content: "";
border-right: 50px solid transparent; border-right: 50px solid transparent;
border-bottom: 50px solid #fff; border-bottom: 50px solid #fff;
position: absolute; position: absolute;
right: -50px; right: -50px;
top: 0; top: 0;
display:none; display:none;
} }
#footer .footer { #footer .footer {
/* line-height: 50px; */ /* line-height: 50px; */
} }
#footer .footer p { #footer .footer p {
font-size: 12px; font-size: 12px;
margin: 15px 0 0; margin: 15px 0 0;
} }
#footer .footer .img { #footer .footer .img {
margin: 6px 0 0 0; margin: 6px 0 0 0;
} }
#footer .navbar-inverse .copyrights + div { #footer .navbar-inverse .copyrights + div {
padding-right: 0; padding-right: 0;
} }
/* Grid Styles */ /* Grid Styles */
.grid-full-view { .grid-full-view {
height: calc(100vh - 185px) !important; height: calc(100vh - 185px) !important;
} }
.grid-half-view { .grid-half-view {
height: calc(85vh - 215px) !important; height: calc(85vh - 215px) !important;
} }
.ui-grid-contents-wrapper { .ui-grid-contents-wrapper {
/* height: 90% !important; */ /* height: 90% !important; */
} }
.ui-grid { .ui-grid {
border: none !important; border: none !important;
/* height : 40px; */ /* height : 40px; */
} }
.ui-grid-viewport { .ui-grid-viewport {
/* border: 1px solid #cccccc; */ /* border: 1px solid #cccccc; */
overflow: auto !important; /* Need to check with JS code and remove */ overflow: auto !important; /* Need to check with JS code and remove */
} }
.ui-grid-contents-wrapper .ui-grid-header { .ui-grid-contents-wrapper .ui-grid-header {
border: none; border: none;
} }
.ui-grid-contents-wrapper .ui-grid-header .ui-grid-top-panel { .ui-grid-contents-wrapper .ui-grid-header .ui-grid-top-panel {
background: #34495e; background: #34495e;
border-radius: 3px 3px 0 0; border-radius: 3px 3px 0 0;
color: #ffffff; color: #ffffff;
} }
.ui-grid-contents-wrapper .ui-grid-header-cell { .ui-grid-contents-wrapper .ui-grid-header-cell {
border: none; border: none;
background: #eeeef6; background: #eeeef6;
} }
.ui-grid-contents-wrapper .ui-grid-header-cell > div { .ui-grid-contents-wrapper .ui-grid-header-cell > div {
background: #34495e; background: #34495e;
} }
.ui-grid-contents-wrapper .ui-grid-header-cell .ui-grid-filter-container { .ui-grid-contents-wrapper .ui-grid-header-cell .ui-grid-filter-container {
background: #eeeef6; background: #eeeef6;
padding: 4px 4px 4px 6px; padding: 4px 4px 4px 6px;
} }
.ui-grid-contents-wrapper .ui-grid-header-cell .ui-grid-filter-container select { .ui-grid-contents-wrapper .ui-grid-header-cell .ui-grid-filter-container select {
height: 25px; height: 25px;
} }
.ui-grid-selection-row-header-buttons { .ui-grid-selection-row-header-buttons {
padding: 3px 0; padding: 3px 0;
} }
.ui-grid-selection-row-header-buttons::before { .ui-grid-selection-row-header-buttons::before {
margin: 0; margin: 0;
} }
/* .ui-grid-contents-wrapper .ui-grid-header-cell div:empty { /* .ui-grid-contents-wrapper .ui-grid-header-cell div:empty {
background: #eeeef6; background: #eeeef6;
min-height: 30px; min-height: 30px;
} */ } */
.ui-grid-contents-wrapper .ui-grid-header-cell:last-child div:empty:last-child:after { .ui-grid-contents-wrapper .ui-grid-header-cell:last-child div:empty:last-child:after {
background: #eeeef6; background: #eeeef6;
content: ""; content: "";
display: inline-block; display: inline-block;
width: 6px; width: 6px;
height: 30px; height: 30px;
position: absolute; position: absolute;
right: -6px; right: -6px;
} }
.ui-grid-contents-wrapper .ui-grid-cell-contents { .ui-grid-contents-wrapper .ui-grid-cell-contents {
/* border-bottom: 1px solid #e5e5e5; */ /* border-bottom: 1px solid #e5e5e5; */
padding: 10px 8px; padding: 10px 8px;
word-break: break-word; word-break: break-word;
} }
.ui-grid-contents-wrapper .ui-grid-render-container-body .ui-grid-canvas .ui-grid-cell { .ui-grid-contents-wrapper .ui-grid-render-container-body .ui-grid-canvas .ui-grid-cell {
border: none; border: none;
height: 40px; height: 40px;
/* line-height: 20px; */ /* line-height: 20px; */
margin: 0; margin: 0;
} }
.ui-grid-contents-wrapper .ui-grid-render-container-body .ui-grid-canvas { .ui-grid-contents-wrapper .ui-grid-render-container-body .ui-grid-canvas {
font-size: 13px; font-size: 13px;
padding: 0; padding: 0;
} }
.ui-grid-canvas .ui-grid-row { .ui-grid-canvas .ui-grid-row {
height: auto !important; height: auto !important;
} }
.ui-grid-canvas .ui-grid-cell-contents { .ui-grid-canvas .ui-grid-cell-contents {
line-height : normal; line-height : normal;
white-space: normal; white-space: normal;
} }
.ui-grid-contents-wrapper .ui-grid-render-container-body .ui-grid-canvas .ui-grid-cell-contents, .ui-grid-contents-wrapper .ui-grid-render-container-body .ui-grid-canvas .ui-grid-cell:empty { .ui-grid-contents-wrapper .ui-grid-render-container-body .ui-grid-canvas .ui-grid-cell-contents, .ui-grid-contents-wrapper .ui-grid-render-container-body .ui-grid-canvas .ui-grid-cell:empty {
/* border-bottom: 1px solid #e5e5e5; */ /* border-bottom: 1px solid #e5e5e5; */
} }
.ui-grid-contents-wrapper .ui-grid-render-container-body .ui-grid-canvas .ui-grid-cell p { .ui-grid-contents-wrapper .ui-grid-render-container-body .ui-grid-canvas .ui-grid-cell p {
/* border-bottom: 1px solid #e5e5e5; */ /* border-bottom: 1px solid #e5e5e5; */
min-height: 40px; min-height: 40px;
padding-top: 6px; padding-top: 6px;
} }
.ui-grid-contents-wrapper .ui-grid-row:nth-child(even) .ui-grid-cell { .ui-grid-contents-wrapper .ui-grid-row:nth-child(even) .ui-grid-cell {
/* background-color: #fafafc; */ /* background-color: #fafafc; */
} }
.ui-grid-header-cell-row .ui-grid-column-menu-button { .ui-grid-header-cell-row .ui-grid-column-menu-button {
position: absolute; position: absolute;
right: 0; right: 0;
top: 6px; top: 6px;
} }
.ui-grid-menu .ui-grid-menu-inner ul li .ui-grid-menu-item { .ui-grid-menu .ui-grid-menu-inner ul li .ui-grid-menu-item {
font-size: 12px; font-size: 12px;
padding: 5px 10px 6px 8px; padding: 5px 10px 6px 8px;
} }
.ui-grid-pager-panel { .ui-grid-pager-panel {
background: #fff; background: #fff;
/* border: solid 1px #ccc; */ /* border: solid 1px #ccc; */
border-top: none; border-top: none;
font-size: 13px; font-size: 13px;
width: 99.8% !important; width: 99.8% !important;
} }
.ui-grid-pager-panel .ui-grid-pager-control button { .ui-grid-pager-panel .ui-grid-pager-control button {
background: #dddddd; background: #dddddd;
border-radius: 0; border-radius: 0;
border: none; border: none;
height: auto; height: auto;
padding: 10px 12px; padding: 10px 12px;
} }
.ui-grid-pager-panel .ui-grid-pager-control input { .ui-grid-pager-panel .ui-grid-pager-control input {
background: 1px solid #ccc; background: 1px solid #ccc;
border-radius: 0; border-radius: 0;
height: auto; height: auto;
margin: 0 8px; margin: 0 8px;
} }
.ui-grid-pager-panel .ui-grid-pager-row-count-picker { .ui-grid-pager-panel .ui-grid-pager-row-count-picker {
height: 30px; height: 30px;
margin: 0 6px 0 0; margin: 0 6px 0 0;
padding: 5px 10px 5px 0; padding: 5px 10px 5px 0;
} }
.ui-grid-pager-panel .ui-grid-pager-row-count-picker select { .ui-grid-pager-panel .ui-grid-pager-row-count-picker select {
height: 30px; height: 30px;
margin: 0 8px 0 0; margin: 0 8px 0 0;
} }
.ui-grid-canvas .ui-grid-row:hover { .ui-grid-canvas .ui-grid-row:hover {
background: green; background: green;
} }
.md-toolbar-tools, .md-toolbar { .md-toolbar-tools, .md-toolbar {
background: #3f51b5 !important; background: #3f51b5 !important;
height: 50px !important; height: 50px !important;
min-height: 50px !important; min-height: 50px !important;
max-height: 50px !important; max-height: 50px !important;
} }
.layout-row button { .layout-row button {
background: #3f51b5 !important; background: #3f51b5 !important;
color: #fff !important; color: #fff !important;
} }
/* .ui-grid-viewport { /* .ui-grid-viewport {
height: auto !important; height: auto !important;
max-height: calc(350px - 20px); max-height: calc(350px - 20px);
} */ } */
.ui-grid-icon-cancel{ .ui-grid-icon-cancel{
color:black; color:black;
} }
md-toolbar._md-toolbar-transitions { md-toolbar._md-toolbar-transitions {
min-height: 50px !important; min-height: 50px !important;
} }
.mandatory:after { .mandatory:after {
content: " *"; content: " *";
color: red; color: red;
font-size: 15px; font-size: 15px;
} }
md-select-header.selectHeaderChild { md-select-header.selectHeaderChild {
position: relative position: relative
} }
md-select-header input.searchBoxHeader { md-select-header input.searchBoxHeader {
padding: 8px; padding: 8px;
margin: 8px; margin: 8px;
position: relative; position: relative;
} }
.close-mdselect { .close-mdselect {
position: absolute; position: absolute;
right: 18px; right: 18px;
top: 22px; top: 22px;
} }
.optionScroll{ .optionScroll{
margin-top:0px; margin-top:0px;
} }
.selectHeader .md-content._md { .selectHeader .md-content._md {
max-height: 240px; max-height: 240px;
} }
.md-dialog-container { .md-dialog-container {
z-index: 100 !important; z-index: 100 !important;
} }
.md-select-menu-container { .md-select-menu-container {
z-index: 100 !important; z-index: 100 !important;
} }
.md-dialog-custom-height { .md-dialog-custom-height {
max-height: 95% !important; max-height: 95% !important;
} }
.md-content{ .md-content{
height: 1100px !important; height: 1100px !important;
} }
.md-datepicker-is-showing .md-scroll-mask { .md-datepicker-is-showing .md-scroll-mask {
position: fixed; position: fixed;
z-index: inherit; z-index: inherit;
} }
.red{ .red{
background-color: red !important; background-color: red !important;
color:white; color:white;
font-weight:bold; font-weight:bold;
} }
.orange{ .orange{
background-color: orange !important; background-color: orange !important;
color:white; color:white;
font-weight:bold; font-weight:bold;
} }
.blue{ .blue{
background-color:blue !important; background-color:blue !important;
color:white; color:white;
font-weight:bold; font-weight:bold;
} }
.green{ .green{
background-color:green !important; background-color:green !important;
color:white; color:white;
font-weight:bold; font-weight:bold;
} }
.violet{ .violet{
background-color:#ab0a0a !important; background-color:#ab0a0a !important;
color:white; color:white;
font-weight:bold; font-weight:bold;
} }
/* .manage-accounts .ui-grid-viewport { /* .manage-accounts .ui-grid-viewport {
height: 400px !important; height: 400px !important;
} */ } */
.autoComplete-dropdown { .autoComplete-dropdown {
border-color: #ececec; border-color: #ececec;
border-width: 1px; border-width: 1px;
cursor: pointer; cursor: pointer;
max-height: 206px; max-height: 206px;
overflow-y: auto; overflow-y: auto;
position: absolute; position: absolute;
top: 35px; top: 35px;
z-index: 99; z-index: 99;
width: 180px; width: 180px;
} }
/* .project-allocation .ui-grid-canvas .ui-grid-row, .manage-accounts .ui-grid-canvas .ui-grid-row { /* .project-allocation .ui-grid-canvas .ui-grid-row, .manage-accounts .ui-grid-canvas .ui-grid-row {
} */ } */
.project-allocation .ui-grid-canvas .ui-grid-row div div:nth-child(3), .manage-accounts .ui-grid-canvas .ui-grid-row div div:nth-child(3){ .project-allocation .ui-grid-canvas .ui-grid-row div div:nth-child(3), .manage-accounts .ui-grid-canvas .ui-grid-row div div:nth-child(3){
/* border-bottom: solid 1px #e5e5e5; */ /* border-bottom: solid 1px #e5e5e5; */
line-height: normal; line-height: normal;
overflow: auto; overflow: auto;
padding: 5px 0; padding: 5px 0;
} }
.project-allocation .ui-grid-canvas .ui-grid-row div div:nth-child(3) div:first-child, .manage-accounts .ui-grid-canvas .ui-grid-row div div:nth-child(3) div:first-child{ .project-allocation .ui-grid-canvas .ui-grid-row div div:nth-child(3) div:first-child, .manage-accounts .ui-grid-canvas .ui-grid-row div div:nth-child(3) div:first-child{
padding-top: 5px; padding-top: 5px;
} }
.login-reports-page { .login-reports-page {
margin : 0 0 15px 0; margin : 0 0 15px 0;
} }
.login-reports-page > .col-lg-12 > .row > .col-lg-2 { .login-reports-page > .col-lg-12 > .row > .col-lg-2 {
margin-right: 40px; margin-right: 40px;
} }
.reports-btn > button { .reports-btn > button {
background-color : #3f51b5; background-color : #3f51b5;
} }
.reports-btn > button:disabled { .reports-btn > button:disabled {
background-color : #3f51b5; background-color : #3f51b5;
} }
.update-Teammate>h4 { .update-Teammate>h4 {
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
padding-bottom : 5px; padding-bottom : 5px;
} }
.update-teammate-dropdown md-select { .update-teammate-dropdown md-select {
margin : -6px 0 0 0; margin : -6px 0 0 0;
} }
.panel-default>.panel-heading { .panel-default>.panel-heading {
color: #fff; color: #fff;
background-color: #3f51b5; background-color: #3f51b5;
border-color: #ddd; border-color: #ddd;
} }
.update-Teammate .form-inline { .update-Teammate .form-inline {
margin-bottom : 15px; margin-bottom : 15px;
} }
.billable-table { .billable-table {
margin-top : 10px; margin-top : 10px;
} }
.billable-table .table { .billable-table .table {
margin : 0px; margin : 0px;
} }
.grid-Dropdown md-select { .grid-Dropdown md-select {
margin : 0px; margin : 0px;
} }
.employees-login { .employees-login {
height: calc(100vh - 254px) !important; height: calc(100vh - 254px) !important;
} }
.manage-attendance-report { .manage-attendance-report {
height: calc(85vh - 183px) !important; height: calc(85vh - 183px) !important;
} }
.manage-employee-efforts { .manage-employee-efforts {
height: calc(100vh - 260px) !important; height: calc(100vh - 260px) !important;
} }
.md-datepicker-input-mask { .md-datepicker-input-mask {
height : 0px; height : 0px;
} }
.allocation-change-report { .allocation-change-report {
height: calc(85vh - 168px) !important; height: calc(85vh - 168px) !important;
} }
\ No newline at end of file .utilization-report {
height: calc(86vh - 346px) !important;
}
<html> <html>
<body> <body>
<div class="md-padding" <div class="md-padding"
id="popupContainer" ng-controller="chartsController"> id="popupContainer" ng-controller="chartsController">
<div class="text-right"> <div class="text-right">
Report Type:<select ng-model="report" #ref ng-change="clickMe(report)" ng-options="report.Name for report in reports"></select> Report Type:<select ng-model="report" #ref ng-change="clickMe(report)" ng-options="report.Name for report in reports"></select>
</div> </div>
<hc-pie-chart title="Browser usage" data="pieData" options="chartOptions">Placeholder for pie chart</hc-pie-chart> <hc-pie-chart title="Browser usage" data="pieData" options="chartOptions">Placeholder for pie chart</hc-pie-chart>
<div class="row col-lg-12"> <div class="row col-lg-12">
<div id="gridTest" ui-grid="gridOptions" ui-grid-pagination ui-grid-exporter <div id="gridTest" ui-grid="gridOptions" ui-grid-pagination ui-grid-exporter
class="myGrid" style="width:100%;height:186px;margin-left:0px;"> class="myGrid utilization-report">
<div class="watermark" ng-show="!gridOptions.data.length">No <div class="watermark" ng-show="!gridOptions.data.length">No
data available</div> data available</div>
</div> </div>
</div> </div>
</div> </div>
</body> </body>
</html> </html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment