public function actionComplete()
 {
     $id = Yii::$app->request->get('id');
     $model = Orders::findOne($id);
     if ($model->complite == 1) {
         $complite = 2;
     } else {
         $complite = 1;
     }
     $products = unserialize($model->product);
     foreach ($products as $key => $val) {
         $q = Data::find()->where(['title' => $val['title']])->one();
         if ($complite == 2) {
             $q->quantity = $q->quantity - $val['quantity'];
         } else {
             $q->quantity = $q->quantity + $val['quantity'];
         }
         $q->update();
     }
     $model->complite = $complite;
     $model->update();
 }
Esempio n. 2
0
 /**
  * Finds the Orders model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Orders the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Orders::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function actionFail()
 {
     $id = $_POST["InvId"];
     $model = Orders::findOne($id);
     $notpay = "Отказ от оплаты!!!";
     $this->SendMailAdmin($model, $notpay);
     $model->delete();
     echo "Вы отказались то оплаты";
 }