diff --git a/common/messages/ru/app.php b/common/messages/ru/app.php index 5dd9487..f077bb1 100644 --- a/common/messages/ru/app.php +++ b/common/messages/ru/app.php @@ -294,7 +294,7 @@ return [ 'gohomepage' => 'Go to Homepage', 'formname' => 'Имя', - 'formtheme' => 'Тема', + 'formtheme' => 'Телефон', 'formmess' => 'Сообщение', 'nashiuslugi' => 'Наши услуги', "Home" => "Главная", diff --git a/common/messages/ua/app.php b/common/messages/ua/app.php index 13713ec..19934a5 100644 --- a/common/messages/ua/app.php +++ b/common/messages/ua/app.php @@ -295,7 +295,7 @@ return [ 'gohomepage' => 'На головну', 'formname' => 'Ім\'я', - 'formtheme' => 'Тема', + 'formtheme' => 'Телефон', 'formmess' => 'Повідомлення', 'nashiuslugi' => 'Наші послуги', diff --git a/common/models/Feedback.php b/common/models/Feedback.php index 0f07118..54fb551 100644 --- a/common/models/Feedback.php +++ b/common/models/Feedback.php @@ -1,163 +1,175 @@ "Адрес", + '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) { - - const SCENARIO_CALCULATOR = 'calculator'; - const calculator_attributes = [ - 'adress', - 'module_install_angle', - 'latitude', - 'longitude', - 'south_deviation', - 'power_station_type', - 'area', - 'power', - 'budget', - 'auth_day', - 'auth_month', - 'auth_pwr_all', - 'auth_pwr_days', - ]; - - const translate_attributes = [ - 'adress' => "Адрес", - '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; - } - } else { - parent::__set($name, $value); - } - } - - public function __get($name) - { - if (in_array($name, self::calculator_attributes)) { - return $this->attributeValues[ $name ]??''; - } else { - return parent::__get($name); + if (in_array($name, self::calculator_attributes)) { + if (isset($value) && !empty($value)) { + $this->attributeValues[ $name ] = $value; } + } else { + parent::__set($name, $value); } - - public function getCalculatorAttributes() - { - return $this->attributeValues; + } + + public function __get($name) + { + if (in_array($name, self::calculator_attributes)) { + return $this->attributeValues[ $name ]??''; + } else { + return parent::__get($name); } - - public function scenarios() - { - return array_merge( - parent::scenarios(), - [ - parent::SCENARIO_FEEDBACK => [ - 'name', - 'email', - 'phone', - 'message', - 'returnUrl', - 'topic', - ], - parent::SCENARIO_CALLBACK => [ + } + + public function getCalculatorAttributes() + { + return $this->attributeValues; + } + + public function scenarios() + { + return array_merge( + parent::scenarios(), + [ + parent::SCENARIO_FEEDBACK => [ + 'name', + 'email', + 'phone', + 'message', + 'returnUrl', + 'topic', + ], + parent::SCENARIO_CALLBACK => [ + 'name', + 'phone', + 'message', + 'returnUrl', + 'topic', + ], + self::SCENARIO_CALCULATOR => array_merge( + [ 'name', 'phone', - 'message', + 'email', 'returnUrl', 'topic', + 'calc_json_info', ], - self::SCENARIO_CALCULATOR => array_merge( - [ - 'name', - 'phone', - 'email', - 'returnUrl', - 'topic', - 'calc_json_info', - ], - self::calculator_attributes - ), - ] - ); - } - - public function rules() - { - - return array_merge( - parent::rules(), + self::calculator_attributes + ), + ] + ); + } + + public function rules() + { + + return array_merge( + parent::rules(), + [ [ [ - [ - 'topic', - ], - 'required', + 'topic', ], + 'required', + ], + [ [ - [ - 'topic', - ], - 'string', - 'max' => 100, + 'topic', ], + 'string', + 'max' => 100, + ], + [ [ - [ - 'name', - 'phone', - 'email', - 'calc_json_info', - - 'adress', - 'module_install_angle', - ], - 'required', - 'on' => self::SCENARIO_CALCULATOR, + 'name', + 'phone', + 'email', + 'calc_json_info', + + 'adress', + 'module_install_angle', ], - ] - ); - } - - public function setCalcJsonInfo() - { - $this->calc_json_info = json_encode($this->attributeValues); - } - - public function getCalcJsonInfo() - { - return json_decode($this->calc_json_info); - } - } \ No newline at end of file + 'required', + 'on' => self::SCENARIO_CALCULATOR, + ], + [ + ['message'],'required','message'=>'Поле сообщение обязательное для заполнения'], + [ + ['message'],'string','min'=>10], + [['phone'],'string','length'=>[17,17],'message'=>'Введите данные в форму согласно заданному шаблону: +38(132) 456 78 89'], + [['phone'],'match','pattern'=>'/\+3?8?\(?([\d]{3}([ .-]?))\)?([ .-]?)([\d]{3}([ .-]?))\2([\d]{2}([ .-]?))([\d]{2}([ .-]?))/','message'=>'некорректный ввод поля. Значение должно иметь вид: +38(123) 456 78 79'], + + [['name','email'],'string','length'=>[5,25]], + [['name'],'match','pattern' => '/^[а-яА-ЯёЁa-zA-Z\-\s]+$/','message'=> \Yii::t('app', 'Имя может состоять только из + английский или латинских символов')], + [['email'],'email'], + + ] + ); + } + + public function setCalcJsonInfo() + { + $this->calc_json_info = json_encode($this->attributeValues); + } + + public function getCalcJsonInfo() + { + return json_decode($this->calc_json_info); + } +} \ No newline at end of file diff --git a/frontend/assets/AppAsset.php b/frontend/assets/AppAsset.php index 75e7f70..aed8e68 100644 --- a/frontend/assets/AppAsset.php +++ b/frontend/assets/AppAsset.php @@ -30,6 +30,7 @@ 'js/front.js', 'js/owl.carousel.min.js', 'js/script.js', + 'js/jquery.mask.min.js' ]; public $depends = [ 'yii\web\YiiAsset', diff --git a/frontend/web/js/script.js b/frontend/web/js/script.js index 567c78c..c06e055 100755 --- a/frontend/web/js/script.js +++ b/frontend/web/js/script.js @@ -1,5 +1,7 @@ $( function() { + phoneMask('input[name="Feedback[phone]"]'); + /** * Modal form submit code @@ -142,5 +144,52 @@ $( // $("#feedback-form")['0'].reset(); $(".send-form").attr('id', 'callback'); }); + + + function phoneMask(maskCssSelector) { + var phoneInput = maskCssSelector; + + if($('body').find(phoneInput).length>0){ + $(phoneInput).mask('+38(000)000-00-00',{placeholder:'+38(000)000-00-00'}); + $(phoneInput).focus(function () { + if(($(this).val())== '') {$(this).val('+38(0')} + }); + $(phoneInput).focusout(function () { + var phoneVal = $(this).val() + //if(phoneVal == '+38(0' || phoneVal == '+38(' || phoneVal == '+38' || phoneVal == '+3' || phoneVal == '+') {$(this).val('')} + if(phoneVal.length <17) {$(this).val('')} + }); + } + } + + + /** + * Блокирую кнопку сабмита после нажатия на 5 сек + */ + $('button[type="Submit"]').on('click',function () { + var $this = $(this); + $this.attr('disabled', true); + setTimeout(function() { + $this.attr('disabled', false); + }, 5000); + }); + + + + + + + + } + + + + + + + + + + ); \ No newline at end of file -- libgit2 0.21.4