public function init() { $value = $this->getValue(); if ($this->_riseValue === null) { $baseInterestModel = new BaseInterest(); $rangeStart = $baseInterestModel->getRangeStart($this->depositDays); $rangeEnd = $baseInterestModel->getRangeEnd($this->depositDays); if ($rangeEnd === null) { $this->_riseValue += $rangeStart->value / 100; } else { // wyliczane z interpolacji $x0 = $rangeStart->period; $x1 = $rangeEnd->period; $y0 = $rangeStart->value; $y1 = $rangeEnd->value; $x = $this->depositDays; $this->_riseValue += $this->linearInterpolation($x0, $x1, $y0, $y1, $x) / 100; } } $value += $this->_riseValue; $this->setValue($value); }
public function save($con = null) { $con = Propel::getConnection(); try { $con->begin(); $ret = parent::save(); // update interested_users in question table $question = $this->getQuestion(); $interested_users = $question->getInterestedUsers(); $question->setInterestedUsers($interested_users + 1); $question->save(); $con->commit(); return $ret; } catch (Exception $e) { $con->rollback(); throw $e; } }
public function getPeer() { if (self::$peer === null) { self::$peer = new InterestPeer(); } return self::$peer; }
public function updatebase() { $formValues = $this->view->form->getValues(); $dbAdapter = Zend_Db_Table::getDefaultAdapter(); $dbAdapter->beginTransaction(); $baseInterest = new BaseInterest(); try { foreach ($formValues as $key => $value) { $row = $baseInterest->fetchRow(array('code = ?' => $key), 'created_at DESC'); if ($row !== null) { $baseInterest->insert(array('code' => $row->code, 'value' => $value, 'period' => $row->period)); $newRow = $baseInterest->fetchRow(array('code = ?' => $key), 'created_at DESC'); $log = Zend_Registry::get('admin_log'); $log->baseinterest(array('old' => $row, 'new' => $newRow)); } else { throw new Exception('Nie znaleziono kodu stawki do aktualizacji!'); } } $dbAdapter->commit(); } catch (Exception $e) { $dbAdapter->rollBack(); $this->_helper->messenger->error($e->getMessage()); return false; // return $this->_helper->redirector('updatebase', 'externalbase'); } return true; }