package utiliServlet;

import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import m05bClasses.m05bComun;
import m05bClasses.m05bConstantes;
import m05bClasses.m05bConstantesInformes;
import m05bClasses.m05bFileLog;
import m05bObjects.m05bCTK;

import org.apache.fop.apps.Driver;
import org.xml.sax.InputSource;


/**
 * Inserte aquí la descripción del tipo.
 * Fecha de creación: (29/03/06)
 */
    
public class m05bImpCTKTotalKmServlet extends javax.servlet.http.HttpServlet    {
		
		String sLinea;
		String sValor="";
        String sFoFileDir = "/datos/m05b/tmp/";
        File foFileDir ;
        File tmpFoFile ;
		FileOutputStream tmpFoFileStream ;
	    m05bComun miComun = new m05bComun();
		m05bFileLog miLog = new m05bFileLog();   
		String persona="";
//      Logger log = null;

	    public static final String FO_REQUEST_PARAM = "fo";
	    
	    
   public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
   {
      performTask(request, response);
   }

   public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException
   {
      performTask(request, response);
   }

   private String Calcular(String sImporte1,String sImporte2) throws java.lang.Exception{
   	  String sNumero="0";
      if (((!(sImporte1.equals("")))&& (sImporte1 != null )&&(!(sImporte1.equals("0")))) && 
         ((!(sImporte2.equals("")))&& (sImporte2 != null )&&(!(sImporte2.equals("0"))))){
      sImporte1= miComun.ImportesABasedatos(sImporte1);
      sImporte2= miComun.ImportesABasedatos(sImporte2);
      double Importe1 = Double.parseDouble(sImporte1);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe1-"+Importe1, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe2=Double.parseDouble(sImporte2);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe2-"+Importe2, m05bConstantes.LOG_NIVEL_BAJO);		
      double Tot = Importe1 / Importe2;
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Tot"+Tot, m05bConstantes.LOG_NIVEL_BAJO);		
      sNumero=miComun.formatearDblMilesDec4(Tot); 
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"sNumero"+sNumero, m05bConstantes.LOG_NIVEL_BAJO);		
      }
   return  sNumero;
   }   
  private String Calcular2(String sImporte1,String sImporte2,String sImporte3) throws java.lang.Exception{
   	  String sNumero="0";
      if ((!(sImporte3.equals("")))&& (sImporte3 != null )&&(!(sImporte3.equals("0")))){
  	    if (((sImporte2.equals("")))|| (sImporte2 == null ))
  	       {sImporte2="0";}
  	    if (((sImporte1.equals("")))|| (sImporte1 == null ))
  	       {sImporte1="0";}
      sImporte1= miComun.ImportesABasedatos(sImporte1);
      sImporte2= miComun.ImportesABasedatos(sImporte2);
      sImporte3= miComun.ImportesABasedatos(sImporte3);
      
      double Importe1 = Double.parseDouble(sImporte1);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe1-"+Importe1, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe2=Double.parseDouble(sImporte2);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe2-"+Importe2, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe3=Double.parseDouble(sImporte3);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe3-"+Importe3, m05bConstantes.LOG_NIVEL_BAJO);		
      
      double Tot = (Importe1 * Importe2 / Importe3);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Tot"+Tot, m05bConstantes.LOG_NIVEL_BAJO);		
      sNumero=miComun.formatearDblMilesDec4(Tot); 
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"sNumero"+sNumero, m05bConstantes.LOG_NIVEL_BAJO);		
      }
   return  sNumero;
   }   
  private String Calcular3(String sImporte1,String sImporte2,String sImporte3,String sImporte4,String sImporte5) throws java.lang.Exception{
  	  String sNumero="0";
      if (((!(sImporte3.equals("")))&& (sImporte3 != null )&&(!(sImporte3.equals("0")))) && 
         ((!(sImporte5.equals("")))&& (sImporte5 != null )&&(!(sImporte5.equals("0"))))){
  	    if (((sImporte2.equals("")))|| (sImporte2 == null ))
  	       {sImporte2="0";}
  	    if (((sImporte1.equals("")))|| (sImporte1 == null ))
  	       {sImporte1="0";}
  	    if (((sImporte4.equals("")))|| (sImporte4 == null ))
  	       {sImporte4="0";}
      sImporte1= miComun.ImportesABasedatos(sImporte1);
      sImporte2= miComun.ImportesABasedatos(sImporte2);
      sImporte3= miComun.ImportesABasedatos(sImporte3);
      sImporte4= miComun.ImportesABasedatos(sImporte4);
      sImporte5= miComun.ImportesABasedatos(sImporte5);
      
      double Importe1 = Double.parseDouble(sImporte1);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe1-"+Importe1, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe2=Double.parseDouble(sImporte2);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe2-"+Importe2, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe3=Double.parseDouble(sImporte3);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe3-"+Importe3, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe4=Double.parseDouble(sImporte4);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe4-"+Importe4, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe5=Double.parseDouble(sImporte5);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe5-"+Importe5, m05bConstantes.LOG_NIVEL_BAJO);		
    
      double Tot = (Importe1 * Importe2 / Importe3 * Importe4 / Importe5);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Tot"+Tot, m05bConstantes.LOG_NIVEL_BAJO);		
      sNumero=miComun.formatearDblMilesDec4(Tot); 
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"sNumero"+sNumero, m05bConstantes.LOG_NIVEL_BAJO);		
      }
   return  sNumero;
   }   
   
  private String Calcular4(String sImporte1,String sImporte2,String sImporte3,String sImporte4,String sImporte5,String sImporte6) throws java.lang.Exception{
  	  String sNumero="0";
  	    if (((sImporte1.equals("")))|| (sImporte1 == null ))
  	       {sImporte1="0";}
  	    if (((sImporte2.equals("")))|| (sImporte2 == null ))
  	       {sImporte2="0";}
  	    if (((sImporte3.equals("")))|| (sImporte3 == null ))
  	       {sImporte3="0";}
  	    if (((sImporte4.equals("")))|| (sImporte4 == null ))
  	       {sImporte4="0";}
  	    if (((sImporte5.equals("")))|| (sImporte5 == null ))
  	       {sImporte5="0";}
  	    if (((sImporte6.equals("")))|| (sImporte6 == null ))
  	       {sImporte6="0";}
  	  
      
      sImporte1= miComun.ImportesABasedatos(sImporte1);
      sImporte2= miComun.ImportesABasedatos(sImporte2);
      sImporte3= miComun.ImportesABasedatos(sImporte3);
      sImporte4= miComun.ImportesABasedatos(sImporte4);
      sImporte5= miComun.ImportesABasedatos(sImporte5);
      sImporte6= miComun.ImportesABasedatos(sImporte6);

      double Importe1 = Double.parseDouble(sImporte1);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe1-"+Importe1, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe2=Double.parseDouble(sImporte2);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe2-"+Importe2, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe3=Double.parseDouble(sImporte3);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe3-"+Importe3, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe4=Double.parseDouble(sImporte4);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe4-"+Importe4, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe5=Double.parseDouble(sImporte5);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe5-"+Importe5, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe6=Double.parseDouble(sImporte6);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe6-"+Importe6, m05bConstantes.LOG_NIVEL_BAJO);		
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Calcular4 Importe6"+Importe6, m05bConstantes.LOG_NIVEL_BAJO);		
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Calcular4 Importe6Resta"+(Importe3 - Importe4 - Importe5), m05bConstantes.LOG_NIVEL_BAJO);		
      if ((!(Importe6==0.0)) && ((Importe3 - Importe4 - Importe5)!=0.0)){
          double Tot = Importe1 * Importe2 / (Importe3 - Importe4 - Importe5)/Importe6;
          miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Tot"+Tot, m05bConstantes.LOG_NIVEL_BAJO);		
          sNumero=miComun.formatearDblMilesDec4(Tot); 
          miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"sNumero"+sNumero, m05bConstantes.LOG_NIVEL_BAJO);		
      }
   return  sNumero;
   }   
  private String CalcularTot1(String sImporte1,String sImporte2,String sImporte3,String sImporte4,String sImporte5) throws java.lang.Exception{
  	  String sNumero="0";
  	  if (((sImporte1.equals("")))|| (sImporte1 == null ))
  	       {sImporte1="0";}
  	  if (((sImporte2.equals("")))|| (sImporte2 == null ))
  	       {sImporte2="0";}
  	  if (((sImporte3.equals("")))|| (sImporte3 == null ))
  	       {sImporte3="0";}
  	  if (((sImporte4.equals("")))|| (sImporte4 == null ))
  	       {sImporte4="0";}
  	  if (((sImporte5.equals("")))|| (sImporte5 == null ))
  	       {sImporte5="0";}
      sImporte1= miComun.ImportesABasedatos(sImporte1);
      sImporte2= miComun.ImportesABasedatos(sImporte2);
      sImporte3= miComun.ImportesABasedatos(sImporte3);
      sImporte4= miComun.ImportesABasedatos(sImporte4);
      sImporte5= miComun.ImportesABasedatos(sImporte5);

      double Importe1 = Double.parseDouble(sImporte1);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe1-"+Importe1, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe2=Double.parseDouble(sImporte2);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe2-"+Importe2, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe3=Double.parseDouble(sImporte3);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe3-"+Importe3, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe4=Double.parseDouble(sImporte4);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe4-"+Importe4, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe5=Double.parseDouble(sImporte5);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe5-"+Importe5, m05bConstantes.LOG_NIVEL_BAJO);		

      double Tot = Importe1 + Importe2 + Importe3 + Importe4 + Importe5;
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Tot"+Tot, m05bConstantes.LOG_NIVEL_BAJO);		
      sNumero=miComun.formatearDblMilesDec4(Tot); 
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"sNumero"+sNumero, m05bConstantes.LOG_NIVEL_BAJO);		
   return  sNumero;
   }   
  private String CalcularTot2(String sImporte1,String sImporte2,String sImporte3,String sImporte4,String sImporte5,String sImporte6,String sImporte7) throws java.lang.Exception{
  	  String sNumero="0";
  	  if (((sImporte1.equals("")))|| (sImporte1 == null ))
  	       {sImporte1="0";}
  	  if (((sImporte2.equals("")))|| (sImporte2 == null ))
  	       {sImporte2="0";}
  	  if (((sImporte3.equals("")))|| (sImporte3 == null ))
  	       {sImporte3="0";}
  	  if (((sImporte4.equals("")))|| (sImporte4 == null ))
  	       {sImporte4="0";}
  	  if (((sImporte5.equals("")))|| (sImporte5 == null ))
  	       {sImporte5="0";}
  	  if (((sImporte6.equals("")))|| (sImporte6 == null ))
  	       {sImporte6="0";}
  	  if (((sImporte7.equals("")))|| (sImporte7 == null ))
  	       {sImporte7="0";}
  	       
      
      sImporte1= miComun.ImportesABasedatos(sImporte1);
      sImporte2= miComun.ImportesABasedatos(sImporte2);
      sImporte3= miComun.ImportesABasedatos(sImporte3);
      sImporte4= miComun.ImportesABasedatos(sImporte4);
      sImporte5= miComun.ImportesABasedatos(sImporte5);
      sImporte6= miComun.ImportesABasedatos(sImporte5);
      sImporte7= miComun.ImportesABasedatos(sImporte5);
      
      
      double Importe1 = Double.parseDouble(sImporte1);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe1-"+Importe1, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe2=Double.parseDouble(sImporte2);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe2-"+Importe2, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe3=Double.parseDouble(sImporte3);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe3-"+Importe3, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe4=Double.parseDouble(sImporte4);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe4-"+Importe4, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe5=Double.parseDouble(sImporte5);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe5-"+Importe5, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe6=Double.parseDouble(sImporte6);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe6-"+Importe6, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe7=Double.parseDouble(sImporte7);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe7-"+Importe7, m05bConstantes.LOG_NIVEL_BAJO);		
      
      double Tot = Importe1 + Importe2 + Importe3 + Importe4 + Importe5 + Importe6 + Importe7;
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Tot"+Tot, m05bConstantes.LOG_NIVEL_BAJO);		
      sNumero=miComun.formatearDblMilesDec4(Tot); 
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"sNumero"+sNumero, m05bConstantes.LOG_NIVEL_BAJO);		
   return  sNumero;
   }   
  private String CalcularTot3(String sImporte1,String sImporte2,String sImporte3,String sImporte4,String sImporte5,String sImporte6) throws java.lang.Exception{
  	  String sNumero="0";
  	  if (((sImporte1.equals("")))|| (sImporte1 == null ))
  	       {sImporte1="0";}
  	  if (((sImporte2.equals("")))|| (sImporte2 == null ))
  	       {sImporte2="0";}
  	  if (((sImporte3.equals("")))|| (sImporte3 == null ))
  	       {sImporte3="0";}
  	  if (((sImporte4.equals("")))|| (sImporte4 == null ))
  	       {sImporte4="0";}
  	  if (((sImporte5.equals("")))|| (sImporte5 == null ))
  	       {sImporte5="0";}
  	  if (((sImporte6.equals("")))|| (sImporte6 == null ))
  	       {sImporte6="0";}
      
      sImporte1= miComun.ImportesABasedatos(sImporte1);
      sImporte2= miComun.ImportesABasedatos(sImporte2);
      sImporte3= miComun.ImportesABasedatos(sImporte3);
      sImporte4= miComun.ImportesABasedatos(sImporte4);
      sImporte5= miComun.ImportesABasedatos(sImporte5);
      sImporte6= miComun.ImportesABasedatos(sImporte5);
      
      
      double Importe1 = Double.parseDouble(sImporte1);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe1-"+Importe1, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe2=Double.parseDouble(sImporte2);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe2-"+Importe2, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe3=Double.parseDouble(sImporte3);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe3-"+Importe3, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe4=Double.parseDouble(sImporte4);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe4-"+Importe4, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe5=Double.parseDouble(sImporte5);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe5-"+Importe5, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe6=Double.parseDouble(sImporte6);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Importe6-"+Importe6, m05bConstantes.LOG_NIVEL_BAJO);		
      
      double Tot = Importe1 + Importe2 + Importe3 + Importe4 + Importe5 + Importe6 ;
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Tot"+Tot, m05bConstantes.LOG_NIVEL_BAJO);		
      sNumero=miComun.formatearDblMilesDec4(Tot); 
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"sNumero"+sNumero, m05bConstantes.LOG_NIVEL_BAJO);		
   return  sNumero;
   }   
  private String CalcularTot4(String sImporte1,String sImporte2,String sImporte3) throws java.lang.Exception{
  	  String sNumero="0";
  	  if (((sImporte1.equals("")))|| (sImporte1 == null ))
  	       {sImporte1="0";}
  	  if (((sImporte2.equals("")))|| (sImporte2 == null ))
  	       {sImporte2="0";}
  	  if (((sImporte3.equals("")))|| (sImporte3 == null ))
  	       {sImporte3="0";}
      
      sImporte1= miComun.ImportesABasedatos(sImporte1);
      sImporte2= miComun.ImportesABasedatos(sImporte2);
      sImporte3= miComun.ImportesABasedatos(sImporte3);
      
      
      double Importe1 = Double.parseDouble(sImporte1);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"CalcularTot4Importe1-"+Importe1, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe2=Double.parseDouble(sImporte2);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"CalcularTot4Importe2-"+Importe2, m05bConstantes.LOG_NIVEL_BAJO);		
      double Importe3=Double.parseDouble(sImporte3);
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"CalcularTot4Importe3-"+Importe3, m05bConstantes.LOG_NIVEL_BAJO);		
      
      double Tot = Importe1 + Importe2 + Importe3  ;
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"Tot"+Tot, m05bConstantes.LOG_NIVEL_BAJO);		
      sNumero=miComun.formatearDblMilesDec4(Tot); 
      miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"sNumero"+sNumero, m05bConstantes.LOG_NIVEL_BAJO);		
   return  sNumero;
   }   
   
   public void performTask(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws ServletException {
	 
      try {  
      	 HttpSession session = request.getSession(false);
      	 persona = (String) session.getAttribute("persona");
      	 
		 m05bCTK objCTK = (m05bCTK)session.getAttribute("CTK");
		 double dNumero1=0.0;
		 double dNumero2=0.0;
		 double Tot=0.0;
		 String sNumero1="";
		 String sNumero2="";
	     String desde=request.getParameter("Desde");
	     String fDesde=desde.substring(6,8)+"-"+desde.substring(4,6)+"-"+desde.substring(0,4);
	     String hasta=request.getParameter("Hasta");
	     String fHasta=hasta.substring(6,8)+"-"+hasta.substring(4,6)+"-"+hasta.substring(0,4);
		 m05bComun miComun = new m05bComun();
		 String sImprimirValor="";
		 String sAmortizacionA="",sAmortizacionB="",sAmortizacionC="",sAmortizacionD="";
		 String sCombustibleA="",sCombustibleB="",sCombustibleC="",sCombustibleD="",sCombustibleE="";
		 String sManoObraA="",sManoObraB="",sManoObraC="",sManoObraD="";
		 String sSuministrosA="",sSuministrosB="",sSuministrosC="",sSuministrosD="";
		 String sAmortizacionTallerA="",sAmortizacionTallerB="",sAmortizacionTallerC="",sAmortizacionTallerD="";
		 String sOtrosGastosA="",sOtrosGastosB="",sOtrosGastosC="",sOtrosGastosD="";
		 String sTalleresExternosA="",sTalleresExternosB="",sTalleresExternosC="",sTalleresExternosD="";
		 String sTotalGastosA="",sTotalGastosB="",sTotalGastosC="",sTotalGastosD="";
		 String sSeguroA="",sSeguroB="",sSeguroC="",sSeguroD="";
		 String sItvA="",sItvB="",sItvC="";
		 String sTasasA="",sTasasB="",sTasasC="",sTasasD="";
		 String sAdministracionA="",sAdministracionB="",sAdministracionC="",sAdministracionD="",sAdministracionE="";
		 String sRenting="";
         // Extraccion de parametros, aprovecho la url para xlnets para sacar la url de jakina
         String xlnetsini = miComun.leerPropiedad("xlnets");
         //String urlprin = xlnetsini.substring(0, xlnetsini.indexOf("/", 8));

         //String foParam = request.getParameter(FO_REQUEST_PARAM);
		 fncAbrirFicheroTemporal();

         tmpFoFileStream = new FileOutputStream(tmpFoFile);

         sLinea = "<?xml version=\"1.0\" encoding=\"windows-1252\"?>\n";
         tmpFoFileStream.write(sLinea.getBytes());
         
         sLinea = "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\">\n";
         tmpFoFileStream.write(sLinea.getBytes());
		 // LAYOUT DEL LISTADO 
	         sLinea = "<fo:layout-master-set>\n";
	         tmpFoFileStream.write(sLinea.getBytes());
		           sLinea = "	<fo:simple-page-master master-name=\"general\"  page-height=\"21cm\" page-width=\"29.5cm\" margin-top=\"2cm\" margin-bottom=\"2cm\" margin-left=\"2.5cm\" margin-right=\"2.5cm\">\n";
			       tmpFoFileStream.write(sLinea.getBytes());
			         sLinea = "		<fo:region-before extent=\"2cm\"/>\n";
			         tmpFoFileStream.write(sLinea.getBytes());
			         sLinea = "		<fo:region-body  margin-top=\"2cm\" margin-bottom=\"2cm\" />\n";
			         tmpFoFileStream.write(sLinea.getBytes());
			         sLinea = "		<fo:region-after  extent=\"2cm\"/>\n";
			         tmpFoFileStream.write(sLinea.getBytes());
			         sLinea = "		<fo:region-start extent=\"0cm\"/>\n";
			         tmpFoFileStream.write(sLinea.getBytes());
			         sLinea = "		<fo:region-end extent=\"0cm\"/>\n";
			         tmpFoFileStream.write(sLinea.getBytes());
			         
		            sLinea = "	</fo:simple-page-master>\n";
		          tmpFoFileStream.write(sLinea.getBytes());
	         sLinea = "</fo:layout-master-set>\n";
	         tmpFoFileStream.write(sLinea.getBytes());

		 // PAGE-SEQUENCE DEL LISTADO 
	         sLinea = "<fo:page-sequence master-reference=\"general\">\n";
	         tmpFoFileStream.write(sLinea.getBytes());
	         

		//REGION BEFORE
        	sLinea = "		<fo:static-content flow-name=\"xsl-region-before\" >\n";
        	tmpFoFileStream.write(sLinea.getBytes());
                    sLinea = "      <fo:block font-weight=\"bold\" padding-top=\"10pt\">\n Dirección de Recursos Generales - Servicio de Parque Móvil</fo:block>\n";
			        tmpFoFileStream.write(sLinea.getBytes());
                    sLinea = "      <fo:block font-weight=\"bold\" padding-top=\"10pt\">\n Valores de los indicadores de eficiencia económica en el periodo:    Desde: " + fDesde + "  -  Hasta: " + fHasta + "</fo:block>\n";
			        tmpFoFileStream.write(sLinea.getBytes());
        	sLinea = " 		</fo:static-content>\n"; 
        	tmpFoFileStream.write(sLinea.getBytes());


            //PIE DE PAGINA
			fncGenerarPiePagina();
			
			//BODY
		         sLinea = "	<fo:flow flow-name=\"xsl-region-body\">\n";
		         tmpFoFileStream.write(sLinea.getBytes());
		         Context ctx =  new InitialContext(System.getProperties());
      	         // --------------    DETALLE DEL LISTADO    --------------
           		// tabla CONCEPTOS
		           		sLinea= "        <fo:table space-after.optimum=\"12pt\">\n";
		            	tmpFoFileStream.write(sLinea.getBytes());
		            		sLinea = "	    <fo:table-column column-width=\"50mm\"/>\n";
			            	tmpFoFileStream.write(sLinea.getBytes());
		            		sLinea = "	    <fo:table-column column-width=\"25mm\"/>\n";
			            	tmpFoFileStream.write(sLinea.getBytes());
		            		sLinea = "	    <fo:table-column column-width=\"25mm\"/>\n";
			            	tmpFoFileStream.write(sLinea.getBytes());
		            		sLinea = "	    <fo:table-column column-width=\"25mm\"/>\n";
			            	tmpFoFileStream.write(sLinea.getBytes());
		            		sLinea = "	    <fo:table-column column-width=\"25mm\"/>\n";
			            	tmpFoFileStream.write(sLinea.getBytes());
		            		sLinea = "	    <fo:table-column column-width=\"25mm\"/>\n";
			            	tmpFoFileStream.write(sLinea.getBytes());
		                    /*sLinea = "	    <fo:table-header font-family=\"Helvetica\" font-size=\"7pt\" >\n";
			                tmpFoFileStream.write(sLinea.getBytes());
			                sLinea = "	    </fo:table-header>\n";
			                tmpFoFileStream.write(sLinea.getBytes());*/
			            		
			            		// DETALLE
		            		sLinea = "	    <fo:table-body font-family=\"Helvetica\" font-size=\"8pt\">\n";
			            	tmpFoFileStream.write(sLinea.getBytes());
			            		// CABECERA
   		                        sLinea = "	    <fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            			// Blanco
			            			sLinea = "	    <fo:table-cell border-width=\"0.1mm\" border-left-width=\"0pt\" border-top-width=\"0pt\" border-bottom-width=\"0pt\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block>\n  </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// Blanco
			            			sLinea = "	    <fo:table-cell  background-color=\"rgb(200,200,200)\" border-width=\"0.1mm\" border-right-width=\"0pt\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block>\n</fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES
			            			sLinea = "	    <fo:table-cell  background-color=\"rgb(200,200,200)\" padding-top=\"1mm\" border-left-width=\"0pt\" border-right-width=\"0pt\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"right\" font-weight=\"bold\">\nCOSTE  </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// POR
			            			sLinea = "	    <fo:table-cell  background-color=\"rgb(200,200,200)\" padding-top=\"1mm\" border-width=\"0.1mm\" border-left-width=\"0pt\" border-right-width=\"0pt\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
							            sLinea = "      <fo:block  text-align=\"center\" font-weight=\"bold\">\nTOTAL POR</fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// RANGO
			            			sLinea = "	    <fo:table-cell  background-color=\"rgb(200,200,200)\" padding-top=\"1mm\" border-width=\"0.1mm\" border-left-width=\"0pt\" border-right-width=\"0pt\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
							            sLinea = "      <fo:block  text-align=\"left\" font-weight=\"bold\">\nKILOMETROS</fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// Blanco
			            			sLinea = "	    <fo:table-cell  background-color=\"rgb(200,200,200)\" border-width=\"0.1mm\" border-left-width=\"0pt\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block>\n</fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            		sLinea = "	    </fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            		// CABECERA
   		                        sLinea = "	    <fo:table-row >\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            			// CONCEPTOS 
			            			sLinea = "	    <fo:table-cell border-width=\"0.1mm\" border-left-width=\"0pt\"  border-bottom-width=\"0pt\" border-top-width=\"0pt\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block text-align=\"left\" font-weight=\"bold\">\n </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// A
			            			sLinea = "	    <fo:table-cell background-color=\"rgb(200,200,200)\" padding-top=\"1mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"center\" font-weight=\"bold\">\n A </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// B
			            			sLinea = "	    <fo:table-cell background-color=\"rgb(200,200,200)\" padding-top=\"1mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"center\" font-weight=\"bold\">\n B </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// C
			            			sLinea = "	    <fo:table-cell background-color=\"rgb(200,200,200)\" padding-top=\"1mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
							            sLinea = "      <fo:block  text-align=\"center\" font-weight=\"bold\">\n C </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// D
			            			sLinea = "	    <fo:table-cell background-color=\"rgb(200,200,200)\" padding-top=\"1mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
							            sLinea = "      <fo:block  text-align=\"center\" font-weight=\"bold\">\n D </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// R 
			            			sLinea = "	    <fo:table-cell background-color=\"rgb(200,200,200)\" padding-top=\"1mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"center\" font-weight=\"bold\">\n R </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			        			            		sLinea = "	    </fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			 	      	    sLinea = "	    </fo:table-body>\n";
			            	tmpFoFileStream.write(sLinea.getBytes());
			            sLinea= "       </fo:table>\n";
		            	tmpFoFileStream.write(sLinea.getBytes());
           		// tabla NUMERO DE VEHICULOS
		           		sLinea= "        <fo:table space-after.optimum=\"12pt\">\n";
		            	tmpFoFileStream.write(sLinea.getBytes());
		            		sLinea = "	    <fo:table-column column-width=\"50mm\" background-color=\"rgb(200,200,200)\" />\n";
			            	tmpFoFileStream.write(sLinea.getBytes());
		            		sLinea = "	    <fo:table-column column-width=\"25mm\"/>\n";
			            	tmpFoFileStream.write(sLinea.getBytes());
		            		sLinea = "	    <fo:table-column column-width=\"25mm\"/>\n";
			            	tmpFoFileStream.write(sLinea.getBytes());
		            		sLinea = "	    <fo:table-column column-width=\"25mm\"/>\n";
			            	tmpFoFileStream.write(sLinea.getBytes());
		            		sLinea = "	    <fo:table-column column-width=\"25mm\"/>\n";
			            	tmpFoFileStream.write(sLinea.getBytes());
		            		sLinea = "	    <fo:table-column column-width=\"25mm\"/>\n";
			            	tmpFoFileStream.write(sLinea.getBytes());
			            		
			            		///DETALLE
		            		sLinea = "	    <fo:table-body font-family=\"Helvetica\" font-size=\"8pt\">\n";
			            	tmpFoFileStream.write(sLinea.getBytes());
			            		
			            		// AMORTIZACION
   		                        sLinea = "	    <fo:table-row >\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            			// AMORTIZACION 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" padding-left=\"1mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"left\" font-weight=\"bold\">\nAmortización </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - A
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			//Amortizacion 1
			            			sImprimirValor=Calcular(objCTK.getCTK_elem(3,0),objCTK.getCTK_elem(2,0));
			            			sAmortizacionA=sImprimirValor;
			            			if (sImprimirValor.equals("0"))
			            			{sImprimirValor="";}
								    sLinea = "      <fo:block  text-align=\"right\">\n " +sImprimirValor + " </fo:block>\n";
								    tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - B
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=Calcular(objCTK.getCTK_elem(3,1),objCTK.getCTK_elem(2,1));
			            			sAmortizacionB=sImprimirValor;
			            			if (sImprimirValor.equals("0"))
			            			{sImprimirValor="";}

								        sLinea = "      <fo:block  text-align=\"right\">\n " + sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - C
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=Calcular(objCTK.getCTK_elem(3,2),objCTK.getCTK_elem(2,2));
			            			sAmortizacionC=sImprimirValor;
			            			if (sImprimirValor.equals("0"))
			            			{sImprimirValor="";}
							            sLinea = "      <fo:block  text-align=\"right\">\n " + sImprimirValor + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - D
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=Calcular(objCTK.getCTK_elem(3,3),objCTK.getCTK_elem(2,3));
			            			sAmortizacionD=sImprimirValor;
			            			if (sImprimirValor.equals("0"))
			            			{sImprimirValor="";}
							            sLinea = "      <fo:block  text-align=\"right\">\n " + sImprimirValor + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - R 
			            			sLinea = "	    <fo:table-cell background-color=\"rgb(200,200,200)\" padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"right\">\n " +  " </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            		sLinea = "	    </fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            		// COMBUSTIBLE
   		                        sLinea = "	    <fo:table-row >\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            			// COMBUSTIBLE 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block text-align=\"left\" font-weight=\"bold\">\n Gastos Combustible </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - A
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=Calcular(objCTK.getCTK_elem(4,0),objCTK.getCTK_elem(2,0));
			            			sCombustibleA=sImprimirValor;
			            			if (sImprimirValor.equals("0"))
			            			{sImprimirValor="";}
								        sLinea = "      <fo:block  text-align=\"right\">\n " + sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - B
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			                        sImprimirValor=Calcular(objCTK.getCTK_elem(4,1),objCTK.getCTK_elem(2,1));			            			
			            			sCombustibleB=sImprimirValor;
			            			if (sImprimirValor.equals("0"))
			            			{sImprimirValor="";}
								        sLinea = "      <fo:block  text-align=\"right\">\n " + sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - C
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			                        sImprimirValor=Calcular(objCTK.getCTK_elem(4,2),objCTK.getCTK_elem(2,2));			            			
			            			sCombustibleC=sImprimirValor;
			            			if (sImprimirValor.equals("0"))
			            			{sImprimirValor="";}
							            sLinea = "      <fo:block  text-align=\"right\">\n " + sImprimirValor + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - D
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			                        sImprimirValor=Calcular(objCTK.getCTK_elem(4,3),objCTK.getCTK_elem(2,3));			            			
			            			sCombustibleD=sImprimirValor;
			            			if (sImprimirValor.equals("0"))
			            			{sImprimirValor="";}
							            sLinea = "      <fo:block  text-align=\"right\">\n " + sImprimirValor + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - R 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			                        sImprimirValor=Calcular(objCTK.getCTK_elem(4,4),objCTK.getCTK_elem(2,4));			            			
			            			sCombustibleE=sImprimirValor;
			            			if (sImprimirValor.equals("0"))
			            			{sImprimirValor="";}
								        sLinea = "      <fo:block  text-align=\"right\">\n " + sImprimirValor + " </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            		sLinea = "	    </fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            	   	sLinea = "	    <fo:table-row >\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            			// GASTOS TALLER 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block text-align=\"left\" font-weight=\"bold\">\n Gastos Taller </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// Blanco
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0mm\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"center\" font-weight=\"bold\">\n  </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// Blanco
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0mm\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"center\" font-weight=\"bold\">\n  </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// Blanco
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0mm\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"center\" font-weight=\"bold\">\n  </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// Blanco
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0mm\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"center\" font-weight=\"bold\">\n  </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// Blanco
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0mm\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"center\" font-weight=\"bold\">\n  </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            		sLinea = "	    </fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            		// MANO DE OBRA
   		                        sLinea = "	    <fo:table-row >\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            			// MANO DE OBRA 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block text-align=\"right\" >\n Mano de Obra </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - A
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			                            sImprimirValor=Calcular3(objCTK.getCTK_elem(6,0),objCTK.getCTK_elem(12,5),objCTK.getCTK_elem(11,5),objCTK.getCTK_elem(13,5),objCTK.getCTK_elem(2,0));
			                            sManoObraA=sImprimirValor;	
			            			if (sImprimirValor.equals("0"))
			            			{sImprimirValor="";}
								        sLinea = "      <fo:block  text-align=\"right\">\n " + sImprimirValor + " </fo:block>";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - B
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
	                                    sImprimirValor=Calcular3(objCTK.getCTK_elem(6,1),objCTK.getCTK_elem(12,5),objCTK.getCTK_elem(11,5),objCTK.getCTK_elem(13,5),objCTK.getCTK_elem(2,1));			            			
			                            sManoObraB=sImprimirValor;	
				            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}
								        sLinea = "      <fo:block  text-align=\"right\">\n " + sImprimirValor + " </fo:block>";
								        tmpFoFileStream.write(sLinea.getBytes());			            			
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - C
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
	                                    sImprimirValor=Calcular3(objCTK.getCTK_elem(6,2),objCTK.getCTK_elem(12,5),objCTK.getCTK_elem(11,5),objCTK.getCTK_elem(13,5),objCTK.getCTK_elem(2,2));			            			
			                            sManoObraC=sImprimirValor;
				            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}
								        sLinea = "      <fo:block  text-align=\"right\">\n " + sImprimirValor + " </fo:block>";
								        tmpFoFileStream.write(sLinea.getBytes());			            			
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - D
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
	                                    sImprimirValor=Calcular3(objCTK.getCTK_elem(6,3),objCTK.getCTK_elem(12,5),objCTK.getCTK_elem(11,5),objCTK.getCTK_elem(13,5),objCTK.getCTK_elem(2,3));			            			
			                            sManoObraD=sImprimirValor;	
				            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}
								        sLinea = "      <fo:block  text-align=\"right\">\n " + sImprimirValor + " </fo:block>";
								        tmpFoFileStream.write(sLinea.getBytes());			            			
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - R 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" background-color=\"rgb(200,200,200)\"  border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
	                                    sImprimirValor="";			            			
								        sLinea = "      <fo:block  text-align=\"right\">\n " + sImprimirValor + " </fo:block>";
								        tmpFoFileStream.write(sLinea.getBytes());			            			
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            		sLinea = "	    </fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            		// SUMINISTROS TALLER
   		                        sLinea = "	    <fo:table-row >\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            			// SUMINISTROS TALLER 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block text-align=\"right\">\n Suministros Taller </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - A
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sValor=objCTK.getCTK_elem(6,0);
			            			sValor=sValor.substring(0,sValor.length()-1);
                                    sImprimirValor=Calcular2(sValor,objCTK.getCTK_elem(7,5),objCTK.getCTK_elem(2,0));
			                        sSuministrosA=sImprimirValor;	
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}
								        sLinea = "      <fo:block  text-align=\"right\" >\n " + sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - B
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
 			                        sValor=objCTK.getCTK_elem(6,1).substring(0,objCTK.getCTK_elem(6,1).length()-1);			            			
			            			sImprimirValor=Calcular2(sValor,objCTK.getCTK_elem(7,5),objCTK.getCTK_elem(2,1));
			                        sSuministrosB=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			                        		
								        sLinea = "      <fo:block  text-align=\"right\" >\n " + sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - C
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
 			                        sValor=objCTK.getCTK_elem(6,2).substring(0,objCTK.getCTK_elem(6,2).length()-1);			            			
			            			sImprimirValor=Calcular2(sValor,objCTK.getCTK_elem(7,5),objCTK.getCTK_elem(2,2));
			                        sSuministrosC=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			                        		
							            sLinea = "      <fo:block  text-align=\"right\" >\n " + sImprimirValor + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - D
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
 			                        sValor=objCTK.getCTK_elem(6,3).substring(0,objCTK.getCTK_elem(6,3).length()-1);			            			
			            			sImprimirValor=Calcular2(sValor,objCTK.getCTK_elem(7,5),objCTK.getCTK_elem(2,3));
			                        sSuministrosD=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			                        		
							            sLinea = "      <fo:block  text-align=\"right\">\n " + sImprimirValor + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - R 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" background-color=\"rgb(200,200,200)\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"right\" >\n " + " </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            		sLinea = "	    </fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            		// AMORTIZACION EQUIPO TALLER
   		                        sLinea = "	    <fo:table-row >\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            			// AMORTIZACION EQUIPO TALLER 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block text-align=\"right\">\n Amortización equipo taller propio</fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - A
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
 			                        sValor=objCTK.getCTK_elem(6,0).substring(0,objCTK.getCTK_elem(6,0).length()-1);			            			
			            			sImprimirValor=Calcular2(sValor,objCTK.getCTK_elem(8,5),objCTK.getCTK_elem(2,0));
                                    sAmortizacionTallerA=sImprimirValor;			            			
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
								        sLinea = "      <fo:block  text-align=\"right\" >\n " + sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - B
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
 			                        sValor=objCTK.getCTK_elem(6,1).substring(0,objCTK.getCTK_elem(6,1).length()-1);			            			
			            			sImprimirValor=Calcular2(sValor,objCTK.getCTK_elem(8,5),objCTK.getCTK_elem(2,1));
                                    sAmortizacionTallerB=sImprimirValor;			            			
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
								        sLinea = "      <fo:block  text-align=\"right\" >\n " + sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - C
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
 			                        sValor=objCTK.getCTK_elem(6,2).substring(0,objCTK.getCTK_elem(6,2).length()-1);			            			
			            			sImprimirValor=Calcular2(sValor,objCTK.getCTK_elem(8,5),objCTK.getCTK_elem(2,2));
                                    sAmortizacionTallerC=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
							            sLinea = "      <fo:block  text-align=\"right\" >\n " +sImprimirValor + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - D
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
 			                        sValor=objCTK.getCTK_elem(6,3).substring(0,objCTK.getCTK_elem(6,3).length()-1);			            			
			            			sImprimirValor=Calcular2(sValor,objCTK.getCTK_elem(8,5),objCTK.getCTK_elem(2,3));
                                    sAmortizacionTallerD=sImprimirValor;			            			
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
							            sLinea = "      <fo:block  text-align=\"right\" >\n " + sImprimirValor + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - R 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" background-color=\"rgb(200,200,200)\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"right\" >\n " +  " </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            		sLinea = "	    </fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            		// OTROS GASTOS TALLER 
   		                        sLinea = "	    <fo:table-row >\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            			// OTROS GASTOS TALLER 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block text-align=\"right\">\n Otros Gastos Taller </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - A
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=Calcular(objCTK.getCTK_elem(9,0),objCTK.getCTK_elem(2,0));
                                    sOtrosGastosA=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
								        sLinea = "      <fo:block  text-align=\"right\" >\n " + sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - B
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=Calcular(objCTK.getCTK_elem(9,1),objCTK.getCTK_elem(2,1));
                                    sOtrosGastosB=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
								        sLinea = "      <fo:block  text-align=\"right\" >\n " + sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - C
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=Calcular(objCTK.getCTK_elem(9,2),objCTK.getCTK_elem(2,2));
                                    sOtrosGastosC=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
							            sLinea = "      <fo:block  text-align=\"right\" >\n " + sImprimirValor + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - D
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=Calcular(objCTK.getCTK_elem(9,3),objCTK.getCTK_elem(2,3));
                                    sOtrosGastosD=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
							            sLinea = "      <fo:block  text-align=\"right\" >\n " + sImprimirValor + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - R 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" background-color=\"rgb(200,200,200)\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"right\" >\n " + " </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            		sLinea = "	    </fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            		// GASTOS TALLERES EXTERNOS
   		                        sLinea = "	    <fo:table-row >\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            			// GASTOS TALLERES EXTERNOS
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block text-align=\"right\">\n Talleres Externos </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - A
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=Calcular(objCTK.getCTK_elem(10,0),objCTK.getCTK_elem(2,0));
                                    sTalleresExternosA=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
								        sLinea = "      <fo:block  text-align=\"right\" >\n " + sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - B
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=Calcular(objCTK.getCTK_elem(10,1),objCTK.getCTK_elem(2,1));
                                    sTalleresExternosB=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
								        sLinea = "      <fo:block  text-align=\"right\" >\n " + sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - C
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=Calcular(objCTK.getCTK_elem(10,2),objCTK.getCTK_elem(2,2));
                                    sTalleresExternosC=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
							            sLinea = "      <fo:block  text-align=\"right\" >\n " + sImprimirValor + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - D
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=Calcular(objCTK.getCTK_elem(10,3),objCTK.getCTK_elem(2,3));
                                    sTalleresExternosD=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
							            sLinea = "      <fo:block  text-align=\"right\" >\n " + sImprimirValor + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - R 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" background-color=\"rgb(200,200,200)\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"right\" >\n " +  " </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            		sLinea = "	    </fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
		                        //TOTAL GASTOS DE TALLER
			            	   	sLinea = "	    <fo:table-row >\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            			// TOTAL GASTOS DE TALLER 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block text-align=\"left\" font-weight=\"bold\">\n Total Gastos De Taller </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// Blanco
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=CalcularTot1(sManoObraA,sSuministrosA,sAmortizacionTallerA,sOtrosGastosA,sTalleresExternosA);
			            			sTotalGastosA=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
								        sLinea = "      <fo:block  text-align=\"right\" font-weight=\"bold\">\n " + sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// Blanco
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=CalcularTot1(sManoObraB,sSuministrosB,sAmortizacionTallerB,sOtrosGastosB,sTalleresExternosB);
			            			sTotalGastosB=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
								        sLinea = "      <fo:block  text-align=\"right\" font-weight=\"bold\">\n " + sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// Blanco
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=CalcularTot1(sManoObraC,sSuministrosC,sAmortizacionTallerC,sOtrosGastosC,sTalleresExternosC);
			            			sTotalGastosC=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
								        sLinea = "      <fo:block  text-align=\"right\" font-weight=\"bold\">\n " + sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// Blanco
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=CalcularTot1(sManoObraD,sSuministrosD,sAmortizacionTallerD,sOtrosGastosD,sTalleresExternosD);
			            			sTotalGastosD=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
								        sLinea = "      <fo:block  text-align=\"right\" font-weight=\"bold\">\n " + sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// Blanco
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" background-color=\"rgb(200,200,200)\"  border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"center\" font-weight=\"bold\">\n  </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			               		sLinea = "	    </fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            		// SEGURO
   		                        sLinea = "	    <fo:table-row >\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            			// SEGURO 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block text-align=\"left\"  font-weight=\"bold\">\n Seguro </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - A
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=Calcular2(objCTK.getCTK_elem(1,0),objCTK.getCTK_elem(15,5),objCTK.getCTK_elem(2,0));
			            			sSeguroA=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
								        sLinea = "      <fo:block  text-align=\"right\" >\n " + sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - B
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=Calcular2(objCTK.getCTK_elem(1,1),objCTK.getCTK_elem(15,5),objCTK.getCTK_elem(2,1));
			            			sSeguroB=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
								        sLinea = "      <fo:block  text-align=\"right\" >\n " +sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - C
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=Calcular2(objCTK.getCTK_elem(1,2),objCTK.getCTK_elem(15,5),objCTK.getCTK_elem(2,2));
			            			sSeguroC=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
							            sLinea = "      <fo:block  text-align=\"right\" >\n " +sImprimirValor + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - D
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=Calcular2(objCTK.getCTK_elem(1,3),objCTK.getCTK_elem(15,5),objCTK.getCTK_elem(2,3));
			            			sSeguroC=sImprimirValor;
    		            			if (sImprimirValor.equals("0"))
     			            			{sImprimirValor="";}			            			
							            sLinea = "      <fo:block  text-align=\"right\" >\n " +sImprimirValor + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - R 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" background-color=\"rgb(200,200,200)\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"right\" >\n " +" </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			               		sLinea = "	    </fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            		// ITV
   		                        sLinea = "	    <fo:table-row >\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            			// ITV
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block text-align=\"left\"  font-weight=\"bold\">\n ITV </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - A
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
  			            			tmpFoFileStream.write(sLinea.getBytes());
  			            			sImprimirValor=Calcular4(objCTK.getCTK_elem(1,0),objCTK.getCTK_elem(16,5),objCTK.getCTK_elem(11,5),objCTK.getCTK_elem(1,3),objCTK.getCTK_elem(1,4),objCTK.getCTK_elem(2,0));
			            			sItvA=sImprimirValor;
                                    miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"sImprimirValor"+sImprimirValor, m05bConstantes.LOG_NIVEL_BAJO);		
    		            			if ((sImprimirValor.equals("0"))|| (sImprimirValor.equals("-0")))
     			            			{sImprimirValor="";}			            			
							            sLinea = "      <fo:block  text-align=\"right\" >\n " +sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - B
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
     			            			sImprimirValor=Calcular4(objCTK.getCTK_elem(1,1),objCTK.getCTK_elem(16,5),objCTK.getCTK_elem(11,5),objCTK.getCTK_elem(1,3),objCTK.getCTK_elem(1,4),objCTK.getCTK_elem(2,1));
			            			    sItvB=sImprimirValor;
    		            			if ((sImprimirValor.equals("0"))|| (sImprimirValor.equals("-0")))
     			                           {sImprimirValor="";}			            			
							            sLinea = "      <fo:block  text-align=\"right\" >\n " +sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - C
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
     			            			sImprimirValor=Calcular4(objCTK.getCTK_elem(1,2),objCTK.getCTK_elem(16,5),objCTK.getCTK_elem(11,5),objCTK.getCTK_elem(1,3),objCTK.getCTK_elem(1,4),objCTK.getCTK_elem(2,2));
			            			    sItvC=sImprimirValor;
    		            			if ((sImprimirValor.equals("0"))|| (sImprimirValor.equals("-0")))
     			                           {sImprimirValor="";}			            			
							            sLinea = "      <fo:block  text-align=\"right\" >\n " +sImprimirValor + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - D
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" background-color=\"rgb(200,200,200)\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
							            sLinea = "      <fo:block  text-align=\"right\" >\n " + objCTK.getCTK_elem(12,3) + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - R 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" background-color=\"rgb(200,200,200)\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"right\" >\n " + objCTK.getCTK_elem(12,4) + " </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			               		sLinea = "	    </fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            		// IMPUESTOS
   		                        sLinea = "	    <fo:table-row >\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            			// IMPUESTOS
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block text-align=\"left\" font-weight=\"bold\">\n Impuestos </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - A
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			    sTasasA=objCTK.getCTK_elem(13,0);
								        sLinea = "      <fo:block  text-align=\"right\" >\n " + sTasasA + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - B
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			    sTasasB= objCTK.getCTK_elem(13,1);
								        sLinea = "      <fo:block  text-align=\"right\" >\n " + sTasasB+" </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - C
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			    sTasasC= objCTK.getCTK_elem(13,2);
							            sLinea = "      <fo:block  text-align=\"right\" >\n " + objCTK.getCTK_elem(13,2) + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - D
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			    sTasasD= objCTK.getCTK_elem(13,3);
							            sLinea = "      <fo:block  text-align=\"right\" >\n " + objCTK.getCTK_elem(13,3) + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - R 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\"  background-color=\"rgb(200,200,200)\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"right\" >\n " + objCTK.getCTK_elem(13,4) + " </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			               		sLinea = "	    </fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            		// ADMINISTRACION
   		                        sLinea = "	    <fo:table-row >\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            			// ADMINISTRACION
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block text-align=\"left\" font-weight=\"bold\">\n Administración </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - A
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			    sAdministracionA= objCTK.getCTK_elem(14,0);
								        sLinea = "      <fo:block  text-align=\"right\" >\n " + sAdministracionA + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - B
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			    sAdministracionB= objCTK.getCTK_elem(14,1);
								        sLinea = "      <fo:block  text-align=\"right\" >\n " + sAdministracionB + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - C
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			    sAdministracionC= objCTK.getCTK_elem(14,2);
							            sLinea = "      <fo:block  text-align=\"right\" >\n " + sAdministracionC + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - D
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			    sAdministracionD= objCTK.getCTK_elem(14,3);
							            sLinea = "      <fo:block  text-align=\"right\" >\n " + sAdministracionD + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - R 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			    sAdministracionE= objCTK.getCTK_elem(14,4);
								        sLinea = "      <fo:block  text-align=\"right\" >\n " + sAdministracionE + " </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			               		sLinea = "	    </fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            		// Renting
   		                        sLinea = "	    <fo:table-row >\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            			// Renting
			            			sLinea = "	    <fo:table-cell   padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block text-align=\"left\" font-weight=\"bold\">\n Renting </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - A
			            			sLinea = "	    <fo:table-cell background-color=\"rgb(200,200,200)\" padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"right\">\n " + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - B
			            			sLinea = "	    <fo:table-cell background-color=\"rgb(200,200,200)\" padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block  text-align=\"right\">\n " +  " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - C
			            			sLinea = "	    <fo:table-cell background-color=\"rgb(200,200,200)\" padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
							            sLinea = "      <fo:block  text-align=\"right\" >\n " + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - D
			            			sLinea = "	    <fo:table-cell background-color=\"rgb(200,200,200)\" padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
							            sLinea = "      <fo:block  text-align=\"right\" >\n " + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - R 
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sImprimirValor=Calcular(objCTK.getCTK_elem(18,4),objCTK.getCTK_elem(2,4));
			            			sRenting=sImprimirValor;
                           			if (sImprimirValor.equals("0"))
   			                           {sImprimirValor="";}			            			
								        sLinea = "      <fo:block  text-align=\"right\" >\n " + sImprimirValor + " </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            		sLinea = "	    </fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            		// TOTAL CTK
   		                        sLinea = "	    <fo:table-row >\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            			// TOTAL CTK
			            			sLinea = "	    <fo:table-cell padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
								        sLinea = "      <fo:block text-align=\"left\"  font-weight=\"bold\">\n TOTAL CTK </fo:block>";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - A
			            			sLinea = "	    <fo:table-cell background-color=\"rgb(200,200,200)\" padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
                                     sImprimirValor=CalcularTot2(sAmortizacionA, sCombustibleA, sTotalGastosA,sSeguroA,sItvA,sTasasA,sAdministracionA);			            			
                             			if (sImprimirValor.equals("0"))
     			                           {sImprimirValor="";}			            			
								        sLinea = "      <fo:block  text-align=\"right\" font-weight=\"bold\">\n " + sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - B
			            			sLinea = "	    <fo:table-cell background-color=\"rgb(200,200,200)\" padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
                                    sImprimirValor=CalcularTot2(sAmortizacionB, sCombustibleB, sTotalGastosB,sSeguroB,sItvB,sTasasB,sAdministracionB);			            			
                             			if (sImprimirValor.equals("0"))
     			                           {sImprimirValor="";}			            			
								        sLinea = "      <fo:block  text-align=\"right\" font-weight=\"bold\">\n " + sImprimirValor + " </fo:block>\n";
								        tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - C
			            			sLinea = "	    <fo:table-cell background-color=\"rgb(200,200,200)\" padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
                                    sImprimirValor=CalcularTot2(sAmortizacionC, sCombustibleC, sTotalGastosC,sSeguroC,sItvC,sTasasC,sAdministracionC);			            			
                             			if (sImprimirValor.equals("0"))
     			                           {sImprimirValor="";}			            			
							            sLinea = "      <fo:block  text-align=\"right\" font-weight=\"bold\">\n " + sImprimirValor + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - D
			            			sLinea = "	    <fo:table-cell background-color=\"rgb(200,200,200)\" padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
                                    sImprimirValor=CalcularTot3(sAmortizacionD, sCombustibleD, sTotalGastosD,sSeguroD,sTasasD,sAdministracionD);			            			
                             			if (sImprimirValor.equals("0"))
     			                           {sImprimirValor="";}			            			
							            sLinea = "      <fo:block  text-align=\"right\" font-weight=\"bold\">\n " + sImprimirValor + " </fo:block>\n";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			// VALORES POR RANGO - R 
			            			sLinea = "	    <fo:table-cell background-color=\"rgb(200,200,200)\" padding-top=\"0.2mm\" border-width=\"0.1mm\" border-style=\"solid\">\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
                                    sImprimirValor=CalcularTot4(sCombustibleE, sAdministracionE, sRenting);			            			
                             			if (sImprimirValor.equals("0"))
     			                           {sImprimirValor="";}			            			
							            sLinea = "      <fo:block  text-align=\"right\" font-weight=\"bold\">\n " + sImprimirValor + " </fo:block>\n";
				 			            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            		sLinea = "	    </fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			 	      	    sLinea = "	    </fo:table-body>\n";
			            	tmpFoFileStream.write(sLinea.getBytes());			            								            		
			            sLinea= "       </fo:table>\n";
		            	tmpFoFileStream.write(sLinea.getBytes());
		         sLinea = "      </fo:flow>\n";
                 tmpFoFileStream.write(sLinea.getBytes());

                 
         	 sLinea = "   </fo:page-sequence>\n";
             tmpFoFileStream.write(sLinea.getBytes());
             
         sLinea = "</fo:root>\n";
         tmpFoFileStream.write(sLinea.getBytes());

         tmpFoFileStream.close();
         
         FileInputStream file = new FileInputStream(sFoFileDir + tmpFoFile.getName());
         renderFO(new InputSource(file), response);
         tmpFoFile.delete();
         response.flushBuffer();

      } catch (Exception ex) {
      	try {
			response.sendRedirect("m05bError.jsp");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			miLog.addTraza(e);
		}
      } 
    }  // Fin funcion performTask


    /**
     * renders an FO inputsource into a PDF file which is rendered
     * directly to the response object's OutputStream
     */
    public void renderFO(InputSource foFile, HttpServletResponse response) throws ServletException
    {
        try  {
            ByteArrayOutputStream out = new ByteArrayOutputStream();

	    	response.reset();
            OutputStream oOut=response.getOutputStream();
            BufferedOutputStream bOut=new BufferedOutputStream(oOut);
            Driver driver = new Driver(foFile, out);
            driver.setRenderer(Driver.RENDER_PDF);
            driver.run();

            response.setContentLength(out.size());
	    	response.setContentType("application/pdf");


            bOut.write(out.toByteArray());
	    	out.close();
	    	bOut.flush();
            bOut.close();
//	    response.flushBuffer();
        }  catch (Exception ex) {
            throw new ServletException(ex);
        }
    }


	private void fncAbrirFicheroTemporal() throws java.io.IOException
	{	     foFileDir = new File(sFoFileDir);
	         tmpFoFile = File.createTempFile("m05b", "Fo", foFileDir);
			 tmpFoFileStream = new FileOutputStream(tmpFoFile);
	}	
	
	
	private void fncGenerarPiePagina() throws java.io.IOException {
        	sLinea = "		<fo:static-content flow-name=\"xsl-region-after\">\n";
        	tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block >\n";
		            tmpFoFileStream.write(sLinea.getBytes());
		            	sLinea= "       <fo:table>\n";
		            	tmpFoFileStream.write(sLinea.getBytes());
		            		sLinea = "	    <fo:table-column column-width=\"80mm\"/>\n";
			            	tmpFoFileStream.write(sLinea.getBytes());
		            		sLinea = "	    <fo:table-column column-width=\"160mm\"/>\n";
			            	tmpFoFileStream.write(sLinea.getBytes());
		            		sLinea = "	    <fo:table-body font-family=\"Helvetica\" font-size=\"6pt\">\n";
			            	tmpFoFileStream.write(sLinea.getBytes());
			            		sLinea = "	    <fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    <fo:table-cell >\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
							            sLinea = "      <fo:block text-align=\"left\">" + miComun.getDetFechaActual(m05bConstantesInformes.IDIOMA_C)+ "</fo:block>";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    <fo:table-cell >\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            			    sLinea = "      <fo:block text-align=\"right\">" ; 
                       		            tmpFoFileStream.write(sLinea.getBytes());
		                                sLinea = "Página <fo:page-number/> \n";
                        	            tmpFoFileStream.write(sLinea.getBytes());
							            sLinea=  "</fo:block>";
							            tmpFoFileStream.write(sLinea.getBytes());
			            			sLinea = "	    </fo:table-cell>\n";
			            			tmpFoFileStream.write(sLinea.getBytes());
			            		sLinea = "	    </fo:table-row>\n";
			            		tmpFoFileStream.write(sLinea.getBytes());
		            		sLinea = "	    </fo:table-body>\n";
			            	tmpFoFileStream.write(sLinea.getBytes());			            								            		
			            sLinea= "       </fo:table>\n";
		            	tmpFoFileStream.write(sLinea.getBytes());
		            sLinea = "      </fo:block>\n";
		            tmpFoFileStream.write(sLinea.getBytes());
        	sLinea = " 		</fo:static-content>\n"; 
        	tmpFoFileStream.write(sLinea.getBytes());
		 miLog.addTraza(m05bConstantes.LOG_NO_USER,m05bConstantes.LOG_NO_SRC,"CUATRO", m05bConstantes.LOG_NIVEL_BAJO);		
	}		
    
	


}