Example usage for com.itextpdf.text Section add

List of usage examples for com.itextpdf.text Section add

Introduction

In this page you can find the example usage for com.itextpdf.text Section add.

Prototype

@Override
public boolean add(final Element element) 

Source Link

Document

Adds a Paragraph, List, Table or another Section to this Section.

Usage

From source file:report.pdfs.Vet_Visit_PDF_Report.java

private void addPieChart(Section catPart) {
    Vet_Visit_Pie_Chart_Report chart = new Vet_Visit_Pie_Chart_Report(show, "Comparison",
            "Vet Visit Expenses Overview");
    Image To_be_Added = null;/*from  ww  w . j a v  a2s  .c o m*/
    try {
        To_be_Added = Image.getInstance("pie_chart.png");
    } catch (BadElementException e) {
        e.printStackTrace();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    To_be_Added.setAlignment(Image.MIDDLE | Image.TEXTWRAP);
    //To_be_Added.setBorder(Image.BOX);
    //To_be_Added.setBorderWidth(15);

    catPart.add(To_be_Added);
}

From source file:report.pdfs.Water_PDF_Report.java

private void createTable(Section catPart) throws BadElementException {
    PdfPTable table = new PdfPTable(4);
    table.setSpacingBefore(25);/*from  ww w .  jav  a2  s . co m*/
    // t.setBorderColor(BaseColor.GRAY);
    // t.setPadding(4);
    // t.setSpacing(4);
    // t.setBorderWidth(1);

    PdfPCell c1 = new PdfPCell(new Phrase("Type"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Expense"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Month"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Year"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    table.setHeaderRows(1);

    selectAll();
    calcWExpense(table);

    catPart.add(table);
}

From source file:report.pdfs.Water_PDF_Report.java

private void addBarChart(Section catPart) {
    Water_Bar_Chart_Report chart = new Water_Bar_Chart_Report(show, "Water Expenses Overview");
    Image To_be_Added = null;//w w w  .  ja v a  2 s  . c  om
    try {
        To_be_Added = Image.getInstance("bar_chart.png");
    } catch (BadElementException e) {
        e.printStackTrace();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    To_be_Added.setAlignment(Image.MIDDLE | Image.TEXTWRAP);
    //To_be_Added.setBorder(Image.BOX);
    //To_be_Added.setBorderWidth(15);

    catPart.add(To_be_Added);
}

From source file:report.pdfs.Water_PDF_Report.java

private void addPieChart(Section catPart) {
    Water_Pie_Chart_Report chart = new Water_Pie_Chart_Report(show, "Comparison", "Water Expenses Overview");
    Image To_be_Added = null;//from www  . j ava 2 s .co m
    try {
        To_be_Added = Image.getInstance("pie_chart.png");
    } catch (BadElementException e) {
        e.printStackTrace();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    To_be_Added.setAlignment(Image.MIDDLE | Image.TEXTWRAP);
    //To_be_Added.setBorder(Image.BOX);
    //To_be_Added.setBorderWidth(15);

    catPart.add(To_be_Added);
}

From source file:sipl.recursos.GenerarPDFGrafica.java

private void createTable(Section subCatPart) throws BadElementException {
    String p = Titulo.charAt(0) + "";
    if (p.equals("P")) {
        ArrayList<Prestamo> prestamos = preDAO.getRangoFecha_prestamo(fecha1, fecha2);
        ArrayList<Material> materiales = matDAO.getMateriales();
        if (rango.equals("Anho")) {
            int T[][] = new int[materiales.size()][2];
            for (int i = 0; i < materiales.size(); i++) {
                T[i][0] = materiales.get(i).getCodigo();
                T[i][1] = 0;/*from ww w  .  j  a  v a 2 s  . c o m*/
            }
            for (int i = 0; i < prestamos.size(); i++) {
                String[] P = prestamos.get(i).getMat().split(";");
                for (String P1 : P) {
                    for (int k = 0; k < materiales.size(); k++) {
                        int c;
                        if (T[k][0] == Integer.parseInt(P1)) {
                            c = T[k][1];
                            c++;
                            T[k][1] = c;
                            k = materiales.size();
                        }
                    }
                }
            }
            PdfPTable table = new PdfPTable(2);
            PdfPCell c1 = new PdfPCell(new Phrase("Categora Material"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase("Cantidad Material"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            table.setHeaderRows(1);
            if (prestamos.isEmpty()) {
                table.addCell("No hay prstamos en ese rango de fecha");
            } else {
                ArrayList<Tipo_material> tm = tipDAO.getTipo_material();
                int TM[][] = new int[tm.size()][2];
                for (int i = 0; i < tm.size(); i++) {
                    TM[i][0] = tm.get(i).getId();
                    TM[i][1] = 0;
                }
                for (int i = 0; i < T.length; i++) {
                    int c;
                    Material mat = matDAO.getMaterial(T[i][0]);
                    for (int j = 0; j < TM.length; j++) {
                        if (TM[j][0] == mat.getTipo_mat().getId()) {
                            c = TM[j][1];
                            c += T[i][1];
                            TM[j][1] = c;
                            j = tm.size();
                        }
                    }
                }
                for (int i = 0; i < TM.length; i++) {
                    if (TM[i][1] > 0) {
                        Tipo_material tip = tipDAO.getTipo_material(TM[i][0]);
                        table.addCell("" + tip.getNombre());
                        table.addCell("" + TM[i][1]);
                    }
                }
            }
            table.addCell("");
            table.addCell("");
            table.addCell("Ao");
            table.addCell("Cantidad Prstamos");
            String[] f1 = fecha1.split("/");
            int a = Integer.parseInt(f1[0]);
            String[] f2 = fecha2.split("/");
            int b = Integer.parseInt(f2[0]);
            int dif = b - a;
            dif++;
            int tamY[][] = new int[dif][2];
            for (int i = 0; i < dif; i++) {
                tamY[i][0] = a;
                a++;
            }
            for (int j = 0; j < dif; j++) {
                tamY[j][1] = 0;
            }
            for (int k = 0; k < prestamos.size(); k++) {
                int t = prestamos.get(k).getFecha_prestamo().get(Calendar.YEAR);
                for (int l = 0; l < dif; l++) {
                    if (tamY[l][0] == t) {
                        int cant = tamY[l][1];
                        cant++;
                        tamY[l][1] = cant;
                    }
                }
            }
            for (int i = 0; i < dif; i++) {
                if (tamY[i][1] > 0) {
                    table.addCell("" + tamY[i][0]);
                    table.addCell("" + tamY[i][1]);
                }
            }
            subCatPart.add(table);
        } else if (rango.equals("Mes")) {
            int T[][] = new int[materiales.size()][2];
            for (int i = 0; i < materiales.size(); i++) {
                T[i][0] = materiales.get(i).getCodigo();
                T[i][1] = 0;
            }
            for (int i = 0; i < prestamos.size(); i++) {
                String[] P = prestamos.get(i).getMat().split(";");
                for (String P1 : P) {
                    for (int k = 0; k < materiales.size(); k++) {
                        int c;
                        if (T[k][0] == Integer.parseInt(P1)) {
                            c = T[k][1];
                            c++;
                            T[k][1] = c;
                            k = materiales.size();
                        }
                    }
                }
            }
            PdfPTable table = new PdfPTable(2);
            PdfPCell c1 = new PdfPCell(new Phrase("Categora Material"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase("Cantidad Material"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            table.setHeaderRows(1);
            if (prestamos.isEmpty()) {
                table.addCell("No hay prstamos en ese rango de fecha");
            } else {
                ArrayList<Tipo_material> tm = tipDAO.getTipo_material();
                int TM[][] = new int[tm.size()][2];
                for (int i = 0; i < tm.size(); i++) {
                    TM[i][0] = tm.get(i).getId();
                    TM[i][1] = 0;
                }
                for (int i = 0; i < T.length; i++) {
                    int c;
                    Material mat = matDAO.getMaterial(T[i][0]);
                    for (int j = 0; j < TM.length; j++) {
                        if (TM[j][0] == mat.getTipo_mat().getId()) {
                            c = TM[j][1];
                            c += T[i][1];
                            TM[j][1] = c;
                            j = tm.size();
                        }
                    }
                }
                for (int i = 0; i < TM.length; i++) {
                    if (TM[i][1] > 0) {
                        Tipo_material tip = tipDAO.getTipo_material(TM[i][0]);
                        table.addCell("" + tip.getNombre());
                        table.addCell("" + TM[i][1]);
                    }
                }
            }
            table.addCell("");
            table.addCell("");
            table.addCell("Mes");
            table.addCell("Cantidad Prstamos");
            String[] meses = { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto",
                    "Septiembre", "Octubre", "Noviembre", "Diciembre" };
            int tamY[][] = new int[12][2];
            for (int i = 0; i < 12; i++) {
                tamY[i][0] = i;
            }
            for (int j = 0; j < 12; j++) {
                tamY[j][1] = 0;
            }
            for (int k = 0; k < prestamos.size(); k++) {
                int t = prestamos.get(k).getFecha_prestamo().get(Calendar.MONTH);
                for (int l = 0; l < 12; l++) {
                    if (tamY[l][0] == t) {
                        int cant = tamY[l][1];
                        cant++;
                        tamY[l][1] = cant;
                    }
                }
            }
            for (int i = 0; i < 12; i++) {
                if (tamY[i][1] > 0) {
                    table.addCell("" + meses[i]);
                    table.addCell("" + tamY[i][1]);
                }
            }
            subCatPart.add(table);
        } else if (rango.equals("Dia")) {
            int T[][] = new int[materiales.size()][2];
            for (int i = 0; i < materiales.size(); i++) {
                T[i][0] = materiales.get(i).getCodigo();
                T[i][1] = 0;
            }
            for (int i = 0; i < prestamos.size(); i++) {
                String[] P = prestamos.get(i).getMat().split(";");
                for (String P1 : P) {
                    for (int k = 0; k < materiales.size(); k++) {
                        int c;
                        if (T[k][0] == Integer.parseInt(P1)) {
                            c = T[k][1];
                            c++;
                            T[k][1] = c;
                            k = materiales.size();
                        }
                    }
                }
            }
            PdfPTable table = new PdfPTable(2);
            PdfPCell c1 = new PdfPCell(new Phrase("Categora Material"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase("Cantidad Material"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            table.setHeaderRows(1);
            if (prestamos.isEmpty()) {
                table.addCell("No hay prstamos en ese rango de fecha");
            } else {
                ArrayList<Tipo_material> tm = tipDAO.getTipo_material();
                int TM[][] = new int[tm.size()][2];
                for (int i = 0; i < tm.size(); i++) {
                    TM[i][0] = tm.get(i).getId();
                    TM[i][1] = 0;
                }
                for (int i = 0; i < T.length; i++) {
                    int c;
                    Material mat = matDAO.getMaterial(T[i][0]);
                    for (int j = 0; j < TM.length; j++) {
                        if (TM[j][0] == mat.getTipo_mat().getId()) {
                            c = TM[j][1];
                            c += T[i][1];
                            TM[j][1] = c;
                            j = tm.size();
                        }
                    }
                }
                for (int i = 0; i < TM.length; i++) {
                    if (TM[i][1] > 0) {
                        Tipo_material tip = tipDAO.getTipo_material(TM[i][0]);
                        table.addCell("" + tip.getNombre());
                        table.addCell("" + TM[i][1]);
                    }
                }
            }
            table.addCell("");
            table.addCell("");
            table.addCell("Dia");
            table.addCell("Cantidad Prstamos");
            int tamY[][] = new int[32][2];
            for (int i = 0; i < 32; i++) {
                tamY[i][0] = i;
            }
            for (int j = 0; j < 32; j++) {
                tamY[j][1] = 0;
            }
            for (int k = 0; k < prestamos.size(); k++) {
                int t = prestamos.get(k).getFecha_prestamo().get(Calendar.DAY_OF_MONTH);
                for (int l = 0; l < 32; l++) {
                    if (tamY[l][0] == t) {
                        int cant = tamY[l][1];
                        cant++;
                        tamY[l][1] = cant;
                    }
                }
            }
            for (int i = 0; i < 32; i++) {
                if (tamY[i][1] > 0) {
                    table.addCell("" + i);
                    table.addCell("" + tamY[i][1]);
                }
            }
            subCatPart.add(table);
        } else if (rango.equals("Hora")) {
            int T[][] = new int[materiales.size()][2];
            for (int i = 0; i < materiales.size(); i++) {
                T[i][0] = materiales.get(i).getCodigo();
                T[i][1] = 0;
            }
            for (int i = 0; i < prestamos.size(); i++) {
                String[] P = prestamos.get(i).getMat().split(";");
                for (String P1 : P) {
                    for (int k = 0; k < materiales.size(); k++) {
                        int c;
                        if (T[k][0] == Integer.parseInt(P1)) {
                            c = T[k][1];
                            c++;
                            T[k][1] = c;
                            k = materiales.size();
                        }
                    }
                }
            }
            PdfPTable table = new PdfPTable(2);
            PdfPCell c1 = new PdfPCell(new Phrase("Categora Material"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase("Cantidad Material"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            table.setHeaderRows(1);
            if (prestamos.isEmpty()) {
                table.addCell("No hay prstamos en ese rango de fecha");
            } else {
                ArrayList<Tipo_material> tm = tipDAO.getTipo_material();
                int TM[][] = new int[tm.size()][2];
                for (int i = 0; i < tm.size(); i++) {
                    TM[i][0] = tm.get(i).getId();
                    TM[i][1] = 0;
                }
                for (int i = 0; i < T.length; i++) {
                    int c;
                    Material mat = matDAO.getMaterial(T[i][0]);
                    for (int j = 0; j < TM.length; j++) {
                        if (TM[j][0] == mat.getTipo_mat().getId()) {
                            c = TM[j][1];
                            c += T[i][1];
                            TM[j][1] = c;
                            j = tm.size();
                        }
                    }
                }
                for (int i = 0; i < TM.length; i++) {
                    if (TM[i][1] > 0) {
                        Tipo_material tip = tipDAO.getTipo_material(TM[i][0]);
                        table.addCell("" + tip.getNombre());
                        table.addCell("" + TM[i][1]);
                    }
                }
            }
            table.addCell("");
            table.addCell("");
            table.addCell("Hora");
            table.addCell("Cantidad Prstamos");
            int tamY[][] = new int[24][2];
            for (int i = 0; i < 24; i++) {
                tamY[i][0] = i;
            }
            for (int j = 0; j < 24; j++) {
                tamY[j][1] = 0;
            }
            for (int k = 0; k < prestamos.size(); k++) {
                int t = prestamos.get(k).getFecha_prestamo().get(Calendar.HOUR_OF_DAY);
                for (int l = 0; l < 24; l++) {
                    if (tamY[l][0] == t) {
                        int cant = tamY[l][1];
                        cant++;
                        tamY[l][1] = cant;
                    }
                }
            }
            for (int i = 0; i < 24; i++) {
                if (tamY[i][1] > 0) {
                    table.addCell("" + i);
                    table.addCell("" + tamY[i][1]);
                }
            }
            subCatPart.add(table);
        }
    } else if (p.equals("M")) {
        ArrayList<Multa> multas = mulDAO.getRangoFecha_multa(fecha1, fecha2);
        if (rango.equals("Anho")) {
            PdfPTable table = new PdfPTable(2);
            PdfPCell c1 = new PdfPCell(new Phrase("Ao"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase("Cantidad Multas"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            table.setHeaderRows(1);
            if (multas.isEmpty()) {
                table.addCell("No hay multas en ese rango de fecha");
            } else {
                String[] f1 = fecha1.split("/");
                int a = Integer.parseInt(f1[0]);
                String[] f2 = fecha2.split("/");
                int b = Integer.parseInt(f2[0]);
                int dif = b - a;
                dif++;

                int tamY[][] = new int[dif][2];
                int u = a;
                for (int i = 0; i < dif; i++) {
                    tamY[i][0] = u;
                    u++;
                }
                for (int j = 0; j < dif; j++) {
                    tamY[j][1] = 0;
                }
                for (int k = 0; k < multas.size(); k++) {
                    int t = multas.get(k).getFecha_multa().get(Calendar.YEAR);
                    for (int l = 0; l < dif; l++) {
                        if (tamY[l][0] == t) {
                            int cant = tamY[l][1];
                            cant++;
                            tamY[l][1] = cant;
                        }
                    }
                }
                for (int i = 0; i < dif; i++) {
                    if (tamY[i][1] > 0) {
                        table.addCell("" + tamY[i][0]);
                        table.addCell("" + tamY[i][1]);
                    }
                }
            }
            subCatPart.add(table);
        } else if (rango.equals("Mes")) {
            PdfPTable table = new PdfPTable(2);
            PdfPCell c1 = new PdfPCell(new Phrase("Mes"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase("Cantidad Multas"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            table.setHeaderRows(1);
            if (multas.isEmpty()) {
                table.addCell("No hay multas en ese rango de fecha");
            } else {
                String[] meses = { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto",
                        "Septiembre", "Octubre", "Noviembre", "Diciembre" };
                int tamY[][] = new int[12][2];
                for (int i = 0; i < 12; i++) {
                    tamY[i][0] = i;
                }
                for (int j = 0; j < 12; j++) {
                    tamY[j][1] = 0;
                }
                for (int k = 0; k < multas.size(); k++) {
                    int t = multas.get(k).getFecha_multa().get(Calendar.MONTH);
                    for (int l = 0; l < 12; l++) {
                        if (tamY[l][0] == t) {
                            int cant = tamY[l][1];
                            cant++;
                            tamY[l][1] = cant;
                        }
                    }
                }
                for (int i = 0; i < 12; i++) {
                    if (tamY[i][1] > 0) {
                        table.addCell("" + meses[i]);
                        table.addCell("" + tamY[i][1]);
                    }
                }
            }
            subCatPart.add(table);
        } else if (rango.equals("Dia")) {
            PdfPTable table = new PdfPTable(2);
            PdfPCell c1 = new PdfPCell(new Phrase("Da del mes"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase("Cantidad Multas"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            table.setHeaderRows(1);
            if (multas.isEmpty()) {
                table.addCell("No hay multas en ese rango de fecha");
            } else {
                int tamY[][] = new int[32][2];
                for (int i = 0; i < 32; i++) {
                    tamY[i][0] = i;
                }
                for (int j = 0; j < 32; j++) {
                    tamY[j][1] = 0;
                }
                for (int k = 0; k < multas.size(); k++) {
                    int t = multas.get(k).getFecha_multa().get(Calendar.DAY_OF_MONTH);
                    for (int l = 0; l < 32; l++) {
                        if (tamY[l][0] == t) {
                            int cant = tamY[l][1];
                            cant++;
                            tamY[l][1] = cant;
                        }
                    }
                }
                for (int i = 0; i < 32; i++) {
                    if (tamY[i][1] > 0) {
                        table.addCell("" + i);
                        table.addCell("" + tamY[i][1]);
                    }
                }
            }
            subCatPart.add(table);
        } else if (rango.equals("Hora")) {
            PdfPTable table = new PdfPTable(2);
            PdfPCell c1 = new PdfPCell(new Phrase("Hora del da"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase("Cantidad Multas"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            table.setHeaderRows(1);
            if (multas.isEmpty()) {
                table.addCell("No hay multas en ese rango de fecha");
            } else {
                int tamY[][] = new int[24][2];
                for (int i = 0; i < 24; i++) {
                    tamY[i][0] = i;
                }
                for (int j = 0; j < 24; j++) {
                    tamY[j][1] = 0;
                }
                for (int k = 0; k < multas.size(); k++) {
                    int t = multas.get(k).getFecha_multa().get(Calendar.HOUR_OF_DAY);
                    for (int l = 0; l < 24; l++) {
                        if (tamY[l][0] == t) {
                            int cant = tamY[l][1];
                            cant++;
                            tamY[l][1] = cant;
                        }
                    }
                }
                for (int i = 0; i < 24; i++) {
                    if (tamY[i][1] > 0) {
                        table.addCell("" + i);
                        table.addCell("" + tamY[i][1]);
                    }
                }
            }
            subCatPart.add(table);
        }
    } else if (p.equals("D")) {
        ArrayList<Danho> danhos = danDAO.getRangoFecha_danhos(fecha1, fecha2);
        ArrayList<Material> materiales = matDAO.getMateriales();
        if (rango.equals("Anho")) {
            PdfPTable table = new PdfPTable(2);
            PdfPCell c1 = new PdfPCell(new Phrase("Categora Material"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase("Cantidad Material"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            table.setHeaderRows(1);
            if (danhos.isEmpty()) {
                table.addCell("No hay daos en ese rango de fecha");
            } else {
                int T[][] = new int[materiales.size()][2];
                for (int i = 0; i < materiales.size(); i++) {
                    T[i][0] = materiales.get(i).getCodigo();
                    T[i][1] = 0;
                }
                for (int i = 0; i < danhos.size(); i++) {
                    int P = danhos.get(i).getMat().getCodigo();
                    for (int k = 0; k < materiales.size(); k++) {
                        int c = 0;
                        if (T[k][0] == P) {
                            c = T[k][1];
                            c++;
                            T[k][1] = c;
                            k = materiales.size();
                        }
                    }
                }
                ArrayList<Tipo_material> tm = tipDAO.getTipo_material();
                int TM[][] = new int[tm.size()][2];
                for (int i = 0; i < tm.size(); i++) {
                    TM[i][0] = tm.get(i).getId();
                    TM[i][1] = 0;
                }
                for (int i = 0; i < T.length; i++) {
                    int c = 0;
                    Material mat = matDAO.getMaterial(T[i][0]);
                    for (int j = 0; j < TM.length; j++) {
                        if (TM[j][0] == mat.getTipo_mat().getId()) {
                            c = TM[j][1];
                            c += T[i][1];
                            TM[j][1] = c;
                            j = tm.size();
                        }
                    }
                }
                for (int i = 0; i < TM.length; i++) {
                    if (TM[i][1] > 0) {
                        Tipo_material tip = tipDAO.getTipo_material(TM[i][0]);
                        table.addCell("" + tip.getNombre());
                        table.addCell("" + TM[i][1]);
                    }
                }
                c1 = new PdfPCell(new Phrase("Ao"));
                c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(c1);
                c1 = new PdfPCell(new Phrase("Cantidad Daos"));
                c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(c1);
                String[] f1 = fecha1.split("/");
                int a = Integer.parseInt(f1[0]);
                String[] f2 = fecha2.split("/");
                int b = Integer.parseInt(f2[0]);
                int dif = b - a;
                dif++;
                int tamY[][] = new int[dif][2];
                int u = a;
                for (int i = 0; i < dif; i++) {
                    tamY[i][0] = u;
                    u++;
                }
                for (int j = 0; j < dif; j++) {
                    tamY[j][1] = 0;
                }
                for (int k = 0; k < danhos.size(); k++) {
                    int t = danhos.get(k).getFecha_d().get(Calendar.YEAR);
                    for (int l = 0; l < dif; l++) {
                        if (tamY[l][0] == t) {
                            int cant = tamY[l][1];
                            cant++;
                            tamY[l][1] = cant;
                        }
                    }
                }
                for (int i = 0; i < dif; i++) {
                    if (tamY[i][1] > 0) {
                        table.addCell("" + tamY[i][0]);
                        table.addCell("" + tamY[i][1]);
                    }
                }
                c1 = new PdfPCell(new Phrase("Estado"));
                c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(c1);
                c1 = new PdfPCell(new Phrase("Cantidad"));
                c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(c1);
                int tipoD[] = new int[3];
                for (int i = 0; i < 3; i++) {
                    tipoD[i] = 0;
                }
                for (int k = 0; k < danhos.size(); k++) {
                    int cont;
                    if (danhos.get(k).getEstado() == 0) {
                        cont = tipoD[0];
                        cont++;
                        tipoD[0] = cont;
                    } else if (danhos.get(k).getEstado() == 1) {
                        cont = tipoD[1];
                        cont++;
                        tipoD[1] = cont;
                    } else if (danhos.get(k).getEstado() == 2) {
                        cont = tipoD[2];
                        cont++;
                        tipoD[2] = cont;
                    }
                }
                table.addCell("Daado");
                table.addCell("" + tipoD[0]);
                table.addCell("Reparado");
                table.addCell("" + tipoD[1]);
                table.addCell("Dado de Baja");
                table.addCell("" + tipoD[2]);
            }
            subCatPart.add(table);
        } else if (rango.equals("Mes")) {
            PdfPTable table = new PdfPTable(2);
            PdfPCell c1 = new PdfPCell(new Phrase("Categora Material"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase("Cantidad Material"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            table.setHeaderRows(1);
            if (danhos.isEmpty()) {
                table.addCell("No hay daos en ese rango de fecha");
            } else {
                int T[][] = new int[materiales.size()][2];
                for (int i = 0; i < materiales.size(); i++) {
                    T[i][0] = materiales.get(i).getCodigo();
                    T[i][1] = 0;
                }
                for (int i = 0; i < danhos.size(); i++) {
                    int P = danhos.get(i).getMat().getCodigo();
                    for (int k = 0; k < materiales.size(); k++) {
                        int c = 0;
                        if (T[k][0] == P) {
                            c = T[k][1];
                            c++;
                            T[k][1] = c;
                            k = materiales.size();
                        }
                    }
                }
                ArrayList<Tipo_material> tm = tipDAO.getTipo_material();
                int TM[][] = new int[tm.size()][2];
                for (int i = 0; i < tm.size(); i++) {
                    TM[i][0] = tm.get(i).getId();
                    TM[i][1] = 0;
                }
                for (int i = 0; i < T.length; i++) {
                    int c = 0;
                    Material mat = matDAO.getMaterial(T[i][0]);
                    for (int j = 0; j < TM.length; j++) {
                        if (TM[j][0] == mat.getTipo_mat().getId()) {
                            c = TM[j][1];
                            c += T[i][1];
                            TM[j][1] = c;
                            j = tm.size();
                        }
                    }
                }
                for (int i = 0; i < TM.length; i++) {
                    if (TM[i][1] > 0) {
                        Tipo_material tip = tipDAO.getTipo_material(TM[i][0]);
                        table.addCell("" + tip.getNombre());
                        table.addCell("" + TM[i][1]);
                    }
                }
                c1 = new PdfPCell(new Phrase("Mes"));
                c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(c1);
                c1 = new PdfPCell(new Phrase("Cantidad Daos"));
                c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(c1);
                String[] meses = { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto",
                        "Septiembre", "Octubre", "Noviembre", "Diciembre" };
                int tamY[][] = new int[12][2];
                for (int i = 0; i < 12; i++) {
                    tamY[i][0] = i;
                }
                for (int j = 0; j < 12; j++) {
                    tamY[j][1] = 0;
                }
                for (int k = 0; k < danhos.size(); k++) {
                    int t = danhos.get(k).getFecha_d().get(Calendar.MONTH);
                    for (int l = 0; l < 12; l++) {
                        if (tamY[l][0] == t) {
                            int cant = tamY[l][1];
                            cant++;
                            tamY[l][1] = cant;
                        }
                    }
                }
                for (int i = 0; i < 12; i++) {
                    if (tamY[i][1] > 0) {
                        table.addCell("" + meses[i]);
                        table.addCell("" + tamY[i][1]);
                    }
                }
                c1 = new PdfPCell(new Phrase("Estado"));
                c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(c1);
                c1 = new PdfPCell(new Phrase("Cantidad"));
                c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(c1);
                int tipoD[] = new int[3];
                for (int i = 0; i < 3; i++) {
                    tipoD[i] = 0;
                }
                for (int k = 0; k < danhos.size(); k++) {
                    int cont;
                    if (danhos.get(k).getEstado() == 0) {
                        cont = tipoD[0];
                        cont++;
                        tipoD[0] = cont;
                    } else if (danhos.get(k).getEstado() == 1) {
                        cont = tipoD[1];
                        cont++;
                        tipoD[1] = cont;
                    } else if (danhos.get(k).getEstado() == 2) {
                        cont = tipoD[2];
                        cont++;
                        tipoD[2] = cont;
                    }
                }
                table.addCell("Daado");
                table.addCell("" + tipoD[0]);
                table.addCell("Reparado");
                table.addCell("" + tipoD[1]);
                table.addCell("Dado de Baja");
                table.addCell("" + tipoD[2]);
            }
            subCatPart.add(table);
        } else if (rango.equals("Dia")) {
            PdfPTable table = new PdfPTable(2);
            PdfPCell c1 = new PdfPCell(new Phrase("Categora Material"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase("Cantidad Material"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            table.setHeaderRows(1);
            if (danhos.isEmpty()) {
                table.addCell("No hay daos en ese rango de fecha");
            } else {
                int T[][] = new int[materiales.size()][2];
                for (int i = 0; i < materiales.size(); i++) {
                    T[i][0] = materiales.get(i).getCodigo();
                    T[i][1] = 0;
                }
                for (int i = 0; i < danhos.size(); i++) {
                    int P = danhos.get(i).getMat().getCodigo();
                    for (int k = 0; k < materiales.size(); k++) {
                        int c = 0;
                        if (T[k][0] == P) {
                            c = T[k][1];
                            c++;
                            T[k][1] = c;
                            k = materiales.size();
                        }
                    }
                }
                ArrayList<Tipo_material> tm = tipDAO.getTipo_material();
                int TM[][] = new int[tm.size()][2];
                for (int i = 0; i < tm.size(); i++) {
                    TM[i][0] = tm.get(i).getId();
                    TM[i][1] = 0;
                }
                for (int i = 0; i < T.length; i++) {
                    int c = 0;
                    Material mat = matDAO.getMaterial(T[i][0]);
                    for (int j = 0; j < TM.length; j++) {
                        if (TM[j][0] == mat.getTipo_mat().getId()) {
                            c = TM[j][1];
                            c += T[i][1];
                            TM[j][1] = c;
                            j = tm.size();
                        }
                    }
                }
                for (int i = 0; i < TM.length; i++) {
                    if (TM[i][1] > 0) {
                        Tipo_material tip = tipDAO.getTipo_material(TM[i][0]);
                        table.addCell("" + tip.getNombre());
                        table.addCell("" + TM[i][1]);
                    }
                }
                c1 = new PdfPCell(new Phrase("Da del mes"));
                c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(c1);
                c1 = new PdfPCell(new Phrase("Cantidad Daos"));
                c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(c1);
                int tamY[][] = new int[32][2];
                for (int i = 0; i < 32; i++) {
                    tamY[i][0] = i;
                }
                for (int j = 0; j < 32; j++) {
                    tamY[j][1] = 0;
                }
                for (int k = 0; k < danhos.size(); k++) {
                    int t = danhos.get(k).getFecha_d().get(Calendar.DAY_OF_MONTH);
                    for (int l = 0; l < 32; l++) {
                        if (tamY[l][0] == t) {
                            int cant = tamY[l][1];
                            cant++;
                            tamY[l][1] = cant;
                        }
                    }
                }
                for (int i = 0; i < 32; i++) {
                    if (tamY[i][1] > 0) {
                        table.addCell("" + i);
                        table.addCell("" + tamY[i][1]);
                    }
                }
                c1 = new PdfPCell(new Phrase("Estado"));
                c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(c1);
                c1 = new PdfPCell(new Phrase("Cantidad"));
                c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(c1);
                int tipoD[] = new int[3];
                for (int i = 0; i < 3; i++) {
                    tipoD[i] = 0;
                }
                for (int k = 0; k < danhos.size(); k++) {
                    int cont;
                    if (danhos.get(k).getEstado() == 0) {
                        cont = tipoD[0];
                        cont++;
                        tipoD[0] = cont;
                    } else if (danhos.get(k).getEstado() == 1) {
                        cont = tipoD[1];
                        cont++;
                        tipoD[1] = cont;
                    } else if (danhos.get(k).getEstado() == 2) {
                        cont = tipoD[2];
                        cont++;
                        tipoD[2] = cont;
                    }
                }
                table.addCell("Daado");
                table.addCell("" + tipoD[0]);
                table.addCell("Reparado");
                table.addCell("" + tipoD[1]);
                table.addCell("Dado de Baja");
                table.addCell("" + tipoD[2]);
            }
            subCatPart.add(table);
        } else if (rango.equals("Hora")) {
            PdfPTable table = new PdfPTable(2);
            PdfPCell c1 = new PdfPCell(new Phrase("Categora Material"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase("Cantidad Material"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            table.setHeaderRows(1);
            if (danhos.isEmpty()) {
                table.addCell("No hay daos en ese rango de fecha");
            } else {
                int T[][] = new int[materiales.size()][2];
                for (int i = 0; i < materiales.size(); i++) {
                    T[i][0] = materiales.get(i).getCodigo();
                    T[i][1] = 0;
                }
                for (int i = 0; i < danhos.size(); i++) {
                    int P = danhos.get(i).getMat().getCodigo();
                    for (int k = 0; k < materiales.size(); k++) {
                        int c = 0;
                        if (T[k][0] == P) {
                            c = T[k][1];
                            c++;
                            T[k][1] = c;
                            k = materiales.size();
                        }
                    }
                }
                ArrayList<Tipo_material> tm = tipDAO.getTipo_material();
                int TM[][] = new int[tm.size()][2];
                for (int i = 0; i < tm.size(); i++) {
                    TM[i][0] = tm.get(i).getId();
                    TM[i][1] = 0;
                }
                for (int i = 0; i < T.length; i++) {
                    int c = 0;
                    Material mat = matDAO.getMaterial(T[i][0]);
                    for (int j = 0; j < TM.length; j++) {
                        if (TM[j][0] == mat.getTipo_mat().getId()) {
                            c = TM[j][1];
                            c += T[i][1];
                            TM[j][1] = c;
                            j = tm.size();
                        }
                    }
                }
                for (int i = 0; i < TM.length; i++) {
                    if (TM[i][1] > 0) {
                        Tipo_material tip = tipDAO.getTipo_material(TM[i][0]);
                        table.addCell("" + tip.getNombre());
                        table.addCell("" + TM[i][1]);
                    }
                }
                c1 = new PdfPCell(new Phrase("Hora del da"));
                c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(c1);
                c1 = new PdfPCell(new Phrase("Cantidad Daos"));
                c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(c1);
                int tamY[][] = new int[24][2];
                for (int i = 0; i < 24; i++) {
                    tamY[i][0] = i;
                }
                for (int j = 0; j < 24; j++) {
                    tamY[j][1] = 0;
                }
                for (int k = 0; k < danhos.size(); k++) {
                    Calendar cy = danhos.get(k).getFecha_d();
                    int t = danhos.get(k).getFecha_d().get(Calendar.HOUR_OF_DAY);
                    for (int l = 0; l < 24; l++) {
                        if (tamY[l][0] == t) {
                            int cant = tamY[l][1];
                            cant++;
                            tamY[l][1] = cant;
                        }
                    }
                }
                for (int i = 0; i < 24; i++) {
                    if (tamY[i][1] > 0) {
                        table.addCell("" + i);
                        table.addCell("" + tamY[i][1]);
                    }
                }
                c1 = new PdfPCell(new Phrase("Estado"));
                c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(c1);
                c1 = new PdfPCell(new Phrase("Cantidad"));
                c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(c1);
                int tipoD[] = new int[3];
                for (int i = 0; i < 3; i++) {
                    tipoD[i] = 0;
                }
                for (int k = 0; k < danhos.size(); k++) {
                    int cont;
                    if (danhos.get(k).getEstado() == 0) {
                        cont = tipoD[0];
                        cont++;
                        tipoD[0] = cont;
                    } else if (danhos.get(k).getEstado() == 1) {
                        cont = tipoD[1];
                        cont++;
                        tipoD[1] = cont;
                    } else if (danhos.get(k).getEstado() == 2) {
                        cont = tipoD[2];
                        cont++;
                        tipoD[2] = cont;
                    }
                }
                table.addCell("Daado");
                table.addCell("" + tipoD[0]);
                table.addCell("Reparado");
                table.addCell("" + tipoD[1]);
                table.addCell("Dado de Baja");
                table.addCell("" + tipoD[2]);
            }
            subCatPart.add(table);
        }
    }
}

From source file:sipl.recursos.GenerarPDFGrafica.java

private void createTable2(Section subCatPart) throws BadElementException {
    ArrayList<Multa> multas = mulDAO.getRangoFecha_multa(fecha1, fecha2);
    ArrayList<Usuario> usuarios = usuDAO.getUsuarios();
    String codusuarios[] = new String[usuarios.size()];
    int canMult[] = new int[usuarios.size()];
    for (int i = 0; i < usuarios.size(); i++) {
        codusuarios[i] = usuarios.get(i).getCodigo();
        canMult[i] = 0;//from   www  .  j  a  v  a2 s.co  m
    }
    for (int i = 0; i < multas.size(); i++) {
        for (int j = 0; j < usuarios.size(); j++) {
            if (codusuarios[j].equals(multas.get(i).getUsu().getCodigo())) {
                canMult[j]++;
                j = usuarios.size();
            }
        }
    }
    PdfPTable table = new PdfPTable(4);
    PdfPCell c1 = new PdfPCell(new Phrase("Usuario"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);
    c1 = new PdfPCell(new Phrase("Nombre"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);
    c1 = new PdfPCell(new Phrase("Apellidos"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);
    c1 = new PdfPCell(new Phrase("Cantidad Multas"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);
    table.setHeaderRows(1);
    if (multas.isEmpty()) {
        table.addCell("No hay multas en ese rango de fecha");
    } else {
        for (int i = 0; i < usuarios.size(); i++) {
            if (canMult[i] > 0) {
                Usuario usuario1 = usuDAO.getUsuario(codusuarios[i]);
                table.addCell("" + codusuarios[i]);
                table.addCell("" + usuario1.getNombre());
                table.addCell("" + usuario1.getApellido());
                table.addCell("" + canMult[i]);
            }
        }
        subCatPart.add(table);
    }
}

From source file:sipl.recursos.GenerarPDFListar.java

private void createTable(Section subCatPart) {
    switch (Titulo) {
    case "Listar materiales": {
        ArrayList<Material> materiales = matDAO.getMateriales();
        PdfPTable table = new PdfPTable(7);
        PdfPCell c1 = new PdfPCell(new Phrase("Cdigo"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);//from ww w. j av  a 2s  .co m
        c1 = new PdfPCell(new Phrase("Tipo"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Marca"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Serial"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Estado actual"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Nro Inventario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Disp"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        table.setHeaderRows(1);
        for (int i = 0; i < materiales.size(); i++) {
            Material mat = materiales.get(i);
            table.addCell("" + mat.getCodigo());
            table.addCell(mat.getTipo_mat().getNombre());
            table.addCell(mat.getMarca());
            table.addCell(mat.getSerial());
            if (mat.getEstado() == 0) {
                table.addCell("Activo");
            } else if (mat.getEstado() == 1) {
                table.addCell("Dado de Baja");
            } else if (mat.getEstado() == 2) {
                table.addCell("Daado");
            } else {
                table.addCell("Error");
            }
            table.addCell(mat.getNum_inventario());
            if (mat.getDisponibilidad() == 0) {
                table.addCell("Libre");
            } else if (mat.getDisponibilidad() == 1) {
                table.addCell("Prestado");
            } else if (mat.getDisponibilidad() == 2) {
                table.addCell("Reservado");
            } else {
                table.addCell("Error");
            }
        }
        subCatPart.add(table);
        break;
    }
    case "Listar usuarios": {
        ArrayList<Usuario> usuarios = usuDAO.getUsuarios();
        PdfPTable table = new PdfPTable(6);
        PdfPCell c1 = new PdfPCell(new Phrase("Cdigo"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Nombre"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Apellido"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Telfono"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Correo"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Estado"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        table.setHeaderRows(1);
        for (int i = 0; i < usuarios.size(); i++) {
            Usuario usu = usuarios.get(i);
            table.addCell("" + usu.getCodigo());
            table.addCell(usu.getNombre());
            table.addCell(usu.getApellido());
            table.addCell("" + usu.getTelefono());
            table.addCell("" + usu.getCorreo());
            if (usu.getEstado() == 0) {
                table.addCell("Activo");
            } else if (usu.getEstado() == 1) {
                table.addCell("Inactivo");
            } else if (usu.getEstado() == 2) {
                table.addCell("Con prstamo");
            } else if (usu.getEstado() == 3) {
                table.addCell("Con reserva ");
            } else if (usu.getEstado() == 4) {
                table.addCell("Con multa");
            } else {
                table.addCell("Error");
            }
        }
        subCatPart.add(table);
        break;
    }
    case "Listar laboratorios": {
        ArrayList<Laboratorio> laboratorios = labDAO.getLaboratorios();
        PdfPTable table = new PdfPTable(4);
        PdfPCell c1 = new PdfPCell(new Phrase("Cdigo"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Nombre"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Descripcin"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Ubicacin"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        table.setHeaderRows(1);
        for (int i = 0; i < laboratorios.size(); i++) {
            Laboratorio lab = laboratorios.get(i);
            table.addCell("" + lab.getCodigo());
            table.addCell(lab.getNombre());
            table.addCell(lab.getDescripcion());
            table.addCell(lab.getUbicacion());
        }
        subCatPart.add(table);
        break;
    }
    case "Listar reservas": {
        ArrayList<Reserva> reservas = resDAO.getReservas();
        PdfPTable table = new PdfPTable(6);
        PdfPCell c1 = new PdfPCell(new Phrase("Cdigo Reserva"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Nombre Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Apellido Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Cdigo Materiales"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Fecha Reserva"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Estado Reserva"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        table.setHeaderRows(1);
        for (int i = 0; i < reservas.size(); i++) {
            Reserva res = reservas.get(i);
            if (res.getEstado() == 0) {
                table.addCell("" + res.getCodigo());
                table.addCell(res.getUsu().getNombre());
                table.addCell(res.getUsu().getApellido());
                table.addCell(res.getMat());
                Calendar cal1 = res.getFecha_reserva();
                String fecha = cal1.get(Calendar.YEAR) + "-";
                int mes = cal1.get(Calendar.MONTH);
                mes++;
                fecha += mes + "-";
                fecha += cal1.get(Calendar.DAY_OF_MONTH);
                fecha += " " + cal1.get(Calendar.HOUR_OF_DAY);
                fecha += ":" + cal1.get(Calendar.MINUTE) + ":00";
                table.addCell(fecha);
                if (res.getEstado() == 0) {
                    table.addCell("Activo");
                } else if (res.getEstado() == 1) {
                    table.addCell("Inactivo");
                } else {
                    table.addCell("Error");
                }
            }
        }
        subCatPart.add(table);
        break;
    }
    case "Listar multas": {
        ArrayList<Multa> multas = mulDAO.getMultas();
        PdfPTable table = new PdfPTable(6);
        PdfPCell c1 = new PdfPCell(new Phrase("Cdigo Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Nombre Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Apellido Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Fecha Multa"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Estado Multa"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Tiempo Multa"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        table.setHeaderRows(1);
        for (int i = 0; i < multas.size(); i++) {
            Multa mul = multas.get(i);
            if (mul.getEstado_multa() == 0) {
                table.addCell("" + mul.getUsu().getCodigo());
                table.addCell(mul.getUsu().getNombre());
                table.addCell(mul.getUsu().getApellido());
                Calendar cal1 = mul.getFecha_multa();
                String fecha = cal1.get(Calendar.YEAR) + "-";
                int mes = cal1.get(Calendar.MONTH);
                mes++;
                fecha += mes + "-";
                fecha += cal1.get(Calendar.DAY_OF_MONTH);
                fecha += " " + cal1.get(Calendar.HOUR_OF_DAY);
                fecha += ":" + cal1.get(Calendar.MINUTE) + ":00";
                table.addCell(fecha);
                if (mul.getEstado_multa() == 0) {
                    table.addCell("Activo");
                } else if (mul.getEstado_multa() == 1) {
                    table.addCell("Inactivo");
                } else {
                    table.addCell("Error");
                }
                table.addCell("" + mul.getTiempo_multa());
            }
        }
        subCatPart.add(table);
        break;
    }
    case "Listar prestamos": {
        ArrayList<Prestamo> prestamos = preDAO.getprestamos();
        PdfPTable table = new PdfPTable(7);
        PdfPCell c1 = new PdfPCell(new Phrase("Cdigo Prstamo"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Cdigo Material"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Nombre Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Apellido Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Fecha Prstamo"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Fecha Devolucin"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Estado"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        table.setHeaderRows(1);
        for (int i = 0; i < prestamos.size(); i++) {
            Prestamo pre = prestamos.get(i);
            table.addCell("" + pre.getCodigo());
            table.addCell(pre.getMat());
            table.addCell(pre.getUsu().getNombre());
            table.addCell(pre.getUsu().getApellido());
            Calendar cal1 = pre.getFecha_prestamo();
            String fecha = cal1.get(Calendar.YEAR) + "-";
            int mes = cal1.get(Calendar.MONTH);
            mes++;
            fecha += mes + "-";
            fecha += cal1.get(Calendar.DAY_OF_MONTH);
            fecha += " " + cal1.get(Calendar.HOUR_OF_DAY);
            fecha += ":" + cal1.get(Calendar.MINUTE) + ":00";
            table.addCell(fecha);
            Calendar cal2 = pre.getFecha_devolucion();
            String fecha1 = cal2.get(Calendar.YEAR) + "-";
            int mes1 = cal2.get(Calendar.MONTH);
            mes1++;
            fecha1 += mes1 + "-";
            fecha1 += cal2.get(Calendar.DAY_OF_MONTH);
            fecha1 += " " + cal2.get(Calendar.HOUR_OF_DAY);
            fecha1 += ":" + cal2.get(Calendar.MINUTE) + ":00";
            table.addCell(fecha1);
            if (pre.getEstado() == 0) {
                table.addCell("Activo");
            } else if (pre.getEstado() == 1) {
                table.addCell("Inactivo");
            } else {
                table.addCell("Error");
            }
        }
        subCatPart.add(table);
        break;
    }
    case "Listar Danho": {
        ArrayList<Danho> danhos = danDAO.getDanhos();
        PdfPTable table = new PdfPTable(9);
        PdfPCell c1 = new PdfPCell(new Phrase("Descripcin Dao"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Cdigo Material"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Descripcin Material"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Codigo Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Nombre Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Apellidos Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Fecha Dao"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Dao Reportado por"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Estado"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        table.setHeaderRows(1);
        for (int i = 0; i < danhos.size(); i++) {
            Danho dan = danhos.get(i);
            table.addCell("" + dan.getDescripcion());
            table.addCell("" + dan.getMat().getCodigo());
            table.addCell(dan.getMat().getDescripcion());
            table.addCell(dan.getUsu().getCodigo());
            table.addCell(dan.getUsu().getNombre());
            table.addCell(dan.getUsu().getApellido());
            Calendar cal1 = dan.getFecha_d();
            String fecha = cal1.get(Calendar.YEAR) + "-";
            int mes = cal1.get(Calendar.MONTH);
            mes++;
            fecha += mes + "-";
            fecha += cal1.get(Calendar.DAY_OF_MONTH);
            fecha += " " + cal1.get(Calendar.HOUR_OF_DAY);
            fecha += ":" + cal1.get(Calendar.MINUTE) + ":00";
            table.addCell(fecha);
            table.addCell("" + dan.getUsu_rd().getNombre());
            if (dan.getEstado() == 0) {
                table.addCell("Daado");
            } else if (dan.getEstado() == 1) {
                table.addCell("Reparado");
            } else if (dan.getEstado() == 2) {
                table.addCell("Dado de baja");
            } else {
                table.addCell("Error");
            }
        }
        subCatPart.add(table);
        break;
    }
    }
}

From source file:sipl.recursos.GenerarPDFListarActivos.java

private void createTable(Section subCatPart) {
    switch (Titulo) {
    case "Listar materiales": {
        ArrayList<Material> materiales = matDAO.getMaterialesActivos();
        PdfPTable table = new PdfPTable(7);
        PdfPCell c1 = new PdfPCell(new Phrase("Cdigo"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);//from   w w w. j a v a2s .c om
        c1 = new PdfPCell(new Phrase("Tipo"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Marca"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Serial"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Estado actual"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Nro Inventario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Disp"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        table.setHeaderRows(1);
        for (int i = 0; i < materiales.size(); i++) {
            Material mat = materiales.get(i);
            table.addCell("" + mat.getCodigo());
            table.addCell(mat.getTipo_mat().getNombre());
            table.addCell(mat.getMarca());
            table.addCell(mat.getSerial());
            if (mat.getEstado() == 0) {
                table.addCell("Activo");
            } else if (mat.getEstado() == 1) {
                table.addCell("Dado de Baja");
            } else if (mat.getEstado() == 2) {
                table.addCell("Daado");
            } else {
                table.addCell("Error");
            }
            table.addCell(mat.getNum_inventario());
            if (mat.getDisponibilidad() == 0) {
                table.addCell("Libre");
            } else if (mat.getDisponibilidad() == 1) {
                table.addCell("Prestado");
            } else if (mat.getDisponibilidad() == 2) {
                table.addCell("Reservado");
            } else {
                table.addCell("Error");
            }
        }
        subCatPart.add(table);
        break;
    }
    case "Listar usuarios": {
        ArrayList<Usuario> usuarios = usuDAO.getUsuariosActivos();
        PdfPTable table = new PdfPTable(6);
        PdfPCell c1 = new PdfPCell(new Phrase("Cdigo"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Nombre"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Apellido"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Telfono"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Correo"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Estado"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        table.setHeaderRows(1);
        for (int i = 0; i < usuarios.size(); i++) {
            Usuario usu = usuarios.get(i);
            table.addCell("" + usu.getCodigo());
            table.addCell(usu.getNombre());
            table.addCell(usu.getApellido());
            table.addCell("" + usu.getTelefono());
            table.addCell("" + usu.getCorreo());
            if (usu.getEstado() == 0) {
                table.addCell("Activo");
            } else if (usu.getEstado() == 1) {
                table.addCell("Inactivo");
            } else if (usu.getEstado() == 2) {
                table.addCell("Con prstamo");
            } else if (usu.getEstado() == 3) {
                table.addCell("Con reserva ");
            } else if (usu.getEstado() == 4) {
                table.addCell("Con multa");
            } else {
                table.addCell("Error");
            }
        }
        subCatPart.add(table);
        break;
    }
    case "Listar laboratorios": {
        ArrayList<Laboratorio> laboratorios = labDAO.getLaboratorios();
        PdfPTable table = new PdfPTable(4);
        PdfPCell c1 = new PdfPCell(new Phrase("Cdigo"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Nombre"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Descripcin"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Ubicacin"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        table.setHeaderRows(1);
        for (int i = 0; i < laboratorios.size(); i++) {
            Laboratorio lab = laboratorios.get(i);
            table.addCell("" + lab.getCodigo());
            table.addCell(lab.getNombre());
            table.addCell(lab.getDescripcion());
            table.addCell(lab.getUbicacion());
        }
        subCatPart.add(table);
        break;
    }
    case "Listar reservas": {
        ArrayList<Reserva> reservas = resDAO.getReservasAct();
        PdfPTable table = new PdfPTable(6);
        PdfPCell c1 = new PdfPCell(new Phrase("Cdigo Reserva"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Nombre Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Apellido Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Cdigo Materiales"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Fecha Reserva"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Estado Reserva"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        table.setHeaderRows(1);
        for (int i = 0; i < reservas.size(); i++) {
            Reserva res = reservas.get(i);
            if (res.getEstado() == 0) {
                table.addCell("" + res.getCodigo());
                table.addCell(res.getUsu().getNombre());
                table.addCell(res.getUsu().getApellido());
                table.addCell(res.getMat());
                Calendar cal1 = res.getFecha_reserva();
                String fecha = cal1.get(Calendar.YEAR) + "-";
                int mes = cal1.get(Calendar.MONTH);
                mes++;
                fecha += mes + "-";
                fecha += cal1.get(Calendar.DAY_OF_MONTH);
                fecha += " " + cal1.get(Calendar.HOUR_OF_DAY);
                fecha += ":" + cal1.get(Calendar.MINUTE) + ":00";
                table.addCell(fecha);
                if (res.getEstado() == 0) {
                    table.addCell("Activo");
                } else if (res.getEstado() == 1) {
                    table.addCell("Inactivo");
                } else {
                    table.addCell("Error");
                }
            }
        }
        subCatPart.add(table);
        break;
    }
    case "Listar multas": {
        ArrayList<Multa> multas = mulDAO.getMultasAct();
        PdfPTable table = new PdfPTable(6);
        PdfPCell c1 = new PdfPCell(new Phrase("Cdigo Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Nombre Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Apellido Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Fecha Multa"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Estado Multa"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Tiempo Multa"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        table.setHeaderRows(1);
        for (int i = 0; i < multas.size(); i++) {
            Multa mul = multas.get(i);
            if (mul.getEstado_multa() == 0) {
                table.addCell("" + mul.getUsu().getCodigo());
                table.addCell(mul.getUsu().getNombre());
                table.addCell(mul.getUsu().getApellido());
                Calendar cal1 = mul.getFecha_multa();
                String fecha = cal1.get(Calendar.YEAR) + "-";
                int mes = cal1.get(Calendar.MONTH);
                mes++;
                fecha += mes + "-";
                fecha += cal1.get(Calendar.DAY_OF_MONTH);
                fecha += " " + cal1.get(Calendar.HOUR_OF_DAY);
                fecha += ":" + cal1.get(Calendar.MINUTE) + ":00";
                table.addCell(fecha);
                if (mul.getEstado_multa() == 0) {
                    table.addCell("Activo");
                } else if (mul.getEstado_multa() == 1) {
                    table.addCell("Inactivo");
                } else {
                    table.addCell("Error");
                }
                table.addCell("" + mul.getTiempo_multa());
            }
        }
        subCatPart.add(table);
        break;
    }
    case "Listar prestamos": {
        ArrayList<Prestamo> prestamos = preDAO.getprestamosActivos();
        PdfPTable table = new PdfPTable(7);
        PdfPCell c1 = new PdfPCell(new Phrase("Cdigo Prstamo"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Cdigo Material"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Nombre Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Apellido Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Fecha Prstamo"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Fecha Devolucin"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Estado"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        table.setHeaderRows(1);
        for (int i = 0; i < prestamos.size(); i++) {
            Prestamo pre = prestamos.get(i);
            if (pre.getEstado() == 0) {
                table.addCell("" + pre.getCodigo());
                table.addCell(pre.getMat());
                table.addCell(pre.getUsu().getNombre());
                table.addCell(pre.getUsu().getApellido());
                Calendar cal1 = pre.getFecha_prestamo();
                String fecha = cal1.get(Calendar.YEAR) + "-";
                int mes = cal1.get(Calendar.MONTH);
                mes++;
                fecha += mes + "-";
                fecha += cal1.get(Calendar.DAY_OF_MONTH);
                fecha += " " + cal1.get(Calendar.HOUR_OF_DAY);
                fecha += ":" + cal1.get(Calendar.MINUTE) + ":00";
                table.addCell(fecha);
                Calendar cal2 = pre.getFecha_devolucion();
                String fecha1 = cal2.get(Calendar.YEAR) + "-";
                int mes1 = cal2.get(Calendar.MONTH);
                mes1++;
                fecha1 += mes1 + "-";
                fecha1 += cal2.get(Calendar.DAY_OF_MONTH);
                fecha1 += " " + cal2.get(Calendar.HOUR_OF_DAY);
                fecha1 += ":" + cal2.get(Calendar.MINUTE) + ":00";
                table.addCell(fecha1);
                if (pre.getEstado() == 0) {
                    table.addCell("Activo");
                } else if (pre.getEstado() == 1) {
                    table.addCell("Inactivo");
                } else {
                    table.addCell("Error");
                }
            }

        }
        subCatPart.add(table);
        break;
    }
    case "Listar Danho": {
        ArrayList<Danho> danhos = danDAO.getDanhosActivos();
        PdfPTable table = new PdfPTable(9);
        PdfPCell c1 = new PdfPCell(new Phrase("Descripcin Dao"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Cdigo Material"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Descripcin Material"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Codigo Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Nombre Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Apellidos Usuario"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Fecha Dao"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Dao Reportado por"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Estado"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        table.setHeaderRows(1);
        for (int i = 0; i < danhos.size(); i++) {
            Danho dan = danhos.get(i);
            table.addCell("" + dan.getDescripcion());
            table.addCell("" + dan.getMat().getCodigo());
            table.addCell(dan.getMat().getDescripcion());
            table.addCell(dan.getUsu().getCodigo());
            table.addCell(dan.getUsu().getNombre());
            table.addCell(dan.getUsu().getApellido());
            Calendar cal1 = dan.getFecha_d();
            String fecha = cal1.get(Calendar.YEAR) + "-";
            int mes = cal1.get(Calendar.MONTH);
            mes++;
            fecha += mes + "-";
            fecha += cal1.get(Calendar.DAY_OF_MONTH);
            fecha += " " + cal1.get(Calendar.HOUR_OF_DAY);
            fecha += ":" + cal1.get(Calendar.MINUTE) + ":00";
            table.addCell(fecha);
            table.addCell("" + dan.getUsu_rd().getNombre());
            if (dan.getEstado() == 0) {
                table.addCell("Daado");
            } else if (dan.getEstado() == 1) {
                table.addCell("Reparado");
            } else if (dan.getEstado() == 2) {
                table.addCell("Dado de baja");
            } else {
                table.addCell("Error");
            }
        }
        subCatPart.add(table);
        break;
    }
    }
}

From source file:sipl.recursos.GenerarPDFtipomaterial.java

private static void createTable(Section subCatPart) throws BadElementException {
    ArrayList<Tipo_material> Tipos = tipDAO.getTipo_material();
    PdfPTable table = new PdfPTable(5);
    PdfPCell c1 = new PdfPCell(new Phrase("Cat."));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);/*from ww w.  j  a  va2  s .c o  m*/
    c1 = new PdfPCell(new Phrase("Nombre"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);
    c1 = new PdfPCell(new Phrase("Descripcin"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);
    c1 = new PdfPCell(new Phrase("Cantidad"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);
    c1 = new PdfPCell(new Phrase("Disponibilidad"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);
    table.setHeaderRows(1);
    if (Tipos.isEmpty()) {
        table.addCell("No hay Tipos de Material");
    } else {
        int cont = 0;
        for (int i = 0; i < Tipos.size(); i++) {
            table.addCell("" + Tipos.get(i).getId());
            table.addCell("" + Tipos.get(i).getNombre());
            table.addCell("" + Tipos.get(i).getDescripcion());
            table.addCell("" + Tipos.get(i).getCantidad());
            table.addCell("" + Tipos.get(i).getDisponibilidad());
            cont += Tipos.get(i).getCantidad();
        }
        table.addCell("");
        table.addCell("");
        table.addCell("Total Materiales");
        table.addCell("" + cont);
        table.addCell("");
    }
    subCatPart.add(table);
}

From source file:tn.com.hitechart.eds.Util.pdfRpport.FirstPdf.java

private void createTable(Section subCatPart) throws BadElementException {

    //-------------------------- TAB POINTAGE -------------------//
    PdfPTable table = new PdfPTable(8);
    table.setTotalWidth(PageSize.A4.rotate().getWidth() - 10);
    table.setLockedWidth(true);/*w  w w.ja  v  a2 s  .  c  o  m*/
    // t.setBorderColor(BaseColor.GRAY);
    // t.setPadding(4);
    // t.setSpacing(4);
    // t.setBorderWidth(1);
    //----------- C1 --------------//
    PdfPCell c1 = new PdfPCell(new Phrase("Date Rapport"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setBorder(Rectangle.NO_BORDER);
    table.addCell(c1);
    //----------- C2 --------------//
    c1 = new PdfPCell(new Phrase("Technicien"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setBorder(Rectangle.NO_BORDER);
    table.addCell(c1);
    //----------- C3 --------------//
    c1 = new PdfPCell(new Phrase("Poinatge"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    //----------- C4 --------------//
    c1 = new PdfPCell(new Phrase("Matin"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);
    //----------- C5 --------------//
    c1 = new PdfPCell(new Phrase("Aprs-Midi"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    //----------- C6 --------------//
    c1 = new PdfPCell(new Phrase("Rapport Journalier", catFont));
    c1.setBorder(Rectangle.NO_BORDER);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setColspan(3);
    table.addCell(c1);
    //----------- C7 --------------//

    //----------- C8 --------------//

    table.setHeaderRows(1);

    //----------- R2 --------------//
    //----------- C1 --------------//
    c1 = new PdfPCell(new Phrase(tabDatapointage[0], dataFont));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setRowspan(2);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(user.getLogin(), dataFont));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setRowspan(2);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Arrive"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(tabDatapointage[1], dataFont));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(tabDatapointage[2], dataFont));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(""));
    c1.setBorder(Rectangle.NO_BORDER);
    table.addCell(c1);
    //----------- C7 --------------//

    c1 = new PdfPCell(new Phrase(""));
    c1.setBorder(Rectangle.NO_BORDER);
    table.addCell(c1);
    //----------- C8 --------------//

    c1 = new PdfPCell(new Phrase(""));
    c1.setBorder(Rectangle.NO_BORDER);
    table.addCell(c1);

    //----------- R3 --------------//

    c1 = new PdfPCell(new Phrase("Sortie"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(tabDatapointage[3], dataFont));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(tabDatapointage[4], dataFont));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(""));
    c1.setBorder(Rectangle.NO_BORDER);
    table.addCell(c1);
    //----------- C7 --------------//
    c1 = new PdfPCell(new Phrase(""));
    c1.setBorder(Rectangle.NO_BORDER);
    table.addCell(c1);
    //----------- C8 --------------//
    c1 = new PdfPCell(new Phrase(""));
    c1.setBorder(Rectangle.NO_BORDER);
    table.addCell(c1);
    table.setSpacingAfter(10);
    subCatPart.add(table);

    //-------------------------- END TAB POINTAGE -------------------//
    // TODO: 20/01/2017
    //--------------------------------- TASK ---------------------//
    PdfPTable tableTask = new PdfPTable(5);

    tableTask.setTotalWidth(PageSize.A4.rotate().getWidth() - 10);
    tableTask.setLockedWidth(true);

    PdfPCell c2 = new PdfPCell(new Phrase("Dossiers Traits", catFont));
    c2.setHorizontalAlignment(Element.ALIGN_CENTER);
    c2.setColspan(5);
    c2.setBorder(Rectangle.NO_BORDER);
    tableTask.addCell(c2);

    tableTask.setHeaderRows(1);

    c2 = new PdfPCell(new Phrase("NDoss.", dataFont));
    c2.setHorizontalAlignment(Element.ALIGN_CENTER);
    tableTask.addCell(c2);

    c2 = new PdfPCell(new Phrase("Client", dataFont));
    c2.setHorizontalAlignment(Element.ALIGN_CENTER);
    tableTask.addCell(c2);

    c2 = new PdfPCell(new Phrase("Dure", dataFont));
    c2.setHorizontalAlignment(Element.ALIGN_CENTER);
    tableTask.addCell(c2);

    c2 = new PdfPCell(new Phrase("Mission", dataFont));
    c2.setHorizontalAlignment(Element.ALIGN_CENTER);
    tableTask.addCell(c2);

    c2 = new PdfPCell(new Phrase("Resultat", dataFont));
    c2.setHorizontalAlignment(Element.ALIGN_CENTER);
    tableTask.addCell(c2);
    if (tasks.isEmpty()) {
        c2 = new PdfPCell(new Phrase("Aucune  Tache a t trait", catFontempty));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        c2.setColspan(5);
        tableTask.addCell(c2);
    } else {

        if (!dossiers.isEmpty()) {
            for (Dossier d : dossiers) {

                tableTask.addCell(d.getNumDoss());
                tableTask.addCell(d.getClient());
                tableTask.addCell(convertLongtoDurationfr(d.getTimeDuration()));
                tableTask.addCell(td.getTaskById(d.get_idTask()).getType());
                tableTask.addCell(td.getTaskById(d.get_idTask()).getRes());
            }
        }

    }

    tableTask.setSpacingAfter(10);

    subCatPart.add(tableTask);

    //-------------------------- END TAB TASK -------------------//
    // TODO: 20/01/2017  tab achat
    //-------------------------- TAB ACHAT -------------------//

    PdfPTable tableAchat = new PdfPTable(3);

    tableAchat.setTotalWidth(PageSize.A4.rotate().getWidth() - 10);
    tableAchat.setLockedWidth(true);

    PdfPCell c3 = new PdfPCell(new Phrase("Frais Engags", catFont));
    c3.setHorizontalAlignment(Element.ALIGN_CENTER);
    c3.setColspan(3);
    c3.setBorder(Rectangle.NO_BORDER);
    tableAchat.addCell(c3);

    tableAchat.setHeaderRows(1);
    c3 = new PdfPCell(new Phrase("N.Doss.", dataFont));
    c3.setHorizontalAlignment(Element.ALIGN_CENTER);
    tableAchat.addCell(c3);

    c3 = new PdfPCell(new Phrase("Dsignation", dataFont));
    c3.setHorizontalAlignment(Element.ALIGN_CENTER);
    tableAchat.addCell(c3);

    c3 = new PdfPCell(new Phrase("Montant TCC", dataFont));
    c3.setHorizontalAlignment(Element.ALIGN_CENTER);
    tableAchat.addCell(c3);
    if (achats.isEmpty()) {
        c3 = new PdfPCell(new Phrase("la liste des achats est vide", catFontempty));
        c3.setHorizontalAlignment(Element.ALIGN_CENTER);
        c3.setColspan(3);
        tableAchat.addCell(c3);
    } else {

        for (Achat achat : achats) {

            tableAchat.addCell(String.valueOf(achat.getNumDoss()));
            tableAchat.addCell(achat.getDesignation());
            tableAchat.addCell(String.valueOf(achat.getPrix()));
        }
    }
    tableAchat.setSpacingAfter(10);
    subCatPart.add(tableAchat);
    //-------------------------- END TAB ACHAT -------------------//

    // TODO: 20/01/2017  tab composant
    //-------------------------- TAB COMPOSANT -------------------//

    PdfPTable tableComp = new PdfPTable(3);

    tableComp.setTotalWidth(PageSize.A4.rotate().getWidth() - 10);
    tableComp.setLockedWidth(true);

    PdfPCell c4 = new PdfPCell(new Phrase("Composants", catFont));
    c4.setHorizontalAlignment(Element.ALIGN_CENTER);
    c4.setColspan(3);
    c4.setBorder(Rectangle.NO_BORDER);
    tableComp.addCell(c4);
    tableComp.setHeaderRows(1);

    c4 = new PdfPCell(new Phrase("N.Doss.", dataFont));
    c4.setHorizontalAlignment(Element.ALIGN_CENTER);
    tableComp.addCell(c4);

    c4 = new PdfPCell(new Phrase("Dsignation", dataFont));
    c4.setHorizontalAlignment(Element.ALIGN_CENTER);
    tableComp.addCell(c4);

    c4 = new PdfPCell(new Phrase("Quantit", dataFont));
    c4.setHorizontalAlignment(Element.ALIGN_CENTER);
    tableComp.addCell(c4);

    if (comps.isEmpty()) {
        c4 = new PdfPCell(new Phrase("la liste des composants est vide", catFontempty));
        c4.setHorizontalAlignment(Element.ALIGN_CENTER);
        c4.setColspan(3);
        tableComp.addCell(c4);
    } else {
        for (Composant comp : comps) {

            tableComp.addCell(String.valueOf(comp.getNumDoss()));
            tableComp.addCell(comp.getName());
            tableComp.addCell(String.valueOf(comp.getQte()));
        }
    }
    tableComp.setSpacingAfter(10);
    subCatPart.add(tableComp);
    //-------------------------- END TAB COMPOSANT -------------------//

    // TODO: 20/01/2017  tab message
    //-------------------------- TAB MESSAGE -------------------//

    PdfPTable tableMsg = new PdfPTable(2);

    tableMsg.setTotalWidth(PageSize.A4.rotate().getWidth() - 10);
    tableMsg.setLockedWidth(true);

    PdfPCell c5 = new PdfPCell(new Phrase("Message  Transmettre", catFont));
    c5.setHorizontalAlignment(Element.ALIGN_CENTER);
    c5.setColspan(3);
    c5.setBorder(Rectangle.NO_BORDER);
    tableMsg.addCell(c5);

    c5 = new PdfPCell(new Phrase("N.Doss.", dataFont));
    c5.setHorizontalAlignment(Element.ALIGN_CENTER);
    tableMsg.addCell(c5);

    tableMsg.setHeaderRows(1);
    c5 = new PdfPCell(new Phrase("Message", dataFont));
    c5.setHorizontalAlignment(Element.ALIGN_CENTER);
    tableMsg.addCell(c5);

    tableMsg.setHeaderRows(1);
    if (msgs.isEmpty()) {
        c5 = new PdfPCell(new Phrase("Aucun message", catFontempty));
        c5.setHorizontalAlignment(Element.ALIGN_CENTER);
        c5.setColspan(3);
        tableMsg.addCell(c5);
    } else {
        for (Message msg : msgs) {

            tableMsg.addCell(String.valueOf(msg.getNumDoss()));
            tableMsg.addCell(msg.getMsg());
        }
    }
    tableMsg.setSpacingAfter(10);
    subCatPart.add(tableMsg);
    //-------------------------- END TAB MESSAGE -------------------//

    // TODO: 20/01/2017  tab Activitee
    //-------------------------- TAB ACTIVITEE -------------------//

    PdfPTable tableAct = new PdfPTable(2);

    tableAct.setTotalWidth(PageSize.A4.rotate().getWidth() - 10);
    tableAct.setLockedWidth(true);

    PdfPCell c6 = new PdfPCell(new Phrase("Autre Activites", catFont));
    c6.setHorizontalAlignment(Element.ALIGN_CENTER);
    c6.setColspan(2);
    c6.setBorder(Rectangle.NO_BORDER);
    tableAct.addCell(c6);

    tableAct.setHeaderRows(1);

    c6 = new PdfPCell(new Phrase("N.Doss.", dataFont));
    c6.setHorizontalAlignment(Element.ALIGN_CENTER);
    tableAct.addCell(c6);

    c6 = new PdfPCell(new Phrase("Dure", dataFont));
    c6.setHorizontalAlignment(Element.ALIGN_CENTER);
    tableAct.addCell(c6);
    if (autreActs.isEmpty()) {
        c6 = new PdfPCell(new Phrase("Aucune autre Activite a t effectu", catFontempty));
        c6.setHorizontalAlignment(Element.ALIGN_CENTER);
        c6.setColspan(3);
        tableAct.addCell(c6);
    } else {

        for (Task autreA : autreActs) {

            tableAct.addCell(String.valueOf(autreA.getType()));
            tableAct.addCell(autreA.getNumDoss());
        }

    }
    tableAct.setSpacingAfter(10);
    subCatPart.add(tableAct);
    //-------------------------- END TAB MESSAGE -------------------//
}