diff --git a/common/mail/calculator.php b/common/mail/calculator.php new file mode 100644 index 0000000..def50f0 --- /dev/null +++ b/common/mail/calculator.php @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
name ?>
topic ?>
phone ?>
email ?>
calc_json_info ?>
diff --git a/common/models/Feedback.php b/common/models/Feedback.php index af2c59e..8149dc6 100644 --- a/common/models/Feedback.php +++ b/common/models/Feedback.php @@ -24,16 +24,18 @@ const calculator_attributes = [ 'adress', 'module_install_angle', 'latitude', 'longitude', 'south_deviation', 'power_station_type', 'area', 'power', - 'budget', 'day_consumption', 'month_consumption', 'consumptors_total_power', - 'autonomous_days' + 'budget', 'auth_day', 'auth_month', 'auth_pwr_all', + 'auth_pwr_days' ]; - - private $attributeValues = []; + + public $attributeValues = []; public function __set($name, $value) { if(in_array($name, self::calculator_attributes)){ - $this->attributeValues[$name] = $value; + if(isset($value) && !empty($value)){ + $this->attributeValues[$name] = $value; + } } else{ parent::__set($name, $value); @@ -111,7 +113,6 @@ 'name', 'phone', 'email', - 'returnUrl', 'topic', 'calc_json_info', @@ -125,9 +126,9 @@ ); } - public function setCalcJsonInfo( array $value) + public function setCalcJsonInfo() { - $this->calc_json_info = json_encode($value); + $this->calc_json_info = json_encode($this->attributeValues); } public function getCalcJsonInfo() : array diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 366760d..c1f0c86 100644 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -160,8 +160,8 @@ if (empty(Yii::$app->request->post())) { throw new BadRequestHttpException(); } else { - - switch (Yii::$app->request->post('topic')){ + $post = Yii::$app->request->post('Feedback'); + switch ($post['topic']){ case Feedback::SCENARIO_FEEDBACK : $model = new Feedback(['scenario' => Feedback::SCENARIO_FEEDBACK]); $view = 'feedback'; @@ -178,14 +178,7 @@ $model = new Feedback(['scenario' => Feedback::SCENARIO_CALCULATOR]); $view = 'calculator'; $isLoaded = $model->load(Yii::$app->request->post()); - $newPost = []; - foreach (Feedback::calculator_attributes as $calculator_attribute_name){ - $calculator_attribute_value = Yii::$app->request->post($calculator_attribute_name); - if( isset($calculator_attribute_value) && !empty($calculator_attribute_value) ){ - $newPost[$calculator_attribute_name] = $calculator_attribute_value; - } - } - $model->setCalcJsonInfo($newPost); + $model->setCalcJsonInfo(); break; default: @@ -216,6 +209,8 @@ return [ 'success' => true, 'message' => 'Success message', + 'view' => $view, + 'model' => $model->attributeValues, 'alert' => $this->renderPartial('success_alert'), ]; } else { diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index ad6cafc..5fcb57c 100644 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -565,165 +565,98 @@
-
- - - -

-
+ field($feedback, "area") + ->textInput() + ->label( + \Yii::t( + 'app', + 'info_area' + ) + )?>
-
- - - -

-
+ field($feedback, "power") + ->textInput() + ->label( + \Yii::t( + 'app', + 'info_power' + ) + )?>
-
- - - -

-
+ field($feedback, "budget") + ->textInput() + ->label( + \Yii::t( + 'app', + 'info_budget' + ) + )?>
- - -
- -
-
-

-
-
-
-
-
-
-
-
-
-
-
-
-
- - - -

-
-
-
-
- - - -

-
-
-
-
- - - -

-
-
-
-
-
-
-
- -
-
-

-
-
-
-
- -

- -

- +
+ +

+ +

+ +
diff --git a/frontend/web/js/script.js b/frontend/web/js/script.js index 3c12a95..a91de16 100644 --- a/frontend/web/js/script.js +++ b/frontend/web/js/script.js @@ -6,7 +6,7 @@ $( */ $(document) .on( - 'beforeSubmit', '#feedback-form', function(e) { + 'beforeSubmit', '#calculate-form, #feedback-form', function(e) { var f = this; var form = $(this); var formData = form.serialize(); @@ -17,7 +17,7 @@ $( data: formData, success: function(data) { f.reset(); - $('#feedback-modal') + $('#feedback-modal,#calculate-modal') .modal('hide'); form.data('yiiActiveForm').validated = false; $('#success-modal') @@ -32,7 +32,7 @@ $( } ) .on( - 'submit', '#feedback-form', function(e) { + 'submit', '#calculate-form, #feedback-form', function(e) { e.preventDefault(); } ); -- libgit2 0.21.4