VeneHosting.com :: Tu Hosting en Venezuela

Autor Tema: Generar dos cabeceras con fpdf en la msima hoja  (Leído 653 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado chimaria

  • Novato
  • *
  • Mensajes: 5
  • Puntuación: 0
    • Ver Perfil
Generar dos cabeceras con fpdf en la msima hoja
« : 17 de septiembre de 2010, 05:02:51 pm »
Saludos a todos tengo una pregunta, estoy generando un reporte con fpdf, en mi caso particular estoy generando un recibo, y necesito que en una hoja salgan las dos copias del recibo, el problema que tengo es que no se como hacer para que me genere la segunda cabecera dentro de la misma hoja, los conceptos si los puedo generar de nuevo con un cliclo pero la cabecera no aqui les coloco  el codigo para ver si alguien me puede ayudar.
Gracias de Antemano


define('FPDF_FONTPATH','fpdf/font/');
require_once('fpdf/fpdf.php');
    class PDF extends FPDF
   {
   
   //Cabecera de página
   function Header()
   {
      $fecha = date("d/m/Y");
      //Logo
      $tipo_nomina  = $_GET['TIPO_NOMINA'];
      $numero_control = $_GET['NUMERO_CONTROL'];
      $empleado = $_GET['EMPLEADO'];
      $nomina = nombre_nomina($tipo_nomina);
      $matriz_empleados = bsc_datos_empleados($tipo_nomina,$numero_control, $empleado);
      //for($i=0;$i<2;$i++) {
      /*-----------------------------------------------*/
      $this->SetFont('Arial','',9);
      $this->Image('../imagenes/escudo_ujap.jpg',10,8,20);
      $this->SetFont('Arial','',9);
      $this->Text(30,17,"UNIVERSIDAD JOSÉ ANTONIO PÁEZ");
      $this->SetFont('Arial','',8);
      $this->Text(30,20,"DEPARTAMENTO DE RECURSOS HUMANOS");
      $this->SetFont('Arial','',7);
      $this->Text(45,23,"VALENCIA- EDO. CARABOBO");
      $this->SetFont('Arial','B',7);
      $this->Text(52,26,"Rif:J-xxxxxxxxx-9");
      //Salto de línea
      $this->SetFillColor(232,232,232);
      $this->Line(10,31,200,31); // Linea Horizontal
      //$this->Line(10,45,200,45);// Linea horizontal
      
      // Principal
      $this->SetFont('Arial','B',8);
      $this->Text(120,20,"Desde");
      $this->SetFont('Arial','',7);
      $this->Text(133,20,date("d/m/Y",fecha_a_mktime($matriz_empleados['FECHA_INICIO'])));
      
      $this->SetFont('Arial','B',8);
      $this->Text(155,20,"Hasta");
      $this->SetFont('Arial','',7);
      $this->Text(165,20,date("d/m/Y",fecha_a_mktime($matriz_empleados['FECHA_FIN'])));
      
      $this->SetFont('Arial','B',8);
      $this->Text(120,23,'Nro Control');
      $this->SetFont('Arial','',7);
      $this->Text(138,23,$numero_control);
      
      $this->SetFont('Arial','B',8);
      $this->Text(155,23,'Nro Cuenta');
      $this->SetFont('Arial','',7);
      $this->Text(175,23,$matriz_empleados['NRO_CUENTA']);
      
      $this->SetFont('Arial','B',8);
      $this->Text(155,29,'Fecha Ingreso');
      $this->SetFont('Arial','',7);
      $this->Text(175,29,date("d/m/Y",fecha_a_mktime($matriz_empleados['FECHA_INGRESO'])));
      
      
      $this->SetFont('Arial','B',8);
      $this->Text(12,37,"Cédula");
      $this->SetFont('Arial','',7);
      $this->Text(27,37,$empleado);
      
      $this->SetFont('Arial','B',8);
      $this->Text(48,37,"Nombres y Apellidos");
      $this->SetFont('Arial','',7);
      $this->Text(80,37,$matriz_empleados['NOMBRES'].' '.$matriz_empleados['APELLIDOS']);
      
      $this->SetFont('Arial','B',8);
      $this->Text(155,37,"Sueldo Mensual");
      $this->SetFont('Arial','',7);
      $this->Text(180,37,$matriz_empleados['SUELDO']);
      $this->Line(10,39,200,39); // Linea Horizontal
   
      $this->SetFont('Arial','B',8);
      $this->Text(12,45,"Departamento");
      $this->SetFont('Arial','',7);
      $this->Text(35,45, $matriz_empleados['DEPARTAMENTO']);
      
      $this->SetFont('Arial','B',8);
      $this->Text(122,45,"Cargo");
      $this->SetFont('Arial','',7);
      $this->Text(135,45, $matriz_empleados['CARGO']);
      $this->Line(10,47,200,47); // Linea Horizontal
   
      $this->SetFont('Arial','B',8);
      $this->Text(12,52,"Concepto");
      $this->SetFont('Arial','B',8);
      $this->Text(105,52, 'Asignaciones');
      $this->SetFont('Arial','B',8);
      $this->Text(140,52, 'Deducciones');
      $this->SetFont('Arial','B',8);
      $this->Text(177,52, 'Neto');
      $this->Line(10,47,200,47); // Linea Horizontal
      $this->SetFont('Arial','',7);
   
      $this->Ln(43);
   } // fin de la funcion header
   //Pie de página
   function Footer()
   {
      $this->SetY(-15);   //Posición: a 1,5 cm del final
      $this->SetFont('Arial','I',8);   //Arial italic 8
      $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');   //Número de página

    }//fin de la funcion Footer
   }// fin de la clase
    //Creación del objeto de la clase heredada
   $pdf=new PDF();
   $pdf->AliasNbPages();
   $pdf->AddPage();
   for($i=0; $i<2;$i++) {
   $pdf->SetFont('Arial','',7);
   $fill=false;
   
   $w=array(90,25,33,40);
   
     $total_asignaciones = 0;
     $total_deducciones  = 0;
     $indice_movimientos = 0;
     $total_conceptos_movimientos = count($matriz_movimientos_empleados);
     while($indice_movimientos < $total_conceptos_movimientos) {
         
      $pdf->Cell($w[0],6,$matriz_movimientos_empleados[$indice_movimientos]['CONCEPTO'],0,0,'L',$fill);
      if( $matriz_movimientos_empleados[$indice_movimientos]['CLASE']==1) { $total_asignaciones = $total_asignaciones +$matriz_movimientos_empleados[$indice_movimientos]['MONTO'];
         $pdf->Cell($w[1],6,number_format($matriz_movimientos_empleados[$indice_movimientos]['MONTO'],2,',','.'),0,0,'R',$fill);
         $pdf->Cell($w[2],6,' ',0,0,'J',$fill);
      }else {
         $total_deducciones = $total_deducciones +$matriz_movimientos_empleados[$indice_movimientos]['MONTO'];
         $pdf->Cell($w[1],6,' ',0,0,'J',$fill);
         $pdf->Cell($w[2],6,number_format($matriz_movimientos_empleados[$indice_movimientos]['MONTO'],2,',','.'),0,0,'R',$fill);
      }// fin del else
      $pdf->Cell($w[3],6,' ',0,0,'J',$fill);
      $indice_movimientos++;
      $pdf->Ln(4);
      }// fin del while
      $pdf->Ln(1);
      $pdf->Cell(188,1,'','T');
      $pdf->Ln(2);
      $pdf->SetFont('Arial','B',8);
      $pdf->Cell($w[0],6,'Totales ',0,0,'L',$fill);
      $pdf->SetFont('Arial','B',7);
      $pdf->Cell($w[1],6,$total_asignaciones,0,0,'R',$fill);
      $pdf->Cell($w[2],6,$total_deducciones,0,0,'R',$fill);
      $pdf->Cell($w[3],6,$total_asignaciones - $total_deducciones,0,0,'C',$fill);
      $pdf->Ln(5);
      $pdf->SetFont('Arial','B',8);
      $pdf->Cell($w[0],6,'Observaciones ',0,0,'L',$fill);
      $pdf->Ln(5);
      //$pdf->set_line_width(1);
      $pdf->Cell(188,1,'','T');//Linea Horizontal
      $pdf->Ln(8);
      $pdf->Cell(188,1,'','T');//Linea Horizontal
      $pdf->Ln(4);
      $pdf->Cell(10,25,'','C');
      $pdf->Header();
      $pdf->Ln(10);
      //$pdf->Line(10,113,10,121); // Linea Vertical
   }// fin del for
      $pdf->Output();
?>

Desconectado Carlos Belisario

  • Usuario Dedicado
  • ***
  • Mensajes: 152
  • Puntuación: 9
  • Sexo: Masculino
    • Ver Perfil
    • Carlosbelisario.com
Re:Generar dos cabeceras con fpdf en la msima hoja
« Respuesta #1 : 17 de septiembre de 2010, 05:05:47 pm »
bueno yo tube un problema similar y lo que hice aunque no se si sea lo mejor fue que no use la cabecera sino que dentro del ciclo cree las cabeceras y el texto y pie de pagina esto por el problema que se te presenta ya que las cabeceras y pie de pagina se repiten es por hoja espero que te pueda servir mi concejo saludos

Desconectado chimaria

  • Novato
  • *
  • Mensajes: 5
  • Puntuación: 0
    • Ver Perfil
Re:Generar dos cabeceras con fpdf en la msima hoja
« Respuesta #2 : 17 de septiembre de 2010, 06:57:12 pm »
bueno yo tube un problema similar y lo que hice aunque no se si sea lo mejor fue que no use la cabecera sino que dentro del ciclo cree las cabeceras y el texto y pie de pagina esto por el problema que se te presenta ya que las cabeceras y pie de pagina se repiten es por hoja espero que te pueda servir mi concejo saludos





Hola Carlos lo que tu dices es que coloque el for dentro de l funcion header , porque si es eso lo hice pero no me funciono
al,go asi fue lo que intemnte pero no me funciono
define('FPDF_FONTPATH','fpdf/font/');
require_once('fpdf/fpdf.php');
    class PDF extends FPDF
   {
   
   //Cabecera de página
   function Header()
   {
      $fecha = date("d/m/Y");
      //Logo
      $tipo_nomina  = $_GET['TIPO_NOMINA'];
      $numero_control = $_GET['NUMERO_CONTROL'];
      $empleado = $_GET['EMPLEADO'];
      $nomina = nombre_nomina($tipo_nomina);
      $matriz_empleados = bsc_datos_empleados($tipo_nomina,$numero_control, $empleado);
      /*-----------------------------------------------*/
      for($i=0;$i<2;$i++) {
      $this->SetFont('Arial','',9);
      $this->Image('../imagenes/escudo_ujap.jpg',10,8,20);
      $this->SetFont('Arial','',9);
      $this->Text(30,17,"UNIVERSIDAD JOSÉ ANTONIO PÁEZ");
      $this->SetFont('Arial','',8);
      $this->Text(30,20,"DEPARTAMENTO DE RECURSOS HUMANOS");
      $this->SetFont('Arial','',7);
      $this->Text(45,23,"VALENCIA- EDO. CARABOBO");
      $this->SetFont('Arial','B',7);
      $this->Text(52,26,"Rif:J-30400858-9");
      //Salto de línea
      $this->SetFillColor(232,232,232);
      $this->Line(10,31,200,31); // Linea Horizontal
      //$this->Line(10,45,200,45);// Linea horizontal
      
      // Principal
      $this->SetFont('Arial','B',8);
      $this->Text(120,20,"Desde");
      $this->SetFont('Arial','',7);
      $this->Text(133,20,date("d/m/Y",fecha_a_mktime($matriz_empleados['FECHA_INICIO'])));
      
      $this->SetFont('Arial','B',8);
      $this->Text(155,20,"Hasta");
      $this->SetFont('Arial','',7);
      $this->Text(165,20,date("d/m/Y",fecha_a_mktime($matriz_empleados['FECHA_FIN'])));
      
      $this->SetFont('Arial','B',8);
      $this->Text(120,23,'Nro Control');
      $this->SetFont('Arial','',7);
      $this->Text(138,23,$numero_control);
      
      $this->SetFont('Arial','B',8);
      $this->Text(155,23,'Nro Cuenta');
      $this->SetFont('Arial','',7);
      $this->Text(175,23,$matriz_empleados['NRO_CUENTA']);
      
      $this->SetFont('Arial','B',8);
      $this->Text(155,29,'Fecha Ingreso');
      $this->SetFont('Arial','',7);
      $this->Text(175,29,date("d/m/Y",fecha_a_mktime($matriz_empleados['FECHA_INGRESO'])));
      
      
      $this->SetFont('Arial','B',8);
      $this->Text(12,37,"Cédula");
      $this->SetFont('Arial','',7);
      $this->Text(27,37,$empleado);
      
      $this->SetFont('Arial','B',8);
      $this->Text(48,37,"Nombres y Apellidos");
      $this->SetFont('Arial','',7);
      $this->Text(80,37,$matriz_empleados['NOMBRES'].' '.$matriz_empleados['APELLIDOS']);
      
      $this->SetFont('Arial','B',8);
      $this->Text(155,37,"Sueldo Mensual");
      $this->SetFont('Arial','',7);
      $this->Text(180,37,$matriz_empleados['SUELDO']);
      $this->Line(10,39,200,39); // Linea Horizontal
   
      $this->SetFont('Arial','B',8);
      $this->Text(12,45,"Departamento");
      $this->SetFont('Arial','',7);
      $this->Text(35,45, $matriz_empleados['DEPARTAMENTO']);
      
      $this->SetFont('Arial','B',8);
      $this->Text(122,45,"Cargo");
      $this->SetFont('Arial','',7);
      $this->Text(135,45, $matriz_empleados['CARGO']);
      $this->Line(10,47,200,47); // Linea Horizontal
   
      $this->SetFont('Arial','B',8);
      $this->Text(12,52,"Concepto");
      $this->SetFont('Arial','B',8);
      $this->Text(105,52, 'Asignaciones');
      $this->SetFont('Arial','B',8);
      $this->Text(140,52, 'Deducciones');
      $this->SetFont('Arial','B',8);
      $this->Text(177,52, 'Neto');
      $this->Line(10,47,200,47); // Linea Horizontal
      $this->SetFont('Arial','',7);
   
      $this->Ln(43);
      }// fin de la llave del for
   } // fin de la funcion header
   //Pie de página



Desconectado Carlos Belisario

  • Usuario Dedicado
  • ***
  • Mensajes: 152
  • Puntuación: 9
  • Sexo: Masculino
    • Ver Perfil
    • Carlosbelisario.com
Re:Generar dos cabeceras con fpdf en la msima hoja
« Respuesta #3 : 17 de septiembre de 2010, 09:26:25 pm »
no que no uses la funcion header sino que las cabeceras las establescas en el mismo cuerpo del mensaje a ver

PHP de Venezuela

Re:Generar dos cabeceras con fpdf en la msima hoja
« Respuesta #3 : 17 de septiembre de 2010, 09:26:25 pm »

 

PHP de Venezuela on Facebook