I am creating an application for vehicle control with codeigniter 3.0. The SQL query I do is the following:
MODEL
private function dataParaProcedimiento($criteria){
$this->db->select( T_PADRON_NOMBRES ." as nombres,".
T_PADRON_APELLIDO_PATERNO ." as apellido_paterno,".
T_TIPO_IDENTIFICACION_F_DESCRIPCION ." as tipo_identificacion,".
T_PADRON_DOCUMENTO ." as numero_identificacion,".
T_VEHICULOS_F_MARCA ." as marca,".
T_VEHICULOS_F_MODELO ." as modelo,".
T_VEHICULOS_F_PATENTE ." as patente,".
T_OBLEA_F_CODIGO ." as codigo,")
->from(T_PADRON)
->from(T_VEHICULOS)
->join(T_OBLEA, T_OBLEA_F_ID_VEHICULO." = ".T_VEHICULOS_F_ID_VEHICULO)
->join(T_TIPO_IDENTIFICACION, T_TIPO_IDENTIFICACION_F_ID_TIPO_IDENTIFICACION." = ".T_PADRON_TIPO_DOCUMENTO)
->join(T_PADRON_OBLEA, T_PADRON_OBLEA_F_ID_PADRON." = ".T_PADRON_ID_PADRON)
->where(T_PADRON_OBLEA_F_ID_PADRON." = ".T_PADRON_ID_PADRON)
->where(T_PADRON_OBLEA_F_ID_OBLEA." = ".T_OBLEA_F_ID_OBLEA)
->order_by(T_PADRON_APELLIDO_PATERNO,"ASC");
if($criteria){
$this->db->like(T_PADRON_NOMBRES,$criteria)
->or_like(T_PADRON_APELLIDO_PATERNO, $criteria)
->or_like(T_PADRON_APELLIDO_MATERNO, $criteria);
}
}
VIEW
In the view I have only one inputbox ( $criteria
) to perform the search.
JavaScript
<script>
$(document).ready(function(){
$("#buttonBusqueda").click( function(){
var inputBusqueda = $('#inputBusqueda').val();
var selectedBusqueda = $('#select_busqueda').val();
var url = "<?=base_url('index.php/principal/buscarPersonaParaProcedimiento')?>";
var params = "/"+selectedBusqueda+"/"+inputBusqueda
var winParams="toolbar=no,scrollbars=yes,resizable=yes,top=100,left=100,height=400";
window.open(url+params,"Pop Up",winParams);
});
$('#popup_values').change( function() {
var arr = JSON.parse($(this).val());
$('#id_entity').val(arr[0].value);
$('#entity').val($('#select_busqueda').val());
$('#label_data').text('Datos Asociados:');
var contentDtDd = $('#selected_data');
contentDtDd.html('');
$.each(arr, function (index, item) {
contentDtDd.append('<dt>'+item.title+'</dt>');
contentDtDd.append('<dd>'+item.value+'</dd>');
});
});
Code to assemble the table
<?php
$this->load->view('comun/popup_header');
$html_table_rows = "";
foreach ($list as $item):
$html_table_rows.="<tr><td title='Usuario:'>".$item['apellido_paterno']." ".$item['apellido_materno']." ".$item['nombres']."</td>";
$html_table_rows.="<td title='Tipo y Nro. de Doc.:'>".$item['tipo_identificacion']." ".$item['numero_identificacion']."</td>";
$html_table_rows.="<td title='Vehiculo:'>".$item['marca']." ".$item['modelo']." ".$item['patente']."</td>";
$html_table_rows.="<td title='Oblea Nº'>".$item['codigo']."</td></tr>";
endforeach; ?>
HTML
<div id="content" style="height: auto;" >
<div class="jumbotron" style="height: 33px;padding-top: 10px; padding-bottom: 45px;">
<h2 style="margin-top: 0px; text-align: center">Elegir Persona</h2>
</div>
<div class="form-group">
<div class="col-lg-12">
<table class="table table-borderer">
<thead>
<th>Usuario</th>
<th>Tipo y Nro. de Doc.</th>
<th>Vehiculo</th>
<th>Oblea Nº</th>
</thead>
<tbody id="rows-selectable">
<?=$html_table_rows?>
</tbody>
</table>
</div>
</div>
</div>
RESULT
When I search by name ( $criteria
), it shows me the result of the search:
PROBLEM
The problem occurs when I search by last name, which shows me the following:
When it should show me as the previous result.
Thank you!