diff --git a/backend/controllers/AdminMenuController.php b/backend/controllers/AdminMenuController.php index 2e28a03..4dbe470 100755 --- a/backend/controllers/AdminMenuController.php +++ b/backend/controllers/AdminMenuController.php @@ -83,7 +83,7 @@ class AdminMenuController extends Controller $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->adminmenu_id]); + return $this->redirect(['view', 'id' => $model->admin_menu_id]); } else { return $this->render('update', [ 'model' => $model, diff --git a/common/behaviors/MapsBehavior.php b/common/behaviors/MapsBehavior.php index aeb3924..91cb7c5 100644 --- a/common/behaviors/MapsBehavior.php +++ b/common/behaviors/MapsBehavior.php @@ -58,7 +58,7 @@ $location .= $owner->$location_attribute; $first = false; } - $location = Html::encode($location); + $location = urlencode(Html::encode($location)); $ch = curl_init(); if(!$ch) { throw new ErrorException('Curl error'); diff --git a/common/models/Portfolio.php b/common/models/Portfolio.php index 26004f5..c88409c 100644 --- a/common/models/Portfolio.php +++ b/common/models/Portfolio.php @@ -2,6 +2,7 @@ namespace common\models; + use common\behaviors\MapsBehavior; use common\modules\comment\models\Comment; use common\modules\comment\models\Rating; use Yii; @@ -66,6 +67,17 @@ [ 'class' => 'common\behaviors\ShowImage', ], + 'maps' => [ + 'class' => MapsBehavior::className(), + 'location_attributes' => [ + 'city', + 'street', + 'house', + ], + 'required_attributes' => [ + 'city', + ], + ], ]; } diff --git a/common/models/Specialization.php b/common/models/Specialization.php index 986129a..3468f88 100755 --- a/common/models/Specialization.php +++ b/common/models/Specialization.php @@ -97,4 +97,18 @@ class Specialization extends \yii\db\ActiveRecord } + public function getStack() + { + $stack[] = $this->specialization_id; + if(!empty($this->children)) { + foreach($this->children as $child) { + $stack[] = $child->specialization_id; + if(!empty($child->children)) { + $stack = array_merge($stack, ArrayHelper::getColumn($child->children, 'specialization_id', false)); + } + } + } + return $stack; + } + } diff --git a/frontend/assets/AppAsset.php b/frontend/assets/AppAsset.php index 5679da5..01ef47d 100755 --- a/frontend/assets/AppAsset.php +++ b/frontend/assets/AppAsset.php @@ -43,6 +43,7 @@ '/js/myGallery_min.js', '/js/fieldWidget.js', '/js/owl.carousel.min.js', + '/js/artbox.maps.js', ]; public $depends = [ diff --git a/frontend/controllers/CompanyController.php b/frontend/controllers/CompanyController.php index 3e7fb19..036692a 100755 --- a/frontend/controllers/CompanyController.php +++ b/frontend/controllers/CompanyController.php @@ -77,7 +77,7 @@ } $projectProvider = new ActiveDataProvider([ - 'query' => $company->getProjects(), + 'query' => $company->getPortfolios(), ]); $blogProvider = new ActiveDataProvider([ diff --git a/frontend/controllers/PortfolioController.php b/frontend/controllers/PortfolioController.php new file mode 100644 index 0000000..4c1e73e --- /dev/null +++ b/frontend/controllers/PortfolioController.php @@ -0,0 +1,99 @@ +request; + $response = \Yii::$app->response; + $response->format = $response::FORMAT_JSON; + $user = User::findOne($user_id); + if(empty( $user )) { + throw new NotFoundHttpException('User not found'); + } + if(!empty( $specialization_id )) { + $specializations[] = $specialization_id; + $specialization = Specialization::find() + ->where([ 'specialization_id' => $specialization_id ]) + ->one(); + if(!empty( $specialization )) { + $specializations = $specialization->stack; + } else { + $specializations = NULL; + } + } else { + $specializations = NULL; + } + $portfolios = $user->getPortfolios() + ->asArray() + ->joinWith('specializations') + ->andWhere([ + 'not', + [ 'portfolio.lat' => NULL ], + ]) + ->andWhere([ + 'not', + [ 'portfolio.lng' => NULL ], + ]) + ->andWhere([ + '>=', + 'portfolio.date_add', + date('Y-m-d', $start), + ]) + ->andFilterWhere([ 'specialization.specialization_id' => $specializations ]) + ->all(); + return [ 'result' => $portfolios ]; + } + + public function actionPortfolioAll() + { + $request = \Yii::$app->request; + $response = \Yii::$app->response; + $response->format = $response::FORMAT_JSON; + $portfolios = Portfolio::find() + ->asArray() + ->andWhere([ + 'not', + [ 'portfolio.lat' => NULL ], + ]) + ->andWhere([ + 'not', + [ 'portfolio.lng' => NULL ], + ]) + ->all(); + return [ 'result' => $portfolios ]; + } + + } diff --git a/frontend/controllers/ProjectController.php b/frontend/controllers/ProjectController.php new file mode 100644 index 0000000..bc47719 --- /dev/null +++ b/frontend/controllers/ProjectController.php @@ -0,0 +1,45 @@ +request; + $response = \Yii::$app->response; + $response->format = $response::FORMAT_JSON; + $projects = Project::find() + ->asArray() + ->andWhere([ + 'not', + [ 'project.lat' => NULL ], + ]) + ->andWhere([ + 'not', + [ 'project.lng' => NULL ], + ]) + ->all(); + return [ 'result' => $projects ]; + } + + } diff --git a/frontend/views/company/common.php b/frontend/views/company/common.php index 086ecee..ae6ff22 100755 --- a/frontend/views/company/common.php +++ b/frontend/views/company/common.php @@ -6,6 +6,7 @@ * @var ActiveDataProvider $blogProvider * @var ActiveDataProvider $commentProvider */ + use common\models\Specialization; use common\models\User; use yii\data\ActiveDataProvider; use yii\helpers\ArrayHelper; @@ -37,179 +38,56 @@
Наши объекты (totalCount ?>)
-
+
- -
+
- + where([ 'specialization_pid' => 0 ]) + ->with('children.children') + ->orderBy('specialization_id') + ->all(); + ?> -
diff --git a/frontend/views/site/index.php b/frontend/views/site/index.php index be7b7a9..a2962ea 100755 --- a/frontend/views/site/index.php +++ b/frontend/views/site/index.php @@ -10,26 +10,6 @@ $this->title = 'My Yii Application'; ?>
- -
- -
- - */ - ?>
@@ -107,134 +87,15 @@

Проекты на нашем сайте

    -
  • Текущие
  • -
  • Завершенные
  • + +
- -
+
diff --git a/frontend/web/js/artbox.maps.js b/frontend/web/js/artbox.maps.js new file mode 100644 index 0000000..073ca61 --- /dev/null +++ b/frontend/web/js/artbox.maps.js @@ -0,0 +1,259 @@ +var company_map = []; +var main_map = []; +$( + function() + { + initMap(company_map); + initMainMap(main_map); + $(document).on( + 'click', '.map_company_filter', function(e) + { + e.preventDefault(); + var id = $(this).data('id'); + var user = $('#map_company').data('user'); + $.ajax( + { + url : '/portfolio/portfolio', + data : { + user_id : user, + specialization_id : id, + start: company_map['start'] + }, + success : function(data) + { + if(data['result'].length > 0) + { + showMarkers(company_map, data['result']); + company_map['map'].fitBounds(company_map['bounds']); + } else + { + clearMap(company_map); + } + }, + dataType : 'json' + } + ); + } + ); + $(document).on('click', '.company_map_time_link', function(e) { + e.preventDefault(); + $('.company_map_time_link').removeClass('active'); + $(this).addClass('active'); + company_map['start'] = $(this).data('start'); + }); + $(document).on('click', '.main_map_link', function(e) { + e.preventDefault(); + var action = $(this).data('action'); + $.ajax( + { + url : '/'+action+'/'+action+'-all', + data : {}, + success : function(data) + { + if(data['result'].length > 0) + { + showMarkers(main_map, data['result']); + main_map['map'].fitBounds(main_map['bounds']); + } else + { + clearMap(main_map); + } + }, + dataType : 'json' + } + ); + }); + } +); +function showMarkers(variable, elements) +{ + console.log(elements); + var position = { + lat : undefined, + lng : undefined + }; + var color; + var title; + setMapOnAll(variable['markers'], null); + variable['markers'] = []; + if(variable['clusterer'] !== undefined) + { + variable['clusterer'].clearMarkers(); + } + variable['bounds'] = new google.maps.LatLngBounds(); + for(var i = 0; i < elements.length; i++) + { + position.lat = parseFloat(elements[i].lat); + position.lng = parseFloat(elements[i].lng); + title = elements[i].name; + if(elements[i].specializations !== null && elements[i].specializations !== undefined) { + color = elements[i].specializations[0].background; + } + icon = variable['icon']; + if(color !== null && color !== undefined) + { + icon.fillColor = color; + } + marker = new google.maps.Marker( + { + position : position, + title : title, + icon : icon + } + ); + variable['markers'].push(marker); + variable['bounds'].extend(marker.getPosition()); + } + setMapOnAll(variable['markers'], variable['map']); + replaceClusterer(variable); +} +function clearMap(variable) { + setMapOnAll(variable['markers'], null); + variable['markers'] = []; + if(variable['clusterer'] !== undefined) + { + variable['clusterer'].clearMarkers(); + } +} +function replaceClusterer(variable) +{ + if(variable['clusterer' !== undefined]) + { + variable['clusterer'].clearMarkers(); + } + variable['clusterer'] = new MarkerClusterer( + variable['map'], variable['markers'], { + maxZoom : 10, + gridSize : 100, + styles : variable['clusterer_style'] + } + ); +} +function setMapOnAll(markers, map) +{ + for(var i = 0; i < markers.length; i++) + { + markers[i].setMap(map); + } +} +function initMap(variable) +{ + if(document.getElementById('map_company') == null) { + return false; + } + variable['settings'] = { + zoom : 7, + scrollwheel : true, + maxZoom: 18, + center : { + "lat" : 50.4501, + "lng" : 30.5234 + }, + mapTypeControl : false, + mapTypeControlOptions : {style : google.maps.MapTypeControlStyle.DROPDOWN_MENU}, + navigationControl : false, + navigationControlOptions : {style : google.maps.NavigationControlStyle.SMALL}, + scaleControl : false, + streetViewControl : false, + rotateControl : false, + zoomControl : true, + mapTypeId : google.maps.MapTypeId.ROADMAP, + }; + variable['map'] = new google.maps.Map(document.getElementById('map_company'), variable['settings']); + variable['markers'] = []; + variable['clusterer'] = undefined; + variable['icon'] = { + path : 'M0-48c-9.8 0-17.7 7.8-17.7 17.4 0 15.5 17.7 30.6 17.7 30.6s17.7-15.4 17.7-30.6c0-9.6-7.9-17.4-17.7-17.4z', + fillColor : 'white', + fillOpacity : 0.8, + scale : 0.5 + }; + variable['clusterer_style'] = [ + { + url : '/images/markers/clasters.png', + height : 36, + width : 36 + } + ]; + variable['bounds'] = new google.maps.LatLngBounds(); + variable['start'] = $('.company_map_time_link.active').data('start'); + $.ajax( + { + url : '/portfolio/portfolio', + data : { + user_id : $('#map_company').data('user') + }, + success : function(data) + { + if(data['result'].length > 0) + { + showMarkers(company_map, data['result']); + company_map['map'].fitBounds(company_map['bounds']); + } else + { + clearMap(company_map); + } + }, + dataType : 'json' + } + ); +} +function initMainMap(variable) +{ + if(document.getElementById('map_main') == null) { + return false; + } + variable['settings'] = { + zoom : 7, + scrollwheel : true, + maxZoom: 18, + center : { + "lat" : 50.4501, + "lng" : 30.5234 + }, + mapTypeControl : false, + mapTypeControlOptions : {style : google.maps.MapTypeControlStyle.DROPDOWN_MENU}, + navigationControl : false, + navigationControlOptions : {style : google.maps.NavigationControlStyle.SMALL}, + scaleControl : false, + streetViewControl : false, + rotateControl : false, + zoomControl : true, + mapTypeId : google.maps.MapTypeId.ROADMAP + }; + variable['map'] = new google.maps.Map(document.getElementById('map_main'), variable['settings']); + variable['markers'] = []; + variable['clusterer'] = undefined; + variable['icon'] = { + path : 'M0-48c-9.8 0-17.7 7.8-17.7 17.4 0 15.5 17.7 30.6 17.7 30.6s17.7-15.4 17.7-30.6c0-9.6-7.9-17.4-17.7-17.4z', + fillColor : 'white', + fillOpacity : 0.8, + scale : 0.5 + }; + variable['clusterer_style'] = [ + { + url : '/images/markers/clasters.png', + height : 36, + width : 36 + } + ]; + variable['bounds'] = new google.maps.LatLngBounds(); + $.ajax( + { + url : '/project/project-all', + data : {}, + success : function(data) + { + if(data['result'].length > 0) + { + showMarkers(main_map, data['result']); + main_map['map'].fitBounds(main_map['bounds']); + } else + { + clearMap(main_map); + } + }, + dataType : 'json' + } + ); +} \ No newline at end of file diff --git a/frontend/web/js/no-comprss/script-nocompress.js b/frontend/web/js/no-comprss/script-nocompress.js index 1582c10..c8f9a21 100755 --- a/frontend/web/js/no-comprss/script-nocompress.js +++ b/frontend/web/js/no-comprss/script-nocompress.js @@ -165,23 +165,23 @@ $(document).ready(function(){ }); } - function newMenuMap(){ - $('.company-performer-map-menu .content-menu-first>li>ul').addClass('content-menu-map-first'); - $('.company-performer-map-menu .content-menu-first>li>ul>li').addClass('content-menu-map-second'); - $('.company-performer-map-menu .content-menu-first>li').addClass('old-content-menu-map-zero'); - $('.company-performer-map-menu .content-menu-map-first').parent().removeClass('old-content-menu-map-zero').addClass('content-menu-map-zero'); - $('.company-performer-map-menu .content-menu-map-zero').click(function(e){ - e.preventDefault(); - }); - $('.company-performer-map-menu .content-menu-map-second, .company-performer-map-menu .old-content-menu-map-zero').click(function(e){ - e.preventDefault() - $.post("maps/maps.php", function (data) { - $("#map_cloud").empty(); - $("#map_cloud").append(data); - initialize(); - }); - }); - } +// function newMenuMap(){ +// $('.company-performer-map-menu .content-menu-first>li>ul').addClass('content-menu-map-first'); +// $('.company-performer-map-menu .content-menu-first>li>ul>li').addClass('content-menu-map-second'); +// $('.company-performer-map-menu .content-menu-first>li').addClass('old-content-menu-map-zero'); +// $('.company-performer-map-menu .content-menu-map-first').parent().removeClass('old-content-menu-map-zero').addClass('content-menu-map-zero'); +// $('.company-performer-map-menu .content-menu-map-zero').click(function(e){ +// e.preventDefault(); +// }); +// $('.company-performer-map-menu .content-menu-map-second, .company-performer-map-menu .old-content-menu-map-zero').click(function(e){ +// e.preventDefault() +// $.post("maps/maps.php", function (data) { +// $("#map_cloud").empty(); +// $("#map_cloud").append(data); +// initialize(); +// }); +// }); +// } function projectAllMenu() { $('.all-project-home-title_menu li').click(function(){ @@ -190,28 +190,27 @@ $(document).ready(function(){ }) } - function mapLoad(){ - $('.settings-map-ul ul li a').click(function (e) { - e.preventDefault(); - $('.settings-map-ul ul li a').removeClass('active') - $(this).addClass('active') - $.post("maps/maps.php", function (data) { - $("#map_cloud").empty(); - $("#map_cloud").append(data); - initialize(); - }); - }); - } - mapLoadNewMenus() - function mapLoadNewMenus(){ - $('.all-project-home-title_menu ul li').click(function () { - $.post("maps/maps.php", function (data) { - $("#map_cloud").empty(); - $("#map_cloud").append(data); - initialize(); - }); - }); - } +// function mapLoad(){ +// $('.settings-map-ul ul li a').click(function (e) { +// e.preventDefault(); +// $('.settings-map-ul ul li a').removeClass('active') +// $(this).addClass('active') +// $.post("maps/maps.php", function (data) { +// $("#map_cloud").empty(); +// $("#map_cloud").append(data); +// initialize(); +// }); +// }); +// } +// mapLoadNewMenus() +// $('.all-project-home-title_menu ul li').click(function () { +// $.post("maps/maps.php", function (data) { +// $("#map_cloud").empty(); +// $("#map_cloud").append(data); +// initialize(); +// }); +// }); +// } function federationHome(){ var menu_width = 0; diff --git a/frontend/web/js/script.js b/frontend/web/js/script.js index c904077..99a21f2 100755 --- a/frontend/web/js/script.js +++ b/frontend/web/js/script.js @@ -11,7 +11,7 @@ $(document).ready( scrolling(); menuBg(); projectAllMenu(); - mapLoad(); +// mapLoad(); federationHome(); //validationForms(); //menuContent(); @@ -19,7 +19,7 @@ $(document).ready( box15Height(); formRezume(); fileVal(); - newMenuMap(); + //newMenuMap(); seeAllComm(); gallerPage(); selectAfter(); @@ -214,33 +214,33 @@ $(document).ready( ); } - function newMenuMap() - { - $('.company-performer-map-menu .content-menu-first>li>ul').addClass('content-menu-map-first'); - $('.company-performer-map-menu .content-menu-first>li>ul>li').addClass('content-menu-map-second'); - $('.company-performer-map-menu .content-menu-first>li').addClass('old-content-menu-map-zero'); - $('.company-performer-map-menu .content-menu-map-first').parent().removeClass('old-content-menu-map-zero').addClass('content-menu-map-zero'); - $('.company-performer-map-menu .content-menu-map-zero').click( - function(e) - { - e.preventDefault(); - } - ); - $('.company-performer-map-menu .content-menu-map-second, .company-performer-map-menu .old-content-menu-map-zero').click( - function(e) - { - e.preventDefault() - $.post( - "maps/maps.php", function(data) - { - $("#map_cloud").empty(); - $("#map_cloud").append(data); - initialize(); - } - ); - } - ); - } +// function newMenuMap() +// { +// $('.company-performer-map-menu .content-menu-first>li>ul').addClass('content-menu-map-first'); +// $('.company-performer-map-menu .content-menu-first>li>ul>li').addClass('content-menu-map-second'); +// $('.company-performer-map-menu .content-menu-first>li').addClass('old-content-menu-map-zero'); +// $('.company-performer-map-menu .content-menu-map-first').parent().removeClass('old-content-menu-map-zero').addClass('content-menu-map-zero'); +// $('.company-performer-map-menu .content-menu-map-zero').click( +// function(e) +// { +// e.preventDefault(); +// } +// ); +// $('.company-performer-map-menu .content-menu-map-second, .company-performer-map-menu .old-content-menu-map-zero').click( +// function(e) +// { +// e.preventDefault() +// $.post( +// "maps/maps.php", function(data) +// { +// $("#map_cloud").empty(); +// $("#map_cloud").append(data); +// initialize(); +// } +// ); +// } +// ); +// } function projectAllMenu() { @@ -253,43 +253,43 @@ $(document).ready( ) } - function mapLoad() - { - $('.settings-map-ul ul li a').click( - function(e) - { - e.preventDefault(); - $('.settings-map-ul ul li a').removeClass('active') - $(this).addClass('active') - $.post( - "maps/maps.php", function(data) - { - $("#map_cloud").empty(); - $("#map_cloud").append(data); - initialize(); - } - ); - } - ); - } - - mapLoadNewMenus() - function mapLoadNewMenus() - { - $('.all-project-home-title_menu ul li').click( - function() - { - $.post( - "maps/maps.php", function(data) - { - $("#map_cloud").empty(); - $("#map_cloud").append(data); - initialize(); - } - ); - } - ); - } +// function mapLoad() +// { +// $('.settings-map-ul ul li a').click( +// function(e) +// { +// e.preventDefault(); +// $('.settings-map-ul ul li a').removeClass('active') +// $(this).addClass('active') +// $.post( +// "maps/maps.php", function(data) +// { +// $("#map_cloud").empty(); +// $("#map_cloud").append(data); +// initialize(); +// } +// ); +// } +// ); +// } +// +// mapLoadNewMenus() +// function mapLoadNewMenus() +// { +// $('.all-project-home-title_menu ul li').click( +// function() +// { +// $.post( +// "maps/maps.php", function(data) +// { +// $("#map_cloud").empty(); +// $("#map_cloud").append(data); +// initialize(); +// } +// ); +// } +// ); +// } function federationHome() { -- libgit2 0.21.4