static function getShippingMethod($flag)
 {
     $shipping = ShippingMethod::getArray();
     if (array_key_exists($flag, $shipping)) {
         return $shipping[$flag];
     } else {
         return false;
     }
 }
 public function __construct(ServiceAbstract $service, User $userLogado = null, $isDisabled = true, $produto)
 {
     parent::__construct('transaction_form');
     $disabled = $isDisabled ? 'disabled' : '';
     $this->setHydrator(new ClassMethodsHydrator(false))->setObject(new Transaction());
     $this->setAttributes(array('method' => 'post'));
     $this->add(array('name' => TransactionConst::FLD_ID_TRANSACTION, 'attributes' => array('type' => 'hidden', 'class' => ''), 'options' => array('label' => '')));
     $this->add(array('name' => TransactionConst::FLD_INSTITUTION_USER, 'attributes' => array('type' => 'hidden', 'class' => ''), 'options' => array('label' => TransactionConst::LBL_INSTITUTION_USER_ID)));
     $this->add(array('name' => TransactionConst::FLD_PERSON_USER, 'attributes' => array('type' => 'hidden', 'class' => '', 'value' => !is_null($userLogado) ? $userLogado->getId() : ''), 'options' => array('label' => TransactionConst::LBL_PERSON_USER_ID)));
     $this->add(array('name' => TransactionConst::FLD_START_DATE, 'attributes' => array('type' => 'Date', 'class' => '', 'disabled' => $disabled), 'options' => array('label' => TransactionConst::LBL_START_DATE)));
     $this->add(array('name' => TransactionConst::FLD_END_DATE, 'attributes' => array('type' => 'Date', 'class' => '', 'disabled' => $disabled), 'options' => array('label' => TransactionConst::LBL_END_DATE)));
     $this->add(array('name' => TransactionConst::FLD_PRODUTO, 'attributes' => array('type' => 'hidden', 'class' => '', 'value' => $produto), 'options' => array('label' => TransactionConst::LBL_PRODUTO)));
     $this->add(array('name' => TransactionConst::FLD_QUANTIFY, 'attributes' => array('type' => 'number', 'class' => '', 'disabled' => $disabled), 'options' => array('label' => TransactionConst::LBL_QUANTIFY)));
     $this->add(array('name' => TransactionConst::FLD_SHIPPING_METHOD, 'type' => 'Zend\\Form\\Element\\Select', 'options' => array('empty_option' => FormConst::SELECT_OPTION_SELECIONE, 'label' => TransactionConst::LBL_SHIPPING_METHOD, 'value_options' => ShippingMethod::getArray(), 'disable_inarray_validator' => true)));
     $this->add(array('name' => TransactionConst::FLD_STATUS, 'attributes' => array('type' => 'text', 'class' => '', 'disabled' => $disabled), 'options' => array('label' => TransactionConst::LBL_STATUS)));
     $this->add(array('name' => 'btn_salvar_doacao', 'attributes' => array('value' => 'Salvar Doacao', 'id' => 'btn_salvar_doacao', 'class' => 'btn-primary btn-white width-25 btn', 'style' => ''), 'options' => array('label' => 'Salvar', 'glyphicon' => 'glyphicon glyphicon-floppy-disk blue')));
 }
 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;
 }