}
else if ((save != null) && save.equalsIgnoreCase("Save"))
{
TimeSheetVOX timeSheetVOX = new TimeSheetVOX(userobjectd,
dynaValidatorForm);
TimeSheetVO timeSheetVO = timeSheetVOX.getTimeSheetVO();
String addslipflag = (String) session.getAttribute("addslip");
//Condition that instructs that the NewSlip button is clicked and the timesheet is already added to the database
if (addslipflag == null)
{
saveForm();
}
ListPreference listpreference = userobjectd.getListPreference("TimeSheet");
DisplayList displaylistSession = (DisplayList) session.getAttribute("displaylist");
DisplayList displaylist = (DisplayList) request.getAttribute("displaylist");
TimeSheetList DL = null;
if (displaylist == null)
{
ListGenerator lg = ListGenerator.getListGenerator(dataSource);
DL = (TimeSheetList) lg.getTimeSheetList(userobjectd.getIndividualID(),
1, listpreference.getRecordsPerPage(), "", listpreference.getSortElement());
}
else
{
DL = (TimeSheetList) displaylistSession;
}
request.setAttribute("HrExpenseForm", form);
session.setAttribute("HrExpenseForm", form);
session.setAttribute("displaylist", DL);
session.setAttribute("timesheetvo", timeSheetVO);
request.setAttribute("displaylist", DL);
request.setAttribute("list", "TimeSheet");
request.setAttribute(HrConstantKeys.TYPEOFSUBMODULE, HrConstantKeys.TIMESHEET);
returnStatus = ".view.hr.timesheet.edit";
}
else if ((saveandclose != null) &&
saveandclose.equalsIgnoreCase("Save & Close"))
{
TimeSheetVOX timeSheetVOX = new TimeSheetVOX(userobjectd,
dynaValidatorForm);
TimeSheetVO timeSheetVO = timeSheetVOX.getTimeSheetVO();
String addslipflag = (String) session.getAttribute("addslip");
//Condition that instructs that the NewSlip button is clicked and the timesheet is already added to the database
if (addslipflag == null)
{
saveForm();
}
else
{
session.setAttribute("addslip", null);
}
ListPreference listpreference = userobjectd.getListPreference("TimeSheet");
DisplayList displaylistSession = (DisplayList) session.getAttribute("displaylist");
DisplayList displaylist = (DisplayList) request.getAttribute("displaylist");
TimeSheetList DL = null;
if (displaylist == null)
{
ListGenerator lg = ListGenerator.getListGenerator(dataSource);
DL = (TimeSheetList) lg.getTimeSheetList(userobjectd.getIndividualID(),
1, listpreference.getRecordsPerPage(), "", listpreference.getSortElement());
}
else
{
DL = (TimeSheetList) displaylistSession;
}
session.setAttribute("displaylist", DL);
request.setAttribute("displaylist", DL);
request.setAttribute("list", "TimeSheet");
request.setAttribute(HrConstantKeys.TYPEOFSUBMODULE, HrConstantKeys.TIMESHEET);
returnStatus = ".view.hr.timesheet.list";
}
else if ((saveandnew != null) &&
saveandnew.equalsIgnoreCase("Save & New"))
{
String addslipflag = (String) session.getAttribute("addslip");
if (addslipflag == null)
{
saveForm();
}
else
{
session.setAttribute("addslip", null);
}
dynaValidatorForm.initialize(mapping);
session.setAttribute("timesliplist", null);
session.setAttribute("savenewflag", "true");
returnStatus = ".view.hr.timesheet.new";
}
}
else if (sTypeOfOperation.equalsIgnoreCase("EDIT"))
{
//Here we will be doing the editing of the timesheet records
//i.e. the update query will be set
String sTimeSheetID = (String) request.getParameter("timesheetID");
int timesheetId = 0;
if (sTimeSheetID != null)
{
Integer iTimeSheetId = new Integer(sTimeSheetID);
timesheetId = iTimeSheetId.intValue();
}
else
{
Integer iTimeSheetId = (Integer) request.getAttribute("timesheetID");
timesheetId = iTimeSheetId.intValue();
}
updateForm(timesheetId);
if ((save != null) && save.equals("Save"))
{
//The record is updated in the DB and the new timesheet screen is shown.
returnStatus = ".view.hr.timesheet.edit";
dynaValidatorForm.initialize(mapping);
}
if ((saveandclose != null) && saveandclose.equals("Save & Close"))
{
//The record will be updated in the DB and the page is closed.
returnStatus = ".view.hr.timesheet.list";
}
else if ((saveandnew != null) && saveandnew.equals("Save & New"))
{
//The record is updated in the DB and the new timesheet screen is shown.
session.setAttribute("savenewflag", "true");
returnStatus = ".view.hr.timesheet.new";
dynaValidatorForm.initialize(mapping);
}
session.setAttribute("TYPEOFOPERATION", sTypeOfOperation);
}
else if (sTypeOfOperation.equalsIgnoreCase("DUPLICATE"))
{
String sTimeSheetID = (String) request.getParameter("timesheetID");
Integer iTimeSheetId = new Integer(0);
if (sTimeSheetID != null){
iTimeSheetId = new Integer(sTimeSheetID);
}
else if(request.getAttribute("timesheetID") != null){
iTimeSheetId = (Integer) request.getAttribute("timesheetID");
}
if (iTimeSheetId != null)
{
int timesheetId = iTimeSheetId.intValue();
int iNewTimeSheetId = saveForm();
TimeSheetVO timeSheetVO=null;
try
{
HrFacadeHome aa = (HrFacadeHome)
CVUtility.getHomeObject("com.centraview.hr.hrfacade.HrFacadeHome", "HrFacade");
HrFacade remote = (HrFacade) aa.create();
remote.setDataSource(dataSource);
timeSheetVO = remote.getTimeSheet(iNewTimeSheetId);
}
catch (Exception e)
{
System.out.println("[Exception] AddTimeSheetHandler.execute: " + e.toString());
e.printStackTrace();
}
DisplayList DL = null;
if (timeSheetVO != null)
{
DL = (DisplayList) timeSheetVO.getTimeSlipList();
}
if(DL != null){
duplicateTimeSlipRecords(iNewTimeSheetId, DL);
}
Integer ID = new Integer(iNewTimeSheetId);