Example #1
0
 public function init()
 {
     $value = $this->getValue();
     if ($this->_riseValue === null) {
         if ($this->depositDays <= 365) {
             $wiborModel = new Wibor();
             $rangeStart = $wiborModel->getRangeStart($this->depositDays);
             $rangeEnd = $wiborModel->getRangeEnd($this->depositDays);
         } else {
             $irsModel = new Irs();
             $rangeStart = $irsModel->getRangeStart($this->depositDays);
             $rangeEnd = $irsModel->getRangeEnd($this->depositDays);
             if ($rangeStart === null) {
                 // dla okresów z przedziału [366D, 729D]
                 $wiborModel = new Wibor();
                 $rangeStart = $wiborModel->getRangeStart($this->depositDays);
             }
         }
         if ($rangeEnd === null) {
             $this->_riseValue += $rangeStart->value;
         } else {
             $x0 = $rangeStart->period;
             $x1 = $rangeEnd->period;
             $y0 = $rangeStart->value;
             $y1 = $rangeEnd->value;
             $x = $this->depositDays;
             $this->_riseValue += $this->linearInterpolation($x0, $x1, $y0, $y1, $x);
         }
     }
     $value += $this->_riseValue;
     $this->setValue($value);
 }
Example #2
0
 public function manualupdate()
 {
     //$formValues = $form->getValues();
     $formValues = $this->getRequest()->getPost();
     $dbAdapter = Zend_Db_Table::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     $wiborModel = new Wibor();
     $irsModel = new Irs();
     try {
         foreach ($formValues as $key => $value) {
             $wiborRow = $wiborModel->fetchRow(array('code = ?' => $key), 'created_at DESC');
             $irsRow = $irsModel->fetchRow(array('code = ?' => $key), 'created_at DESC');
             if ($wiborRow !== null) {
                 $wiborModel->insert(array('code' => $wiborRow->code, 'currency_code' => $wiborRow->currency_code, 'value' => $value, 'period' => $wiborRow->period));
                 $newWiborRow = $wiborModel->fetchRow(array('code = ?' => $key), 'created_at DESC');
                 $log = Zend_Registry::get('admin_log');
                 $log->wibor(array('old' => $wiborRow, 'new' => $newWiborRow));
             } else {
                 if ($irsRow !== null) {
                     $irsModel->insert(array('code' => $irsRow->code, 'currency_code' => $irsRow->currency_code, 'value' => $value, 'period' => $irsRow->period));
                     $newIrsRow = $irsModel->fetchRow(array('code = ?' => $key), 'created_at DESC');
                     $log = Zend_Registry::get('admin_log');
                     $log->irs(array('old' => $irsRow, 'new' => $newIrsRow));
                 }
             }
         }
         $dbAdapter->commit();
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_helper->messenger->error($e->getMessage());
         return false;
         //return $this->_helper->redirector('manualupdate', 'externalbase');
     }
     $this->_helper->messenger->success('Stawki zaktualizowane pomyślnie!');
     return true;
     //	return $this->_helper->redirector('manualupdate', 'externalbase');
 }