I have the following query that currently brings me 2 rows that later that table will be filled more...
// Acá estamos en el modelo...
public function GetLocales() {
$query = 'SELECT loc.codigo_contable, emp.razon_social, loc.codigo, loc.nombre, evem.fecha_comprobacion, ';
$query .= 'IF(evem.glosa="","NO APLICA", evem.glosa) AS glosa, evem.codigoevento ';
$query .= 'FROM eltit_dte_manager.clientes_locales AS loc ';
$query .= 'INNER JOIN eltit_dte_manager.clientes_dte AS emp ';
$query .= 'ON (loc.codigo_contable = emp.codigo_contable) ';
$query .= 'INNER JOIN eltit_auditoria.dte_eventos_empresas AS evem ';
$query .= 'ON (loc.codigo = evem.local) ';
$query .= 'WHERE loc.mostrar_monitor_acuse = "1" ';
$rpta = $this->db->query($query);
if ($rpta->num_rows() > 0) {
return $rpta->result();
} else {
return "0";
}
}
I capture this in the controller that this is where I need to add more fields to it "key => value" and I have tried several ways, 2 of them are the following foreach
// Aquí estamos en el controlador...
public function getlocales() {
$locales = $this->Auditoria->GetLocales();
$arrColumnas = array('','','','','','','','','','','','','');
$arrLocales = array();
$i = 0;
$local = new stdClass;
foreach ($locales as $dato) {
$arrLocales = array(
$local[$i]->codigo_contable = $dato->codigo_contable,
$local[$i]->razon_social = $dato->razon_social,
$local[$i]->codigo = $dato->codigo,
$local[$i]->nombre = $dato->nombre,
$local[$i]->fecha_comprobacion = $dato->fecha_comprobacion,
$local[$i]->codigo_evento = $dato->codigoevento,
$local[$i]->col1 = "ROJO",
$local[$i]->col2 = "ROJO",
$local[$i]->col3 = "ROJO",
$local[$i]->col4 = "ROJO",
$local[$i]->col5 = "ROJO",
$local[$i]->col6 = "ROJO",
$local[$i]->col7 = "ROJO",
$local[$i]->col8 = "ROJO",
$local[$i]->col9 = "ROJO",
$local[$i]->col10 = "ROJO",
$local[$i]->col11 = "ROJO",
$local[$i]->col12 = "ROJO",
$local[$i]->col13 = "ROJO"
);
$i++;
}
/*
foreach($locales as $dato) {
$arrLocales = array(
"codigo_contable" => $dato->codigo_contable,
"razon_social" => $dato->razon_social,
"codigo" => $dato->codigo,
"nombre" => $dato->nombre,
"fecha_comprobacion" => $dato->fecha_comprobacion,
"codigo_evento" => $dato->codigoevento,
"col1" => "ROJO",
"col2" => "ROJO",
"col3" => "ROJO",
"col4" => "ROJO",
"col5" => "ROJO",
"col6" => "ROJO",
"col7" => "ROJO",
"col8" => "ROJO",
"col9" => "ROJO",
"col10" => "ROJO",
"col11" => "ROJO",
"col12" => "ROJO",
"col13" => "ROJO"
);
}
*/
$locales = $arrLocales;
echo json_encode($locales);
}
And my problem is that in these ways it only returns an object that is the last one that goes through the foreach... How could I store these objects in an array and return it to go through it in the Ajax call? My question is only what should I do in the controller, how to show it with Ajax is not difficult for me