Ver Mensaje Individual
  #4 (permalink)  
Antiguo 19/06/2014, 00:35
quimfv
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 1 mes
Puntos: 574
Respuesta: problemas al generar pdf-> base de datos

No parece que

Código php:
Ver original
  1. echo"<a href='../GenerarPdf1.php?id_parte=$fila14[ID_PARTE]&&num_carne=$num_carne'>$fila14[INDICATIVO]</a>";

sea el cancelar.

Usa highlight please


Código PHP:
Ver original
  1. <?php
  2. require('../fpdf/fpdf.php');
  3. include("../funciones/conectarBBDD.php");
  4. include("../funciones/desconectarBBDD.php");
  5.  
  6. $conexion=conectarBBDD();
  7. $conectado=$conexion[0];
  8. $manejador=$conexion[1];
  9.  
  10. header("Content-Type: text/html;charset=utf-8");
  11. $pdf=new FPDF('L');
  12. $pdf->SetTopMargin(15);
  13. $pdf->SetLeftMargin(15);
  14. $pdf->SetRightMargin(15);
  15. $pdf->AddPage();
  16.  
  17. $pdf->SetFont('Helvetica','UB',12);
  18. $pdf->Ln();
  19. /*
  20. Cell (w, h, texto, borde, ln, align, fill, link)
  21. w-> ancho de celda. Si=0 la celda se extiende hasta el margen derecha
  22. h-> alto de celda.
  23. texto
  24. borde-> 0 o 1
  25. ln->nos dice donde se empezará a escribir después de llamar a esta función (0-> a la derecha; 1, al comienzo de la sig linea; 2-> debajo
  26. align-> alineación L,C y R
  27. Fill-> fondo con color o no (true o false)
  28.  
  29. */
  30. $pdf->SetFont('Arial','UB',18);
  31. $pdf->Cell(0,10,'- PARTE -',0,1,'C'); //lo escribimos, sin borde y pasamos a la siguiente línea
  32.  
  33. if(!$_GET)
  34. {
  35. $id_parte=$_POST['id_parte'];
  36. $num_carne=$_POST['num_carne'];
  37. }
  38. else
  39. {
  40. $id_parte=$_GET['id_parte'];
  41. $num_carne=$_GET['num_carne'];
  42. }
  43.  
  44. //Grabación de la consulta
  45. $consulta13="SELECT ID_CONSULTA FROM consultas order by ID_CONSULTA DESC";
  46. $datos13=mysql_query($consulta13);
  47. $fila13=mysql_fetch_array($datos13);
  48.  
  49. $id_consulta=$fila13['ID_CONSULTA']+1;
  50. if(!empty($_SERVER['HTTP_CLIENT_IP']))
  51. {
  52. $ip=$_SERVER['HTTP_CLIENT_IP'];
  53. }
  54. elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
  55. {
  56. $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
  57. }
  58. else
  59. {
  60. $ip=$_SERVER['REMOTE_ADDR'];
  61. }
  62.  
  63. $fecha=getdate();
  64. $d=$fecha['mday'];
  65. if($d<10)
  66. $dia='0'.$d;
  67. else
  68. $dia=$d;
  69. $m=$fecha['mon'];
  70. if($m<10)
  71. $mes='0'.$m;
  72. else
  73. $mes=$m;
  74. $ano=$fecha['year'];
  75. $h=$fecha['hours'];
  76. if($h<10)
  77. $hora='0'.$h;
  78. else
  79. $hora=$h;
  80. $min=$fecha['minutes'];
  81. if($min<10)
  82. $minutos='0'.$min;
  83. else
  84. $minutos=$min;
  85. $f=$ano.'-'.$mes.'-'.$dia;
  86. $h=$hora.':'.$minutos;
  87.  
  88. /*ERROR!!! ESTO LO HACE SIEMPRE, ...AUNQUE LE DE A CANCELAR!!!*/
  89. $consulta16="INSERT INTO consultas VALUES ($id_consulta,$id_parte,'$ip','$num_carne',2,'$f', '$h')";
  90. $datos16=mysql_query($consulta16);
  91. if(!$datos16)
  92. {
  93. $mensaje="Ha ocurrido alg&uacute;n error durante la grabaci&oacute;n";
  94. $mal=1;
  95. echo"<script type='text/javascript'>window.alert('$mensaje');window.histor y.back();</script>";
  96. exit();
  97. }
  98.  
  99. $consulta="SELECT * FROM parte WHERE ID_PARTE=$id_parte";
  100. $datos=mysql_query($consulta);
  101. $fila=mysql_fetch_array($datos);
  102.  
  103. $pdf->SetFont('Arial','B',12);
  104. $pdf->Cell(50,8,'Unidad de: ',0,0,'L');
  105. $pdf->SetFont('Arial','U',12);
  106. $pdf->Cell(50,8,$fila['UNIDAD'],0,0,'L');
  107.  
  108. $pdf->SetFont('Arial','B',12);
  109. $pdf->Cell(40,8,'Tipo: ',0,0,'L');
  110. $pdf->SetFont('Arial','U',12);
  111. $pdf->Cell(25,8,$fila['TIPO'],0,0,'L');
  112.  
  113. $pdf->SetFont('Arial','B',12);
  114. $pdf->Cell(29,8,'Indicativo: ',0,0,'L');
  115. $pdf->SetFont('Arial','U',12);
  116. $pdf->Cell(25,8,$fila['INDICATIVO'],0,0,'L');
  117.  
  118. $pdf->SetFont('Arial','B',12);
  119. $pdf->Cell(27,8,'Matrícula: ',0,0,'L');
  120. $pdf->SetFont('Arial','U',12);
  121. $pdf->Cell(27,8,$fila['MATRICULA'],0,1,'L');
  122.  
  123. $pdf->SetFont('Arial','B',12);
  124. $pdf->Cell(27,8,'Fecha: ',0,0,'L');
  125. $pdf->SetFont('Arial','U',12);
  126. $pdf->Cell(35,8,$fila['FECHA_PARTE'],0,0,'L');
  127.  
  128. $pdf->SetFont('Arial','B',12);
  129. $pdf->Cell(27,8,'Hora: ',0,0,'L');
  130. $pdf->SetFont('Arial','U',12);
  131. $pdf->Cell(27,8,$fila['HORA_PARTE'],0,0,'L');
  132.  
  133. $pdf->SetFont('Arial','B',12);
  134. $pdf->Cell(54,8,'Nº/s: ',0,0,'L');
  135. $pdf->SetFont('Arial','U',12);
  136. $consulta1="SELECT * FROM personal_parte WHERE ID_PARTE=$id_parte";
  137. $datos1=mysql_query($consulta1);
  138. $texto='';
  139. while($fila1=mysql_fetch_array($datos1))
  140. {
  141. $texto= $fila1['NUM_CARNE'].' ,'.$texto;
  142. }
  143. $pdf->Cell(100,8,$texto,0,1,'L');
  144.  
  145. //145
  146. $pdf->SetFont('Arial','B',12);
  147. $pdf->Cell(45,8,'Lugar: ',0,0,'L');
  148. $pdf->SetFont('Arial','U',12);
  149. $texto=$fila['TIPO_VIA'].' '.$fila['NOMBRE_VIA'];
  150. $pdf->Cell(100,8,$texto,0,0,'L');
  151.  
  152. //125
  153. $pdf->SetFont('Arial','B',12);
  154. $pdf->Cell(30,8,'Motivo: ',0,0,'L');
  155. $pdf->SetFont('Arial','U',12);
  156. if($fila['MOTIVO']==1)
  157. $texto='Llamada';
  158. else if($fila['MOTIVO']==2)
  159. $texto='Sí';
  160. else if($fila['MOTIVO']==3)
  161. $texto='No';
  162. $pdf->Cell(95,8,$texto,0,1,'L');
  163.  
  164. $pdf->SetFont('Arial','BU',8);
  165. $pdf->Cell(0,10,'Personas ',0,1,'C'); //lo escribimos, sin borde y pasamos a la siguiente línea
  166. $pdf->SetFont('Arial','B',8);
  167. $pdf->Cell(30,12,"D.N.I.\n PASAPORTE",1,0,'C');
  168. $pdf->Cell(50,12,'NOMBRE Y APELLIDOS',1,0,'C');
  169. $pdf->Cell(50,12,'LUGAR Y FECHA NACIMIENTO ',1,0,'C');
  170.  
  171. $consulta2="SELECT * FROM PARTICIPANTES_PARTE WHERE ID_PARTE=$id_parte";
  172. $datos2=mysql_query($consulta2);
  173. $vacio=0;
  174. while ($fila2=mysql_fetch_array($datos2))
  175. {
  176. //para cada participante
  177. $vacio=1;
  178. if($fila2['TIPO_DOC']==1)
  179. $texto='Indocumentado';
  180. else
  181. $texto=$fila2['DNI'];
  182. $pdf->Cell(30,8,$texto,1,0,'C');
  183. $texto=$fila2['NOMBRE'].' '. $fila2['APE1'].' '. $fila2['APE2'];
  184. $pdf->Cell(50,8,$texto,1,0,'C');
  185. $texto=$fila2['LUGAR_NAC'].', '.$fila2['FECHA_NAC'];
  186. $pdf->Cell(50,8,$texto,1,0,'C');
  187. $pdf->Cell(30,8,$texto,1,1,'C');
  188. }
  189. if($vacio==0)
  190. {
  191. $pdf->Cell(30,8,'',1,0,'C');
  192. $pdf->Cell(50,8,'',1,0,'C');
  193. $pdf->Cell(50,8,'',1,0,'C');
  194. $pdf->Cell(30,8,'',1,0,'C');
  195. $pdf->Cell(50,8,'',1,0,'C');
  196. $pdf->Cell(30,8,'',1,0,'C');
  197. $pdf->Cell(30,8,'',1,1,'C');
  198. }
  199.  
  200. $texto='Vehículos '.$fila['VEHICULOS'];
  201. $pdf->Cell(0,10, $texto, 0, 1,'L');
  202.  
  203. $texto='RESUMEN DE LO ACTUADO: '. $fila['RESUMEN'];
  204. $pdf->Cell(0,10,$texto,0,1,'L');
  205.  
  206. $fecha=explode('-',$fila['FECHA_CREACION']);
  207. if($fecha[1]=='01')
  208. $mes='Enero';
  209. else if ($fecha[1]=='02')
  210. $mes='Febrero';
  211. else if ($fecha[1]=='03')
  212. $mes='Marzo';
  213. else if ($fecha[1]=='04')
  214. $mes='Abril';
  215. else if ($fecha[1]=='05')
  216. $mes='Mayo';
  217. else if ($fecha[1]=='06')
  218. $mes='Junio';
  219. else if ($fecha[1]=='07')
  220. $mes='Julio';
  221. else if ($fecha[1]=='08')
  222. $mes='Agosto';
  223. else if ($fecha[1]=='09')
  224. $mes='Septiembre';
  225. else if ($fecha[1]=='10')
  226. $mes='Octubre';
  227. else if ($fecha[1]=='11')
  228. $mes='Noviembre';
  229. else if ($fecha[1]=='12')
  230. $mes='Diciembre';
  231.  
  232. $pdf->SetFont('Times','U',11);
  233. $texto='Salamanca, '.$fecha[2].' de '.$mes.' de '. $fecha[0];
  234. $pdf->Cell(0,8,$texto,0,1,'C');
  235.  
  236.  
  237. $texto='Parte__'.$num_carne.'__'.$fecha[0].'_'.$fecha[1].'_'.$fecha[2].'.pdf';
  238. $pdf->Output($texto,'D');
  239.  
  240. desconectarBBDD($manejador);
__________________
Quim
--------------------------------------------------
Ayudar a ayudar es una buena práctica!!! Y da buenos resultados.

Última edición por quimfv; 19/06/2014 a las 00:48