PageRenderTime 41ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/controllers/consultar_factura_con.php

https://bitbucket.org/osmary/gestioninventario
PHP | 124 lines | 108 code | 13 blank | 3 comment | 2 complexity | 6001cc63ccd71d7f5c162be5a8b8a020 MD5 | raw file
  1. <?php
  2. if (!defined('BASEPATH'))
  3. exit('No direct script access allowed');
  4. class consultar_factura_con extends CI_Controller {
  5. var $modulos = '';
  6. function __construct() {
  7. parent::__construct();
  8. $this->load->model('Utilidades_db_mod');
  9. $this->load->helper('url');
  10. $this->load->library('funciones');
  11. $this->load->library('Pdf');
  12. $this->load->helper('form', 'url');
  13. $this->load->helper('js_css');
  14. $this->cargar_config();
  15. $this->funciones->verifica_sesion($this->Utilidades_db_mod->ambiente[0], FRONTEND, $this->modulos);
  16. }
  17. private function cargar_config() {
  18. //Parametros comunes en todos los metodos
  19. $this->data['ambiente'] = $this->Utilidades_db_mod->ambiente[1];
  20. $this->data['titulo_pagina'] = $this->config->item('nombre_sistema');
  21. $this->data['contenido'] = 'login_view';
  22. $this->data['mensaje'] = '';
  23. $this->data['ruta_js'] = $this->config->item('ruta_js');
  24. $this->data['ruta_css'] = $this->config->item('ruta_css');
  25. $this->data['ruta_js_sist'] = $this->config->item('ruta_js_sist');
  26. $this->data['ruta_css_sist'] = $this->config->item('ruta_css_sist');
  27. $this->data['css_sist'] = array('contenido.css', 'top_view.css', 'principal_view.css');
  28. $this->data['js_sist'] = array('top_view.js', 'consultar_factura_view.js');
  29. $this->data['salir'] = $this->config->item('logoff');
  30. $this->data['nombre_usuario'] = '';
  31. }
  32. function index() {
  33. $this->data['mostrar_cintillo'] = true;
  34. $this->data['mostrar_menu'] = 'principal';
  35. $this->data['menu_activo'] = '';
  36. if ($this->data['mostrar_menu']) {
  37. $this->load->model('Top_mod');
  38. $json_menu = json_decode($this->Top_mod->traer_menu());
  39. $menu_depurado[$this->data['mostrar_menu']] = $this->funciones->configurar_menu($json_menu, $this->data['mostrar_menu']);
  40. $this->data['menu_todos'] = json_encode($menu_depurado);
  41. }
  42. $this->data['title'] = "Pagina Principal";
  43. $this->data['contenido'] = 'consultar_factura_view';
  44. $this->data['mensaje'] = '';
  45. $this->data['nombre_usuario'] = $_SESSION['login'];
  46. $this->load->view('plantillas/plantilla_view', $this->data);
  47. }
  48. public function __destruct() {
  49. $this->Utilidades_db_mod = null;
  50. $this->data = null;
  51. }
  52. public function tabla_listar_facturas() {
  53. $parametros = $this->input->post();
  54. $this->load->model('consultar_factura_mod');
  55. $this->data['datos_tmp'] = $this->consultar_factura_mod->mostrar_factura($parametros);
  56. $this->load->view('paginas/datos_tmp', $this->data);
  57. }
  58. public function seleccionar_proveedores() {
  59. $parametros = $this->input->post();
  60. $this->load->model('consultar_factura_mod');
  61. $this->data['datos_tmp'] = $this->consultar_factura_mod->seleccionar_proveedor($parametros);
  62. $this->load->view('paginas/datos_tmp', $this->data);
  63. }
  64. public function generar_reporte() {
  65. $parametros = $this->input->post();
  66. $this->load->model('consultar_factura_mod');
  67. ////creamos el PDF
  68. $this->pdf = new Pdf();
  69. $this->pdf->AddPage();
  70. $this->pdf->AliasNbPages();
  71. $this->pdf->SetTitle('FACTURA DE INVENTARIO');
  72. $this->pdf->SetFillColor(52, 152, 219);
  73. $this->pdf->SetFont('Arial', 'B', 12);
  74. $this->pdf->Cell(200, 10, 'FACTURA DE INVENTARIO', 0, 0, 'C');
  75. $this->pdf->SetFont('Arial', 'B', 8);
  76. //////Titulos de las columnas//////////
  77. $this->pdf->SetXY(7, 50);
  78. $this->pdf->Cell(15, 10, utf8_decode('N° FACT'), 1, 0, 'C', 1);
  79. $this->pdf->Cell(20, 10, 'NOMBRE', 1, 0, 'C', 1);
  80. $this->pdf->Cell(15, 10, 'RIF', 1, 0, 'C', 1);
  81. $this->pdf->Cell(30, 10, 'DIRECCION', 1, 0, 'C', 1);
  82. $this->pdf->Cell(20, 10, 'TELEFONO', 1, 0, 'C', 1);
  83. $this->pdf->Cell(40, 10, 'RUBRO', 1, 0, 'C', 1);
  84. $this->pdf->Cell(17, 10, 'CANTIDAD', 1, 0, 'C', 1);
  85. $this->pdf->Cell(12, 10, 'PRECIO', 1, 0, 'C', 1);
  86. $this->pdf->Cell(15, 10, 'TOTAL', 1, 0, 'C', 1);
  87. $this->pdf->Cell(15, 10, 'FECHA', 1, 0, 'C', 1);
  88. $this->pdf->Ln(10);
  89. $datos = $this->consultar_factura_mod->generar_reporte($parametros);
  90. foreach ($datos as $dato) {
  91. $this->pdf->SetX(7);
  92. $this->pdf->SetFont('Arial', '', 7 );
  93. $this->pdf->Cell(15, 5, $dato->num_factura, 1, 0, 'C', 0);
  94. $this->pdf->Cell(20, 5, utf8_decode($dato->nombre), 1, 0, 'L', 0);
  95. $this->pdf->Cell(15, 5, utf8_decode($dato->rif), 1, 0, 'L', 0);
  96. $this->pdf->Cell(30, 5, utf8_decode($dato->direccion), 1, 0, 'L', 0);
  97. $this->pdf->Cell(20, 5, $dato->telefono, 1, 0, 'L', 0);
  98. $this->pdf->Cell(40, 5, utf8_decode($dato->rubro), 1, 0, 'L', 0);
  99. $this->pdf->Cell(17, 5, $dato->cantidad, 1, 0, 'C', 0);
  100. $this->pdf->Cell(12, 5, $dato->preciounitario, 1, 0, 'C', 0);
  101. $this->pdf->Cell(15, 5, $dato->total, 1, 0, 'C', 0);
  102. $this->pdf->Cell(15, 5, $dato->fecha_recibido, 1, 0, 'C', 0);
  103. $this->pdf->Ln();
  104. }
  105. $pdfString = $this->pdf->Output("Reporte.pdf", 'S');
  106. $pdfBase64 = base64_encode($pdfString);
  107. $this->data['datos_tmp'] = 'data:application/pdf;base64,' . $pdfBase64;
  108. $this->load->view('paginas/datos_tmp', $this->data);
  109. }
  110. }
  111. ?>