Commit 53868b90a64a0bd2aa1e7ffdc3f483e785e1ba52
1 parent
3d730a7c
120716
Showing
5 changed files
with
300 additions
and
1 deletions
Show diff stats
frontend/config/main.php
frontend/controllers/RoadController.php
... | ... | @@ -6,7 +6,9 @@ |
6 | 6 | use common\models\Region; |
7 | 7 | use common\models\Road; |
8 | 8 | use common\models\RoadCategory; |
9 | + use common\models\RoadToCategory; | |
9 | 10 | use common\models\RoadType; |
11 | + use common\models\RoadWidth; | |
10 | 12 | use common\models\SettlementAddressLink; |
11 | 13 | use yii\data\ActiveDataProvider; |
12 | 14 | use yii\filters\VerbFilter; |
... | ... | @@ -176,16 +178,43 @@ |
176 | 178 | ->select('region_id') |
177 | 179 | ->where([ 'road_id' => $id ]) |
178 | 180 | ->column(); |
181 | + | |
179 | 182 | if(!empty( $region_ids )) { |
180 | 183 | $cross_section_regions = Region::find() |
181 | 184 | ->where([ 'region_id' => $region_ids ]) |
182 | 185 | ->all(); |
183 | 186 | } |
187 | + $road_to_categories = [ ]; | |
188 | + $region_ids = [ ]; | |
189 | + $region_ids = RoadToCategory::find() | |
190 | + ->distinct() | |
191 | + ->select('region_id') | |
192 | + ->where([ 'road_id' => $id ]) | |
193 | + ->column(); | |
194 | + if(!empty( $region_ids )) { | |
195 | + $road_to_categories = Region::find() | |
196 | + ->where([ 'region_id' => $region_ids ]) | |
197 | + ->all(); | |
198 | + } | |
199 | + $road_width = [ ]; | |
200 | + $region_ids = [ ]; | |
201 | + $region_ids = RoadWidth::find() | |
202 | + ->distinct() | |
203 | + ->select('region_id') | |
204 | + ->where([ 'road_id' => $id ]) | |
205 | + ->column(); | |
206 | + if(!empty( $region_ids )) { | |
207 | + $road_width = Region::find() | |
208 | + ->where([ 'region_id' => $region_ids ]) | |
209 | + ->all(); | |
210 | + } | |
184 | 211 | return $this->render('view', [ |
185 | 212 | 'road' => $road, |
186 | 213 | 'settlement_regions' => $settlement_regions, |
187 | 214 | 'flow_intensity_regions' => $flow_intensity_regions, |
188 | 215 | 'cross_section_regions' => $cross_section_regions, |
216 | + 'road_to_categories' => $road_to_categories, | |
217 | + 'road_width' => $road_width, | |
189 | 218 | ]); |
190 | 219 | } |
191 | 220 | |
... | ... | @@ -214,6 +243,55 @@ |
214 | 243 | ]); |
215 | 244 | } |
216 | 245 | |
246 | + public function actionRoadToCategory(int $id, int $region_id) | |
247 | + { | |
248 | + $road = Road::findOne($id); | |
249 | + if(empty( $road )) { | |
250 | + throw new NotFoundHttpException('Road not found'); | |
251 | + } | |
252 | + $region = Region::findOne($region_id); | |
253 | + if(empty( $region )) { | |
254 | + throw new NotFoundHttpException('Region not found'); | |
255 | + } | |
256 | + $dataProvider = new ActiveDataProvider([ | |
257 | + 'query' => RoadToCategory::find() | |
258 | + ->where([ | |
259 | + 'road_id' => $id, | |
260 | + 'region_id' => $region_id, | |
261 | + ]), | |
262 | + 'pagination' => false, | |
263 | + ]); | |
264 | + return $this->render('road-to-category', [ | |
265 | + 'road' => $road, | |
266 | + 'region' => $region, | |
267 | + 'dataProvider' => $dataProvider, | |
268 | + ]); | |
269 | + } | |
270 | + | |
271 | + public function actionRoadWidth(int $id, int $region_id) | |
272 | + { | |
273 | + $road = Road::findOne($id); | |
274 | + if(empty( $road )) { | |
275 | + throw new NotFoundHttpException('Road not found'); | |
276 | + } | |
277 | + $region = Region::findOne($region_id); | |
278 | + if(empty( $region )) { | |
279 | + throw new NotFoundHttpException('Region not found'); | |
280 | + } | |
281 | + $dataProvider = new ActiveDataProvider([ | |
282 | + 'query' => RoadWidth::find() | |
283 | + ->where([ | |
284 | + 'road_id' => $id, | |
285 | + 'region_id' => $region_id, | |
286 | + ]), | |
287 | + 'pagination' => false, | |
288 | + ]); | |
289 | + return $this->render('road-width', [ | |
290 | + 'road' => $road, | |
291 | + 'region' => $region, | |
292 | + 'dataProvider' => $dataProvider, | |
293 | + ]); | |
294 | + } | |
217 | 295 | public function actionFlowIntensity(int $id, int $region_id) |
218 | 296 | { |
219 | 297 | $road = Road::findOne($id); | ... | ... |
1 | +<?php | |
2 | + | |
3 | + /** | |
4 | + * @var Road $road | |
5 | + * @var Region $region | |
6 | + * @var ActiveDataProvider $dataProvider | |
7 | + */ | |
8 | + | |
9 | + use common\models\Region; | |
10 | + use common\models\Road; | |
11 | + use common\models\SettlementAddressLink; | |
12 | + use yii\data\ActiveDataProvider; | |
13 | + use yii\grid\GridView; | |
14 | +use common\models\RoadToCategory; | |
15 | + | |
16 | + $this->title = $road->name; | |
17 | + $this->params[ 'breadcrumbs' ][] = [ | |
18 | + 'label' => 'Дороги', | |
19 | + 'url' => [ 'index' ], | |
20 | + ]; | |
21 | + $this->params[ 'breadcrumbs' ][] = [ | |
22 | + 'label' => $this->title, | |
23 | + 'url' => [ | |
24 | + 'view', | |
25 | + 'id' => $road->road_id, | |
26 | + ], | |
27 | + ]; | |
28 | + $this->params[ 'breadcrumbs' ][] = 'Відомість адресної прив\'язки населених пунктів - ' . ucfirst($region->name). ' область'; | |
29 | +?> | |
30 | +<div class="site-index"> | |
31 | + <div class="col-xs-6 text-center"> | |
32 | + Міністрество транспорту України <br> | |
33 | + Державна служба автомобільних доріг <br> | |
34 | + України | |
35 | + </div> | |
36 | + <div class="col-xs-6 text-center"> | |
37 | + Служба автомобільних доріг у <?php echo $region->name; ?> області | |
38 | + </div> | |
39 | + <div class="clearfix"></div> | |
40 | + <div class="col-xs-12 text-center"> | |
41 | + <p class="h3">Відомість</p> | |
42 | + <p class="text-center"><b>адресної прив'язки населених пунктів</b></p> | |
43 | + <p>на автомобільній дорозі</p> | |
44 | + <p><ins><?php echo $road->name; ?></ins></p> | |
45 | + <p><ins><?php echo $road->roadType->definition;?></ins> значення станом на <ins><?php echo date('d F Y');?> р.</ins></p> | |
46 | + </div> | |
47 | + <div class="col-xs-12 text-center"> | |
48 | + <?php | |
49 | + echo GridView::widget([ | |
50 | + 'dataProvider' => $dataProvider, | |
51 | + 'layout' => "{items}", | |
52 | + 'columns' => [ | |
53 | + [ | |
54 | + 'attribute' => 'begin', | |
55 | + 'value' => function($model) { | |
56 | + /** | |
57 | + * @var RoadToCategory $model | |
58 | + */ | |
59 | + return $model->getBeginString(); | |
60 | + } | |
61 | + ], | |
62 | + [ | |
63 | + 'attribute' => 'end', | |
64 | + 'value' => function($model) { | |
65 | + /** | |
66 | + * @var RoadToCategory $model | |
67 | + */ | |
68 | + return $model->getEndString(); | |
69 | + } | |
70 | + ], | |
71 | + 'distance', | |
72 | + [ | |
73 | + 'attribute' => 'road_category_id', | |
74 | + 'value' => function($model) { | |
75 | + /** | |
76 | + * @var RoadToCategory $model | |
77 | + */ | |
78 | + return $model->roadCategory->value; | |
79 | + } | |
80 | + ], | |
81 | + ] | |
82 | + ]) | |
83 | + ?> | |
84 | + </div> | |
85 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | + /** | |
4 | + * @var Road $road | |
5 | + * @var Region $region | |
6 | + * @var ActiveDataProvider $dataProvider | |
7 | + */ | |
8 | + | |
9 | + use common\models\Region; | |
10 | + use common\models\Road; | |
11 | + use common\models\SettlementAddressLink; | |
12 | + use yii\data\ActiveDataProvider; | |
13 | + use yii\grid\GridView; | |
14 | +use common\models\RoadToCategory; | |
15 | + | |
16 | + $this->title = $road->name; | |
17 | + $this->params[ 'breadcrumbs' ][] = [ | |
18 | + 'label' => 'Дороги', | |
19 | + 'url' => [ 'index' ], | |
20 | + ]; | |
21 | + $this->params[ 'breadcrumbs' ][] = [ | |
22 | + 'label' => $this->title, | |
23 | + 'url' => [ | |
24 | + 'view', | |
25 | + 'id' => $road->road_id, | |
26 | + ], | |
27 | + ]; | |
28 | + $this->params[ 'breadcrumbs' ][] = 'Відомість адресної прив\'язки населених пунктів - ' . ucfirst($region->name). ' область'; | |
29 | +?> | |
30 | +<div class="site-index"> | |
31 | + <div class="col-xs-6 text-center"> | |
32 | + Міністрество транспорту України <br> | |
33 | + Державна служба автомобільних доріг <br> | |
34 | + України | |
35 | + </div> | |
36 | + <div class="col-xs-6 text-center"> | |
37 | + Служба автомобільних доріг у <?php echo $region->name; ?> області | |
38 | + </div> | |
39 | + <div class="clearfix"></div> | |
40 | + <div class="col-xs-12 text-center"> | |
41 | + <p class="h3">Відомість</p> | |
42 | + <p class="text-center"><b>адресної прив'язки населених пунктів</b></p> | |
43 | + <p>на автомобільній дорозі</p> | |
44 | + <p><ins><?php echo $road->name; ?></ins></p> | |
45 | + <p><ins><?php echo $road->roadType->definition;?></ins> значення станом на <ins><?php echo date('d F Y');?> р.</ins></p> | |
46 | + </div> | |
47 | + <div class="col-xs-12 text-center"> | |
48 | + <?php | |
49 | + echo GridView::widget([ | |
50 | + 'dataProvider' => $dataProvider, | |
51 | + 'layout' => "{items}", | |
52 | + 'columns' => [ | |
53 | + [ | |
54 | + 'attribute' => 'begin', | |
55 | + 'value' => function($model) { | |
56 | + /** | |
57 | + * @var RoadToCategory $model | |
58 | + */ | |
59 | + return $model->getBeginString(); | |
60 | + } | |
61 | + ], | |
62 | + [ | |
63 | + 'attribute' => 'end', | |
64 | + 'value' => function($model) { | |
65 | + /** | |
66 | + * @var RoadToCategory $model | |
67 | + */ | |
68 | + return $model->getEndString(); | |
69 | + } | |
70 | + ], | |
71 | + 'width_roadside_left', | |
72 | + 'width_reverse_road', | |
73 | + 'width_strip', | |
74 | + 'width_roadway_forward', | |
75 | + 'width_roadside_right', | |
76 | + 'count_lane_left', | |
77 | + 'count_lane_right', | |
78 | + ] | |
79 | + ]) | |
80 | + ?> | |
81 | + </div> | |
82 | +</div> | ... | ... |
frontend/views/road/view.php
... | ... | @@ -5,6 +5,8 @@ |
5 | 5 | * @var Region[] $settlement_regions |
6 | 6 | * @var Region[] $flow_intensity_regions |
7 | 7 | * @var Region[] $cross_section_regions |
8 | + * @var Region[] $road_to_categories | |
9 | + * @var Region[] $road_width | |
8 | 10 | */ |
9 | 11 | |
10 | 12 | use common\models\Region; |
... | ... | @@ -124,6 +126,58 @@ |
124 | 126 | ?> |
125 | 127 | </div> |
126 | 128 | </div> |
129 | + <div class="panel panel-default"> | |
130 | + <div class="panel-heading"> | |
131 | + <a href="#road_to_categories" data-toggle="collapse" aria-expanded="false" aria-controls="road_to_categories">Категорії доріг</a> | |
132 | + </div> | |
133 | + <div class="panel-body collapse" id="road_to_categories"> | |
134 | + <?php | |
135 | + if(!empty( $road_to_categories )) { | |
136 | + ?> | |
137 | + <div class="list-group"> | |
138 | + <?php | |
139 | + foreach($road_to_categories as $region) { | |
140 | + echo Html::a($region->name . ' область', [ | |
141 | + 'road-to-category', | |
142 | + 'id' => $road->road_id, | |
143 | + 'region_id' => $region->region_id, | |
144 | + ]); | |
145 | + } | |
146 | + ?> | |
147 | + </div> | |
148 | + <?php | |
149 | + } else { | |
150 | + echo Html::tag('p', 'Населені пункти не знайдені.'); | |
151 | + } | |
152 | + ?> | |
153 | + </div> | |
154 | + </div> | |
155 | + <div class="panel panel-default"> | |
156 | + <div class="panel-heading"> | |
157 | + <a href="#road_width" data-toggle="collapse" aria-expanded="false" aria-controls="road_width">Ширина проїзної частини та земляного полотна</a> | |
158 | + </div> | |
159 | + <div class="panel-body collapse" id="road_width"> | |
160 | + <?php | |
161 | + if(!empty( $road_width )) { | |
162 | + ?> | |
163 | + <div class="list-group"> | |
164 | + <?php | |
165 | + foreach($road_width as $region) { | |
166 | + echo Html::a($region->name . ' область', [ | |
167 | + 'road-width', | |
168 | + 'id' => $road->road_id, | |
169 | + 'region_id' => $region->region_id, | |
170 | + ]); | |
171 | + } | |
172 | + ?> | |
173 | + </div> | |
174 | + <?php | |
175 | + } else { | |
176 | + echo Html::tag('p', 'Населені пункти не знайдені.'); | |
177 | + } | |
178 | + ?> | |
179 | + </div> | |
180 | + </div> | |
127 | 181 | </div> |
128 | 182 | <div class="clearfix"></div> |
129 | 183 | </div> | ... | ... |