/**
  * Сменить валюту
  */
 public function executeChange(sfWebRequest $request)
 {
     $currency = myCurrencyTable::getInstance()->findOneById((int) $request->getParameter('currency'));
     $this->forward404Unless($currency);
     $this->getUser()->setAttribute('id', $currency->getId(), 'currency');
     $this->getUser()->setAttribute('format', $currency->getFormat(), 'currency');
     if ($referer = $request->getReferer()) {
         return $this->redirect($referer);
     } else {
         return $this->redirect('homepage');
     }
 }
 /**
  * Конвертировать из текущей в базовую
  *
  * @param decimal $value
  * @param int     $currencyId
  *
  * return decimal
  */
 public static function convertToBase($value, $currencyId)
 {
     $base = self::getBaseCurrency();
     if (is_null($currencyId) || $currencyId == $base->getId()) {
         return $value;
     }
     $currency = myCurrencyTable::getInstance()->findOneById($currencyId);
     return $value * $currency->getCourse() / $base->getCourse();
 }
 /**
  * Список выбора валюты
  */
 public function executeChanger()
 {
     $table = myCurrencyTable::getInstance();
     $this->items = $table->getActiveCurrency();
     $this->currentId = $this->getUser()->getAttribute('id', $table->getDefaultCurrency()->getId(), 'currency');
 }