Commit 984ae8aafb298057bd2171e602b910b5e9b422c3
1 parent
a6d2664d
120716
Showing
19 changed files
with
1178 additions
and
0 deletions
Show diff stats
1 | +<?php | |
2 | + | |
3 | +namespace common\models; | |
4 | + | |
5 | +use Yii; | |
6 | + | |
7 | +/** | |
8 | + * This is the model class for table "road_to_category". | |
9 | + * | |
10 | + * @property integer $road_to_category_id | |
11 | + * @property integer $region_id | |
12 | + * @property integer $road_id | |
13 | + * @property double $begin | |
14 | + * @property double $end | |
15 | + * @property double $distance | |
16 | + * @property integer $road_category_id | |
17 | + * | |
18 | + * @property Region $region | |
19 | + * @property Road $road | |
20 | + * @property RoadCategory $roadCategory | |
21 | + */ | |
22 | +class RoadToCategory extends \yii\db\ActiveRecord | |
23 | +{ | |
24 | + /** | |
25 | + * @inheritdoc | |
26 | + */ | |
27 | + public static function tableName() | |
28 | + { | |
29 | + return 'road_to_category'; | |
30 | + } | |
31 | + | |
32 | + /** | |
33 | + * @inheritdoc | |
34 | + */ | |
35 | + public function rules() | |
36 | + { | |
37 | + return [ | |
38 | + [['region_id', 'road_id', 'road_category_id'], 'integer'], | |
39 | + [['begin', 'end', 'distance'], 'number'], | |
40 | + [['region_id'], 'exist', 'skipOnError' => true, 'targetClass' => Region::className(), 'targetAttribute' => ['region_id' => 'region_id']], | |
41 | + [['road_id'], 'exist', 'skipOnError' => true, 'targetClass' => Road::className(), 'targetAttribute' => ['road_id' => 'road_id']], | |
42 | + [['road_category_id'], 'exist', 'skipOnError' => true, 'targetClass' => RoadCategory::className(), 'targetAttribute' => ['road_category_id' => 'road_category_id']], | |
43 | + ]; | |
44 | + } | |
45 | + | |
46 | + /** | |
47 | + * @inheritdoc | |
48 | + */ | |
49 | + public function attributeLabels() | |
50 | + { | |
51 | + return [ | |
52 | + 'road_to_category_id' => 'Індекс', | |
53 | + 'region_id' => 'Область', | |
54 | + 'road_id' => 'Дорога', | |
55 | + 'begin' => 'Місцезнаходження, км+ початок', | |
56 | + 'end' => 'Місцезнаходження, км+ кінець', | |
57 | + 'distance' => 'Протяжність, км', | |
58 | + 'road_category_id' => 'Категорія', | |
59 | + ]; | |
60 | + } | |
61 | + | |
62 | + /** | |
63 | + * @return \yii\db\ActiveQuery | |
64 | + */ | |
65 | + public function getRegion() | |
66 | + { | |
67 | + return $this->hasOne(Region::className(), ['region_id' => 'region_id']); | |
68 | + } | |
69 | + | |
70 | + /** | |
71 | + * @return \yii\db\ActiveQuery | |
72 | + */ | |
73 | + public function getRoad() | |
74 | + { | |
75 | + return $this->hasOne(Road::className(), ['road_id' => 'road_id']); | |
76 | + } | |
77 | + | |
78 | + /** | |
79 | + * @return \yii\db\ActiveQuery | |
80 | + */ | |
81 | + public function getRoadCategory() | |
82 | + { | |
83 | + return $this->hasOne(RoadCategory::className(), ['road_category_id' => 'road_category_id']); | |
84 | + } | |
85 | + | |
86 | + public function getBeginString() | |
87 | + { | |
88 | + return floor($this->begin) . '+' . ( str_pad(round(( $this->begin - floor($this->begin) ) * 1000), 3, '0', STR_PAD_LEFT) ); | |
89 | + } | |
90 | + | |
91 | + public function getEndString() | |
92 | + { | |
93 | + return floor($this->end) . '+' . ( str_pad(round(( $this->end - floor($this->end) ) * 1000), 3, '0', STR_PAD_LEFT) ); | |
94 | + } | |
95 | +} | ... | ... |
1 | +<?php | |
2 | + | |
3 | +namespace common\models; | |
4 | + | |
5 | +use Yii; | |
6 | +use yii\base\Model; | |
7 | +use yii\data\ActiveDataProvider; | |
8 | +use common\models\RoadToCategory; | |
9 | + | |
10 | +/** | |
11 | + * RoadToCategorySearch represents the model behind the search form about `common\models\RoadToCategory`. | |
12 | + */ | |
13 | +class RoadToCategorySearch extends RoadToCategory | |
14 | +{ | |
15 | + /** | |
16 | + * @inheritdoc | |
17 | + */ | |
18 | + public function rules() | |
19 | + { | |
20 | + return [ | |
21 | + [['road_to_category_id', 'region_id', 'road_id', 'road_category_id'], 'integer'], | |
22 | + [['begin', 'end', 'distance'], 'number'], | |
23 | + ]; | |
24 | + } | |
25 | + | |
26 | + /** | |
27 | + * @inheritdoc | |
28 | + */ | |
29 | + public function scenarios() | |
30 | + { | |
31 | + // bypass scenarios() implementation in the parent class | |
32 | + return Model::scenarios(); | |
33 | + } | |
34 | + | |
35 | + /** | |
36 | + * Creates data provider instance with search query applied | |
37 | + * | |
38 | + * @param array $params | |
39 | + * | |
40 | + * @return ActiveDataProvider | |
41 | + */ | |
42 | + public function search($params) | |
43 | + { | |
44 | + $query = RoadToCategory::find(); | |
45 | + | |
46 | + // add conditions that should always apply here | |
47 | + | |
48 | + $dataProvider = new ActiveDataProvider([ | |
49 | + 'query' => $query, | |
50 | + ]); | |
51 | + | |
52 | + $this->load($params); | |
53 | + | |
54 | + if (!$this->validate()) { | |
55 | + // uncomment the following line if you do not want to return any records when validation fails | |
56 | + // $query->where('0=1'); | |
57 | + return $dataProvider; | |
58 | + } | |
59 | + | |
60 | + // grid filtering conditions | |
61 | + $query->andFilterWhere([ | |
62 | + 'road_to_category_id' => $this->road_to_category_id, | |
63 | + 'region_id' => $this->region_id, | |
64 | + 'road_id' => $this->road_id, | |
65 | + 'begin' => $this->begin, | |
66 | + 'end' => $this->end, | |
67 | + 'distance' => $this->distance, | |
68 | + 'road_category_id' => $this->road_category_id, | |
69 | + ]); | |
70 | + | |
71 | + return $dataProvider; | |
72 | + } | |
73 | +} | ... | ... |
1 | +<?php | |
2 | + | |
3 | +namespace common\models; | |
4 | + | |
5 | +use Yii; | |
6 | + | |
7 | +/** | |
8 | + * This is the model class for table "road_width". | |
9 | + * | |
10 | + * @property integer $road_width_id | |
11 | + * @property integer $region_id | |
12 | + * @property integer $road_id | |
13 | + * @property double $begin | |
14 | + * @property double $end | |
15 | + * @property double $width_roadside_left | |
16 | + * @property double $width_reverse_road | |
17 | + * @property double $width_strip | |
18 | + * @property double $width_roadway_forward | |
19 | + * @property double $width_roadside_right | |
20 | + * @property double $count_lane_left | |
21 | + * @property double $count_lane_right | |
22 | + * | |
23 | + * @property Region $region | |
24 | + * @property Road $road | |
25 | + */ | |
26 | +class RoadWidth extends \yii\db\ActiveRecord | |
27 | +{ | |
28 | + /** | |
29 | + * @inheritdoc | |
30 | + */ | |
31 | + public static function tableName() | |
32 | + { | |
33 | + return 'road_width'; | |
34 | + } | |
35 | + | |
36 | + /** | |
37 | + * @inheritdoc | |
38 | + */ | |
39 | + public function rules() | |
40 | + { | |
41 | + return [ | |
42 | + [['region_id', 'road_id'], 'integer'], | |
43 | + [['begin', 'end', 'width_roadside_left', 'width_reverse_road', 'width_strip', 'width_roadway_forward', 'width_roadside_right', 'count_lane_left', 'count_lane_right'], 'number'], | |
44 | + [['region_id'], 'exist', 'skipOnError' => true, 'targetClass' => Region::className(), 'targetAttribute' => ['region_id' => 'region_id']], | |
45 | + [['road_id'], 'exist', 'skipOnError' => true, 'targetClass' => Road::className(), 'targetAttribute' => ['road_id' => 'road_id']], | |
46 | + ]; | |
47 | + } | |
48 | + | |
49 | + /** | |
50 | + * @inheritdoc | |
51 | + */ | |
52 | + public function attributeLabels() | |
53 | + { | |
54 | + return [ | |
55 | + 'road_width_id' => 'Індекс', | |
56 | + 'region_id' => 'Область', | |
57 | + 'road_id' => 'Дорога', | |
58 | + 'begin' => 'Місцезнаходженя, км+ початок', | |
59 | + 'end' => 'Місцезнаходженя, км+ кінець', | |
60 | + 'width_roadside_left' => 'Ширина, узбіччя зліва', | |
61 | + 'width_reverse_road' => 'Ширина, проїзна зворотнього напрямку', | |
62 | + 'width_strip' => 'Ширина, розподільча смуга', | |
63 | + 'width_roadway_forward' => 'Ширина, проїзна прямого напрямку', | |
64 | + 'width_roadside_right' => 'Ширина, узбіччя справа', | |
65 | + 'count_lane_left' => 'Кількість смуг руху зліва', | |
66 | + 'count_lane_right' => 'Кількість смуг руху справа', | |
67 | + ]; | |
68 | + } | |
69 | + | |
70 | + /** | |
71 | + * @return \yii\db\ActiveQuery | |
72 | + */ | |
73 | + public function getRegion() | |
74 | + { | |
75 | + return $this->hasOne(Region::className(), ['region_id' => 'region_id']); | |
76 | + } | |
77 | + | |
78 | + /** | |
79 | + * @return \yii\db\ActiveQuery | |
80 | + */ | |
81 | + public function getRoad() | |
82 | + { | |
83 | + return $this->hasOne(Road::className(), ['road_id' => 'road_id']); | |
84 | + } | |
85 | + | |
86 | + public function getBeginString() | |
87 | + { | |
88 | + return floor($this->begin) . '+' . ( str_pad(round(( $this->begin - floor($this->begin) ) * 1000), 3, '0', STR_PAD_LEFT) ); | |
89 | + } | |
90 | + | |
91 | + public function getEndString() | |
92 | + { | |
93 | + return floor($this->end) . '+' . ( str_pad(round(( $this->end - floor($this->end) ) * 1000), 3, '0', STR_PAD_LEFT) ); | |
94 | + } | |
95 | +} | ... | ... |
1 | +<?php | |
2 | + | |
3 | +namespace common\models; | |
4 | + | |
5 | +use Yii; | |
6 | +use yii\base\Model; | |
7 | +use yii\data\ActiveDataProvider; | |
8 | +use common\models\RoadWidth; | |
9 | + | |
10 | +/** | |
11 | + * RoadWidthSearch represents the model behind the search form about `common\models\RoadWidth`. | |
12 | + */ | |
13 | +class RoadWidthSearch extends RoadWidth | |
14 | +{ | |
15 | + /** | |
16 | + * @inheritdoc | |
17 | + */ | |
18 | + public function rules() | |
19 | + { | |
20 | + return [ | |
21 | + [['road_width_id', 'region_id', 'road_id'], 'integer'], | |
22 | + [['begin', 'end', 'width_roadside_left', 'width_reverse_road', 'width_strip', 'width_roadway_forward', 'width_roadside_right', 'count_lane_left', 'count_lane_right'], 'number'], | |
23 | + ]; | |
24 | + } | |
25 | + | |
26 | + /** | |
27 | + * @inheritdoc | |
28 | + */ | |
29 | + public function scenarios() | |
30 | + { | |
31 | + // bypass scenarios() implementation in the parent class | |
32 | + return Model::scenarios(); | |
33 | + } | |
34 | + | |
35 | + /** | |
36 | + * Creates data provider instance with search query applied | |
37 | + * | |
38 | + * @param array $params | |
39 | + * | |
40 | + * @return ActiveDataProvider | |
41 | + */ | |
42 | + public function search($params) | |
43 | + { | |
44 | + $query = RoadWidth::find(); | |
45 | + | |
46 | + // add conditions that should always apply here | |
47 | + | |
48 | + $dataProvider = new ActiveDataProvider([ | |
49 | + 'query' => $query, | |
50 | + ]); | |
51 | + | |
52 | + $this->load($params); | |
53 | + | |
54 | + if (!$this->validate()) { | |
55 | + // uncomment the following line if you do not want to return any records when validation fails | |
56 | + // $query->where('0=1'); | |
57 | + return $dataProvider; | |
58 | + } | |
59 | + | |
60 | + // grid filtering conditions | |
61 | + $query->andFilterWhere([ | |
62 | + 'road_width_id' => $this->road_width_id, | |
63 | + 'region_id' => $this->region_id, | |
64 | + 'road_id' => $this->road_id, | |
65 | + 'begin' => $this->begin, | |
66 | + 'end' => $this->end, | |
67 | + 'width_roadside_left' => $this->width_roadside_left, | |
68 | + 'width_reverse_road' => $this->width_reverse_road, | |
69 | + 'width_strip' => $this->width_strip, | |
70 | + 'width_roadway_forward' => $this->width_roadway_forward, | |
71 | + 'width_roadside_right' => $this->width_roadside_right, | |
72 | + 'count_lane_left' => $this->count_lane_left, | |
73 | + 'count_lane_right' => $this->count_lane_right, | |
74 | + ]); | |
75 | + | |
76 | + return $dataProvider; | |
77 | + } | |
78 | +} | ... | ... |
console/migrations/m160712_142430_create_road_width.php
0 → 100644
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +/** | |
6 | + * Handles the creation for table `road_width`. | |
7 | + */ | |
8 | +class m160712_142430_create_road_width extends Migration | |
9 | +{ | |
10 | + /** | |
11 | + * @inheritdoc | |
12 | + */ | |
13 | + public function up() | |
14 | + { | |
15 | + $this->createTable('road_width', [ | |
16 | + 'road_width_id' => $this->primaryKey()->comment('Індекс'), | |
17 | + 'region_id' => $this->integer()->comment('Область'), | |
18 | + 'road_id' => $this->integer()->comment('Дорога'), | |
19 | + 'begin' => $this->float()->comment('Місцезнаходженя, км+ початок'), | |
20 | + 'end' => $this->float()->comment('Місцезнаходженя, км+ кінець'), | |
21 | + 'width_roadside_left' => $this->float()->comment('Ширина, узбіччя зліва'), | |
22 | + 'width_reverse_road' => $this->float()->comment('Ширина, проїзна зворотнього напрямку'), | |
23 | + 'width_strip' => $this->float()->comment('Ширина, розподільча смуга'), | |
24 | + 'width_roadway_forward' => $this->float()->comment('Ширина, проїзна прямого напрямку'), | |
25 | + 'width_roadside_right' => $this->float()->comment('Ширина, узбіччя справа'), | |
26 | + 'count_lane_left' => $this->float()->comment('Кількість смуг руху зліва'), | |
27 | + 'count_lane_right' => $this->float()->comment('Кількість смуг руху справа'), | |
28 | + | |
29 | + ]); | |
30 | + $this->addForeignKey('road_width_region', 'road_width', 'region_id', 'region', 'region_id', 'CASCADE', 'CASCADE'); | |
31 | + $this->addForeignKey('road_width_road', 'road_width', 'road_id', 'road', 'road_id', 'CASCADE', 'CASCADE'); | |
32 | + } | |
33 | + | |
34 | + /** | |
35 | + * @inheritdoc | |
36 | + */ | |
37 | + public function down() | |
38 | + { | |
39 | + $this->dropForeignKey('road_width_region', 'road_width'); | |
40 | + $this->dropForeignKey('road_width_road', 'road_width'); | |
41 | + $this->dropTable('road_width'); | |
42 | + } | |
43 | +} | ... | ... |
1 | +<?php | |
2 | + | |
3 | +namespace frontend\controllers; | |
4 | + | |
5 | +use common\models\Region; | |
6 | +use common\models\Road; | |
7 | +use common\models\RoadCategory; | |
8 | +use Yii; | |
9 | +use common\models\RoadToCategory; | |
10 | +use common\models\RoadToCategorySearch; | |
11 | +use yii\web\Controller; | |
12 | +use yii\web\NotFoundHttpException; | |
13 | +use yii\filters\VerbFilter; | |
14 | + | |
15 | +/** | |
16 | + * RoadToCategoryController implements the CRUD actions for RoadToCategory model. | |
17 | + */ | |
18 | +class RoadToCategoryController extends Controller | |
19 | +{ | |
20 | + /** | |
21 | + * @inheritdoc | |
22 | + */ | |
23 | + public function behaviors() | |
24 | + { | |
25 | + return [ | |
26 | + 'verbs' => [ | |
27 | + 'class' => VerbFilter::className(), | |
28 | + 'actions' => [ | |
29 | + 'delete' => ['POST'], | |
30 | + ], | |
31 | + ], | |
32 | + ]; | |
33 | + } | |
34 | + | |
35 | + /** | |
36 | + * Lists all RoadToCategory models. | |
37 | + * @return mixed | |
38 | + */ | |
39 | + public function actionIndex() | |
40 | + { | |
41 | + $searchModel = new RoadToCategorySearch(); | |
42 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | |
43 | + | |
44 | + return $this->render('index', [ | |
45 | + 'searchModel' => $searchModel, | |
46 | + 'dataProvider' => $dataProvider, | |
47 | + ]); | |
48 | + } | |
49 | + | |
50 | + /** | |
51 | + * Displays a single RoadToCategory model. | |
52 | + * @param integer $id | |
53 | + * @return mixed | |
54 | + */ | |
55 | + public function actionView($id) | |
56 | + { | |
57 | + return $this->render('view', [ | |
58 | + 'model' => $this->findModel($id), | |
59 | + ]); | |
60 | + } | |
61 | + | |
62 | + /** | |
63 | + * Creates a new RoadToCategory model. | |
64 | + * If creation is successful, the browser will be redirected to the 'view' page. | |
65 | + * @return mixed | |
66 | + */ | |
67 | + public function actionCreate() | |
68 | + { | |
69 | + $model = new RoadToCategory(); | |
70 | + $regions = Region::find() | |
71 | + ->select([ | |
72 | + 'name', | |
73 | + 'region_id', | |
74 | + ]) | |
75 | + ->indexBy('region_id') | |
76 | + ->asArray() | |
77 | + ->column(); | |
78 | + $roads = Road::find() | |
79 | + ->select([ | |
80 | + 'name', | |
81 | + 'road_id', | |
82 | + ]) | |
83 | + ->indexBy('road_id') | |
84 | + ->asArray() | |
85 | + ->column(); | |
86 | + $road_categories = RoadCategory::find() | |
87 | + ->select([ | |
88 | + 'value', | |
89 | + 'road_category_id', | |
90 | + ]) | |
91 | + ->indexBy('road_id') | |
92 | + ->asArray() | |
93 | + ->column(); | |
94 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
95 | + return $this->redirect(['view', 'id' => $model->road_to_category_id]); | |
96 | + } else { | |
97 | + return $this->render('create', [ | |
98 | + 'model' => $model, | |
99 | + 'regions' => $regions, | |
100 | + 'roads' => $roads, | |
101 | + 'road_categories' => $road_categories, | |
102 | + ]); | |
103 | + } | |
104 | + } | |
105 | + | |
106 | + /** | |
107 | + * Updates an existing RoadToCategory model. | |
108 | + * If update is successful, the browser will be redirected to the 'view' page. | |
109 | + * @param integer $id | |
110 | + * @return mixed | |
111 | + */ | |
112 | + public function actionUpdate($id) | |
113 | + { | |
114 | + $model = $this->findModel($id); | |
115 | + $regions = Region::find() | |
116 | + ->select([ | |
117 | + 'name', | |
118 | + 'region_id', | |
119 | + ]) | |
120 | + ->indexBy('region_id') | |
121 | + ->asArray() | |
122 | + ->column(); | |
123 | + $roads = Road::find() | |
124 | + ->select([ | |
125 | + 'name', | |
126 | + 'road_id', | |
127 | + ]) | |
128 | + ->indexBy('road_id') | |
129 | + ->asArray() | |
130 | + ->column(); | |
131 | + $road_categories = RoadCategory::find() | |
132 | + ->select([ | |
133 | + 'value', | |
134 | + 'road_category_id', | |
135 | + ]) | |
136 | + ->indexBy('road_id') | |
137 | + ->asArray() | |
138 | + ->column(); | |
139 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
140 | + return $this->redirect(['view', 'id' => $model->road_to_category_id]); | |
141 | + } else { | |
142 | + return $this->render('update', [ | |
143 | + 'model' => $model, | |
144 | + 'regions' => $regions, | |
145 | + 'roads' => $roads, | |
146 | + 'road_categories' => $road_categories, | |
147 | + ]); | |
148 | + } | |
149 | + } | |
150 | + | |
151 | + /** | |
152 | + * Deletes an existing RoadToCategory model. | |
153 | + * If deletion is successful, the browser will be redirected to the 'index' page. | |
154 | + * @param integer $id | |
155 | + * @return mixed | |
156 | + */ | |
157 | + public function actionDelete($id) | |
158 | + { | |
159 | + $this->findModel($id)->delete(); | |
160 | + | |
161 | + return $this->redirect(['index']); | |
162 | + } | |
163 | + | |
164 | + /** | |
165 | + * Finds the RoadToCategory model based on its primary key value. | |
166 | + * If the model is not found, a 404 HTTP exception will be thrown. | |
167 | + * @param integer $id | |
168 | + * @return RoadToCategory the loaded model | |
169 | + * @throws NotFoundHttpException if the model cannot be found | |
170 | + */ | |
171 | + protected function findModel($id) | |
172 | + { | |
173 | + if (($model = RoadToCategory::findOne($id)) !== null) { | |
174 | + return $model; | |
175 | + } else { | |
176 | + throw new NotFoundHttpException('The requested page does not exist.'); | |
177 | + } | |
178 | + } | |
179 | +} | ... | ... |
1 | +<?php | |
2 | + | |
3 | +namespace frontend\controllers; | |
4 | + | |
5 | +use common\models\Region; | |
6 | +use common\models\Road; | |
7 | +use Yii; | |
8 | +use common\models\RoadWidth; | |
9 | +use common\models\RoadWidthSearch; | |
10 | +use yii\web\Controller; | |
11 | +use yii\web\NotFoundHttpException; | |
12 | +use yii\filters\VerbFilter; | |
13 | + | |
14 | +/** | |
15 | + * RoadWidthController implements the CRUD actions for RoadWidth model. | |
16 | + */ | |
17 | +class RoadWidthController extends Controller | |
18 | +{ | |
19 | + /** | |
20 | + * @inheritdoc | |
21 | + */ | |
22 | + public function behaviors() | |
23 | + { | |
24 | + return [ | |
25 | + 'verbs' => [ | |
26 | + 'class' => VerbFilter::className(), | |
27 | + 'actions' => [ | |
28 | + 'delete' => ['POST'], | |
29 | + ], | |
30 | + ], | |
31 | + ]; | |
32 | + } | |
33 | + | |
34 | + /** | |
35 | + * Lists all RoadWidth models. | |
36 | + * @return mixed | |
37 | + */ | |
38 | + public function actionIndex() | |
39 | + { | |
40 | + $searchModel = new RoadWidthSearch(); | |
41 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | |
42 | + | |
43 | + return $this->render('index', [ | |
44 | + 'searchModel' => $searchModel, | |
45 | + 'dataProvider' => $dataProvider, | |
46 | + ]); | |
47 | + } | |
48 | + | |
49 | + /** | |
50 | + * Displays a single RoadWidth model. | |
51 | + * @param integer $id | |
52 | + * @return mixed | |
53 | + */ | |
54 | + public function actionView($id) | |
55 | + { | |
56 | + return $this->render('view', [ | |
57 | + 'model' => $this->findModel($id), | |
58 | + ]); | |
59 | + } | |
60 | + | |
61 | + /** | |
62 | + * Creates a new RoadWidth model. | |
63 | + * If creation is successful, the browser will be redirected to the 'view' page. | |
64 | + * @return mixed | |
65 | + */ | |
66 | + public function actionCreate() | |
67 | + { | |
68 | + $model = new RoadWidth(); | |
69 | + $regions = Region::find() | |
70 | + ->select([ | |
71 | + 'name', | |
72 | + 'region_id', | |
73 | + ]) | |
74 | + ->indexBy('region_id') | |
75 | + ->asArray() | |
76 | + ->column(); | |
77 | + $roads = Road::find() | |
78 | + ->select([ | |
79 | + 'name', | |
80 | + 'road_id', | |
81 | + ]) | |
82 | + ->indexBy('road_id') | |
83 | + ->asArray() | |
84 | + ->column(); | |
85 | + | |
86 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
87 | + return $this->redirect(['view', 'id' => $model->road_width_id]); | |
88 | + } else { | |
89 | + return $this->render('create', [ | |
90 | + 'model' => $model, | |
91 | + 'regions' => $regions, | |
92 | + 'roads' => $roads, | |
93 | + ]); | |
94 | + } | |
95 | + } | |
96 | + | |
97 | + /** | |
98 | + * Updates an existing RoadWidth model. | |
99 | + * If update is successful, the browser will be redirected to the 'view' page. | |
100 | + * @param integer $id | |
101 | + * @return mixed | |
102 | + */ | |
103 | + public function actionUpdate($id) | |
104 | + { | |
105 | + $model = $this->findModel($id); | |
106 | + $regions = Region::find() | |
107 | + ->select([ | |
108 | + 'name', | |
109 | + 'region_id', | |
110 | + ]) | |
111 | + ->indexBy('region_id') | |
112 | + ->asArray() | |
113 | + ->column(); | |
114 | + $roads = Road::find() | |
115 | + ->select([ | |
116 | + 'name', | |
117 | + 'road_id', | |
118 | + ]) | |
119 | + ->indexBy('road_id') | |
120 | + ->asArray() | |
121 | + ->column(); | |
122 | + | |
123 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
124 | + return $this->redirect(['view', 'id' => $model->road_width_id]); | |
125 | + } else { | |
126 | + return $this->render('update', [ | |
127 | + 'model' => $model, | |
128 | + 'regions' => $regions, | |
129 | + 'roads' => $roads, | |
130 | + ]); | |
131 | + } | |
132 | + } | |
133 | + | |
134 | + /** | |
135 | + * Deletes an existing RoadWidth model. | |
136 | + * If deletion is successful, the browser will be redirected to the 'index' page. | |
137 | + * @param integer $id | |
138 | + * @return mixed | |
139 | + */ | |
140 | + public function actionDelete($id) | |
141 | + { | |
142 | + $this->findModel($id)->delete(); | |
143 | + | |
144 | + return $this->redirect(['index']); | |
145 | + } | |
146 | + | |
147 | + /** | |
148 | + * Finds the RoadWidth model based on its primary key value. | |
149 | + * If the model is not found, a 404 HTTP exception will be thrown. | |
150 | + * @param integer $id | |
151 | + * @return RoadWidth the loaded model | |
152 | + * @throws NotFoundHttpException if the model cannot be found | |
153 | + */ | |
154 | + protected function findModel($id) | |
155 | + { | |
156 | + if (($model = RoadWidth::findOne($id)) !== null) { | |
157 | + return $model; | |
158 | + } else { | |
159 | + throw new NotFoundHttpException('The requested page does not exist.'); | |
160 | + } | |
161 | + } | |
162 | +} | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | +use yii\widgets\ActiveForm; | |
5 | + | |
6 | +/** | |
7 | + * @var yii\web\View $this | |
8 | + * @var common\models\RoadToCategory $model | |
9 | + * @var array $regions | |
10 | + * @var array $roads | |
11 | + * @var array $road_categories | |
12 | + * @var yii\widgets\ActiveForm $form | |
13 | + */ | |
14 | +?> | |
15 | + | |
16 | +<div class="road-to-category-form"> | |
17 | + | |
18 | + <?php $form = ActiveForm::begin(); ?> | |
19 | + | |
20 | + <?= $form->field($model, 'region_id')->dropDownList($regions) ?> | |
21 | + | |
22 | + <?= $form->field($model, 'road_id')->dropDownList($roads) ?> | |
23 | + | |
24 | + <?= $form->field($model, 'begin')->textInput() ?> | |
25 | + | |
26 | + <?= $form->field($model, 'end')->textInput() ?> | |
27 | + | |
28 | + <?= $form->field($model, 'distance')->textInput() ?> | |
29 | + | |
30 | + <?= $form->field($model, 'road_category_id')->dropDownList($road_categories) ?> | |
31 | + | |
32 | + <div class="form-group"> | |
33 | + <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | |
34 | + </div> | |
35 | + | |
36 | + <?php ActiveForm::end(); ?> | |
37 | + | |
38 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | +use yii\widgets\ActiveForm; | |
5 | + | |
6 | +/* @var $this yii\web\View */ | |
7 | +/* @var $model common\models\RoadToCategorySearch */ | |
8 | +/* @var $form yii\widgets\ActiveForm */ | |
9 | +?> | |
10 | + | |
11 | +<div class="road-to-category-search"> | |
12 | + | |
13 | + <?php $form = ActiveForm::begin([ | |
14 | + 'action' => ['index'], | |
15 | + 'method' => 'get', | |
16 | + ]); ?> | |
17 | + | |
18 | + <?= $form->field($model, 'road_to_category_id') ?> | |
19 | + | |
20 | + <?= $form->field($model, 'region_id') ?> | |
21 | + | |
22 | + <?= $form->field($model, 'road_id') ?> | |
23 | + | |
24 | + <?= $form->field($model, 'begin') ?> | |
25 | + | |
26 | + <?= $form->field($model, 'end') ?> | |
27 | + | |
28 | + <?php // echo $form->field($model, 'distance') ?> | |
29 | + | |
30 | + <?php // echo $form->field($model, 'road_category_id') ?> | |
31 | + | |
32 | + <div class="form-group"> | |
33 | + <?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?> | |
34 | + <?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?> | |
35 | + </div> | |
36 | + | |
37 | + <?php ActiveForm::end(); ?> | |
38 | + | |
39 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | + | |
5 | + | |
6 | +/** | |
7 | + * @var yii\web\View $this | |
8 | + * @var common\models\RoadToCategory $model | |
9 | + * @var array $regions | |
10 | + * @var array $roads | |
11 | + * @var array $road_categories | |
12 | + */ | |
13 | + | |
14 | +$this->title = 'Create Road To Category'; | |
15 | +$this->params['breadcrumbs'][] = ['label' => 'Road To Categories', 'url' => ['index']]; | |
16 | +$this->params['breadcrumbs'][] = $this->title; | |
17 | +?> | |
18 | +<div class="road-to-category-create"> | |
19 | + | |
20 | + <h1><?= Html::encode($this->title) ?></h1> | |
21 | + | |
22 | + <?= $this->render('_form', [ | |
23 | + 'model' => $model, | |
24 | + 'regions' => $regions, | |
25 | + 'roads' => $roads, | |
26 | + 'road_categories' => $road_categories, | |
27 | + ]) ?> | |
28 | + | |
29 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | +use yii\grid\GridView; | |
5 | + | |
6 | +/* @var $this yii\web\View */ | |
7 | +/* @var $searchModel common\models\RoadToCategorySearch */ | |
8 | +/* @var $dataProvider yii\data\ActiveDataProvider */ | |
9 | + | |
10 | +$this->title = 'Road To Categories'; | |
11 | +$this->params['breadcrumbs'][] = $this->title; | |
12 | +?> | |
13 | +<div class="road-to-category-index"> | |
14 | + | |
15 | + <h1><?= Html::encode($this->title) ?></h1> | |
16 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | |
17 | + | |
18 | + <p> | |
19 | + <?= Html::a('Create Road To Category', ['create'], ['class' => 'btn btn-success']) ?> | |
20 | + </p> | |
21 | + <?= GridView::widget([ | |
22 | + 'dataProvider' => $dataProvider, | |
23 | + 'filterModel' => $searchModel, | |
24 | + 'columns' => [ | |
25 | + ['class' => 'yii\grid\SerialColumn'], | |
26 | + | |
27 | + 'road_to_category_id', | |
28 | + 'region_id', | |
29 | + 'road_id', | |
30 | + 'begin', | |
31 | + 'end', | |
32 | + // 'distance', | |
33 | + // 'road_category_id', | |
34 | + | |
35 | + ['class' => 'yii\grid\ActionColumn'], | |
36 | + ], | |
37 | + ]); ?> | |
38 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | + | |
5 | +/** | |
6 | + * @var yii\web\View $this | |
7 | + * @var common\models\RoadToCategory $model | |
8 | + * @var array $regions | |
9 | + * @var array $roads | |
10 | + * @var array $road_categories | |
11 | + */ | |
12 | + | |
13 | +$this->title = 'Update Road To Category: ' . $model->road_to_category_id; | |
14 | +$this->params['breadcrumbs'][] = ['label' => 'Road To Categories', 'url' => ['index']]; | |
15 | +$this->params['breadcrumbs'][] = ['label' => $model->road_to_category_id, 'url' => ['view', 'id' => $model->road_to_category_id]]; | |
16 | +$this->params['breadcrumbs'][] = 'Update'; | |
17 | +?> | |
18 | +<div class="road-to-category-update"> | |
19 | + | |
20 | + <h1><?= Html::encode($this->title) ?></h1> | |
21 | + | |
22 | + <?= $this->render('_form', [ | |
23 | + 'model' => $model, | |
24 | + 'regions' => $regions, | |
25 | + 'roads' => $roads, | |
26 | + 'road_categories' => $road_categories, | |
27 | + ]) ?> | |
28 | + | |
29 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | +use yii\widgets\DetailView; | |
5 | + | |
6 | +/* @var $this yii\web\View */ | |
7 | +/* @var $model common\models\RoadToCategory */ | |
8 | + | |
9 | +$this->title = $model->road_to_category_id; | |
10 | +$this->params['breadcrumbs'][] = ['label' => 'Road To Categories', 'url' => ['index']]; | |
11 | +$this->params['breadcrumbs'][] = $this->title; | |
12 | +?> | |
13 | +<div class="road-to-category-view"> | |
14 | + | |
15 | + <h1><?= Html::encode($this->title) ?></h1> | |
16 | + | |
17 | + <p> | |
18 | + <?= Html::a('Update', ['update', 'id' => $model->road_to_category_id], ['class' => 'btn btn-primary']) ?> | |
19 | + <?= Html::a('Delete', ['delete', 'id' => $model->road_to_category_id], [ | |
20 | + 'class' => 'btn btn-danger', | |
21 | + 'data' => [ | |
22 | + 'confirm' => 'Are you sure you want to delete this item?', | |
23 | + 'method' => 'post', | |
24 | + ], | |
25 | + ]) ?> | |
26 | + </p> | |
27 | + | |
28 | + <?= DetailView::widget([ | |
29 | + 'model' => $model, | |
30 | + 'attributes' => [ | |
31 | + 'road_to_category_id', | |
32 | + 'region_id', | |
33 | + 'road_id', | |
34 | + 'begin', | |
35 | + 'end', | |
36 | + 'distance', | |
37 | + 'road_category_id', | |
38 | + ], | |
39 | + ]) ?> | |
40 | + | |
41 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | +use yii\widgets\ActiveForm; | |
5 | + | |
6 | +/* | |
7 | + * @var yii\web\View $this | |
8 | + * @var common\models\RoadWidth $model | |
9 | + * @var yii\widgets\ActiveForm $form | |
10 | + * @var array $regions | |
11 | + * @var array $roads | |
12 | + */ | |
13 | +?> | |
14 | + | |
15 | +<div class="road-width-form"> | |
16 | + | |
17 | + <?php $form = ActiveForm::begin(); ?> | |
18 | + | |
19 | + <?= $form->field($model, 'region_id')->dropDownList($regions) ?> | |
20 | + | |
21 | + <?= $form->field($model, 'road_id')->dropDownList($roads) ?> | |
22 | + | |
23 | + <?= $form->field($model, 'begin')->textInput() ?> | |
24 | + | |
25 | + <?= $form->field($model, 'end')->textInput() ?> | |
26 | + | |
27 | + <?= $form->field($model, 'width_roadside_left')->textInput() ?> | |
28 | + | |
29 | + <?= $form->field($model, 'width_reverse_road')->textInput() ?> | |
30 | + | |
31 | + <?= $form->field($model, 'width_strip')->textInput() ?> | |
32 | + | |
33 | + <?= $form->field($model, 'width_roadway_forward')->textInput() ?> | |
34 | + | |
35 | + <?= $form->field($model, 'width_roadside_right')->textInput() ?> | |
36 | + | |
37 | + <?= $form->field($model, 'count_lane_left')->textInput() ?> | |
38 | + | |
39 | + <?= $form->field($model, 'count_lane_right')->textInput() ?> | |
40 | + | |
41 | + <div class="form-group"> | |
42 | + <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | |
43 | + </div> | |
44 | + | |
45 | + <?php ActiveForm::end(); ?> | |
46 | + | |
47 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | +use yii\widgets\ActiveForm; | |
5 | + | |
6 | +/* @var $this yii\web\View */ | |
7 | +/* @var $model common\models\RoadWidthSearch */ | |
8 | +/* @var $form yii\widgets\ActiveForm */ | |
9 | +?> | |
10 | + | |
11 | +<div class="road-width-search"> | |
12 | + | |
13 | + <?php $form = ActiveForm::begin([ | |
14 | + 'action' => ['index'], | |
15 | + 'method' => 'get', | |
16 | + ]); ?> | |
17 | + | |
18 | + <?= $form->field($model, 'road_width_id') ?> | |
19 | + | |
20 | + <?= $form->field($model, 'region_id') ?> | |
21 | + | |
22 | + <?= $form->field($model, 'road_id') ?> | |
23 | + | |
24 | + <?= $form->field($model, 'begin') ?> | |
25 | + | |
26 | + <?= $form->field($model, 'end') ?> | |
27 | + | |
28 | + <?php // echo $form->field($model, 'width_roadside_left') ?> | |
29 | + | |
30 | + <?php // echo $form->field($model, 'width_reverse_road') ?> | |
31 | + | |
32 | + <?php // echo $form->field($model, 'width_strip') ?> | |
33 | + | |
34 | + <?php // echo $form->field($model, 'width_roadway_forward') ?> | |
35 | + | |
36 | + <?php // echo $form->field($model, 'width_roadside_right') ?> | |
37 | + | |
38 | + <?php // echo $form->field($model, 'count_lane_left') ?> | |
39 | + | |
40 | + <?php // echo $form->field($model, 'count_lane_right') ?> | |
41 | + | |
42 | + <div class="form-group"> | |
43 | + <?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?> | |
44 | + <?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?> | |
45 | + </div> | |
46 | + | |
47 | + <?php ActiveForm::end(); ?> | |
48 | + | |
49 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | + | |
5 | + | |
6 | +/* | |
7 | + * @var yii\web\View $this | |
8 | + * @var common\models\RoadWidth $model | |
9 | + * @var array $regions | |
10 | + * @var array $roads | |
11 | +*/ | |
12 | + | |
13 | +$this->title = 'Create Road Width'; | |
14 | +$this->params['breadcrumbs'][] = ['label' => 'Road Widths', 'url' => ['index']]; | |
15 | +$this->params['breadcrumbs'][] = $this->title; | |
16 | +?> | |
17 | +<div class="road-width-create"> | |
18 | + | |
19 | + <h1><?= Html::encode($this->title) ?></h1> | |
20 | + | |
21 | + <?= $this->render('_form', [ | |
22 | + 'model' => $model, | |
23 | + 'regions' => $regions, | |
24 | + 'roads' => $roads, | |
25 | + ]) ?> | |
26 | + | |
27 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | +use yii\grid\GridView; | |
5 | + | |
6 | +/* @var $this yii\web\View */ | |
7 | +/* @var $searchModel common\models\RoadWidthSearch */ | |
8 | +/* @var $dataProvider yii\data\ActiveDataProvider */ | |
9 | + | |
10 | +$this->title = 'Road Widths'; | |
11 | +$this->params['breadcrumbs'][] = $this->title; | |
12 | +?> | |
13 | +<div class="road-width-index"> | |
14 | + | |
15 | + <h1><?= Html::encode($this->title) ?></h1> | |
16 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | |
17 | + | |
18 | + <p> | |
19 | + <?= Html::a('Create Road Width', ['create'], ['class' => 'btn btn-success']) ?> | |
20 | + </p> | |
21 | + <?= GridView::widget([ | |
22 | + 'dataProvider' => $dataProvider, | |
23 | + 'filterModel' => $searchModel, | |
24 | + 'columns' => [ | |
25 | + ['class' => 'yii\grid\SerialColumn'], | |
26 | + | |
27 | + 'road_width_id', | |
28 | + 'region_id', | |
29 | + 'road_id', | |
30 | + 'begin', | |
31 | + 'end', | |
32 | + // 'width_roadside_left', | |
33 | + // 'width_reverse_road', | |
34 | + // 'width_strip', | |
35 | + // 'width_roadway_forward', | |
36 | + // 'width_roadside_right', | |
37 | + // 'count_lane_left', | |
38 | + // 'count_lane_right', | |
39 | + | |
40 | + ['class' => 'yii\grid\ActionColumn'], | |
41 | + ], | |
42 | + ]); ?> | |
43 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | + | |
5 | +/* | |
6 | + * @var yii\web\View $this | |
7 | + * @var common\models\RoadWidth $model | |
8 | + * @var array $regions | |
9 | + * @var array $roads | |
10 | +*/ | |
11 | + | |
12 | +$this->title = 'Update Road Width: ' . $model->road_width_id; | |
13 | +$this->params['breadcrumbs'][] = ['label' => 'Road Widths', 'url' => ['index']]; | |
14 | +$this->params['breadcrumbs'][] = ['label' => $model->road_width_id, 'url' => ['view', 'id' => $model->road_width_id]]; | |
15 | +$this->params['breadcrumbs'][] = 'Update'; | |
16 | +?> | |
17 | +<div class="road-width-update"> | |
18 | + | |
19 | + <h1><?= Html::encode($this->title) ?></h1> | |
20 | + | |
21 | + <?= $this->render('_form', [ | |
22 | + 'model' => $model, | |
23 | + 'regions' => $regions, | |
24 | + 'roads' => $roads, | |
25 | + ]) ?> | |
26 | + | |
27 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | +use yii\widgets\DetailView; | |
5 | + | |
6 | +/* @var $this yii\web\View */ | |
7 | +/* @var $model common\models\RoadWidth */ | |
8 | + | |
9 | +$this->title = $model->road_width_id; | |
10 | +$this->params['breadcrumbs'][] = ['label' => 'Road Widths', 'url' => ['index']]; | |
11 | +$this->params['breadcrumbs'][] = $this->title; | |
12 | +?> | |
13 | +<div class="road-width-view"> | |
14 | + | |
15 | + <h1><?= Html::encode($this->title) ?></h1> | |
16 | + | |
17 | + <p> | |
18 | + <?= Html::a('Update', ['update', 'id' => $model->road_width_id], ['class' => 'btn btn-primary']) ?> | |
19 | + <?= Html::a('Delete', ['delete', 'id' => $model->road_width_id], [ | |
20 | + 'class' => 'btn btn-danger', | |
21 | + 'data' => [ | |
22 | + 'confirm' => 'Are you sure you want to delete this item?', | |
23 | + 'method' => 'post', | |
24 | + ], | |
25 | + ]) ?> | |
26 | + </p> | |
27 | + | |
28 | + <?= DetailView::widget([ | |
29 | + 'model' => $model, | |
30 | + 'attributes' => [ | |
31 | + 'road_width_id', | |
32 | + 'region_id', | |
33 | + 'road_id', | |
34 | + 'begin', | |
35 | + 'end', | |
36 | + 'width_roadside_left', | |
37 | + 'width_reverse_road', | |
38 | + 'width_strip', | |
39 | + 'width_roadway_forward', | |
40 | + 'width_roadside_right', | |
41 | + 'count_lane_left', | |
42 | + 'count_lane_right', | |
43 | + ], | |
44 | + ]) ?> | |
45 | + | |
46 | +</div> | ... | ... |