Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function show_search_form()
- {
- $output .= '
- <form class="form" action="crearcotizacion.php?action=por_descripcion" onsubmit="return llenartabla_por_desc();" method="post">
- <div class="form-body">
- <div class="form-group">
- <label for="descripcion">Inserte Descripci贸n O Palabra Clave:</label>
- <input type="text" id="descripcion" class="form-control"
- placeholder="Descripci贸n" name="descripcion" autocomplete="off">
- </div>
- <button type="submit" class="btn btn-primary btn-block">
- <i class="icon-search"></i> Buscar
- </button>
- </div>
- </form>
- ';
- return $output;
- }
- public function select_by_descripcion()
- {
- $query = "SELECT * from listado_general_01
- where Descripcion LIKE '%". $this->postData['descripcion']."%';";
- //$params_query = array();
- if($rs = $this->sql->select($query, array()))
- {
- return $rs;
- }
- else
- {
- return false;
- }
- }
- public function show_table_results_descripcion()
- {
- $output .= '
- <div class="table-responsive" style="max-height:400px;" id="areaImprimir">
- <div class="card-block">
- <p>Resultados Totales: <strong>';
- foreach ($this->count_by_descripcion() as $value)
- {
- $output .= $value['total_result'];
- }
- $output .= '
- </strong>
- </p>
- </div>
- <table class="table table-bordered table-hover mb-0 thead-inverse" id="tabla">
- <thead>
- <tr>
- <th># Parte</th>
- <th>Descripci贸n</th>
- <th>Precio</th>
- </tr>
- </thead>
- <tbody>
- </tbody>
- </table>
- </div>
- ';
- $output .= '
- <script>
- var datos = [';
- foreach ($this->select_by_descripcion() as $value)
- {
- $output .= '
- '.(json_encode($value)).'
- ';
- }
- $output .= '
- ];
- </script>';
- return $output;
- }
- function llenartabla_por_desc(datos) {
- event.preventDefault();
- var descripcion = document.getElementById('descripcion').value;
- var data_send = 'descripcion='+descripcion;
- event.preventDefault();
- $.ajax({
- url: '?action=por_descripcion',
- type: 'POST',
- data: data_send,
- success:function(resp){
- var d = '<tr>'+
- '<th># Parte</th>'+
- '<th>Descripci贸n</th>'+
- '<th>Precio</th>'+
- '</tr>';
- for (var i = 1; i < datos.length; i++)
- {
- d+= '<tr>'+
- '<td>'+datos[i].id+'</td>'+
- '<td>'+datos[i].Descripcion+'</td>'+
- '<td>'+datos[i].Precio+'</td>'+
- '</tr>';
- }
- $("#tabla").append(d);
- }
- })
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement