Exemplo n.º 1
0
 public function search($params)
 {
     $query = PersonalAccount::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'service_id' => $this->service_id]);
     $query->andFilterWhere(['like', 'value', $this->value]);
     return $dataProvider;
 }
Exemplo n.º 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;
     }
 }
Exemplo n.º 3
0
 public function getAccs()
 {
     return $this->hasMany(PersonalAccount::className(), ['user_id' => 'id']);
 }
Exemplo n.º 4
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);
 }