Пример #1
0
 /**
  * Return R2R percent
  *
  * @return int
  */
 public static function getR2RPercent()
 {
     /*
     $option = SettingTable::getOptionByName('percent_r2r');
     return (int)$option->getValue();
     */
     return (double) Period::getCurrentPeriod()->getR2rShare();
 }
Пример #2
0
 public static function setPositions()
 {
     $q = Doctrine_Query::create()->select('v.*')->from('Vote v')->where('v.id_period = ?', Period::getCurrentPeriod()->getId())->orderBy('v.weight DESC');
     $votes = $q->execute();
     $k = 1;
     foreach ($votes as $i => $vote) {
         $k += $i;
         $vote->setPosition($k);
         $vote->save();
     }
 }
Пример #3
0
 /**
  * Show Visit stats
  *
  * @param sfWebRequest $request
  */
 public function executeVisit(sfWebRequest $request)
 {
     $this->form = new CategorySelectForm();
     $iCategoryId = 1;
     $iPeriodId = Period::getCurrentPeriod()->getId();
     if ($request->getParameter('category', false)) {
         $this->form->bind($request->getParameter($this->form->getName()));
         $iCategoryId = $this->form->getValue('id_category');
         $this->form->setDefault('id_category', $iCategoryId);
     }
     $this->aFullData = StatisticsTable::getInstance()->getFullStatistics($iPeriodId);
     $this->aDataByCategory = StatisticsTable::getInstance()->getFullStatistics($iPeriodId, $iCategoryId);
 }
Пример #4
0
 /**
  * Enter description here...
  *
  * @param int $user_id
  * @param int $period_id
  * @return BalanceUser
  */
 public static function getByUserIdAndPeriodId($user_id, $period_id = 0)
 {
     if ($period_id == 0) {
         $period_id = Period::getCurrentPeriod()->getId();
     }
     $q = Doctrine_Query::create()->from('BalanceUser bu')->where('bu.id_user=?', $user_id)->andWhere('bu.id_period=?', $period_id)->limit(1);
     $balance = $q->fetchOne();
     if (false === $balance) {
         BalanceUser::setInitialRecord($user_id, $period_id);
         $balance = self::getByUserIdAndPeriodId($user_id, $period_id);
         //throw new sfException('Cannot get Balance for User: '******' period: '.$period_id.'. Error in DB data');
     }
     return $balance;
 }
Пример #5
0
 public function postInsert($event)
 {
     $oStatistics = new Statistics();
     $oStatistics->setCategoryId($this->getId());
     try {
         $iPeriod = Period::getCurrentPeriod();
     } catch (sfException $e) {
         return;
     }
     if (false !== $iPeriod) {
         $oStatistics->setPeriodId($iPeriod);
         $oStatistics->save();
     }
 }
Пример #6
0
 public function executeIndex(sfWebRequest $request)
 {
     // sorting
     if ($request->getParameter('sort') && $this->isValidSortColumn($request->getParameter('sort'))) {
         $this->setSort(array($request->getParameter('sort'), $request->getParameter('sort_type')));
     }
     // pager
     if ($request->getParameter('page')) {
         $this->setPage($request->getParameter('page'));
     }
     $this->pager = $this->getPager();
     $this->sort = $this->getSort();
     $user = new User();
     $this->dataArray = array('amountSum' => $user->getUserAmountSum('uuser', Period::getCurrentPeriod()->getId()), 'sellPurchaseSum' => $user->getUserSellPurchaseSum('uuser', Period::getCurrentPeriod()->getId()));
 }
Пример #7
0
 public static function genMassPayWM($pay = true)
 {
     $max_id = Doctrine_Query::create()->select('max(bu.was_paid_id) as bu_max')->from('BalanceUser bu')->where('bu.was_paid > 0')->execute()->getFirst()->getBuMax();
     $q = Doctrine_Query::create()->select("bu.id_user, u.account_number as account_number, sum(bu.payable) as to_pay,\n                group_concat(p.date separator '|') as p_date, group_concat(bu.id separator '|') as for_ids")->from('BalanceUser bu')->innerJoin('bu.User u')->innerJoin('bu.Period p')->where('bu.was_paid = 0')->andWhere('bu.payable > 0')->andWhere("u.utype = 'puser'")->andWhere('bu.id_period != ?', Period::getCurrentPeriod()->getId())->groupBy('bu.id_user')->execute();
     $min_payout = (double) Setting::getValueByName('minPayout');
     $out = array();
     $out_num = 0;
     foreach ($q as $rec) {
         if (preg_match('/^R[0-9]{12}$/', $rec->getAccountNumber()) && $rec->getToPay() >= $min_payout) {
             if ($pay === true) {
                 $max_id = (int) $max_id + 1;
                 $bu_ids = explode('|', $rec->getForIds());
                 foreach ($bu_ids as $bu_id) {
                     $bu = BalanceUserTable::getInstance()->findOneById($bu_id);
                     $bu->setWasPaidId($max_id);
                     $bu->save();
                 }
                 $per = array();
                 $per_dates = explode('|', $rec->getPDate());
                 foreach ($per_dates as $p_date) {
                     $p_date_t = explode('-', $p_date);
                     $per[] = $p_date_t[1] . '/' . $p_date_t[0];
                 }
                 $row = array();
                 $row[] = $rec->getAccountNumber();
                 // номер кошелька
                 $row[] = $rec->getToPay();
                 // сумма тут надо разобраться с валютой
                 $row[] = mb_convert_encoding('Выплата за ', 'cp1251', 'utf-8') . join(', ', $per) . '. read2read.ru, payId:' . $max_id;
                 // комментарий к выплате
                 $row[] = $max_id;
                 // номер платежа
                 $out[] = join(';', $row);
             } else {
                 $out_num += $rec->getToPay();
             }
         }
     }
     if ($pay === true) {
         return join(PHP_EOL, $out);
     } else {
         return (int) $out_num;
     }
 }
Пример #8
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->period = Period::getCurrentPeriod();
     $this->user = $this->getUSer()->getGuardUser();
     $this->form = new UserVoteForm();
     if ($this->user->isVoted()) {
         $this->redirect('profile_p_vote1k_all');
     }
     if ($request->getParameter('create-vote') != '') {
         if ($this->user->hasVote()->count() == 0) {
             if ($this->processForm($request, $this->form)) {
                 $vote = $this->form->save();
                 $vote->setUser($this->user);
                 $vote->setPeriod($this->period);
                 $vote->setWeight($this->user->getWeight());
                 $vote->save();
                 VoteTable::getInstance()->setPositions();
             }
         }
     }
 }
Пример #9
0
 /**
  * U_User посмотрел категорию. Учитываем только один заход за день
  *
  * @param int $iUserId
  * @param int $iCategoryId
  */
 public static function uuserViewCategory($iUserId = 0, $iCategoryId = 0)
 {
     $q = Doctrine_Query::create()->select('sc.user_id')->from('StatisticsCategory sc')->where('sc.visit_date = CURDATE()')->andWhere('sc.category_id = ?', $iCategoryId)->andWhere('sc.user_id = ?', $iUserId)->limit(1);
     if (false !== $q->fetchOne()) {
         return;
     }
     // No first visit
     // New u_user
     $oStatsCategory = new StatisticsCategory();
     $oStatsCategory->setCategoryId($iCategoryId);
     $oStatsCategory->setUserId($iUserId);
     $oStatsCategory->setVisitDate(date('Y-m-d'));
     $oStatsCategory->save();
     // Update category stats
     $oStatistics = StatisticsTable::getInstance()->getFullStatistics(Period::getCurrentPeriod(), $iCategoryId);
     if (!$oStatistics instanceof Statistics) {
         throw new sfException('Cannon get Statistics object');
     }
     $callMethodGet = 'get' . date('j') . 'Login';
     $callMethodSet = 'set' . date('j') . 'Login';
     $oStatistics->{$callMethodSet}($oStatistics->{$callMethodGet}() + 1);
     $oStatistics->save();
 }
Пример #10
0
 /**
  * Execute Login Form action
  *
  * @param sfWebRequest $request
  */
 public function executeLoginForm(sfWebRequest $request)
 {
     $this->form = new LoginForm();
     if ($request->isMethod('post') && null !== $request->getParameter($this->form->getName())) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $values = $this->form->getValues();
             $this->getUser()->signin($values['user'], true);
             $oUser = $this->getUser()->getGuardUser();
             if ($oUser->getLastLogin() != date("Y-m-d") && $oUser->getUtype() == 'uuser') {
                 // statistic writing
                 // set last login
                 $oUser->setLastLogin(date("Y-m-d"));
                 $oUser->save();
                 // get current statistic raw
                 $oStatistics = StatisticsTable::getInstance()->getFullStatistics(Period::getCurrentPeriod()->getId());
                 // update login statistic
                 $oStatistics->set(date("j") . '_login', $oStatistics->get(date("j") . '_login') + 1);
                 $oStatistics->save();
             }
             return $this->getController()->redirect('@homepage');
         }
     }
 }
Пример #11
0
?>
</a></li>
    <li><a href="/task/user"><?php 
echo __('Tasks');
?>
</a></li>
    <li><?php 
echo Period::getCurrentPeriod()->name;
?>
</li>
</ol>

<div class="page-header">
    <h3>
        <i class="fa fa-tasks"></i> <?php 
echo __('Tasks on :period', array(':period' => Period::getCurrentPeriod()->name));
?>
    </h3>
</div>

<div class="row">
    <div class="col col-md-3">

    </div>
    <div class="col col-md-12">
        <?php 
$this->renderPartial('user/tasks', array('model' => $model));
?>
    </div>
</div>
Пример #12
0
 public function userTasksForCurrentPeriod(User $user)
 {
     $criteria = new CDbCriteria();
     $criteria->alias = 'job';
     $criteria->select = 'task.user_id as task_user_id, task.name as name, task.number as number, task.priority as priority, user.name as user_name, job.*';
     $criteria->join = 'LEFT JOIN ' . Task::model()->tableName() . ' on task.id = job.task_id
                          LEFT JOIN ' . User::model()->tableName() . ' on user.id = task.user_id';
     $criteria->compare('job.organization_id', $user->organization_id);
     $criteria->compare('task.period_id', Period::getCurrentPeriod()->id);
     return new CActiveDataProvider(Job::model(), array('criteria' => $criteria, 'sort' => array('defaultOrder' => 'task.period_id DESC, job.status ASC, task.priority DESC', 'route' => "site/usertasks", 'attributes' => array('priority' => array('asc' => 'task.priority', 'desc' => 'task.priority DESC'), 'name' => array('asc' => 'task.name', 'desc' => 'task.name DESC'), 'number' => array('asc' => 'task.number', 'desc' => 'task.number DESC'), 'user_name' => array('asc' => 'user.name', 'desc' => 'user.name DESC'), '*')), 'pagination' => array('pageSize' => 20, 'route' => "site/usertasks")));
 }
Пример #13
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->period = Period::getCurrentPeriod();
     $this->stats_nopub = ContentTable::getInstance()->getUserStatsNoPublished($this->getUser()->getId());
     //        $this->stats_pub = ContentTable::getInstance()->getUserStatsPublished($this->getUser()->getId());
     $this->stats_pub = $this->getUser()->getGuardUser()->getSoldStatsForPeriod($this->period);
 }
Пример #14
0
 public static function addFundsFin(Transaction $transaction)
 {
     if ($transaction->getIsPaid()) {
         // транзакция уже была обработана
         return false;
     } else {
         $transaction->addFundsFin();
     }
     // set new balance
     $user = UserTable::getInstance()->findOneById($transaction->getIdReceiver());
     $user->setBalans($transaction->getReceiverBalanceAfter());
     $user->save();
     $amount = $transaction->getAmount();
     // write to BalanceUser instance
     if (!($userBalance = BalanceUserTable::getByUserIdAndPeriodId($user->getId()))) {
         $userBalance = new BalanceUser();
         $userBalance->setPeriod(Period::getCurrentPeriod());
         $userBalance->setUser($user);
     }
     $userBalance->setAddFunds($userBalance->getAddFunds() + $amount);
     $userBalance->save();
     if (!($systemBalance = BalanceSystem::getCurrentBalanceInstance())) {
         sfContext::getInstance()->getLogger()->info('aS4W Error: getCurrentBalanceInstance return false');
         return false;
     }
     if ($user->getUSerTypePrefix() == 'u') {
         $systemBalance->setDepositUser($systemBalance->getDepositUser() + $amount);
     } else {
         switch ($user->getTariff()) {
             case 'standart':
                 $systemBalance->setDepositStandart($systemBalance->getDepositStandart() + $amount);
                 break;
             case 'super':
                 $systemBalance->setDepositSuper($systemBalance->getDepositSuper() + $amount);
                 break;
             case 'expert':
                 $systemBalance->setDepositExpert($systemBalance->getDepositExpert() + $amount);
                 break;
         }
     }
     $systemBalance->save();
     // If user blocked try UnBlock
     if ($user->is_blocked) {
         $user->tryUnBlockUser();
     }
     return true;
 }
Пример #15
0
<?php 
slot('title_page');
?>
Catalog - Каталог
<?php 
end_slot('title_page');
?>

<div id=mdl xmlns="http://www.w3.org/1999/html">
    <p>Сайт <span>read2read.ru</span> продает переводы к английским текстам в целях помощи при изучении английского языка. </p>
    <p>Сайт содержит 23 раздела , каждый из которых посвящен какому-либо виду человеческой деятельности или стороне жизни. <br>
    Кроме переводов, вниманию читателей предлагаются комментарии к отдельным словам, выражениям, сокращениям.</p>
    <p>Цена перевода зависит от его объема, который измеряется в тасячах знаков. Считаются все знаки, кроме пробелов. </p>
    <p> Стоимость <b>1тысячи</b> знаков = <span><?php 
echo number_format(Period::getCurrentPeriod()->get1k(), 2, '.', '');
?>
 руб.</span></p>

    <table id=items border="0" cellpadding="0" cellspacing="0">

        <tr class=bl>
            <td>
                <p class=le>Title</p>
                <p class=ri>Название</p>
                <p class=price>Цена</p>
                <p class=kzn>Объем</p>
            </td>
        </tr>

        <?php 
Пример #16
0
 /**
  * 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';
         }
     }
 }
Пример #17
0
        <th width="20%" align="center"><?php 
echo $user->getSellPurchaseCnt();
?>
</th>
        <th width="20%" align="center"><?php 
echo $user->getAmount();
?>
</th>
      </tr>
      <tr class="sf_admin_row even" align="center">
        <td align="left"><b>Работы</b></td>
        <td>Количество покупок</td>
        <td>Сумма по покупкам</td>
      </tr>
      <?php 
foreach ($user->getContentPurchaseForPeriod(Period::getCurrentPeriod()) as $i => $content_purchase) {
    $odd = fmod(++$i, 2) ? 'odd' : 'even';
    ?>
        <?php 
    $content = $content_purchase->getContent();
    ?>
      <tr class="sf_admin_row <?php 
    echo $odd;
    ?>
">
        <td><a href="<?php 
    echo sfProjectConfiguration::getActive()->generateFrontendUrl('article_by_categories', array('id' => $content->getId()));
    ?>
"><p style="text-align: left"><?php 
    echo $content->getTitleEn();
    ?>
Пример #18
0
 public function puserDailyPayment(User $oUser, BalanceSystem $oBalanceSystem, array &$aTariffs)
 {
     $this->setPeriod(Period::getCurrentPeriod());
     $this->setOperation('charges_service');
     $fAmount = $aTariffs[$oUser->getTariff()];
     $this->setAmount($fAmount);
     // Sender
     $this->setIdSender($oUser->getId());
     $this->setSenderBalanceBefore($oUser->getBalans());
     // Set user balance and save
     $itog = $oUser->getBalans() - $fAmount;
     if ($itog < 0) {
         $oUser->setIsBlocked(1);
         $oUser->save();
         return;
     }
     $oUser->setBalans($oUser->getBalans() - $fAmount);
     $oUser->save();
     //
     $this->setSenderBalanceAfter($oUser->getBalans());
     // Recipient - Read2Read
     $this->setIdReceiver(0);
     $this->setReceiverBalanceBefore(0);
     $this->setReceiverBalanceAfter(0);
     $sGetMethod = 'getCharges' . ucfirst($oUser->getTariff());
     $sSetMethod = 'setCharges' . ucfirst($oUser->getTariff());
     $bal = $oBalanceSystem->{$sGetMethod}();
     $bal += $fAmount;
     $oBalanceSystem->{$sSetMethod}($bal);
     $oBalanceSystem->save();
     $oBalanceUser = BalanceUserTable::getByUserIdAndPeriodId($oUser->getId());
     $oBalanceUser->setUsePayment($oBalanceUser->getUsePayment() + $fAmount);
     $oBalanceUser->save();
     // Save transaction
     $this->save();
     if ($itog < $fAmount) {
         $oUser->setIsBlocked(1);
         $oUser->save();
     }
 }
Пример #19
0
echo $paid;
?>
</td>
            </tr>
            <tr>
                <th>Логин</th>
                <th>№ кошелька</th>
                <th>Сумма к выплате</th>
                <th>Признак выплаты</th>
                <th>Выплачено</th>
            </tr>
            <?php 
foreach ($p_users as $i => $puser) {
    ?>
                <?php 
    $to_pay = $puser->getToPayForPeriod(Period::getCurrentPeriod()->getId());
    if ((int) $to_pay) {
        $odd = fmod(++$i, 2) ? 'odd' : 'even';
        ?>
                    <tr class="sf_admin_row <?php 
        echo $odd;
        ?>
">
                        <td><?php 
        echo $puser->getLogin();
        ?>
</td>
                        <td><?php 
        echo $puser->getAccountNumber();
        ?>
</td>
Пример #20
0
/* @var $this TaskController */
/* @var $model Task */
Yii::app()->clientScript->registerScript('search', "\n\$('.search-form form').submit(function(){\n\t\$('#task-grid').yiiGridView('update', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
?>
<ol class="breadcrumb">
    <li><a href="/"><?php 
echo __('Home');
?>
</a></li>
    <li><?php 
echo __('Tasks');
?>
</li>
    <span class="pull-right admin_action">
        <a href="/task/create/<?php 
echo Period::getCurrentPeriod()->id;
?>
"><i
                class="fa fa-plus"></i> <?php 
echo __('Create New Task');
?>
</a>
    </span>
</ol>
<div class="page-header">
    <h3>
        Tasks
    </h3>
</div>
<div class="row">
    <div class="col col-lg-3">
Пример #21
0
 public function setUserContentRating($iUserId, $iTranslateRate)
 {
     $oPeriod = Period::getCurrentPeriod();
     $oUser = UserTable::getInstance()->findOneById($iUserId);
     if (!($oContentRating = $oUser->hasRateTranslate($this->getId()))) {
         $oContentRating = new ContentRating();
         $oContentRating->setContentId($this->getId());
         $oContentRating->setPeriodId($oPeriod->getId());
         $oContentRating->setUserId($iUserId);
     }
     $oContentRating->setContentRating($iTranslateRate);
     $oContentRating->save();
     $aArticles = ContentRatingTable::getInstance()->getRatesByArticle($this->getId(), $oPeriod->getId());
     $iSum = 0;
     foreach ($aArticles as $oRating) {
         $iSum += $oRating->getContentRating();
     }
     $this->setContRate($iSum / $aArticles->count());
     $this->save();
 }
Пример #22
0
echo $balance->getSellPurchaseCnt();
?>
</th>
                <th align="center"><?php 
echo $balance->getAmount();
?>
</th>
            </tr>
            <tr align="center">
                <th>&nbsp;</th>
                <th>Работы</th>
                <th>Количество продаж</th>
                <th>Сумма по продажам</th>
            </tr>
            <?php 
foreach ($user->getSoldForPeriod(Period::getCurrentPeriod()) as $i => $content) {
    $odd = fmod(++$i, 2) ? 'odd' : 'even';
    ?>
            <tr class="sf_admin_row <?php 
    echo $odd;
    ?>
">
                <td>&nbsp;</td>
                <td><a href="<?php 
    echo sfProjectConfiguration::getActive()->generateFrontendUrl('article_by_categories', array('id' => $content->getContent()->getId()));
    ?>
"><p style="text-align: left"><?php 
    echo $content->getContent()->getTitleEn();
    ?>
</p>
Пример #23
0
 /**
  * Saves form
  *
  * @param sfForm $form
  * @param <string> $utype
  * @return User $user
  */
 protected function saveForm(sfForm $form)
 {
     $user = $form->save();
     $group = UserGroupTable::getInstance()->findOneBy('name', $user->getUtype());
     $userGroup = new User__Group();
     $userGroup->setUser($user);
     $userGroup->setGroup($group);
     $userGroup->save();
     $userBalance = new BalanceUser();
     $userBalance->setPeriod(Period::getCurrentPeriod());
     $userBalance->setUser($user);
     $userBalance->save();
     $user->setIsBlocked(true);
     $user->setActivationCode(sha1($user->getEmail() . mt_rand(10, 15)));
     $user->save();
     return $user;
 }