Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. public function show_search_form()
  2. {
  3. $output .= '
  4. <form class="form" action="crearcotizacion.php?action=por_descripcion" onsubmit="return llenartabla_por_desc();" method="post">
  5. <div class="form-body">
  6.  
  7. <div class="form-group">
  8. <label for="descripcion">Inserte Descripci贸n O Palabra Clave:</label>
  9. <input type="text" id="descripcion" class="form-control"
  10. placeholder="Descripci贸n" name="descripcion" autocomplete="off">
  11. </div>
  12.  
  13. <button type="submit" class="btn btn-primary btn-block">
  14. <i class="icon-search"></i> Buscar
  15. </button>
  16.  
  17. </div>
  18. </form>
  19. ';
  20. return $output;
  21. }
  22.  
  23. public function select_by_descripcion()
  24. {
  25. $query = "SELECT * from listado_general_01
  26. where Descripcion LIKE '%". $this->postData['descripcion']."%';";
  27.  
  28. //$params_query = array();
  29.  
  30. if($rs = $this->sql->select($query, array()))
  31. {
  32. return $rs;
  33. }
  34. else
  35. {
  36. return false;
  37. }
  38. }
  39.  
  40. public function show_table_results_descripcion()
  41. {
  42. $output .= '
  43. <div class="table-responsive" style="max-height:400px;" id="areaImprimir">
  44. <div class="card-block">
  45. <p>Resultados Totales: <strong>';
  46. foreach ($this->count_by_descripcion() as $value)
  47. {
  48. $output .= $value['total_result'];
  49. }
  50. $output .= '
  51. </strong>
  52. </p>
  53. </div>
  54.  
  55.  
  56. <table class="table table-bordered table-hover mb-0 thead-inverse" id="tabla">
  57. <thead>
  58. <tr>
  59. <th># Parte</th>
  60. <th>Descripci贸n</th>
  61. <th>Precio</th>
  62. </tr>
  63. </thead>
  64. <tbody>
  65.  
  66. </tbody>
  67. </table>
  68. </div>
  69. ';
  70. $output .= '
  71. <script>
  72. var datos = [';
  73. foreach ($this->select_by_descripcion() as $value)
  74. {
  75. $output .= '
  76. '.(json_encode($value)).'
  77. ';
  78. }
  79. $output .= '
  80. ];
  81. </script>';
  82. return $output;
  83. }
  84.  
  85. function llenartabla_por_desc(datos) {
  86. event.preventDefault();
  87. var descripcion = document.getElementById('descripcion').value;
  88.  
  89. var data_send = 'descripcion='+descripcion;
  90.  
  91. event.preventDefault();
  92. $.ajax({
  93. url: '?action=por_descripcion',
  94. type: 'POST',
  95. data: data_send,
  96. success:function(resp){
  97. var d = '<tr>'+
  98. '<th># Parte</th>'+
  99. '<th>Descripci贸n</th>'+
  100. '<th>Precio</th>'+
  101. '</tr>';
  102.  
  103. for (var i = 1; i < datos.length; i++)
  104. {
  105. d+= '<tr>'+
  106. '<td>'+datos[i].id+'</td>'+
  107. '<td>'+datos[i].Descripcion+'</td>'+
  108. '<td>'+datos[i].Precio+'</td>'+
  109. '</tr>';
  110. }
  111. $("#tabla").append(d);
  112. }
  113. })
  114. return false;
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement