public function getIsSufficiency($people = false) { $count_people_now = $this->count_kids + $this->count_adult; $QuotaTimeTable = QuotaTimeTable::find()->where(['<=', 'start_date', $this->date]); $QuotaTimeTable = $QuotaTimeTable->andWhere(['>=', 'end_date', $this->date])->all(); if (isset($QuotaTimeTable[0])) { $time_table = $QuotaTimeTable[0]; $id_quota = $time_table->id_type; } else { $id_quota = 1; } $QuotaType = QuotaType::findOne($id_quota); $date1 = strtotime(date("Y-m-d 00:00:00", strtotime($this->date))); $date2 = strtotime(date("Y-m-d 23:59:59", strtotime($this->date))); $count_people_order_resudie = $QuotaType->getResudie($this->type_ticket, $date1, $date2); if ($people == false) { echo "Count All=" . $count_people_order_resudie; echo "Count Now=" . $count_people_now; if ($count_people_now < $count_people_order_resudie) { return false; } else { return true; } } else { if ($count_people_order_resudie > 0) { return true; } else { return false; } } }
/** * Finds the QuotaType model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return QuotaType the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = QuotaType::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }