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 getGridDados($isFinalizados = false)
 {
     /** @var MoneyDonationDao $dao */
     $dao = $this->getFromServiceLocator(MoneyDonationConst::DAO);
     /** @var \Application\Entity\User $instituicaoLogado */
     $instituicaoLogado = $this->getFromServiceLocator(UsuarioConst::ZFCUSER_AUTH_SERVICE)->getIdentity();
     $qb = $dao->findMoneyDonation($instituicaoLogado->getId(), $isFinalizados);
     $jqgrid = new JqGridTable();
     $jqgrid->setAlias('m');
     $jqgrid->setQuery($qb);
     //$paramsPost = $jqgrid->getParametrosFromPost();
     $rows = $jqgrid->getDatatableArray();
     $dados = [];
     foreach ($rows[JqGridConst::PARAM_REGISTROS] as $row) {
         /** @var MoneyDonation $moneyDonation */
         $moneyDonation = $row;
         $temp[MoneyDonationConst::FLD_PERSON_USER_ID] = $moneyDonation->getIdPersonUser()->getPerson()->getName();
         $temp[MoneyDonationConst::FLD_STATUS] = StatusTransacao::getStatusByFlag($moneyDonation->getStatus());
         $temp[MoneyDonationConst::FLD_VALUE] = $moneyDonation->getValue();
         $temp[MoneyDonationConst::FLD_START_DATE] = $moneyDonation->getStartdate()->format('d/m/Y');
         if ($moneyDonation->getEndDate()) {
             $ano = $moneyDonation->getEndDate()->format('Y');
             if ($ano != FormConst::DATA_INVALIDA) {
                 $dataEnd = $moneyDonation->getEndDate()->format('d/m/Y');
             } else {
                 $dataEnd = '';
             }
         } else {
             $dataEnd = '';
         }
         $temp[MoneyDonationConst::FLD_END_DATE] = $dataEnd;
         $botaoConfirmar = new JqGridButton();
         $botaoConfirmar->setTitle('Confirmar Recebimento');
         $botaoConfirmar->setClass('btn btn-success btn-xs');
         $botaoConfirmar->setUrl('/transacao/confirmar-recebimento/' . $moneyDonation->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/' . $moneyDonation->getId());
         $botaoCancelar->setIcon('glyphicon glyphicon-ban-circle');
         $temp[JqGridConst::ACAO] = "<div class='agrupa-botoes'>" . $botaoConfirmar->render() . $botaoCancelar->render() . "</div>";
         $dados[] = $temp;
     }
     $rows[JqGridConst::PARAM_REGISTROS] = $dados;
     return $rows;
 }
 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;
 }
 public function getGridDadosTemplate()
 {
     /** @var TemplateEmailDao $dao */
     $dao = $this->getFromServiceLocator(TemplateEmailConst::DAO);
     /** @var \Application\Entity\User $instituicaoLogado */
     $instituicaoLogado = $this->getFromServiceLocator(UsuarioConst::ZFCUSER_AUTH_SERVICE)->getIdentity();
     $qb = $dao->findTemplatesByUser($instituicaoLogado->getId());
     $jqgrid = new JqGridTable();
     $jqgrid->setAlias('t');
     $jqgrid->setQuery($qb);
     //$paramsPost = $jqgrid->getParametrosFromPost();
     $rows = $jqgrid->getDatatableArray();
     $dados = [];
     foreach ($rows[JqGridConst::PARAM_REGISTROS] as $row) {
         /** @var TemplateEmail $template*/
         $template = $row;
         $temp[TemplateEmailConst::FLD_DESC] = $template->getDescription();
         $botaoEditar = new JqGridButton();
         $botaoEditar->setTitle('Editar');
         $botaoEditar->setClass('btn btn-primary btn-xs');
         $botaoEditar->setUrl('/relacionamento/editar-modelo/' . $template->getId());
         $botaoEditar->setIcon('glyphicon glyphicon-edit');
         $botaoExcluir = new JqGridButton();
         $botaoExcluir->setTitle('Excluir');
         $botaoExcluir->setClass('btn btn-danger btn-xs');
         $botaoExcluir->setUrl('/relacionamento/excluir-modelo/' . $template->getId());
         $botaoExcluir->setIcon('glyphicon glyphicon-trash');
         $temp[JqGridConst::ACAO] = "<div class='agrupa-botoes'>" . $botaoEditar->render() . $botaoExcluir->render() . "</div>";
         $dados[] = $temp;
     }
     $rows[JqGridConst::PARAM_REGISTROS] = $dados;
     return $rows;
 }