List of usage examples for com.itextpdf.text.pdf PdfPCell setBackgroundColor
public void setBackgroundColor(final BaseColor backgroundColor)
From source file:be.roots.taconic.pricingguide.service.PDFServiceImpl.java
License:Open Source License
private PdfPCell cellH(Phrase p) { final PdfPCell cell = new PdfPCell(p); cell.setBackgroundColor(iTextUtil.getPurple()); cell.setPadding(5f);//from w w w . j a v a2 s . c o m cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(0); return cell; }
From source file:be.zenodotus.creatie.GeneratePDF.java
License:Open Source License
public String vakantieAfdruk(Context context, String name, int jaar) { this.context = context; PdfWriter w = null;/*w w w . ja v a2s .c o m*/ Document d = new Document(PageSize.A4.rotate(), 5, 5, 10, 10); d.setPageCount(3); String fileName = name; String file = name; GregorianCalendar datum = new GregorianCalendar(); datum.set(GregorianCalendar.YEAR, jaar); String[] maanden = { "Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December" }; int[] dagen = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; VerlofDao dao = new VerlofDao(context); FeestdagDao feestdagDao = new FeestdagDao(context); WerkdagDao werkdagDao = new WerkdagDao(context); File folder = new File(context.getFilesDir(), "pdfs"); folder.mkdirs(); if (datum.isLeapYear(jaar)) { dagen[1] = 29; } File temp = null; temp = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "Jacqueline" + jaar + ".pdf"); fileName = temp.toString(); try { dao.open(); ArrayList<Verlof> verloflijst = dao.getAlleVerlovenPerJaar(jaar); w = PdfWriter.getInstance(d, new FileOutputStream(temp)); d.open(); d.addAuthor("Jacqueline Vandenbroecke"); d.addCreationDate(); d.addCreator("Verlofplanner"); d.addTitle("Vakantie " + jaar + " van Jacqueline Vandenbroecke"); Font standaard = FontFactory.getFont(FontFactory.HELVETICA, 8); Font standaardBold = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD); Paragraph gegeven = new Paragraph("Jacqueline Vandenbroecke Verlof " + jaar + "\n", standaardBold); gegeven.setAlignment(Paragraph.ALIGN_CENTER); d.add(gegeven); for (int paginas = 0; paginas < 2; paginas++) { int aantal = 0; if (paginas == 1) { d.newPage(); aantal = 6; } PdfPTable table = new PdfPTable(6); for (int i = aantal; i < (aantal + 6); i++) { PdfPCell cell = new PdfPCell(new Paragraph(maanden[i], standaardBold)); cell.setBorder(1); table.addCell(cell); } int dag = 1; int k = aantal; for (int i = aantal; i < (aantal + 6); i++) { for (int j = 0; j < 32; j++) { if (k > ((aantal + 6) - 1)) { k = aantal; dag++; } if (dag > dagen[k]) { PdfPCell cell = new PdfPCell(new Paragraph("", standaard)); table.addCell(cell); k++; } else { SimpleDateFormat formatterDag = new SimpleDateFormat("dd"); SimpleDateFormat formatterWeek = new SimpleDateFormat("EEE"); datum.set(jaar, k, dag); PdfPTable dagTabel = new PdfPTable(4); PdfPCell cellDag = new PdfPCell( new Paragraph(formatterDag.format(datum.getTime()), standaard)); PdfPCell cellWeek = new PdfPCell( new Paragraph(formatterWeek.format(datum.getTime()), standaard)); ArrayList<Verlof> verlof = new ArrayList<Verlof>(); for (int z = 0; z < verloflijst.size(); z++) { if (((verloflijst.get(z).getDag() + 1) == dag) && (verloflijst.get(z).getMaand() == k)) { verlof.add(verloflijst.get(z)); } } feestdagDao.open(); Feestdag feestdag = feestdagDao.getFeestdag(jaar, datum.get(GregorianCalendar.MONTH), datum.get(GregorianCalendar.DATE)); feestdagDao.close(); werkdagDao.open(); java.util.List<Werkdag> weekend = werkdagDao.getWeekend(); werkdagDao.close(); String Verlof = ""; String uur = ""; if (verlof.size() > 0) { if (verlof.size() > 1) { Verlof = verlof.get(0).getVerlofsoort() + "\n" + verlof.get(1).getVerlofsoort(); uur = verlof.get(0).getUrental() + "\n" + verlof.get(1).getUrental(); } else { Verlof = verlof.get(0).getVerlofsoort(); uur = verlof.get(0).getUrental(); } } PdfPCell cellVerlof = new PdfPCell(new Paragraph(Verlof, standaard)); PdfPCell uren = new PdfPCell(new Paragraph(uur, standaard)); if (verlof.size() > 0) { BaseColor kleur = new BaseColor(Color.GRAY); cellVerlof.setBackgroundColor(kleur); uren.setBackgroundColor(kleur); cellDag.setBackgroundColor(kleur); cellWeek.setBackgroundColor(kleur); } for (int z = 0; z < weekend.size(); z++) { if ((formatterWeek.format(datum.getTime())).equals(weekend.get(z).getDag())) { BaseColor kleur = new BaseColor(Color.LTGRAY); cellVerlof.setBackgroundColor(kleur); uren.setBackgroundColor(kleur); cellDag.setBackgroundColor(kleur); cellWeek.setBackgroundColor(kleur); } } if (feestdag != null) { BaseColor kleur = new BaseColor(Color.GREEN); uren.setBackgroundColor(kleur); cellVerlof.setBackgroundColor(kleur); uren.setBackgroundColor(kleur); cellDag.setBackgroundColor(kleur); cellWeek.setBackgroundColor(kleur); } dagTabel.addCell(cellDag); dagTabel.addCell(cellWeek); dagTabel.addCell(cellVerlof); dagTabel.addCell(uren); table.addCell(dagTabel); k++; } } } d.add(table); dao.close(); } } catch (Exception ex) { ex.printStackTrace(); } finally { d.close(); w.close(); } return fileName; }
From source file:beans.CronogramaPDF.java
private void createPdf(String dest) throws IOException, DocumentException, SQLException { Parametrizacion p = new Parametrizacion(); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(dest)); document.open();//ww w . ja v a 2s . c o m PdfPTable table = new PdfPTable(12); BaseColor color = new BaseColor(142, 170, 219); PdfPCell celda; Phrase texto; Font font = new Font(Font.FontFamily.TIMES_ROMAN, 7); Font font1 = new Font(Font.FontFamily.TIMES_ROMAN, 10); table.setWidthPercentage(100); Image img = Image.getInstance(p.getParametro("rutaImgServer") + "logo.png"); celda = new PdfPCell(img, true); celda.setPadding(5); celda.setColspan(4); table.addCell(celda); celda = new PdfPCell(new Phrase( "\n\n\nFecha de creacin: " + dateFormat.format(Calendar.getInstance().getTime()), font1)); celda.setColspan(8); // head.setBackgroundColor(BaseColor.CYAN); table.addCell(celda); celda = new PdfPCell(new Phrase("CRONOGRAMA DE MANTENIMIENTOS", font)); celda.setColspan(112); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase("N", font)); celda.setColspan(1); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase("CODIGO", font)); celda.setColspan(1); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase("FECHA SOLICITUD", font)); celda.setColspan(1); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase("EQUIPO", font)); celda.setColspan(3); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase("SERVICIO SOLICITADO", font)); celda.setColspan(3); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase("ACCIONES A REALIZAR", font)); celda.setColspan(3); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); int i = 1; for (SolicitudDeMantenimiento sM : this.solicitudes) { if (!sM.getEstado().equals("Realizada")) { celda = new PdfPCell(new Phrase(i + "", font)); celda.setColspan(1); table.addCell(celda); celda = new PdfPCell(new Phrase(sM.getCodigo(), font)); celda.setColspan(1); table.addCell(celda); celda = new PdfPCell(new Phrase(sM.getFecha(), font)); celda.setColspan(1); table.addCell(celda); celda = new PdfPCell(new Phrase(sM.getEquipo().getNombre(), font)); celda.setColspan(3); table.addCell(celda); celda = new PdfPCell(new Phrase(sM.getDescripcionServicio(), font)); celda.setColspan(3); table.addCell(celda); celda = new PdfPCell(new Phrase(sM.getDescripcionAcciones(), font)); celda.setColspan(3); table.addCell(celda); i++; } } document.add(table); document.close(); }
From source file:beans.ManagedBeanReportes.java
public PdfPTable traerSubtabla(Tienda t) throws DocumentException { PdfPTable tabla_PesajeDetalle = new PdfPTable(4); tabla_PesajeDetalle.setWidthPercentage(100); tabla_PesajeDetalle.setTotalWidth(450f); tabla_PesajeDetalle.setLockedWidth(true); tabla_PesajeDetalle.setWidths(anchocol03); tabla_PesajeDetalle.getDefaultCell(); PdfPCell Cell_Headers = new PdfPCell(new Paragraph("PRODUCTO", titulopequeFont)); Cell_Headers.setBackgroundColor(BaseColor.LIGHT_GRAY); Cell_Headers.setHorizontalAlignment(Paragraph.ALIGN_CENTER); Cell_Headers.setVerticalAlignment(Paragraph.ALIGN_MIDDLE); tabla_PesajeDetalle.addCell(Cell_Headers); Cell_Headers = new PdfPCell(new Paragraph("UBICACIONES", titulopequeFont)); Cell_Headers.setHorizontalAlignment(Paragraph.ALIGN_CENTER); Cell_Headers.setVerticalAlignment(Paragraph.ALIGN_MIDDLE); Cell_Headers.setBackgroundColor(BaseColor.LIGHT_GRAY); tabla_PesajeDetalle.addCell(Cell_Headers); Cell_Headers = new PdfPCell(new Paragraph("MINIMO", titulopequeFont)); Cell_Headers.setHorizontalAlignment(Paragraph.ALIGN_CENTER); Cell_Headers.setVerticalAlignment(Paragraph.ALIGN_MIDDLE); Cell_Headers.setBackgroundColor(BaseColor.LIGHT_GRAY); tabla_PesajeDetalle.addCell(Cell_Headers); Cell_Headers = new PdfPCell(new Paragraph("STOCK TOTAL", titulopequeFont)); Cell_Headers.setBackgroundColor(BaseColor.LIGHT_GRAY); Cell_Headers.setVerticalAlignment(Paragraph.ALIGN_MIDDLE); Cell_Headers.setHorizontalAlignment(Paragraph.ALIGN_CENTER); tabla_PesajeDetalle.addCell(Cell_Headers); for (StockProductoTiendaOrigen det : stockProductoTiendaOrigenFacade.lista_stock_tienda(t)) { tabla_PesajeDetalle.addCell(traerCelda(det.getProducto().getNombreProducto())); String ubicaciones_ = ""; for (DetalleAlmacenProductos p : detalleAlmacenProductosFacade.lista_para_stock_tienda(t, det.getProducto())) {/*from w w w. j av a 2s .co m*/ if (p.getUbicacionFisica().getIdUbicacionFisica() > 1) { ubicaciones_ = p.getUbicacionFisica().getNombreUbicacionFisica() + ";" + ubicaciones_; } } tabla_PesajeDetalle.addCell(traerCelda(ubicaciones_)); tabla_PesajeDetalle.addCell(traerCelda(String.valueOf(det.getCantidadMinimaStock()))); tabla_PesajeDetalle.addCell(traerCelda(String.valueOf(det.getCantidad()))); } return tabla_PesajeDetalle; }
From source file:beans.OrdenDeTrabajoPDF.java
private void createPdf(String dest) throws IOException, DocumentException { Parametrizacion p = new Parametrizacion(); this.listaPartes = new JsonParser().parse(ot.getPartes()).getAsJsonArray(); this.listaDescripcionesTrabajos = new JsonParser().parse(ot.getDescripcionesTrabajos()).getAsJsonArray(); this.listaMateriales = new JsonParser().parse(ot.getMateriales()).getAsJsonArray(); Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(dest)); document.open();// ww w . ja va 2 s .c o m PdfPTable table = new PdfPTable(12); BaseColor color = new BaseColor(142, 170, 219); PdfPCell celda; Phrase texto; Font font = new Font(Font.FontFamily.TIMES_ROMAN, 10); table.setWidthPercentage(100); Image img = Image.getInstance(p.getParametro("rutaImgServer") + "logo.png"); celda = new PdfPCell(img, true); celda.setPadding(5); celda.setColspan(4); table.addCell(celda); celda = new PdfPCell(new Phrase("ORDEN DE TRABAJO N:" + this.ot.getNumeroOrdenDeTrabajo() + "\nFECHA INICIO:" + this.ot.getFechaInicio() + "\nFECHA FIN:" + this.ot.getFechaFin() + "\nSOLICITUD N:" + this.ot.getSolicitudDeMantenimiento().getCodigo() + "", font)); celda.setColspan(8); // head.setBackgroundColor(BaseColor.CYAN); table.addCell(celda); String tipoSolicitud = ot.getTipoSolicitud(); if (tipoSolicitud.equals("Urgente")) { celda = new PdfPCell(new Phrase("TIPO DE SOLICITUD NORMAL: URGENTE: X", font)); celda.setColspan(12); table.addCell(celda); } else { celda = new PdfPCell(new Phrase("TIPO DE SOLICITUD NORMAL: X URGENTE:", font)); celda.setColspan(12); table.addCell(celda); } if (ot.isDptAdmyControl()) { celda = new PdfPCell(new Phrase( "DTO.ADMS. Y CONTROL DE LA PRODUCCION" + " GENERA ORDEN DE TRABAJO DE MTTO SI:X NO:", font)); celda.setColspan(12); table.addCell(celda); } else { celda = new PdfPCell(new Phrase( "DTO.ADMS. Y CONTROL DE LA PRODUCCION" + " GENERA ORDEN DE TRABAJO DE MTTO SI: NO:X", font)); celda.setColspan(12); table.addCell(celda); } celda = new PdfPCell( new Phrase("CODIGO EQUIPO: " + ot.getSolicitudDeMantenimiento().getEquipo().getCodigo(), font)); celda.setColspan(3); table.addCell(celda); celda = new PdfPCell( new Phrase("NOMBRE EQUIPO: " + ot.getSolicitudDeMantenimiento().getEquipo().getNombre(), font)); celda.setColspan(9); table.addCell(celda); String tipoMantenimiento = ""; for (String element : ot.getTiposDeMantenimiento()) { tipoMantenimiento += element + "\n"; } celda = new PdfPCell(new Phrase("TIPO DE MANTENIMIENTO\n", font)); celda.setColspan(12); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase(tipoMantenimiento, font)); celda.setColspan(12); table.addCell(celda); celda = new PdfPCell(new Phrase("PARTE", font)); celda.setColspan(3); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase("ANOMALIA", font)); celda.setColspan(3); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase("CAUSA", font)); celda.setColspan(3); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase("POSIBLE SOLUCION", font)); celda.setColspan(3); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); for (int i = 0; i < listaPartes.size(); i++) { celda = new PdfPCell(new Phrase( listaPartes.get(i).getAsJsonObject().get("parte").toString().replace("\"", ""), font)); celda.setColspan(3); table.addCell(celda); celda = new PdfPCell(new Phrase( listaPartes.get(i).getAsJsonObject().get("anomalia").toString().replace("\"", ""), font)); celda.setColspan(3); table.addCell(celda); celda = new PdfPCell(new Phrase( listaPartes.get(i).getAsJsonObject().get("causa").toString().replace("\"", ""), font)); celda.setColspan(3); table.addCell(celda); celda = new PdfPCell(new Phrase( listaPartes.get(i).getAsJsonObject().get("solucion").toString().replace("\"", ""), font)); celda.setColspan(3); table.addCell(celda); } celda = new PdfPCell(new Phrase("SOLICTADA POR: " + ot.getSolicitadaPor() + "\n\nFIRMA", font)); celda.setColspan(4); table.addCell(celda); celda = new PdfPCell(new Phrase("REVISADA POR: " + ot.getRevisadaPor() + "\n\nFIRMA", font)); celda.setColspan(4); table.addCell(celda); celda = new PdfPCell(new Phrase("AUTORIZADA POR: " + ot.getAutorizadaPor() + "\n\nFIRMA", font)); celda.setColspan(4); table.addCell(celda); celda = new PdfPCell(new Phrase("N", font)); celda.setColspan(1); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase("DESCRIPCIN DE LOS TRABAJOS A REALIZAR", font)); celda.setColspan(11); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); for (int i = 0; i < listaDescripcionesTrabajos.size(); i++) { celda = new PdfPCell(new Phrase((i + 1) + "", font)); celda.setColspan(1); table.addCell(celda); celda = new PdfPCell(new Phrase( listaDescripcionesTrabajos.get(i).getAsJsonObject().get("trabajo").toString().replace("\"", ""), font)); celda.setColspan(11); table.addCell(celda); } celda = new PdfPCell(new Phrase("MATERIALES", font)); celda.setColspan(12); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase("N", font)); celda.setColspan(1); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase("CANTIDAD", font)); celda.setColspan(2); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase("DESCRIPCIN", font)); celda.setColspan(3); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase("REFERENCIA", font)); celda.setColspan(2); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase("VALOR UNI", font)); celda.setColspan(2); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase("VALOR TOTAL", font)); celda.setColspan(2); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); for (int i = 0; i < listaMateriales.size(); i++) { celda = new PdfPCell(new Phrase("" + (1 + i), font)); celda.setColspan(1); table.addCell(celda); celda = new PdfPCell(new Phrase( listaMateriales.get(i).getAsJsonObject().get("cantidad").toString().replace("\"", ""), font)); celda.setColspan(2); table.addCell(celda); celda = new PdfPCell(new Phrase( listaMateriales.get(i).getAsJsonObject().get("descripcion").toString().replace("\"", ""), font)); celda.setColspan(3); table.addCell(celda); celda = new PdfPCell(new Phrase( listaMateriales.get(i).getAsJsonObject().get("referencia").toString().replace("\"", ""), font)); celda.setColspan(2); table.addCell(celda); celda = new PdfPCell(new Phrase( listaMateriales.get(i).getAsJsonObject().get("unitario").toString().replace("\"", ""), font)); celda.setColspan(2); table.addCell(celda); celda = new PdfPCell(new Phrase( listaMateriales.get(i).getAsJsonObject().get("total").toString().replace("\"", ""), font)); celda.setColspan(2); table.addCell(celda); } celda = new PdfPCell(new Phrase("COSTOS", font)); celda.setBackgroundColor(new BaseColor(142, 170, 219)); celda.setColspan(12); table.addCell(celda); celda = new PdfPCell(new Phrase("MANO DE OBRA: $" + ot.getCostoManoDeObra() + "", font)); celda.setColspan(4); table.addCell(celda); celda = new PdfPCell(new Phrase("MATERIALES: $" + ot.getCostoMateriales() + "", font)); celda.setColspan(4); table.addCell(celda); celda = new PdfPCell(new Phrase("TOTAL: $" + ot.getCostoTotal() + "", font)); celda.setColspan(4); table.addCell(celda); celda = new PdfPCell(new Phrase("TIEMPO EMPLEADO", font)); celda.setBackgroundColor(new BaseColor(142, 170, 219)); celda.setColspan(12); table.addCell(celda); celda = new PdfPCell(new Phrase("TOTAL HORAS MTO: " + ot.getTotalHorasMto() + "", font)); celda.setColspan(6); table.addCell(celda); celda = new PdfPCell(new Phrase("TOTAL HORAS PARADA: " + ot.getTotalHorasParada() + "", font)); celda.setColspan(6); table.addCell(celda); celda = new PdfPCell(new Phrase("DESCRIPCIN DE LOS DAOS ENCONTRADOS", font)); celda.setBackgroundColor(new BaseColor(142, 170, 219)); celda.setColspan(12); table.addCell(celda); celda = new PdfPCell(new Phrase("" + ot.getDescripcionDanos(), font)); celda.setColspan(12); table.addCell(celda); celda = new PdfPCell(new Phrase("DESCRIPCIN DE LOS TRABAJOS REALIZADOS", font)); celda.setBackgroundColor(new BaseColor(142, 170, 219)); celda.setColspan(12); table.addCell(celda); celda = new PdfPCell(new Phrase("" + ot.getDescripcionTrabajosRealizados(), font)); celda.setColspan(12); table.addCell(celda); celda = new PdfPCell(new Phrase("OBSERVACIONES Y RECOMENDACIONES", font)); celda.setBackgroundColor(new BaseColor(142, 170, 219)); celda.setColspan(12); table.addCell(celda); celda = new PdfPCell(new Phrase("" + ot.getObservaciones(), font)); celda.setColspan(12); table.addCell(celda); celda = new PdfPCell(new Phrase("EJECUTO: " + ot.getEjecutadoPor() + "\n\nFIRMA", font)); celda.setColspan(6); table.addCell(celda); celda = new PdfPCell(new Phrase("RECIBI Y APROB: " + ot.getRecibidoAprobadoPor() + "\n\nFIRMA", font)); celda.setColspan(6); table.addCell(celda); document.add(table); document.close(); }
From source file:beans.SolicitudDeMantenimientoPDF.java
public void createPdf(String dest) throws IOException, DocumentException { Parametrizacion p = new Parametrizacion(); Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(dest)); document.open();// ww w . j a va2 s . c om PdfPTable table = new PdfPTable(12); Font font = new Font(Font.FontFamily.TIMES_ROMAN, 10); PdfPCell celda; table.setWidthPercentage(100); Image img = Image.getInstance(p.getParametro("rutaImgServer") + "logo.png"); celda = new PdfPCell(img, true); celda.setPadding(5); celda.setColspan(4); table.addCell(celda); celda = new PdfPCell(new Phrase("CODIGO: " + sm.getCodigo() + "\nREVISION: " + sm.getRevision() + "\nSOLICITUD DE SERVICIO: " + sm.getSolicitudDeServicio() + "\nFECHA: " + sm.getFecha() + "", font)); celda.setColspan(8); // head.setBackgroundColor(BaseColor.CYAN); table.addCell(celda); celda = new PdfPCell(new Phrase("SECCION", font)); celda.setColspan(4); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase("MAQUINA", font)); celda.setColspan(4); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase("NOMBRE DEL OPERARIO", font)); celda.setColspan(4); celda.setBackgroundColor(new BaseColor(142, 170, 219)); table.addCell(celda); celda = new PdfPCell(new Phrase("" + sm.getEquipo().getUbicacion(), font)); celda.setColspan(4); table.addCell(celda); celda = new PdfPCell(new Phrase("" + sm.getEquipo().getNombre(), font)); celda.setColspan(4); table.addCell(celda); celda = new PdfPCell(new Phrase("" + sm.getEquipo().getOperario(), font)); celda.setColspan(4); table.addCell(celda); celda = new PdfPCell(new Phrase("SERVICIO SOLICITADO", font)); celda.setBackgroundColor(new BaseColor(142, 170, 219)); celda.setColspan(12); table.addCell(celda); String reparacion = " "; String mtoMecanico = " "; String mtoPreventivo = " "; String mtoElectrico = " "; String mtoCorrectivo = " "; String otros = " "; if (sm.isReparacion()) { reparacion += " X"; } if (sm.isMtoMecanico()) { mtoMecanico += " X"; } if (sm.isMtoPreventivo()) { mtoPreventivo += " X"; } if (sm.isMtoElectrico()) { mtoElectrico += " X"; } if (sm.isMtoCorrectivo()) { mtoCorrectivo += " X"; } if (sm.isOtros()) { otros += " X"; } celda = new PdfPCell(new Phrase("REPARACION", font)); celda.setColspan(3); table.addCell(celda); celda = new PdfPCell(new Phrase(reparacion, font)); celda.setColspan(1); table.addCell(celda); celda = new PdfPCell(new Phrase("MTO. MECANICO", font)); celda.setColspan(3); table.addCell(celda); celda = new PdfPCell(new Phrase(mtoMecanico, font)); celda.setColspan(1); table.addCell(celda); celda = new PdfPCell(new Phrase("MTO. PREVENTIVO", font)); celda.setColspan(3); table.addCell(celda); celda = new PdfPCell(new Phrase(mtoPreventivo, font)); celda.setColspan(1); table.addCell(celda); celda = new PdfPCell(new Phrase("MTO. ELECTRICO", font)); celda.setColspan(3); table.addCell(celda); celda = new PdfPCell(new Phrase(mtoElectrico, font)); celda.setColspan(1); table.addCell(celda); celda = new PdfPCell(new Phrase("MTO. CORRECTIVO", font)); celda.setColspan(3); table.addCell(celda); celda = new PdfPCell(new Phrase(mtoCorrectivo, font)); celda.setColspan(1); table.addCell(celda); celda = new PdfPCell(new Phrase("OTROS", font)); celda.setColspan(3); table.addCell(celda); celda = new PdfPCell(new Phrase(otros, font)); celda.setColspan(1); table.addCell(celda); celda = new PdfPCell(new Phrase("DESCRIPCIN DEL SERVICIO SOLICITADO", font)); celda.setBackgroundColor(new BaseColor(142, 170, 219)); celda.setColspan(12); table.addCell(celda); celda = new PdfPCell(new Phrase("" + sm.getDescripcionServicio(), font)); celda.setColspan(12); table.addCell(celda); celda = new PdfPCell(new Phrase("DESCRIPCIN DE ACCIONES A REALIZAR", font)); celda.setBackgroundColor(new BaseColor(142, 170, 219)); celda.setColspan(12); table.addCell(celda); celda = new PdfPCell(new Phrase("" + sm.getDescripcionAcciones(), font)); celda.setColspan(12); table.addCell(celda); celda = new PdfPCell(new Phrase("MATERIAL A EMPLEAR", font)); celda.setBackgroundColor(new BaseColor(142, 170, 219)); celda.setColspan(12); table.addCell(celda); celda = new PdfPCell(new Phrase("" + sm.getMaterial(), font)); celda.setColspan(12); table.addCell(celda); celda = new PdfPCell(new Phrase("GENERALIDADES", font)); celda.setBackgroundColor(new BaseColor(142, 170, 219)); celda.setColspan(12); table.addCell(celda); celda = new PdfPCell(new Phrase("TOTAL HORAS PARADA: " + sm.getHorasParada() + "", font)); celda.setColspan(6); table.addCell(celda); celda = new PdfPCell(new Phrase("HORA SOLICITUD: " + sm.getHoraSolicitud() + "", font)); celda.setColspan(6); table.addCell(celda); celda = new PdfPCell(new Phrase("TOTAL HORAS MTO: " + sm.getHorasMTO() + "", font)); celda.setColspan(6); table.addCell(celda); celda = new PdfPCell(new Phrase("HORA ENTREGA: " + sm.getHoraEntrega() + "", font)); celda.setColspan(6); table.addCell(celda); celda = new PdfPCell(new Phrase("SERVICIO SOLICITADO POR: " + sm.getSolicitadoPor() + "\n" + "SERVICIO REALIZADO POR: " + sm.getRealizadoPor() + "\n" + "RECIBO A CONFORMIDAD: " + sm.getRecibidoPor() + "\n\n\n FIRMA", font)); celda.setColspan(12); table.addCell(celda); document.add(table); document.close(); }
From source file:bemyguest.controller.ValidationResevation.java
@FXML private void handleButtonValiderAction(ActionEvent event) throws FileNotFoundException, DocumentException { Resrevation e = tab_reservation.getSelectionModel().getSelectedItem(); if (e == null) { Alert alert = new Alert(Alert.AlertType.WARNING); alert.setTitle("Warning Dialog"); alert.setHeaderText(null);/* w w w . j ava2 s . c om*/ alert.setContentText("selectionner un demande de reservation a traiter svp!"); alert.showAndWait(); LoadData(); setCellTable(); } else { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("Confiramtion"); alert.setHeaderText(null); alert.setContentText("vous etes sur d'accepter cette demande de reservation"); Optional<ButtonType> answer = alert.showAndWait(); if (answer.get() == ButtonType.OK) { ResevationDAO dao = new ResevationDAO(); if (dao.ajouter_Reservation(e)) { LoadData(); setCellTable(); alert.setTitle("Success Dialog"); alert.setHeaderText(null); alert.setContentText("Demandes accepter avec success"); alert.showAndWait(); try { Document d = new Document(PageSize.A4.rotate()); PdfWriter.getInstance(d, new FileOutputStream(e.getUser().getNom() + "Facture.pdf")); d.open(); d.add(new Paragraph("BeMyGuest Facture :", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.RED))); d.add(new Paragraph(new Date().toString())); d.add(new Paragraph( "-------------------------------------------------------------------------------------------------------------")); d.add(new Paragraph(" ")); d.add(new Paragraph(" ")); PdfPTable pdt = new PdfPTable(7); PdfPCell cell = new PdfPCell(new Paragraph("Composant de facture")); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.RED); pdt.addCell(cell); pdt.addCell(new Paragraph("Nom:", FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK))); pdt.addCell(new Paragraph("Prenom:", FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK))); pdt.addCell(new Paragraph("Date Debut:", FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK))); pdt.addCell(new Paragraph("Date Fin:", FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK))); pdt.addCell(new Paragraph("nbre chambre:", FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK))); pdt.addCell(new Paragraph("nbre personne:", FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK))); pdt.addCell(new Paragraph("Prix:", FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK))); pdt.addCell(new Paragraph(e.getUserDemandant().getNom(), FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK))); pdt.addCell(new Paragraph(e.getUserDemandant().getPrenom(), FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK))); pdt.addCell(new Paragraph(e.getDateDebut().toString(), FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK))); pdt.addCell(new Paragraph(e.getDateFin().toString(), FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK))); pdt.addCell(e.getDateDebut().toString()); int nb = e.getPropriete().getNbrChambre(); float pr = e.getPropriete().getPrix(); int nbp = e.getPropriete().getNbrVoyageur(); pdt.addCell(new Paragraph(Integer.toString(nb), FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK))); pdt.addCell(new Paragraph(Integer.toString(nbp), FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK))); pdt.addCell(new Paragraph(Float.toString(pr), FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK))); pdt.addCell(Float.toString(pr)); d.add(pdt); d.close(); } catch (Exception b) { JOptionPane.showMessageDialog(null, b); } } else { alert.setTitle("Error Dialog"); alert.setHeaderText(null); alert.setContentText("Cette Propriete Reserver pendant cette date "); alert.showAndWait(); LoadData(); setCellTable(); } } else { LoadData(); setCellTable(); } } }
From source file:Capa_Modelo.Reportes.java
public void generarReporteInventario() { Connection con;// w w w.j ava 2 s.c o m ResultSet res; Statement sentencia; Document documento = new Document(PageSize.A4); con = ConexionDB.GetConnection(); try { sentencia = con.createStatement(); res = sentencia.executeQuery( "SELECT Cantidad, Cantidadmin, Cantidadmax, Medicamento.Nombre, Medicamento.FechaElaboracion, Medicamento.Composicion, Medicamento.FechaVencimiento, Medicamento.Laboratorio FROM Inventario inner join Medicamento on Inventario.ID_Medicamento = Medicamento.ID_Medicamento "); PdfWriter.getInstance(documento, new FileOutputStream( "reportes/reporte_de_inventario " + fechaActual() + " " + horaActual() + ".pdf")); documento.open(); float[] columnWidths = { 2, 2, 2, 2, 2, 2, 2, 2 }; PdfPTable table = new PdfPTable(columnWidths); table.setWidthPercentage(100); table.getDefaultCell().setUseAscender(true); table.getDefaultCell().setUseDescender(true); Font f = new Font(Font.FontFamily.HELVETICA, 13, Font.NORMAL, GrayColor.GRAYWHITE); PdfPCell cell = new PdfPCell(new Phrase("Reporte de Medicamentos", f)); cell.setBackgroundColor(GrayColor.GRAYBLACK); cell.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_CENTER); cell.setColspan(8); table.addCell(cell); table.getDefaultCell().setBackgroundColor(new GrayColor(0.75f)); for (int i = 0; i < 2; i++) { table.addCell("Medicamento"); table.addCell("Composicion"); table.addCell("Laboratorio"); table.addCell("Fecha de Elaboracion"); table.addCell("Fecha de Vencimiento"); table.addCell("Cantidad minima"); table.addCell("Cantidad actual"); table.addCell("Cantidad maxima"); } table.setHeaderRows(3); table.setFooterRows(1); table.getDefaultCell().setBackgroundColor(GrayColor.GRAYWHITE); table.getDefaultCell().setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_CENTER); while (res.next()) { table.addCell(res.getString("Nombre")); table.addCell(res.getString("Composicion")); table.addCell(res.getString("Laboratorio")); table.addCell(res.getString("FechaElaboracion")); table.addCell(res.getString("FechaVencimiento")); table.addCell(res.getString("Cantidadmin")); table.addCell(res.getString("Cantidad")); table.addCell(res.getString("Cantidadmax")); } documento.add(table); documento.close(); JOptionPane.showMessageDialog(null, "Reporte de Inventario generado correctamente"); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, "Error al conectar con la base de datos"); } catch (FileNotFoundException ex) { JOptionPane.showMessageDialog(null, "Error al generar la ruta del archivo"); } catch (DocumentException ex) { JOptionPane.showMessageDialog(null, "Error al generar el archivo"); } }
From source file:Capa_Modelo.Reportes.java
public void generarReporteVencimiento() { Connection con;//w w w . j av a 2 s . c o m ResultSet res; Statement sentencia; Document documento = new Document(PageSize.A4); con = ConexionDB.GetConnection(); try { sentencia = con.createStatement(); res = sentencia.executeQuery( "SELECT Cantidad, Cantidadmin, Cantidadmax, Medicamento.Nombre, Medicamento.FechaElaboracion, Medicamento.FechaVencimiento, Medicamento.Laboratorio FROM Inventario inner join Medicamento on Inventario.ID_Medicamento = Medicamento.ID_Medicamento "); PdfWriter.getInstance(documento, new FileOutputStream( "reportes/reporte_de_vencimiento " + fechaActual() + " " + horaActual() + ".pdf")); documento.open(); float[] columnWidths = { 2, 2, 2, 2 }; PdfPTable table = new PdfPTable(columnWidths); table.setWidthPercentage(100); table.getDefaultCell().setUseAscender(true); table.getDefaultCell().setUseDescender(true); Font f = new Font(Font.FontFamily.HELVETICA, 13, Font.NORMAL, GrayColor.GRAYWHITE); PdfPCell cell = new PdfPCell(new Phrase("Reporte de Vencimiento", f)); cell.setBackgroundColor(GrayColor.GRAYBLACK); cell.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); table.getDefaultCell().setBackgroundColor(new GrayColor(0.75f)); for (int i = 0; i < 2; i++) { table.addCell("Medicamento"); table.addCell("Laboratorio"); table.addCell("Fecha de Vencimiento"); table.addCell("Cantidad actual"); } table.setHeaderRows(3); table.setFooterRows(1); table.getDefaultCell().setBackgroundColor(GrayColor.GRAYWHITE); table.getDefaultCell().setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_CENTER); while (res.next()) { if (vencido(res.getDate("FechaVencimiento"))) { table.addCell(res.getString("Nombre")); table.addCell(res.getString("Laboratorio")); table.addCell(res.getString("FechaVencimiento")); table.addCell(res.getString("Cantidad")); } } documento.add(table); documento.close(); JOptionPane.showMessageDialog(null, "Reporte de Vencimiento generado correctamente"); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, "Error en conectar con base de datos"); } catch (DocumentException ex) { Logger.getLogger(Reportes.class.getName()).log(Level.SEVERE, null, "El documento no se pudo generar"); } catch (FileNotFoundException ex) { Logger.getLogger(Reportes.class.getName()).log(Level.SEVERE, null, "EL archivo no se abri"); } }
From source file:Capa_Modelo.Reportes.java
public void generarReporteConsumoMedicamentos() { DecimalFormat df = new DecimalFormat("####0.00"); Connection con;// w w w .ja v a 2s .co m ResultSet res; Statement sentencia; Document documento = new Document(PageSize.A4); double consumo, cantidad; double porcentaje; consumo = cantidad = 0; con = ConexionDB.GetConnection(); try { sentencia = con.createStatement(); res = sentencia.executeQuery( "SELECT Medicamento.Nombre, Medicamento.Composicion, Medicamento.Laboratorio, Inventario.Cantidad, SUM(MedicinaPaciente.Cantidad) as Consumo FROM MedicinaPaciente INNER JOIN Medicamento ON MedicinaPaciente.ID_Medicamento = Medicamento.ID_Medicamento INNER JOIN Inventario ON MedicinaPaciente.ID_Medicamento = Inventario.ID_Medicamento GROUP BY Medicamento.Nombre, Medicamento.Composicion , Medicamento.Laboratorio, Inventario.Cantidad ORDER BY Consumo"); PdfWriter.getInstance(documento, new FileOutputStream( "reportes/reporte_de_consumo_medicamentos " + fechaActual() + " " + horaActual() + ".pdf")); documento.open(); float[] columnWidths = { 2, 2, 2, 2, 2, 2 }; PdfPTable table = new PdfPTable(columnWidths); table.setWidthPercentage(100); table.getDefaultCell().setUseAscender(true); table.getDefaultCell().setUseDescender(true); Font f = new Font(Font.FontFamily.HELVETICA, 13, Font.NORMAL, GrayColor.GRAYWHITE); PdfPCell cell = new PdfPCell(new Phrase("Reporte de Consumo Medicamentos", f)); cell.setBackgroundColor(GrayColor.GRAYBLACK); cell.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_CENTER); cell.setColspan(8); table.addCell(cell); table.getDefaultCell().setBackgroundColor(new GrayColor(0.75f)); for (int i = 0; i < 2; i++) { table.addCell("Medicamento"); table.addCell("Composicion"); table.addCell("Laboratorio"); table.addCell("Cantidad"); table.addCell("Unidades consumidas"); table.addCell("Porcentaje de consumo"); } table.setHeaderRows(3); table.setFooterRows(1); table.getDefaultCell().setBackgroundColor(GrayColor.GRAYWHITE); table.getDefaultCell().setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_CENTER); while (res.next()) { consumo = res.getInt("Consumo"); cantidad = res.getInt("Cantidad"); porcentaje = consumo / cantidad * 100; System.out.println("consumo: " + consumo + " cantidad: " + cantidad + " porcentaje: " + porcentaje); table.addCell(res.getString("Nombre")); table.addCell(res.getString("Composicion")); table.addCell(res.getString("Laboratorio")); table.addCell(res.getString("Cantidad")); table.addCell(res.getString("Consumo")); table.addCell(((df.format(porcentaje))) + "%"); } documento.add(table); documento.close(); JOptionPane.showMessageDialog(null, "Reporte de Consumo de Medicamentos generado correctamente"); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, "Error al conectar con la base de datos"); } catch (FileNotFoundException ex) { JOptionPane.showMessageDialog(null, "Error al generar la ruta del archivo"); } catch (DocumentException ex) { JOptionPane.showMessageDialog(null, "Error al generar el archivo"); } }