Beispiel #1
0
 /**
  * Devuelve un array con los agentes que son REPARTIDORES (ROL=2)
  * y están adscritos a la empresa y sucursal indicada.
  * Si el agente en curso es repartidor, solo se mostrará el mismo.
  *
  * @param integer $idEmpresa Opcional
  * @param integer $idSucursal Opcional
  * @return array
  */
 public function getRepartidores($idEmpresa = '', $idSucursal = '')
 {
     $usuario = new Agentes($_SESSION['usuarioPortal']['Id']);
     switch ($usuario->getIDRol()->getIDTipo()) {
         case '2':
             // ROLL REPARTIDOR
             $repartidores[] = array('Id' => $usuario->getIDAgente(), 'Value' => $usuario->getNombre());
             break;
         default:
             // RESTO DE ROLES
             //if ($idEmpresa == '')
             //    $idEmpresa = $_SESSION['emp'];
             if ($idSucursal == '') {
                 $idSucursal = $_SESSION['suc'];
             }
             $usuariosPcae = new PcaeUsuarios();
             $em = new EntityManager($this->getConectionName());
             $link = $em->getDbLink();
             if (is_resource($link)) {
                 $query = "select a.IDAgente as Id, concat(u.Nombre,u.Apellidos) as Value\n                             from \n                                {$this->getDataBaseName()}.{$this->getTableName()} as a,\n                                {$usuariosPcae->getDataBaseName()}.{$usuariosPcae->getTableName()} as u\n                            where\n                            (a.IDAgente <> 1) AND                            \n                            (a.IDAgente = u.Id) AND\n                            (a.IDRol='2') AND\n                            (a.Activo='1') AND (\n                            (a.IDSucursal='{$idSucursal}') OR (a.IDSucursal='0'))";
                 $em->query($query);
                 $repartidores = $em->fetchResult();
                 $em->desConecta();
                 $repartidores[] = array('Id' => '', 'Value' => '** Todos **');
             }
             unset($em);
             break;
     }
     unset($usuario);
     return $repartidores;
 }