public void onClick$buttonAceptarP() {
   buttonImprimir.setVisible(true);
   listfinicial.setLabel("Año");
   listffinal.setLabel("Mes");
   lista =
       dbrp.ReportePorMes(
           cmb_tipo.getText(),
           cmb_demanda.getText(),
           (cmb_mes.getSelectedIndex() + 1),
           cmb_anio2.getText());
   ListModelList<ReporteProducto> modeloDeDatos = new ListModelList<ReporteProducto>(lista);
   listademanda.setModel(modeloDeDatos);
   gpb_lista.setVisible(true);
   buttonAceptarP.setVisible(false);
   cmb_mes.setDisabled(true);
   cmb_anio2.setDisabled(true);
   if (cmb_tipo.getText().equals("General")) {
     listffinal.setVisible(true);
     listfinicial.setVisible(true);
     liscat.setVisible(true);
   } else {
     listffinal.setVisible(true);
     listfinicial.setVisible(true);
     liscat.setVisible(true);
   }
 }
 public void onClick$buttonAceptar() {
   buttonImprimir.setVisible(true);
   Calendar c1 = Calendar.getInstance();
   Calendar c2 = new GregorianCalendar();
   if (txtFechaLlegada.getText().isEmpty() || txtFechaSalida.getText().isEmpty()) {
     alert("Seleccione fechas!!");
   } else {
     String fechai =
         ""
             + (txtFechaLlegada.getValue().getYear() + 1900)
             + "-"
             + (txtFechaLlegada.getValue().getMonth() + 1)
             + "-"
             + txtFechaLlegada.getValue().getDate();
     String fechau =
         ""
             + (txtFechaSalida.getValue().getYear() + 1900)
             + "-"
             + (txtFechaSalida.getValue().getMonth() + 1)
             + "-"
             + txtFechaSalida.getValue().getDate();
     if (txtFechaLlegada.getValue().after(txtFechaSalida.getValue())) {
       alert("Fecha de Inicio no debe exceder a la fecha límite!!");
     } else {
       if (txtFechaLlegada.getValue().after(c1.getTime())
           || txtFechaSalida.getValue().after(c1.getTime())) {
         alert("las fechas no pueden exceder a la fecha actual!!");
       } else {
         lista = dbrp.ReportePorFecha(cmb_tipo.getText(), cmb_demanda.getText(), fechai, fechau);
         ListModelList<ReporteProducto> modeloDeDatos = new ListModelList<ReporteProducto>(lista);
         listademanda.setModel(modeloDeDatos);
         gpb_lista.setVisible(true);
         buttonAceptar.setVisible(false);
         txtFechaLlegada.setDisabled(true);
         txtFechaSalida.setDisabled(true);
         if (cmb_tipo.getText().equals("General")) {
           listffinal.setVisible(true);
           listfinicial.setVisible(true);
           liscat.setVisible(true);
         } else {
           listffinal.setVisible(true);
           listfinicial.setVisible(true);
           liscat.setVisible(true);
         }
       }
     }
   }
 }
 public void onClick$buttonAceptaru() {
   buttonImprimir.setVisible(false);
   buttonDeshacer.setVisible(true);
   if (cmb_tiempo.getText().equals("Por Año")) {
     gpb_2.setVisible(false);
     gpb_1.setVisible(true);
     gpb_3.setVisible(false);
     buttonAceptaru.setVisible(false);
     cmb_tiempo.setDisabled(true);
     cmb_tipo.setDisabled(true);
     cmb_demanda.setDisabled(true);
     gpb_lista.setVisible(false);
     gpb_anio.setVisible(true);
   } else {
     if (cmb_tiempo.getText().equals("Por Mes")) {
       gpb_2.setVisible(true);
       gpb_1.setVisible(true);
       buttonAceptaru.setVisible(false);
       cmb_tiempo.setDisabled(true);
       cmb_tipo.setDisabled(true);
       cmb_demanda.setDisabled(true);
       gpb_3.setVisible(false);
       gpb_lista.setVisible(false);
       gpb_anio.setVisible(false);
     } else {
       gpb_2.setVisible(false);
       gpb_1.setVisible(true);
       gpb_3.setVisible(true);
       buttonAceptaru.setVisible(false);
       cmb_tiempo.setDisabled(true);
       cmb_tipo.setDisabled(true);
       cmb_demanda.setDisabled(true);
       gpb_lista.setVisible(false);
       gpb_anio.setVisible(false);
     }
   }
 }
  @Override
  public void render(final Row row, Object object) throws Exception {
    if (inputfmtcombo != null) {
      inputRateSelected = inputfmtcombo.getText();
      if (!inputRateSelected.contains("VFI_")) inputRateSelected = "VFI_" + inputRateSelected;
    }
    final DefaultFormatMapEntries fmtMapEntry = (DefaultFormatMapEntries) object;
    final Combobox inputFormatCombo = new Combobox();
    inputFormatCombo.setReadonly(true);
    String rateFormat = fmtMapEntry.getRateFormat();
    if (rateFormat.contains("VF_")) rateFormat = rateFormat.replaceAll("VF_", "");
    inputFormatCombo.setText(rateFormat);
    rateForamatSelected.add(rateFormat);
    if (fmtMapEntry.isOnEdit()) inputFormatCombo.setDisabled(true);
    final Collection<String> comboRateArray = new ArrayList<String>();
    if (inputRateSelected.equals("VFI_480i")) {

      comboRateArray.add(VideoFormatT.findByValue(21).toString().replaceAll("VF_", ""));
      comboRateArray.add(VideoFormatT.findByValue(22).toString().replaceAll("VF_", ""));
      comboRateArray.add(VideoFormatT.findByValue(23).toString().replaceAll("VF_", ""));
    } else {

      comboRateArray.add(VideoFormatT.findByValue(1).toString().replaceAll("VF_", ""));
      comboRateArray.add(VideoFormatT.findByValue(2).toString().replaceAll("VF_", ""));
      comboRateArray.add(VideoFormatT.findByValue(3).toString().replaceAll("VF_", ""));
      comboRateArray.add(VideoFormatT.findByValue(4).toString().replaceAll("VF_", ""));
      comboRateArray.add(VideoFormatT.findByValue(5).toString().replaceAll("VF_", ""));
    }
    comboRateArray.removeAll(rateForamatSelected);
    inputFormatCombo.setModel(new ListModelList(comboRateArray));
    ComboitemRenderer renderer =
        new ComboitemRenderer() {

          @Override
          public void render(Comboitem item, Object data) throws Exception {
            String audiotype = data.toString();
            item.setLabel(audiotype);
          }
        };
    inputFormatCombo.setItemRenderer(renderer);

    inputFormatCombo.addEventListener(
        Events.ON_OPEN,
        new EventListener() {

          public void onEvent(Event event) throws Exception {
            // inputFormatCombo.getModel().getSize();
            comboRateArray.removeAll(rateForamatSelected);
            inputFormatCombo.setModel(new ListModelList(comboRateArray));
          }
        });
    inputFormatCombo.addEventListener(
        Events.ON_CHANGE,
        new EventListener() {

          public void onEvent(Event event) throws Exception {
            String rateformtname = inputFormatCombo.getText();
            if (!rateformtname.contains("VF_")) rateformtname = "VF_" + rateformtname;
            fmtMapEntry.setRateFormat(rateformtname);
            System.out.println("......." + rateForamatSelected + rateformtname);
            rateForamatSelected.add(inputFormatCombo.getText());

            inputFormatCombo.setDisabled(true);
          }
        });

    inputFormatCombo.setParent(row);

    final Intbox bitrateIntBox = new Intbox();
    bitrateIntBox.setMaxlength(5);
    bitrateIntBox.setConstraint(new IntValueConstraint());
    bitrateIntBox.setText(fmtMapEntry.getBitRate());
    bitrateIntBox.addEventListener(
        Events.ON_CHANGE,
        new EventListener() {
          public void onEvent(Event event) throws Exception {

            try {
              fmtMapEntry.setBitRate(bitrateIntBox.getText());
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        });
    bitrateIntBox.setParent(row);
    final Button cancelBtn = new Button();

    cancelBtn.setSclass("check_off");
    cancelBtn.setTooltiptext("Delete");

    cancelBtn.addEventListener(
        Events.ON_CLICK,
        new EventListener() {
          public void onEvent(Event event) throws Exception {

            if (row.getGrid().getListModel().getSize() > 1) {
              removeRow(row);
            } else {
              Messagebox.show(
                  "Sorry,You will not be able to delete this row.!",
                  "Aereo",
                  Messagebox.OK,
                  Messagebox.INFORMATION);
            }
          }
        });

    cancelBtn.setParent(row);
  }
  public void onClick$buttonImprimir() {
    String nombrepdf = "";
    try {
      Calendar cal = Calendar.getInstance();
      // lol
      Calendar cal2 = new GregorianCalendar();
      Document document = new Document();
      String nombre =
          ""
              + (cal.getTime().getYear() + 1900)
              + "_"
              + (cal.getTime().getMonth() + 1)
              + "_"
              + cal.getTime().getDate();
      String tipo = "";
      Font miFuente = new Font();
      miFuente.setStyle(Font.BOLD);
      miFuente.setColor(Color.BLUE);
      Font miFuente2 = new Font();
      miFuente2.setStyle(Font.BOLD);
      miFuente2.setColor(Color.RED);
      PdfPTable tabla;
      PdfPCell celda;
      PdfPCell c1;
      ReporteProducto rowlista;
      String dem = "";
      String esp = "";
      if (cmb_demanda.getText().equals("Mayor Demanda")) {
        dem = "mayDemanda";
      } else {
        dem = "menDemanda";
      }

      if (cmb_tipo.getText().equals("General")) {
        esp = dem + "General";
      } else {
        esp = dem + "PorCat";
      }

      if (cmb_tiempo.getText().equals("Por Año")) {
        tipo = esp + "PorAño";
        tabla = new PdfPTable(4);
        celda = new PdfPCell(new Phrase("Año", miFuente2));
        celda.setHorizontalAlignment(Element.ALIGN_CENTER);
        celda.setVerticalAlignment(Element.ALIGN_CENTER);
        tabla.addCell(celda);
        celda = new PdfPCell(new Phrase("Producto", miFuente2));
        celda.setHorizontalAlignment(Element.ALIGN_CENTER);
        celda.setVerticalAlignment(Element.ALIGN_CENTER);
        tabla.addCell(celda);
        celda = new PdfPCell(new Phrase("Categoría", miFuente2));
        celda.setHorizontalAlignment(Element.ALIGN_CENTER);
        celda.setVerticalAlignment(Element.ALIGN_CENTER);
        tabla.addCell(celda);
        celda = new PdfPCell(new Phrase("Cantidad de Pedidos", miFuente2));
        celda.setHorizontalAlignment(Element.ALIGN_CENTER);
        celda.setVerticalAlignment(Element.ALIGN_CENTER);
        tabla.addCell(celda);
        for (int i = 0; i < lista.size(); i++) {
          rowlista = lista.get(i);
          c1 = new PdfPCell(new Phrase("" + rowlista.getFinicial()));
          c1.setHorizontalAlignment(Element.ALIGN_CENTER);
          c1.setVerticalAlignment(Element.ALIGN_CENTER);
          tabla.addCell(c1);
          c1 = new PdfPCell(new Phrase("" + rowlista.getProducto()));
          c1.setHorizontalAlignment(Element.ALIGN_CENTER);
          c1.setVerticalAlignment(Element.ALIGN_CENTER);
          tabla.addCell(c1);
          c1 = new PdfPCell(new Phrase("" + rowlista.getCategoria()));
          c1.setHorizontalAlignment(Element.ALIGN_CENTER);
          c1.setVerticalAlignment(Element.ALIGN_CENTER);
          tabla.addCell(c1);
          c1 = new PdfPCell(new Phrase("" + rowlista.getCantidad()));
          c1.setHorizontalAlignment(Element.ALIGN_CENTER);
          c1.setVerticalAlignment(Element.ALIGN_CENTER);
          tabla.addCell(c1);
        }
      } else {
        if (cmb_tiempo.getText().equals("Por Mes")) {
          tipo = esp + "PorMes";
          tabla = new PdfPTable(5);
          celda = new PdfPCell(new Phrase("Año", miFuente2));
          celda.setHorizontalAlignment(Element.ALIGN_CENTER);
          celda.setVerticalAlignment(Element.ALIGN_CENTER);
          tabla.addCell(celda);
          celda = new PdfPCell(new Phrase("Mes", miFuente2));
          celda.setHorizontalAlignment(Element.ALIGN_CENTER);
          celda.setVerticalAlignment(Element.ALIGN_CENTER);
          tabla.addCell(celda);
          celda = new PdfPCell(new Phrase("Producto", miFuente2));
          celda.setHorizontalAlignment(Element.ALIGN_CENTER);
          celda.setVerticalAlignment(Element.ALIGN_CENTER);
          tabla.addCell(celda);
          celda = new PdfPCell(new Phrase("Categoría", miFuente2));
          celda.setHorizontalAlignment(Element.ALIGN_CENTER);
          celda.setVerticalAlignment(Element.ALIGN_CENTER);
          tabla.addCell(celda);
          celda = new PdfPCell(new Phrase("Cantidad de Pedidos", miFuente2));
          celda.setHorizontalAlignment(Element.ALIGN_CENTER);
          celda.setVerticalAlignment(Element.ALIGN_CENTER);
          tabla.addCell(celda);

        } else {
          tipo = esp + "PorFecha";
          tabla = new PdfPTable(5);
          celda = new PdfPCell(new Phrase("Fecha Inicial", miFuente2));
          celda.setHorizontalAlignment(Element.ALIGN_CENTER);
          celda.setVerticalAlignment(Element.ALIGN_CENTER);
          tabla.addCell(celda);
          celda = new PdfPCell(new Phrase("Fecha Final", miFuente2));
          celda.setHorizontalAlignment(Element.ALIGN_CENTER);
          celda.setVerticalAlignment(Element.ALIGN_CENTER);
          tabla.addCell(celda);
          celda = new PdfPCell(new Phrase("Producto", miFuente2));
          celda.setHorizontalAlignment(Element.ALIGN_CENTER);
          celda.setVerticalAlignment(Element.ALIGN_CENTER);
          tabla.addCell(celda);
          celda = new PdfPCell(new Phrase("Categoría", miFuente2));
          celda.setHorizontalAlignment(Element.ALIGN_CENTER);
          celda.setVerticalAlignment(Element.ALIGN_CENTER);
          tabla.addCell(celda);
          celda = new PdfPCell(new Phrase("Cantidad de Pedidos", miFuente2));
          celda.setHorizontalAlignment(Element.ALIGN_CENTER);
          celda.setVerticalAlignment(Element.ALIGN_CENTER);
          tabla.addCell(celda);
        }

        for (int i = 0; i < lista.size(); i++) {
          rowlista = lista.get(i);
          c1 = new PdfPCell(new Phrase("" + rowlista.getFinicial()));
          c1.setHorizontalAlignment(Element.ALIGN_CENTER);
          c1.setVerticalAlignment(Element.ALIGN_CENTER);
          tabla.addCell(c1);
          c1 = new PdfPCell(new Phrase("" + rowlista.getFfinal()));
          c1.setHorizontalAlignment(Element.ALIGN_CENTER);
          c1.setVerticalAlignment(Element.ALIGN_CENTER);
          tabla.addCell(c1);
          c1 = new PdfPCell(new Phrase("" + rowlista.getProducto()));
          c1.setHorizontalAlignment(Element.ALIGN_CENTER);
          c1.setVerticalAlignment(Element.ALIGN_CENTER);
          tabla.addCell(c1);
          c1 = new PdfPCell(new Phrase("" + rowlista.getCategoria()));
          c1.setHorizontalAlignment(Element.ALIGN_CENTER);
          c1.setVerticalAlignment(Element.ALIGN_CENTER);
          tabla.addCell(c1);
          c1 = new PdfPCell(new Phrase("" + rowlista.getCantidad()));
          c1.setHorizontalAlignment(Element.ALIGN_CENTER);
          c1.setVerticalAlignment(Element.ALIGN_CENTER);
          tabla.addCell(c1);
        }
      }
      nombrepdf = "ReporteProductos" + tipo + "_" + nombre + ".pdf";
      PdfWriter.getInstance(document, new FileOutputStream(nombrepdf));
      document.open();
      Paragraph Titulo =
          new Paragraph(
              "Reporte "
                  + cmb_tipo.getText()
                  + " de Productos de "
                  + cmb_demanda.getText()
                  + " "
                  + cmb_tiempo.getText(),
              miFuente);
      Titulo.setAlignment(Element.ALIGN_CENTER);
      Paragraph encabezado = new Paragraph("Prueba");
      encabezado.setAlignment(Element.ALIGN_CENTER);
      document.add(Titulo);
      document.add(encabezado);
      document.add(new Paragraph(" "));

      document.add(tabla);
      document.close();
    } catch (Exception e) {

      e.printStackTrace();
    }
    Hashtable h = new Hashtable();
    h.put("File", nombrepdf);
    Executions.getCurrent()
        .createComponents("Modulo_Reportes/Pdf_Viewer.zul", win_reportesproductos, h);
    File filepdf = new File(nombrepdf);
    filepdf.delete();
    /*  try {
    if ((new File(nombrepdf)).exists()) {
    	Process p = Runtime
    	   .getRuntime()
    	   .exec("rundll32 url.dll,FileProtocolHandler "+nombrepdf);
    	p.waitFor();
    	buttonImprimir.setVisible(false);
    } else {
    	alert("File is not exists!");
    }
    alert("Done!");
    	  } catch (Exception ex) {
    ex.printStackTrace();
     }*/
  }