Ejemplo n.º 1
0
 /**
  * Returns current period instance
  *
  * @return <Doctrine_Object> instance of Period
  */
 public static function getCurrentPeriod()
 {
     $date = Period::getCurPeriodDate();
     $oPeriod = PeriodTable::getInstance()->findOneByDate($date);
     if (!$oPeriod instanceof Period) {
         // выставить новые тарифы на новый период
         UserTable::setNewTariffs();
         $oPeriod = new Period();
         // вычислить стоимость 1к знаков
         if (($prev = Period::getPrevPeriod()) === false) {
             $price1k = SettingTable::getOptionByName('price1k')->getValue();
         } else {
             // рассчитать веса пользователей
             UserTable::countWeights($prev);
             if (($price1k = VoteTable::getVoted1k($prev)) === false) {
                 $price1k = $prev->get1k();
             }
         }
         $oPeriod->set1k(number_format((double) $price1k, 2));
         // выставить процент
         $oPeriod->setR2rShare(number_format(Setting::getValueByName('percent_r2r'), 2, '.', ''));
         // --
         $oPeriod->setDate($date);
         $oPeriod->save();
         //throw new sfException('Cannot get current period. Error in DB data');
     }
     return $oPeriod;
 }
Ejemplo n.º 2
0
 public static function getAllTariffs()
 {
     $out[User::STANDART] = SettingTable::getOptionByName(User::STANDART)->getValue();
     $out[User::EXPERT] = SettingTable::getOptionByName(User::EXPERT)->getValue();
     $out[User::SUPER] = SettingTable::getOptionByName(User::SUPER)->getValue();
     return $out;
 }
Ejemplo n.º 3
0
 public static function getValueByName($name)
 {
     $out = SettingTable::getOptionByName($name);
     return $out->getValue();
 }