/**
  * @return string
  */
 public function actionIndex()
 {
     $this->layout = 'home';
     $subcat = new Subcategory();
     $cat = Category::find()->all();
     $basicModel = PaymentPlans::findOne(['name' => 'Basic']);
     $advancedModel = PaymentPlans::findOne(['name' => 'Advanced']);
     $proModel = PaymentPlans::findOne(['name' => 'Pro']);
     return $this->render('index', compact('cat', 'subcat', 'basic', 'advanced', 'pro', 'basicModel', 'advancedModel', 'proModel'));
 }
 /**
  * @param $id
  * @return string|yii\web\Response
  * @throws ForbiddenHttpException
  */
 public function actionEdit($id)
 {
     if (User::isAdmin(Yii::$app->user->identity->username)) {
         $model = new PaymentPlans();
         $value = PaymentPlans::findOne($id);
         if (Yii::$app->request->isPost) {
             $item = Yii::$app->request->post('PaymentPlans');
             if ($plan = PaymentPlans::updateAll(['name' => $item['name'], 'max_allow_sms' => $item['max_allow_sms'], 'price' => $item['price']], ['id' => $id])) {
                 return $this->redirect('/plans/index');
             } else {
                 throw new ForbiddenHttpException('Ошибка обновление тарифного плана!', 404);
             }
         }
         return $this->render('edit', compact('model', 'value'));
     } else {
         throw new ForbiddenHttpException('У вас нет прав администратора!', 404);
     }
 }
 public function actionSet($id, $category_id)
 {
     if ($category_id == '2') {
         $basicModel = PaymentPlans::findOne(['name' => 'BasicElectronic']);
         $advancedModel = PaymentPlans::findOne(['name' => 'AdvancedElectronic']);
         $proModel = PaymentPlans::findOne(['name' => 'ProElectronic']);
     } else {
         if ($category_id == '3') {
             $basicModel = PaymentPlans::findOne(['name' => 'BasicTransport']);
             $advancedModel = PaymentPlans::findOne(['name' => 'AdvancedTransport']);
             $proModel = PaymentPlans::findOne(['name' => 'ProTransport']);
         } else {
             $basicModel = PaymentPlans::findOne(['name' => 'Basic']);
             $advancedModel = PaymentPlans::findOne(['name' => 'Advanced']);
             $proModel = PaymentPlans::findOne(['name' => 'Pro']);
         }
     }
     $liqpay = new LiqPay('i3673026691', '3fOw8EDMYgscpvSO8XkmIuAWmV5vkwBcE7FUV9h0');
     $basic = $liqpay->cnb_form(['version' => '3', 'phone' => Yii::$app->user->identity->phone, 'amount' => $basicModel->price, 'currency' => 'UAH', 'description' => $basicModel->id, 'order_id' => Yii::$app->security->generateRandomString(), 'server_url' => 'http://sishik.net/plans/transaction/' . $id, 'result_url' => 'http://sishik.net/user/profile']);
     $advanced = $liqpay->cnb_form(['version' => '3', 'phone' => Yii::$app->user->identity->phone, 'amount' => $advancedModel->price, 'currency' => 'UAH', 'description' => $advancedModel->id, 'order_id' => Yii::$app->security->generateRandomString(), 'server_url' => 'http://sishik.net/plans/transaction/' . $id, 'result_url' => 'http://sishik.net/user/profile']);
     $pro = $liqpay->cnb_form(['version' => '3', 'phone' => Yii::$app->user->identity->phone, 'amount' => $proModel->price, 'currency' => 'UAH', 'description' => $proModel->id, 'order_id' => Yii::$app->security->generateRandomString(), 'server_url' => 'http://sishik.net/plans/transaction/' . $id, 'result_url' => 'http://sishik.net/user/profile']);
     return $this->render('set', compact('basic', 'advanced', 'pro', 'basicModel', 'advancedModel', 'proModel'));
 }