Guest User

cotizador PDF

a guest
Oct 23rd, 2017
1,307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. <?php
  2. /*-------------------------
  3. Autor: Obed Alvarado
  4. Web: obedalvarado.pw
  5. ---------------------------*/
  6. ob_start();
  7. session_start();
  8. /* Connect To Database*/
  9. include("../../config/db.php");
  10. include("../../config/conexion.php");
  11. $session_id= session_id();
  12. $sql_count=mysqli_query($con,"select * from tmp_cotizacion where session_id='".$session_id."'");
  13. $count=mysqli_num_rows($sql_count);
  14. if ($count==0)
  15. {
  16. echo "<script>alert('No hay productos agregados a la cotizacion')</script>";
  17. echo "<script>window.close();</script>";
  18. exit;
  19. }
  20.  
  21. require_once(dirname(__FILE__).'/../html2pdf.class.php');
  22.  
  23. //Variables por GET
  24. $atencion=$_GET['atencion'];
  25. $tel1=$_GET['tel1'];
  26. $empresa=$_GET['empresa'];
  27. $tel2=$_GET['tel2'];
  28. $email=$_GET['email'];
  29. $condiciones=$_GET['condiciones'];
  30. $validez=$_GET['validez'];
  31. $entrega=$_GET['entrega'];
  32. //Fin de variables por GET
  33. $sql_cotizacion=mysqli_query($con, "select LAST_INSERT_ID(numero_cotizacion) as last from cotizaciones_demo order by id_cotizacion desc limit 0,1 ");
  34. $rwC=mysqli_fetch_array($sql_cotizacion);
  35. $numero_cotizacion=$rwC['last']+1;
  36. // get the HTML
  37.  
  38. include(dirname('__FILE__').'/res/cotizacion_html.php');
  39. $content = ob_get_clean();
  40.  
  41. try
  42. {
  43. // init HTML2PDF
  44. $html2pdf = new HTML2PDF('P', 'LETTER', 'es', true, 'UTF-8', array(0, 0, 0, 0));
  45. // display the full page
  46. $html2pdf->pdf->SetDisplayMode('fullpage');
  47. // convert
  48. $html2pdf->writeHTML($content, isset($_GET['vuehtml']));
  49. // send the PDF
  50. ob_end_clean();
  51. $html2pdf->Output('Cotizacion.pdf');
  52. }
  53. catch(HTML2PDF_exception $e) {
  54. echo $e;
  55. exit;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment