diff --git a/common/models/BusStop.php b/common/models/BusStop.php new file mode 100644 index 0000000..b16abf8 --- /dev/null +++ b/common/models/BusStop.php @@ -0,0 +1,129 @@ + true, 'targetClass' => Region::className(), 'targetAttribute' => ['region_id' => 'region_id']], + [['road_id'], 'exist', 'skipOnError' => true, 'targetClass' => Road::className(), 'targetAttribute' => ['road_id' => 'road_id']], + [['settlement_id'], 'exist', 'skipOnError' => true, 'targetClass' => Settlement::className(), 'targetAttribute' => ['settlement_id' => 'settlement_id']], + [['state_common_id'], 'exist', 'skipOnError' => true, 'targetClass' => StateCommon::className(), 'targetAttribute' => ['state_common_id' => 'state_common_id']], + [['surface_type_id'], 'exist', 'skipOnError' => true, 'targetClass' => SurfaceType::className(), 'targetAttribute' => ['surface_type_id' => 'surface_type_id']], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'bus_stop_id' => 'Індекс', + 'road_id' => 'Дорога', + 'region_id' => 'Область', + 'settlement_id' => 'Назва населеного пункту', + 'location_right' => 'Місцезнаходження, км+ справа', + 'location_left' => 'Місцезнаходження, км+ зліва', + 'surface_type_id' => 'Тип покриття', + 'area_stop_availability' => 'Наявність елементів зупин. майдан', + 'area_land_availability' => 'Наявність елементів посад. майдан', + 'pocket_availability' => 'Наявність елементів заїзна кишеня', + 'toilet_availability' => 'Наявність елементів туалет', + 'year_build' => 'Рік будівництва', + 'year_repair' => 'Рік ремонту', + 'state_common_id' => 'Технічний стан', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getRegion() + { + return $this->hasOne(Region::className(), ['region_id' => 'region_id']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getRoad() + { + return $this->hasOne(Road::className(), ['road_id' => 'road_id']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getSettlement() + { + return $this->hasOne(Settlement::className(), ['settlement_id' => 'settlement_id']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getStateCommon() + { + return $this->hasOne(StateCommon::className(), ['state_common_id' => 'state_common_id']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getSurfaceType() + { + return $this->hasOne(SurfaceType::className(), ['surface_type_id' => 'surface_type_id']); + } + + public function getRightString() + { + return floor($this->location_right) . '+' . ( str_pad(round(( $this->location_right - floor($this->location_right) ) * 1000), 3, '0', STR_PAD_LEFT) ); + } + + public function getLeftString() + { + return floor($this->location_left) . '+' . ( str_pad(round(( $this->location_left - floor($this->location_left) ) * 1000), 3, '0', STR_PAD_LEFT) ); + } +} diff --git a/common/models/BusStopSearch.php b/common/models/BusStopSearch.php new file mode 100644 index 0000000..2e049c8 --- /dev/null +++ b/common/models/BusStopSearch.php @@ -0,0 +1,80 @@ + $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'bus_stop_id' => $this->bus_stop_id, + 'road_id' => $this->road_id, + 'region_id' => $this->region_id, + 'settlement_id' => $this->settlement_id, + 'location_right' => $this->location_right, + 'location_left' => $this->location_left, + 'surface_type_id' => $this->surface_type_id, + 'area_stop_availability' => $this->area_stop_availability, + 'area_land_availability' => $this->area_land_availability, + 'pocket_availability' => $this->pocket_availability, + 'toilet_availability' => $this->toilet_availability, + 'year_build' => $this->year_build, + 'year_repair' => $this->year_repair, + 'state_common_id' => $this->state_common_id, + ]); + + return $dataProvider; + } +} diff --git a/common/models/DepartmentAffiliation.php b/common/models/DepartmentAffiliation.php new file mode 100644 index 0000000..6c3aa68 --- /dev/null +++ b/common/models/DepartmentAffiliation.php @@ -0,0 +1,53 @@ + 255], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'department_affiliation_id' => 'Department Affiliation ID', + 'name' => 'Name', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getServiceObjects() + { + return $this->hasMany(ServiceObject::className(), ['department_affiliation_id' => 'department_affiliation_id']); + } +} diff --git a/common/models/RoadSurface.php b/common/models/RoadSurface.php new file mode 100644 index 0000000..9b83310 --- /dev/null +++ b/common/models/RoadSurface.php @@ -0,0 +1,129 @@ + true, 'targetClass' => Region::className(), 'targetAttribute' => ['region_id' => 'region_id']], + [['road_id'], 'exist', 'skipOnError' => true, 'targetClass' => Road::className(), 'targetAttribute' => ['road_id' => 'road_id']], + [['road_direction_id'], 'exist', 'skipOnError' => true, 'targetClass' => RoadDirection::className(), 'targetAttribute' => ['road_direction_id' => 'road_direction_id']], + [['state_common_id'], 'exist', 'skipOnError' => true, 'targetClass' => StateCommon::className(), 'targetAttribute' => ['state_common_id' => 'state_common_id']], + [['surface_treatment_id'], 'exist', 'skipOnError' => true, 'targetClass' => SurfaceTreatment::className(), 'targetAttribute' => ['surface_treatment_id' => 'surface_treatment_id']], + [['surface_type_id'], 'exist', 'skipOnError' => true, 'targetClass' => SurfaceType::className(), 'targetAttribute' => ['surface_type_id' => 'surface_type_id']], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'road_surface_id' => 'Індекс', + 'road_id' => 'Дорога', + 'region_id' => 'Область', + 'road_direction_id' => 'Напрямок смуги руху', + 'begin' => 'Місцезнаходження, км+ початок', + 'end' => 'Місцезнаходження, км+ кінець', + 'surface_type_id' => 'Тип покриття', + 'surface_treatment_id' => 'Тип поверхневої обробки', + 'state_common_id' => 'Стан покриття', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getRegion() + { + return $this->hasOne(Region::className(), ['region_id' => 'region_id']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getRoad() + { + return $this->hasOne(Road::className(), ['road_id' => 'road_id']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getRoadDirection() + { + return $this->hasOne(RoadDirection::className(), ['road_direction_id' => 'road_direction_id']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getStateCommon() + { + return $this->hasOne(StateCommon::className(), ['state_common_id' => 'state_common_id']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getSurfaceTreatment() + { + return $this->hasOne(SurfaceTreatment::className(), ['surface_treatment_id' => 'surface_treatment_id']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getSurfaceType() + { + return $this->hasOne(SurfaceType::className(), ['surface_type_id' => 'surface_type_id']); + } + + public function getBeginString() + { + return floor($this->begin) . '+' . ( str_pad(round(( $this->begin - floor($this->begin) ) * 1000), 3, '0', STR_PAD_LEFT) ); + } + + public function getEndString() + { + return floor($this->end) . '+' . ( str_pad(round(( $this->end - floor($this->end) ) * 1000), 3, '0', STR_PAD_LEFT) ); + } +} diff --git a/common/models/RoadSurfaceSearch.php b/common/models/RoadSurfaceSearch.php new file mode 100644 index 0000000..1733c01 --- /dev/null +++ b/common/models/RoadSurfaceSearch.php @@ -0,0 +1,75 @@ + $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'road_surface_id' => $this->road_surface_id, + 'road_id' => $this->road_id, + 'region_id' => $this->region_id, + 'road_direction_id' => $this->road_direction_id, + 'begin' => $this->begin, + 'end' => $this->end, + 'surface_type_id' => $this->surface_type_id, + 'surface_treatment_id' => $this->surface_treatment_id, + 'state_common_id' => $this->state_common_id, + ]); + + return $dataProvider; + } +} diff --git a/common/models/ServiceObject.php b/common/models/ServiceObject.php new file mode 100644 index 0000000..cef7a3d --- /dev/null +++ b/common/models/ServiceObject.php @@ -0,0 +1,131 @@ + true, 'targetClass' => DepartmentAffiliation::className(), 'targetAttribute' => ['department_affiliation_id' => 'department_affiliation_id']], + [['region_id'], 'exist', 'skipOnError' => true, 'targetClass' => Region::className(), 'targetAttribute' => ['region_id' => 'region_id']], + [['road_id'], 'exist', 'skipOnError' => true, 'targetClass' => Road::className(), 'targetAttribute' => ['road_id' => 'road_id']], + [['service_object_type_id'], 'exist', 'skipOnError' => true, 'targetClass' => ServiceObjectType::className(), 'targetAttribute' => ['service_object_type_id' => 'service_object_type_id']], + [['settlement_id'], 'exist', 'skipOnError' => true, 'targetClass' => Settlement::className(), 'targetAttribute' => ['settlement_id' => 'settlement_id']], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'service_object_id' => 'Індекс', + 'road_id' => 'Дорога', + 'region_id' => 'Область', + 'service_object_type_id' => 'Вид споруди чи об\'єкту', + 'settlement_id' => 'Назва підприємства та населеного пункту', + 'department_affiliation_id' => 'Відоча приналежність', + 'location_right' => 'Місцезнаходження, км+ справа', + 'location_left' => 'Місцезнаходження, км+ зліва', + 'location_axis' => 'Місцезнаходження, км+ по осі', + 'distance' => 'Відстань до об\'єкту від вісі дор., м', + 'capacity' => 'Потужність', + 'arrangement_elements' => 'Елементи облаштування', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getDepartmentAffiliation() + { + return $this->hasOne(DepartmentAffiliation::className(), ['department_affiliation_id' => 'department_affiliation_id']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getRegion() + { + return $this->hasOne(Region::className(), ['region_id' => 'region_id']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getRoad() + { + return $this->hasOne(Road::className(), ['road_id' => 'road_id']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getServiceObjectType() + { + return $this->hasOne(ServiceObjectType::className(), ['service_object_type_id' => 'service_object_type_id']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getSettlement() + { + return $this->hasOne(Settlement::className(), ['settlement_id' => 'settlement_id']); + } + + public function getLeftString() + { + return floor($this->location_left) . '+' . ( str_pad(round(( $this->location_left - floor($this->location_left) ) * 1000), 3, '0', STR_PAD_LEFT) ); + } + + public function getRightString() + { + return floor($this->location_right) . '+' . ( str_pad(round(( $this->location_right - floor($this->location_right) ) * 1000), 3, '0', STR_PAD_LEFT) ); + } + + public function getAxisString() + { + return floor($this->location_axis) . '+' . ( str_pad(round(( $this->location_axis - floor($this->location_axis) ) * 1000), 3, '0', STR_PAD_LEFT) ); + } +} diff --git a/common/models/ServiceObjectSearch.php b/common/models/ServiceObjectSearch.php new file mode 100644 index 0000000..8e25e71 --- /dev/null +++ b/common/models/ServiceObjectSearch.php @@ -0,0 +1,80 @@ + $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'service_object_id' => $this->service_object_id, + 'road_id' => $this->road_id, + 'region_id' => $this->region_id, + 'service_object_type_id' => $this->service_object_type_id, + 'settlement_id' => $this->settlement_id, + 'department_affiliation_id' => $this->department_affiliation_id, + 'location_right' => $this->location_right, + 'location_left' => $this->location_left, + 'location_axis' => $this->location_axis, + 'distance' => $this->distance, + 'capacity' => $this->capacity, + ]); + + $query->andFilterWhere(['like', 'arrangement_elements', $this->arrangement_elements]); + + return $dataProvider; + } +} diff --git a/common/models/ServiceObjectType.php b/common/models/ServiceObjectType.php new file mode 100644 index 0000000..ee18489 --- /dev/null +++ b/common/models/ServiceObjectType.php @@ -0,0 +1,53 @@ + 255], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'service_object_type_id' => 'Service Object Type ID', + 'name' => 'Name', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getServiceObjects() + { + return $this->hasMany(ServiceObject::className(), ['service_object_type_id' => 'service_object_type_id']); + } +} diff --git a/common/models/SurfaceTreatment.php b/common/models/SurfaceTreatment.php new file mode 100644 index 0000000..8b1aa0d --- /dev/null +++ b/common/models/SurfaceTreatment.php @@ -0,0 +1,53 @@ + 255], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'surface_treatment_id' => 'Surface Treatment ID', + 'name' => 'Name', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getRoadSurfaces() + { + return $this->hasMany(RoadSurface::className(), ['surface_treatment_id' => 'surface_treatment_id']); + } +} diff --git a/console/migrations/m160712_130834_create_road_surface.php b/console/migrations/m160712_130834_create_road_surface.php new file mode 100644 index 0000000..ba4908d --- /dev/null +++ b/console/migrations/m160712_130834_create_road_surface.php @@ -0,0 +1,55 @@ +createTable('road_surface', [ + 'road_surface_id' => $this->primaryKey()->comment('Індекс'), + 'road_id' => $this->integer()->comment('Дорога'), + 'region_id' => $this->integer()->comment('Область'), + 'road_direction_id' => $this->integer()->comment('Напрямок смуги руху'), + 'begin' => $this->float()->comment('Місцезнаходження, км+ початок'), + 'end' => $this->float()->comment('Місцезнаходження, км+ кінець'), + 'surface_type_id' => $this->integer()->comment('Тип покриття'), + 'surface_treatment_id' => $this->integer()->comment('Тип поверхневої обробки'), + 'state_common_id' => $this->integer()->comment('Стан покриття'), + ]); + $this->createTable('surface_treatment', [ + 'surface_treatment_id' => $this->primaryKey(), + 'name' => $this->string(), + ]); + $this->batchInsert('surface_treatment', [ 'name' ], [ + [ 'нема' ], + ]); + $this->addForeignKey('road_surface_road_direction', 'road_surface', 'road_direction_id', 'road_direction', 'road_direction_id', 'CASCADE', 'CASCADE'); + $this->addForeignKey('road_surface_region', 'road_surface', 'region_id', 'region', 'region_id', 'CASCADE', 'CASCADE'); + $this->addForeignKey('road_surface_road', 'road_surface', 'road_id', 'road', 'road_id', 'CASCADE', 'CASCADE'); + $this->addForeignKey('road_surface_surface_type', 'road_surface', 'surface_type_id', 'surface_type', 'surface_type_id', 'CASCADE', 'CASCADE'); + $this->addForeignKey('road_surface_state_common', 'road_surface', 'state_common_id', 'state_common', 'state_common_id', 'CASCADE', 'CASCADE'); + $this->addForeignKey('road_surface_surface_treatment', 'road_surface', 'surface_treatment_id', 'surface_treatment', 'surface_treatment_id', 'CASCADE', 'CASCADE'); + } + + /** + * @inheritdoc + */ + public function down() + { + $this->dropForeignKey('road_surface_road_direction', 'road_surface'); + $this->dropForeignKey('road_surface_region', 'road_surface'); + $this->dropForeignKey('road_surface_road', 'road_surface'); + $this->dropForeignKey('road_surface_surface_type', 'road_surface'); + $this->dropForeignKey('road_surface_state_common', 'road_surface'); + $this->dropForeignKey('road_surface_surface_treatment', 'road_surface'); + $this->dropTable('road_surface'); + $this->dropTable('surface_treatment'); + } +} diff --git a/console/migrations/m160712_144805_create_service_object.php b/console/migrations/m160712_144805_create_service_object.php new file mode 100644 index 0000000..50febf1 --- /dev/null +++ b/console/migrations/m160712_144805_create_service_object.php @@ -0,0 +1,79 @@ +createTable('service_object', [ + 'service_object_id' => $this->primaryKey() + ->comment('Індекс'), + 'road_id' => $this->integer() + ->comment('Дорога'), + 'region_id' => $this->integer() + ->comment('Область'), + 'service_object_type_id' => $this->integer() + ->comment('Вид споруди чи об\'єкту'), + 'settlement_id' => $this->integer() + ->comment('Назва підприємства та населеного пункту'), + 'department_affiliation_id' => $this->integer() + ->comment('Відоча приналежність'), + 'location_right' => $this->float() + ->comment('Місцезнаходження, км+ справа'), + 'location_left' => $this->float() + ->comment('Місцезнаходження, км+ зліва'), + 'location_axis' => $this->float() + ->comment('Місцезнаходження, км+ по осі'), + 'distance' => $this->float() + ->comment('Відстань до об\'єкту від вісі дор., м'), + 'capacity' => $this->float() + ->comment('Потужність'), + 'arrangement_elements' => $this->text() + ->comment('Елементи облаштування'), + ]); + $this->createTable('service_object_type', [ + 'service_object_type_id' => $this->primaryKey(), + 'name' => $this->string(), + ]); + $this->createTable('department_affiliation', [ + 'department_affiliation_id' => $this->primaryKey(), + 'name' => $this->string(), + ]); + $this->batchInsert('service_object_type', [ 'name' ], [ + [ 'кафе' ], + [ 'автозаправочна станція (АЗС)' ], + [ 'мотель' ], + ]); + $this->batchInsert('department_affiliation', [ 'name' ], [ + [ 'Приватне підприємство' ], + ]); + $this->addForeignKey('service_object_road', 'service_object', 'road_id', 'road', 'road_id', 'CASCADE', 'CASCADE'); + $this->addForeignKey('service_object_region', 'service_object', 'region_id', 'region', 'region_id', 'CASCADE', 'CASCADE'); + $this->addForeignKey('service_object_settlement', 'service_object', 'settlement_id', 'settlement', 'settlement_id', 'CASCADE', 'CASCADE'); + $this->addForeignKey('service_object_department_affiliation', 'service_object', 'department_affiliation_id', 'department_affiliation', 'department_affiliation_id', 'CASCADE', 'CASCADE'); + $this->addForeignKey('service_object_service_object_type', 'service_object', 'service_object_type_id', 'service_object_type', 'service_object_type_id', 'CASCADE', 'CASCADE'); + } + + /** + * @inheritdoc + */ + public function down() + { + $this->dropForeignKey('service_object_road', 'service_object'); + $this->dropForeignKey('service_object_region', 'service_object'); + $this->dropForeignKey('service_object_settlement', 'service_object'); + $this->dropForeignKey('service_object_department_affiliation', 'service_object'); + $this->dropForeignKey('service_object_service_object_type', 'service_object'); + $this->dropTable('service_object'); + $this->dropTable('service_object_type'); + $this->dropTable('department_affiliation'); + } + } diff --git a/console/migrations/m160712_144806_create_bus_stop.php b/console/migrations/m160712_144806_create_bus_stop.php new file mode 100644 index 0000000..d41d23e --- /dev/null +++ b/console/migrations/m160712_144806_create_bus_stop.php @@ -0,0 +1,65 @@ +createTable('bus_stop', [ + 'bus_stop_id' => $this->primaryKey() + ->comment('Індекс'), + 'road_id' => $this->integer() + ->comment('Дорога'), + 'region_id' => $this->integer() + ->comment('Область'), + 'settlement_id' => $this->integer() + ->comment('Назва населеного пункту'), + 'location_right' => $this->float() + ->comment('Місцезнаходження, км+ справа'), + 'location_left' => $this->float() + ->comment('Місцезнаходження, км+ зліва'), + 'surface_type_id' => $this->integer() + ->comment('Тип покриття'), + 'area_stop_availability' => $this->integer() + ->comment('Наявність елементів зупин. майдан'), + 'area_land_availability' => $this->integer() + ->comment('Наявність елементів посад. майдан'), + 'pocket_availability' => $this->integer() + ->comment('Наявність елементів заїзна кишеня'), + 'toilet_availability' => $this->integer() + ->comment('Наявність елементів туалет'), + 'year_build' => $this->integer() + ->comment('Рік будівництва'), + 'year_repair' => $this->integer() + ->comment('Рік ремонту'), + 'state_common_id' => $this->integer() + ->comment('Технічний стан'), + ]); + $this->addForeignKey('bus_stop_road', 'bus_stop', 'road_id', 'road', 'road_id', 'CASCADE', 'CASCADE'); + $this->addForeignKey('bus_stop_region', 'bus_stop', 'region_id', 'region', 'region_id', 'CASCADE', 'CASCADE'); + $this->addForeignKey('bus_stop_settlement', 'bus_stop', 'settlement_id', 'settlement', 'settlement_id', 'CASCADE', 'CASCADE'); + $this->addForeignKey('bus_stop_surface_type', 'bus_stop', 'surface_type_id', 'surface_type', 'surface_type_id', 'CASCADE', 'CASCADE'); + $this->addForeignKey('bus_stop_state_common', 'bus_stop', 'state_common_id', 'state_common', 'state_common_id', 'CASCADE', 'CASCADE'); + } + + /** + * @inheritdoc + */ + public function down() + { + $this->dropForeignKey('bus_stop_road', 'bus_stop'); + $this->dropForeignKey('bus_stop_region', 'bus_stop'); + $this->dropForeignKey('bus_stop_settlement', 'bus_stop'); + $this->dropForeignKey('bus_stop_surface_type', 'bus_stop'); + $this->dropForeignKey('bus_stop_state_common', 'bus_stop'); + $this->dropTable('bus_stop'); + } + } diff --git a/frontend/controllers/BusStopController.php b/frontend/controllers/BusStopController.php new file mode 100644 index 0000000..0aed4d1 --- /dev/null +++ b/frontend/controllers/BusStopController.php @@ -0,0 +1,245 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => [ 'POST' ], + ], + ], + ]; + } + + /** + * Lists all BusStop models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new BusStopSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single BusStop model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new BusStop model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new BusStop(); + + $roads = Road::find() + ->select([ + 'name', + 'road_id', + ]) + ->asArray() + ->indexBy('road_id') + ->column(); + + $regions = Region::find() + ->select([ + 'name', + 'region_id', + ]) + ->asArray() + ->indexBy('region_id') + ->column(); + + $settlements = Settlement::find() + ->select([ + 'name', + 'settlement_id', + ]) + ->asArray() + ->indexBy('settlement_id') + ->column(); + + $surface_types = SurfaceType::find() + ->select([ + 'name', + 'surface_type_id', + ]) + ->asArray() + ->indexBy('surface_type_id') + ->column(); + + $state_commons = StateCommon::find() + ->select([ + 'value', + 'state_common_id', + ]) + ->asArray() + ->indexBy('state_common_id') + ->column(); + + if($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect([ + 'view', + 'id' => $model->bus_stop_id, + ]); + } else { + return $this->render('create', [ + 'model' => $model, + 'roads' => $roads, + 'regions' => $regions, + 'settlements' => $settlements, + 'surface_types' => $surface_types, + 'state_commons' => $state_commons, + ]); + } + } + + /** + * Updates an existing BusStop model. + * If update is successful, the browser will be redirected to the 'view' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + $roads = Road::find() + ->select([ + 'name', + 'road_id', + ]) + ->asArray() + ->indexBy('road_id') + ->column(); + + $regions = Region::find() + ->select([ + 'name', + 'region_id', + ]) + ->asArray() + ->indexBy('region_id') + ->column(); + + $settlements = Settlement::find() + ->select([ + 'name', + 'settlement_id', + ]) + ->asArray() + ->indexBy('settlement_id') + ->column(); + + $surface_types = SurfaceType::find() + ->select([ + 'name', + 'surface_type_id', + ]) + ->asArray() + ->indexBy('surface_type_id') + ->column(); + + $state_commons = StateCommon::find() + ->select([ + 'value', + 'state_common_id', + ]) + ->asArray() + ->indexBy('state_common_id') + ->column(); + + if($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect([ + 'view', + 'id' => $model->bus_stop_id, + ]); + } else { + return $this->render('update', [ + 'model' => $model, + 'roads' => $roads, + 'regions' => $regions, + 'settlements' => $settlements, + 'surface_types' => $surface_types, + 'state_commons' => $state_commons, + ]); + } + } + + /** + * Deletes an existing BusStop model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id) + ->delete(); + + return $this->redirect([ 'index' ]); + } + + /** + * Finds the BusStop model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return BusStop the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if(( $model = BusStop::findOne($id) ) !== NULL) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + } diff --git a/frontend/controllers/RoadController.php b/frontend/controllers/RoadController.php index 416210a..7c9b543 100755 --- a/frontend/controllers/RoadController.php +++ b/frontend/controllers/RoadController.php @@ -1,14 +1,17 @@ where([ 'region_id' => $region_ids ]) ->all(); } + $road_surface_regions = [ ]; + $region_ids = [ ]; + $region_ids = RoadSurface::find() + ->distinct() + ->select('region_id') + ->where([ 'road_id' => $id ]) + ->column(); + if(!empty( $region_ids )) { + $road_surface_regions = Region::find() + ->where([ 'region_id' => $region_ids ]) + ->all(); + } + $service_object_regions = [ ]; + $region_ids = [ ]; + $region_ids = ServiceObject::find() + ->distinct() + ->select('region_id') + ->where([ 'road_id' => $id ]) + ->column(); + if(!empty( $region_ids )) { + $service_object_regions = Region::find() + ->where([ 'region_id' => $region_ids ]) + ->all(); + } + $bus_stop_regions = [ ]; + $region_ids = [ ]; + $region_ids = BusStop::find() + ->distinct() + ->select('region_id') + ->where([ 'road_id' => $id ]) + ->column(); + if(!empty( $region_ids )) { + $bus_stop_regions = Region::find() + ->where([ 'region_id' => $region_ids ]) + ->all(); + } $road_to_categories = [ ]; $region_ids = [ ]; $region_ids = RoadToCategory::find() @@ -215,6 +254,9 @@ 'cross_section_regions' => $cross_section_regions, 'road_to_categories' => $road_to_categories, 'road_width' => $road_width, + 'road_surface_regions' => $road_surface_regions, + 'service_object_regions' => $service_object_regions, + 'bus_stop_regions' => $bus_stop_regions, ]); } @@ -317,7 +359,7 @@ ]); } - public function actionCrossSection($id, $region_id) + public function actionCrossSection(int $id, int $region_id) { $road = Road::findOne($id); if(empty( $road )) { @@ -341,4 +383,79 @@ 'dataProvider' => $dataProvider, ]); } + + public function actionRoadSurface(int $id, int $region_id) + { + $road = Road::findOne($id); + if(empty( $road )) { + throw new NotFoundHttpException('Road not found'); + } + $region = Region::findOne($region_id); + if(empty( $region )) { + throw new NotFoundHttpException('Region not found'); + } + $dataProvider = new ActiveDataProvider([ + 'query' => RoadSurface::find() + ->where([ + 'road_id' => $id, + 'region_id' => $region_id, + ]), + 'pagination' => false, + ]); + return $this->render('road-surface', [ + 'road' => $road, + 'region' => $region, + 'dataProvider' => $dataProvider, + ]); + } + + public function actionServiceObject(int $id, int $region_id) + { + $road = Road::findOne($id); + if(empty( $road )) { + throw new NotFoundHttpException('Road not found'); + } + $region = Region::findOne($region_id); + if(empty( $region )) { + throw new NotFoundHttpException('Region not found'); + } + $dataProvider = new ActiveDataProvider([ + 'query' => ServiceObject::find() + ->where([ + 'road_id' => $id, + 'region_id' => $region_id, + ]), + 'pagination' => false, + ]); + return $this->render('service-object', [ + 'road' => $road, + 'region' => $region, + 'dataProvider' => $dataProvider, + ]); + } + + public function actionBusStop(int $id, int $region_id) + { + $road = Road::findOne($id); + if(empty( $road )) { + throw new NotFoundHttpException('Road not found'); + } + $region = Region::findOne($region_id); + if(empty( $region )) { + throw new NotFoundHttpException('Region not found'); + } + $dataProvider = new ActiveDataProvider([ + 'query' => BusStop::find() + ->where([ + 'road_id' => $id, + 'region_id' => $region_id, + ]), + 'pagination' => false, + ]); + return $this->render('bus-stop', [ + 'road' => $road, + 'region' => $region, + 'dataProvider' => $dataProvider, + ]); + } } diff --git a/frontend/controllers/RoadSurfaceController.php b/frontend/controllers/RoadSurfaceController.php new file mode 100644 index 0000000..5d8b02b --- /dev/null +++ b/frontend/controllers/RoadSurfaceController.php @@ -0,0 +1,266 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => [ 'POST' ], + ], + ], + ]; + } + + /** + * Lists all RoadSurface models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new RoadSurfaceSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single RoadSurface model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new RoadSurface model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new RoadSurface(); + + $roads = Road::find() + ->select([ + 'name', + 'road_id', + ]) + ->asArray() + ->indexBy('road_id') + ->column(); + + $regions = Region::find() + ->select([ + 'name', + 'region_id', + ]) + ->asArray() + ->indexBy('region_id') + ->column(); + + $road_directions = RoadDirection::find() + ->select([ + 'direction_name', + 'road_direction_id', + ]) + ->asArray() + ->indexBy('road_direction_id') + ->column(); + + $surface_types = SurfaceType::find() + ->select([ + 'name', + 'surface_type_id', + ]) + ->asArray() + ->indexBy('surface_type_id') + ->column(); + + $surface_treatments = SurfaceTreatment::find() + ->select([ + 'name', + 'surface_treatment_id', + ]) + ->asArray() + ->indexBy('surface_treatment_id') + ->column(); + + $state_commons = StateCommon::find() + ->select([ + 'value', + 'state_common_id', + ]) + ->asArray() + ->indexBy('state_common_id') + ->column(); + + if($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect([ + 'view', + 'id' => $model->road_surface_id, + ]); + } else { + return $this->render('create', [ + 'model' => $model, + 'roads' => $roads, + 'regions' => $regions, + 'road_directions' => $road_directions, + 'surface_types' => $surface_types, + 'surface_treatments' => $surface_treatments, + 'state_commons' => $state_commons, + ]); + } + } + + /** + * Updates an existing RoadSurface model. + * If update is successful, the browser will be redirected to the 'view' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + $roads = Road::find() + ->select([ + 'name', + 'road_id', + ]) + ->asArray() + ->indexBy('road_id') + ->column(); + + $regions = Region::find() + ->select([ + 'name', + 'region_id', + ]) + ->asArray() + ->indexBy('region_id') + ->column(); + + $road_directions = RoadDirection::find() + ->select([ + 'direction_name', + 'road_direction_id', + ]) + ->asArray() + ->indexBy('road_direction_id') + ->column(); + + $surface_types = SurfaceType::find() + ->select([ + 'name', + 'surface_type_id', + ]) + ->asArray() + ->indexBy('surface_type_id') + ->column(); + + $surface_treatments = SurfaceTreatment::find() + ->select([ + 'name', + 'surface_treatment_id', + ]) + ->asArray() + ->indexBy('surface_treatment_id') + ->column(); + + $state_commons = StateCommon::find() + ->select([ + 'value', + 'state_common_id', + ]) + ->asArray() + ->indexBy('state_common_id') + ->column(); + + if($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect([ + 'view', + 'id' => $model->road_surface_id, + ]); + } else { + return $this->render('update', [ + 'model' => $model, + 'roads' => $roads, + 'regions' => $regions, + 'road_directions' => $road_directions, + 'surface_types' => $surface_types, + 'surface_treatments' => $surface_treatments, + 'state_commons' => $state_commons, + ]); + } + } + + /** + * Deletes an existing RoadSurface model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id) + ->delete(); + + return $this->redirect([ 'index' ]); + } + + /** + * Finds the RoadSurface model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return RoadSurface the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if(( $model = RoadSurface::findOne($id) ) !== NULL) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + } diff --git a/frontend/controllers/ServiceObjectController.php b/frontend/controllers/ServiceObjectController.php new file mode 100644 index 0000000..fd41069 --- /dev/null +++ b/frontend/controllers/ServiceObjectController.php @@ -0,0 +1,245 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => [ 'POST' ], + ], + ], + ]; + } + + /** + * Lists all ServiceObject models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new ServiceObjectSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single ServiceObject model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new ServiceObject model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new ServiceObject(); + + $roads = Road::find() + ->select([ + 'name', + 'road_id', + ]) + ->asArray() + ->indexBy('road_id') + ->column(); + + $regions = Region::find() + ->select([ + 'name', + 'region_id', + ]) + ->asArray() + ->indexBy('region_id') + ->column(); + + $service_object_types = ServiceObjectType::find() + ->select([ + 'name', + 'service_object_type_id', + ]) + ->asArray() + ->indexBy('service_object_type_id') + ->column(); + + $settlements = Settlement::find() + ->select([ + 'name', + 'settlement_id', + ]) + ->asArray() + ->indexBy('settlement_id') + ->column(); + + $department_affiliations = DepartmentAffiliation::find() + ->select([ + 'name', + 'department_affiliation_id', + ]) + ->asArray() + ->indexBy('department_affiliation_id') + ->column(); + + if($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect([ + 'view', + 'id' => $model->service_object_id, + ]); + } else { + return $this->render('create', [ + 'model' => $model, + 'roads' => $roads, + 'regions' => $regions, + 'service_object_types' => $service_object_types, + 'settlements' => $settlements, + 'department_affiliations' => $department_affiliations, + ]); + } + } + + /** + * Updates an existing ServiceObject model. + * If update is successful, the browser will be redirected to the 'view' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + $roads = Road::find() + ->select([ + 'name', + 'road_id', + ]) + ->asArray() + ->indexBy('road_id') + ->column(); + + $regions = Region::find() + ->select([ + 'name', + 'region_id', + ]) + ->asArray() + ->indexBy('region_id') + ->column(); + + $service_object_types = ServiceObjectType::find() + ->select([ + 'name', + 'service_object_type_id', + ]) + ->asArray() + ->indexBy('service_object_type_id') + ->column(); + + $settlements = Settlement::find() + ->select([ + 'name', + 'settlement_id', + ]) + ->asArray() + ->indexBy('settlement_id') + ->column(); + + $department_affiliations = DepartmentAffiliation::find() + ->select([ + 'name', + 'department_affiliation_id', + ]) + ->asArray() + ->indexBy('department_affiliation_id') + ->column(); + + if($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect([ + 'view', + 'id' => $model->service_object_id, + ]); + } else { + return $this->render('update', [ + 'model' => $model, + 'roads' => $roads, + 'regions' => $regions, + 'service_object_types' => $service_object_types, + 'settlements' => $settlements, + 'department_affiliations' => $department_affiliations, + ]); + } + } + + /** + * Deletes an existing ServiceObject model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id) + ->delete(); + + return $this->redirect([ 'index' ]); + } + + /** + * Finds the ServiceObject model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return ServiceObject the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if(( $model = ServiceObject::findOne($id) ) !== NULL) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + } diff --git a/frontend/views/bus-stop/_form.php b/frontend/views/bus-stop/_form.php new file mode 100644 index 0000000..37e4b99 --- /dev/null +++ b/frontend/views/bus-stop/_form.php @@ -0,0 +1,67 @@ + + +
+ = Html::a('Create Bus Stop', ['create'], ['class' => 'btn btn-success']) ?> +
+ = GridView::widget([ + 'dataProvider' => $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'bus_stop_id', + 'road_id', + 'region_id', + 'settlement_id', + 'location_right', + // 'location_left', + // 'surface_type_id', + // 'area_stop_availability', + // 'area_land_availability', + // 'pocket_availability', + // 'toilet_availability', + // 'year_build', + // 'year_repair', + // 'state_common_id', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> ++ = Html::a('Update', ['update', 'id' => $model->bus_stop_id], ['class' => 'btn btn-primary']) ?> + = Html::a('Delete', ['delete', 'id' => $model->bus_stop_id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ]) ?> +
+ + = DetailView::widget([ + 'model' => $model, + 'attributes' => [ + 'bus_stop_id', + 'road_id', + 'region_id', + 'settlement_id', + 'location_right', + 'location_left', + 'surface_type_id', + 'area_stop_availability', + 'area_land_availability', + 'pocket_availability', + 'toilet_availability', + 'year_build', + 'year_repair', + 'state_common_id', + ], + ]) ?> + ++ = Html::a('Create Road Surface', ['create'], ['class' => 'btn btn-success']) ?> +
+ = GridView::widget([ + 'dataProvider' => $dataProvider, + 'filterModel' => null, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + [ + 'attribute' => 'road_id', + 'value' => function($model) { + /** + * @var RoadSurface $model + */ + return $model->road->name; + } + ], + [ + 'attribute' => 'region_id', + 'value' => function($model) { + /** + * @var RoadSurface $model + */ + return $model->region->name; + } + ], + [ + 'attribute' => 'road_direction_id', + 'value' => function($model) { + /** + * @var RoadSurface $model + */ + return $model->roadDirection->direction_name; + } + ], + [ + 'attribute' => 'begin', + 'value' => function($model) { + /** + * @var RoadSurface $model + */ + return $model->getBeginString(); + } + ], + [ + 'attribute' => 'end', + 'value' => function($model) { + /** + * @var RoadSurface $model + */ + return $model->getEndString(); + } + ], + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> ++ = Html::a('Update', ['update', 'id' => $model->road_surface_id], ['class' => 'btn btn-primary']) ?> + = Html::a('Delete', ['delete', 'id' => $model->road_surface_id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ]) ?> +
+ + = DetailView::widget([ + 'model' => $model, + 'attributes' => [ + 'road_surface_id', + 'road_id', + 'region_id', + 'road_direction_id', + 'begin', + 'end', + 'surface_type_id', + 'surface_treatment_id', + 'state_common_id', + ], + ]) ?> + +Відомість
+наявності та технічного стану
+автобусних зупинок
+на автомобільній дорозі
+name; ?>
+roadType->definition;?> значення станом на р.
+Відомість
+наявності та технічного стану покриття
+покриття автодоріг
+на автомобільній дорозі
+name; ?>
+roadType->definition;?> значення станом на р.
+Відомість
+наявносіті
+споруд автослужб, об'єктів сервісу
+на автомобільній дорозі
++ name; ?> +
++ roadType->definition; ?> + значення станом на + р. +
++ = Html::a('Create Service Object', [ 'create' ], [ 'class' => 'btn btn-success' ]) ?> +
+ = GridView::widget([ + 'dataProvider' => $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + [ 'class' => 'yii\grid\SerialColumn' ], + [ + 'attribute' => 'location_right', + 'value' => function($model) { + /** + * @var ServiceObject $model + */ + return $model->getRightString(); + }, + ], + [ + 'attribute' => 'location_left', + 'value' => function($model) { + /** + * @var ServiceObject $model + */ + return $model->getLeftString(); + }, + ], + [ + 'attribute' => 'location_axis', + 'value' => function($model) { + /** + * @var ServiceObject $model + */ + return $model->getAxisString(); + }, + ], + [ + 'attribute' => 'road_id', + 'value' => function($model) { + /** + * @var ServiceObject $model + */ + return $model->road->name; + }, + ], + [ + 'attribute' => 'region_id', + 'value' => function($model) { + /** + * @var ServiceObject $model + */ + return $model->region->name; + }, + ], + [ + 'attribute' => 'service_object_type_id', + 'value' => function($model) { + /** + * @var ServiceObject $model + */ + return $model->serviceObjectType->name; + }, + ], + [ 'class' => 'yii\grid\ActionColumn' ], + ], + ]); ?> ++ = Html::a('Update', ['update', 'id' => $model->service_object_id], ['class' => 'btn btn-primary']) ?> + = Html::a('Delete', ['delete', 'id' => $model->service_object_id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ]) ?> +
+ + = DetailView::widget([ + 'model' => $model, + 'attributes' => [ + 'service_object_id', + 'road_id', + 'region_id', + 'service_object_type_id', + 'settlement_id', + 'department_affiliation_id', + 'location_right', + 'location_left', + 'location_axis', + 'distance', + 'capacity', + 'arrangement_elements:ntext', + ], + ]) ?> + +