protected function execute(InputInterface $input, OutputInterface $output) { try { $id = (int) $input->getArgument('unidade'); if ($id > 0) { // verificando unidade $unidade = $this->em->find('Novosga\\Model\\Unidade', $id); if (!$unidade) { throw new Exception("Unidade inválida: {$id}"); } } $service = new AtendimentoService($this->em); $service->acumularAtendimentos($id); $output->writeln('<info>Senhas reiniciadas com sucesso</info>'); } catch (Exception $e) { $output->writeln("<error>{$e->getMessage()}</error>"); } }
public function acumular_atendimentos(Context $context) { $response = new JsonResponse(); try { if (!$context->request()->isPost()) { throw new Exception(_('Somente via POST')); } $service = new AtendimentoService($this->em()); $service->acumularAtendimentos(); $response->success = true; } catch (\Exception $e) { $response->message = $e->getMessage(); } return $response; }
/** * Distribui uma nova senha */ public function distribui($unidade, $usuario, $servico, $prioridade, $nomeCliente, $documentoCliente) { $service = new AtendimentoService($this->em); return $service->distribuiSenha($unidade, $usuario, $servico, $prioridade, $nomeCliente, $documentoCliente)->jsonSerialize(); }
/** * Atualiza o status da senha para cancelado. * * @param Novosga\Context $context */ public function cancelar(Context $context) { $response = new JsonResponse(); try { $unidade = $context->getUser()->getUnidade(); if (!$unidade) { throw new Exception(_('Nenhuma unidade selecionada')); } $id = (int) $context->request()->post('id'); $atendimento = $this->getAtendimento($unidade, $id); $service = new AtendimentoService($this->em()); $response->success = $service->cancelar($atendimento, $unidade); } catch (Exception $e) { $response->message = $e->getMessage(); } return $response; }
/** * @return Senha */ public function getSenha() { if (!$this->senha) { $this->senha = new Senha(); $this->senha->setSigla($this->siglaSenha); $numero = AtendimentoService::isNumeracaoServico() ? $this->numeroSenhaServico : $this->numeroSenha; $this->senha->setNumero((int) $numero); $this->senha->setPrioridade($this->prioridade); } return $this->senha; }
private function total_atendimentos_status($dataInicial, $dataFinal, $unidadeId = 0) { $unidades = $this->unidadesArray($unidadeId); $dados = array(); $status = AtendimentoService::situacoes(); $query = $this->em()->createQuery("\n SELECT \n COUNT(e) as total \n FROM \n Novosga\\Model\\ViewAtendimento e\n WHERE \n e.dataChegada >= :inicio AND \n e.dataChegada <= :fim AND\n e.unidade = :unidade AND \n e.status = :status\n "); $query->setParameter('inicio', $dataInicial); $query->setParameter('fim', $dataFinal); foreach ($unidades as $unidade) { $dados[$unidade->getId()] = array(); // pegando todos os status foreach ($status as $k => $v) { $query->setParameter('unidade', $unidade->getId()); $query->setParameter('status', $k); $rs = $query->getSingleResult(); $dados[$unidade->getId()][$k] = (int) $rs['total']; } } return $dados; }
/** * Busca os atendimentos a partir do número da senha * @param Context $context */ public function consulta_senha(Context $context) { $response = new JsonResponse(); $unidade = $context->getUser()->getUnidade(); if ($unidade) { $numero = $context->request()->get('numero'); $service = new AtendimentoService($this->em()); $atendimentos = $service->buscaAtendimentos($unidade, $numero); $response->data['total'] = sizeof($atendimentos); foreach ($atendimentos as $atendimento) { $response->data['atendimentos'][] = $atendimento->jsonSerialize(); } $response->success = true; } else { $response->message = _('Nenhuma unidade selecionada'); } return $response; }