コード例 #1
0
 public function actionSearched()
 {
     if (User::isAdmin(Yii::$app->user->identity->username)) {
         $link = new ActiveDataProvider(['query' => Searched::find(), 'pagination' => ['pageSize' => 10]]);
         return $this->render('searched', compact('link'));
     } else {
         throw new ForbiddenHttpException('У вас нет прав администратора!', 404);
     }
 }
コード例 #2
0
 public function actionIndex()
 {
     $dataSender = null;
     $searched = Searched::find()->where(['status' => Searched::STATUS_ACTIVE])->andWhere(['!=', 'plan_id', '1'])->all();
     foreach ($searched as $search) {
         $items = Items::search(json_decode($search->url, true))->limit($search->plan->max_allow_sms)->all();
         foreach ($items as $item) {
             $sms = new SmsClient('0676124113', '0673188966');
             $id = $sms->sendSMS('Sishik.net', $search->user->phone, 'Ваш товар найден: ' . $item->url);
             if ($sms->hasErrors()) {
                 var_dump($sms->getErrors());
             } else {
                 $sms = new Sms();
                 $sms->search_id = $search->id;
                 $sms->text = 'Ваш товар найден: ' . $item->url;
                 $sms->status = Sms::STATUS_DELIVERED;
                 $sms->save();
             }
         }
     }
 }
コード例 #3
0
 /**
  * @param $id
  * @return \yii\web\Response
  */
 public function actionDeactivate($id)
 {
     if (Searched::updateAll(['status' => Searched::STATUS_INACTIVE], ['id' => $id, 'status' => Searched::STATUS_ACTIVE, 'user_id' => Yii::$app->user->id])) {
         return $this->redirect('/user/profile');
     } else {
         return $this->goHome();
     }
 }
コード例 #4
0
ファイル: Sms.php プロジェクト: Sywooch/find-parser
 /**
  * Получение информации о поиске
  * @return \yii\db\ActiveQuery
  */
 public function getSearch()
 {
     return $this->hasOne(Searched::className(), ['search_id' => 'id']);
 }
コード例 #5
0
 /**
  * Рендер личного кабинета пользователя
  * @return string
  */
 public function actionProfile()
 {
     $data = User::findOne(Yii::$app->user->id);
     $query = Searched::find()->where(['user_id' => Yii::$app->user->id]);
     $link = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     return $this->render('profile', compact('data', 'link'));
 }
コード例 #6
0
ファイル: profile.php プロジェクト: Sywooch/find-parser
    </div>
    <div class="row">
        <div class="panel panel-default">
            <div class="panel-heading"><i class="fa fa-sign-in"></i>Мои поиски</div>
            <div class="panel-body">
                <?php 
echo GridView::widget(['id' => 'tableData', 'dataProvider' => $link, 'tableOptions' => ['class' => 'table table-striped table-responsive'], 'columns' => [['label' => '№', 'value' => function ($model) {
    return $model->id;
}], ['label' => 'Категория', 'value' => function ($model) {
    $url_data = json_decode($model->url, true);
    $category = \common\models\Category::findOne($url_data['category_id']);
    return $category->title;
}], ['label' => 'Пользовательский текст', 'value' => function ($model) {
    $url_data = json_decode($model->url, true);
    if (!empty($url_data['text'])) {
        return $url_data['text'];
    } else {
        return "Не задан";
    }
}], ['label' => '', 'format' => 'raw', 'contentOptions' => ['class' => 'text-left mnw250'], 'value' => function ($model) {
    return '<a href="/delete/' . $model->id . '" class="btn btn-mini btn-default">Удалить поиск</a>';
}], ['label' => '', 'format' => 'raw', 'contentOptions' => ['class' => 'text-left mnw250'], 'value' => function ($model) {
    $url_data = json_decode($model->url, true);
    return Searched::isBuy($model->id) ? Searched::isActive($model->id) ? '<a href="/deactivate/' . $model->id . '" class="btn btn-mini btn-default">Деактивировать смс рассылку</a>' : '<a href="/activate/' . $model->id . '" class="btn btn-mini btn-default">Активировать смс рассылку</a>' : '<a href="' . \yii\helpers\Url::to('/plans/set/') . $model->id . '/' . $url_data['category_id'] . '" class="btn btn-mini btn-default">Активировать</a>';
}]]]);
?>
            </div>
        </div>
    </div>
<?php 
Pjax::end();
コード例 #7
0
 public function actionTransaction($id)
 {
     $result = Yii::$app->request->post();
     $json_data = base64_decode($result['data']);
     $data = json_decode($json_data, true);
     if ($data) {
         Transaction::saveTransaction($data, $id);
     }
     if ($data['status'] === 'success') {
         $this->send();
         if ($model = Searched::updateAll(['plan_id' => $data['description']], ['id' => $id])) {
             return $this->redirect('/user/profile');
         } else {
             return $this->goHome();
         }
     } else {
         return $this->goHome();
     }
 }