/** * * @return array */ public function updateAction() { if ($this->getRequest()->isPost()) { $params = $this->getRequest()->getParams(); $id = $this->getRequest()->getParam('id_freigth_fare'); $freightFare = FreightFareQuery::create()->findByPKOrThrow($id, $this->i18n->_("It does not exist the FreightFare with id {$id}")); try { $this->getFreightFareCatalog()->beginTransaction(); $date = new Zend_Date($params["good_through"], "MM/dd/yyyy"); $params["good_through"] = $date->toString("yyyy/MM/dd"); FreightFareFactory::populate($freightFare, $params); $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; $freightFare->setIdTransit($idtransit); //die(print_r($freightFare)); $this->getFreightFareCatalog()->update($freightFare); $this->getFreightFareCatalog()->commit(); $this->setFlash('ok', $this->i18n->_("The Freight Fare with Id Transit {$idtransit} was updated")); } 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); }