static function getUnidadeBySigla($sigla) { $unidades = Unidade::getArray(); if (array_key_exists($sigla, $unidades)) { return $unidades[$sigla]; } else { return false; } }
public function getGridDados() { /** @var ProductDao $dao */ $dao = $this->getFromServiceLocator(ProductConst::DAO); /** @var TransactionDao $daoTransaction */ $daoTransaction = $this->getFromServiceLocator(TransactionConst::DAO); /** @var \Application\Entity\User $instituicaoLogado */ $instituicaoLogado = $this->getFromServiceLocator(UsuarioConst::ZFCUSER_AUTH_SERVICE)->getIdentity(); $qb = $dao->findProductsByUser($instituicaoLogado->getId()); $jqgrid = new JqGridTable(); $jqgrid->setAlias('p'); $jqgrid->setQuery($qb); //$paramsPost = $jqgrid->getParametrosFromPost(); $rows = $jqgrid->getDatatableArray(); $dados = []; foreach ($rows[JqGridConst::PARAM_REGISTROS] as $row) { /** @var Product $produto */ $produto = $row; $transacoes = $daoTransaction->findTransactionsByProduto($produto->getIdProduto()); $qtd = 0; if ($transacoes) { /** @var Transaction $transacao */ foreach ($transacoes as $transacao) { $qtd += $transacao->getQuantity(); } } $data = $produto->getDate(); $temp[ProductConst::FLD_QTD] = $produto->getQuantity(); $temp[ProductConst::FLD_UNITY] = Unidade::getUnidadeBySigla($produto->getUnity()); $temp[ProductConst::FLD_TITLE] = $produto->getTitle(); $temp[ProductConst::FLD_DATE] = $data->format('d/m/Y'); $temp[ProductConst::FLD_TIPO] = $produto->getProductType()->getDescription(); $temp[ProductConst::FLD_DESC] = $produto->getDescription(); $temp[ProductConst::FLD_COLLECT] = $qtd < $produto->getQuantity() ? '<span style="color: red">' . $qtd . '</span>' : '<span style="color: green">' . $qtd . '</span>'; $botaoEditar = new JqGridButton(); $botaoEditar->setTitle('Editar'); $botaoEditar->setClass('btn btn-primary btn-xs'); $botaoEditar->setUrl('/produto/editar/' . $produto->getIdProduto()); $botaoEditar->setIcon('glyphicon glyphicon-edit'); $botaoExcluir = new JqGridButton(); $botaoExcluir->setTitle('Excluir'); $botaoExcluir->setClass('btn btn-danger btn-xs'); $botaoExcluir->setUrl('/produto/excluir/' . $produto->getIdProduto()); $botaoExcluir->setIcon('glyphicon glyphicon-trash'); //$botaoExcluir->getOnClick(); $temp[JqGridConst::ACAO] = "<div class='agrupa-botoes'>" . $botaoEditar->render() . $botaoExcluir->render() . "</div>"; $dados[] = $temp; } $rows[JqGridConst::PARAM_REGISTROS] = $dados; return $rows; }
public function getDonationAction() { /** @var ProductService $service */ $service = $this->getFromServiceLocator(ProductConst::SERVICE); $id = $this->params()->fromQuery('id'); /** @var Product $doacao */ $doacao = $service->getProduto($id); $retorno[ProductConst::FLD_ID_PRODUTO] = $doacao->getIdProduto(); $retorno[ProductConst::FLD_TITLE] = $doacao->getTitle(); $retorno[ProductConst::FLD_INSTITUICAO] = $doacao->getInstitutionUser()->getUserId(); $retorno[ProductConst::FLD_DESC] = $doacao->getDescription(); $retorno[ProductConst::FLD_UNITY] = Unidade::getUnidadeBySigla($doacao->getUnity()); $retorno[ProductConst::FLD_DATE] = $doacao->getDate()->format('d/m/y'); $retorno[ProductConst::FLD_QTD] = $doacao->getQuantity(); $retorno[ProductConst::FLD_TIPO] = $doacao->getProductType()->getDescription(); return new JsonModel($retorno); }
/** * Cria o formulario para grupo. */ public function __construct($url = null, \Application\Entity\User $userLogado, ProductService $service) { parent::__construct('produto_form'); $this->setHydrator(new ClassMethodsHydrator(false))->setObject(new Product()); $this->setAttributes(array('method' => 'post', 'action' => $url)); $this->add(array('name' => ProductConst::FLD_ID_PRODUTO, 'attributes' => array('type' => 'hidden', 'class' => ''), 'options' => array('label' => ''))); $this->add(array('name' => ProductConst::FLD_INSTITUICAO, 'attributes' => array('type' => 'hidden', 'class' => '', 'value' => !is_null($userLogado) ? $userLogado->getEmail() : ''), 'options' => array('label' => ''))); $this->add(array('name' => ProductConst::FLD_DESC, 'attributes' => array('type' => 'textarea', 'class' => '', 'rows' => '4', 'cols' => '4', 'max-row' => 200), 'options' => array('label' => ProductConst::LBL_DESC))); $this->add(array('name' => ProductConst::FLD_TITLE, 'attributes' => array('type' => 'text', 'class' => ''), 'options' => array('label' => ProductConst::LBL_TITLE))); $this->add(array('name' => ProductConst::FLD_STATUS, 'type' => 'Zend\\Form\\Element\\Select', 'options' => array('empty_option' => FormConst::SELECT_OPTION_SELECIONE, 'label' => ProductConst::LBL_STATUS, 'value_options' => StatusProduto::getArray(), 'disable_inarray_validator' => true))); $this->add(array('name' => ProductConst::FLD_UNITY, 'type' => 'Zend\\Form\\Element\\Select', 'options' => array('empty_option' => FormConst::SELECT_OPTION_SELECIONE, 'label' => ProductConst::LBL_UNITY, 'value_options' => Unidade::getArray(), 'disable_inarray_validator' => true))); $this->add(array('name' => ProductConst::FLD_TIPO, 'type' => 'Zend\\Form\\Element\\Select', 'options' => array('empty_option' => FormConst::SELECT_OPTION_SELECIONE, 'label' => ProductConst::LBL_TIPO, 'value_options' => $service->createSelectFromArray($service->getProductType(), ProductTypeConst::FLD_ID_PRODUCT_TYPE, ProductTypeConst::FLD_DESC_PRODUCT_TYPE), 'disable_inarray_validator' => true))); $this->add(array('name' => ProductConst::FLD_DATE, 'attributes' => array('type' => 'Date', 'class' => ''), 'options' => array('label' => ProductConst::LBL_DATE))); $this->add(array('name' => ProductConst::FLD_QTD, 'attributes' => array('type' => 'number', 'class' => ''), 'options' => array('label' => ProductConst::LBL_QTD))); $this->add(array('name' => 'btn_salvar', 'type' => 'button', 'attributes' => array('type' => 'submit', 'value' => 'Salvar', 'id' => 'salvar_' . $this->getName(), 'class' => 'btn-primary btn-white width-25 btn', 'style' => ''), 'options' => array('label' => 'Salvar', 'glyphicon' => 'glyphicon glyphicon-floppy-disk blue'))); $this->add(array('name' => 'btn_cancelar', 'type' => 'button', 'attributes' => array('type' => 'reset', 'value' => 'Cancelar', 'id' => 'cancelar_' . $this->getName(), 'class' => 'btn-danger btn-white margin-left-right-10px width-25 btn'), 'options' => array('label' => 'Cancelar', 'glyphicon' => 'glyphicon glyphicon-remove red'))); }
public function getGridDados($status = null) { /** @var TransactionDao $dao */ $dao = $this->getFromServiceLocator(TransactionConst::DAO); /** @var \Application\Entity\User $instituicaoLogado */ $instituicaoLogado = $this->getFromServiceLocator(UsuarioConst::ZFCUSER_AUTH_SERVICE)->getIdentity(); $qb = $dao->findTransactions($instituicaoLogado->getId(), $status); $jqgrid = new JqGridTable(); $jqgrid->setAlias('r'); $jqgrid->setQuery($qb); //$paramsPost = $jqgrid->getParametrosFromPost(); $rows = $jqgrid->getDatatableArray(); $dados = []; foreach ($rows[JqGridConst::PARAM_REGISTROS] as $row) { /** @var Transaction $transaction */ $transaction = $row; $temp[TransactionConst::FLD_PRODUTO] = $transaction->getProduct()->getTitle(); $temp[TransactionConst::FLD_PERSON_USER] = $transaction->getPersonUser()->getPerson()->getName(); $temp[TransactionConst::FLD_STATUS] = StatusTransacao::getStatusByFlag($transaction->getStatus()); $temp[TransactionConst::FLD_QUANTIFY] = $transaction->getQuantity() . ' (' . Unidade::getUnidadeBySigla($transaction->getProduct()->getUnity()) . ')'; $temp[TransactionConst::FLD_START_DATE] = $transaction->getStartDate()->format('d/m/Y'); $botaoVer = new JqGridButton(); $botaoVer->setTitle('Ver transacao'); $botaoVer->setClass('btn btn-primary btn-xs'); $botaoVer->setUrl('#modal_transacao'); $botaoVer->setIcon('glyphicon glyphicon-eye-open'); $botaoVer->setDataToggle('modal'); $botaoVer->setOnClick("\$('#modal_transacao .modal-body').load('/transacao/visualizar/{$transaction->getId()}')"); $botaoConfirmar = new JqGridButton(); $botaoConfirmar->setTitle('Confirmar Recebimento'); $botaoConfirmar->setClass('btn btn-success btn-xs'); $botaoConfirmar->setUrl('/transacao/confirmar-recebimento/' . $transaction->getId()); $botaoConfirmar->setIcon('glyphicon glyphicon-ok-sign'); $botaoCancelar = new JqGridButton(); $botaoCancelar->setTitle('Cancelar Recebimento'); $botaoCancelar->setClass('btn btn-danger btn-xs'); $botaoCancelar->setUrl('/transacao/cancelar-recebimento/' . $transaction->getId()); $botaoCancelar->setIcon('glyphicon glyphicon-ban-circle'); $temp[JqGridConst::ACAO] = "<div class='agrupa-botoes'>" . $botaoVer->render() . $botaoConfirmar->render() . $botaoCancelar->render() . "</div>"; $dados[] = $temp; } $rows[JqGridConst::PARAM_REGISTROS] = $dados; return $rows; }