Commit 0e73a6d1 authored by Srikanth Gajula's avatar Srikanth Gajula

MT-01:[Srikanth] latest changes pulled from Nisum Repo

parent 3d30819d
# mytime
\ No newline at end of file
# NisumTime
\ No newline at end of file
......@@ -13,6 +13,12 @@ buildscript {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'war'
war {
baseName = 'my-time'
version = ''
}
group = 'com.nisum.mytime'
version = '0.0.1-SNAPSHOT'
......@@ -37,7 +43,7 @@ dependencies {
compile('org.quartz-scheduler:quartz:2.2.1')
compile('org.quartz-scheduler:quartz:2.3.0')
testCompile('org.springframework.boot:spring-boot-starter-test')
compile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version:'1.5.8.RELEASE'
testCompile ('junit:junit:4.12')
compile('net.sf.ucanaccess:ucanaccess:4.0.1')
testCompile('org.hsqldb:hsqldb')
......
package com.nisum.mytime.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
@Configuration
@EnableWebMvc
@WebAppConfiguration("webapp")
public class MvcConfiguration extends WebMvcConfigurerAdapter {
@Bean
public InternalResourceViewResolver getViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/");
resolver.setViewNames("templates/**");
resolver.setSuffix(".html");
return resolver;
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/css/**").addResourceLocations("/WEB-INF/css/");
registry.addResourceHandler("/images/**").addResourceLocations("/WEB-INF/images/");
registry.addResourceHandler("/js/**").addResourceLocations("/WEB-INF/js/");
registry.addResourceHandler("/controllers/**").addResourceLocations("/WEB-INF/controllers/");
registry.addResourceHandler("/fonts/**").addResourceLocations("/WEB-INF/fonts/");
registry.addResourceHandler("/reports/**").addResourceLocations("/WEB-INF/reports/");
registry.addResourceHandler("/templates/**").addResourceLocations("/WEB-INF/templates/");
}
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
}
\ No newline at end of file
package com.nisum.mytime.configuration;
import java.io.File;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ResourceLoader;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class ReportsCleanUpScheduler {
private static final Logger logger = LoggerFactory.getLogger(ReportsCleanUpScheduler.class);
@Autowired
ResourceLoader resourceLoader;
@Scheduled(cron= "0 55 23 1/1 * *")
public boolean cleanReports(){
boolean flag = false;
try {
File dir = resourceLoader.getResource("/WEB-INF/reports/").getFile();
for(File file : dir.listFiles()){
String fileName = file.getName();
if(file.exists() && !"MyTime.pdf".equals(fileName)){
flag = file.delete();
}
}
logger.info("Reports cleanup performed successfully");
} catch (IOException e) {
logger.error("Report deletion failed due to: ");
}
return flag;
}
}
......@@ -28,7 +28,7 @@ import com.nisum.mytime.schedular.MyTimeCronSchedularJob;
public class SchedulerConfig {
@Value("${cron.expression}")
private String crosExp;
private String cronExp;
@Bean
public JobFactory jobFactory(ApplicationContext applicationContext) {
......@@ -84,7 +84,7 @@ public class SchedulerConfig {
private CronTriggerFactoryBean createCronTrigger(JobDetail jobDetail, long cronExpression) {
CronTriggerFactoryBean factoryBean = new CronTriggerFactoryBean();
factoryBean.setJobDetail(jobDetail);
factoryBean.setCronExpression(crosExp);
factoryBean.setCronExpression(cronExp);
factoryBean.setMisfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW);
return factoryBean;
}
......
package com.nisum.mytime.controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@RestController("/")
@Controller
public class ApplicationController {
@RequestMapping("/")
public String login() {
return "index";
return "templates/index";
}
}
package com.nisum.mytime.controller;
import java.sql.SQLException;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -9,10 +10,13 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.AttendenceData;
import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.service.AttendanceService;
import com.nisum.mytime.service.UserService;
@RestController
......@@ -22,26 +26,28 @@ public class AttendanceController {
@Autowired
private UserService userService;
@RequestMapping(value = "employee/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmpLoginData>> fetchEmployeeDataBasedOnEmpId(@PathVariable("id") long id)
throws MyTimeException {
List<EmpLoginData> empLoginData = userService.fetchEmployeeDataBasedOnEmpId(id);
return new ResponseEntity<>(empLoginData, HttpStatus.OK);
}
@Autowired
private AttendanceService attendanceService;
@RequestMapping(value = "employeeLoginsBasedOnDate/{id}/{fromDate}/{toDate}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmpLoginData>> employeeLoginsBasedOnDate(@PathVariable("id") long id,
@PathVariable("fromDate") String fromDate, @PathVariable("toDate") String toDate) throws MyTimeException {
@RequestMapping(value = "employeeLoginsBasedOnDate", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmpLoginData>> employeeLoginsBasedOnDate(@RequestParam("empId") long id,
@RequestParam("fromDate") String fromDate, @RequestParam("toDate") String toDate) throws MyTimeException {
List<EmpLoginData> message = userService.employeeLoginsBasedOnDate(id, fromDate, toDate);
return new ResponseEntity<>(message, HttpStatus.OK);
}
@RequestMapping(value = "generatePdfReport/{id}/{fromDate}/{toDate}", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<String> generatePdfReport(@PathVariable("id") long id,
@PathVariable("fromDate") String fromDate, @PathVariable("toDate") String toDate)
throws MyTimeException {
String result= userService.generatePdfReport(id, fromDate, toDate);
@PathVariable("fromDate") String fromDate, @PathVariable("toDate") String toDate) throws MyTimeException {
String result = userService.generatePdfReport(id, fromDate, toDate);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@RequestMapping(value = "attendanciesReport/{reportDate}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<AttendenceData>> attendanciesReport(@PathVariable("reportDate") String reportDate)
throws MyTimeException, SQLException {
List<AttendenceData> lisOfAttendenceData = attendanceService.getAttendanciesReport(reportDate);
return new ResponseEntity<>(lisOfAttendenceData, HttpStatus.OK);
}
}
\ No newline at end of file
......@@ -31,9 +31,6 @@ public class EmailController {
@RequestMapping(value = "/deleteReport/{fileName}", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<String> deletePdfReport(@PathVariable("fileName") String fileName) {
String response = mailService.deletePdfReport(fileName);
if ("Success".equals(response))
return new ResponseEntity<>(response, HttpStatus.OK);
else
return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR);
return new ResponseEntity<>(response, HttpStatus.OK);
}
}
package com.nisum.mytime.controller;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import com.nisum.mytime.model.Employee;
@Controller
public class GoogleController {
@PostMapping("/empData")
@ResponseBody
public String getEmpData(@RequestBody Employee employee,
HttpSession session) {
System.out.println(employee.getEmail());
return "{'message':'success'}";
}
}
package com.nisum.mytime.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.EmployeeRoles;
import com.nisum.mytime.model.Project;
import com.nisum.mytime.service.ProjectService;
import com.nisum.mytime.service.UserService;
@RestController
@RequestMapping("/project")
public class ProjectController {
@Autowired
private UserService userService;
@Autowired
private ProjectService projectService;
@RequestMapping(value = "/employee", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> getEmployeeRole(@RequestParam("emailId") String emailId)
throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeesRole(emailId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK);
}
@RequestMapping(value = "/employeesDataSave", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Boolean> employeesDataSave() throws MyTimeException {
Boolean result = userService.fetchEmployeesData();
return new ResponseEntity<>(result, HttpStatus.OK);
}
@RequestMapping(value = "/addProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Project> addProject(@RequestBody Project employeeRoles) throws MyTimeException {
Project project = projectService.addProject(employeeRoles);
return new ResponseEntity<>(project, HttpStatus.OK);
}
@RequestMapping(value = "/updateProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Project> updateEmployeeRole(@RequestBody Project project) throws MyTimeException {
Project updatedProject = projectService.updateProject(project);
return new ResponseEntity<>(updatedProject, HttpStatus.OK);
}
@RequestMapping(value = "/deleteProject", method = RequestMethod.DELETE, produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<String> deleteProject(@RequestParam("projectId") String projectId) throws MyTimeException {
projectService.deleteProject(projectId);
return new ResponseEntity<>("Success", HttpStatus.OK);
}
@RequestMapping(value = "/getProjects", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Project>> getProjects() throws MyTimeException {
List<Project> projects = projectService.getProjects();
return new ResponseEntity<>(projects, HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> getEmployeeRoleData(@RequestParam("empId") String empId)
throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeesRoleData(empId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK);
}
}
\ No newline at end of file
package com.nisum.mytime.controller;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.EmployeeRoles;
import com.nisum.mytime.model.Project;
import com.nisum.mytime.model.ProjectTeamMate;
import com.nisum.mytime.service.ProjectService;
import com.nisum.mytime.service.UserService;
@RestController
@RequestMapping("/projectTeam")
public class ProjectTeamController {
@Autowired
private UserService userService;
@Autowired
private ProjectService projectService;
@RequestMapping(value = "/employee", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> getEmployeeRole(@RequestParam("emailId") String emailId)
throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeesRole(emailId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK);
}
@RequestMapping(value = "/employeesDataSave", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Boolean> employeesDataSave() throws MyTimeException {
Boolean result = userService.fetchEmployeesData();
return new ResponseEntity<>(result, HttpStatus.OK);
}
@RequestMapping(value = "/addProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Project> addProject(@RequestBody Project employeeRoles) throws MyTimeException {
Project project = projectService.addProject(employeeRoles);
return new ResponseEntity<>(project, HttpStatus.OK);
}
@RequestMapping(value = "/updateEmployeeRole", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> updateEmployeeRole(@RequestBody EmployeeRoles employeeRoles) throws MyTimeException {
EmployeeRoles employeeRole = userService.updateEmployeeRole(employeeRoles);
return new ResponseEntity<>(employeeRole, HttpStatus.OK);
}
@RequestMapping(value = "/deleteEmployee", method = RequestMethod.DELETE, produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<String> deleteEmployee(@RequestParam("empId") String empId) throws MyTimeException {
userService.deleteEmployee(empId);
return new ResponseEntity<>("Success", HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> getEmployeeRoleData(@RequestParam("empId") String empId)
throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeesRoleData(empId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeesToTeam", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getManagers() throws MyTimeException {
List<EmployeeRoles> employeesRoles = userService.getEmployeeRoles();
/*List<EmployeeRoles> managers=new ArrayList<>();
for(EmployeeRoles emp:employeesRoles) {
if(emp.getRole().equalsIgnoreCase("Manager")) {
managers.add(emp) ; }
}*/
//List<EmployeeRoles> managers = employeesRoles.stream().filter(e -> e.getRole().equalsIgnoreCase("Manager")).collect(Collectors.toList());
return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
}
@RequestMapping(value = "/getTeamDetails", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ProjectTeamMate>> getTeamDetails(@RequestParam("employeeId") String employeeId) throws MyTimeException {
List<ProjectTeamMate> employeesRoles = projectService.getTeamDetails(employeeId);
//projectService.get
/*List<EmployeeRoles> managers=new ArrayList<>();
for(EmployeeRoles emp:employeesRoles) {
if(emp.getRole().equalsIgnoreCase("Manager")) {
managers.add(emp) ; }
}*/
//List<EmployeeRoles> managers = employeesRoles.stream().filter(e -> e.getRole().equalsIgnoreCase("Manager")).collect(Collectors.toList());
return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
}
@RequestMapping(value = "/addEmployeeToTeam", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ProjectTeamMate> addEmployeeToTeam(@RequestBody ProjectTeamMate employeeRoles) throws MyTimeException {
ProjectTeamMate project = projectService.addProject(employeeRoles);
return new ResponseEntity<>(project, HttpStatus.OK);
}
@RequestMapping(value = "/getProjects", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Project>> getProjects(@RequestParam("employeeId") String employeeId) throws MyTimeException {
List<Project> projects = projectService.getProjects(employeeId);
return new ResponseEntity<>(projects, HttpStatus.OK);
}
@RequestMapping(value = "/getMyTeamDetails", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ProjectTeamMate>> getMyTeamDetails(@RequestParam("employeeId") String employeeId) throws MyTimeException {
List<ProjectTeamMate> employeesRoles = projectService.getMyTeamDetails(employeeId);
//projectService.get
/*List<EmployeeRoles> managers=new ArrayList<>();
for(EmployeeRoles emp:employeesRoles) {
if(emp.getRole().equalsIgnoreCase("Manager")) {
managers.add(emp) ; }
}*/
//List<EmployeeRoles> managers = employeesRoles.stream().filter(e -> e.getRole().equalsIgnoreCase("Manager")).collect(Collectors.toList());
return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
}
}
\ No newline at end of file
package com.nisum.mytime.controller;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
......@@ -17,14 +18,14 @@ import com.nisum.mytime.model.EmployeeRoles;
import com.nisum.mytime.service.UserService;
@RestController
@RequestMapping("/employee")
@RequestMapping("/user")
public class UserController {
@Autowired
private UserService userService;
@RequestMapping(value = "employee/{emailId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> getEmployeeRole(@PathVariable("emailId") String emailId)
@RequestMapping(value = "/employee", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> getEmployeeRole(@RequestParam("emailId") String emailId)
throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeesRole(emailId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK);
......@@ -36,22 +37,41 @@ public class UserController {
return new ResponseEntity<>(result, HttpStatus.OK);
}
@RequestMapping(value = "/assigingEmployeeRole", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> assigingEmployeeRole(@RequestBody EmployeeRoles employeeRoles) throws MyTimeException {
@RequestMapping(value = "/assignEmployeeRole", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> assigingEmployeeRole(@RequestBody EmployeeRoles employeeRoles) throws MyTimeException {
EmployeeRoles employeeRole = userService.assigingEmployeeRole(employeeRoles);
return new ResponseEntity<>(employeeRole.getId(), HttpStatus.OK);
return new ResponseEntity<>(employeeRole, HttpStatus.OK);
}
@RequestMapping(value = "/updateEmployeeRole", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> updateEmployeeRole(@RequestBody EmployeeRoles employeeRoles) throws MyTimeException {
EmployeeRoles employeeRole = userService.updateEmployeeRole(employeeRoles);
return new ResponseEntity<>(employeeRole, HttpStatus.OK);
}
@RequestMapping(value = "/deleteEmployee", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<String> deleteEmployee(@RequestBody EmployeeRoles employeeRoles) throws MyTimeException {
userService.deleteEmployee(employeeRoles);
@RequestMapping(value = "/deleteEmployee", method = RequestMethod.DELETE, produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<String> deleteEmployee(@RequestParam("empId") String empId) throws MyTimeException {
userService.deleteEmployee(empId);
return new ResponseEntity<>("Success", HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeeRoles", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getEmployeeRoles() throws MyTimeException {
@RequestMapping(value = "/getUserRoles", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getUserRoles() throws MyTimeException {
List<EmployeeRoles> employeesRoles = userService.getEmployeeRoles();
return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> getEmployeeRoleData(@RequestParam("empId") String empId)
throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeesRoleData(empId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK);
}
@RequestMapping(value = "/getManagers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getManagers() throws MyTimeException {
List<EmployeeRoles> employeesRoles = userService.getEmployeeRoles();
List<EmployeeRoles> managers = employeesRoles.stream().filter(e -> e.getRole().equalsIgnoreCase("Manager")).collect(Collectors.toList());
return new ResponseEntity<>(managers, HttpStatus.OK);
}
}
\ No newline at end of file
package com.nisum.mytime.model;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class AttendenceData implements Serializable {
/**
*
*/
private static final long serialVersionUID = -7656364713943754178L;
private String employeeId;
private String employeeName;
private String ifPresent;
private int totalPresent;
private int totalAbsent;
}
package com.nisum.mytime.model;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Comparator;
import java.util.Date;
public class DateCompare implements Comparator<EmpLoginData> {
import com.nisum.mytime.utils.MyTimeLogger;
import com.nisum.mytime.utils.MyTimeUtils;
private static final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public class DateCompare implements Comparator<EmpLoginData> {
public int compare(EmpLoginData o1, EmpLoginData o2) {
Date first = null;
Date second = null;
try {
first = formatter.parse(o1.getFirstLogin());
second = formatter.parse(o2.getFirstLogin());
first = MyTimeUtils.df.parse(o1.getFirstLogin());
second = MyTimeUtils.df.parse(o2.getFirstLogin());
} catch (ParseException e) {
e.printStackTrace();
MyTimeLogger.getInstance().info(e.getMessage());
}
return first.before(second) ? -1 : first.after(second) ? 1 : 0;
......
......@@ -33,5 +33,6 @@ public class EmpLoginData implements Serializable {
private String lastLogout;
private String totalLoginTime;
private String direction;
private String totalAvgTime;
}
......@@ -2,8 +2,10 @@ package com.nisum.mytime.model;
import java.io.Serializable;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
......@@ -21,13 +23,14 @@ public class EmployeeRoles implements Serializable {
/**
*
*/
private static final long serialVersionUID = 2685951572250975416L;
private static final long serialVersionUID = 1L;
@Id
private String id;
private ObjectId id;
private String employeeId;
private String employeeName;
private String emailId;
private String role;
private String shift;
}
package com.nisum.mytime.model;
import java.io.Serializable;
import java.util.List;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "Projects")
public class Project implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private ObjectId id;
private String projectId;
private String projectName;
private String managerId;
private String managerName;
private List<String> employeeIds;
}
package com.nisum.mytime.model;
import java.io.Serializable;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document(collection = "ProjectTeamMate")
public class ProjectTeamMate implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private ObjectId id;
private String employeeId;
private String employeeName;
private String emailId;
private String role;
private String shift;
private String projectId;
private String projectName;
private String managerId;
private String managerName;
private String experience;
private String designation;
private String billableStatus;
private String mobileNumber;
}
package com.nisum.mytime.repository;
import java.io.Serializable;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.EmployeeRoles;
public interface EmployeeRolesRepo extends MongoRepository<EmployeeRoles, Serializable> {
public interface EmployeeRolesRepo extends MongoRepository<EmployeeRoles, String> {
EmployeeRoles findByEmailId(String emailId);
EmployeeRoles findByEmployeeId(String employeeId);
}
package com.nisum.mytime.repository;
import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.Project;
public interface ProjectRepo extends MongoRepository<Project, String> {
Project findByProjectId(String projectId);
List<Project> findByManagerId(String managerId);
}
\ No newline at end of file
package com.nisum.mytime.repository;
import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.EmployeeRoles;
import com.nisum.mytime.model.Project;
import com.nisum.mytime.model.ProjectTeamMate;
public interface ProjectTeamMatesRepo extends MongoRepository<ProjectTeamMate, String> {
List<ProjectTeamMate> findByProjectId(String projectId);
List<ProjectTeamMate> findByManagerId(String projectId);
List<ProjectTeamMate> findByEmployeeId(String employeeId);
}
package com.nisum.mytime.schedular;
import java.sql.SQLException;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.service.AttendanceDataService;
import com.nisum.mytime.service.EmployeeDataService;
import com.nisum.mytime.utils.MyTimeLogger;
@DisallowConcurrentExecution
public class MyTimeCronSchedularJob implements Job {
@Autowired
private AttendanceDataService attendanceDataService;
private EmployeeDataService employeeDataService;
@Override
public void execute(JobExecutionContext jobExecutionContext) {
try {
attendanceDataService.populateEmployeeAttendanceData();
} catch (MyTimeException e) {
MyTimeLogger.getInstance().info(e.getMessage());
if (employeeDataService.fetchEmployeesDataOnDayBasis()) {
MyTimeLogger.getInstance().info("Shedular Executed Successfully Records Saved in DB");
}
} catch (MyTimeException | SQLException e) {
MyTimeLogger.getInstance().error("Shedular failed to Executed ::: " + e.getMessage());
}
}
}
package com.nisum.mytime.service;
import java.sql.SQLException;
import java.util.List;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.AttendenceData;
public interface AttendanceService {
List<AttendenceData> getAttendanciesReport(String reportDate) throws MyTimeException, SQLException;
}
package com.nisum.mytime.service;
import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;
import com.mongodb.BasicDBObject;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.nisum.mytime.configuration.DbConnection;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.AttendenceData;
import com.nisum.mytime.utils.MyTimeLogger;
import com.nisum.mytime.utils.MyTimeUtils;
@Service
public class AttendanceServiceImpl implements AttendanceService {
@Value("${mytime.attendance.fileName}")
private String mdbFile;
@Value("${mytime.localFile.directory}")
private String localFileDirectory;
@Autowired
private MongoTemplate mongoTemplate;
private Connection connection = null;
private Statement statement = null;
private ResultSet resultSet = null;
private List<AttendenceData> listOfAbsentEmployees = null;
private StringBuilder queryMonthDecider = null;
private List<String> presentiesList = null;
private File finalfile = null;
private List<String> listOfPresentEmployees = new ArrayList<>();
private Calendar calendar = new GregorianCalendar();
private int month = (calendar.get(Calendar.MONTH)) + 1;
private int year = calendar.get(Calendar.YEAR);
private Date toDay = calendar.getTime();
@Override
public List<AttendenceData> getAttendanciesReport(String reportDate) throws MyTimeException {
long start_ms = System.currentTimeMillis();
try {
File dir = new File(localFileDirectory);
for (File file : dir.listFiles()) {
if (file.getCanonicalPath().contains(mdbFile)) {
finalfile = new File(file.getCanonicalPath());
}
}
if (null != finalfile) {
int dayOftoDay = calendar.get(Calendar.DAY_OF_MONTH);
Date selectedDate = MyTimeUtils.dfmt.parse(reportDate);
calendar.setTime(MyTimeUtils.dfmt.parse(reportDate));
int dayOfSelectedDate = calendar.get(Calendar.DAY_OF_MONTH);
if (dayOfSelectedDate == dayOftoDay) {
fecthRecordsFromMDb();
} else if (selectedDate.before(toDay)) {
calendar.setTime(selectedDate);
fecthRecordsFromMongoDb(reportDate);
}
MyTimeLogger.getInstance().info("Time Taken for " + (System.currentTimeMillis() - start_ms));
}
} catch (Exception e) {
MyTimeLogger.getInstance().error(e.getMessage());
throw new MyTimeException(e.getMessage());
}
return listOfAbsentEmployees;
}
private void createDbStatementWithFile() throws MyTimeException {
try {
queryMonthDecider = new StringBuilder();
String dbURL = MyTimeUtils.driverUrl + finalfile.getCanonicalPath();
MyTimeLogger.getInstance().info(dbURL);
connection = DbConnection.getDBConnection(dbURL);
statement = connection.createStatement();
Calendar calendar1 = Calendar.getInstance();
calendar1.set(year, (month - 1), calendar.get(Calendar.DAY_OF_MONTH), 6, 00, 00);
Date dayStartsTime = calendar1.getTime();
Date maxTimeToLogin = DateUtils.addHours(dayStartsTime, 12);
queryMonthDecider.append(MyTimeUtils.USERID_QUERY);
queryMonthDecider.append(month);
queryMonthDecider.append(MyTimeUtils.UNDER_SCORE);
queryMonthDecider.append(year);
queryMonthDecider.append(MyTimeUtils.WHERE_COND);
queryMonthDecider.append(MyTimeUtils.df.format(dayStartsTime) + MyTimeUtils.SINGLE_QUOTE);
queryMonthDecider.append(MyTimeUtils.AND_COND);
queryMonthDecider.append(MyTimeUtils.df.format(maxTimeToLogin) + MyTimeUtils.SINGLE_QUOTE);
MyTimeLogger.getInstance().info(queryMonthDecider.toString());
} catch (Exception e) {
MyTimeLogger.getInstance().error(e.getMessage());
throw new MyTimeException(e.getMessage());
}
}
private void fecthRecordsFromMDb() throws MyTimeException, SQLException {
presentiesList=new ArrayList<>();
try {
createDbStatementWithFile();
resultSet = statement.executeQuery(queryMonthDecider.toString());
while (resultSet.next()) {
if (resultSet.getString(1).length() >= 5) {
listOfPresentEmployees.add(resultSet.getString(1));
}
}
presentiesList = listOfPresentEmployees.stream().distinct().collect(Collectors.toList());
fetchAbsenteesListFromDb();
} catch (Exception e) {
MyTimeLogger.getInstance().error(e.getMessage());
throw new MyTimeException(e.getMessage());
} finally {
if (null != connection) {
connection.close();
statement.close();
resultSet.close();
}
}
}
private void fecthRecordsFromMongoDb(String reportDate) throws MyTimeException {
DBCursor cursor = null;
presentiesList=new ArrayList<>();
createDbStatementWithFile();
BasicDBObject gtQuery = new BasicDBObject();
gtQuery.put(MyTimeUtils.DATE_OF_LOGIN, reportDate);
cursor = mongoTemplate.getCollection(MyTimeUtils.EMPLOYEE_COLLECTION).find(gtQuery)
.sort(new BasicDBObject(MyTimeUtils.EMPLOYEE_ID, 1));
while (cursor.hasNext()) {
DBObject dbObject = cursor.next();
listOfPresentEmployees.add(dbObject.get(MyTimeUtils.EMPLOYEE_ID).toString());
}
presentiesList = listOfPresentEmployees.stream().distinct().collect(Collectors.toList());
fetchAbsenteesListFromDb();
}
private void fetchAbsenteesListFromDb() throws MyTimeException {
try {
listOfAbsentEmployees = new ArrayList<>();
StringBuilder absentiesQuery = new StringBuilder();
absentiesQuery.append(MyTimeUtils.ABESENT_QUERY);
absentiesQuery.append(queryMonthDecider.toString());
absentiesQuery.append(MyTimeUtils.ABESENT_QUERY1);
MyTimeLogger.getInstance().info(absentiesQuery.toString());
resultSet = statement.executeQuery(absentiesQuery.toString());
while (resultSet.next()) {
if (resultSet.getString(3).length() >= 5) {
AttendenceData attendenceData = new AttendenceData();
attendenceData.setEmployeeName(resultSet.getString(2));
attendenceData.setEmployeeId(resultSet.getString(3));
attendenceData.setIfPresent(MyTimeUtils.ABESENT);
listOfAbsentEmployees.add(attendenceData);
}
}
listOfAbsentEmployees.get(0).setTotalPresent(presentiesList.size());
listOfAbsentEmployees.get(0).setTotalAbsent(listOfAbsentEmployees.size());
} catch (Exception e) {
MyTimeLogger.getInstance().error(e.getMessage());
throw new MyTimeException(e.getMessage());
}
}
}
......@@ -13,7 +13,6 @@ import javax.mail.internet.MimeMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.mail.javamail.JavaMailSender;
......@@ -37,9 +36,6 @@ public class MailServiceImpl implements MailService {
@Autowired
ResourceLoader resourceLoader;
@Value("${spring.mail.username}")
private String fromEmail;
@Override
public String sendEmailWithAttachment(EmailDomain emailObj) {
String response = "Success";
......@@ -48,12 +44,23 @@ public class MailServiceImpl implements MailService {
MimeMessageHelper helper = new MimeMessageHelper(msg, true);
helper.setTo(emailObj.getToEmail());
helper.setCc(emailObj.getCcEmail());
helper.setFrom(fromEmail);
helper.setSubject(emailObj.getEmpId() + " - Login hours Report");
helper.setText("Hi,\n PFA for your login hours report for the period: " + emailObj.getFromDate() + " / "
+ emailObj.getToDate());
String fileName = emailObj.getEmpId() + "_" + emailObj.getFromDate() + "_" + emailObj.getToDate()+".pdf";
File file = resourceLoader.getResource("/reports/" + fileName).getFile();
String fromDate = emailObj.getFromDate();
String toDate = emailObj.getToDate();
String subject = "";
String mailContent = "";
String empId = emailObj.getEmpId();
if("".equals(empId)){
empId = "0";
subject = "All employees - Login hours Report for the period: "+fromDate+" to "+toDate;
mailContent = "Hi,\n PFA for All employees login hours report for the period: " + fromDate + " to "+ toDate;
}else{
subject = empId+ " - Login hours Report for the period: "+fromDate+" to "+toDate;
mailContent = "Hi,\n PFA for Employee ID: "+empId+" login hours report for the period: " + fromDate + " to "+ toDate;
}
helper.setSubject(subject);
helper.setText(mailContent);
String fileName = empId + "_" + fromDate + "_" + toDate+".pdf";
File file = resourceLoader.getResource("/WEB-INF/reports/" + fileName).getFile();
FileSystemResource fileSystem = new FileSystemResource(file);
helper.addAttachment(fileSystem.getFilename(), fileSystem);
helper.setSentDate(new Date());
......@@ -72,8 +79,8 @@ public class MailServiceImpl implements MailService {
public String deletePdfReport(String fileName) {
String response = "";
try {
File file = resourceLoader.getResource("/reports/" + fileName+".pdf").getFile();
if(file.exists()){
File file = resourceLoader.getResource("/WEB-INF/reports/" + fileName+".pdf").getFile();
if(null != file && file.exists()){
boolean status = file.delete();
if(status){
response = "Success";
......
package com.nisum.mytime.service;
import java.util.List;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.model.EmployeeRoles;
import com.nisum.mytime.model.Project;
import com.nisum.mytime.model.ProjectTeamMate;
public interface ProjectService {
Boolean fetchEmployeesData() throws MyTimeException;
List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate, String toDate) throws MyTimeException;
List<Project> getProjects() throws MyTimeException;
Project addProject(Project project) throws MyTimeException;
String generatePdfReport(long id, String fromDate, String toDate) throws MyTimeException;
EmployeeRoles getEmployeesRole(String emailId);
void deleteProject(String projectId);
Project updateProject(Project project);
EmployeeRoles getEmployeesRoleData(String empId);
List<ProjectTeamMate> getTeamDetails(String empId);
ProjectTeamMate addProject(ProjectTeamMate project) throws MyTimeException;
List<Project> getProjects(String managerId) throws MyTimeException;
List<ProjectTeamMate> getMyTeamDetails(String empId);
}
package com.nisum.mytime.service;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.FindAndModifyOptions;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.model.EmployeeRoles;
import com.nisum.mytime.model.Project;
import com.nisum.mytime.model.ProjectTeamMate;
import com.nisum.mytime.repository.EmployeeAttendanceRepo;
import com.nisum.mytime.repository.EmployeeRolesRepo;
import com.nisum.mytime.repository.ProjectRepo;
import com.nisum.mytime.repository.ProjectTeamMatesRepo;
import com.nisum.mytime.utils.PdfReportGenerator;
@Service("projectService")
public class ProjectServiceImpl implements ProjectService {
@Autowired
private EmployeeAttendanceRepo employeeLoginsRepo;
@Autowired
private EmployeeRolesRepo employeeRolesRepo;
@Autowired
private ProjectRepo projectRepo;
@Autowired
private ProjectTeamMatesRepo projectTeamMatesRepo;
@Autowired
private EmployeeDataService employeeDataBaseService;
@Autowired
private PdfReportGenerator pdfReportGenerator;
@Autowired
private MongoTemplate mongoTemplate;
@Override
public Boolean fetchEmployeesData() throws MyTimeException {
Boolean result = false;
List<EmpLoginData> listOfEmpLoginData = employeeDataBaseService
.fetchEmployeesData();
employeeLoginsRepo.save(listOfEmpLoginData);
result = true;
return result;
}
@Override
public List<EmpLoginData> employeeLoginsBasedOnDate(long id,
String fromDate, String toDate) throws MyTimeException {
return employeeDataBaseService.fetchEmployeeLoginsBasedOnDates(id,
fromDate, toDate);
}
@Override
public String generatePdfReport(long id, String fromDate, String toDate)
throws MyTimeException {
return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate);
}
@Override
public List<Project> getProjects() throws MyTimeException {
return projectRepo.findAll();
}
@Override
public Project addProject(Project project) throws MyTimeException {
return projectRepo.save(project);
}
@Override
public EmployeeRoles getEmployeesRole(String emailId) {
return employeeRolesRepo.findByEmailId(emailId);
}
@Override
public void deleteProject(String projectId) {
Project project = projectRepo.findByProjectId(projectId);
projectRepo.delete(project);
}
@Override
public Project updateProject(Project project) {
Query query = new Query(
Criteria.where("projectId").is(project.getProjectId()));
Update update = new Update();
update.set("managerId", project.getManagerId());
update.set("managerName", project.getManagerName());
FindAndModifyOptions options = new FindAndModifyOptions();
options.returnNew(true);
options.upsert(true);
return mongoTemplate.findAndModify(query, update, options,
Project.class);
}
@Override
public EmployeeRoles getEmployeesRoleData(String employeeId) {
return employeeRolesRepo.findByEmployeeId(employeeId);
}
@Override
public List<ProjectTeamMate> getTeamDetails(String empId) {
return projectTeamMatesRepo.findByManagerId(empId);
}
@Override
public ProjectTeamMate addProject(ProjectTeamMate project)
throws MyTimeException {
return projectTeamMatesRepo.save(project);
}
@Override
public List<Project> getProjects(String managerId) throws MyTimeException {
return projectRepo.findByManagerId(managerId);
}
@Override
public List<ProjectTeamMate> getMyTeamDetails(String empId) {
System.out.println("empId"+empId);
// TODO Auto-generated method stub
List<ProjectTeamMate> teamMates=new ArrayList<>();
List<ProjectTeamMate> empRecords= projectTeamMatesRepo.findByEmployeeId(empId);
System.out.println("empRecords"+empRecords);
for(ProjectTeamMate pt:empRecords) {
System.out.println("pt.getProjectId()"+pt.getProjectId());
teamMates.addAll(projectTeamMatesRepo.findByProjectId(pt.getProjectId()));
}
return teamMates;
}
}
......@@ -8,8 +8,6 @@ import com.nisum.mytime.model.EmployeeRoles;
public interface UserService {
List<EmpLoginData> fetchEmployeeDataBasedOnEmpId(long id) throws MyTimeException;
Boolean fetchEmployeesData() throws MyTimeException;
List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate, String toDate) throws MyTimeException;
......@@ -17,11 +15,14 @@ public interface UserService {
List<EmployeeRoles> getEmployeeRoles() throws MyTimeException;
EmployeeRoles assigingEmployeeRole(EmployeeRoles employeeRoles) throws MyTimeException;
String generatePdfReport(long id, String fromDate, String toDate) throws MyTimeException;
EmployeeRoles getEmployeesRole(String emailId);
void deleteEmployee(EmployeeRoles employeeRoles);
void deleteEmployee(String empId);
EmployeeRoles updateEmployeeRole(EmployeeRoles employeeRoles);
EmployeeRoles getEmployeesRoleData(String empId);
}
......@@ -3,6 +3,11 @@ package com.nisum.mytime.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.FindAndModifyOptions;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import com.nisum.mytime.exception.handler.MyTimeException;
......@@ -27,10 +32,9 @@ public class UserServiceImpl implements UserService {
@Autowired
private PdfReportGenerator pdfReportGenerator;
@Override
public List<EmpLoginData> fetchEmployeeDataBasedOnEmpId(long id) throws MyTimeException {
return employeeDataBaseService.fetchEmployeeDataBasedOnEmpId(id);
}
@Autowired
private MongoTemplate mongoTemplate;
@Override
public Boolean fetchEmployeesData() throws MyTimeException {
......@@ -69,8 +73,28 @@ public class UserServiceImpl implements UserService {
}
@Override
public void deleteEmployee(EmployeeRoles employeeRoles) {
employeeRolesRepo.delete(employeeRoles);
public void deleteEmployee(String employeeId) {
EmployeeRoles role = employeeRolesRepo.findByEmployeeId(employeeId);
employeeRolesRepo.delete(role);
}
@Override
public EmployeeRoles updateEmployeeRole(EmployeeRoles employeeRoles) {
Query query = new Query(Criteria.where("employeeId").is(employeeRoles.getEmployeeId()));
Update update = new Update();
update.set("employeeName", employeeRoles.getEmployeeName());
update.set("emailId", employeeRoles.getEmailId());
update.set("role", employeeRoles.getRole());
update.set("shift", employeeRoles.getShift());
FindAndModifyOptions options = new FindAndModifyOptions();
options.returnNew(true);
options.upsert(true);
return mongoTemplate.findAndModify(query, update, options, EmployeeRoles.class);
}
@Override
public EmployeeRoles getEmployeesRoleData(String employeeId) {
return employeeRolesRepo.findByEmployeeId(employeeId);
}
}
......@@ -13,4 +13,28 @@ public class MyTimeUtils {
public final static DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public final static DateFormat tdf = new SimpleDateFormat("HH:mm");
public final static DateFormat dfmt = new SimpleDateFormat("yyyy-MM-dd");
public final static String UNDER_SCORE = "_";
public final static String DATE_OF_LOGIN = "dateOfLogin";
public final static String EMPLOYEE_ID = "employeeId";
public final static String EMPLOYEE_NAME = "employeeName";
public final static String FIRST_LOGIN = "firstLogin";
public final static String LAST_LOGOUT = "lastLogout";
public final static String TOTAL_LOGIN_TIME = "totalLoginTime";
public final static String EMPLOYEE_COLLECTION = "EmployeesLoginData";
public final static String ID = "_id";
public final static String HYPHEN = "-";
public final static String ZERO = "0";
public final static String COLON = ":";
public final static String EMP_NAME_QUERY = "SELECT * FROM EMPLOYEES Where EMPLOYEECODE=?";
public final static String WORKING_EMPLOYEES = "SELECT * FROM EMPLOYEES WHERE EMPLOYEECODE NOT IN(SELECT UserId FROM DeviceLogs_12_2017 WHERE LogDate BETWEEN '2017-12-27 06:00:00' AND '2017-12-27 11:00:00') AND STATUS='Working'";
public final static String QUERY = "SELECT * FROM DeviceLogs_";
public final static String USERID_QUERY = "SELECT USERID FROM DeviceLogs_";
public final static String WHERE_COND = " WHERE LogDate between '";
public final static String AND_COND = " AND '";
public final static String SINGLE_QUOTE = "'";
public final static String ABESENT_QUERY = "SELECT * FROM EMPLOYEES WHERE EMPLOYEECODE NOT IN(";
public final static String ABESENT_QUERY1 = ") AND STATUS='Working' AND EMPLOYEECODE NOT LIKE 'del%' ";
public final static String ABESENT ="Absent";
}
......@@ -35,11 +35,13 @@ public class PdfReportGenerator {
private EmployeeDataService employeeDataBaseService;
public String generateEmployeeReport(long employeeId, String startDate, String endDate) throws MyTimeException {
String fileName = employeeId + "_" + startDate + "_" + endDate + ".pdf";
List<EmpLoginData> empLoginDetails = getEmployeeData(employeeId, startDate, endDate);
return createPDF(fileName, empLoginDetails);
if (empLoginDetails.isEmpty()) {
return "No data available";
} else {
return createPDF(fileName, empLoginDetails, employeeId);
}
}
private List<EmpLoginData> getEmployeeData(long employeeId, String fromDate, String toDate) throws MyTimeException {
......@@ -47,15 +49,16 @@ public class PdfReportGenerator {
return employeeDataBaseService.fetchEmployeeLoginsBasedOnDates(employeeId, fromDate, toDate);
}
private String createPDF(String pdfFilename, List<EmpLoginData> empLoginDatas) throws MyTimeException {
private String createPDF(String pdfFilename, List<EmpLoginData> empLoginDatas, long employeeId)
throws MyTimeException {
Document doc = new Document();
PdfWriter docWriter = null;
try {
File file = resourceLoader.getResource("/reports/" + pdfFilename).getFile();
File file = resourceLoader.getResource("/WEB-INF/reports/" + pdfFilename).getFile();
docWriter = PdfWriter.getInstance(doc, new FileOutputStream(file.getPath()));
setPdfDocumentProperties(doc);
doc.open();
preparePdfDocument(doc, empLoginDatas);
preparePdfDocument(doc, empLoginDatas, employeeId);
} catch (Exception dex) {
MyTimeLogger.getInstance()
.error("DocumentException while generating {} " + pdfFilename + "\n" + dex.getMessage());
......@@ -80,27 +83,34 @@ public class PdfReportGenerator {
doc.setPageSize(PageSize.A4);
}
private void preparePdfDocument(Document doc, List<EmpLoginData> empLoginDatas) throws DocumentException {
private void preparePdfDocument(Document doc, List<EmpLoginData> empLoginDatas, long employeeId) throws DocumentException {
boolean isFirst = true;
Paragraph paragraph = new Paragraph();
Paragraph paragraph1 = new Paragraph();
float[] columnWidths = { 1f, 1f, 1f, 1f };
PdfPTable table = new PdfPTable(columnWidths);
table.setWidthPercentage(100f);
prepareTableHeader(table);
float[] columnWidths = null;
PdfPTable table = null;
if(employeeId == 0){
columnWidths = new float[]{ 1f, 1f, 1f, 1f, 1f, 1f };
table = new PdfPTable(columnWidths);
table.setWidthPercentage(100f);
prepareTableHeader(table, "All");
}else{
columnWidths = new float[]{ 1f, 1f, 1f, 1f};
table = new PdfPTable(columnWidths);
table.setWidthPercentage(100f);
prepareTableHeader(table, "Single");
}
for (EmpLoginData data : empLoginDatas) {
if (isFirst) {
if (isFirst && employeeId != 0) {
Anchor anchorTarget = new Anchor(
"Employee Id : " + data.getEmployeeId() + "\nEmployee Name : " + data.getEmployeeName());
isFirst = false;
paragraph1.add(anchorTarget);
}
prepareTableRow(table, data);
if(employeeId == 0) prepareTableRow(table, data, "All");
else prepareTableRow(table, data, "Single");
}
paragraph.add(table);
......@@ -109,9 +119,13 @@ public class PdfReportGenerator {
doc.add(paragraph);
}
private void prepareTableHeader(PdfPTable table) {
private void prepareTableHeader(PdfPTable table, String tableFor) {
Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0));
if ("All".equals(tableFor)) {
insertCell(table, "ID ", Element.ALIGN_CENTER, 1, bfBold12);
insertCell(table, "Name ", Element.ALIGN_CENTER, 1, bfBold12);
}
insertCell(table, "Date ", Element.ALIGN_CENTER, 1, bfBold12);
insertCell(table, "Login Time", Element.ALIGN_CENTER, 1, bfBold12);
insertCell(table, "Logout Time", Element.ALIGN_CENTER, 1, bfBold12);
......@@ -120,12 +134,16 @@ public class PdfReportGenerator {
}
private void prepareTableRow(PdfPTable table, EmpLoginData data) {
private void prepareTableRow(PdfPTable table, EmpLoginData data, String tableFor) {
Font bf12 = new Font(FontFamily.TIMES_ROMAN, 12);
insertCell(table, data.getDateOfLogin(), Element.ALIGN_CENTER, 1, bf12);
insertCell(table, data.getFirstLogin(), Element.ALIGN_CENTER, 1, bf12);
insertCell(table, data.getLastLogout(), Element.ALIGN_CENTER, 1, bf12);
insertCell(table, data.getTotalLoginTime(), Element.ALIGN_CENTER, 1, bf12);
if ("All".equals(tableFor)) {
insertCell(table, (data.getEmployeeId() == null? "" : data.getEmployeeId()), Element.ALIGN_CENTER, 1, bf12);
insertCell(table, (data.getEmployeeName() == null? "" : data.getEmployeeName()), Element.ALIGN_CENTER, 1, bf12);
}
insertCell(table, (data.getDateOfLogin() == null? "" : data.getDateOfLogin()), Element.ALIGN_CENTER, 1, bf12);
insertCell(table, (data.getFirstLogin() == null? "" : data.getFirstLogin()), Element.ALIGN_CENTER, 1, bf12);
insertCell(table, (data.getLastLogout() == null? "" : data.getLastLogout()), Element.ALIGN_CENTER, 1, bf12);
insertCell(table, (data.getTotalLoginTime() == null? "" : data.getTotalLoginTime()), Element.ALIGN_CENTER, 1, bf12);
}
private void insertCell(PdfPTable table, String text, int align, int colspan, Font font) {
......
server.port=8080
server.context-path=/my-time/
#Mongo DB configuration
spring.data.mongodb.host=localhost
spring.data.mongodb.host=192.168.15.17
spring.data.mongodb.port=27017
spring.data.mongodb.database=mytime
spring.data.mongodb.database=mytimedb
spring.data.mongodb.username=mytime
spring.data.mongodb.password=nisum@123
quartz.enabled=false
cron.expression=0 0/1 * 1/1 * ? *
#Local configuration
#spring.data.mongodb.host=localhost
#spring.data.mongodb.port=27017
#spring.data.mongodb.database=mytime
quartz.enabled=true
cron.expression=0 50 10/10 1/1 * ? *
myTimejob.frequency=10000
mytime.remoteFileTransfer.required=false
mytime.remote.connection=smb://MyTime:nisum@192.168.15.67/eTimeTrackLite/
mytime.localFile.directory=/Users/nisum/Documents/
mytime.remote.directory=/C:\\Program Files (x86)\\eSSL\\eTimeTrackLite
mytime.remoteFileTransfer.required=true
mytime.remote.directory=\\\C:\\Program Files (x86)\\eSSL\\eTimeTrackLite
mytime.attendance.fileName=eTimeTrackLite1.mdb
#Local configuration purpose
mytime.remote.connection=smb://MyTime:nisum@192.168.15.67/eTimeTrackLite/
mytime.localFile.directory=/home/nisum/Documents/
#Mail configuration
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=<no-reply@nisum.com>
spring.mail.password=<password>
spring.mail.username=mytime.nisum@gmail.com
spring.mail.password=nisum@123
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
,--. ,--. ,--. ,--. ,--------. ,--. ,--. ,--. ,------.
| `.' | \ `.' / '--. .--' | | | `.' | | .---'
| |'.'| | '. / | | | | | |'.'| | | `--,
| | | | | | | | | | | | | | | `---.
`--' `--' `--' `--' `--' `--' `--' `------'
\ No newline at end of file
This diff is collapsed.
myApp.controller("headerController",function($scope, myFactory, $compile, $mdDialog, $timeout){
$scope.empId = myFactory.getEmpId();
$scope.empName = myFactory.getEmpName();
$scope.empEmailId = myFactory.getEmpEmailId();
$scope.profilePicUrl = myFactory.getProfileUrl();
$scope.logout = function() {
showProgressDialog();
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function () {
console.log("User signed out.");
});
auth2.disconnect();
//Clear if any values set to factory
var menuItems = [];
myFactory.setEmpId("");
myFactory.setEmpName("");
myFactory.setEmpEmailId("");
myFactory.setEmpRole("");
myFactory.setMenuItems(menuItems);
myFactory.setTemplateUrl("");
myFactory.setProfileUrl("");
$timeout(function(){redirectToLoginPage();},2000);
}
function redirectToLoginPage(){
var element = document.getElementById('home');
var path = "'templates/login.html'";
element.setAttribute("src", path);
var newTemplate = angular.element(element);
$('#home').html(newTemplate);
$compile($('#home'))($scope);
$mdDialog.hide();
}
function showProgressDialog(){
$mdDialog.show({
templateUrl: 'templates/progressDialog.html',
controller: ProgressController,
parent: angular.element(document.body),
clickOutsideToClose:false
});
}
function ProgressController($scope) {
$scope.progressText = "Please wait!!! Logging out from My Time.";
}
});
\ No newline at end of file
myApp.controller("leftmenuController",function($scope, myFactory, $compile){
$scope.empId = myFactory.getEmpId();
$scope.empName = myFactory.getEmpName();
$scope.empEmailId = myFactory.getEmpEmailId();
$scope.role = myFactory.getEmpRole();
$scope.menuItems = myFactory.getMenuItems();
$scope.setTemplateUrl = function(path){
var element = document.getElementById('main');
path = "'"+path+"'";
element.setAttribute("ng-include", path);
var newTemplate = angular.element(element);
$('#main').html(newTemplate);
$compile($('#main'))($scope)
}
});
\ No newline at end of file
myApp.controller("loginController",function($scope, myFactory, $compile, $window, $http, appConfig, $mdDialog, $timeout){
var menuItems = myFactory.getMenuItems();
$window.onSignIn = onSignIn;
$window.onFailure = onFailure;
$scope.rolesData = [];
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
console.log('Name: ' + profile.getName());
console.log('Email: ' + profile.getEmail());
console.log('Image URL: ' + profile.getImageUrl());
getUserRole(profile);
getAllUserRoles();
}
function onFailure(error){
if(error.type == "tokenFailed"){
showAlert('Please login with @Nisum account');
}
}
function showAlert(message) {
$mdDialog.show($mdDialog.alert().parent(
angular.element(document.querySelector('#popupContainer')))
.clickOutsideToClose(true).textContent(message).ariaLabel(
'Alert Dialog').ok('Ok'));
}
function getUserRole(profile){
$http({
method : "GET",
url : appConfig.appUri + "user/employee?emailId="+profile.getEmail()
}).then(function mySuccess(response) {
var result = response.data;
if(result == "" || result.length == 0){
showRegisterEmployeeScreen(profile);
}else{
showProgressDialog("Please wait!!! Redirecting to home page.");
$timeout(function(){setDefaultValues(result, profile.getImageUrl());},2000);
}
}, function myError(response) {
showProgressDialog("Something went wrong redirecting to login page!!!");
$timeout(function(){redirectToLoginPage();},2000);
});
}
function getAllUserRoles(){
$http({
method : "GET",
url : appConfig.appUri + "user/getUserRoles"
}).then(function mySuccess(response) {
$scope.rolesData = response.data;
}, function myError(response) {
$scope.rolesData = [];
});
};
function showRegisterEmployeeScreen(profile){
$mdDialog.show({
controller: NewEmployeeController,
templateUrl: 'templates/registerEmployee.html',
parent: angular.element(document.body),
clickOutsideToClose:false,
locals:{dataToPass: profile, rolesData:$scope.rolesData },
})
.then(function(result) {
if(result == "Cancelled"){ console.log(result);
showProgressDialog("Registration cancelled!!! Please wait while redirected to login page.");
$timeout(function(){redirectToLoginPage();},2000);
}else if(result == "Error"){
showProgressDialog("Registration failed!!! Please wait while redirected to login page.");
$timeout(function(){redirectToLoginPage();},2000);
}else{
showProgressDialog("Registered successfully!!! Please wait while redirected to home page.");
console.log("Result:: "+result.data);
$timeout(function(){setDefaultValues(result.data, profile.getImageUrl());},2000);
}
});
}
function NewEmployeeController($scope, $mdDialog, dataToPass, rolesData) {
$scope.alertMsg = "";
$scope.empId = "";
$scope.empName = dataToPass.getName();
$scope.empEmail = dataToPass.getEmail();
$scope.empShift;
$scope.shifts = ["Shift 1(09:00 AM - 06:00 PM)","Shift 2(03:30 PM - 12:30 PM)", "Shift 3(09:00 PM - 06:00 AM)"];
$scope.getSelectedShift = function(){
if ($scope.empShift !== undefined) {
return $scope.empShift;
} else {
return "Please select a shift";
}
};
$scope.validateEmpId = function(){
var searchId = $scope.empId;
if(searchId != "" && isNaN(searchId)){
$scope.alertMsg = "Please enter only digits";
document.getElementById('empId').focus();
}else if(searchId != "" && ((searchId.length >0 && searchId.length <5) || searchId.length>5)){
$scope.alertMsg = "Employee ID should be 5 digits";
document.getElementById('empId').focus();
}else if(searchId != "" && !checkEmpIdRange(searchId)){
$scope.alertMsg = 'Employee ID should be in between '+appConfig.empStartId+' - '+appConfig.empEndId;
document.getElementById('empId').focus();
}else if(searchId != "" && checkRoleExistence(searchId)){
$scope.alertMsg = 'Employee is already registered';
document.getElementById('empId').focus();
}else{
$scope.alertMsg = "";
}
};
function checkEmpIdRange(searchId){
return parseInt(searchId) >= appConfig.empStartId && parseInt(searchId) <= appConfig.empEndId;
}
function checkRoleExistence(searchId){
for(var i in rolesData){
if(rolesData[i].employeeId == searchId){
return true;
}
}
return false;
}
$scope.validateFields = function(){
var searchId = $scope.empId;
var empName = $scope.empName;
var empShift = $scope.empShift;
if(searchId == ""){
$scope.alertMsg = "Employee ID is mandatory";
document.getElementById('empId').focus();
}else if(searchId != "" && !checkEmpIdRange(searchId)){
$scope.alertMsg = 'Employee ID should be in between '+appConfig.empStartId+' - '+appConfig.empEndId;
document.getElementById('empId').focus();
}else if(searchId != "" && checkRoleExistence(searchId)){
$scope.alertMsg = 'Employee is already registered';
document.getElementById('empId').focus();
}else if(empName == ""){
$scope.alertMsg = "Employee Name is mandatory";
document.getElementById('empName').focus();
}else if(empShift == undefined){
$scope.alertMsg = "Please select a shift";
document.getElementById('empShift').focus();
}else{
$scope.alertMsg = "";
var record = {"employeeId":$scope.empId, "employeeName": $scope.empName, "emailId": $scope.empEmail, "role": "Employee", "shift": $scope.empShift};
addEmployee(record);
}
};
function addEmployee(record){
var urlRequest = appConfig.appUri+ "user/assignEmployeeRole";
var req = {
method : 'POST',
url : urlRequest,
headers : {
"Content-type" : "application/json"
},
data : record
}
$http(req).then(function mySuccess(response) {
$mdDialog.hide(response);
}, function myError(response){
$mdDialog.hide("Error");
});
}
$scope.cancel = function() {
$mdDialog.hide('Cancelled');
};
}
function setDefaultValues(userRole, profilePicUrl){
$mdDialog.hide();
menuItems = [];
//Setting default values to myFactory object so that we can use it anywhere in application
myFactory.setEmpId(userRole.employeeId);
myFactory.setEmpName(userRole.employeeName);
myFactory.setEmpEmailId(userRole.emailId);
var role = userRole.role;
myFactory.setEmpRole(role);
if(role == "HR"){
menuItems.push({"menu" : "My Details","icon" : "fa fa-indent fa-2x","path" : "templates/employee.html"});
menuItems.push({"menu" : "Employee Details","icon" : "fa fa-users fa-2x","path" : "templates/employees.html"});
menuItems.push({"menu" : "Reports","icon" : "fa fa-pie-chart fa-2x","path" : "templates/reports.html"});
menuItems.push({"menu" : "Manage Employees","icon" : "fa fa-user-plus fa-2x","path" : "templates/roles.html"});
menuItems.push({"menu" : "Manage Projects","icon" : "fa fa-tasks fa-2x","path" : "templates/projects.html"});
}else if(role == "Manager"){
menuItems.push({"menu" : "My Details","icon" : "fa fa-indent fa-2x","path" : "templates/employee.html"});
menuItems.push({"menu" : "Reportee Details","icon" : "fa fa-users fa-2x","path" : "templates/reportees.html"});
menuItems.push({"menu" : "Manage Team","icon" : "fa fa-sitemap fa-2x","path" : "templates/projectDetails.html"});
menuItems.push({"menu" : "My Team","icon" : "fa fa-futbol-o fa-2x","path" : "templates/myTeam.html"});
}else if(role == "Employee"){
menuItems.push({"menu" : "My Details","icon" : "fa fa-indent fa-2x","path" : "templates/employee.html"});
menuItems.push({"menu" : "My Team","icon" : "fa fa-futbol-o fa-2x","path" : "templates/myTeam.html"});
}
myFactory.setMenuItems(menuItems);
myFactory.setTemplateUrl("templates/employee.html");
myFactory.setProfileUrl(profilePicUrl);
//Redirecting to home page after logging in successfully
var element = document.getElementById('home');
var path = "'templates/home.html'";
element.setAttribute("src", path);
var newTemplate = angular.element(element);
$('#home').html(newTemplate);
$compile($('#home'))($scope)
}
function redirectToLoginPage(){
$mdDialog.hide();
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function () {
console.log('User signed out.');
});
auth2.disconnect();
//Clear if any values set to factory
var menuItems = [];
myFactory.setEmpId("");
myFactory.setEmpName("");
myFactory.setEmpEmailId("");
myFactory.setEmpRole("");
myFactory.setMenuItems(menuItems);
myFactory.setTemplateUrl("");
myFactory.setProfileUrl("");
var element = document.getElementById('home');
var path = "'templates/login.html'";
element.setAttribute("src", path);
var newTemplate = angular.element(element);
$('#home').html(newTemplate);
$compile($('#home'))($scope)
}
function showProgressDialog(msg){
$mdDialog.show({
templateUrl: 'templates/progressDialog.html',
controller: ProgressController,
parent: angular.element(document.body),
clickOutsideToClose:false,
locals: {dataToPass:msg}
});
}
function ProgressController($scope, dataToPass) {
$scope.progressText = dataToPass;
}
});
\ No newline at end of file
myApp.controller("reporteesController", function($scope, $http, myFactory, $mdDialog, appConfig) {
$scope.records = [];
$scope.empId = myFactory.getEmpId();
$scope.empName = myFactory.getEmpName();
$scope.empEmailId = myFactory.getEmpEmailId();
$scope.role = myFactory.getEmpRole();
$scope.avgLoginHrs = "";
$scope.isVisible = false;
$scope.reportees = [];
$scope.reporteeDetail;
// Date picker related code
var today = new Date();
var priorDt = new Date(today.getTime() - (30 * 24 * 60 * 60 * 1000));
$scope.maxDate = today;
$scope.fromDate = priorDt;
$scope.toDate = today;
$scope.gridOptions = {
paginationPageSizes : [ 10, 20, 30, 40, 50, 100],
paginationPageSize : 10,
pageNumber: 1,
pageSize:10,
columnDefs : [
{field : 'employeeId',displayName: 'Employee ID', enableColumnMenu: true, enableSorting: true},
{field : 'employeeName',displayName: 'Name', enableColumnMenu: false, enableSorting: false},
{field : 'dateOfLogin',displayName: 'Date', enableColumnMenu: true, enableSorting: true},
{field : 'firstLogin',displayName: 'Login Time', enableColumnMenu: false,enableSorting: false},
{field : 'lastLogout',displayName: 'Logout Time', enableColumnMenu: false, enableSorting: false},
{field : 'totalLoginTime',displayName: 'Total Hours(HH:MM)', enableColumnMenu: false, enableSorting: false}
]
};
$scope.gridOptions.data = [];
$scope.refreshPage = function(){
$scope.reporteeDetail = undefined;
$scope.fromDate = priorDt;
$scope.toDate = today;
$scope.gridOptions.data = [];
};
$scope.getReporteesDetails = function(){
$http({
method : "GET",
url : appConfig.appUri + "projectTeam/getTeamDetails?employeeId=" + $scope.empId
}).then(function mySuccess(response) {
$scope.reportees = response.data;
}, function myError(response) {
$scope.reportees = [];
});
};
$scope.getSelectedReportee = function(){
if ($scope.reporteeDetail !== undefined) {
return $scope.reporteeDetail.employeeName;
} else {
return "Select an Employee ID";
}
};
$scope.getEmployeeData = function(type){
var searchId = $scope.reporteeDetail;
var fromDate = getFormattedDate($scope.fromDate);
var toDate = getFormattedDate($scope.toDate);
if(searchId == undefined){
showAlert('Please select an Employee ID');
document.getElementById('reporteeDetail').focus();
}else{
getData(searchId.employeeId, fromDate, toDate);
}
}
function getData(empId, fromDate, toDate){
$http({
method : "GET",
url : appConfig.appUri + "attendance/employeeLoginsBasedOnDate?empId=" + empId + "&fromDate=" + fromDate + "&toDate=" +toDate
}).then(function mySuccess(response) {
var recs = response.data;
if(recs.length == 0){
showAlert('No data available');
setFieldsEmpty();
}else{
$scope.gridOptions.data = response.data;
}
}, function myError(response) {
showAlert("Something went wrong while fetching data!!!");
$scope.gridOptions.data = [];
});
}
$scope.validateDates = function(dateValue, from) {
if(from == "FromDate"){
var toDt = $scope.toDate;
var diff = daysBetween(dateValue, toDt);
if(diff < 30 ){
showAlert('Date range should have minimum of 30 days difference');
$scope.fromDate = priorDt;
$scope.toDate = today;
setFieldsEmpty();
}else{
$scope.fromDate = dateValue;
$scope.toDate = getCalculatedDate(dateValue, 'Add');
}
}else if(from == "ToDate"){
$scope.toDate = dateValue;
$scope.fromDate = getCalculatedDate(dateValue, 'Substract');
}
};
function showAlert(message) {
$mdDialog.show($mdDialog.alert().parent(
angular.element(document.querySelector('#popupContainer')))
.clickOutsideToClose(true).textContent(message).ariaLabel(
'Alert Dialog').ok('Ok'));
}
function getFormattedDate(date){
var day = date.getDate();
var month = date.getMonth() + 1;
var year = date.getFullYear();
return year + '-' + (month < 10 ? "0" + month : month) + '-'
+ (day < 10 ? "0" + day : day);
}
function setFieldsEmpty(){
$scope.reporteeDetail = undefined;
$scope.fromDate = priorDt;
$scope.toDate = today;
$scope.gridOptions.data = [];
}
function treatAsUTC(date) {
var result = new Date(date);
result.setMinutes(result.getMinutes() - result.getTimezoneOffset());
return result;
}
function daysBetween(fromDate, toDate) {
var millisecondsPerDay = 24 * 60 * 60 * 1000;
return Math.round((treatAsUTC(toDate) - treatAsUTC(fromDate)) / millisecondsPerDay);
}
function getCalculatedDate(selectedDate, type){
var futureDt = null;
if(type == "Add"){
futureDt = new Date(selectedDate.getTime() + (30 * 24 * 60 * 60 * 1000));
}else {
futureDt = new Date(selectedDate.getTime() - (30 * 24 * 60 * 60 * 1000));
}
return futureDt;
}
});
myApp.controller("employeeController", function($scope, $http, myFactory, $mdDialog, appConfig) {
$scope.records = [];
$scope.empId = myFactory.getEmpId();
$scope.empName = myFactory.getEmpName();
$scope.empEmailId = myFactory.getEmpEmailId();
$scope.avgLoginHrs = "";
// Date picker related code
var today = new Date();
var priorDt = new Date(today.getTime() - (30 * 24 * 60 * 60 * 1000));
$scope.maxDate = today;
$scope.fromDate = priorDt;
$scope.toDate = today;
$scope.gridOptions = {
paginationPageSizes : [ 10, 20, 30, 40, 50, 100],
paginationPageSize : 10,
pageNumber: 1,
pageSize:10,
columnDefs : [
{field : 'dateOfLogin',displayName: 'Date', enableColumnMenu: true, enableSorting: true},
{field : 'firstLogin',displayName: 'Login Time', enableColumnMenu: false, enableSorting: false},
{field : 'lastLogout',displayName: 'Logout Time', enableColumnMenu: false, enableSorting: false},
{field : 'totalLoginTime',displayName: 'Total Hours(HH:MM)', enableColumnMenu: false, enableSorting: false}
]
};
$scope.gridOptions.data = [];
$scope.getEmployeeData = function(){
var fromDate = getFormattedDate($scope.fromDate);
var toDate = getFormattedDate($scope.toDate);
var empId = $scope.empId;
$http({
method : "GET",
url : appConfig.appUri + "attendance/employeeLoginsBasedOnDate?empId=" + empId + "&fromDate=" + fromDate + "&toDate=" +toDate
}).then(function mySuccess(response) {
$scope.gridOptions.data = response.data;
$scope.avgLoginHrs = response.data[0].totalAvgTime + " Hrs";
}, function myError(response) {
showAlert("Something went wrong while fetching data!!!");
$scope.gridOptions.data = [];
});
}
$scope.refreshPage = function(){
$scope.fromDate = priorDt;
$scope.toDate = today;
$scope.getEmployeeData();
};
function getFormattedDate(date){
var day = date.getDate();
var month = date.getMonth() + 1;
var year = date.getFullYear();
return year + '-' + (month < 10 ? "0" + month : month) + '-'
+ (day < 10 ? "0" + day : day);
}
$scope.validateDates = function(dateValue, from) {
if(from == "FromDate"){
var toDt = $scope.toDate;
var diff = daysBetween(dateValue, toDt);
if(diff < 30 ){
showAlert('Date range should have minimum of 30 days difference');
$scope.fromDate = priorDt;
$scope.toDate = today;
}else{
$scope.fromDate = dateValue;
$scope.toDate = getCalculatedDate(dateValue, 'Add');
}
}else if(from == "ToDate"){
$scope.toDate = dateValue;
$scope.fromDate = getCalculatedDate(dateValue, 'Substract');
}
};
function getCalculatedDate(selectedDate, type){
var futureDt = null;
if(type == "Add"){
futureDt = new Date(selectedDate.getTime() + (30 * 24 * 60 * 60 * 1000));
}else {
futureDt = new Date(selectedDate.getTime() - (30 * 24 * 60 * 60 * 1000));
}
return futureDt;
}
function showAlert(message) {
$mdDialog.show($mdDialog.alert().parent(
angular.element(document.querySelector('#popupContainer')))
.clickOutsideToClose(true).textContent(message).ariaLabel(
'Alert Dialog').ok('Ok'));
}
function treatAsUTC(date) {
var result = new Date(date);
result.setMinutes(result.getMinutes() - result.getTimezoneOffset());
return result;
}
function daysBetween(fromDate, toDate) {
var millisecondsPerDay = 24 * 60 * 60 * 1000;
return Math.round((treatAsUTC(toDate) - treatAsUTC(fromDate)) / millisecondsPerDay);
}
});
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
myApp.controller("employeesController", function($scope, $http, myFactory, $mdDialog, appConfig) {
$scope.records = [];
$scope.empId = myFactory.getEmpId();
$scope.empName = myFactory.getEmpName();
$scope.empEmailId = myFactory.getEmpEmailId();
$scope.role = myFactory.getEmpRole();
$scope.avgLoginHrs = "";
$scope.isVisible = false;
$scope.searchId="";
// Date picker related code
var today = new Date();
var priorDt = today;
$scope.maxDate = today;
$scope.fromDate = priorDt;
$scope.toDate = today;
$scope.gridOptions = {
paginationPageSizes : [ 10, 20, 30, 40, 50, 100],
paginationPageSize : 10,
pageNumber: 1,
pageSize:10,
columnDefs : [
{field : 'employeeId',displayName: 'Employee ID', enableColumnMenu: true, enableSorting: true},
{field : 'employeeName',displayName: 'Name', enableColumnMenu: false, enableSorting: false},
{field : 'dateOfLogin',displayName: 'Date', enableColumnMenu: true, enableSorting: true},
{field : 'firstLogin',displayName: 'Login Time', enableColumnMenu: false,enableSorting: false},
{field : 'lastLogout',displayName: 'Logout Time', enableColumnMenu: false, enableSorting: false},
{field : 'totalLoginTime',displayName: 'Total Hours(HH:MM)', enableColumnMenu: false, enableSorting: false}
]
};
$scope.gridOptions.data = [];
$scope.setPageDefaults = function(){
getData(0, getFormattedDate($scope.fromDate), getFormattedDate($scope.toDate), 'onload');
}
$scope.refreshPage = function(){
$scope.searchId="";
$scope.fromDate = priorDt;
$scope.toDate = today;
$scope.gridOptions.data = [];
$scope.isVisible = false;
$scope.setPageDefaults();
};
$scope.getEmployeeData = function(type){
var searchId = $scope.searchId;
var fromDate = getFormattedDate($scope.fromDate);
var toDate = getFormattedDate($scope.toDate);
if(type == "blur"){
if(searchId != "" && isNaN(searchId)){
showAlert('Please enter only digits');
setFieldsEmpty();
}else if(searchId != "" && ((searchId.length >0 && searchId.length <5) || searchId.length>5)){
showAlert('Employee ID should be 5 digits');
setFieldsEmpty();
}else if(searchId != "" && !checkEmpIdRange(searchId)){
showAlert('Employee ID should be in between '+appConfig.empStartId+' - '+appConfig.empEndId);
setFieldsEmpty();
}else{
if(searchId == "") getData(0, fromDate, toDate, 'onblur');
else getData(searchId, fromDate, toDate, 'onblur');
}
}else if(type == "click"){
if(searchId == ""){
getData(0, fromDate, toDate, 'onclick');
}else if(searchId != "" && isNaN(searchId)){
showAlert('Please enter only digits');
setFieldsEmpty();
}else if(searchId != "" && !checkEmpIdRange(searchId)){
showAlert('Employee ID should be in between '+appConfig.empStartId+' - '+appConfig.empEndId);
setFieldsEmpty();
}else if(searchId != ""&& (searchId.length < 5 || searchId.length > 5)){
showAlert('Employee ID should be 5 digits');
setFieldsEmpty();
}else{
getData(searchId, fromDate, toDate, 'onclick');
}
}
}
function checkEmpIdRange(searchId){
return parseInt(searchId) >= appConfig.empStartId && parseInt(searchId) <= appConfig.empEndId;
}
function getData(empId, fromDate, toDate, type){
$http({
method : "GET",
url : appConfig.appUri + "attendance/employeeLoginsBasedOnDate?empId=" + empId + "&fromDate=" + fromDate + "&toDate=" +toDate
}).then(function mySuccess(response) {
var recs = response.data;
if(recs.length == 0 && type == "onclick"){
showAlert('No data available');
setFieldsEmpty();
}else{
if(empId == 0){
$scope.isVisible = false;
$scope.gridOptions.data = response.data;
}else{
$scope.isVisible = true;
$scope.avgLoginHrs = response.data[0].totalAvgTime +" Hrs";
$scope.gridOptions.data = response.data;
}
}
}, function myError(response) {
showAlert("Something went wrong while fetching data!!!");
$scope.gridOptions.data = [];
});
}
$scope.validateDates = function(dateValue, from) {
if(from == "FromDate"){
var toDat = $scope.toDate;
var difference = daysBetween(dateValue, toDat);
if(difference < 0 ){
showAlert('From Date should not be greater than To Date');
$scope.fromDate = priorDt;
$scope.toDate = today;
}else{
$scope.fromDate = dateValue;
$scope.toDate = toDat;
}
}else if(from == "ToDate"){
var fromDat = $scope.fromDate;
var differene = daysBetween(fromDat, dateValue);
if(differene < 0 ){
showAlert('To Date should not be less than From Date');
$scope.fromDate = priorDt;
$scope.toDate = today;
}else{
$scope.fromDate = fromDat;
$scope.toDate = dateValue;
}
}
};
function showAlert(message) {
$mdDialog.show($mdDialog.alert().parent(
angular.element(document.querySelector('#popupContainer')))
.clickOutsideToClose(true).textContent(message).ariaLabel(
'Alert Dialog').ok('Ok'));
}
function getFormattedDate(date){
var day = date.getDate();
var month = date.getMonth() + 1;
var year = date.getFullYear();
return year + '-' + (month < 10 ? "0" + month : month) + '-'
+ (day < 10 ? "0" + day : day);
}
function setFieldsEmpty(){
$scope.searchId="";
$scope.fromDate = priorDt;
$scope.toDate = today;
$scope.gridOptions.data = [];
$scope.isVisible = false;
}
function treatAsUTC(date) {
var result = new Date(date);
result.setMinutes(result.getMinutes() - result.getTimezoneOffset());
return result;
}
function daysBetween(fromDate, toDate) {
var millisecondsPerDay = 24 * 60 * 60 * 1000;
return Math.round((treatAsUTC(toDate) - treatAsUTC(fromDate)) / millisecondsPerDay);
}
});
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
#header {
width: 100%;
height: 8%;
}
#sidebar-left {
float: left;
width: 20%;
height: 84.5%;
}
#main {
float: left;
width: 80%;
height: 84.5%;
background-color: floralwhite;
}
#footer {
height: 8%;
width: 100%;
}
.myGrid {
width:98.5%;
height: 300px;
margin-left:5px;
}
#gridTest,#gridTest1 .ui-grid-cell-contents{
text-align:center;
}
.watermark {
position: absolute;
top: 50%;
transform: translateY(-50%);
opacity: 0.75;
width: 100%;
text-align: center;
z-index: 1000;
}
.md-button {
text-transform: capitalize !important;
}
.carousel-indicators li{
background-color:orange;
border-color:#ff9200;
}
.carousel-indicators .active{
background-color:orange;
border-color:#ff9200;
}
md-dialog{
margin-left: 15%;
}
.navbar-inverse {
background-color: darkslategray;
border-color: darkslategray;
color:#fff;
}
.navbar-inverse .navbar-nav>.dropdown>a .caret {
border-top-color: #fff;
border-bottom-color: #fff;
}
.navbar-inverse .navbar-nav > .active > a, .navbar-inverse .navbar-nav > .active > a:hover, .navbar-inverse .navbar-nav > .active > a:focus {
color: #fff;
background-color: darkslategray;
}
.mainDivHeaderClass{
text-align: center;
background: cadetblue;
color: floralwhite;
border-radius: 5px;
}
.dropdown-menu {
position: absolute;
top: 100%;
left: 0;
z-index: 1000;
display: none;
float: left;
width: 290px;
height:261px;
padding: 0;
margin: 0;
list-style: none;
background-color: transparent;
border: 1px solid rgba(0,0,0,0.15);
border-radius: 5px;
-webkit-box-shadow: 0 6px 6px rgba(0,0,0,0.175);
box-shadow: 0 6px 6px rgba(0,0,0,0.175);
background-clip: padding-box;
}
This diff is collapsed.
*{box-sizing: border-box;}
.wrapper {margin: 0 auto; width: 940px;background: #888; }
.pdf-controls { width: 99%; background: #888; padding: 1em;}
.rotate0 {-webkit-transform: rotate(0deg); transform: rotate(0deg);background: #888;
padding-left: 10px;}
.rotate90 {-webkit-transform: rotate(90deg); transform: rotate(90deg); background: #888;
padding-left: 10px;}
.rotate180 {-webkit-transform: rotate(180deg); transform: rotate(180deg);background: #888;
padding-left: 10px;}
.rotate270 {-webkit-transform: rotate(270deg); transform: rotate(270deg); background: #888;
padding-left: 10px;}
.fixed { position: fixed; top: 0; left: calc(50% - 480px); z-index: 100; width: 99%; padding: 1em; background: #888; width: 940px; }
\ No newline at end of file
.card {
padding-top: 20px;
margin:0;
background-color: rgba(214, 224, 226, 0.2);
border-top-width: 0;
border-bottom-width: 2px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.card.hovercard {
position: relative;
padding-top: 0;
overflow: hidden;
text-align: center;
background-color: darkcyan;
height: 255px;
}
.card.hovercard .cardheader {
background: url("/my-time/images/profile-background.jpg");
background-size: cover;
height: 95px;
}
.card.hovercard .avatar {
position: relative;
top: -60px;
margin-bottom: -60px;
}
.card.hovercard .avatar img {
width: 100px;
height: 100px;
max-width: 100px;
max-height: 100px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
border: 5px solid rgba(255,255,255,0.5);
}
.card.hovercard .info {
padding: 4px 8px 10px;
}
.card.hovercard .info .title {
margin-bottom: 4px;
font-size: 24px;
line-height: 1;
color: floralwhite;
vertical-align: middle;
}
.card.hovercard .info .desc {
overflow: hidden;
font-size: 12px;
line-height: 20px;
color: #fff;
text-overflow: ellipsis;
}
.ui-grid-pager-control input{
width: 65px;
}
\ No newline at end of file
This diff is collapsed.
var myApp = angular.module(
"myTimeApp",
[ "ngRoute", "ngCookies", "ui.grid", "ui.grid.pagination",
"ngMaterial", "ui.bootstrap", "pdf" ]).config(
function($mdDateLocaleProvider) {
$mdDateLocaleProvider.formatDate = function(date) {
var day = date.getDate();
var month = date.getMonth() + 1;
var year = date.getFullYear();
return year + '-' + (month < 10 ? "0" + month : month) + '-'
+ (day < 10 ? "0" + day : day);
};
});
//TODO: Replace this appUri with the domain name created
myApp.constant('appConfig', {
appName: "MyTime",
appUri: "http://192.168.15.17:8080/my-time/",
version:"1.0",
empStartId:16001,
empEndId:16999
});
myApp.factory('myFactory', function() {
var empId = "";
var empName = "";
var empEmailId = "";
var empRole = "";
var menuItems = [];
var templateUrl = "";
var profileUrl = "";
function setEmpId(id) {
empId = id;
}
function getEmpId() {
return empId;
}
function setEmpName(name) {
empName = name;
}
function getEmpName() {
return empName;
}
function setEmpEmailId(email) {
empEmailId = email;
}
function getEmpEmailId() {
return empEmailId;
}
function setEmpRole(role) {
empRole = role;
}
function getEmpRole() {
return empRole;
}
function setMenuItems(items) {
menuItems = items;
}
function getMenuItems() {
return menuItems;
}
function setTemplateUrl(url) {
templateUrl = url;
}
function getTemplateUrl() {
return templateUrl;
}
function setProfileUrl(picurl) {
profileUrl = picurl;
}
function getProfileUrl() {
return profileUrl;
}
return {
setEmpId : setEmpId,
getEmpId : getEmpId,
setEmpName : setEmpName,
getEmpName : getEmpName,
setEmpEmailId : setEmpEmailId,
getEmpEmailId : getEmpEmailId,
setEmpRole : setEmpRole,
getEmpRole : getEmpRole,
setMenuItems : setMenuItems,
getMenuItems : getMenuItems,
setTemplateUrl : setTemplateUrl,
getTemplateUrl : getTemplateUrl,
setProfileUrl : setProfileUrl,
getProfileUrl : getProfileUrl
}
});
This diff is collapsed.
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("angular")):"function"==typeof define&&define.amd?define("pdf",["angular"],t):"object"==typeof exports?exports.pdf=t(require("angular")):e.pdf=t(e.angular)}(this,function(e){return function(e){function t(a){if(n[a])return n[a].exports;var r=n[a]={i:a,l:!1,exports:{}};return e[a].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,a){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:a})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s="./src/angular-pdf.module.js")}({"./src/angular-pdf.directive.js":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.NgPdf=["$window","$document","$log",function(e,t,n){"ngInject";var a=function(t){var n=t.getContext("2d");return(e.devicePixelRatio||1)/(n.webkitBackingStorePixelRatio||n.mozBackingStorePixelRatio||n.msBackingStorePixelRatio||n.oBackingStorePixelRatio||n.backingStorePixelRatio||1)},r=function(e,t,n){var r=a(e);return e.width=Math.floor(t*r),e.height=Math.floor(n*r),e.style.width=Math.floor(t)+"px",e.style.height=Math.floor(n)+"px",e.getContext("2d").setTransform(r,0,0,r,0,0),e},o=function(e,t){angular.element(t).addClass("rotate0"),e.append(t)};return{restrict:"E",templateUrl:function(e,t){return t.templateUrl?t.templateUrl:"partials/viewer.html"},link:function(a,i,l){function u(){w&&w.clearRect(0,0,x.width,x.height)}function s(){u();var e={url:d,withCredentials:b};f&&(e.httpHeaders=f),d&&d.length&&(p=PDFJS.getDocument(e),p.onProgress=a.onProgress,p.onPassword=a.onPassword,p.then(function(e){angular.isFunction(a.onLoad)&&a.onLoad(),h=e,a.renderPage(a.pageToDisplay),a.$apply(function(){a.pageCount=e.numPages})},function(e){e&&angular.isFunction(a.onError)&&a.onError(e)}))}var c=null,p=null,g=!1,d=a.pdfUrl,f=a.httpHeaders,h=null,P=isFinite(l.page)?parseInt(l.page):1,m="page-fit"===l.scale,y="1"===l.limitcanvasheight,v=l.scale>0?l.scale:1,x=t[0].createElement("canvas");o(i,x);var b=l.usecredentials;g=!!l.hasOwnProperty("debug")&&l.debug;var w=x.getContext("2d"),D=angular.element(e);i.css("display","block"),D.on("scroll",function(){a.$apply(function(){a.scroll=D[0].scrollY})}),PDFJS.disableWorker=!0,a.pageNum=P,a.renderPage=function(e){c&&c._internalRenderTask.cancel(),h.getPage(e).then(function(e){var t=void 0,o=void 0,l=void 0;if(m){t=e.getViewport(1);var u=i[0].getBoundingClientRect();o=u.width/t.width,y&&(o=Math.min(o,u.height/t.height)),v=o}t=e.getViewport(v),r(x,t.width,t.height),l={canvasContext:w,viewport:t},c=e.render(l),c.promise.then(function(){angular.isFunction(a.onPageRender)&&a.onPageRender()}).catch(function(e){n.log(e)})})},a.goPrevious=function(){a.pageToDisplay<=1||(a.pageToDisplay=parseInt(a.pageToDisplay)-1,a.pageNum=a.pageToDisplay)},a.goNext=function(){a.pageToDisplay>=h.numPages||(a.pageToDisplay=parseInt(a.pageToDisplay)+1,a.pageNum=a.pageToDisplay)},a.zoomIn=function(){return m=!1,v=parseFloat(v)+.2,a.renderPage(a.pageToDisplay),v},a.zoomOut=function(){return m=!1,v=parseFloat(v)-.2,a.renderPage(a.pageToDisplay),v},a.fit=function(){m=!0,a.renderPage(a.pageToDisplay)},a.changePage=function(){a.renderPage(a.pageToDisplay)},a.rotate=function(){"rotate0"===x.getAttribute("class")?x.setAttribute("class","rotate90"):"rotate90"===x.getAttribute("class")?x.setAttribute("class","rotate180"):"rotate180"===x.getAttribute("class")?x.setAttribute("class","rotate270"):x.setAttribute("class","rotate0")},a.$watch("pageNum",function(e){a.pageToDisplay=parseInt(e),null!==h&&a.renderPage(a.pageToDisplay)}),a.$watch("pdfUrl",function(e){""!==e&&(g&&n.log("pdfUrl value change detected: ",a.pdfUrl),d=e,a.pageNum=a.pageToDisplay=P,p?p.destroy().then(function(){s()}):s())})}}}]},"./src/angular-pdf.module.js":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Pdf=void 0;var a=n(0),r=function(e){return e&&e.__esModule?e:{default:e}}(a),o=n("./src/angular-pdf.directive.js"),i=t.Pdf=r.default.module("pdf",[]).directive("ngPdf",o.NgPdf).name;t.default=i},0:function(t,n){t.exports=e}})});
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
!function(e){function t(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="./",t(t.s=10)}([function(e,t,n){"use strict";function i(e,t){if(e.focus(),r.a.isEdge()||r.a.isIE())try{e.contentWindow.document.execCommand("print",!1,null)}catch(t){e.contentWindow.print()}r.a.isIE()||r.a.isEdge()||e.contentWindow.print(),r.a.isIE()&&"pdf"===t.type&&setTimeout(function(){e.parentNode.removeChild(e)},2e3),t.showModal&&a.a.close(),t.onLoadingEnd&&t.onLoadingEnd()}function o(e,t,n){void 0===e.naturalWidth||0===e.naturalWidth?setTimeout(function(){o(e,t,n)},500):i(t,n)}var r=n(1),a=n(3),d={send:function(e,t){document.getElementsByTagName("body")[0].appendChild(t);var n=document.getElementById(e.frameId);"pdf"===e.type&&(r.a.isIE()||r.a.isEdge())?n.setAttribute("onload",i(n,e)):t.onload=function(){if("pdf"===e.type)i(n,e);else{var t=n.contentWindow||n.contentDocument;t.document&&(t=t.document),t.body.innerHTML=e.htmlData,"image"===e.type?o(t.getElementById("printableImage"),n,e):i(n,e)}}}};t.a=d},function(e,t,n){"use strict";var i={isFirefox:function(){return"undefined"!=typeof InstallTrigger},isIE:function(){return-1!==navigator.userAgent.indexOf("MSIE")||!!document.documentMode},isEdge:function(){return!i.isIE()&&!!window.StyleMedia},isChrome:function(){return!!window.chrome&&!!window.chrome.webstore},isSafari:function(){return Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")>0||-1!==navigator.userAgent.toLowerCase().indexOf("safari")}};t.a=i},function(e,t,n){"use strict";function i(e,t){return'<div style="font-family:'+t.font+" !important; font-size: "+t.font_size+' !important; width:100%;">'+e+"</div>"}function o(e){return e.charAt(0).toUpperCase()+e.slice(1)}function r(e,t){var n=document.defaultView||window,i=[],o="";if(n.getComputedStyle){i=n.getComputedStyle(e,"");var r=["border","box","break","text-decoration"],a=["clear","display","width","min-width","height","min-height","max-height"];t.honorMarginPadding&&r.push("margin","padding"),t.honorColor&&r.push("color");for(var d=0;d<i.length;d++)for(var l=0;l<r.length;l++)-1===i[d].indexOf(r[l])&&-1===a.indexOf(i[d])||(o+=i[d]+":"+i.getPropertyValue(i[d])+";")}else if(e.currentStyle){i=e.currentStyle;for(var s in i)-1!==i.indexOf("border")&&-1!==i.indexOf("color")&&(o+=s+":"+i[s]+";")}return o+="max-width: "+t.maxWidth+"px !important;"+t.font_size+" !important;"}function a(e,t){for(var n=0;n<e.length;n++){var i=e[n],o=i.tagName;if("INPUT"===o||"TEXTAREA"===o||"SELECT"===o){var d=r(i,t),l=i.parentNode,s="SELECT"===o?document.createTextNode(i.options[i.selectedIndex].text):document.createTextNode(i.value),c=document.createElement("div");c.appendChild(s),c.setAttribute("style",d),l.appendChild(c),l.removeChild(i)}else i.setAttribute("style",r(i,t));var p=i.children;p&&p.length&&a(p,t)}}function d(e,t,n){var i=document.createElement("h1"),o=document.createTextNode(t);i.appendChild(o),i.setAttribute("style",n),e.insertBefore(i,e.childNodes[0])}t.a=i,t.b=o,t.c=r,t.d=a,t.e=d},function(e,t,n){"use strict";var i={show:function(e){var t=document.createElement("div");t.setAttribute("style","font-family:sans-serif; display:table; text-align:center; font-weight:300; font-size:30px; left:0; top:0;position:fixed; z-index: 9990;color: #0460B5; width: 100%; height: 100%; background-color:rgba(255,255,255,.9);transition: opacity .3s ease;"),t.setAttribute("id","printJS-Modal");var n=document.createElement("div");n.setAttribute("style","display:table-cell; vertical-align:middle; padding-bottom:100px;");var o=document.createElement("div");o.setAttribute("class","printClose"),o.setAttribute("id","printClose"),n.appendChild(o);var r=document.createElement("span");r.setAttribute("class","printSpinner"),n.appendChild(r);var a=document.createTextNode(e.modalMessage);n.appendChild(a),t.appendChild(n),document.getElementsByTagName("body")[0].appendChild(t),document.getElementById("printClose").addEventListener("click",function(){i.close()})},close:function(){var e=document.getElementById("printJS-Modal");e.parentNode.removeChild(e)}};t.a=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(7),o=i.a.init;"undefined"!=typeof window&&(window.printJS=o),t.default=o},function(e,t,n){"use strict";var i=n(2),o=n(0);t.a={print:function(e,t){var r=document.getElementById(e.printable);if(!r)return window.console.error("Invalid HTML element id: "+e.printable),!1;var a=document.createElement("div");a.appendChild(r.cloneNode(!0)),a.setAttribute("style","display:none;"),a.setAttribute("id","printJS-html"),r.parentNode.appendChild(a),a=document.getElementById("printJS-html"),a.setAttribute("style",n.i(i.c)(a,e)+"margin:0 !important;");var d=a.children;n.i(i.d)(d,e),e.header&&n.i(i.e)(a,e.header,e.headerStyle),a.parentNode.removeChild(a),e.htmlData=n.i(i.a)(a.innerHTML,e),o.a.send(e,t)}}},function(e,t,n){"use strict";var i=n(2),o=n(0);t.a={print:function(e,t){var r=document.createElement("img");r.src=e.printable,r.onload=function(){r.setAttribute("style","width:100%;"),r.setAttribute("id","printableImage");var a=document.createElement("div");a.setAttribute("style","width:100%"),a.appendChild(r),e.header&&n.i(i.e)(a,e.header,e.headerStyle),e.htmlData=a.outerHTML,o.a.send(e,t)}}}},function(e,t,n){"use strict";var i=n(1),o=n(3),r=n(9),a=n(5),d=n(6),l=n(8),s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c=["pdf","html","image","json"];t.a={init:function(){var e={printable:null,type:"pdf",header:null,headerStyle:"font-weight: 300;",maxWidth:800,font:"TimesNewRoman",font_size:"12pt",honorMarginPadding:!0,honorColor:!1,properties:null,gridHeaderStyle:"font-weight: bold;",gridStyle:"border: 1px solid lightgray; margin-bottom: -1px;",showModal:!1,onLoadingStart:function(){},onLoadingEnd:function(){},modalMessage:"Retrieving Document...",frameId:"printJS",htmlData:"",documentTitle:"Document"},t=arguments[0];if(void 0===t)throw new Error("printJS expects at least 1 attribute.");switch(void 0===t?"undefined":s(t)){case"string":e.printable=encodeURI(t),e.type=arguments[1]||e.type;break;case"object":e.printable=t.printable,e.type=void 0!==t.type?t.type:e.type,e.frameId=void 0!==t.frameId?t.frameId:e.frameId,e.header=void 0!==t.header?t.header:e.header,e.headerStyle=void 0!==t.headerStyle?t.headerStyle:e.headerStyle,e.maxWidth=void 0!==t.maxWidth?t.maxWidth:e.maxWidth,e.font=void 0!==t.font?t.font:e.font,e.font_size=void 0!==t.font_size?t.font_size:e.font_size,e.honorMarginPadding=void 0!==t.honorMarginPadding?t.honorMarginPadding:e.honorMarginPadding,e.properties=void 0!==t.properties?t.properties:e.properties,e.gridHeaderStyle=void 0!==t.gridHeaderStyle?t.gridHeaderStyle:e.gridHeaderStyle,e.gridStyle=void 0!==t.gridStyle?t.gridStyle:e.gridStyle,e.showModal=void 0!==t.showModal?t.showModal:e.showModal,e.onLoadingStart=void 0!==t.onLoadingStart?t.onLoadingStart:e.onLoadingStart,e.onLoadingEnd=void 0!==t.onLoadingEnd?t.onLoadingEnd:e.onLoadingEnd,e.modalMessage=void 0!==t.modalMessage?t.modalMessage:e.modalMessage,e.documentTitle=void 0!==t.documentTitle?t.documentTitle:e.documentTitle;break;default:throw new Error('Unexpected argument type! Expected "string" or "object", got '+(void 0===t?"undefined":s(t)))}if(!e.printable)throw new Error("Missing printable information.");if(!e.type||"string"!=typeof e.type||-1===c.indexOf(e.type.toLowerCase()))throw new Error("Invalid print type. Available types are: pdf, html, image and json.");e.showModal&&o.a.show(e),e.onLoadingStart&&e.onLoadingStart();var n=document.getElementById(e.frameId);n&&n.parentNode.removeChild(n);var p=void 0;switch(p=document.createElement("iframe"),p.setAttribute("style","display:none;"),p.setAttribute("id",e.frameId),"pdf"!==e.type&&(p.srcdoc="<html><head><title>"+e.documentTitle+"</title></head><body></body></html>"),e.type){case"pdf":if(i.a.isFirefox()||i.a.isEdge()||i.a.isIE()){window.open(e.printable,"_blank").focus(),e.showModal&&o.a.close(),e.onLoadingEnd&&e.onLoadingEnd()}else r.a.print(e,p);break;case"image":d.a.print(e,p);break;case"html":a.a.print(e,p);break;case"json":l.a.print(e,p);break;default:throw new Error("Invalid print type. Available types are: pdf, html, image and json.")}}}},function(e,t,n){"use strict";function i(e){var t=e.printable,i=e.properties,r='<div style="display:flex; flex-direction: column;">';r+='<div style="flex:1 1 auto; display:flex;">';for(var a=0;a<i.length;a++)r+='<div style="flex:1; padding:5px;'+e.gridHeaderStyle+'">'+n.i(o.b)(i[a].displayName||i[a])+"</div>";r+="</div>";for(var d=0;d<t.length;d++){r+='<div style="flex:1 1 auto; display:flex;">';for(var l=0;l<i.length;l++)r+='<div style="flex:1; padding:5px;'+e.gridStyle+'">'+t[d][i[l].field||i[l]]+"</div>";r+="</div>"}return r+="</div>"}var o=n(2),r=n(0),a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.a={print:function(e,t){if("object"!==a(e.printable))throw new Error("Invalid javascript data object (JSON).");if(!e.properties||"object"!==a(e.properties))throw new Error("Invalid properties array for your JSON data.");var d="";e.header&&(d+='<h1 style="'+e.headerStyle+'">'+e.header+"</h1>"),d+=i(e),e.htmlData=n.i(o.a)(d,e),r.a.send(e,t)}}},function(e,t,n){"use strict";function i(e,t){t.setAttribute("src",e.printable),r.a.send(e,t)}var o=n(1),r=n(0);t.a={print:function(e,t){if(e.showModal||e.onLoadingStart||o.a.isIE()){var n=new window.XMLHttpRequest;n.addEventListener("load",i(e,t)),n.open("GET",window.location.origin+e.printable,!0),n.send()}else i(e,t)}}},function(e,t,n){e.exports=n(4)}]);
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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