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

import com.rjconsultores.ventaboletos.entidad.TarifaOficial;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;

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

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

    public void render(Listitem lstm, Object o) throws Exception {
        TarifaOficial t = (TarifaOficial) o;

        DecimalFormat df = new DecimalFormat("###,###,##0.00", new java.text.DecimalFormatSymbols(java.util.Locale.US));

        Listcell lc = new Listcell(t.getTarifaOficialId().toString());
        lc.setParent(lstm);

        if (t.getPrecio() != null) {
            lc = new Listcell(df.format(t.getPrecio()));
        } else {
            lc = new Listcell("");
        }
        lc.setParent(lstm);

        if (t.getPreciooriginal() != null) {
            lc = new Listcell(df.format(t.getPreciooriginal()));
        } else {
            lc = new Listcell("");
        }
        lc.setParent(lstm);

        lc = new Listcell(t.getImportepedagio() == null ? "" : df.format(t.getImportepedagio()));
        lc.setParent(lstm);
        lc = new Listcell(t.getImportetaxaembarque() == null ? "" : df.format(t.getImportetaxaembarque()));
        lc.setParent(lstm);
        lc = new Listcell(t.getImporteseguro() == null ? "" : df.format(t.getImporteseguro()));
        lc.setParent(lstm);
        lc = new Listcell(t.getImporteoutros() == null ? "" : df.format(t.getImporteoutros()));
        lc.setParent(lstm);


        if (t.getTramo() != null) {
            lc = new Listcell(t.getTramo().getOrigem().getDescparada());
            lc.setParent(lstm);
            lc = new Listcell(t.getTramo().getDestino().getDescparada());
            lc.setParent(lstm);
            lc = new Listcell(t.getTramo().getVia().getNombvia());
            lc.setParent(lstm);
        } else {
            lc = new Listcell("");
            lc.setParent(lstm);
            lc = new Listcell("");
            lc.setParent(lstm);
            lc = new Listcell("");
            lc.setParent(lstm);
        }



        if (t.getMarca() != null) {
            lc = new Listcell(t.getMarca().getDescmarca());
        } else {
            lc = new Listcell("");
        }
        lc.setParent(lstm);



        if (t.getClaseServicio() != null) {
            lc = new Listcell(t.getClaseServicio().getDescclase());
        } else {
            lc = new Listcell("");
        }
        lc.setParent(lstm);

        if (t.getOrgaoConcedente() != null) {
            lc = new Listcell(t.getOrgaoConcedente().getDescOrgao());
        } else {
            lc = new Listcell("");
        }
        lc.setParent(lstm);

        if (t.getRuta() != null) {
            lc = new Listcell(t.getRuta().getPrefixo());
        } else {
            lc = new Listcell("");
        }
        lc.setParent(lstm);

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