/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rjconsultores.ventaboletos.web.utilerias.render;

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

import com.rjconsultores.ventaboletos.entidad.PerfilFuncion;

/**
 * 
 * @author rodrigo
 */
public class RenderPermiso implements ListitemRenderer {

	public void render(Listitem lstm, Object o) throws Exception {
		PerfilFuncion permiso = (PerfilFuncion) o;

		Checkbox chkRead = new Checkbox();
		chkRead.setDisabled(Boolean.TRUE);
		Checkbox chkWrite = new Checkbox();
		chkWrite.setDisabled(Boolean.TRUE);

		Listcell lc = new Listcell(permiso.getFuncionSistema().toString());
		lc.setParent(lstm);

		lc = new Listcell();
		
		boolean indLectura = permiso.getIndLectura() == null ? false : permiso.getIndLectura();
		if (indLectura) {
			chkRead.setChecked(Boolean.TRUE);
		}
		lc.appendChild(chkRead);
		lc.setParent(lstm);

		lc = new Listcell();

		if (!indLectura) {
			chkWrite.setChecked(Boolean.TRUE);
		}
		lc.appendChild(chkWrite);
		lc.setParent(lstm);

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