Commit 1e6c9ff6 authored by Mardonio Costa's avatar Mardonio Costa

Inicial

parents
Pipeline #121 canceled with stages
/nbproject/
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Configuration;
use Doctrine\ORM\QueryBuilder;
use Novosga\Entity\Unidade;
use Novosga\Entity\Usuario;
use Novosga\Infrastructure\StorageInterface;
/**
* OrderingParameter
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class OrderingParameter implements ParameterInterface
{
/**
* @var Unidade
*/
private $unidade;
/**
* @var Usuario
*/
private $usuario;
/**
* @var StorageInterface
*/
private $storage;
/**
* @var QueryBuilder
*/
private $queryBuilder;
public function getUnidade(): Unidade
{
return $this->unidade;
}
public function getUsuario(): ?Usuario
{
return $this->usuario;
}
public function getStorage(): StorageInterface
{
return $this->storage;
}
public function getQueryBuilder(): QueryBuilder
{
return $this->queryBuilder;
}
public function setUnidade(Unidade $unidade)
{
$this->unidade = $unidade;
return $this;
}
public function setUsuario(?Usuario $usuario)
{
$this->usuario = $usuario;
return $this;
}
public function setStorage(StorageInterface $storage)
{
$this->storage = $storage;
return $this;
}
public function setQueryBuilder(QueryBuilder $queryBuilder)
{
$this->queryBuilder = $queryBuilder;
return $this;
}
}
\ No newline at end of file
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Configuration;
/**
* Configuration file parameter interface
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
interface ParameterInterface
{
}
\ No newline at end of file
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
use DateTime;
use DateInterval;
use Novosga\Entity\Cliente;
use Novosga\Entity\Senha;
/**
* AbstractAtendimento.
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
abstract class AbstractAtendimento implements \JsonSerializable
{
/**
* @var mixed
*/
protected $id;
/**
* @var Unidade
*/
protected $unidade;
/**
* @var Servico
*/
protected $servico;
/**
* @var Usuario
*/
protected $usuario;
/**
* @var Usuario
*/
protected $usuarioTriagem;
/**
* @var Local
*/
protected $local;
/**
* @var int
*/
protected $numeroLocal;
/**
* @var Prioridade
*/
private $prioridade;
/**
* @var \DateTime
*/
protected $dataAgendamento;
/**
* @var \DateTime
*/
protected $dataChegada;
/**
* @var \DateTime
*/
protected $dataChamada;
/**
* @var \DateTime
*/
private $dataInicio;
/**
* @var \DateTime
*/
private $dataFim;
/**
* @var int
*/
private $tempoEspera;
/**
* @var int
*/
private $tempoPermanencia;
/**
* @var int
*/
private $tempoAtendimento;
/**
* @var int
*/
private $tempoDeslocamento;
/**
* @var string
*/
protected $status;
/**
* @var string
*/
protected $resolucao;
/**
* @var Cliente
*/
protected $cliente;
/**
* @var Senha
*/
protected $senha;
/**
* @var Atendimento
*/
protected $pai;
/**
* @var string
*/
protected $observacao;
public function __construct()
{
$this->senha = new Senha();
}
public function getId()
{
return $this->id;
}
public function setId($id): self
{
$this->id = $id;
return $this;
}
public function getUnidade(): ?Unidade
{
return $this->unidade;
}
public function setUnidade(?Unidade $unidade): self
{
$this->unidade = $unidade;
return $this;
}
public function getServico(): ?Servico
{
return $this->servico;
}
public function setServico(?Servico $servico): self
{
$this->servico = $servico;
return $this;
}
public function getUsuario(): ?Usuario
{
return $this->usuario;
}
public function setUsuario(?Usuario $usuario): self
{
$this->usuario = $usuario;
return $this;
}
public function setUsuarioTriagem(?Usuario $usuario): self
{
$this->usuarioTriagem = $usuario;
return $this;
}
public function getUsuarioTriagem(): ?Usuario
{
return $this->usuarioTriagem;
}
public function getLocal(): ?Local
{
return $this->local;
}
public function getNumeroLocal(): ?int
{
return $this->numeroLocal;
}
public function setLocal(?Local $local): self
{
$this->local = $local;
return $this;
}
public function setNumeroLocal(?int $numeroLocal): self
{
$this->numeroLocal = $numeroLocal;
return $this;
}
public function getDataAgendamento(): ?DateTime
{
return $this->dataAgendamento;
}
public function setDataAgendamento(?DateTime $dataAgendamento): self
{
$this->dataAgendamento = $dataAgendamento;
return $this;
}
/**
* @return DateTime
*/
public function getDataChegada(): ?DateTime
{
return $this->dataChegada;
}
public function setDataChegada(?DateTime $dataChegada): self
{
$this->dataChegada = $dataChegada;
return $this;
}
/**
* @return DateTime
*/
public function getDataChamada(): ?DateTime
{
return $this->dataChamada;
}
public function setDataChamada(?DateTime $dataChamada): self
{
$this->dataChamada = $dataChamada;
return $this;
}
/**
* @return DateTime
*/
public function getDataInicio(): ?DateTime
{
return $this->dataInicio;
}
public function setDataInicio(?DateTime $dataInicio): self
{
$this->dataInicio = $dataInicio;
return $this;
}
/**
* @return DateTime
*/
public function getDataFim(): ?DateTime
{
return $this->dataFim;
}
public function setDataFim(?DateTime $dataFim): self
{
$this->dataFim = $dataFim;
return $this;
}
public function getStatus()
{
return $this->status;
}
public function setStatus($status): self
{
$this->status = $status;
return $this;
}
public function getResolucao()
{
return $this->resolucao;
}
public function setResolucao($resolucao): self
{
$this->resolucao = $resolucao;
return $this;
}
public function setCliente(Cliente $cliente): self
{
$this->cliente = $cliente;
return $this;
}
public function getPai(): ?self
{
return $this->pai;
}
public function setPai(?self $pai): self
{
$this->pai = $pai;
return $this;
}
/**
* @param DateInterval $tempoEspera
* @return $this
*/
public function setTempoEspera(DateInterval $tempoEspera): self
{
$this->tempoEspera = $this->dateIntervalToSeconds($tempoEspera);
return $this;
}
/**
* Retorna o tempo de espera do cliente até ser atendido.
* A diferença entre a data de chegada até a data de chamada (ou atual).
*
* @return DateInterval
*/
public function getTempoEspera()
{
if ($this->tempoEspera) {
return $this->secondsToDateInterval($this->tempoEspera);
}
$now = new DateTime();
$interval = $now->diff($this->getDataChegada());
return $interval;
}
/**
* @param DateInterval $tempoPermanencia
* @return $this
*/
public function setTempoPermanencia(DateInterval $tempoPermanencia): self
{
$this->tempoPermanencia = $this->dateIntervalToSeconds($tempoPermanencia);
return $this;
}
/**
* Retorna o tempo de permanência do cliente na unidade.
* A diferença entre a data de chegada até a data de fim de atendimento.
*
* @return DateInterval
*/
public function getTempoPermanencia()
{
if ($this->tempoPermanencia) {
return $this->secondsToDateInterval($this->tempoPermanencia);
}
$interval = new DateInterval('P0M');
if ($this->getDataFim()) {
$interval = $this->getDataFim()->diff($this->getDataChegada());
}
return $interval;
}
/**
* @param DateInterval $tempoAtendimento
* @return $this
*/
public function setTempoAtendimento(DateInterval $tempoAtendimento = null): self
{
if ($tempoAtendimento) {
$this->tempoAtendimento = $this->dateIntervalToSeconds($tempoAtendimento);
} else {
$this->tempoAtendimento = 0;
}
return $this;
}
/**
* Retorna o tempo total do atendimento.
* A diferença entre a data de início e fim do atendimento.
*
* @return DateInterval
*/
public function getTempoAtendimento()
{
if ($this->tempoAtendimento) {
return $this->secondsToDateInterval($this->tempoAtendimento);
}
$interval = new DateInterval('P0M');
if ($this->getDataFim()) {
$interval = $this->getDataFim()->diff($this->getDataInicio());
}
return $interval;
}
/**
* @param DateInterval $tempoEspera
* @return $this
*/
public function setTempoDeslocamento(DateInterval $tempoDeslocamento): self
{
$this->tempoDeslocamento = $this->dateIntervalToSeconds($tempoDeslocamento);
return $this;
}
/**
* Retorna o tempo de deslocamento do cliente.
* A diferença entre a data de chamada até a data de início.
*
* @return \DateInterval
*/
public function getTempoDeslocamento()
{
if ($this->tempoDeslocamento) {
return $this->secondsToDateInterval($this->tempoDeslocamento);
}
$interval = new \DateInterval('P0M');
if ($this->getDataChamada()) {
$interval = $this->getDataInicio()->diff($this->getDataChamada());
}
return $interval;
}
/**
* @return Cliente
*/
public function getCliente()
{
return $this->cliente;
}
/**
* @return Senha
*/
public function getSenha()
{
return $this->senha;
}
public function getPrioridade()
{
return $this->prioridade;
}
public function setPrioridade(Prioridade $prioridade): self
{
$this->prioridade = $prioridade;
return $this;
}
public function getObservacao()
{
return $this->observacao;
}
public function setObservacao($observacao): self
{
$this->observacao = $observacao;
return $this;
}
public function jsonSerialize()
{
return [
'id' => $this->getId(),
'senha' => $this->getSenha(),
'servico' => [
'id' => $this->getServico()->getId(),
'nome' => $this->getServico()->getNome(),
],
'observacao' => $this->getObservacao(),
'dataChegada' => $this->getDataChegada()->format('Y-m-d\TH:i:s'),
'dataChamada' => $this->getDataChamada() ? $this->getDataChamada()->format('Y-m-d\TH:i:s') : null,
'dataInicio' => $this->getDataInicio() ? $this->getDataInicio()->format('Y-m-d\TH:i:s') : null,
'dataFim' => $this->getDataFim() ? $this->getDataFim()->format('Y-m-d\TH:i:s') : null,
'dataAgendamento' => $this->getDataAgendamento() ? $this->getDataAgendamento()->format('Y-m-d\TH:i:s') : null,
'tempoEspera' => $this->getTempoEspera()->format('%H:%I:%S'),
'prioridade' => $this->getPrioridade(),
'status' => $this->getStatus(),
'resolucao' => $this->getResolucao(),
'cliente' => $this->getCliente(),
'triagem' => $this->getUsuarioTriagem() ? $this->getUsuarioTriagem()->getUsername() : null,
'usuario' => $this->getUsuario() ? $this->getUsuario()->getUsername() : null,
];
}
public function __toString()
{
return $this->getSenha()->toString();
}
private function dateIntervalToSeconds(\DateInterval $d): int
{
$seconds = $d->s + ($d->i * 60) + ($d->h * 3600) + ($d->d * 86400) + ($d->m * 2592000);
return $seconds;
}
private function secondsToDateInterval(int $s)
{
$dt1 = new \DateTime("@0");
$dt2 = new \DateTime("@{$s}");
return $dt1->diff($dt2);
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* AbstractAtendimentoCodificado
* atendimento codificado (servico realizado).
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
abstract class AbstractAtendimentoCodificado
{
/**
* @var Servico
*/
protected $servico;
/**
* @var int
*/
protected $peso;
abstract public function getAtendimento();
abstract public function setAtendimento(AbstractAtendimento $atendimento);
public function getServico()
{
return $this->servico;
}
public function setServico($servico)
{
$this->servico = $servico;
}
public function getPeso()
{
return $this->peso;
}
public function setPeso($peso)
{
$this->peso = $peso;
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Abstract metadata.
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
abstract class AbstractMetadata implements \JsonSerializable
{
/**
* @var string
*/
protected $namespace;
/**
* @var string
*/
protected $name;
/**
* @var mixed
*/
protected $value;
public function getNamespace()
{
return $this->namespace;
}
public function setNamespace(string $namespace)
{
$this->namespace = $namespace;
return $this;
}
public function getName()
{
return $this->name;
}
public function getValue()
{
return $this->value;
}
public function setName(string $name)
{
$this->name = $name;
return $this;
}
public function setValue($value)
{
$this->value = $value;
return $this;
}
public function jsonSerialize()
{
return [
'namespace' => $this->getName(),
'name' => $this->getNamespace(),
'value' => $this->getValue(),
];
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
use DateTime;
/**
* Agendamento.
*
* @author rogerio
*/
class Agendamento implements \JsonSerializable
{
/**
* @var mixed
*/
protected $id;
/**
* @var DateTime
*/
private $data;
/**
* @var DateTime
*/
private $hora;
/**
* @var Cliente
*/
private $cliente;
/**
* @var Unidade
*/
private $unidade;
/**
* @var Servico
*/
private $servico;
/**
* @var DateTime
*/
private $dataConfirmacao;
public function __construct()
{
}
public function getId()
{
return $this->id;
}
public function getData()
{
return $this->data;
}
public function getHora()
{
return $this->hora;
}
public function getCliente()
{
return $this->cliente;
}
public function getUnidade()
{
return $this->unidade;
}
public function getServico()
{
return $this->servico;
}
public function getDataConfirmacao()
{
return $this->dataConfirmacao;
}
public function setData(DateTime $data = null)
{
$this->data = $data;
return $this;
}
public function setHora(DateTime $hora = null)
{
$this->hora = $hora;
return $this;
}
public function setCliente(Cliente $cliente = null)
{
$this->cliente = $cliente;
return $this;
}
public function setUnidade(Unidade $unidade = null)
{
$this->unidade = $unidade;
return $this;
}
public function setServico(Servico $servico = null)
{
$this->servico = $servico;
return $this;
}
public function setDataConfirmacao(DateTime $dataConfirmacao)
{
$this->dataConfirmacao = $dataConfirmacao;
return $this;
}
public function __toString()
{
return $this->getId();
}
public function jsonSerialize()
{
return [
'id' => $this->getId(),
'cliente' => $this->getCliente(),
'servico' => $this->getServico(),
'unidade' => $this->getUnidade(),
'data' => $this->getData() ? $this->getData()->format('Y-m-d') : null,
'hora' => $this->getHora() ? $this->getHora()->format('H:i') : null,
'dataConfirmacao' => $this->getDataConfirmacao(),
];
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
/**
* Classe Atendimento
* contem o Cliente, o Servico e o Status do atendimento.
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class Atendimento extends AbstractAtendimento
{
/**
* @var AtendimentoCodificado[]
*/
private $codificados;
public function __construct()
{
parent::__construct();
$this->codificados = new ArrayCollection();
}
public function getCodificados()
{
return $this->codificados;
}
public function setCodificados(Collection $codificados)
{
$this->codificados = $codificados;
return $this;
}
/**
* Atendimento hash.
*
* @return string
*/
public function hash()
{
return sha1("{$this->getId()}:{$this->getDataChegada()->getTimestamp()}");
}
public function jsonSerialize($minimal = false)
{
$arr = parent::jsonSerialize($minimal);
$arr['hash'] = $this->hash();
return $arr;
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Classe Atendimento Codificado
* representa o atendimento codificado (servico realizado).
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class AtendimentoCodificado extends AbstractAtendimentoCodificado
{
/**
* @var Atendimento
*/
private $atendimento;
public function getAtendimento()
{
return $this->atendimento;
}
public function setAtendimento(AbstractAtendimento $atendimento)
{
$this->atendimento = $atendimento;
return $this;
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Classe Atendimento Codificado (Historico)
* representa o atendimento codificado (servico realizado).
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class AtendimentoCodificadoHistorico extends AbstractAtendimentoCodificado
{
/**
* @var AtendimentoHistorico
*/
private $atendimento;
public function getAtendimento()
{
return $this->atendimento;
}
public function setAtendimento(AbstractAtendimento $atendimento)
{
$this->atendimento = $atendimento;
return $this;
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
/**
* AtendimentoHistorico
* historico de atendimento do banco de dados.
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class AtendimentoHistorico extends AbstractAtendimento
{
/**
* @var AtendimentoCodificadoHistorico[]
*/
private $codificados;
public function __construct()
{
$this->codificados = new ArrayCollection();
}
public function getCodificados()
{
return $this->codificados;
}
public function setCodificados(Collection $codificados)
{
$this->codificados = $codificados;
return $this;
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* AtendimentoMeta (Historico).
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class AtendimentoHistoricoMeta extends EntityMetadata
{
public function getAtendimento()
{
return $this->getEntity();
}
public function setAtendimento(AtendimentoHistorico $atendimento)
{
return $this->setEntity($atendimento);
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* AtendimentoMeta.
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class AtendimentoMeta extends EntityMetadata
{
public function getAtendimento()
{
return $this->getEntity();
}
public function setAtendimento(Atendimento $atendimento)
{
return $this->setEntity($atendimento);
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Cliente.
*
* @author rogerio
*/
class Cliente implements \JsonSerializable
{
/**
* @var mixed
*/
protected $id;
/**
* @var string
*/
private $nome;
/**
* @var string
*/
private $documento;
/**
* @var string
*/
private $email;
/**
* @var string
*/
private $telefone;
public function __construct()
{
}
public function getId()
{
return $this->id;
}
public function getNome()
{
return $this->nome;
}
public function getDocumento()
{
return $this->documento;
}
public function getEmail()
{
return $this->email;
}
public function getTelefone()
{
return $this->telefone;
}
public function setId($id)
{
$this->id = $id;
return $this;
}
public function setNome($nome)
{
$this->nome = $nome;
return $this;
}
public function setDocumento($documento)
{
$this->documento = $documento;
return $this;
}
public function setEmail($email)
{
$this->email = $email;
return $this;
}
public function setTelefone($telefone)
{
$this->telefone = $telefone;
return $this;
}
public function __toString()
{
return $this->getNome();
}
public function jsonSerialize()
{
return [
'id' => $this->getId(),
'nome' => $this->getNome(),
'documento' => $this->getDocumento(),
'email' => $this->getEmail(),
'telefone' => $this->getTelefone(),
];
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* ClienteMeta
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class ClienteMeta extends EntityMetadata
{
public function getCliente()
{
return $this->getEntity();
}
public function setCliente(Cliente $cliente)
{
return $this->setEntity($cliente);
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
class ConfiguracaoImpressao implements \JsonSerializable
{
/**
* @var Unidade
*/
private $unidade;
/**
* @var string
*/
private $cabecalho;
/**
* @var string
*/
private $rodape;
/**
* @var bool
*/
private $exibirNomeServico;
/**
* @var bool
*/
private $exibirNomeUnidade;
/**
* @var bool
*/
private $exibirMensagemServico;
/**
* @var bool
*/
private $exibirData;
/**
* @var bool
*/
private $exibirPrioridade;
public function __construct(Unidade $unidade)
{
$this->unidade = $unidade;
$this->cabecalho = 'Novo SGA';
$this->rodape = 'Novo SGA';
$this->exibirData = true;
$this->exibirMensagemServico = true;
$this->exibirNomeServico = true;
$this->exibirNomeUnidade = true;
$this->exibirPrioridade = true;
}
public function getUnidade()
{
return $this->unidade;
}
public function getCabecalho()
{
return $this->cabecalho;
}
public function getRodape()
{
return $this->rodape;
}
public function getExibirNomeServico()
{
return $this->exibirNomeServico;
}
public function getExibirNomeUnidade()
{
return $this->exibirNomeUnidade;
}
public function getExibirMensagemServico()
{
return $this->exibirMensagemServico;
}
public function getExibirData()
{
return $this->exibirData;
}
public function getExibirPrioridade()
{
return $this->exibirPrioridade;
}
public function setUnidade(Unidade $unidade)
{
$this->unidade = $unidade;
return $this;
}
public function setCabecalho($cabecalho)
{
$this->cabecalho = $cabecalho;
return $this;
}
public function setRodape($rodape)
{
$this->rodape = $rodape;
return $this;
}
public function setExibirNomeServico($exibirNomeServico)
{
$this->exibirNomeServico = $exibirNomeServico;
return $this;
}
public function setExibirNomeUnidade($exibirNomeUnidade)
{
$this->exibirNomeUnidade = $exibirNomeUnidade;
return $this;
}
public function setExibirMensagemServico($exibirMensagemServico)
{
$this->exibirMensagemServico = $exibirMensagemServico;
return $this;
}
public function setExibirData($exibirData)
{
$this->exibirData = $exibirData;
return $this;
}
public function setExibirPrioridade($exibirPrioridade)
{
$this->exibirPrioridade = $exibirPrioridade;
return $this;
}
public function jsonSerialize()
{
return [
'cabecalho' => $this->getCabecalho(),
'rodape' => $this->getRodape(),
'exibirData' => $this->getExibirData(),
'exibirPrioridade' => $this->getExibirPrioridade(),
'exibirNomeUnidade' => $this->getExibirNomeUnidade(),
'exibirNomeServico' => $this->getExibirNomeServico(),
'exibirMensagemServico' => $this->getExibirMensagemServico(),
];
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Ticket counter.
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class Contador implements \JsonSerializable
{
/**
* @var Unidade
*/
private $unidade;
/**
* @var Servico
*/
private $servico;
/**
* @var int
*/
private $numero;
/**
* Get the value of Unidade
*
* @return Unidade
*/
public function getUnidade()
{
return $this->unidade;
}
/**
* Set the value of Unidade
*
* @param Unidade unidade
*
* @return self
*/
public function setUnidade(Unidade $unidade)
{
$this->unidade = $unidade;
return $this;
}
/**
* Get the value of Servico
*
* @return Servico
*/
public function getServico()
{
return $this->servico;
}
/**
* Set the value of Servico
*
* @param Servico servico
*
* @return self
*/
public function setServico(Servico $servico)
{
$this->servico = $servico;
return $this;
}
/**
* Get the value of Atual
*
* @return int
*/
public function getNumero()
{
return $this->numero;
}
/**
* Set the value of Atual
*
* @param int atual
*
* @return self
*/
public function setNumero($numero)
{
$this->numero = $numero;
return $this;
}
public function jsonSerialize()
{
return [
'numero' => $this->getNumero(),
'servico' => $this->getServico()
];
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Departamento
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class Departamento implements \JsonSerializable
{
/**
* @var mixed
*/
protected $id;
/**
* @var string
*/
private $nome;
/**
* @var string
*/
private $descricao;
/**
* @var int
*/
private $ativo;
/**
* @var \DateTime
*/
private $createdAt;
/**
* @var \DateTime
*/
private $updatedAt;
public function __construct()
{
$this->ativo = true;
}
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
return $this;
}
public function setNome($nome)
{
$this->nome = $nome;
}
public function getNome()
{
return $this->nome;
}
public function setDescricao($desc)
{
$this->descricao = $desc;
}
public function getDescricao()
{
return $this->descricao;
}
public function isAtivo(): bool
{
return $this->ativo;
}
public function setAtivo(bool $ativo)
{
$this->ativo = $ativo;
}
public function getCreatedAt()
{
return $this->createdAt;
}
public function getUpdatedAt()
{
return $this->updatedAt;
}
public function setCreatedAt(\DateTime $createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
public function setUpdatedAt(\DateTime $updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
public function __toString()
{
return $this->getNome();
}
public function jsonSerialize()
{
return [
'id' => $this->getId(),
'nome' => $this->getNome(),
'descricao' => $this->getDescricao(),
'ativo' => $this->isAtivo(),
];
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Abstract metadata.
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
abstract class EntityMetadata extends AbstractMetadata
{
/**
* @var mixed
*/
protected $entity;
public function setEntity($entity)
{
$this->entity = $entity;
return $this;
}
public function getEntity()
{
return $this->entity;
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Local de atendimento
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class Local implements \JsonSerializable
{
/**
* @var mixed
*/
protected $id;
/**
* @var string
*/
private $nome;
/**
* @var \DateTime
*/
private $createdAt;
/**
* @var \DateTime
*/
private $updatedAt;
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
return $this;
}
public function setNome($nome)
{
$this->nome = $nome;
return $this;
}
public function getNome()
{
return $this->nome;
}
public function getCreatedAt()
{
return $this->createdAt;
}
public function getUpdatedAt()
{
return $this->updatedAt;
}
public function setCreatedAt(\DateTime $createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
public function setUpdatedAt(\DateTime $updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
public function __toString()
{
return $this->getNome();
}
public function jsonSerialize()
{
return [
'id' => $this->getId(),
'nome' => $this->getNome(),
'createdAt' => $this->getCreatedAt() ? $this->getCreatedAt()->format('Y-m-d\TH:i:s') : null,
'updatedAt' => $this->getUpdatedAt() ? $this->getUpdatedAt()->format('Y-m-d\TH:i:s') : null,
];
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Definição de onde o usuário está lotado
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class Lotacao implements \JsonSerializable
{
/**
* @var int
*/
private $id;
/**
* @var Usuario
*/
private $usuario;
/**
* @var Unidade
*/
private $unidade;
/**
* @var Perfil
*/
private $perfil;
public function __construct()
{
}
public function getId()
{
return $this->id;
}
/**
* Modifica usuario.
*
* @param $usuario
*
* @return none
*/
public function setUsuario(Usuario $usuario)
{
$this->usuario = $usuario;
}
/**
* Retorna objeto usuario.
*
* @return Usuario $usuario
*/
public function getUsuario()
{
return $this->usuario;
}
/**
* Modifica unidade.
*
* @param $unidade
*/
public function setUnidade(Unidade $unidade)
{
$this->unidade = $unidade;
}
/**
* Retorna objeto Unidade.
*
* @return Unidade
*/
public function getUnidade()
{
return $this->unidade;
}
/**
* Modifica perfil.
*
* @param $perfil
*
* @return none
*/
public function setPerfil(Perfil $perfil)
{
$this->perfil = $perfil;
}
/**
* Retorna objeto Perfil.
*
* @return Perfil $perfil
*/
public function getPerfil()
{
return $this->perfil;
}
public function jsonSerialize()
{
return [
'id' => $this->getId(),
'perfil' => $this->getPerfil(),
'unidade' => $this->getUnidade(),
'usuario' => $this->getUsuario(),
];
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* System metadata.
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class Metadata extends AbstractMetadata
{
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Painel
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class Painel implements \JsonSerializable
{
/**
* @var int
*/
private $host;
/**
* @var string
*/
private $senha;
/**
* @var Unidade
*/
private $unidade;
/**
* @var PainelServico[]
*/
private $servicos;
public function getHost()
{
return $this->host;
}
public function setHost($host)
{
$this->host = $host;
}
public function getUnidade()
{
return $this->unidade;
}
public function setUnidade($unidade)
{
$this->unidade = $unidade;
}
public function getServicos()
{
return $this->servicos;
}
public function setServicos($servicos)
{
$this->servicos = $servicos;
}
public function getIp()
{
return long2ip($this->getHost());
}
public function __toString()
{
return $this->getIp();
}
public function jsonSerialize()
{
return [
'host' => $this->getHost(),
'ip' => $this->getIp(),
'servicos' => $this->getServicos(),
];
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Senha enviada ao painel
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class PainelSenha implements \JsonSerializable
{
/**
* @var mixed
*/
protected $id;
/**
* @var Servico
*/
private $servico;
/**
* @var Unidade
*/
private $unidade;
/**
* @var int
*/
private $numeroSenha;
/**
* @var string
*/
private $siglaSenha;
/**
* @var string
*/
private $mensagem;
/**
* @var string
*/
private $local;
/**
* @var int
*/
private $numeroLocal;
/**
* @var int
*/
private $peso;
/**
* @var string
*/
private $prioridade;
/**
* @var string
*/
private $nomeCliente;
/**
* @var string
*/
private $documentoCliente;
public function getServico()
{
return $this->servico;
}
public function setServico($servico)
{
$this->servico = $servico;
}
public function getUnidade()
{
return $this->unidade;
}
public function setUnidade($unidade)
{
$this->unidade = $unidade;
}
public function getNumeroSenha()
{
return $this->numeroSenha;
}
public function setNumeroSenha($numeroSenha)
{
$this->numeroSenha = $numeroSenha;
}
public function getSiglaSenha()
{
return $this->siglaSenha;
}
public function setSiglaSenha($siglaSenha)
{
$this->siglaSenha = $siglaSenha;
}
public function getMensagem()
{
return $this->mensagem;
}
public function setMensagem($mensagem)
{
$this->mensagem = $mensagem;
}
public function getLocal()
{
return $this->local;
}
public function setLocal($local)
{
$this->local = $local;
}
public function getNumeroLocal()
{
return $this->numeroLocal;
}
public function setNumeroLocal($numeroLocal)
{
$this->numeroLocal = $numeroLocal;
}
public function getPeso()
{
return $this->peso;
}
public function setPeso($peso)
{
$this->peso = $peso;
}
public function getPrioridade()
{
return $this->prioridade;
}
public function getNomeCliente()
{
return $this->nomeCliente;
}
public function getDocumentoCliente()
{
return $this->documentoCliente;
}
public function setPrioridade($prioridade)
{
$this->prioridade = $prioridade;
}
public function setNomeCliente($nomeCliente)
{
$this->nomeCliente = $nomeCliente;
}
public function setDocumentoCliente($documentoCliente)
{
$this->documentoCliente = $documentoCliente;
}
public function jsonSerialize()
{
return [
'id' => $this->getId(),
'senha' => $this->getSiglaSenha().str_pad($this->getNumeroSenha(), 3, '0', STR_PAD_LEFT),
'local' => $this->getLocal(),
'numeroLocal' => $this->getNumeroLocal(),
'peso' => $this->getPeso(),
'prioridade' => $this->getPrioridade(),
'nomeCliente' => $this->getNomeCliente(),
'documentoCliente' => $this->getDocumentoCliente(),
];
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* PainelServico
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class PainelServico implements \JsonSerializable
{
/**
* @var Painel
*/
private $painel;
/**
* @var Servico
*/
private $servico;
/**
* @var Unidade
*/
private $unidade;
public function getPainel()
{
return $this->painel;
}
public function setPainel($painel)
{
$this->painel = $painel;
}
public function getServico()
{
return $this->servico;
}
public function setServico($servico)
{
$this->servico = $servico;
}
public function getUnidade()
{
return $this->unidade;
}
public function setUnidade($unidade)
{
$this->unidade = $unidade;
}
public function jsonSerialize()
{
return [
'painel' => $this->getPainel(),
'servico' => $this->getServico(),
'unidade' => $this->getUnidade(),
];
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Classe Perfil
* O perfil define permissões de acesso a módulos do sistema.
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class Perfil implements \JsonSerializable
{
/**
* @var mixed
*/
protected $id;
/**
* @var string
*/
private $nome;
/**
* @var string
*/
private $descricao;
/**
* @var Modulo[]
*/
private $modulos;
/**
* @var \DateTime
*/
private $createdAt;
/**
* @var \DateTime
*/
private $updatedAt;
public function __construct()
{
$this->modulos = [];
}
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Define o nome do perfil.
*
* @param string $nome
*/
public function setNome($nome)
{
$this->nome = $nome;
}
/**
* Retorna a descrição do perfil.
*
* @return int
*/
public function getDescricao()
{
return $this->descricao;
}
/**
* Define a descrição do perfil.
*
* @param string $descricao
*/
public function setDescricao($descricao)
{
$this->descricao = $descricao;
}
/**
* Retorna o nome do perfil.
*
* @return string
*/
public function getNome()
{
return $this->nome;
}
public function getModulos()
{
return $this->modulos;
}
public function setModulos($modulos)
{
$this->modulos = $modulos;
return $this;
}
public function getCreatedAt()
{
return $this->createdAt;
}
public function getUpdatedAt()
{
return $this->updatedAt;
}
public function setCreatedAt(\DateTime $createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
public function setUpdatedAt(\DateTime $updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
public function __toString()
{
return $this->nome;
}
public function jsonSerialize()
{
return [
'id' => $this->getId(),
'nome' => $this->getNome(),
'descricao' => $this->getDescricao(),
'modulos' => $this->getModulos(),
'createdAt' => $this->getCreatedAt() ? $this->getCreatedAt()->format('Y-m-d\TH:i:s') : null,
'updatedAt' => $this->getUpdatedAt() ? $this->getUpdatedAt()->format('Y-m-d\TH:i:s') : null,
];
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Prioridade
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class Prioridade implements \JsonSerializable
{
/**
* @var mixed
*/
protected $id;
/**
* @var string
*/
private $nome;
/**
* @var string
*/
private $descricao;
/**
* @var int
*/
private $peso;
/**
* @var int
*/
private $ativo;
/**
* @var \DateTime
*/
private $createdAt;
/**
* @var \DateTime
*/
private $updatedAt;
/**
* @var \DateTime
*/
private $deletedAt;
public function __construct()
{
$this->ativo = true;
}
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
return $this;
}
public function setNome($nome)
{
$this->nome = $nome;
}
public function getNome()
{
return $this->nome;
}
public function setDescricao($desc)
{
$this->descricao = $desc;
}
public function getDescricao()
{
return $this->descricao;
}
public function setPeso($peso)
{
$this->peso = $peso;
}
public function getPeso()
{
return $this->peso;
}
public function isAtivo(): bool
{
return $this->ativo;
}
public function setAtivo(bool $ativo)
{
$this->ativo = $ativo;
}
public function getCreatedAt()
{
return $this->createdAt;
}
public function getUpdatedAt()
{
return $this->updatedAt;
}
public function getDeletedAt()
{
return $this->deletedAt;
}
public function setCreatedAt(\DateTime $createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
public function setUpdatedAt(\DateTime $updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
public function setDeletedAt(\DateTime $deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
public function __toString()
{
return $this->getNome();
}
public function jsonSerialize()
{
return [
'id' => $this->getId(),
'nome' => $this->getNome(),
'descricao' => $this->getDescricao(),
'peso' => $this->getPeso(),
'ativo' => $this->isAtivo(),
'createdAt' => $this->getCreatedAt() ? $this->getCreatedAt()->format('Y-m-d\TH:i:s') : null,
'updatedAt' => $this->getUpdatedAt() ? $this->getUpdatedAt()->format('Y-m-d\TH:i:s') : null,
'deletedAt' => $this->getDeletedAt() ? $this->getDeletedAt()->format('Y-m-d\TH:i:s') : null,
];
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Classe Senha
* Responsavel pelas informacoes do Senha.
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
class Senha implements \JsonSerializable
{
const LENGTH = 3;
/**
* @var string
*/
private $sigla;
/**
* @var int
*/
private $numero;
public function __construct()
{
}
/**
* Define a sigla da senha.
*
* @param char $sigla
*/
public function setSigla($sigla)
{
$this->sigla = $sigla;
}
/**
* Retorna a sigla da senha.
*
* @return char $sigla
*/
public function getSigla()
{
return $this->sigla;
}
/**
* Define o numero da senha.
*
* @param int $numero
*/
public function setNumero($numero)
{
$this->numero = $numero;
}
/**
* Retorna o numero da senha.
*
* @return int $numero
*/
public function getNumero()
{
return $this->numero;
}
/**
* Retorna o numero da senha preenchendo com zero (esquerda).
*
* @return string
*/
public function getNumeroZeros()
{
return str_pad($this->getNumero(), self::LENGTH, '0', STR_PAD_LEFT);
}
/**
* Retorna a senha formatada para exibicao.
*
* @return string
*/
public function __toString()
{
return $this->getSigla() . $this->getNumeroZeros();
}
public function jsonSerialize()
{
return [
'sigla' => $this->getSigla(),
'numero' => $this->getNumero(),
'format' => $this->__toString(),
];
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Servico
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class Servico implements \JsonSerializable
{
/**
* @var mixed
*/
protected $id;
/**
* @var string
*/
private $nome;
/**
* @var string
*/
private $descricao;
/**
* @var int
*/
private $ativo;
/**
* @var int
*/
private $peso;
/**
* @var Servico
*/
private $mestre;
/**
* @var Servico[]
*/
private $subServicos;
/**
* @var ServicoUnidade[]
*/
private $servicosUnidade;
/**
* @var \DateTime
*/
private $createdAt;
/**
* @var \DateTime
*/
private $updatedAt;
/**
* @var \DateTime
*/
private $deletedAt;
public function __construct()
{
$this->ativo = true;
$this->subServicos = new \Doctrine\Common\Collections\ArrayCollection();
$this->servicosUnidade = new \Doctrine\Common\Collections\ArrayCollection();
}
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
return $this;
}
public function setNome($nome)
{
$this->nome = $nome;
}
public function getNome()
{
return $this->nome;
}
public function setDescricao($descricao)
{
$this->descricao = $descricao;
}
public function getDescricao()
{
return $this->descricao;
}
public function setMestre(Servico $servico = null)
{
$this->mestre = $servico;
}
public function getMestre()
{
return $this->mestre;
}
public function isMestre()
{
return ($this->getId() && !$this->getMestre());
}
public function setAtivo(bool $ativo)
{
$this->ativo = $ativo;
}
public function isAtivo(): bool
{
return $this->ativo;
}
public function getPeso()
{
return $this->peso;
}
public function setPeso($peso)
{
$this->peso = $peso;
}
public function getSubServicos()
{
return $this->subServicos;
}
public function setSubServicos($subServicos)
{
$this->subServicos = $subServicos;
}
public function getServicosUnidade()
{
return $this->servicosUnidade;
}
public function setServicosUnidade(array $servicosUnidade)
{
$this->servicosUnidade = $servicosUnidade;
}
public function getCreatedAt()
{
return $this->createdAt;
}
public function getUpdatedAt()
{
return $this->updatedAt;
}
public function getDeletedAt()
{
return $this->deletedAt;
}
public function setCreatedAt(\DateTime $createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
public function setUpdatedAt(\DateTime $updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
public function setDeletedAt(\DateTime $deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
public function __toString()
{
return $this->nome;
}
public function jsonSerialize()
{
return [
'id' => $this->getId(),
'nome' => $this->getNome(),
'descricao' => $this->getDescricao(),
'peso' => $this->getPeso(),
'ativo' => $this->isAtivo(),
'macro' => $this->getMestre(),
'createdAt' => $this->getCreatedAt() ? $this->getCreatedAt()->format('Y-m-d\TH:i:s') : null,
'updatedAt' => $this->getUpdatedAt() ? $this->getUpdatedAt()->format('Y-m-d\TH:i:s') : null,
'deletedAt' => $this->getDeletedAt() ? $this->getDeletedAt()->format('Y-m-d\TH:i:s') : null,
];
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Servico metadata.
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class ServicoMeta extends EntityMetadata
{
public function getServico()
{
return $this->getEntity();
}
public function setServico(Servico $servico)
{
return $this->setEntity($servico);
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Servico Unidade
* Configuração do serviço na unidade
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class ServicoUnidade implements \JsonSerializable
{
/**
* @var Servico
*/
private $servico;
/**
* @var Unidade
*/
private $unidade;
/**
* @var Departamento
*/
private $departamento;
/**
* @var Local
*/
private $local;
/**
* @var string
*/
private $sigla;
/**
* @var int
*/
private $ativo;
/**
* @var int
*/
private $peso;
/**
* @var bool
*/
private $prioridade;
/**
* @var int
*/
private $incremento;
/**
* @var int
*/
private $numeroInicial;
/**
* @var int
*/
private $numeroFinal;
/**
* @var string
*/
private $mensagem;
public function __construct()
{
$this->prioridade = true;
$this->numeroInicial = 1;
$this->incremento = 1;
}
/**
* @return Servico
*/
public function getServico()
{
return $this->servico;
}
public function setServico(Servico $servico)
{
$this->servico = $servico;
}
/**
* @return Unidade
*/
public function getUnidade()
{
return $this->unidade;
}
public function setUnidade(Unidade $unidade)
{
$this->unidade = $unidade;
}
public function setDepartamento(Departamento $departamento = null)
{
$this->departamento = $departamento;
}
public function getDepartamento()
{
return $this->departamento;
}
/**
* @return Local
*/
public function getLocal()
{
return $this->local;
}
public function setLocal(Local $local)
{
$this->local = $local;
}
public function setAtivo(bool $ativo)
{
$this->ativo = !!$ativo;
}
public function isAtivo(): bool
{
return $this->ativo;
}
public function getPeso()
{
return $this->peso;
}
public function setPeso($peso)
{
$this->peso = $peso;
}
public function setSigla($sigla)
{
$this->sigla = $sigla;
}
public function getSigla()
{
return $this->sigla;
}
public function getPrioridade()
{
return $this->prioridade;
}
public function getIncremento()
{
return $this->incremento;
}
public function getNumeroInicial()
{
return $this->numeroInicial;
}
public function getNumeroFinal()
{
return $this->numeroFinal;
}
public function setPrioridade($prioridade)
{
$this->prioridade = $prioridade;
return $this;
}
public function setIncremento($incremento)
{
$this->incremento = $incremento;
return $this;
}
public function setNumeroInicial($numeroInicial)
{
$this->numeroInicial = $numeroInicial;
return $this;
}
public function setNumeroFinal($numeroFinal)
{
$this->numeroFinal = $numeroFinal;
return $this;
}
public function getMensagem()
{
return $this->mensagem;
}
public function setMensagem($mensagem)
{
$this->mensagem = $mensagem;
return $this;
}
public function __toString()
{
return $this->sigla.' - '.$this->getServico()->getNome();
}
public function jsonSerialize()
{
return [
'sigla' => $this->getSigla(),
'peso' => $this->getPeso(),
'local' => $this->getLocal(),
'servico' => $this->getServico(),
'departamento' => $this->getDepartamento(),
'ativo' => $this->isAtivo(),
'prioridade' => $this->getPrioridade(),
'mensagem' => $this->getMensagem(),
'numeroInicial' => $this->getNumeroInicial(),
'numeroFinal' => $this->getNumeroFinal(),
'incremento' => $this->getIncremento()
];
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Servico Usuario
* Configuração do serviço que o usuário atende
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class ServicoUsuario implements \JsonSerializable
{
/**
* @var Servico
*/
private $servico;
/**
* @var Unidade
*/
private $unidade;
/**
* @var Usuario
*/
private $usuario;
/**
* @var int
*/
private $peso;
public function __construct()
{
}
public function getServico()
{
return $this->servico;
}
public function setServico($servico)
{
$this->servico = $servico;
}
public function getUnidade()
{
return $this->unidade;
}
public function setUnidade($unidade)
{
$this->unidade = $unidade;
}
/**
* @return Usuario
*/
public function getUsuario()
{
return $this->usuario;
}
public function setUsuario($usuario)
{
$this->usuario = $usuario;
}
public function getPeso()
{
return $this->peso;
}
public function setPeso($peso)
{
$this->peso = $peso;
return $this;
}
public function jsonSerialize()
{
return [
'peso' => $this->getPeso(),
'servico' => $this->getServico(),
];
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Unidade de atendimento.
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class Unidade implements \JsonSerializable
{
/**
* @var mixed
*/
protected $id;
/**
* @var string
*/
private $nome;
/**
* @var string
*/
private $descricao;
/**
* @var bool
*/
private $ativo;
/**
* @var ConfiguracaoImpressao
*/
private $impressao;
/**
* @var \DateTime
*/
private $createdAt;
/**
* @var \DateTime
*/
private $updatedAt;
/**
* @var \DateTime
*/
private $deletedAt;
public function __construct()
{
$this->ativo = true;
$this->impressao = new ConfiguracaoImpressao($this);
}
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
return $this;
}
public function getDescricao()
{
return $this->descricao;
}
public function setDescricao($descricao)
{
$this->descricao = $descricao;
return $this;
}
public function setNome($nome)
{
$this->nome = $nome;
}
public function getNome()
{
return $this->nome;
}
public function isAtivo(): bool
{
return $this->ativo;
}
public function setAtivo(bool $ativo)
{
$this->ativo = $ativo;
}
public function getImpressao()
{
return $this->impressao;
}
public function getCreatedAt()
{
return $this->createdAt;
}
public function getUpdatedAt()
{
return $this->updatedAt;
}
public function getDeletedAt()
{
return $this->deletedAt;
}
public function setCreatedAt(\DateTime $createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
public function setUpdatedAt(\DateTime $updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
public function setDeletedAt(\DateTime $deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
public function __toString()
{
return $this->getNome();
}
public function jsonSerialize()
{
return [
'id' => $this->getId(),
'nome' => $this->getNome(),
'descricao' => $this->getDescricao(),
'ativo' => $this->isAtivo(),
'impressao' => $this->getImpressao(),
'createdAt' => $this->getCreatedAt() ? $this->getCreatedAt()->format('Y-m-d\TH:i:s') : null,
'updatedAt' => $this->getUpdatedAt() ? $this->getUpdatedAt()->format('Y-m-d\TH:i:s') : null,
'deletedAt' => $this->getDeletedAt() ? $this->getDeletedAt()->format('Y-m-d\TH:i:s') : null,
];
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Unidade metadata.
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class UnidadeMeta extends EntityMetadata
{
public function getUnidade()
{
return $this->getEntity();
}
public function setUnidade(Unidade $unidade)
{
return $this->setEntity($unidade);
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
use DateTime;
use Symfony\Component\Security\Core\Encoder\EncoderAwareInterface;
use Symfony\Component\Security\Core\User\EquatableInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* Usuario
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class Usuario implements
\Serializable,
\JsonSerializable,
UserInterface,
EquatableInterface,
EncoderAwareInterface
{
/**
* @var mixed
*/
protected $id;
/**
* @var string
*/
private $login;
/**
* @var string
*/
private $nome;
/**
* @var string
*/
private $sobrenome;
/**
* @var string
*/
private $email;
/**
* @var string
*/
private $senha;
/**
* @var bool
*/
private $ativo;
/**
* @var DateTime
*/
private $ultimoAcesso;
/**
* @var string
*/
private $ip;
/**
* @var string
*/
private $sessionId;
/**
* @var Lotacao[]
*/
private $lotacoes;
/**
* @var Lotacao
*/
private $lotacao;
/**
* @var bool
*/
private $admin;
/**
* @var string
*/
private $algorithm;
/**
* @var string
*/
private $salt;
/**
* @var array
*/
private $roles = [];
/**
* @var \DateTime
*/
private $createdAt;
/**
* @var \DateTime
*/
private $updatedAt;
/**
* @var \DateTime
*/
private $deletedAt;
private $permissoes;
public function __construct()
{
$this->ativo = true;
$this->lotacoes = new \Doctrine\Common\Collections\ArrayCollection();
}
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
return $this;
}
public function setLogin($login)
{
$this->login = $login;
return $this;
}
public function getLogin()
{
return $this->login;
}
public function setNome($nome)
{
$this->nome = $nome;
return $this;
}
public function getNome()
{
return $this->nome;
}
public function setSobrenome($sobrenome)
{
$this->sobrenome = $sobrenome;
return $this;
}
public function getSobrenome()
{
return $this->sobrenome;
}
/**
* Retorna o nome completo do usuario (nome + sobrenome).
*
* @return string
*/
public function getNomeCompleto()
{
return $this->nome . ' ' . $this->sobrenome;
}
public function getEmail()
{
return $this->email;
}
public function setEmail($email)
{
$this->email = $email;
return $this;
}
public function getSenha()
{
return $this->senha;
}
public function setSenha($senha)
{
$this->senha = $senha;
return $this;
}
public function setAtivo(bool $ativo)
{
$this->ativo = $ativo;
return $this;
}
public function getLotacao()
{
return $this->lotacao;
}
public function setLotacao(Lotacao $lotacao = null)
{
$this->lotacao = $lotacao;
return $this;
}
public function getLotacoes()
{
return $this->lotacoes;
}
public function setSalt($salt)
{
$this->salt = $salt;
return $this;
}
public function setLotacoes($lotacoes)
{
$this->lotacoes = $lotacoes;
return $this;
}
public function addLotacoe(Lotacao $lotacao)
{
$lotacao->setUsuario($this);
$this->getLotacoes()->add($lotacao);
}
public function removeLotacoe(Lotacao $lotacao)
{
$this->getLotacoes()->removeElement($lotacao);
}
public function isAtivo(): bool
{
return (bool) $this->ativo;
}
public function getUltimoAcesso()
{
return $this->ultimoAcesso;
}
public function setUltimoAcesso($ultimoAcesso)
{
$this->ultimoAcesso = $ultimoAcesso;
return $this;
}
public function getIp()
{
return $this->ip;
}
public function setIp($ip)
{
$this->ip = $ip;
return $this;
}
public function getSessionId()
{
return $this->sessionId;
}
public function setSessionId($sessionId)
{
$this->sessionId = $sessionId;
return $this;
}
public function getAlgorithm()
{
return $this->algorithm;
}
public function setAlgorithm($algorithm)
{
$this->algorithm = $algorithm;
return $this;
}
public function isAdmin()
{
return $this->admin;
}
public function setAdmin($admin)
{
$this->admin = $admin;
return $this;
}
public function getCreatedAt()
{
return $this->createdAt;
}
public function getUpdatedAt()
{
return $this->updatedAt;
}
public function getDeletedAt()
{
return $this->deletedAt;
}
public function setCreatedAt(\DateTime $createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
public function setUpdatedAt(\DateTime $updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
public function setDeletedAt(\DateTime $deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
public function isEnabled()
{
return !$this->getDeletedAt() && $this->isAtivo();
}
public function eraseCredentials()
{
}
public function getPassword()
{
return $this->getSenha();
}
public function getRoles()
{
return $this->roles;
}
public function addRole($role)
{
$this->roles[] = $role;
return $this;
}
public function getSalt()
{
return $this->salt;
}
public function getUsername()
{
return $this->getLogin();
}
public function getEncoderName()
{
return $this->algorithm;
}
public function isEqualTo(UserInterface $user)
{
if (!$user instanceof Usuario) {
return false;
}
if ($this->getPassword() !== $user->getPassword()) {
return false;
}
if ($this->getSalt() !== $user->getSalt()) {
return false;
}
if ($this->getUsername() !== $user->getUsername()) {
return false;
}
if ($this->isEnabled() !== $user->isEnabled()) {
return false;
}
if ($this->getSessionId() !== $user->getSessionId()) {
return false;
}
return true;
}
public function serialize()
{
return serialize([
$this->id,
$this->login,
$this->nome,
$this->sessionId,
$this->senha,
$this->salt,
$this->ativo,
]);
}
public function unserialize($serialized)
{
list (
$this->id,
$this->login,
$this->nome,
$this->sessionId,
$this->senha,
$this->salt,
$this->ativo,
) = unserialize($serialized);
}
public function jsonSerialize()
{
return [
'id' => $this->getId(),
'login' => $this->getLogin(),
'nome' => $this->getNome(),
'sobrenome' => $this->getSobrenome(),
'ativo' => $this->isAtivo(),
'createdAt' => $this->getCreatedAt() ? $this->getCreatedAt()->format('Y-m-d\TH:i:s') : null,
'updatedAt' => $this->getUpdatedAt() ? $this->getUpdatedAt()->format('Y-m-d\TH:i:s') : null,
'deletedAt' => $this->getDeletedAt() ? $this->getDeletedAt()->format('Y-m-d\TH:i:s') : null,
];
}
public function __tostring()
{
return (string) $this->getLogin();
}
public function getAtivo(): ?bool
{
return $this->ativo;
}
public function getAdmin(): ?bool
{
return $this->admin;
}
public function getPermissoes(): ?array
{
return $this->permissoes;
}
public function setPermissoes(?array $permissoes): self
{
$this->permissoes = $permissoes;
return $this;
}
public function addLotaco(Lotacao $lotaco): self
{
if (!$this->lotacoes->contains($lotaco)) {
$this->lotacoes[] = $lotaco;
$lotaco->setUsuario($this);
}
return $this;
}
public function removeLotaco(Lotacao $lotaco): self
{
if ($this->lotacoes->removeElement($lotaco)) {
// set the owning side to null (unless already changed)
if ($lotaco->getUsuario() === $this) {
$lotaco->setUsuario(null);
}
}
return $this;
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* Usuario metadata.
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class UsuarioMeta extends EntityMetadata
{
/**
* @return Usuario
*/
public function getUsuario()
{
return $this->getEntity();
}
public function setUsuario(Usuario $usuario)
{
return $this->setEntity($usuario);
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
/**
* View Atendimento
* União dos atendimentos atuais e do histórico
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class ViewAtendimento extends AbstractAtendimento
{
/**
* @var AtendimentoCodificadoHistorico[]
*/
private $codificados;
public function __construct()
{
$this->codificados = new ArrayCollection();
}
public function getCodificados()
{
return $this->codificados;
}
public function setCodificados(Collection $codificados)
{
$this->codificados = $codificados;
return $this;
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Entity;
/**
* view Atendimento Codificado
* União dos atendimentos atuais e do histórico
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class ViewAtendimentoCodificado extends AbstractAtendimentoCodificado
{
/**
* @var ViewAtendimento
*/
private $atendimento;
public function getAtendimento()
{
return $this->atendimento;
}
public function setAtendimento(AbstractAtendimento $atendimento)
{
$this->atendimento = $atendimento;
return $this;
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Event;
/**
* AdvancedEvent
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class AdvancedEvent extends Event implements
LoggerAwareEventInterface,
StorageAwareEventInterface,
UserAwareEventInterface
{
use LoggerAwareTrait,
StorageAwareTrait,
UserAwareTrait;
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Event;
/**
* Event
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class Event implements EventInterface
{
/**
* @var string
*/
private $name;
/**
* @var mixed
*/
private $data;
public function __construct(string $name, $data)
{
$this->name = $name;
$this->data = $data;
}
/**
* {@inheritdoc}
*/
public function getData()
{
return $this->data;
}
/**
* {@inheritdoc}
*/
public function getName(): string
{
return $this->name;
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Event;
/**
* EventDispatcherInterface
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
interface EventDispatcherInterface
{
/**
* @param EventInterface $event
* @return bool
*/
public function dispatch(EventInterface $event): bool;
/**
*
* @param string $eventName
* @param mixed $eventData
* @param bool $advancedEvent
* @return bool
*/
public function createAndDispatch(string $eventName, $eventData, bool $advancedEvent = false): bool;
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Event;
/**
* Event
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
interface EventInterface
{
/**
* Returns event name
*
* @return string
*/
public function getName(): string;
/**
* Returns event data
*
* @return mixed
*/
public function getData();
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Event;
use Psr\Log\LoggerInterface;
/**
* LoggerAwareEventInterface
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
interface LoggerAwareEventInterface extends EventInterface
{
/**
* @param LoggerInterface $logger
*/
public function setLogger(LoggerInterface $logger);
/**
* @return LoggerInterface
*/
public function getLogger(): LoggerInterface;
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Event;
use Psr\Log\LoggerInterface;
/**
* LoggerAwareTrait
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
trait LoggerAwareTrait
{
/**
* @var LoggerInterface
*/
private $storage;
/**
* {@inheritdoc}
*/
public function setLogger(LoggerInterface $storage)
{
$this->storage = $storage;
return $this;
}
/**
* {@inheritdoc}
*/
public function getLogger(): LoggerInterface
{
return $this->storage;
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Event;
use Novosga\Infrastructure\StorageInterface;
/**
* StorageAwareEventInterface
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
interface StorageAwareEventInterface extends EventInterface
{
/**
* @param StorageInterface $storage
*/
public function setStorage(StorageInterface $storage);
/**
* @return StorageInterface
*/
public function getStorage(): StorageInterface;
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Event;
use Novosga\Infrastructure\StorageInterface;
/**
* StorageAwareTrait
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
trait StorageAwareTrait
{
/**
* @var StorageInterface
*/
private $storage;
/**
* {@inheritdoc}
*/
public function setStorage(StorageInterface $storage)
{
$this->storage = $storage;
return $this;
}
/**
* {@inheritdoc}
*/
public function getStorage(): StorageInterface
{
return $this->storage;
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Event;
use Novosga\Entity\Usuario;
/**
* UserAwareEventInterface
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
interface UserAwareEventInterface extends EventInterface
{
/**
* @param Usuario $user
*/
public function setUser(Usuario $user);
/**
* @return Usuario
*/
public function getUser(): Usuario;
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Event;
use Novosga\Entity\Usuario;
/**
* UserAwareTrait
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
trait UserAwareTrait
{
/**
* @var Usuario
*/
private $user;
/**
* {@inheritdoc}
*/
public function setUser(Usuario $user)
{
$this->user = $user;
return $this;
}
/**
* {@inheritdoc}
*/
public function getUser(): Usuario
{
return $this->user;
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Http;
use Exception;
/**
* Envelope
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class Envelope implements \JsonSerializable
{
/**
* @var bool
*/
private $success;
/**
* @var string
*/
private $sessionStatus;
/**
* @var mixed
*/
private $data;
/**
* @var string
*/
private $message;
/**
* @var string
*/
private $detail;
public function __construct()
{
$this->success = true;
$this->sessionStatus = 'active';
}
public function isSuccess()
{
return $this->success;
}
public function getSessionStatus()
{
return $this->sessionStatus;
}
public function getData()
{
return $this->data;
}
public function getMessage()
{
return $this->message;
}
public function setSuccess($success)
{
$this->success = $success;
return $this;
}
public function setSessionStatus($session)
{
$this->sessionStatus = $session;
return $this;
}
public function setData($data)
{
$this->data = $data;
return $this;
}
public function setMessage($message)
{
$this->message = $message;
return $this;
}
public function getDetail()
{
return $this->detail;
}
public function setDetail($detail)
{
$this->detail = $detail;
return $this;
}
public function exception(Exception $e, $debug = false)
{
$this
->setSuccess(false)
->setMessage($e->getMessage());
if ($debug) {
$detail = "{$e->getFile()}:{$e->getLine()}\n{$e->getTraceAsString()}";
$this->setDetail($detail);
}
return $this;
}
public function jsonSerialize()
{
$body = [
'success' => $this->success,
'sessionStatus' => $this->sessionStatus,
'time' => time() * 1000,
];
if ($this->success) {
$body['data'] = $this->data;
} else {
$body['message'] = $this->message;
if ($this->detail) {
$body['detail'] = $this->detail;
}
}
return $body;
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Infrastructure;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Common\Persistence\ObjectRepository;
use Novosga\Entity\Agendamento;
use Novosga\Entity\Atendimento;
use Novosga\Entity\Unidade;
/**
* StorageInterface
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
interface StorageInterface
{
/**
* @return ObjectManager
*/
public function getManager(): ObjectManager;
/**
* @param string $className
* @return ObjectRepository
*/
public function getRepository(string $className): ObjectRepository;
/**
* Gera uma nova senha de atendimento
* @param Atendimento $atendimento
* @param Agendamento $agendamento
*/
public function distribui(Atendimento $atendimento, Agendamento $agendamento = null);
/**
* @param Atendimento $atendimento
*/
public function chamar(Atendimento $atendimento);
/**
*
* @param Atendimento $atendimento
* @param array $codificados
* @param Atendimento $novoAtendimento
*/
public function encerrar(Atendimento $atendimento, array $codificados, Atendimento $novoAtendimento = null);
/**
* Move os dados de atendimento para o histórico
* @param Unidade $unidade
*/
public function acumularAtendimentos(?Unidade $unidade, array $ctx = []);
/**
* Apaga todos os dados de atendimentos
* @param Unidade $unidade
*/
public function apagarDadosAtendimento(?Unidade $unidade, array $ctx = []);
}
Copyright (c) 2012-2016 Rogerio Lino
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Module;
use Symfony\Component\HttpKernel\Bundle\Bundle;
/**
* BaseModule
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
abstract class BaseModule extends Bundle implements ModuleInterface
{
public function getKeyName()
{
$namespace = $this->getNamespace();
$tokens = explode('\\', str_replace('Bundle', '', $namespace));
return strtolower(implode('.', $tokens));
}
public function getRoleName()
{
$keyName = $this->getKeyName();
return 'ROLE_' . strtoupper(str_replace('.', '_', $keyName));
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Module;
/**
* ModuleInterface
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
interface ModuleInterface
{
public function getKeyName();
public function getRoleName();
public function getIconName();
public function getDisplayName();
public function getName();
public function getHomeRoute();
}
# core
NovoSGA core.
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Repository;
use Doctrine\Common\Persistence\ObjectRepository;
use Novosga\Entity\Atendimento;
use Novosga\Entity\Servico;
use Novosga\Entity\Unidade;
/**
* AtendimentoRepositoryInterface
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
interface AtendimentoRepositoryInterface extends ObjectRepository
{
/**
* Retorna o par do id do serviço e o total de atendimentos
* @param Unidade $unidade
* @param Servico[]|int[] $servicos
* @param string $status
* @return array
*/
public function countByServicos(Unidade $unidade, array $servicos, $status = null);
/**
*
* @param Unidade $unidade
* @param Servico $servico
* @return Atendimento
*/
public function getUltimo(Unidade $unidade, Servico $servico = null);
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Repository;
use Doctrine\Common\Persistence\ObjectRepository;
/**
* ClienteRepositoryInterface
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
interface ClienteRepositoryInterface extends ObjectRepository
{
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Repository;
use Doctrine\Common\Persistence\ObjectRepository;
/**
* DepartamentoRepositoryInterface
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
interface DepartamentoRepositoryInterface extends ObjectRepository
{
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Repository;
use Novosga\Entity\Metadata;
use Doctrine\Common\Persistence\ObjectRepository;
/**
* MetadataRepositoryInterface
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
interface EntityMetadataRepositoryInterface extends ObjectRepository
{
/**
* @param mixed $entity
* @param string $namespace
* @param string $name
* @return Metadata|null
*/
public function get($entity, string $namespace, string $name);
/**
* @param mixed $entity
* @param string $namespace
* @param string $name
* @param mixed $value
* @return Metadata
*/
public function set($entity, string $namespace, string $name, $value);
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Repository;
use Doctrine\Common\Persistence\ObjectRepository;
/**
* LocalRepositoryInterface
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
interface LocalRepositoryInterface extends ObjectRepository
{
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Repository;
use Doctrine\Common\Persistence\ObjectRepository;
/**
* LotacaoRepositoryInterface
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
interface LotacaoRepositoryInterface extends ObjectRepository
{
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Repository;
use Novosga\Entity\Metadata;
use Doctrine\Common\Persistence\ObjectRepository;
/**
* MetadataRepositoryInterface
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
interface MetadataRepositoryInterface extends ObjectRepository
{
/**
* @param string $namespace
* @param string $name
* @return Metadata|null
*/
public function get(string $namespace, string $name);
/**
* @param string $namespace
* @param string $name
* @param mixed $value
* @return Metadata
*/
public function set(string $namespace, string $name, $value);
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Repository;
use Doctrine\Common\Persistence\ObjectRepository;
/**
* PerfilRepositoryInterface
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
interface PerfilRepositoryInterface extends ObjectRepository
{
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Repository;
use Doctrine\Common\Persistence\ObjectRepository;
/**
* PrioridadeRepositoryInterface
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
interface PrioridadeRepositoryInterface extends ObjectRepository
{
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Repository;
use Doctrine\Common\Persistence\ObjectRepository;
use Novosga\Entity\Servico;
/**
* ServicoRepositoryInterface
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
interface ServicoRepositoryInterface extends ObjectRepository
{
/**
* Retorna os subserviços ativos do serviço informado
* @param Servico $servico
* @return Servico[]
*/
public function getSubservicos(Servico $servico);
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Repository;
use Novosga\Entity\Unidade;
use Novosga\Entity\Servico;
use Novosga\Entity\ServicoUnidade;
use Doctrine\Common\Persistence\ObjectRepository;
/**
* ServicoUnidadeRepositoryInterface
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
interface ServicoUnidadeRepositoryInterface extends ObjectRepository
{
/**
* Retorna todos os serviços da unidade
*
* @param Unidade|int $unidade
* @return ServicoUnidade[]
*/
public function getAll($unidade);
/**
* Retorna o relacionamento entre o serviço e a unidade.
*
* @param Unidade|int $unidade
* @param Servico|int $servico
* @return ServicoUnidade|null
*/
public function get($unidade, $servico);
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Repository;
use Novosga\Entity\Usuario;
use Novosga\Entity\Unidade;
use Novosga\Entity\Servico;
use Novosga\Entity\ServicoUsuario;
use Doctrine\Common\Persistence\ObjectRepository;
/**
* ServicoUsuarioRepositoryInterface
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
interface ServicoUsuarioRepositoryInterface extends ObjectRepository
{
/**
* Retorna todos os serviços do usuario
*
* @param Usuario|int $usuario
* @return ServicoUsuario[]
*/
public function getAll($usuario, $unidade);
/**
* Retorna o relacionamento entre o serviço e a usuario.
*
* @param Usuario|int $usuario
* @param Unidade|int $unidade
* @param Servico|int $servico
* @return ServicoUsuario|null
*/
public function get($usuario, $unidade, $servico);
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Repository;
use Novosga\Entity\Usuario;
use Novosga\Entity\Unidade;
use Doctrine\Common\Persistence\ObjectRepository;
/**
* UnidadeRepositoryInterface
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
interface UnidadeRepositoryInterface extends ObjectRepository
{
/**
* Retorna as unidades disponíveis para o usuário
* @param Usuario $usuario
* @return Unidade[]
*/
public function findByUsuario(Usuario $usuario);
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Repository;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Persistence\ObjectRepository;
use Novosga\Entity\Unidade;
use Novosga\Entity\Usuario;
use Novosga\Entity\ServicoUnidade;
/**
* UsuarioRepositoryInterface
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
interface UsuarioRepositoryInterface extends ObjectRepository
{
/**
* Retorna os usuários que tem lotação na unidade
* @param Unidade $unidade
* @param Criteria $criteria
* @return Usuario[]
*/
public function findByUnidade(Unidade $unidade, Criteria $criteria = null);
/**
* Retorna os usuários que atendem o serviço da unidade
* @param ServicoUnidade $servicoUnidade
* @param Criteria $criteria
* @return Usuario[]
*/
public function findByServicoUnidade(ServicoUnidade $servicoUnidade, Criteria $criteria = null);
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Service;
use DateTime;
use Exception;
use Novosga\Entity\Agendamento;
use Novosga\Entity\Atendimento;
use Novosga\Entity\AtendimentoCodificado;
use Novosga\Entity\AtendimentoMeta;
use Novosga\Entity\Cliente;
use Novosga\Event\EventDispatcherInterface;
use Novosga\Entity\Local;
use Novosga\Entity\Lotacao;
use Novosga\Entity\PainelSenha;
use Novosga\Entity\Prioridade;
use Novosga\Entity\Servico;
use Novosga\Entity\ServicoUnidade;
use Novosga\Entity\Unidade;
use Novosga\Entity\Usuario;
use Novosga\Infrastructure\StorageInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Translation\TranslatorInterface;
/**
* AtendimentoService.
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class AtendimentoService extends StorageAwareService
{
// estados do atendimento
const SENHA_EMITIDA = 'emitida';
const CHAMADO_PELA_MESA = 'chamado';
const ATENDIMENTO_INICIADO = 'iniciado';
const ATENDIMENTO_ENCERRADO = 'encerrado';
const NAO_COMPARECEU = 'nao_compareceu';
const SENHA_CANCELADA = 'cancelada';
const ERRO_TRIAGEM = 'erro_triagem';
// resolucoes
const RESOLVIDO = 'resolvido';
const PENDENTE = 'pendente';
/**
* @var EventDispatcherInterface
*/
private $dispatcher;
/**
* @var LoggerInterface
*/
private $logger;
/**
* @var TranslatorInterface
*/
private $translator;
public function __construct(
StorageInterface $storage,
EventDispatcherInterface $dispatcher,
LoggerInterface $logger,
TranslatorInterface $translator
) {
parent::__construct($storage);
$this->dispatcher = $dispatcher;
$this->logger = $logger;
$this->translator = $translator;
}
public function situacoes()
{
return [
self::SENHA_EMITIDA => $this->translator->trans('ticket.status.generated'),
self::CHAMADO_PELA_MESA => $this->translator->trans('ticket.status.called'),
self::ATENDIMENTO_INICIADO => $this->translator->trans('ticket.status.started'),
self::ATENDIMENTO_ENCERRADO => $this->translator->trans('ticket.status.finished'),
self::NAO_COMPARECEU => $this->translator->trans('ticket.status.no_show'),
self::SENHA_CANCELADA => $this->translator->trans('ticket.status.cancelled'),
self::ERRO_TRIAGEM => $this->translator->trans('ticket.status.error'),
];
}
public function resolucoes()
{
return [
self::RESOLVIDO => $this->translator->trans('ticket.resolution.solved'),
self::PENDENTE => $this->translator->trans('ticket.resolution.pending'),
];
}
public function nomeSituacao($status)
{
$arr = $this->situacoes();
return $arr[$status];
}
/**
* Cria ou retorna um metadado do atendimento caso o $value seja null (ou ocultado).
*
* @param Atendimento $atendimento
* @param string $name
* @param string $value
*
* @return AtendimentoMeta
*/
public function meta(Atendimento $atendimento, $name, $value = null)
{
$repo = $this->storage->getRepository(AtendimentoMeta::class);
if ($value === null) {
$metadata = $repo->get($atendimento, $name);
} else {
$metadata = $repo->set($atendimento, $name, $value);
}
return $metadata;
}
/**
* Adiciona uma nova senha na fila de chamada do painel de senhas.
*
* @param Unidade $unidade
* @param Atendimento $atendimento
*/
public function chamarSenha(Unidade $unidade, Atendimento $atendimento)
{
$servico = $atendimento->getServico();
$su = $this->storage
->getRepository(ServicoUnidade::class)
->get($unidade, $servico);
$senha = new PainelSenha();
$senha->setUnidade($unidade);
$senha->setServico($servico);
$senha->setNumeroSenha($atendimento->getSenha()->getNumero());
$senha->setSiglaSenha($atendimento->getSenha()->getSigla());
$senha->setMensagem($su->getMensagem() . '');
// local
$senha->setLocal($atendimento->getLocal()->getNome());
$senha->setNumeroLocal($atendimento->getNumeroLocal());
// prioridade
$senha->setPeso($atendimento->getPrioridade()->getPeso());
$senha->setPrioridade($atendimento->getPrioridade()->getNome());
// cliente
if ($atendimento->getCliente()) {
$senha->setNomeCliente($atendimento->getCliente()->getNome());
$senha->setDocumentoCliente($atendimento->getCliente()->getDocumento());
}
$this->dispatcher->createAndDispatch('panel.pre-call', [$atendimento, $senha], true);
$om = $this->storage->getManager();
$om->persist($senha);
$om->flush();
$this->dispatcher->createAndDispatch('panel.call', [$atendimento, $senha], true);
}
/**
* Move os registros da tabela atendimento para a tabela de historico de atendimentos.
* Se a unidade não for informada, será acumulado serviços de todas as unidades.
*
* @param Unidade $unidade
* @param array $ctx
*
* @throws Exception
*/
public function acumularAtendimentos(?Unidade $unidade, $ctx = [])
{
$this->dispatcher->createAndDispatch('attending.pre-reset', $unidade, true);
$this->storage->acumularAtendimentos($unidade, $ctx);
$this->dispatcher->createAndDispatch('attending.reset', $unidade, true);
}
public function buscaAtendimento(Unidade $unidade, $id)
{
$atendimento = $this->storage
->getManager()
->createQueryBuilder()
->select('e')
->from(Atendimento::class, 'e')
->where('e.id = :id')
->andWhere('e.unidade = :unidade')
->setParameters([
'id' => (int) $id,
'unidade' => $unidade->getId()
])
->getQuery()
->getOneOrNullResult();
return $atendimento;
}
public function buscaAtendimentos(Unidade $unidade, $senha)
{
$i = 0;
$sigla = '';
do {
$char = substr($senha, $i, 1);
$isAlpha = ctype_alpha($char);
if ($isAlpha) {
$sigla .= strtoupper($char);
}
$i++;
} while ($i < strlen($senha) && $isAlpha);
$numero = (int) substr($senha, $i - 1);
$qb = $this
->storage
->getManager()
->createQueryBuilder()
->select([
'e', 's', 'ut', 'u'
])
->from(Atendimento::class, 'e')
->join('e.servico', 's')
->join('e.usuarioTriagem', 'ut')
->leftJoin('e.usuario', 'u')
->where(':numero = 0 OR e.senha.numero = :numero')
->andWhere('e.unidade = :unidade')
->orderBy('e.id', 'ASC')
->setParameters([
'numero' => $numero,
'unidade' => $unidade->getId(),
]);
if (!empty($sigla)) {
$qb
->andWhere('e.senha.sigla = :sigla')
->setParameter('sigla', $sigla);
}
$rs = $qb
->getQuery()
->getResult();
return $rs;
}
public function chamar(Atendimento $atendimento, Usuario $usuario, Local $local, int $numeroLocal)
{
$this->dispatcher->createAndDispatch('attending.pre-call', [$atendimento, $usuario, $local, $numeroLocal], true);
$atendimento
->setUsuario($usuario)
->setLocal($local)
->setNumeroLocal($numeroLocal)
->setStatus(self::CHAMADO_PELA_MESA)
->setDataChamada(new DateTime());
$tempoEspera = $atendimento->getDataChamada()->diff($atendimento->getDataChegada());
$atendimento->setTempoEspera($tempoEspera);
try {
$this->storage->chamar($atendimento);
$this->dispatcher->createAndDispatch('attending.call', [$atendimento, $usuario], true);
} catch (Exception $e) {
return false;
}
return true;
}
/**
* Retorna o atendimento em andamento do usuario informado.
*
* @param int|Usuario $usuario
* @param int|Unidade $unidade
*
* @return Atendimento
*/
public function atendimentoAndamento($usuario, $unidade = null)
{
$status = [
self::CHAMADO_PELA_MESA,
self::ATENDIMENTO_INICIADO,
];
try {
$qb = $this->storage
->getManager()
->createQueryBuilder()
->select('e')
->from(Atendimento::class, 'e')
->where('e.usuario = :usuario')
->andWhere('e.status IN (:status)');
$params = [
'usuario' => $usuario,
'status' => $status,
];
if ($unidade) {
$qb->andWhere('e.unidade = :unidade');
$params['unidade'] = $unidade;
}
return $qb
->setParameters($params)
->getQuery()
->getOneOrNullResult();
} catch (\Doctrine\ORM\NonUniqueResultException $e) {
/*
* caso tenha mais de um atendimento preso ao usuario,
* libera os atendimentos e retorna null para o atendente chamar de novo.
* BUG #213
*/
$this->storage
->getManager()
->createQueryBuilder()
->update(Atendimento::class, 'e')
->set('e.status', ':status')
->set('e.usuario', ':null')
->where('e.usuario = :usuario')
->andWhere('e.status IN (:status)')
->setParameters([
'status' => 1,
'null' => null,
'usuario' => $usuario,
'status' => $status
])
->getQuery()
->execute();
return;
}
}
/**
* Gera um novo atendimento.
*
* @param int|Unidade $unidade
* @param int|Usuario $usuario
* @param int|Servico $servico
* @param int|Prioridade $prioridade
* @param Cliente|null $cliente
* @param Agendamento|null $agendamento
*
* @throws Exception
*
* @return Atendimento
*/
public function distribuiSenha($unidade, $usuario, $servico, $prioridade, Cliente $cliente = null, Agendamento $agendamento = null)
{
$om = $this->storage->getManager();
// verificando a unidade
if (!($unidade instanceof Unidade)) {
$unidade = $om->find(Unidade::class, $unidade);
}
if (!$unidade) {
$error = $this->translator->trans('error.invalid_unity');
throw new Exception($error);
}
// verificando o usuario na sessao
if (!($usuario instanceof Usuario)) {
$usuario = $om->find(Usuario::class, $usuario);
}
if (!$usuario) {
$error = $this->translator->trans('error.invalid_user');
throw new Exception($error);
}
// verificando o servico
if (!($servico instanceof Servico)) {
$servico = $om->find(Servico::class, $servico);
}
if (!$servico) {
$error = $this->translator->trans('error.invalid_service');
throw new Exception($error);
}
// verificando a prioridade
if (!($prioridade instanceof Prioridade)) {
$prioridade = $om->find(Prioridade::class, $prioridade);
}
if (!$prioridade || !$prioridade->isAtivo()) {
$error = $this->translator->trans('error.invalid_priority');
throw new Exception($error);
}
if (!$usuario->isAdmin()) {
$lotacao = $om
->getRepository(Lotacao::class)
->findOneBy([
'usuario' => $usuario,
'unidade' => $unidade,
]);
if (!$lotacao) {
$error = $this->translator->trans('error.user_unity_ticket_permission');
throw new Exception($error);
}
}
$su = $this->checkServicoUnidade($unidade, $servico);
$atendimento = new Atendimento();
$atendimento
->setServico($servico)
->setUnidade($unidade)
->setPrioridade($prioridade)
->setUsuarioTriagem($usuario)
->setStatus(self::SENHA_EMITIDA)
->setLocal(null)
->setNumeroLocal(null);
$atendimento->getSenha()->setSigla($su->getSigla());
if ($agendamento) {
$data = $agendamento->getData()->format('Y-m-d');
$hora = $agendamento->getHora()->format('H:i');
$dtAge = DateTime::createFromFormat('Y-m-d H:i', "{$data} {$hora}");
$atendimento->setDataAgendamento($dtAge);
}
$clienteValido = $this->getClienteValido($cliente);
if ($clienteValido) {
$atendimento->setCliente($clienteValido);
}
$this->dispatcher->createAndDispatch('attending.pre-create', [$atendimento], true);
try {
$this->storage->distribui($atendimento, $agendamento);
} catch (Exception $e) {
$this->logger->error($e->getMessage());
}
if (!$atendimento->getId()) {
$error = $this->translator->trans('error.new_ticket');
throw new Exception($error);
}
return $atendimento;
}
/**
* @param Atendimento $atendimento
* @param Usuario $usuario
* @throws Exception
*/
public function iniciarAtendimento(Atendimento $atendimento, Usuario $usuario)
{
$status = $atendimento->getStatus();
if (!in_array($status, [ self::CHAMADO_PELA_MESA ])) {
throw new Exception('Não pode iniciar esse atendimento.');
}
$atendimento->setStatus(self::ATENDIMENTO_INICIADO);
$atendimento->setDataInicio(new DateTime());
$atendimento->setUsuario($usuario);
$tempoDeslocamento = $atendimento->getDataInicio()->diff($atendimento->getDataChamada());
$atendimento->setTempoDeslocamento($tempoDeslocamento);
$om = $this->storage->getManager();
$om->merge($atendimento);
$om->flush();
}
/**
* @param Atendimento $atendimento
* @param Usuario $usuario
* @throws Exception
*/
public function naoCompareceu(Atendimento $atendimento, Usuario $usuario)
{
$status = $atendimento->getStatus();
if (!in_array($status, [ self::CHAMADO_PELA_MESA ])) {
throw new Exception('Não pode iniciar esse atendimento.');
}
$atendimento->setDataFim(new DateTime());
$atendimento->setStatus(self::NAO_COMPARECEU);
$atendimento->setUsuario($usuario);
$tempoPermanencia = $atendimento->getDataFim()->diff($atendimento->getDataChegada());
$tempoAtendimento = new \DateInterval('P0M');
$tempoDeslocamento = new \DateInterval('P0M');
$atendimento->setTempoPermanencia($tempoPermanencia);
$atendimento->setTempoAtendimento($tempoAtendimento);
$atendimento->setTempoDeslocamento($tempoDeslocamento);
$om = $this->storage->getManager();
$om->merge($atendimento);
$om->flush();
}
/**
* Redireciona um atendimento para outro serviço.
*
* @param Atendimento $atendimento
* @param int|Unidade $unidade
* @param int|Servico $servico
* @param int|Usuario $usuario Novo usuário a atender o serviço redirecionado (opcional)
*
* @return Atendimento
*/
public function redirecionar(Atendimento $atendimento, $unidade, $servico, $usuario = null)
{
$status = $atendimento->getStatus();
if (!in_array($status, [ self::ATENDIMENTO_INICIADO, self::ATENDIMENTO_ENCERRADO ])) {
throw new Exception('Não pode redirecionar esse atendimento.');
}
if (!($unidade instanceof Unidade)) {
$unidade = $this->storage
->getRepository(Unidade::class)
->find($unidade);
}
if (!($servico instanceof Servico)) {
$servico = $this->storage
->getRepository(Servico::class)
->find($servico);
}
if ($usuario !== null && !($usuario instanceof Usuario)) {
$usuario = $this->storage
->getRepository(Usuario::class)
->find($usuario);
}
$this->dispatcher->createAndDispatch('attending.pre-redirect', [$atendimento, $unidade, $servico, $usuario], true);
$atendimento->setStatus(self::ERRO_TRIAGEM);
$atendimento->setDataFim(new DateTime());
$tempoPermanencia = $atendimento->getDataFim()->diff($atendimento->getDataChegada());
$tempoAtendimento = new \DateInterval('P0M');
$atendimento->setTempoPermanencia($tempoPermanencia);
$atendimento->setTempoAtendimento($tempoAtendimento);
$novo = $this->copyToRedirect($atendimento, $unidade, $servico, $usuario);
$om = $this->storage->getManager();
$om->merge($atendimento);
$om->persist($novo);
$om->flush();
$this->dispatcher->createAndDispatch('attending.redirect', [$atendimento, $novo], true);
return $novo;
}
/**
* Transfere o atendimento para outro serviço e prioridade.
*
* @param Atendimento $atendimento
* @param Unidade $unidade
* @param int|Servico $novoServico
* @param int|Prioridade $novaPrioridade
*
* @return bool
*/
public function transferir(Atendimento $atendimento, Unidade $unidade, $novoServico, $novaPrioridade)
{
$this->dispatcher->createAndDispatch('attending.pre-transfer', [ $atendimento, $unidade, $novoServico, $novaPrioridade ], true);
// transfere apenas se a data fim for nula (nao finalizados)
$success = $this->storage
->getManager()
->createQueryBuilder()
->update(Atendimento::class, 'e')
->set('e.servico', ':servico')
->set('e.prioridade', ':prioridade')
->where('e.id = :id')
->andWhere('e.unidade = :unidade')
->andWhere('e.dataFim IS NULL')
->setParameters([
'servico' => $novoServico,
'prioridade' => $novaPrioridade,
'id' => $atendimento,
'unidade' => $unidade
])
->getQuery()
->execute() > 0;
if ($success) {
$this->storage->getManager()->refresh($atendimento);
$this->dispatcher->createAndDispatch('attending.transfer', [$atendimento], true);
}
return $success;
}
/**
* Atualiza o status da senha para cancelado.
*
* @param Atendimento $atendimento
* @param Unidade $unidade
*/
public function cancelar(Atendimento $atendimento)
{
if ($atendimento->getDataFim() !== null) {
throw new Exception('Erro ao tentar cancelar um serviço já encerrado.');
}
$this->dispatcher->createAndDispatch('attending.pre-cancel', $atendimento, true);
$now = new DateTime();
$atendimento->setDataFim($now);
if ($atendimento->getDataChegada()) {
$tempoPermanencia = $atendimento->getDataFim()->diff($atendimento->getDataChegada());
} else {
$tempoPermanencia = $atendimento->getDataFim()->diff($now);
}
if ($atendimento->getDataInicio()) {
$tempoAtendimento = $atendimento->getDataFim()->diff($atendimento->getDataInicio());
} else {
$tempoAtendimento = null;
}
$atendimento->setTempoPermanencia($tempoPermanencia);
$atendimento->setTempoAtendimento($tempoAtendimento);
$atendimento->setStatus(self::SENHA_CANCELADA);
$em = $this->storage->getManager();
$em->merge($atendimento);
$em->flush();
$this->dispatcher->createAndDispatch('attending.cancel', $atendimento, true);
}
/**
* Reativa o atendimento para o mesmo serviço e mesma prioridade.
* Só pode reativar atendimentos que foram: Cancelados ou Não Compareceu.
*
* @param Atendimento $atendimento
* @param Unidade $unidade
*
* @return bool
*/
public function reativar(Atendimento $atendimento, Unidade $unidade)
{
$this->dispatcher->createAndDispatch('attending.pre-reactivate', $atendimento, true);
// reativa apenas se estiver finalizada (data fim diferente de nulo)
$success = $this->storage
->getManager()
->createQueryBuilder()
->update(Atendimento::class, 'e')
->set('e.status', ':status')
->set('e.dataFim', ':data')
->set('e.usuario', ':usuario')
->where('e.id = :id')
->andWhere('e.unidade = :unidade')
->andWhere('e.status IN (:statuses)')
->setParameters([
'status' => self::SENHA_EMITIDA,
'data' => null,
'usuario' => null,
'id' => $atendimento,
'unidade' => $unidade,
'statuses' => [self::SENHA_CANCELADA, self::NAO_COMPARECEU],
])
->getQuery()
->execute() > 0;
if ($success) {
$this->storage->getManager()->refresh($atendimento);
$this->dispatcher->createAndDispatch('attending.reactivate', $atendimento, true);
}
return $success;
}
/**
*
* @param Atendimento $atendimento
* @param Unidade $unidade
* @param Servico[] $servicosRealizados
* @param Servico $servicoRedirecionado
* @param Usuario $novoUsuario
* @throws Exception
*/
public function encerrar(
Atendimento $atendimento,
Unidade $unidade,
array $servicosRealizados,
Servico $servicoRedirecionado = null,
Usuario $novoUsuario = null
) {
if ($atendimento->getStatus() !== AtendimentoService::ATENDIMENTO_INICIADO) {
throw new Exception(
sprintf(
'Erro ao tentar encerrar um atendimento nao iniciado (%s)',
$atendimento->getId()
)
);
}
$executados = [];
$servicoRepository = $this->storage->getRepository(Servico::class);
foreach ($servicosRealizados as $s) {
if ($s instanceof Servico) {
$servico = $s;
} else {
$servico = $servicoRepository->find($s);
}
if (!$servico) {
$error = $this->translator->trans('error.invalid_service');
throw new Exception($error);
}
$executado = new AtendimentoCodificado();
$executado->setAtendimento($atendimento);
$executado->setServico($servico);
$executado->setPeso(1);
$executados[] = $executado;
}
$novoAtendimento = null;
// verifica se esta encerrando e redirecionando
if ($servicoRedirecionado) {
$novoAtendimento = $this->copyToRedirect($atendimento, $unidade, $servicoRedirecionado, $novoUsuario);
}
$atendimento->setDataFim(new DateTime);
$atendimento->setStatus(AtendimentoService::ATENDIMENTO_ENCERRADO);
$tempoPermanencia = $atendimento->getDataFim()->diff($atendimento->getDataChegada());
$tempoAtendimento = $atendimento->getDataFim()->diff($atendimento->getDataInicio());
$atendimento->setTempoPermanencia($tempoPermanencia);
$atendimento->setTempoAtendimento($tempoAtendimento);
$this->storage->encerrar($atendimento, $executados, $novoAtendimento);
}
public function alteraStatusAtendimentoUsuario(Usuario $usuario, $novoStatus)
{
$atual = $this->atendimentoAndamento($usuario->getId());
if (!$atual) {
$error = $this->translator->trans('error.no_servicing_available');
throw new Exception($error);
}
$campoData = null;
switch ($novoStatus) {
case AtendimentoService::ATENDIMENTO_INICIADO:
$statusAtual = [ AtendimentoService::CHAMADO_PELA_MESA ];
$campoData = 'dataInicio';
break;
case AtendimentoService::NAO_COMPARECEU:
$statusAtual = [ AtendimentoService::CHAMADO_PELA_MESA ];
$campoData = 'dataFim';
break;
case AtendimentoService::ATENDIMENTO_ENCERRADO:
$statusAtual = [ AtendimentoService::ATENDIMENTO_INICIADO ];
$campoData = 'dataFim';
break;
case AtendimentoService::ERRO_TRIAGEM:
$statusAtual = [
AtendimentoService::ATENDIMENTO_INICIADO,
AtendimentoService::ATENDIMENTO_ENCERRADO,
];
$campoData = 'dataFim';
break;
default:
throw new Exception('Novo status inválido.');
}
if (!is_array($statusAtual)) {
$statusAtual = [$statusAtual];
}
$data = (new DateTime())->format('Y-m-d H:i:s');
$qb = $this->storage
->getManager()
->createQueryBuilder()
->update(Atendimento::class, 'e')
->set('e.status', ':novoStatus');
if ($campoData !== null) {
$qb->set("e.{$campoData}", ':data');
}
$qb
->where('e.id = :id')
->andWhere('e.status IN (:statusAtual)');
$params = [
'novoStatus' => $novoStatus,
'id' => $atual->getId(),
'statusAtual' => $statusAtual
];
if ($campoData !== null) {
$params['data'] = $data;
}
$success = $qb
->setParameters($params)
->getQuery()
->execute() > 0;
if (!$success) {
$error = $this->translator->trans('error.change_status');
throw new Exception($error);
}
$atual->setStatus($novoStatus);
return $atual;
}
public function checkServicoUnidade(Unidade $unidade, Servico $servico): ServicoUnidade
{
// verificando se o servico esta disponivel na unidade
$su = $this->storage
->getRepository(ServicoUnidade::class)
->get($unidade, $servico);
if (!$su) {
$error = $this->translator->trans('error.service_unity_invalid');
throw new Exception($error);
}
if (!$su->isAtivo()) {
$error = $this->translator->trans('error.service_unity_inactive');
throw new Exception($error);
}
return $su;
}
/**
*
* @param Cliente $cliente
* @return Cliente
*/
public function getClienteValido(Cliente $cliente)
{
// verificando se o cliente ja existe
if ($cliente) {
$clienteExistente = null;
$clienteRepository = $this->storage->getRepository(Cliente::class);
if ($cliente->getId()) {
$clienteExistente = $clienteRepository->find($cliente->getId());
}
if (!$clienteExistente && $cliente->getEmail()) {
$clienteExistente = $clienteRepository->findOneBy(['email' => $cliente->getEmail()]);
}
if (!$clienteExistente && $cliente->getDocumento()) {
$clienteExistente = $clienteRepository->findOneBy(['documento' => $cliente->getDocumento()]);
}
if ($clienteExistente) {
$cliente = $clienteExistente;
}
// evita gerar cliente sem nome e/ou documento
if (!$cliente->getDocumento() || !$cliente->getNome()) {
$cliente = null;
}
}
return $cliente;
}
/**
* Apaga os dados de atendimento da unidade ou global
* @param Unidade $unidade
*/
public function limparDados(Unidade $unidade = null)
{
$this->storage->apagarDadosAtendimento($unidade);
}
/**
*
* @param Atendimento $atendimento
* @param Unidade $unidade
* @param Servico $servico
* @param Usuario $usuario Define o novo atendente (opcional)
* @return Atendimento
*/
private function copyToRedirect(Atendimento $atendimento, Unidade $unidade, Servico $servico, Usuario $usuario = null): Atendimento
{
// copiando a senha do atendimento atual
$novo = new Atendimento();
$novo
->setLocal(null)
->setNumeroLocal(null)
->setServico($servico)
->setUnidade($unidade)
->setPai($atendimento)
->setDataChegada(new DateTime())
->setStatus(self::SENHA_EMITIDA)
->setUsuario($usuario)
->setUsuarioTriagem($atendimento->getUsuario())
->setPrioridade($atendimento->getPrioridade());
$novo
->getSenha()
->setSigla($atendimento->getSenha()->getSigla())
->setNumero($atendimento->getSenha()->getNumero());
if ($atendimento->getCliente()) {
$novo->setCliente($atendimento->getCliente());
}
return $novo;
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Service;
/**
* Configuration
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class Configuration
{
/**
* @var string
*/
private $default;
/**
* @var string
*/
private $custom;
public function __construct($rootDir)
{
$this->default = require("{$rootDir}/config/app.default.php");
$customFile = "{$rootDir}/config/app.php";
if (file_exists($customFile)) {
$this->custom = require($customFile);
}
if (!$this->default) {
$this->default = [];
}
if (!$this->custom) {
$this->custom = [];
}
}
public function get($key)
{
$value = null;
$obj = $this->default;
$tokens = explode('.', $key);
foreach ($tokens as $prop) {
if (is_array($obj)) {
$value = $this->resolve($prop, $obj);
$obj = $value;
} else {
break;
}
}
return $value;
}
private function resolve($key, array $obj)
{
return $this->resolveValue($key, $this->custom, $obj);
}
private function resolveValue($key, array $primary, array $secondary)
{
if (isset($primary[$key])) {
return $primary[$key];
}
if (isset($secondary[$key])) {
return $secondary[$key];
}
return null;
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Service;
use Doctrine\ORM\QueryBuilder;
use Novosga\Entity\Atendimento;
use Novosga\Entity\Servico;
use Novosga\Entity\ServicoUnidade;
use Novosga\Entity\ServicoUsuario;
use Novosga\Entity\Unidade;
use Novosga\Entity\Usuario;
use Novosga\Infrastructure\StorageInterface;
/**
* FilaService
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
class FilaService extends StorageAwareService
{
const TIPO_TODOS = 'todos';
const TIPO_NORMAL = 'normal';
const TIPO_PRIORIDADE = 'prioridade';
const TIPO_AGENDAMENTO = 'agendamento';
/**
* @var Configuration
*/
private $config;
public function __construct(StorageInterface $storage, Configuration $config)
{
parent::__construct($storage);
$this->config = $config;
}
/**
* Retorna a fila de atendimentos do usuario.
*
* @param Unidade $unidade
* @param Usuario $usuario
* @param ServicoUsuario[] $servicosUsuario
* @param string $tipoFila
* @param int $maxResults
*
* @return array
*/
public function filaAtendimento(
Unidade $unidade,
Usuario $usuario,
array $servicosUsuario,
$tipoFila = self::TIPO_TODOS,
$maxResults = 0
) {
$ids = [];
foreach ($servicosUsuario as $servico) {
if ($servico->getUsuario()->getId() === $usuario->getId()) {
$ids[] = $servico->getServico()->getId();
}
}
if (empty($ids)) {
return [];
}
$builder = $this
->builder()
->join(
ServicoUsuario::class,
'servicoUsuario',
'WITH',
'servicoUsuario.servico = servico AND servicoUsuario.usuario = :usuario'
)
->andWhere('(atendimento.usuario IS NULL OR atendimento.usuario = :usuario)')
->andWhere('atendimento.status = :status')
->andWhere('atendimento.unidade = :unidade')
->andWhere('servico.id IN (:servicos)');
// se nao atende todos, filtra pelo tipo de atendimento
switch ($tipoFila) {
case self::TIPO_NORMAL:
case self::TIPO_PRIORIDADE:
$s = ($tipoFila === self::TIPO_NORMAL) ? '=' : '>';
$where = "prioridade.peso $s 0";
$builder->andWhere($where);
break;
case self::TIPO_AGENDAMENTO:
$builder->andWhere("atendimento.dataAgendamento IS NOT NULL");
break;
}
$params = [
'status' => AtendimentoService::SENHA_EMITIDA,
'unidade' => $unidade,
'usuario' => $usuario,
'servicos' => $ids,
];
$this->applyOrders($builder, $unidade, $usuario);
$query = $builder
->setParameters($params)
->getQuery();
if ($maxResults > 0) {
$query->setMaxResults($maxResults);
}
return $query->getResult();
}
/**
* Retorna a fila de espera do serviço na unidade.
*
* @param Unidade $unidade
* @param Servico $servico
*
* @return array
*/
public function filaServico(Unidade $unidade, Servico $servico)
{
$builder = $this->builder();
$params = [
'status' => AtendimentoService::SENHA_EMITIDA,
'unidade' => $unidade,
'servico' => $servico,
];
$builder
->where('atendimento.status = :status')
->andWhere('atendimento.unidade = :unidade')
->andWhere('atendimento.servico = :servico');
$this->applyOrders($builder, $unidade);
$rs = $builder
->setParameters($params)
->getQuery()
->getResult();
return $rs;
}
/**
* Retorna a fila de espera do serviço na unidade.
*
* @param Unidade $unidade
*
* @return array
*/
public function filaUnidade(Unidade $unidade)
{
$builder = $this->builder();
$params = [
'status' => AtendimentoService::SENHA_EMITIDA,
'unidade' => $unidade,
];
$builder
->where('atendimento.status = :status')
->andWhere('atendimento.unidade = :unidade');
$this->applyOrders($builder, $unidade);
$rs = $builder
->setParameters($params)
->getQuery()
->getResult();
return $rs;
}
/**
* @return QueryBuilder
*/
private function builder()
{
$qb = $this
->storage
->getManager()
->createQueryBuilder()
->select([
'atendimento',
'prioridade',
'unidade',
'servico',
])
->from(Atendimento::class, 'atendimento')
->join('atendimento.prioridade', 'prioridade')
->join('atendimento.unidade', 'unidade')
->join('atendimento.servico', 'servico')
->join(
ServicoUnidade::class,
'servicoUnidade',
'WITH',
'servicoUnidade.unidade = unidade AND servicoUnidade.servico = servico'
);
return $qb;
}
/**
* Aplica a ordenação na QueryBuilder.
*
* @param QueryBuilder $builder
*/
private function applyOrders(QueryBuilder $builder, Unidade $unidade, Usuario $usuario = null)
{
$ordering = $this->config->get('queue.ordering');
if (is_callable($ordering)) {
$param = new \Novosga\Configuration\OrderingParameter();
$param->setUnidade($unidade);
$param->setUsuario($usuario);
$param->setQueryBuilder($builder);
$param->setStorage($this->storage);
$ordering = $ordering($param);
}
if (is_array($ordering)) {
foreach ($ordering as $item) {
if (!isset($item['exp'])) {
break;
}
$exp = $item['exp'];
$order = isset($item['order']) ? $item['order'] : 'ASC';
$builder->addOrderBy($exp, $order);
}
}
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Service;
use Doctrine\Common\Collections\ArrayCollection;
use Novosga\Entity\Servico;
use Novosga\Entity\ServicoMeta;
use Novosga\Entity\ServicoUnidade;
use Novosga\Entity\Unidade;
use Novosga\Entity\Usuario;
/**
* ServicoService.
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
class ServicoService extends StorageAwareService
{
/**
* Cria ou retorna um metadado do serviço caso o $value seja null (ou ocultado).
*
* @param Servico $servico
* @param string $name
* @param string $value
*
* @return ServicoMeta
*/
public function meta(Servico $servico, $name, $value = null)
{
$repo = $this->storage->getRepository(ServicoMeta::class);
if ($value === null) {
$metadata = $repo->get($servico, $name);
} else {
$metadata = $repo->set($servico, $name, $value);
}
return $metadata;
}
/**
* Retorna a lista de serviços ativos.
*
* @param Unidade|int $unidade
* @param array $where
*
* @return ArrayCollection
*/
public function servicosUnidade($unidade, array $where = [])
{
$params = [
'unidade' => $unidade,
];
$qb = $this->storage
->getManager()
->createQueryBuilder()
->select('e')
->from(ServicoUnidade::class, 'e')
->join('e.servico', 's')
->where('e.unidade = :unidade')
->andWhere('s.deletedAt IS NULL')
->orderBy('s.nome', 'ASC');
foreach ($where as $k => $v) {
if (is_array($v)) {
$qb->andWhere("e.{$k} IN (:{$k})");
} else if (is_string($v)) {
$qb->andWhere("e.{$k} LIKE :{$k}");
} else {
$qb->andWhere("e.{$k} = :{$k}");
}
$params[$k] = $v;
}
$servicos = $qb
->setParameters($params)
->getQuery()
->getResult();
return $servicos;
}
/**
* Retorna os servicos que o usuario nao atende na unidade atual.
*
* @param Unidade|int $unidade
* @param Usuario|int $usuario
*
* @return ArrayCollection
*/
public function servicosIndisponiveis($unidade, $usuario)
{
return $this->storage
->getManager()
->createQuery("
SELECT
e
FROM
Novosga\Entity\ServicoUnidade e
JOIN e.servico s
WHERE
s.deletedAt IS NULL AND
e.ativo = TRUE AND
e.unidade = :unidade AND
s.id NOT IN (
SELECT s2.id
FROM Novosga\Entity\ServicoUsuario a
JOIN a.servico s2
WHERE a.usuario = :usuario AND a.unidade = :unidade
)
")
->setParameter('usuario', $usuario)
->setParameter('unidade', $unidade)
->getResult();
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Service;
use Novosga\Infrastructure\StorageInterface;
/**
* ModelService.
*
* @author Rogerio Lino <rogeriolino@gmail.com>
*/
abstract class StorageAwareService
{
/**
* @var StorageInterface
*/
protected $storage;
public function __construct(StorageInterface $storage)
{
$this->storage = $storage;
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Service;
use Novosga\Entity\Unidade;
use Novosga\Entity\UnidadeMeta;
/**
* UnidadeService.
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
class UnidadeService extends StorageAwareService
{
/**
* Cria ou retorna um metadado da unidade caso o $value seja null (ou ocultado).
*
* @param Unidade $unidade
* @param string $name
* @param string $value
*
* @return UnidadeMeta
*/
public function meta(Unidade $unidade, $name, $value = null)
{
$repo = $this->storage->getRepository(UnidadeMeta::class);
if ($value === null) {
$metadata = $repo->get($unidade, $name);
} else {
$metadata = $repo->set($unidade, $name, $value);
}
return $metadata;
}
}
<?php
/*
* This file is part of the Novo SGA project.
*
* (c) Rogerio Lino <rogeriolino@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Novosga\Service;
use Doctrine\Common\Collections\ArrayCollection;
use Novosga\Entity\ServicoUsuario;
use Novosga\Entity\Unidade;
use Novosga\Entity\Usuario;
use Novosga\Entity\UsuarioMeta;
/**
* UsuarioService.
*
* @author Rogério Lino <rogeriolino@gmail.com>
*/
class UsuarioService extends StorageAwareService
{
const ATTR_NAMESPACE = 'global';
const ATTR_ATENDIMENTO_LOCAL = 'atendimento.local';
const ATTR_ATENDIMENTO_NUM_LOCAL = 'atendimento.num_local';
const ATTR_ATENDIMENTO_TIPO = 'atendimento.tipo';
const ATTR_SESSION_UNIDADE = 'session.unidade';
/**
* Cria ou retorna um metadado do usuário caso o $value seja null (ou ocultado).
*
* @param Usuario $usuario
* @param string $name
* @param string $value
*
* @return UsuarioMeta
*/
public function meta(Usuario $usuario, $name, $value = null)
{
$repo = $this->storage->getRepository(UsuarioMeta::class);
if ($value === null) {
$metadata = $repo->get($usuario, self::ATTR_NAMESPACE, $name);
} else {
$metadata = $repo->set($usuario, self::ATTR_NAMESPACE, $name, $value);
}
return $metadata;
}
/**
* Retorna a lista de serviços que o usuário atende na determinada unidade.
*
* @param Usuario $usuario
* @param Unidade $unidade
*
* @return ArrayCollection
*/
public function servicos(Usuario $usuario, Unidade $unidade)
{
$servicos = $this->storage
->getManager()
->createQueryBuilder()
->select('e')
->from(ServicoUsuario::class, 'e')
->join('e.servico', 's')
->where('e.usuario = :usuario')
->andWhere('e.unidade = :unidade')
->andWhere('s.ativo = TRUE')
->orderBy('s.nome', 'ASC')
->setParameters([
'usuario' => $usuario,
'unidade' => $unidade
])
->getQuery()
->getResult();
return $servicos;
}
public function isLocalLivre($unidade, $usuario, $numero)
{
$count = (int) $this->storage
->getManager()
->createQuery('
SELECT
COUNT(1)
FROM
Novosga\Entity\UsuarioMeta e
WHERE
(e.name = :metaLocal AND e.value = :numero AND e.usuario != :usuario)
AND EXISTS (
SELECT e2
FROM Novosga\Entity\UsuarioMeta e2
WHERE
e2.name = :metaUnidade AND
e2.value = :unidade AND
e2.usuario = e.usuario
)
')
->setParameters([
'metaLocal' => self::ATTR_ATENDIMENTO_LOCAL,
'numero' => $numero,
'usuario' => $usuario,
'metaUnidade' => self::ATTR_SESSION_UNIDADE,
'unidade' => $unidade,
])
->getSingleScalarResult();
return $count === 0;
}
}
{
"version": "2.1.0",
"name": "mardoniosc/core",
"license": "MIT",
"type": "library",
"autoload": {
"psr-4": { "Novosga\\": "" }
},
"require": {
"php": "^7.1.3"
},
"extra": {
"branch-alias": {
"dev-master": "2.1-dev"
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment