package com.rjconsultores.ventaboletos.web.utilerias.render;

import java.util.Date;

import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.ListitemRenderer;

import com.rjconsultores.ventaboletos.utilerias.DateUtil;
import com.rjconsultores.ventaboletos.vo.comissao.ConferenciaComissaoVO;
import com.rjconsultores.ventaboletos.vo.comissao.DiaConferenciaComissaoVO;

public class RenderConferenciaComissao implements ListitemRenderer {

	@Override
	public void render(Listitem lstm, Object o) throws Exception {
		ConferenciaComissaoVO conferenciaComissao = (ConferenciaComissaoVO) o;
		
		Listcell lc = new Listcell(conferenciaComissao.getNumPuntoVenta());
        lc.setParent(lstm);

        lc = new Listcell(conferenciaComissao.getNombpuntoventa());
        lc.setParent(lstm);
        
        Date dataAtual = DateUtil.normalizarToFecha(new Date());
        for (DiaConferenciaComissaoVO diaConferenciaComissao : conferenciaComissao.getDiasOrdenado()) {
        	lc = new Listcell();
        	
        	if(dataAtual.compareTo(diaConferenciaComissao.getData()) >= 0) {
        		lc.setId(conferenciaComissao.getPuntoventaId() + "-" + diaConferenciaComissao.getDia());
        		lc.addForward("onDoubleClick", lstm.getParent(), "onDoubleClick");
        		lc.setImage(diaConferenciaComissao.getCor().getUrl());
        	}
        	
        	lc.setParent(lstm);
		}

        lstm.setAttribute("data", conferenciaComissao);
		
	}

}
