Example #1
0
 /**
  * Retorna os grupos folhas que ainda não foram relacionados àlguma unidade
  * @param Novosga\Model\Unidade $atual
  */
 private function getGruposFolhasDisponiveis(Unidade $atual = null)
 {
     // grupos disponíveis
     $query = $this->em()->createQuery("\r\n            SELECT \r\n                e \r\n            FROM \r\n                Novosga\\Model\\Grupo e \r\n            WHERE \r\n                e.right = e.left + 1 AND\r\n                e NOT IN (\r\n                    SELECT g FROM Novosga\\Model\\Unidade u JOIN u.grupo g WHERE u.id != :id\r\n                )\r\n        ");
     // se estiver editando, deve trazer o grupo da unidade atual tambem
     $id = $atual ? $atual->getId() : 0;
     $query->setParameter('id', $id);
     return $query->getResult();
 }
Example #2
0
 /**
  * 
  * @param string $name
  * @param string $description
  * @param integer $weight
  * @return Grupo
  */
 public function create($name, $message, Grupo $grupo)
 {
     $unidade = new Unidade();
     $unidade->setCodigo('1');
     $unidade->setNome($name);
     $unidade->setGrupo($grupo);
     $unidade->setMensagemImpressao($message);
     $unidade->setStatus(1);
     $unidade->setStatusImpressao(1);
     return $unidade;
 }
 public function buscaAtendimentos(Unidade $unidade, $senha)
 {
     $field = self::isNumeracaoServico() ? 'numeroSenhaServico' : 'numeroSenha';
     $cond = '';
     $sigla = strtoupper(substr($senha, 0, 1));
     // verificando se a letra foi informada (o primeiro caracter diferente do valor convertido para int)
     $porSigla = ctype_alpha($sigla);
     if ($porSigla) {
         $cond = 'e.siglaSenha = :sigla AND';
         $numeroSenha = (int) substr($senha, 1);
     } else {
         $numeroSenha = (int) $senha;
     }
     $query = $this->em->createQuery("\n            SELECT\n                e\n            FROM\n                Novosga\\Model\\Atendimento e\n                JOIN e.servicoUnidade su\n                JOIN su.servico s\n                JOIN e.usuarioTriagem ut\n                LEFT JOIN e.usuario u\n            WHERE\n                e.{$field} = :numero AND {$cond}\n                su.unidade = :unidade\n            ORDER BY\n                e.id\n        ");
     $query->setParameter('numero', $numeroSenha);
     if ($porSigla) {
         $query->setParameter('sigla', $sigla);
     }
     $query->setParameter('unidade', $unidade->getId());
     return $query->getResult();
 }
Example #4
0
 private function getAtendimento(Unidade $unidade, $id)
 {
     $atendimento = $this->em()->find('Novosga\\Model\\Atendimento', $id);
     if (!$atendimento || $atendimento->getServicoUnidade()->getUnidade()->getId() != $unidade->getId()) {
         throw new Exception(_('Atendimento inválido'));
     }
     if (!$atendimento) {
         throw new Exception(_('Atendimento inválido'));
     }
     return $atendimento;
 }
Example #5
0
 public function setUnidade(Unidade $unidade)
 {
     $this->unidade = $unidade;
     $this->unidadeId = $unidade->getId();
 }
Example #6
0
 public function setUnidade(Unidade $unidade)
 {
     $this->unidade = $unidade;
     $this->unidadeId = $unidade->getId();
     if ($this->em) {
         (new UsuarioService($this->em))->meta($this->wrapped, UsuarioService::ATTR_UNIDADE, $unidade->getId());
     }
 }