<?php

include_once 'Clases/Oficina.php';
$oficina = new Oficina();
//Obtener el id_rep
$emailRep = $_SESSION['login_user'];
$result = $rep->obtenerPorEmail($emailRep);
$result2 = $result->fetch_array(MYSQLI_ASSOC);
//Aqui se guarda el id del representante
$id_repOfi = $result2['id_rep'];
// se guarda en una variable el resultado de la consulta
// de las oficinas registradas a las que representa
$result = $oficina->obtenerOficinasRep($id_repOfi);
?>


                    <label>Oficina a Representar</label>
                    <select class="form-control" name="oficina" width="25px" required>
                             <option value="0">-- --</option>

                         <?php 
while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
    ?>
               
                            <option value="<?php 
    echo $row['oficina_id'];
    ?>
"><?php 
    echo $row['nom_oficina'];
    ?>
</option>
          
<!--          Se valida el tipo de usuario para mostrar el numero de oficinas totales (vista de administrador)-->
         <?php 
if ($tipo2['login_tipo'] == 0) {
    //Obtener el total de oficinas registradas
    $totOficinas = $oficina->obtenerOficinas();
    $totOficinas = mysqli_num_rows($totOficinas);
}
?>
<!--         Termina validacion para mostrar el total de oficinas registradas (vista de administrador)-->
         
         <!--          Se valida el tipo de usuario para mostrar el numero de oficinas totales (vista de Gerente)-->
         <?php 
if ($tipo2['login_tipo'] == 1) {
    //Obtener el total de oficinas registradas
    $totOficinas = $oficina->obtenerOficinasRep($repId);
    $totOficinas = mysqli_num_rows($totOficinas);
}
?>
         <!--         Termina validacion para mostrar el total de oficinas registradas (vista de Gerente)-->
         
          <span class="value green"><?php 
echo $totOficinas;
?>
</span>
          <span class="headline">Total de oficinas que soy manager</span>
          </div>

        </div>

      </div>