예제 #1
0
 /**
  * @param Atendimento $atendimento
  * @param mixed       $statusAtual (array[int] | int)
  * @param int         $novoStatus
  * @param string      $campoData
  *
  * @return bool
  */
 private function mudaStatusAtendimento(Atendimento $atendimento, $statusAtual, $novoStatus, $campoData)
 {
     $cond = '';
     if ($campoData !== null) {
         $cond = ", e.{$campoData} = :data";
     }
     if (!is_array($statusAtual)) {
         $statusAtual = [$statusAtual];
     }
     // atualizando atendimento
     $query = $this->em()->createQuery("\n            UPDATE\n                Novosga\\Model\\Atendimento e\n            SET\n                e.status = :novoStatus {$cond}\n            WHERE\n                e.id = :id AND\n                e.status IN (:statusAtual)\n        ");
     if ($campoData !== null) {
         $query->setParameter('data', DateUtil::nowSQL());
     }
     $query->setParameter('novoStatus', $novoStatus);
     $query->setParameter('id', $atendimento->getId());
     $query->setParameter('statusAtual', $statusAtual);
     return $query->execute() > 0;
 }
예제 #2
0
 /**
  * Redireciona um atendimento para outro servico.
  *
  * @param Atendimento $atendimento
  * @param Usuario     $usuario
  * @param int|Unidade $unidade
  * @param int|Servico $servico
  *
  * @return Atendimento
  */
 public function redirecionar(Atendimento $atendimento, Usuario $usuario, $unidade, $servico)
 {
     // copiando a senha do atendimento atual
     $service = new ServicoService($this->em);
     $su = $service->servicoUnidade($unidade, $servico);
     AppConfig::getInstance()->hook('attending.pre-redirect', array($atendimento, $su, $usuario));
     $novo = new Atendimento();
     $novo->setLocal(0);
     $novo->setServicoUnidade($su);
     $novo->setPai($atendimento);
     $novo->setDataChegada(new DateTime());
     $novo->setStatus(self::SENHA_EMITIDA);
     $novo->setSiglaSenha($atendimento->getSenha()->getSigla());
     $novo->setNumeroSenha($atendimento->getNumeroSenha());
     $novo->setNumeroSenhaServico($atendimento->getNumeroSenhaServico());
     $novo->setUsuario($usuario);
     $novo->setUsuarioTriagem($usuario);
     $novo->setPrioridade($atendimento->getPrioridade());
     $novo->setNomeCliente($atendimento->getCliente()->getNome());
     $novo->setDocumentoCliente($atendimento->getCliente()->getDocumento());
     $this->em->persist($novo);
     $this->em->flush();
     AppConfig::getInstance()->hook('attending.redirect', $atendimento);
     return $novo;
 }
 /**
  * {@inheritDoc}
  */
 public function __tostring()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, '__tostring', array());
     return parent::__tostring();
 }