package com.tarisan.control; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.sql.Connection; import java.sql.Date; import java.sql.ResultSet; import java.sql.SQLException; import java.text.DecimalFormat; import java.util.Calendar; import java.util.Vector; import com.itextpdf.text.BaseColor; import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; import com.itextpdf.text.Element; import com.itextpdf.text.Font; import com.itextpdf.text.FontFactory; import com.itextpdf.text.PageSize; import com.itextpdf.text.Paragraph; import com.itextpdf.text.Phrase; import com.itextpdf.text.pdf.PdfPCell; import com.itextpdf.text.pdf.PdfPTable; import com.itextpdf.text.pdf.PdfWriter; import com.tarisan.data.TaliquimediDet; import com.tarisan.data.Tavolin; import com.tarisan.excepcion.ExcepcionTarisan; import com.tarisan.log.*; import com.tarisan.util.*; public class PersistenciaTaliquimedidet implements Constantes { /** * Devuelve los resultados correspondientes para ese medico, especialidad, mes y anio, siguiendo la paginacion * @param med * @param espe * @param mes * @param anio * @param pag * @return */ public Vector buscarDetalles(int med, int mes, int anio, int pag) { Vector resultado = new Vector();; TaliquimediDet talimedet = new TaliquimediDet(); Object[] aCondiciones = new Object[3]; StringBuffer sqlSelect = new StringBuffer(); String m = (mes<10)?"0"+mes:""+mes; try { Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion(); sqlSelect.append("Select MEDICO, FACTURA, APELLIDOS, ENTIDAD, COLECTIVO, poliza, orden, fecha_gasto, FECHA_FACTURA, especialidad, descripcion, importe from taliquimedidet"); sqlSelect.append(" where medico = ?"); sqlSelect.append(" and fecha_factura = ?"); sqlSelect.append(" order by fecha_gasto desc"); aCondiciones[0] = Integer.valueOf(med); Calendar cal = Calendar.getInstance(); cal.set(anio, mes-1, Utilidades.ultimo_dia_mes(mes,anio)); aCondiciones[1] = new Date(cal.getTimeInMillis()); ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString().toUpperCase(), aCondiciones); Paginacion pg = new Paginacion(); pg.inicializarPaginacion(rs); pg.realizarPaginacion(rs, pag); for(int i=0;i0) { TaliquimediDet talimedet = new TaliquimediDet(); talimedet = (TaliquimediDet)detalles.get(0); detalles_fra="Detalle de los honorarios del: "+m+"/"+anio+"\n"+ "Fecha Factura: "+talimedet.getFecha_factura()+"\n Factura Numero: "+talimedet.getMedico()+"/"+talimedet.getFactura()+"\n"+"\n"+"\n"+"\n"; Phrase para=new Phrase(detalles_fra,FontFactory.getFont("arial",10,Font.NORMAL,BaseColor.BLACK)); try { PdfWriter.getInstance(documento, new FileOutputStream(file_detalle)); documento.open(); documento.add(para); //Añadimos los encabezados de la tabla PdfPCell celda1 =new PdfPCell (new Paragraph("Póliza",FontFactory.getFont("arial",7,Font.BOLD,BaseColor.RED))); //PdfPCell celda2 =new PdfPCell (new Paragraph("Col.",FontFactory.getFont("arial",7,Font.BOLD,BaseColor.RED))); //PdfPCell celda3 =new PdfPCell (new Paragraph("Póliza",FontFactory.getFont("arial",7,Font.BOLD,BaseColor.RED))); //PdfPCell celda4 =new PdfPCell (new Paragraph("Orden",FontFactory.getFont("arial",7,Font.BOLD,BaseColor.RED))); PdfPCell celda5 =new PdfPCell (new Paragraph("Asegurado",FontFactory.getFont("arial",7,Font.BOLD,BaseColor.RED))); PdfPCell celda6 =new PdfPCell (new Paragraph("Descripción",FontFactory.getFont("arial",7,Font.BOLD,BaseColor.RED))); PdfPCell celda7 =new PdfPCell (new Paragraph("Fecha gasto",FontFactory.getFont("arial",7,Font.BOLD,BaseColor.RED))); PdfPCell celda8 =new PdfPCell (new Paragraph("Importe",FontFactory.getFont("arial",7,Font.BOLD,BaseColor.RED))); //LogTarisan.logger.log(NivelLog.DEBUG, "\n\n\n\nLlega 218\n\n\n\n"); celda1.setBorder(1); celda1.setBorderWidthTop(1); celda1.setBorderWidthBottom(1); celda1.setHorizontalAlignment(Element.ALIGN_RIGHT); celda1.setVerticalAlignment(Element.ALIGN_MIDDLE); /*celda2.setBorder(1); celda2.setBorderWidthTop(1); celda2.setBorderWidthBottom(1); celda2.setHorizontalAlignment(Element.ALIGN_RIGHT); celda2.setVerticalAlignment(Element.ALIGN_MIDDLE); celda3.setBorder(1); celda3.setBorderWidthTop(1); celda3.setBorderWidthBottom(1); celda3.setHorizontalAlignment(Element.ALIGN_RIGHT); celda3.setVerticalAlignment(Element.ALIGN_MIDDLE); celda4.setBorder(1); celda4.setBorderWidthTop(1); celda4.setBorderWidthBottom(1); celda4.setHorizontalAlignment(Element.ALIGN_RIGHT); celda4.setVerticalAlignment(Element.ALIGN_MIDDLE);*/ celda5.setBorder(1); celda5.setBorderWidthTop(1); celda5.setBorderWidthBottom(1); celda5.setHorizontalAlignment(Element.ALIGN_LEFT); celda5.setVerticalAlignment(Element.ALIGN_MIDDLE); celda6.setBorder(1); celda6.setBorderWidthTop(1); celda6.setBorderWidthBottom(1); celda6.setHorizontalAlignment(Element.ALIGN_LEFT); celda6.setVerticalAlignment(Element.ALIGN_MIDDLE); celda7.setBorder(1); celda7.setBorderWidthTop(1); celda7.setBorderWidthBottom(1); celda7.setHorizontalAlignment(Element.ALIGN_RIGHT); celda7.setVerticalAlignment(Element.ALIGN_MIDDLE); celda8.setBorder(1); celda8.setBorderWidthTop(1); celda8.setBorderWidthBottom(1); celda8.setHorizontalAlignment(Element.ALIGN_RIGHT); celda8.setVerticalAlignment(Element.ALIGN_MIDDLE); tabla.addCell(celda1);/* tabla.addCell(celda2); tabla.addCell(celda3); tabla.addCell(celda4);*/ tabla.addCell(celda5); tabla.addCell(celda6); tabla.addCell(celda7); tabla.addCell(celda8); //ahora recorremos el vector con todos los detalles de la liquidacion y vamos añadiendo los campos for(int j=0;j