0
Good afternoon, I swear I’ve searched everywhere, but all I see is teaching to create chat :'(
I am developing a project (corporate TV style) for the company I work, and the project was serving very well until the headquarters liked this project asked to implement in all other units(including the headquarters) and asked for some things "the most" and it is in these things "the most" that brought me this problem of automatically updating.
1. I’m not a professional, I just know the basics and I get by with what I know;
2. As I learned everything on the Internet the project may not be in standard or current form;
3. I learned everything on the Internet;
The project works like this:
- RH inserts the newsletters.
- Displays at index(according to unit). Example: localhost/sicc/general/Rj/Bangu (project/controller/function/parameter)
- Inside the view (which I called slide) shows all the images for that unit, all for the region(function) the images and all the images that serve for all regions and units
I researched several tools that apparently solve my problem, but as I said at the beginning "I only see teaching to create chat", so I came to Sopt to see if I can get some light or path to solving my problem.
Project:
Controller:
public function rj($unidade = null)
{
if (!isset($unidade)) {
redirect('aplicacao');
} else {
if (($unidade === "Caxias") || ($unidade === "caxias")) {
$unidade = "Caxias";
$this->load->view('layouts/inicio_slide');
$this->load->model('slide_model', 'slide');
$dados['todasR'] = $this->slide->todas_unidade($unidade);
$dados['fotos'] = $this->slide->todas_fotos_publicas($unidade);
$this->load->view('slide', $dados);
$this->load->view('layouts/fim_slide');
} elseif (($unidade === "Bangu") || ($unidade === "bangu")) {
$unidade = "Bangu";
$this->load->view('layouts/inicio_slide');
$this->load->model('slide_model', 'slide');
$dados['todasR'] = $this->slide->todas_unidade($unidade);
$dados['fotos'] = $this->slide->todas_fotos_publicas($unidade);
$this->load->view('slide', $dados);
$this->load->view('layouts/fim_slide');
} elseif (($unidade === "grio") || ($unidade === "GRIO")) {
$unidade = "Grande Rio";
$this->load->view('layouts/inicio_slide');
$this->load->model('slide_model', 'slide');
$dados['todasR'] = $this->slide->todas_unidade($unidade);
$dados['fotos'] = $this->slide->todas_fotos_publicas($unidade);
$this->load->view('slide', $dados);
$this->load->view('layouts/fim_slide');
} else {
redirect('aplicacao');
}
}
}
View:
<?php if((count($fotos) === 0) && (count($todasR) === 0)): ?>
<div id="slides">
<div class="slides-container foto-slide">
<img src="<?php echo base_url('assets/images/wallpaper.jpg') ?>" class="foto-slide" >
</div>
</div>
<?php else: ?>
<div id="slides">
<div class="slides-container foto-slide">
<?php foreach($fotos as $foto): ?>
<img src="<?php echo base_url('assets/fotos/'.$foto['foto']) ?>" class="foto-slide" >
<?php endforeach; ?>
<?php if(isset($todasR)): ?>
<?php foreach($todasR as $todaR): ?>
<img src="<?php echo base_url('assets/fotos/'.$todaR['foto']) ?>" class="foto-slide" >
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
Model:
public function busca_regional($id_regional)
{
$resultado = $this->db->select('*')
->where('id_regional', $id_regional)
->get('regionais');
return $resultado->result();
}
public function busca_unidade($unidadeL)
{
$resultado = $this->db->select('*')
->where('unidade', $unidadeL)
->get('unidades');
return $resultado->result();
}
public function busca_unidade_todas($id_regional)
{
$resultado = $this->db->select('*')
->where('id_regional', $id_regional)
->where('unidade', 'Todas')
->get('unidades');
return $resultado->result();
}
public function todas_unidade($unidadeL)
{
$unidade = $this->busca_unidade($unidadeL);
foreach ($unidade as $uni) {
$id_regional_local = $uni->id_regional;
}
$regional = $this->busca_regional($id_regional_local);
foreach ($regional as $reg) {
$id_regional = $reg->id_regional;
}
$toda = $this->busca_unidade_todas($id_regional);
foreach ($toda as $tod) {
$id_unidade = $tod->id_unidade;
}
$resultado = $this->db->select('*')
->from('fotos')
->where('id_regional', $id_regional)
->where('id_unidade', $id_unidade)
->where('publica', true)
->get();
return $resultado->result_array();
}
public function todas_fotos_publicas($unidadeL)
{
$unidade = $this->busca_unidade($unidadeL);
foreach ($unidade as $uni) {
$id_unidade = $uni->id_unidade;
}
$resultado = $this->db->select('*')
->from('fotos')
->where('publica', true)
->where('id_unidade', $id_unidade)
->get();
return $resultado->result_array();
}
I’m sorry if you got confused.
What is the expected result?
– Sr. André Baill
As soon as the person includes the newsletter on the site show automatically in the index
– Daniel Fernando