예제 #1
0
 public function actionIndex()
 {
     if (Yii::app()->user->isGuest) {
         $this->redirect(Yii::app()->homeUrl);
     }
     $this->pageTitle = Yii::t('title', 'Webshop');
     $criteria = new CDbCriteria();
     $criteria->select = '*';
     $criteria->order = 'category_id';
     $model = WebshopCategory::model()->findAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->select = '*';
     $criteria->order = 'id';
     $membership = Membership::model()->findAll($criteria);
     if (isset($_POST['Membership'])) {
         $account = AccountData::model()->findByPk(Yii::app()->user->id);
         $info = Membership::model()->findByPk($_POST['Membership']['id']);
         if ($account->membership == 0) {
             if ($account[Yii::app()->params->money] >= $info->price) {
                 $account->membership = $info->type;
                 $account->expire = date("Y-m-d", mktime() + $info->duration * 86400);
                 $account[Yii::app()->params->money] = $account[Yii::app()->params->money] - $info->price;
                 $account->save();
                 $log = new LogMembership();
                 $log->account = Yii::app()->user->name;
                 $log->title = $info->title;
                 $log->type = Info::membership($info->type);
                 $log->duration = $info->duration;
                 $log->price = $info->price;
                 $log->save();
                 Yii::app()->user->setFlash('message', '<div class="flash_success">' . Yii::t('webshop', 'Account updated!') . '</div>');
                 $this->redirect('webshop');
             } else {
                 Yii::app()->user->setFlash('message', '<div class="flash_error">' . Yii::t('webshop', 'Insufficient funds.') . '</div>');
                 $this->redirect('webshop');
             }
         } else {
             Yii::app()->user->setFlash('message', '<div class="flash_error">' . Yii::t('webshop', 'You have outdated privileges still active, please update them.') . '</div>');
             $this->redirect('webshop');
         }
     }
     $this->render('index', array('model' => $model, 'membership' => $membership));
 }
예제 #2
0
				<td><?php 
echo $ref_link;
?>
</td>
			</tr>
			<tr>
				<td>Уровень доступа</td>
				<td><?php 
echo Info::access_level($model->access_level);
?>
</td>
			</tr>
			<tr>
				<td>Привилегии аккаунта</td>
				<td><?php 
echo Info::membership($model->membership);
?>
</td>
			</tr>
			<tr>
				<td>Истекают</td>
				<td><?php 
echo $model->expire;
?>
</td>
			</tr>
			<tr>
				<td>Последний IP</td>
				<td><?php 
echo $model->last_ip;
?>
예제 #3
0
				<th width="20%">Цена</td>
				<th width="20%">Выбрать</td>
			</tr>
		<?php 
foreach ($membership as $membership) {
    ?>
			<tr class="center">
				<td><label for="Membership_id_<?php 
    echo $membership->id;
    ?>
"><?php 
    echo $membership->title;
    ?>
</label></td>
				<td><?php 
    echo Info::membership($membership->type);
    ?>
</td>
				<td><?php 
    echo $membership->duration;
    ?>
</td>
				<td><?php 
    echo $membership->price;
    ?>
 points</td>
				<td><input type="radio" id="Membership_id_<?php 
    echo $membership->id;
    ?>
" name="Membership[id]" value="<?php 
    echo $membership->id;
예제 #4
0
				<th>Title</th>
				<th>Type</th>
				<th>Duration</th>
				<th>Price</th>
				<th colspan="2">Edit/delete</th>
			</tr>
		<?php 
foreach ($model as $data) {
    ?>
			<tr align="center">
				<td><?php 
    echo $data->title;
    ?>
</td>
				<td><?php 
    echo Info::membership($data->type);
    ?>
</td>
				<td><?php 
    echo $data->duration;
    ?>
</td>
				<td><?php 
    echo $data->price;
    ?>
</td>

				<td width="36px"><a href="<?php 
    echo Yii::app()->homeUrl . 'admin/webshop/membership/' . $data->id;
    ?>
" /><img src="<?php