Example #1
0
 public function search($params)
 {
     $query = PaymentData::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'service_id' => $this->service_id, 'personal_acc_id' => $this->personal_acc_id]);
     $query->andFilterWhere(['like', 'kvit_date', $this->kvit_date])->andFilterWhere(['like', 'dept_end', $this->dept_end])->andFilterWhere(['like', 'dept_begin', $this->dept_begin])->andFilterWhere(['like', 'paid', $this->paid])->andFilterWhere(['like', 'enrolled', $this->enrolled]);
     return $dataProvider;
 }
Example #2
0
 public function actionServiceItem($id)
 {
     $service = Services::findOne($id);
     if ($service && !\Yii::$app->user->isGuest) {
         $user = User::findOne(\Yii::$app->user->id);
         $persAcc = PersonalAccount::find()->where('user_id = :user_id', [':user_id' => $user->id])->andWhere('service_id = :service_id', [':service_id' => $id])->one();
         $history = PaymentData::find()->where('service_id = :service_id', [':service_id' => $id])->andWhere('personal_acc_id = :personal_acc_id', [':personal_acc_id' => $persAcc->id])->all();
         return $this->render('service-item', ['service' => $service, 'history' => $history, 'persAcc' => $persAcc]);
     } else {
         return false;
     }
 }
Example #3
0
 public function actionGetHistoryForService()
 {
     $token = $this->getToken();
     if ($token) {
         $user = User::find()->where('password_reset_token = :token', [':token' => $token])->one();
         if (!empty($user)) {
             if (!empty($_POST['bill']) && !empty($_POST['service_id'])) {
                 $service = Services::find()->where('id = :id', [':id' => $_POST['service_id']])->one();
                 if ($service) {
                     $persAcc = PersonalAccount::find()->where('value = :value', [':value' => $_POST['bill']])->one();
                     if ($persAcc) {
                         $result = ['status' => ['code' => 200, 'message' => 'ОК'], 'data' => ['tariff' => $service->tariff, 'tariff_measure' => $service->tariff_measure, 'history' => []]];
                         $history = PaymentData::find()->where('personal_acc_id = :personal_acc_id', [':personal_acc_id' => $persAcc->id])->andWhere('service_id = :service_id', [':service_id' => $_POST['service_id']])->all();
                         if ($history) {
                             foreach ($history as $index => $payment) {
                                 $result['data']['history'][$index] = ['date' => "" . $payment->kvit_date, 'dept_end' => $payment->dept_end, 'dept_begin' => $payment->dept_begin, 'enrolled' => $payment->enrolled, 'paid' => $payment->paid, 'bill' => $_POST['bill']];
                             }
                         }
                     } else {
                         $result = ['status' => ['code' => 409, 'message' => 'Лицевой счет не найден']];
                     }
                 } else {
                     $result = ['status' => ['code' => 406, 'message' => 'Услуга не найдена']];
                 }
             } else {
                 $result = ['status' => ['code' => 403, 'message' => 'Не все обязательные поля заполнены']];
             }
         } else {
             $result = ['status' => ['code' => 402, 'message' => 'Пользователь не найден']];
         }
     } else {
         $result = ['status' => ['code' => 400, 'message' => 'Значение Token не задано']];
     }
     return Json::encode($result);
 }