Ejemplo n.º 1
0
 static function getStatusByFlag($flag)
 {
     $status = StatusTransacao::getArray();
     if (array_key_exists($flag, $status)) {
         return $status[$flag];
     } else {
         return false;
     }
 }
Ejemplo n.º 2
0
 public function getTransactionAction()
 {
     /** @var TransactionService $service */
     $service = $this->getFromServiceLocator(TransactionConst::SERVICE);
     $id = $this->params()->fromQuery('id');
     /** @var Transaction $transacao */
     $transacao = $service->getTransactionById($id);
     $retorno[TransactionConst::FLD_ID_TRANSACTION] = $transacao->getId();
     $retorno[TransactionConst::FLD_PRODUTO] = $transacao->getProduct()->getTitle();
     $retorno[TransactionConst::FLD_START_DATE] = $transacao->getStartDate()->format('d/m/Y');
     $retorno[TransactionConst::FLD_QUANTIFY] = $transacao->getQuantity();
     $retorno[TransactionConst::FLD_PERSON_USER] = $transacao->getPersonUser()->getPerson()->getName();
     $retorno[TransactionConst::FLD_INSTITUTION_USER] = $transacao->getInstitutionUser()->getInstituicao()->getFancyName();
     $retorno[TransactionConst::FLD_STATUS] = StatusTransacao::getStatusByFlag($transacao->getStatus());
     return new JsonModel($retorno);
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 public function bindTransacao(Transaction &$transacao, TransactionForm $form)
 {
     $dataStart = $transacao->getStartDate()->format('d/m/Y');
     $transacao->setStartDate($dataStart);
     //$ano = $transacao->getEndDate() != null ? $transacao->getEndDate()->format('Y') : '';
     if ($transacao->getEndDate()) {
         $dataEnd = $transacao->getEndDate()->format('d/m/Y');
         $transacao->setEndDate($dataEnd);
     } else {
         $transacao->setEndDate(null);
     }
     $form->bind($transacao);
     $institutionUser = $form->get(TransactionConst::FLD_INSTITUTION_USER)->getValue();
     $form->get(TransactionConst::FLD_PRODUTO)->setValue($transacao->getProduct()->getTitle());
     $form->get(TransactionConst::FLD_STATUS)->setValue(StatusTransacao::getStatusByFlag($transacao->getStatus()));
     $form->get(TransactionConst::FLD_SHIPPING_METHOD)->setValue(ShippingMethod::getShippingMethod($transacao->getShippingMethod()));
     $form->get(TransactionConst::FLD_PERSON_USER)->setValue($transacao->getPersonUser()->getPerson()->getName());
     $form->get(TransactionConst::FLD_QUANTIFY)->setValue($transacao->getQuantity());
     $form->get(TransactionConst::FLD_INSTITUTION_USER)->setValue($institutionUser->getId());
     return $transacao;
 }