Example usage for com.vaadin.ui Window getParent

List of usage examples for com.vaadin.ui Window getParent

Introduction

In this page you can find the example usage for com.vaadin.ui Window getParent.

Prototype

@Override
    public HasComponents getParent() 

Source Link

Usage

From source file:com.openhris.employee.EmployeePersonalInformation.java

private Window updatePersonalInformationConfirmation(final PersonalInformation pi) {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSpacing(true);/*from www  .jav a 2s.co m*/
    vlayout.setMargin(true);

    final Window window = new Window("UPDATE WINDOW", vlayout);
    window.setWidth("350px");

    final TextArea remarks = new TextArea("Remarks");
    remarks.setWidth("100%");
    remarks.setRows(3);
    window.addComponent(remarks);

    Button removeBtn = new Button("UPDATE EMPLOYEE?");
    removeBtn.setWidth("100%");
    removeBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (remarks.getValue() == null || remarks.getValue().toString().trim().isEmpty()) {
                getWindow().showNotification("Add remarks!", Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            boolean result = piService.updatePersonalInformation(pi, remarks.getValue().toString().trim());
            if (result) {
                getWindow().showNotification("Information Updated", Window.Notification.TYPE_TRAY_NOTIFICATION);
                (window.getParent()).removeWindow(window);
            } else {
                getWindow().showNotification("SQL Error", Window.Notification.TYPE_ERROR_MESSAGE);
            }
        }

    });
    window.addComponent(removeBtn);

    return window;
}

From source file:com.openhris.employee.PostEmploymentInfomation.java

public Table positionHistoryTable() {
    positionHistoryTbl.removeAllItems();
    List<PostEmploymentInformationBean> positionList = positionHistoryService
            .getPositionHistory(getEmployeeId());
    int i = 0;//from  w  w  w.  j  ava2s.com
    for (PostEmploymentInformationBean p : positionList) {
        positionHistoryTbl
                .addItem(new Object[] { p.getPositionId(), p.getPosition().toLowerCase(), p.getCompany(),
                        p.getTrade(), p.getBranch(), p.getDepartment(), utilities.convertDateFormatForTableData(
                                utilities.convertDateFormat(p.getEntryDate().toString())) },
                        i);
        i++;
    }
    positionHistoryTbl.setPageLength(7);

    for (Object listener : positionHistoryTbl.getListeners(ItemClickEvent.class)) {
        positionHistoryTbl.removeListener(ItemClickEvent.class, listener);
    }

    positionHistoryTbl.addListener(new ItemClickEvent.ItemClickListener() {

        @Override
        public void itemClick(ItemClickEvent event) {
            Object itemId = event.getItemId();
            Item item = positionHistoryTbl.getItem(itemId);

            newPositionBtn.setValue(false);
            updateBtn.setCaption(BTN_CAPTION_2);

            positionId = utilities.convertStringToInteger(item.getItemProperty("id").getValue().toString());
            setPositionId(positionId);
            if (event.getPropertyId().equals("id")) {
                Window window = new RemovePositionWindow(getPositionId());
                if (window.getParent() == null) {
                    getWindow().addWindow(window);
                }
                window.center();
                window.addListener(subWindowCloseListener);
            } else {
                List<PostEmploymentInformationBean> positionListById = positionHistoryService
                        .getPositionHistoryById(utilities
                                .convertStringToInteger(item.getItemProperty("id").getValue().toString()));
                for (PostEmploymentInformationBean history : positionListById) {
                    Object corporateObjectId = corporate.addItem();
                    corporate.setItemCaption(corporateObjectId, history.getCompany());
                    corporate.setValue(corporateObjectId);

                    Object tradeObjectId = trade.addItem();
                    trade.setItemCaption(tradeObjectId, history.getTrade());
                    trade.setValue(tradeObjectId);

                    Object branchObjectId = branch.addItem();
                    branch.setItemCaption(branchObjectId, history.getBranch());
                    branch.setValue(branchObjectId);

                    department.setValue(history.getDepartment());
                    position.setValue(history.getPosition());
                    entryDate.setValue(history.getEntryDate());
                }
            }
        }
    });

    return positionHistoryTbl;
}

From source file:com.openhris.employee.PostEmploymentInfomation.java

public ComponentContainer layout2() {
    HorizontalLayout hlayout = new HorizontalLayout();
    hlayout.setSpacing(true);//  w w  w. j  a v  a  2  s.co  m
    hlayout.setWidth("100%");

    GridLayout glayout2 = new GridLayout(2, 2);
    glayout2.setSpacing(true);

    final PopupDateField endDate = new HRISPopupDateField("Exit Date: ");
    endDate.setWidth("250px");
    endDate.setDateFormat("MM/dd/yyyy");
    glayout2.addComponent(endDate, 0, 0);
    glayout2.setComponentAlignment(endDate, Alignment.BOTTOM_LEFT);

    Button endDateBtn = new Button("RESIGN");
    endDateBtn.setWidth("150px");
    endDateBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (endDate.getValue() == null || endDate.getValue().toString().trim().isEmpty()) {
                getWindow().showNotification("Enter End Date.", Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            Window window = new ConfirmResignWindow(getEmployeeId(),
                    utilities.convertDateFormat(endDate.getValue().toString().trim().toLowerCase()));
            if (window.getParent() == null) {
                getWindow().addWindow(window);
            }
        }
    });
    glayout2.addComponent(endDateBtn, 1, 0);
    glayout2.setComponentAlignment(endDateBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        endDateBtn.setEnabled(true);
    } else {
        endDateBtn.setEnabled(false);
    }

    hlayout.addComponent(glayout2);
    hlayout.setComponentAlignment(glayout2, Alignment.MIDDLE_RIGHT);

    final PopupDateField entryDateFromEmp = new HRISPopupDateField("Entry Date from Employment: ");
    entryDateFromEmp.setWidth("250px");
    entryDateFromEmp.setDateFormat("MM/dd/yyyy");
    entryDateFromEmp.setValue(utilities.parsingDate(employeeService.getEmploymentEntryDate(getEmployeeId())));
    glayout2.addComponent(entryDateFromEmp, 0, 1);
    glayout2.setComponentAlignment(entryDateFromEmp, Alignment.BOTTOM_LEFT);

    Button entryDateFromEmpBtn = new Button("EDIT");
    entryDateFromEmpBtn.setWidth("150px");
    entryDateFromEmpBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (!GlobalVariables.getUserRole().equals("administrator")) {
                getWindow().showNotification(
                        "You need to be an ADMINISTRATOR to EDIT date entry of employment.",
                        Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            Window sub = new EditEmploymentDateEntryWindow(getEmployeeId(),
                    utilities.convertDateFormat(entryDateFromEmp.getValue().toString()));
            if (sub.getParent() == null) {
                getWindow().addWindow(sub);
            }
        }
    });
    glayout2.addComponent(entryDateFromEmpBtn, 1, 1);
    glayout2.setComponentAlignment(entryDateFromEmpBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        entryDateFromEmpBtn.setEnabled(true);
    } else {
        entryDateFromEmpBtn.setEnabled(false);
    }

    return hlayout;
}

From source file:com.openhris.employee.salary.EmployeeSalaryInformation.java

public ComponentContainer layout2() {
    GridLayout glayout = new GridLayout(2, 1);
    glayout.setSpacing(true);/*from w ww . j ava2  s .  c  o m*/
    glayout.setWidth("600px");

    TextField employmentStatusField = new HRISTextField("Employment Status: ");
    employmentStatusField.setWidth("200px");
    glayout.addComponent(employmentStatusField, 0, 0);

    Button setContributionBtn = new Button("SET EMPLOYEE'S CONTRIBUTIONS MAIN BRANCH");
    setContributionBtn.setWidth("100%");
    setContributionBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window subWindow = setContributionMainBranch();
            if (subWindow.getParent() == null) {
                getWindow().addWindow(subWindow);
            }
            subWindow.setModal(true);
            subWindow.center();
        }
    });
    glayout.addComponent(setContributionBtn, 1, 0);
    glayout.setColumnExpandRatio(1, 1);
    glayout.setComponentAlignment(setContributionBtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        setContributionBtn.setEnabled(true);
    } else {
        setContributionBtn.setEnabled(false);
    }

    if (getEmployeeId() != null) {
        EmploymentInformation employmentInformation = si.getEmployeeSalaryInformation(getEmployeeId());
        employmentStatusField.setValue(employmentInformation.getCurrentStatus().toUpperCase());
    }
    employmentStatusField.setReadOnly(true);

    return glayout;
}

From source file:com.openhris.employee.salary.EmployeeSalaryInformation.java

private Window setContributionMainBranch() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setMargin(true);/*www . j  a v  a2 s .c o  m*/
    vlayout.setSpacing(true);

    final Window subWindow = new Window("Set Branch", vlayout);
    subWindow.setWidth("300px");

    corporate = dropDown.populateCorporateComboBox(new ComboBox());
    corporate.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (corporate.getValue() == null) {
            } else {
                corporateId = companyService.getCorporateId(corporate.getValue().toString());
                trade = dropDown.populateTradeComboBox(trade, corporateId);
            }
        }
    });
    corporate.setWidth("100%");
    subWindow.addComponent(corporate);

    trade.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (trade.getValue() == null) {
            } else {
                tradeId = companyService.getTradeId(trade.getValue().toString(), corporateId);
                branch = dropDown.populateBranchComboBox(branch, tradeId, corporateId);
            }
        }
    });
    trade.setWidth("100%");
    subWindow.addComponent(trade);

    branch.setWidth("100%");
    branch.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (branch.getValue() == null) {
            } else {
                branchId = companyService.getBranchId(tradeId, branch.getValue().toString());
            }
        }
    });
    subWindow.addComponent(branch);

    final ComboBox remarks = new ComboBox("Remarks");
    remarks.setWidth("100%");
    remarks.setNullSelectionItemId(false);
    remarks.addItem("Transfer to new Branch.");
    remarks.addItem("Wrong Entry");
    subWindow.addComponent(remarks);

    Button updateBtn = new Button("SET BRANCH for CONTRIBUTION");
    updateBtn.setWidth("100%");
    updateBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (corporate.getValue() == null) {
                getWindow().showNotification("Select Corporation!", Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            if (trade.getValue() == null) {
                getWindow().showNotification("Select Trade!", Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            if (branch.getValue() == null) {
                getWindow().showNotification("Select Branch!", Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            if (remarks.getValue() == null) {
                getWindow().showNotification("Remarks required!", Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            boolean result = si.updateEmployeeContributionBranch(getEmployeeId(), branchId,
                    remarks.getValue().toString(), corporateId);
            if (result) {
                getWindow().showNotification("Successfully transferred to new Branch!");
                (subWindow.getParent()).removeWindow(subWindow);
            } else {
                getWindow().showNotification("SQL Error, Contact your DBA!");
                (subWindow.getParent()).removeWindow(subWindow);
            }
        }
    });
    subWindow.addComponent(updateBtn);

    return subWindow;
}

From source file:com.openhris.employee.salary.EmployeeSalaryInformation.java

private Window editDateEntryWindow(final String entryDate) {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setWidth("100%");
    vlayout.setMargin(true);/*from   w w w .ja  va2s .c om*/
    vlayout.setSpacing(true);

    final Window window = new Window("EDIT DATE ENTRY", vlayout);
    window.setResizable(false);

    Button editBtn = new Button("EDIT DATE ENTRY?");
    editBtn.setWidth("100%");
    editBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            boolean result = si.editEmploymentDateEntry(getEmployeeId(), entryDate);
            if (result) {
                getWindow().showNotification("Update Entry Date.", Window.Notification.TYPE_TRAY_NOTIFICATION);
                (window.getParent()).removeWindow(window);
            }
        }
    });
    window.addComponent(editBtn);

    return window;
}

From source file:com.openhris.payroll.AdjustmentWindow.java

private Table adjustmentTable() {
    adjustmentTbl.removeAllItems();//from   www  .j  ava 2  s.c  o  m
    adjustmentTbl.setWidth("100%");
    adjustmentTbl.setImmediate(true);
    adjustmentTbl.setSelectable(true);

    adjustmentTbl.addContainerProperty("id", Integer.class, null);
    adjustmentTbl.addContainerProperty("amount", Double.class, null);
    adjustmentTbl.addContainerProperty("remarks", String.class, null);
    adjustmentTbl.addContainerProperty("date posted", String.class, null);

    int i = 0;
    List<Adjustment> adjustmentList = payrollService.getListOfAdjustmentFromPayrollId(getPayrollId());
    for (Adjustment adj : adjustmentList) {
        adjustmentTbl.addItem(new Object[] { adj.getAdjustmentId(), adj.getAmount(), adj.getRemarks(),
                utilities.convertDateFormat(adj.getDatePosted().toString()) }, i);
        i++;
    }

    adjustmentTbl.setPageLength(adjustmentTbl.size());

    for (Object listener : adjustmentTbl.getListeners(ItemClickEvent.class)) {
        adjustmentTbl.removeListener(ItemClickEvent.class, listener);
    }

    adjustmentTbl.addListener(new ItemClickEvent.ItemClickListener() {

        @Override
        public void itemClick(ItemClickEvent event) {
            Object itemId = event.getItemId();
            final Item item = adjustmentTbl.getItem(itemId);

            double adjustments = utilities
                    .convertStringToDouble(item.getItemProperty("amount").getValue().toString());
            String remarks = item.getItemProperty("remarks").getValue().toString();

            if (remarks.equals("edit timekeeping table")) {
                getWindow().showNotification("You cannot delete adjustment from previous Payroll!",
                        Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            }

            if (event.getPropertyId().equals("id")) {
                Window subWindow = removeAdjustment(
                        utilities.convertStringToInteger(item.getItemProperty("id").getValue().toString()),
                        getAmountToBeReceive(), getAmountReceived(), adjustments, getPayrollId());
                if (subWindow.getParent() == null) {
                    getApplication().getMainWindow().addWindow(subWindow);
                }
                subWindow.setModal(true);
                subWindow.center();
            }

        }
    });

    return adjustmentTbl;
}

From source file:com.openhris.payroll.AdjustmentWindow.java

private Window removeAdjustment(final int adjustmentId, final double amountToBeReceive,
        final double amountReceived, final double adjustment, final int payrollId) {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setMargin(true);//w w w .  j av  a2 s  .  com
    vlayout.setSpacing(true);

    final Window subWindow = new Window("REMOVE ADVANCES", vlayout);
    subWindow.setWidth("200px");

    Button removeAdjBtn = new Button("REMOVE ADJUSTMENT?");
    removeAdjBtn.setWidth("100%");
    removeAdjBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            boolean result = payrollService.removeAdjustmentById(adjustmentId, amountToBeReceive,
                    amountReceived, adjustment, payrollId);
            if (result) {
                (subWindow.getParent()).removeWindow(subWindow);
                adjustmentTable();
            }
        }
    });
    subWindow.addComponent(removeAdjBtn);

    return subWindow;
}

From source file:com.openhris.payroll.PayrollSubModules.java

public Window perDiemWindow(Item item) {
    this.item = item;

    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSpacing(true);//  ww  w .j a v  a  2  s  .co m
    vlayout.setMargin(true);

    final Window sub = new Window("PER DIEM", vlayout);
    sub.setWidth("220px");
    sub.setModal(true);
    sub.center();

    final TextField perDiemAmount = new TextField("Amount: ");
    perDiemAmount.setWidth("100%");
    perDiemAmount
            .setValue(util.convertStringToDouble(getPayrollTableItem().getItemProperty("per diem").toString()));
    perDiemAmount.setNullSettingAllowed(false);
    sub.addComponent(perDiemAmount);

    Button save = new Button("SAVE");
    save.setWidth("100%");
    save.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            int payrollId = util
                    .convertStringToInteger(getPayrollTableItem().getItemProperty("id").getValue().toString());
            double amountToBeReceive = util.convertStringToDouble(
                    getPayrollTableItem().getItemProperty("amount to be receive").toString());
            double amountReceived = util
                    .convertStringToDouble(getPayrollTableItem().getItemProperty("amount received").toString());
            double amount = util.convertStringToDouble(perDiemAmount.getValue().toString())
                    - util.convertStringToDouble(
                            getPayrollTableItem().getItemProperty("per diem").getValue().toString());

            boolean result = ps.addPerDiem(payrollId,
                    util.convertStringToDouble(perDiemAmount.getValue().toString()),
                    util.convertStringToDouble(
                            getPayrollTableItem().getItemProperty("per diem").getValue().toString()),
                    amountToBeReceive, amountReceived);
            if (result) {
                getPayrollTableItem().getItemProperty("amount to be receive")
                        .setValue(amountToBeReceive + amount);
                getPayrollTableItem().getItemProperty("amount received").setValue(amountReceived + amount);
                getPayrollTableItem().getItemProperty("per diem").setValue(perDiemAmount.getValue());
                (sub.getParent()).removeWindow(sub);
            }
        }
    });
    sub.addComponent(save);

    return sub;
}

From source file:com.openhris.timekeeping.EditAttendanceTableContainerWindow.java

VerticalLayout generateAttendanceTable() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSizeFull();// w  w w  .java 2s . c o m
    vlayout.setSpacing(true);

    if (getEmploymentWageEntry().equals("monthly")) {
        employmentWage = utilities.roundOffToTwoDecimalPlaces((employmentWage * 12) / 314);
    }

    final Table table = new Table();
    table.removeAllItems();
    table.setEnabled(true);
    table.setWidth("100%");
    table.setImmediate(true);
    table.setColumnCollapsingAllowed(true);

    table.addContainerProperty("edit", CheckBox.class, null);
    table.addContainerProperty("date", String.class, null);
    table.addContainerProperty("policy", String.class, null);
    table.addContainerProperty("holidays", String.class, null);
    table.addContainerProperty("premium", CheckBox.class, null);
    table.addContainerProperty("lates", TextField.class, null);
    table.addContainerProperty("undertime", TextField.class, null);
    table.addContainerProperty("overtime", TextField.class, null);
    table.addContainerProperty("night differential", TextField.class, null);
    table.addContainerProperty("l/min", Double.class, null);
    table.addContainerProperty("u/min", Double.class, null);
    table.addContainerProperty("o/min", Double.class, null);
    table.addContainerProperty("nd/min", Double.class, null);
    table.addContainerProperty("lholiday", Double.class, null);
    table.addContainerProperty("sholiday", Double.class, null);
    table.addContainerProperty("wdo", Double.class, null);
    table.addContainerProperty("psday", Double.class, null); //paid non-working holiday
    table.addContainerProperty("latesLH", Double.class, null);
    table.addContainerProperty("latesSH", Double.class, null);
    table.addContainerProperty("latesWO", Double.class, null);
    table.addContainerProperty("undertimeLH", Double.class, null);
    table.addContainerProperty("undertimeSH", Double.class, null);
    table.addContainerProperty("undertimeWO", Double.class, null);

    table.setColumnAlignment("edit", Table.ALIGN_CENTER);
    table.setColumnAlignment("date", Table.ALIGN_CENTER);
    table.setColumnAlignment("policy", Table.ALIGN_CENTER);
    table.setColumnAlignment("premium", Table.ALIGN_CENTER);
    table.setColumnAlignment("lates", Table.ALIGN_CENTER);
    table.setColumnAlignment("undertime", Table.ALIGN_CENTER);
    table.setColumnAlignment("overtime", Table.ALIGN_CENTER);
    table.setColumnAlignment("night differential", Table.ALIGN_CENTER);
    table.setColumnAlignment("l/min", Table.ALIGN_RIGHT);
    table.setColumnAlignment("u/min", Table.ALIGN_RIGHT);
    table.setColumnAlignment("o/min", Table.ALIGN_RIGHT);
    table.setColumnAlignment("nd/min", Table.ALIGN_RIGHT);
    table.setColumnAlignment("lholiday", Table.ALIGN_RIGHT);
    table.setColumnAlignment("sholiday", Table.ALIGN_RIGHT);
    table.setColumnAlignment("wdo", Table.ALIGN_RIGHT);
    table.setColumnAlignment("psday", Table.ALIGN_RIGHT);
    table.setColumnAlignment("latesLH", Table.ALIGN_RIGHT);
    table.setColumnAlignment("latesSH", Table.ALIGN_RIGHT);
    table.setColumnAlignment("latesWO", Table.ALIGN_RIGHT);
    table.setColumnAlignment("undertimeLH", Table.ALIGN_RIGHT);
    table.setColumnAlignment("undertimeSH", Table.ALIGN_RIGHT);
    table.setColumnAlignment("undertimeWO", Table.ALIGN_RIGHT);

    table.setColumnCollapsed("latesLH", true);
    table.setColumnCollapsed("latesSH", true);
    table.setColumnCollapsed("latesWO", true);
    table.setColumnCollapsed("undertimeLH", true);
    table.setColumnCollapsed("undertimeSH", true);
    table.setColumnCollapsed("undertimeWO", true);

    final String[] holidayList = { "legal-holiday", "special-holiday" };
    for (int i = 0; i < getDateList().size(); i++) {
        Object itemId = new Integer(i);

        final CheckBox edit = new CheckBox();
        edit.setData(i);
        edit.setEnabled(UserAccessControl.isEditAttendance());
        edit.setImmediate(true);

        final CheckBox premium = new CheckBox();
        premium.setData(itemId);
        premium.setEnabled(false);
        premium.setImmediate(true);

        final TextField lates = new TextField();
        lates.setWidth("50px");
        lates.setValue("0");
        lates.setEnabled(true);
        lates.setData(itemId);
        lates.setEnabled(false);
        lates.setImmediate(true);

        final TextField undertime = new TextField();
        undertime.setWidth("50px");
        undertime.setValue("0");
        undertime.setEnabled(true);
        undertime.setData(itemId);
        undertime.setEnabled(false);
        undertime.setImmediate(true);

        final TextField overtime = new TextField();
        overtime.setWidth("50px");
        overtime.setValue("0");
        overtime.setEnabled(true);
        overtime.setData(itemId);
        overtime.setEnabled(false);
        overtime.setImmediate(true);

        final TextField nightDifferential = new TextField();
        nightDifferential.setWidth("50px");
        nightDifferential.setValue("0");
        nightDifferential.setEnabled(true);
        nightDifferential.setData(itemId);
        nightDifferential.setEnabled(false);
        nightDifferential.setImmediate(true);

        edit.addListener(new Button.ClickListener() {

            @Override
            public void buttonClick(Button.ClickEvent event) {
                premium.setEnabled(event.getButton().booleanValue());
                lates.setEnabled(event.getButton().booleanValue());
                undertime.setEnabled(event.getButton().booleanValue());
                overtime.setEnabled(event.getButton().booleanValue());
                nightDifferential.setEnabled(event.getButton().booleanValue());
            }
        });

        premium.addListener(new Button.ClickListener() {

            @Override
            public void buttonClick(Button.ClickEvent event) {
                Object itemId = lates.getData();
                Item item = table.getItem(itemId);

                lates.setValue("0");
                undertime.setValue("0");
                overtime.setValue("0");
                nightDifferential.setValue("0");

                item.getItemProperty("l/min").setValue(0.0);
                item.getItemProperty("u/min").setValue(0.0);
                item.getItemProperty("o/min").setValue(0.0);
                item.getItemProperty("nd/min").setValue(0.0);

                if (event.getButton().booleanValue() == true) {
                    premiumRate = 0.1;
                } else {
                    premiumRate = 0.0;
                }

                item.getItemProperty("wdo")
                        .setValue(utilities.roundOffToTwoDecimalPlaces(
                                Double.parseDouble(item.getItemProperty("wdo").getValue().toString())
                                        + (Double.parseDouble(item.getItemProperty("wdo").getValue().toString())
                                                * premiumRate)));

                item.getItemProperty("lholiday")
                        .setValue(utilities.roundOffToTwoDecimalPlaces(Double
                                .parseDouble(item.getItemProperty("lholiday").getValue().toString())
                                + (Double.parseDouble(item.getItemProperty("lholiday").getValue().toString())
                                        * premiumRate)));

                item.getItemProperty("sholiday")
                        .setValue(utilities.roundOffToTwoDecimalPlaces(Double
                                .parseDouble(item.getItemProperty("sholiday").getValue().toString())
                                + (Double.parseDouble(item.getItemProperty("sholiday").getValue().toString())
                                        * premiumRate)));
            }
        });

        lates.addListener(new FieldEvents.TextChangeListener() {

            @Override
            public void textChange(FieldEvents.TextChangeEvent event) {
                Object itemId = lates.getData();
                Item item = table.getItem(itemId);
                String policyStr = item.getItemProperty("policy").toString();
                String holidayStr = item.getItemProperty("holidays").toString();
                double lateDeduction;

                boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim());
                if (!checkIfInputIsInteger) {
                    getWindow().showNotification("Enter numeric format for lates!",
                            Window.Notification.TYPE_WARNING_MESSAGE);
                    return;
                }

                if (!event.getText().isEmpty()) {
                    if (utilities.convertStringToInteger(event.getText().trim()) > 5) {
                        lateDeduction = computation.processEmployeesLates(policyStr, holidayStr,
                                utilities.convertStringToInteger(event.getText().trim()), getEmploymentWage());
                        if (policyStr == null || policyStr.isEmpty()) {
                            item.getItemProperty("l/min")
                                    .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction));
                        } else if (policyStr.equals("working-holiday") && holidayStr.equals("legal-holiday")) {
                            item.getItemProperty("latesLH")
                                    .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction));
                            item.getItemProperty("latesSH").setValue(0.0);
                            item.getItemProperty("latesWO").setValue(0.0);
                            item.getItemProperty("l/min").setValue(0.0);
                        } else if (policyStr.equals("working-holiday")
                                && holidayStr.equals("special-holiday")) {
                            item.getItemProperty("latesLH").setValue(0.0);
                            item.getItemProperty("latesSH")
                                    .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction));
                            item.getItemProperty("latesWO").setValue(0.0);
                            item.getItemProperty("l/min").setValue(0.0);
                        } else if (policyStr.equals("working-day-off")) {
                            item.getItemProperty("latesLH").setValue(0.0);
                            item.getItemProperty("latesSH").setValue(0.0);
                            item.getItemProperty("latesWO")
                                    .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction));
                            item.getItemProperty("l/min").setValue(0.0);
                        }
                    } else {
                        item.getItemProperty("l/min").setValue(0.0);
                    }
                } else {
                    item.getItemProperty("l/min").setValue(0.0);
                }

            }
        });

        undertime.addListener(new FieldEvents.TextChangeListener() {

            @Override
            public void textChange(FieldEvents.TextChangeEvent event) {
                Object itemId = lates.getData();
                Item item = table.getItem(itemId);
                String policyStr = item.getItemProperty("policy").toString();
                String holidayStr = item.getItemProperty("holidays").toString();
                double undertimeDeduction;

                boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim());
                if (!checkIfInputIsInteger) {
                    getWindow().showNotification("Enter numeric format for undertime!",
                            Window.Notification.TYPE_WARNING_MESSAGE);
                    return;
                }

                if (!event.getText().isEmpty()) {
                    undertimeDeduction = computation.processEmployeesUndertime(policyStr, holidayStr,
                            utilities.convertStringToInteger(event.getText().trim()), getEmploymentWage());
                    if (policyStr == null || policyStr.isEmpty()) {
                        item.getItemProperty("u/min")
                                .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction));
                    } else if (policyStr.equals("working-holiday") && holidayStr.equals("legal-holiday")) {
                        item.getItemProperty("undertimeLH")
                                .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction));
                        item.getItemProperty("undertimeSH").setValue(0.0);
                        item.getItemProperty("undertimeWO").setValue(0.0);
                        item.getItemProperty("u/min").setValue(0.0);
                    } else if (policyStr.equals("working-holiday") && holidayStr.equals("special-holiday")) {
                        item.getItemProperty("undertimeLH").setValue(0.0);
                        item.getItemProperty("undertimeSH")
                                .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction));
                        item.getItemProperty("undertimeWO").setValue(0.0);
                        item.getItemProperty("u/min").setValue(0.0);
                    } else if (policyStr.equals("working-day-off")) {
                        item.getItemProperty("undertimeLH").setValue(0.0);
                        item.getItemProperty("undertimeSH").setValue(0.0);
                        item.getItemProperty("undertimeWO")
                                .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction));
                        item.getItemProperty("u/min").setValue(0.0);
                    }
                } else {
                    item.getItemProperty("u/min").setValue(0.0);
                }
            }
        });

        overtime.addListener(new FieldEvents.TextChangeListener() {

            @Override
            public void textChange(FieldEvents.TextChangeEvent event) {
                Object itemId = lates.getData();
                Item item = table.getItem(itemId);
                String policyStr = item.getItemProperty("policy").toString();
                String holidayStr = item.getItemProperty("holidays").toString();
                double overtimeAddition;

                boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim());
                if (!checkIfInputIsInteger) {
                    getWindow().showNotification("Enter numeric format for undertime!",
                            Window.Notification.TYPE_WARNING_MESSAGE);
                    return;
                }

                if (!event.getText().isEmpty()) {
                    overtimeAddition = computation.processEmployeesOvertime(policyStr, holidayStr,
                            Integer.parseInt(event.getText().trim()), getEmploymentWage());
                    item.getItemProperty("o/min").setValue(utilities
                            .roundOffToTwoDecimalPlaces(overtimeAddition + (overtimeAddition * premiumRate)));
                } else {
                    item.getItemProperty("o/min").setValue(0.0);
                }
            }
        });

        nightDifferential.addListener(new FieldEvents.TextChangeListener() {

            @Override
            public void textChange(FieldEvents.TextChangeEvent event) {
                Object itemId = lates.getData();
                Item item = table.getItem(itemId);
                String policyStr = item.getItemProperty("policy").toString();
                String holidayStr = item.getItemProperty("holidays").toString();
                double nightDifferentialAddition;

                boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim());
                if (!checkIfInputIsInteger) {
                    getWindow().showNotification("Enter numeric format for undertime!",
                            Window.Notification.TYPE_WARNING_MESSAGE);
                    return;
                }

                if (!event.getText().isEmpty()) {
                    nightDifferentialAddition = computation.processEmployeesNightDifferential(policyStr,
                            holidayStr, Integer.parseInt(event.getText().trim()), getEmploymentWage());
                    item.getItemProperty("nd/min").setValue(utilities.roundOffToTwoDecimalPlaces(
                            nightDifferentialAddition + (nightDifferentialAddition * premiumRate)));
                } else {
                    item.getItemProperty("nd/min").setValue(0.0);
                }
            }
        });

        List<Timekeeping> timekeepingListByRowData = timekeepingService.getTimekeepingRowData(
                utilities.convertDateFormat(getDateList().get(i).toString()), getPayrollId());

        for (Timekeeping t : timekeepingListByRowData) {
            String policy;
            String holiday;
            if (!t.getPolicy().equals("null")) {
                policy = t.getPolicy();
            } else {
                policy = "";
            }

            if (!t.getHoliday().equals("null")) {
                holiday = t.getHoliday();
            } else {
                holiday = "";
            }

            premium.setValue(t.isPremium());

            lates.setValue(t.getLates());
            undertime.setValue(t.getUndertime());
            overtime.setValue(t.getOvertime());
            nightDifferential.setValue(t.getNightDifferential());
            table.addItem(
                    new Object[] { edit, utilities.convertDateFormat(getDateList().get(i).toString()), policy,
                            holiday, premium, lates, undertime, overtime, nightDifferential,
                            t.getLateDeduction(), t.getUndertimeDeduction(), t.getOvertimePaid(),
                            t.getNightDifferentialPaid(), t.getLegalHolidayPaid(), t.getSpecialHolidayPaid(),
                            t.getWorkingDayOffPaid(), t.getNonWorkingHolidayPaid(),
                            t.getLatesLegalHolidayDeduction(), t.getLatesSpecialHolidayDeduction(),
                            t.getLatesWorkingDayOffDeduction(), t.getUndertimeLegalHolidayDeduction(),
                            t.getUndertimeSpecialHolidayDeduction(), t.getUndertimeWorkingDayOffDeduction() },
                    new Integer(i));
        }
    }
    table.setPageLength(table.size());

    for (Object listener : table.getListeners(ItemClickEvent.class)) {
        table.removeListener(ItemClickEvent.class, listener);
    }

    table.addListener(new ItemClickEvent.ItemClickListener() {

        @Override
        public void itemClick(ItemClickEvent event) {
            final Object itemId = event.getItemId();
            final Item item = table.getItem(itemId);

            Boolean editRow = Boolean.valueOf(item.getItemProperty("edit").getValue().toString());

            if (event.getPropertyId().equals("policy")) {
                if (editRow) {
                    Window sub = new AttendancePolicyWindow(holidayList, item, getEmploymentWageEntry(),
                            getEmploymentWage());
                    if (sub.getParent() == null) {
                        getApplication().getMainWindow().addWindow(sub);
                    }
                } else {
                    getWindow().showNotification("Click Edit!", Window.Notification.TYPE_WARNING_MESSAGE);
                }
            }
        }
    });

    vlayout.addComponent(table);

    final Button saveButton = new Button();
    saveButton.setWidth("200px");
    saveButton.setCaption("UPDATE ATTENDANCE DATA");
    saveButton.setEnabled(UserAccessControl.isEditAttendance());

    for (Object listener : saveButton.getListeners(Button.ClickListener.class)) {
        saveButton.removeListener(Button.ClickListener.class, listener);
    }

    GridLayout glayout = new GridLayout(2, 1);
    glayout.setSizeFull();
    glayout.setSpacing(true);

    saveButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                Collection attendanceTableCollection = table.getContainerDataSource().getItemIds();
                List<Timekeeping> attendanceList = new ArrayList<>();
                Iterator iterator = attendanceTableCollection.iterator();
                while (iterator.hasNext()) {
                    String str = table.getItem(iterator.next()).toString();
                    String[] attStr = str.split(" ");
                    List<String> tkeepList = new ArrayList<>(Arrays.asList(attStr));

                    Timekeeping t = new Timekeeping();
                    t.setAttendanceDate(utilities.parsingDate(tkeepList.get(1)));
                    t.setPolicy(tkeepList.get(2));
                    t.setHoliday(tkeepList.get(3));
                    t.setPremium(utilities.convertStringToBoolean(tkeepList.get(4)));
                    t.setLates(utilities.convertStringToDouble(tkeepList.get(5)));
                    t.setUndertime(utilities.convertStringToDouble(tkeepList.get(6)));
                    t.setOvertime(utilities.convertStringToDouble(tkeepList.get(7)));
                    t.setNightDifferential(utilities.convertStringToDouble(tkeepList.get(8)));
                    t.setLateDeduction(utilities.convertStringToDouble(tkeepList.get(9)));
                    t.setUndertimeDeduction(utilities.convertStringToDouble(tkeepList.get(10)));
                    t.setOvertimePaid(utilities.convertStringToDouble(tkeepList.get(11)));
                    t.setNightDifferentialPaid(utilities.convertStringToDouble(tkeepList.get(12)));
                    t.setLegalHolidayPaid(utilities.convertStringToDouble(tkeepList.get(13)));
                    t.setSpecialHolidayPaid(utilities.convertStringToDouble(tkeepList.get(14)));
                    t.setWorkingDayOffPaid(utilities.convertStringToDouble(tkeepList.get(15)));
                    t.setNonWorkingHolidayPaid(utilities.convertStringToDouble(tkeepList.get(16)));
                    t.setLatesLegalHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(17)));
                    t.setLatesSpecialHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(18)));
                    t.setLatesWorkingDayOffDeduction(utilities.convertStringToDouble(tkeepList.get(19)));
                    t.setUndertimeLegalHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(20)));
                    t.setUndertimeSpecialHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(21)));
                    t.setUndertimeWorkingDayOffDeduction(utilities.convertStringToDouble(tkeepList.get(22)));
                    attendanceList.add(t);
                }

                ProcessPayrollComputation processPayroll = new ProcessPayrollComputation(getEmployeeId(),
                        getBranchId());
                processPayroll.initVariables();
                processPayroll.initVariablesForComputation(attendanceList);
                boolean result = processPayroll.processPayrollComputation(payrollDate, payrollPeriod,
                        attendancePeriodFrom, attendancePeriodTo, getPayrollId());
                if (result) {
                    close();
                } else {
                    getWindow().showNotification("SQL ERROR");
                }
            } catch (Exception e) {
                e.getMessage();
            }
        }

    });
    glayout.addComponent(saveButton, 0, 0);
    glayout.setComponentAlignment(saveButton, Alignment.MIDDLE_LEFT);
    //        vlayout.addComponent(saveButton);

    Button printButton = new Button("PRINT ATTENDANCE");
    printButton.setWidth("200px");
    printButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            OpenHrisReports reports = new OpenHrisReports(0, null);
            String fileName = "IndividualAttendanceReport_";
            reports.deleteFile(fileName);
            Window reportWindow = new IndividualAttendanceReport(getPayrollId(), getApplication());
        }
    });
    glayout.addComponent(printButton, 1, 0);
    glayout.setComponentAlignment(printButton, Alignment.MIDDLE_RIGHT);

    vlayout.addComponent(glayout);

    return vlayout;
}