PHP - Multicell en FPDF y Encabezados

 
Vista:
sin imagen de perfil
Val: 23
Ha disminuido su posición en 39 puestos en PHP (en relación al último mes)
Gráfica de PHP

Multicell en FPDF y Encabezados

Publicado por Fabian (12 intervenciones) el 28/07/2020 15:00:38
Buenos días,

Recurro a este foro ya que presento inconvenientes en la posision de un multicell cuando pasa a la segunda hoja y hay encabezados. El problema es que en la primera hoja hay un encabezado (que se repite en todas las hojas) y cuando el multicell pasa a la segunda hoja se remonta en el encabezado, la idea es que no se remonte sino que continué abajo de este. Como podría solucionar esto.

1
2

Este es el codigo que uso:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<?php
require('./../Librerias/Pdf/fpdf.php');
require "./../Conexion/Conection.php";
require_once ( "./../Librerias/phpqrcode/qrlib.php");
$Admision = $_POST["Admision"];
 
    $SQL = "SQL STRING VA AQUI'";
 
    $SQL_Res = sqlsrv_query($conn, $SQL) or die (print_r( sqlsrv_errors(), true));
    if ($SQL_SUM = sqlsrv_fetch_array($SQL_Res))
    {
 
    }
    else
    {
    echo "Esta nota aun no tiene cargos guardados, si desea ver la nota dirijase a la opcion de notas por la aplicacion de escritorio";
    return;
    }
?>
 
<?php
class PDF extends FPDF
{
function Header()
{ //ENCABEZADO
     require "./../Conexion/Conection.php";
     $Admision = $_POST["Admision"];
 
    $SQL = "SQL STRING VA AQUI''";
 
    $SQL_Res = sqlsrv_query($conn, $SQL) or die (print_r( sqlsrv_errors(), true));
    $SQL_SUM = sqlsrv_fetch_array($SQL_Res);
 
    $Fecha =  date_format($SQL_SUM["Not_Fecha"], 'Y-m-d');
    $Profesional = $SQL_SUM["Bod_Responsable"];
    $Centro = $SQL_SUM["Com_Nombre"];
    $Nit = $SQL_SUM["Com_Identificacion"];
    $Tels = $SQL_SUM["Com_Telefono"];
    $Direccion = $SQL_SUM["Com_Direccion"];
    $Paciente = $SQL_SUM["Pac_PrimerA"] . " " . $SQL_SUM["Pac_SegundoA"] . " " . $SQL_SUM["Pac_PrimerN"] . " " . $SQL_SUM["Pac_SegundoN"];
    $Documento = $SQL_SUM["Pac_TipoId"] . " " . $SQL_SUM["Pac_IdNum"];
    $Aseguradora = $SQL_SUM["Ase_Descripcion"];
 
    $this->SetFont('Arial','B',8);
    $this->Text(72,10,'NOTAS DE CURACION');
    $this->Text(10,10,'ADMISION: ');
    $this->SetFont('Arial','b',8);
 
    $this->Cell(55);
    $this->Text(10,20,'Profesional: ');
    $this->Text(10,27,'Fecha: ');
    $this->SetFont('Arial','',8);
    $this->Text(30,20,$Profesional);
    $this->Text(30,27,$Fecha);
    $this->SetFont('Arial','b',12);
    $this->Text(30,10,$Admision);
 
    $this->SetFont('Arial','b',8);
    $this->Cell(1);
    $this->SetFont('Arial','',8);
 
    $this->Line(10,30,200,30);
    $this->SetFont('Arial','b',8);
    $this->Text(10,34,'Centro Medico: ');
    $this->SetFont('Arial','',8);
    $this->Text(35,34,$Centro);
 
    $this->SetFont('Arial','b',8);
    $this->Text(10,39,'Nit: ');
    $this->SetFont('Arial','',8);
    $this->Text(35,39,$Nit);
 
    $this->SetFont('Arial','b',8);
    $this->Text(10,44,'Telefonos: ');
    $this->SetFont('Arial','',8);
    $this->Text(35,44,$Tels);
 
    $this->SetFont('Arial','b',8);
    $this->Text(10,49,'Direccion: ');
    $this->SetFont('Arial','',8);
    $this->Text(35,49,$Direccion);
 
    $this->Line(10,51,200,51);
    $this->Ln(4);
 
    $this->SetFont('Arial','b',8);
    $this->Text(10,56,'Paciente: ');
    $this->SetFont('Arial','',8);
    $this->Text(35,56,$Paciente);
 
    $this->SetFont('Arial','b',8);
    $this->Text(10,61,'Identificacion: ');
    $this->SetFont('Arial','',8);
    $this->Text(35,61,$Documento);
 
    $this->SetFont('Arial','b',8);
    $this->Text(100,56,'Aseguradora: ');
    $this->SetFont('Arial','',8);
    $this->Text(125,56,$Aseguradora);
 
    $this->SetFont('Arial','b',8);
    $this->Text(100,61,'Telefono: ');
    $this->SetFont('Arial','',8);
    $this->Line(10,65,200,65);
    $this->Ln(4);
 
    QRcode :: png (" - Orden: " . $Admision . " - Paciente: " . $Paciente . " - Fecha: " . $Fecha, "./../Librerias/Pdf/test.png");
    $this -> Image("./../Librerias/Pdf/test.png",170,3,25,25,"png");
}
 
//PIE DE PAGINA
function Footer()
{
    require "./../Conexion/Conection.php";
 
    $Orden = $_POST["Admision"];
    $suma3 = "SQL STRING VA AQUI'";
    $suma_res3 = sqlsrv_query($conn, $suma3) or die (print_r( sqlsrv_errors(), true));
    $col_sum3 = sqlsrv_fetch_array($suma_res3);
 
    $Medico = $col_sum3["Bod_Responsable"];
 
$start_x=$this->GetX(); //initial x (start of column position)
$current_y = $this->GetY();
$current_x = $this->GetX();
$cell_width = 180;  //define cell width
$cell_height=5;    //define cell height
 
   // $this->SetXY(10, 235);
   // $this->MultiCell($cell_width,$cell_height,$Medico,2); ///////////////////////
    //$this->Line(10,230,200,230);
    $this->SetFont('Arial','b',8);
    $this->Text(10,260,$Medico);
    $this->Text(10,265,'Medico que Ordena');
    $this->Line(10,261,200,261);
    $this->SetFont('Arial','b',8);
    $this->Text(150,265,'Firma y Sello Medico que Ordena');
    $this->SetY(-15);
    $this->SetFont('Arial','I',8);
    $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
 
}
 
//CUERPO DEL DOCUMENTO
$Admision = $_POST["Admision"];
$conV = SQL STRING VA AQUI''";
$resV = sqlsrv_query($conn, $conV) or die (print_r( sqlsrv_errors(), true));
$pdf = new PDF("P", "mm", "Letter");
$pdf->AddPage();
$pdf->SetFont('Arial','',8);
if ($columna = sqlsrv_fetch_array($resV))
{
    $Nota = $columna["Not_Nota"];
    $start_x=$pdf->GetX(); //initial x (start of column position)
    $current_y = $pdf->GetY();
    $current_x = $pdf->GetX();
    $cell_width = 180;  //define cell width
    $cell_height=5;    //define cell height
    $pdf->SetFont('Arial','b',8);
    $pdf->Text(90,69,'NOTA DE CURACION');
    $pdf->Line(10,71,200,71);
    $pdf->SetXY(10, 73);
    $pdf->SetFont('Arial','',8);
    $pdf->MultiCell($cell_width,$cell_height,$Nota,2);
    $pdf->Ln(3);
    $pdf->SetFont('Arial','b',8);
    $pdf->Cell(75);
    $pdf->MultiCell($cell_width,$cell_height,'LISTA DE APOSITOS/INSUMOS',2);
    $pdf->Ln(3);
    $pdf->SetFont('Arial','b',8);
    $pdf->Cell(1);
    $cell_width = 30;  //define cell width
    $cell_height=5;
    $pdf->MultiCell($cell_width,$cell_height,'Codigo',2);
    $pdf->Ln(-5);
    $pdf->Cell(30);
    $pdf->MultiCell($cell_width,$cell_height,'Item/Detalle',2);
    $pdf->Ln(-5);
    $pdf->Cell(150);
    $pdf->MultiCell($cell_width,$cell_height,'Cantidad',2);
    $pdf->SetFont('Arial','',8);
    $pdf->Ln(3);
        $conV2 = "SQL STRING VA AQUI''";
        $resV2 = sqlsrv_query($conn, $conV2) or die (print_r( sqlsrv_errors(), true));
              while ($columna2 = sqlsrv_fetch_array($resV2))
                 {
                    $Codigo = $columna2["Car_Cod"];
                    $Item = $columna2["Car_Item"];
                    $Detalle = $columna2["Car_Detalle"];
                    $Cantidad = $columna2["Car_Cant"];
                    $pdf->SetX(10);
                    $pdf->Cell(2);
                    $pdf->MultiCell($cell_width,$cell_height,$Codigo,2);
                    //$cell_width = 110;
                    //$pdf->Ln(-5);
                    //$pdf->Cell(30);
                    //$pdf->MultiCell($cell_width,$cell_height,$Item,2);
                    //$cell_width = 30;
                    //$pdf->Ln(-5);
                    //$pdf->Cell(155);
                    //$pdf->MultiCell($cell_width,$cell_height,$Cantidad,2);
                    //$cell_width = 110;
                    //$pdf->Ln(0.5);
                    //$pdf->Cell(30);
                    //$pdf->MultiCell($cell_width,$cell_height,$Detalle,2);
                    $pdf->Ln();
                 }
}
$pdf->Output();
?>

Como puedo solucionar esto. Agradezco a las personas que me puedan colaborar.

Muchas gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder