diff --git a/common/mail/calculator.php b/common/mail/calculator.php
index def50f0..4aeca33 100644
--- a/common/mail/calculator.php
+++ b/common/mail/calculator.php
@@ -27,9 +27,21 @@
= \Yii::t('app', 'Email: ') ?> |
= $model->email ?> |
-
- = \Yii::t('app', 'JSON string: ') ?> |
- = $model->calc_json_info ?> |
-
+ getCalcJsonInfo() as $attr => $value) {
+
+ ?>
+
+
+ = \Yii::t('app', $attr) ?> |
+ = $value ?> |
+
+
+
diff --git a/common/messages/ru/app.php b/common/messages/ru/app.php
index c2381ae..3cfde4e 100644
--- a/common/messages/ru/app.php
+++ b/common/messages/ru/app.php
@@ -214,4 +214,22 @@ return [
'showcase_pr_text3' => 'утвержденных компаниями энергоснабжения наших СЭС',
'showcase_pr_text4' => 'введенная в эксплуатацию коммерческая СЭС на крыше офисного здания в Киеве',
'firsts' => '-ая',
+
+ // для отсылки на эмэйл
+
+ 'adress' => "Адрес",
+ 'module_install_angle' => "Угол установки фотомодулей",
+ 'latitude' => "Широта",
+ 'longitude' => "Долгота",
+ 'power_station_type' => "Тип станции",
+ 'area' => "Площадь",
+ 'power' => "Мощность",
+ 'budget' => "Бюджет",
+ 'auth_day' => "Суточное потребление в кВт*ч",
+ 'auth_month' => "Месячное потребление в кВт*ч",
+ 'auth_pwr_all' => "Мощность всех потребителей потребление в кВт*ч",
+ 'auth_pwr_days' => "Суток автономности",
+
+ // для отсылки на эмэйл
+
];
\ No newline at end of file
diff --git a/common/models/Feedback.php b/common/models/Feedback.php
index 8149dc6..32cb06a 100644
--- a/common/models/Feedback.php
+++ b/common/models/Feedback.php
@@ -1,5 +1,7 @@
"Адрес",
+ 'module_install_angle' => "Угол установки фотомодулей",
+ 'latitude' => "Широта",
+ 'longitude' => "Долгота",
+ 'south_deviation' => "Отклонение от юга",
+ 'power_station_type' => "Тип станции",
+ 'area' => "Площадь",
+ 'power' => "Мощность",
+ 'budget' => "Бюджет",
+ 'auth_day' => "Суточное потребление в кВт*ч",
+ 'auth_month' => "Месячное потребление в кВт*ч",
+ 'auth_pwr_all' => "Мощность всех потребителей потребление в кВт*ч",
+ 'auth_pwr_days' => "Суток автономности",
+ ];
+
public $attributeValues = [];
public function __set($name, $value)
{
- if(in_array($name, self::calculator_attributes)){
- if(isset($value) && !empty($value)){
- $this->attributeValues[$name] = $value;
+ if (in_array($name, self::calculator_attributes)) {
+ if (isset($value) && !empty($value)) {
+ $this->attributeValues[ $name ] = $value;
}
- }
- else{
+ } else {
parent::__set($name, $value);
}
}
public function __get($name)
{
- if(in_array($name, self::calculator_attributes)){
- return $this->attributeValues[$name]??'';
- }
- else{
+ if (in_array($name, self::calculator_attributes)) {
+ return $this->attributeValues[ $name ]??'';
+ } else {
return parent::__get($name);
}
}
-
- public function getCalculatorAttributes(){
+
+ public function getCalculatorAttributes()
+ {
return $this->attributeValues;
}
-
+
public function scenarios()
{
return array_merge(
@@ -79,16 +103,17 @@
[
'name',
'phone',
+ 'email',
'returnUrl',
'topic',
'calc_json_info',
],
self::calculator_attributes
- )
+ ),
]
);
}
-
+
public function rules()
{
@@ -113,15 +138,14 @@
'name',
'phone',
'email',
- 'topic',
'calc_json_info',
'adress',
- 'module_install_angle'
+ 'module_install_angle',
],
'required',
'on' => self::SCENARIO_CALCULATOR,
- ]
+ ],
]
);
}
@@ -131,7 +155,7 @@
$this->calc_json_info = json_encode($this->attributeValues);
}
- public function getCalcJsonInfo() : array
+ public function getCalcJsonInfo()
{
return json_decode($this->calc_json_info);
}
diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php
index c1f0c86..164c40f 100644
--- a/frontend/controllers/SiteController.php
+++ b/frontend/controllers/SiteController.php
@@ -55,21 +55,28 @@
$slider = Slider::find()
->with("slides.lang.image")
- ->where(['on_home_page'=>true])
+ ->where([ 'on_home_page' => true ])
->one();
-
+
$objects = Objectkb::find()
- ->with('lang.alias')
- ->where([
- 'id' => array(7,37,38,39)
- ])
- ->orderBy('id')
- ->all();
-
+ ->with('lang.alias')
+ ->where(
+ [
+ 'id' => [
+ 7,
+ 37,
+ 38,
+ 39,
+ ],
+ ]
+ )
+ ->orderBy('id')
+ ->all();
+
return $this->render(
'index',
[
- 'slider' => $slider,
+ 'slider' => $slider,
'objects' => $objects,
]
);
@@ -161,33 +168,32 @@
throw new BadRequestHttpException();
} else {
$post = Yii::$app->request->post('Feedback');
- switch ($post['topic']){
+ switch ($post[ 'topic' ]) {
case Feedback::SCENARIO_FEEDBACK :
- $model = new Feedback(['scenario' => Feedback::SCENARIO_FEEDBACK]);
+ $model = new Feedback([ 'scenario' => Feedback::SCENARIO_FEEDBACK ]);
$view = 'feedback';
$isLoaded = $model->load(Yii::$app->request->post());
break;
-
+
case Feedback::SCENARIO_CALLBACK :
- $model = new Feedback(['scenario' => Feedback::SCENARIO_CALLBACK]);
+ $model = new Feedback([ 'scenario' => Feedback::SCENARIO_CALLBACK ]);
$view = 'feedback';
$isLoaded = $model->load(Yii::$app->request->post());
break;
-
+
case Feedback::SCENARIO_CALCULATOR:
- $model = new Feedback(['scenario' => Feedback::SCENARIO_CALCULATOR]);
+ $model = new Feedback([ 'scenario' => Feedback::SCENARIO_CALCULATOR ]);
$view = 'calculator';
$isLoaded = $model->load(Yii::$app->request->post());
$model->setCalcJsonInfo();
break;
-
+
default:
$model = new Feedback();
$view = 'feedback';
$isLoaded = $model->load(Yii::$app->request->post());
}
-
if ($isLoaded && $model->save()) {
$mailer->compose(
@@ -198,19 +204,19 @@
)
->setFrom('artbox@domain.com')// ->setTo($settings->email)
->setTo(
- [
- 'tamerlan8.05.92@gmail.com',
- 'mpav@artweb.ua',
- ]
- )
+ [
+ 'tamerlan8.05.92@gmail.com',
+ 'mpav@artweb.ua',
+ ]
+ )
->setSubject(\Yii::t('app', 'Feedback'))
->send();
return [
'success' => true,
'message' => 'Success message',
- 'view' => $view,
- 'model' => $model->attributeValues,
+ 'view' => $view,
+ 'model' => $model->attributeValues,
'alert' => $this->renderPartial('success_alert'),
];
} else {
diff --git a/frontend/views/site/index.php b/frontend/views/site/index.php
index 6176884..ae7b50d 100644
--- a/frontend/views/site/index.php
+++ b/frontend/views/site/index.php
@@ -15,9 +15,13 @@
$settings = Settings::getInstance();
$this->title = 'KB Energy';
+ $coordinates = [];
+ $coordinates['lat'] = empty($settings->lat) ? 0 : $settings->lat;
+ $coordinates['lon'] = empty($settings->lon) ? 0 : $settings->lon;
+
$js = <<< JS
-window.lat = {$settings->lat};
-window.lon = {$settings->lon};
+window.lat = {$coordinates['lat']};
+window.lon = {$coordinates['lon']};
JS;
$this->registerJs($js, View::POS_END);
--
libgit2 0.21.4