/** * 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; }
<?php slot('currentPage', 'profile_p_invoice'); slot('title_page', 'Personal room - Личный кабинет'); include_partial('profilep/profMenu'); ?> <table id=count_data cellpadding="0" cellspacing="0"> <tr class=yg> <td class=left> <p>Расчетный период</p> </td> <td class=center> <p><?php echo Period::periodMonthString(Period::getPrevPeriod()); ?> </p> </td> <td class=right> <p> </p> </td> </tr> <tr class=g> <td class=left> <p>К выплате</p> </td> <td class=center> <p class=pay_out> <?php if (!is_null($earnedPrev)) { ?> <?php
/** * Executes invoice action * * @param sfWebRequest $request */ public function executeInvoice(sfWebRequest $request) { $this->period = Period::getCurrentPeriod(); $this->user = $this->getUser()->getGuardUser(); $this->form = null; $this->form_type = ''; $this->earned = $this->user->getUserBalanceByPeriodId(Period::getCurrentPeriod()->getId())->getPayable(); $this->earnedPrev = $this->user->getUserBalanceByPeriodId(Period::getPrevPeriod()->getId()); if ($request->getMethod() == 'POST') { $this->form = new UserPasswordImgForm($this->user); if ($this->processPswChangeForm($request, $this->form)) { // Input purchase ID $this->form_type = 'account_number'; $this->form = new AccountNumberForm($this->user); $this->fieldName = 'account_number'; $this->titleName = 'Номер кошелька'; $this->cssId = 'account_number'; } else { $this->error_img = true; $this->form_type = 'secure_img'; $this->fieldName = 'account_number'; $this->titleName = 'Изменение номера кошелька'; $this->cssId = 'account_number'; } } }