/php/exportar_informe_compras_del_dia_detalle.php

https://github.com/cabenitez/factuweb · PHP · 123 lines · 97 code · 18 blank · 8 comment · 3 complexity · ac127a15790fe9bdbc070bf5f445bb0e MD5 · raw file

  1. <?
  2. //---------------------- Titulo del listado-------------------------------------------------//
  3. $ano = substr($fecha_buscar,0,4);
  4. $mes = substr($fecha_buscar,4,2);
  5. $dia = substr($fecha_buscar,-2);
  6. $fecha_titulo = "$dia/$mes/$ano"; // maqueta la fecha para imprimir
  7. $titulo = "COMPRAS DEL DIA $fecha_titulo - DETALLE POR PROVEEDOR";
  8. //---------------------- INCLUYE CONFIGURACION DE PDF --------------------------------------//
  9. include("conf_listados.php");
  10. if($fecha_buscar){
  11. //---------------------- INCLUYE CONEXION A BD -----------------------------------------------//
  12. include("conexion.php");
  13. // Obtiene el detalle de todos los comprobantes Factura Vta Cliente
  14. $consulta ="select cod_proveedor, SUM(round(subtotal,2)), SUM(round(iva_monto,2)), SUM(round($factura_compra_otros_impuestos,2)), SUM(round(total,2)), n_factura, n_sucursal, fecha_reg, observacion, usuario, id_deposito
  15. from factura_compra
  16. where fecha_fact = $fecha_buscar and cod_proveedor = $cod_proveedor
  17. group by n_factura, n_sucursal";
  18. $result = mysql_query($consulta); // hace la consulta
  19. $registro = mysql_fetch_row($result); // toma el registro
  20. $nfilas = mysql_num_rows ($result); //indica la cantidad de resultados
  21. if($nfilas > 0){
  22. //----------------------------------- PDF --------------------------------------------------------------------------------------------//
  23. $cod_proveedor=$registro[0];
  24. $consulta2 = "SELECT razon_social FROM proveedor where cod_proveedor = $cod_proveedor"; // consulta sql
  25. $result2 = mysql_query($consulta2); // hace la consulta
  26. $registro2 = mysql_fetch_row($result2); // toma el registro
  27. $proveedor = $registro2[0];
  28. $pdf->SetFont('Arial','B',8);
  29. $pdf->Cell(1,3, $proveedor,0,1);
  30. //---------------------- creo los titulos de las columnas-----------------------------------//
  31. $pdf->SetFont('Arial','',8);
  32. $pdf->Cell(6,8,'COMPROBANTE');
  33. $pdf->SetX(35);
  34. $pdf->Cell(10,8,'FECHA REG.');
  35. $pdf->SetX(70);
  36. $pdf->Cell(10,8,'USUARIO');
  37. $pdf->SetX(100);
  38. $pdf->Cell(10,8,'OBSERVACION');
  39. $pdf->SetX(135);
  40. $pdf->Cell(10,8,'TOTAL SIN IMP.');
  41. $pdf->SetX(165);
  42. $pdf->Cell(10,8,'IVA');
  43. $pdf->SetX(175);
  44. $pdf->Cell(10,8,'OTROS IMP.');
  45. $pdf->SetX(195);
  46. $pdf->Cell(10,8,'TOTAL');
  47. //---------------------- creo la linea -----------------------------------------------------//
  48. $pdf->Line(7,34,205,34); // linea
  49. $pdf->Ln(7); //Salto de línea
  50. $pdf->SetFont('Arial','',7);
  51. do{ // obtengo los resultados
  52. $total_sin_imp=$registro[1];
  53. $total_iva=$registro[2];
  54. $total_otros_imp=$registro[3];
  55. $total_factura=$registro[4];
  56. $n_fact=$registro[5];
  57. $suc=$registro[6];
  58. $fecha_reg=$registro[7];
  59. $fecha_reg = substr($fecha_reg,6,2)."/".substr($fecha_reg,4,2)."/".substr($fecha_reg,0,4);
  60. $observacion=$registro[8];
  61. $usuario=$registro[9];
  62. $id_deposito=$registro[10];
  63. $total_carga_sin_imp= $total_carga_sin_imp + $total_sin_imp;
  64. $total_carga_iva = $total_carga_iva + $total_iva;
  65. $total_carga_otros_imp= $total_carga_otros_imp + $total_otros_imp;
  66. $total_carga_factura =$total_carga_factura + $total_factura;
  67. $pdf->Cell(1,3,$suc.' '.$n_fact,0,0);
  68. $pdf->SetX(35);
  69. $pdf->Cell(1,3,$fecha_reg,0,0);
  70. $pdf->SetX(70);
  71. $pdf->Cell(1,3,$usuario,0,0);
  72. $pdf->SetX(100);
  73. $pdf->Cell(1,3,$obs,0,0);
  74. $pdf->SetX(-60);
  75. $pdf->Cell(1,3,$total_sin_imp,0,0,'R');
  76. $pdf->SetX(-38);
  77. $pdf->Cell(1,3,$total_iva,0,0,'R');
  78. $pdf->SetX(-25);
  79. $pdf->Cell(1,3,$total_otros_imp,0,0,'R');
  80. $pdf->SetX(-7);
  81. $pdf->Cell(1,3,$total_factura,0,1,'R');
  82. }while($registro = mysql_fetch_array($result)); //end while
  83. //---------------------- creo el resumen de total de filas------------------------------//
  84. $pdf->SetFont('Arial','',10);
  85. $pdf->Cell(0,0,"_____________________________________________________________________________________________________",0,0,'L');
  86. $pdf->Ln(3); //Salto de línea
  87. $pdf->SetFont('Arial','',8);
  88. $pdf->SetX(6);
  89. $pdf->Cell(0,3,'TOTALES',0,0);
  90. $pdf->SetX(-60);
  91. $pdf->Cell(1,3,number_format($total_carga_sin_imp,2,'.',''),0,0,'R');
  92. $pdf->SetX(-38);
  93. $pdf->Cell(1,3,number_format($total_carga_iva,2,'.',''),0,0,'R');
  94. $pdf->SetX(-25);
  95. $pdf->Cell(1,3,number_format($total_carga_otros_imp,2,'.',''),0,0,'R');
  96. $pdf->SetX(-7);
  97. $pdf->Cell(1,3,number_format($total_carga_factura,2,'.',''),0,1,'R');
  98. }
  99. if(empty($destino)){
  100. $pdf->Output(); // muestra en pantalla
  101. }else{
  102. $pdf->Output('pdf/'.$usuario_sesion.'.pdf','F'); // guarda en el server
  103. }
  104. } // FIN DE if($fecha_buscar){
  105. ?>