Report in CodeIgniter, Foreach problems (Align td with th)

1

I need to generate the table that I show in the image with the headers above.

I have problems when I want to accommodate the operations of the employees according to the headings. Fix my problem with the spaces, the problem is that they do not fit according to the corresponding operation, can you help me please?

It is in this part where I fill the table in the color section:

if(!empty($obtenOperacion)) {
    foreach($obtenOperacion as $fi) { 
        if(!empty($consulta) ) {
            foreach($consulta as $fil) {
                if($fila->cveEmpleado==$fil->cveEmpleado AND $fi->operacion==$fil->operacion AND isset($fil->operacion)){ 
                    echo "<td class='$fil->color'<h4> $fil->operacion</h4> X</td>";
                }
                elseif ($fila->cveEmpleado!=$fil->cveEmpleado AND $fi->operacion==$fil->operacion) {
                    echo "<td>N/A</td>";
                }#cierra else
            }#Cierra consulta 
        }#Cierra if que compara operación
    }#Cierra foreach fi 
}#Cierra if de obtenOperacion 

Here the styles

.azul{
color: #FFFFFF;
background-color: #4B42EC;
font-weight: bold;
}

.azul-marino{
color: #FFFFFF;
background-color: #162D82;
font-weight: bold;
}

.blanco{
color: #000000;
background-color: #FFFFFF;
font-weight: bold;
}

.verde{
color: #FFFFFF;
background-color: #15981D;
font-weight: bold;
}

.amarillo{
color: #000000;
background-color: #F1DB16;
font-weight: bold;
}

.gris{
color: #FFFFFF;
background-color: #6B6B6B;
font-weight: bold;
}

.Marrón{
color: #FFFFFF;
background-color: #663217;
font-weight: bold;
}

.naranja{
color: #FFFFFF;
background-color: #F8751E;
font-weight: bold;
}

.rosa{
color: #000000;
background-color: #F560FA;
font-weight: bold;
}

.morado{
color: #FFFFFF;
background-color: #913EF7;
font-weight: bold;
}

.negro{
color: #FFFFFF;
background-color: #000000;
font-weight: bold;
}

.rojo{
color: #FFFFFF;
background-color: #DC1717;
font-weight: bold;
}

Here where I do the consultations

function consulta($idBloque, $fecha1, $fecha2) {

  $this->db->select("eo.cveEmpleado, eo.idOperacion, o.operacion, b.bloque, c.color, DATEDIFF( NOW( ) , e.fechaIngreso ) diferencia, eo.idEstatus,est.estatus,eo.fechaCertifica");
  $this->db->from('empleado e, estatus est,  color c, bloque b, emp_opera eo, operacion o');
  $this->db->where('eo.idOperacion = o.idOperacion AND est.idEstatus = eo.idEstatus  AND b.idBloque = o.idBloque AND o.idColor = c.idColor AND e.cveEmpleado= eo.cveEmpleado '); 
  $this->db->where('b.idBloque' , $idBloque);
  $this->db->where("eo.fechaCertifica >='$fecha1'");
  $this->db->where("eo.fechaCertifica <='$fecha2'");
  $this->db->group_by('o.operacion,o.idOperacion, eo.cveEmpleado');
  $bloque = $this->db->get();
  return $bloque->result();
}
function obtenOperacion($idBloque) {

  $this->db->select('o.idOperacion,o.operacion,o.idBloque,b.bloque, b.idArea, a.area, c.color, o.idColor');
  $this->db->from('operacion o, area a, color c, emp_opera eo, bloque b');
  $this->db->where('o.idBloque = b.idBloque and b.idArea = a.idArea and o.idColor=c.idColor');
  $this->db->where('o.idBloque', $idBloque);
  $this->db->group_by('o.idOperacion');
  $operacion = $this->db->get();
  return $operacion->result();
}

    
asked by Gaby Hdz 15.12.2016 в 18:22
source

1 answer

0

Here is the solution to my problem: In the controller should put this and filter the query by employee and operation to consequently print a value that would be compared according to the operation that launched, as previously sent all the data in the query, and repeated.

 <?php  
          if(!empty($obtenOperacion)) {
           foreach($obtenOperacion as $fi) { 
            $this->load->model('Reportes_model');
            $fil=$this->Reportes_model->consulta($fila->idBloque, $fecha1, $fecha2, $fila->cveEmpleado, $fi->idOperacion);
            if(!empty($fil))
            {

             foreach($fil as $fil) 
             {

               if($fi->idOperacion==$fil->idOperacion)
               { 

                echo "<td class='$fil->color'><h4> $fil->operacion</h4> X</td>";        
                }#cierra else                
           }#Cierra consulta 
         }
         else
         {

          echo "<td>N/A</td>";
          }#Cierra if que compara operación
        }#Cierra foreach fi 
    }#Cierra if de obtenOperacion 
} #cierre de foreach fila
} #Cierre if consulta ?>
    
answered by 18.01.2017 / 15:13
source