Hello to the whole stackoverflow community, my respects for this site is undoubtedly full of geniuses and I hope you can help me: / ...
The issue here is that I have to make a report of how many people were cited by campaign from the first of the month until today, that I was doing manually, each adding a new campaign I manually added another function in the model looking for those cited with respect to the new campaign ... but I want to optimize the time, making a function that facilitates all this ...
I will explain how I have structured my code:
In my controller I have this:
$Nombres_campañas = $this->realreporteo->Nombres_campañas(); //Con esto obtengo los nombres de las campañas que existen.
if($Nombres_campañas != FALSE)
{
$result = array();
foreach($Nombres_campañas as $row)
{
$info = $row->empresa;
$result[] = $this->realreporteo->Formula_numeros_citados($info);
}
$data['resultados'] = $result;
}
$this->load->view('headers/librerias');
$this->load->view('headers/menu-admin');
$this->load->view('reporteo', $data);
In my model I have the functions like this
function Nombres_campañas() // Este es para sacar los nombres de las campañas
{
$this -> db -> select('empresa,fechaent');
$this -> db -> from($this->TableReporteo);
$this -> db -> where('fechaent >= ', strtotime(date('1-m-Y')), TRUE);
$this -> db -> where('fechaent <= ', strtotime(date('d-m-Y')), TRUE);
$this->db->group_by('empresa');
$query = $this->db->get();
$row = $query->result();
return $row;
}
This is my function that should take the count
function Formula_numeros_citados($info)
{
$this -> db -> select('empresa,fechaent,estatus');
$this -> db -> from($this->TableReporteo);
$this -> db -> where('estatus','Citado');
$this -> db -> where('empresa',$info);
$query = $this->db->get();
$row = $query->row();
return $row;
}
And I want it to be able to print in my view on a table with a foreach
foreach($resultados as $value)
{
echo
'
<tr>
<td>'.$value->empresa.'</td>
<td>'.count().'</td>
</tr>
';
}
My database is called reporting and has basic varchar type fields "name, company, date, campaign, status, telephone, etc etc ..."
Currently the code that I showed you throws a result like this in my view: If you throw me the names of the campaigns but the count does me wrong: (
I would very much appreciate if you could help me: /