/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.arrebol.apc.web.beans.admin;

import com.arrebol.apc.controller.system.employee.EmployeeController;
import com.arrebol.apc.model.core.HumanResource;
import com.arrebol.apc.model.core.Office;
import com.arrebol.apc.model.enums.HumanResourceStatus;
import com.arrebol.apc.web.beans.Datatable;
import com.arrebol.apc.web.beans.GenericBean;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.view.ViewScoped;
import javax.inject.Named;
import org.primefaces.event.ReorderEvent;
import org.primefaces.event.RowEditEvent;

/**
 *
 * @author Oscar
 */
@Named("employeeListManager")
@ViewScoped
public class EmployeeListBean extends GenericBean implements Serializable, Datatable  {
    

    
    
    public List<HumanResource> fillDatatableEmployee() {
        return getController().findEmployeesByType(
                        getLoggedUser().getOffice(),
                        HumanResourceStatus.ENEBLED,
                        getLoggedUser().getUser().getHumanResource().getId());
    }
    
    
    @Override
    public void editRow(RowEditEvent event) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
    }

    @Override
    public void onRowCancel(RowEditEvent event) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void onRowReorder(ReorderEvent event) {
        showMessage(FacesMessage.SEVERITY_INFO, "Registro Movido", "De columna: " + (event.getFromIndex() + 1) + " a columna: " + (event.getToIndex() + 1));
    }

    @Override
    public void addRow() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void deleteRow() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    public EmployeeController getController() {
        return controller;
    }

    public void setController(EmployeeController controller) {
        this.controller = controller;
    }

    public List<HumanResource> getHumanResource() {
        return humanResource;
    }

    public void setHumanResource(List<HumanResource> humanResource) {
        this.humanResource = humanResource;
    }


    private EmployeeController controller;

    private List<HumanResource> humanResource;
            

    @PostConstruct()
    public void init() {
        loadBundlePropertyFile();
        
        controller = new EmployeeController();
        

        setHumanResource(fillDatatableEmployee());
    }

}
