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

import java.text.SimpleDateFormat;

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

import com.rjconsultores.ventaboletos.entidad.AuditLog;
import com.rjconsultores.ventaboletos.enums.auditoria.EnumAuditAction;

public class RenderAudit implements ListitemRenderer {

	@Override
	public void render(Listitem item, Object o) throws Exception {
		
		AuditLog auditLog = (AuditLog) o;

		Listcell lc = new Listcell();
		
		SimpleDateFormat sdf = new SimpleDateFormat();
		sdf.applyPattern("dd/MM/yyyy");

		lc = new Listcell(sdf.format(auditLog.getCreatedDate()));
		
		lc.setParent(item);

		lc = new Listcell(auditLog.getSistema().getNombsistema());
		lc.setParent(item);

		lc = new Listcell(auditLog.getService().getModule().getNameModule());
		lc.setParent(item);
		
		lc = new Listcell(EnumAuditAction.findAction(auditLog.getAction()));
		lc.setParent(item);
		
		lc = new Listcell(auditLog.getEntityName());
		lc.setParent(item);
		
		lc = new Listcell(auditLog.getUsuario().getNombusuario());
		lc.setParent(item);
		
		item.setAttribute("data", auditLog);
	}
}
