view.php 9.01 KB
<?php

use yii\helpers\Html;
use frontend\modules\map\Map;
use frontend\modules\map\models\Item;
use frontend\modules\map\models\ItemLang;
use frontend\themes\defaults\assets\AppAsset;

$bundle = AppAsset::register($this);
$urlMapResource = Map::getUrlListByType('resource');
$urlMapProjects = Map::getUrlListByType('project');
$gallery = $model->getGalleryLink();
$archive = $model->getArchiveLink();
//
$sign = \frontend\components\ImageResizer::getSign(
    Yii::getAlias('@frontend-web') . '/images/sign.png',
    $area->getImageLink2Path(),
    $model['typeItem']['color'],
    $model['area_id'] . $model['type_id']
);
//
function jsString($str = '')
{
    return preg_replace("/('|\"|\r?\n)/", '', $str);
}

/* $js_icons[] = '
             ' . $group['id'] . ':  { icon: \'' . addslashes($group->getImageLink()) . '\'}';*/
$content = $this->render('parts/_popup', ['model' => $model]);
$position = str_replace('(', '', $model['coordinates']);
$position = str_replace(')', '', $position);
$position = explode(',', $position);
$position = '{"lat": ' . $position[0] . ', "lng": ' . $position[1] . '}';
$js_features[] = '{   
                    "id": "' . $model['id'] . '",    
                    "title": "' . addslashes($model['lang']['title']) . '",
                    "position": ' . $position . ',
                    "type": "' . $model['type_id'] . '",
                    "direction": "' . $model['area_id'] . '",
                    "region": "' . $model['region_id'] . '",
                    "power": "' . $model['electric_power'] . '",
                    "investment": "' . $model['investment'] . '",
                    "icon": "' . ($sign) . '",
                    "infoWindow": {"content": "' . addslashes(jsString($content)) . '"}
                }';
//?? $bundle->baseUrl . '/img/curent-wind.png'
if (!empty($js_icons)) {
    $js_icons = implode(",", $js_icons);
} else {
    $js_icons = '';
}

if (!empty($js_features)) {
    $js_features = implode(",", $js_features);
} else {
    $js_features = '';
}
/**
 * @param $attribute
 * @param $model
 */
function getRowBlockInfo($attribute, $model)
{
    $labels = (new ItemLang())->getAttributeLabel($attribute) ?? (new Item())->getAttributeLabel($attribute);
    if (!empty($model[$attribute])):
        echo Html::tag('div', Html::tag('div', Html::tag('div',
                $labels,
                ['class' => 'title-2'])
            . Html::decode($model[$attribute]), [
            'class' => 'col-md-12 col-sm-12'
        ]), ['class' => 'row']);
    endif;
}

?>
    <div style="position: relative;">
        <div class="static-btn-container" style="top: -45px;">
            <?= Html::a(Yii::t('front', 'resource potential'), $urlMapResource, [
                'class' => 'static-btn static-btn-resours'
            ])
            . Html::a(Yii::t('front', 'projects'), $urlMapProjects, [
                'class' => 'static-btn static-btn-project'
            ])
            ?>
        </div>
        <div class="row">
            <div class="col-md-9 col-sm-9 col-xs-9">
                <?= Html::tag('h1', Html::decode($model['lang']['title']), [
                    'class' => 'title-1 reset-margin-top'
                ]) ?>
            </div>
        </div>
        <div class="row project-container">
            <div class="col-md-7 col-xs-12">
                <div class="tabs-wr">
                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a href="#home" data-toggle="tab">
                                <?= Yii::t('front', 'General Information') ?>
                            </a>
                        </li>
                        <?= (!empty($gallery)) ? Html::tag('li', Html::a(Yii::t('front', "Gallery"), '#galery', [
                            'data-toggle' => 'tab'
                        ])) : '' ?>
                        <?= ($model['youtube_link']) ? Html::tag('li', Html::a(Yii::t('front', "Video"), '#video', [
                            'data-toggle' => 'tab'
                        ])) : '' ?>
                    </ul>
                    <!-- Tab panes -->
                    <div class="tab-content">
                        <div class="tab-pane fade in active" id="home">
                            <div class="row tabs-table-heading vertical-align">
                                <div class="col-sm-4">
                                    <i class="table-icon"
                                       style="background-color: <?= $model['typeItem']['color'] ?>"></i>
                                    <?= $model['typeItem']['lang']['title'] ?>
                                </div>
                                <div class="col-sm-4">
                                    <i class="table-icon"
                                       style="background-image: url('<?= Map::getImageLink($model['area']['image_link']) ?>')"></i>
                                    <?= $model['area']['lang']['title'] ?>
                                </div>
                                <div class="col-sm-4"></div>
                            </div>
                            <?= $this->render('vparts/info-table', [
                                'model' => $model,
                                'archive' => $archive
                            ]) ?>
                        </div>
                        <?php
                        if ((!empty($gallery))):
                            echo $this->render('vparts/gallery', [
                                'model' => $model,
                            ]);
                        endif;
                        if ($model['youtube_link']):
                            echo $this->render('vparts/video', [
                                'model' => $model
                            ]);
                        endif;
                        ?>
                    </div>

                </div>
            </div>
            <div class="col-md-5 col-xs-12">
                <div class="text-info map-text-info"><?= Yii::t('front', 'show on map') ?></div>
                <div class="sm-map" id="map">
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-md-12 col-sm-12">
                <?= Html::tag('h2', Yii::t('front', 'about project'), ['class' => 'title-2'])
                . Html::decode($model['lang']['description']) ?>
            </div>
        </div>

        <?php
        if (!empty($model['type_of_promoter']) && $model['type'] == 'project'):
            echo Html::tag('div', Html::tag('div', Html::tag('div',
                    Yii::t('map', 'type_of_promoter'),
                    ['class' => 'title-2'])
                . Html::decode(Item::type_of_promoterKeyRange()[$model['type_of_promoter']]), [
                'class' => 'col-md-9 col-sm-12'
            ]), ['class' => 'row']);
        endif;
        //
        getRowBlockInfo('contact_details_of_project_promoter', $model['lang']);
        getRowBlockInfo('date_of_entry', $model);
        //
        if (!empty($model['current_stage_of_project_development']) && $model['type'] == 'project'):
            echo Html::tag('div', Html::tag('div', Html::tag('div',
                    (new Item)->getAttributeLabel('current_stage_of_project_development'),
                    ['class' => 'title-2'])
                . Html::decode(Item::current_stage_of_project_developmentKeyRange()[$model['current_stage_of_project_development']] ?? ''), [
                'class' => 'col-md-9 col-sm-12'
            ]), ['class' => 'row']);
        endif;
        getRowBlockInfo('share_of_project_equity_offered', $model);
        getRowBlockInfo('expected_financial_return', $model['lang']);
        getRowBlockInfo('kind_of_economic_activity', $model['lang']);
        getRowBlockInfo('estimated_return_on_investment', $model['lang']);
        getRowBlockInfo('technical_parameters', $model['lang']);
//        getRowBlockInfo('total_investment', $model['lang']);
        getRowBlockInfo('forms_cooperation_with_investor', $model['lang']);
        getRowBlockInfo('achieved_effect', $model['lang']);
        getRowBlockInfo('expenditure_additional_infrastructure', $model['lang']);
        ?>
    </div>
<?php
$script = <<< JS
    var markers = [$js_features];
    function initMap() {
            var myLatLng = $position;

            var map = new google.maps.Map(document.getElementById('map'), {
                zoom: 6,
                center: myLatLng,
                scrollwheel: false

            });
            for (var i = 0, l = markers.length; i < l; i++) {
                var marker = markers[i];
                marker.map = map;
                markers[i] = new google.maps.Marker(marker);
            }
       }
JS;
$this->registerJsFile($bundle->baseUrl . '/libs/infoBubble/infobubble.js');
$this->registerJsFile('//developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js');

$this->registerJsFile('//maps.googleapis.com/maps/api/js?key=AIzaSyCRjI5CDX5BPpcmvu6a6bSzDyMXThMaNeo&callback=initMap&language=' . mb_substr(Yii::$app->language, 0, 2));
$this->registerJs($script, yii\web\View::POS_HEAD);