/** * * @return array */ public function createAction() { if ($this->getRequest()->isPost()) { $params = $this->getRequest()->getParams(); $idPort = $params[fob_port]; $port = PortCustomQuery::create()->findByPK($idPort); $portCode = $port->getCode(); $idDestinationPort = $params[destination_port]; $destination = PortCustomQuery::create()->findByPK($idDestinationPort); $destinationCode = $destination->getCode(); $idFreightType = $params[id_freight_type]; $freight = FreightTypeQuery::create()->findByPK($idFreightType); $freightCode = $freight->getCode(); $idtransit = $portCode . $destinationCode . $freightCode; try { $this->getFreightFareCatalog()->beginTransaction(); $date = new Zend_Date($params["good_through"], "MM/dd/yyyy"); $params["good_through"] = $date->toString("yyyy/MM/dd"); $freightFare = FreightFareFactory::createFromArray($params); $freightFare->setStatus(FreightFare::$Status['Active']); $freightFare->setIdTransit($idtransit); $this->getFreightFareCatalog()->create($freightFare); $this->getFreightFareCatalog()->commit(); $this->setFlash('ok', $this->i18n->_("It has been created the Freigth Fare with Id Transit {$idtransit}")); } catch (Exception $e) { $this->getFreightFareCatalog()->rollBack(); $this->setFlash('error', $this->i18n->_($e->getMessage())); } } $this->_redirect('freight-fare/list'); }
/** * * makeBean * @param array $resultset * @return \Application\Model\Bean\FreightFare */ protected function makeBean($resultset) { return FreightFareFactory::createFromArray($resultset); }