Fix Bids forms

parent 292438b1
...@@ -22,8 +22,6 @@ class Module extends \common\components\WebModule ...@@ -22,8 +22,6 @@ class Module extends \common\components\WebModule
public function init() public function init()
{ {
parent::init(); parent::init();
// custom initialization code goes here
} }
public static function name() public static function name()
......
...@@ -26,7 +26,7 @@ use yii\grid\GridView; ...@@ -26,7 +26,7 @@ use yii\grid\GridView;
'attribute' => 'url', 'attribute' => 'url',
'format' => 'raw', 'format' => 'raw',
'value' => function($data) { 'value' => function($data) {
return Html::a($data->url, 'http://soc-zaim.ru/'.$data->url, ['target' => '_blank', 'title' => 'Просмотреть как страницу видит пользователь', 'data-toggle'=>"tooltip"]);$data->category->name; return Html::a($data->url, Yii::$app->params['frontUrl'].($data->url!='/'?'/':'').$data->url, ['target' => '_blank', 'title' => 'Просмотреть как страницу видит пользователь', 'data-toggle'=>"tooltip"]);$data->category->name;
} }
], ],
[ [
......
<?php
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use common\modules\bids\models\Bid;
?>
<div class="hidden">
<div id="zvonok_form" class="popup">
<div class="txtbtnclose">Закрыть</div>
<span class="popup__title">Заказать звонок</span>
<span class="popup__subtittle">Чтобы мы могли вам перезвонить укажите свой номер телефона:</span>
<?php
$model = new Bid;
$model->scenario = Bid::SCENARIO_CALLBACK;
$form = ActiveForm::begin([
'action' => '/',
'options' => [
'class' => 'valid_form bids-form',
],
]); ?>
<?php echo Html::hiddenInput('scenario', $model->scenario); ?>
<?php echo $form->field($model, 'name', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
'errorOptions' => []
])->textInput([
'placeholder' => 'Ваше имя',
'class' => 'input_st'
])->label(false); ?>
<?php echo $form->field($model, 'phone', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
'errorOptions' => []
])->textInput([
'placeholder' => 'Ваш телефон',
'class' => 'input_st'
])->label(false); ?>
<?php echo Html::submitButton('Заказать звонок', ['class' => 'save-button popup_bt_send']); ?>
<?php ActiveForm::end(); ?>
</div>
</div>
\ No newline at end of file
...@@ -22,4 +22,5 @@ ...@@ -22,4 +22,5 @@
<?php $this->registerJsFile('/js/jquery.inputmask.js', ['position' => yii\web\View::POS_END ]);?> <?php $this->registerJsFile('/js/jquery.inputmask.js', ['position' => yii\web\View::POS_END ]);?>
<?php $this->registerJsFile('/js/inputmask.phone.extensions.js', ['position' => yii\web\View::POS_END ]);?> <?php $this->registerJsFile('/js/inputmask.phone.extensions.js', ['position' => yii\web\View::POS_END ]);?>
<?php $this->registerJsFile('/js/common.js', ['position' => yii\web\View::POS_END ]);?> <?php $this->registerJsFile('/js/common.js', ['position' => yii\web\View::POS_END ]);?>
\ No newline at end of file <?php $this->registerJsFile('/js/bids-form.js', ['position' => yii\web\View::POS_END ]);?>
\ No newline at end of file
...@@ -6,67 +6,6 @@ use yii\helpers\Url; ...@@ -6,67 +6,6 @@ use yii\helpers\Url;
use common\modules\bids\models\Bid; use common\modules\bids\models\Bid;
?> ?>
<style type="text/css">
.footer_form input,
.footer_form textarea {
margin-bottom: 9px;
}
.field-bid-file {
margin: 0;
}
</style>
<?php
$js = <<<JS
$('#bid-phone').inputmask("phone", {
url: "js/phone-codes/phone-codes.js",
});
$('form#form_foot').on('beforeSubmit', function(e) {
var form = $(this), xhr = new XMLHttpRequest, filebool = false, file, data = new FormData();
form.find('input, textarea').each(function(){
data.append($(this).attr('name'), $(this).val());
});
if(form.find('input[type=file]').length) {
file = form.find('input[type=file]')[0].files[0];
filebool = !filebool;
data.append("Bid[file]", file);
}
xhr.open("POST", '/bids/bid/add', true);
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.send(data);
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4){
try
{
var response = JSON.parse(xhr.responseText);
}
catch(e)
{
var response = xhr.responseText;
}
if(response.success)
{
form.find('input[name!="scenario"], textarea').val('');
}
}
}
}).on('submit', function(e){
return false;
});
JS;
$this->registerJs($js);
?>
<footer> <footer>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
...@@ -84,27 +23,36 @@ $this->registerJs($js); ...@@ -84,27 +23,36 @@ $this->registerJs($js);
'id' => 'form_foot', 'id' => 'form_foot',
'action' => '/', 'action' => '/',
'options' => [ 'options' => [
'class' => 'footer_form', 'class' => 'footer_form bids-form',
'enctype' => 'multipart/form-data' 'enctype' => 'multipart/form-data'
], ],
]); ?> ]); ?>
<?php echo Html::hiddenInput('scenario', $model->scenario); ?> <?php echo Html::hiddenInput('scenario', $model->scenario); ?>
<?php echo $form->field($model, 'name')->textInput([ <?php echo $form->field($model, 'name', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
'errorOptions' => []
])->textInput([
'placeholder' => 'Ваше имя*', 'placeholder' => 'Ваше имя*',
'class' => 'footer_form__input' 'class' => 'footer_form__input'
])->label(false); ?> ]); ?>
<?php echo $form->field($model, 'phone')->textInput([ <?php echo $form->field($model, 'phone', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
'errorOptions' => []
])->textInput([
'placeholder' => 'Телефон*', 'placeholder' => 'Телефон*',
'class' => 'footer_form__input' 'class' => 'footer_form__input'
])->label(false); ?> ]); ?>
<?php echo $form->field($model, 'email')->textInput([ <?php echo $form->field($model, 'email', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
'errorOptions' => []
])->textInput([
'placeholder' => 'E-mail*', 'placeholder' => 'E-mail*',
'class' => 'footer_form__input' 'class' => 'footer_form__input'
])->label(false); ?> ]); ?>
<?php echo $form->field($model, 'text')->textArea([ <?php echo $form->field($model, 'text')->textArea([
'placeholder' => 'Опишите в двух словах ваш проект', 'placeholder' => 'Опишите в двух словах ваш проект',
...@@ -115,7 +63,9 @@ $this->registerJs($js); ...@@ -115,7 +63,9 @@ $this->registerJs($js);
<div class="file_upload_bt"> <div class="file_upload_bt">
<div class="file-upload"> <div class="file-upload">
<label> <label>
<?php echo $form->field($model, 'file')->fileInput()->label(false); ?> <?php echo $form->field($model, 'file', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>'
])->fileInput(); ?>
<span>Выбрать файл</span> <span>Выбрать файл</span>
</label> </label>
</div> </div>
...@@ -166,15 +116,4 @@ $this->registerJs($js); ...@@ -166,15 +116,4 @@ $this->registerJs($js);
</div> </div>
</footer> </footer>
<div class="hidden"> <?php echo $this->render('block/callback'); ?>
<div id="zvonok_form" class="popup"> \ No newline at end of file
<div class="txtbtnclose">Закрыть</div>
<span class="popup__title">Заказать звонок</span>
<span class="popup__subtittle">Чтобы мы могли вам перезвонить укажите свой номер телефона:</span>
<form class="valid_form">
<input type="text" class="input_st field-input required alphanumeric" placeholder="Ваше имя">
<input type="tel" class="input_st field-input required email" placeholder="Ваш телефон">
<button class="save-button popup_bt_send">Заказать звонок</button>
</form>
</div>
</div>
\ No newline at end of file
...@@ -36,15 +36,4 @@ ...@@ -36,15 +36,4 @@
</div> </div>
</footer> </footer>
<div class="hidden"> <?php echo $this->render('block/callback'); ?>
<div id="zvonok_form" class="popup"> \ No newline at end of file
<div class="txtbtnclose">Закрыть</div>
<span class="popup__title">Заказать звонок</span>
<span class="popup__subtittle">Чтобы мы могли вам перезвонить укажите свой номер телефона:</span>
<form class="valid_form">
<input type="text" class="input_st field-input required alphanumeric" placeholder="Ваше имя">
<input type="tel" class="input_st field-input required email" placeholder="Ваш телефон">
<button class="save-button popup_bt_send">Заказать звонок</button>
</form>
</div>
</div>
\ No newline at end of file
...@@ -19,4 +19,5 @@ ...@@ -19,4 +19,5 @@
<?php $this->registerCssFile('/css/fonts.css');?> <?php $this->registerCssFile('/css/fonts.css');?>
<?php $this->registerCssFile('/css/screen.css');?> <?php $this->registerCssFile('/css/screen.css');?>
<?php $this->registerCssFile('/css/media.css');?> <?php $this->registerCssFile('/css/media.css');?>
\ No newline at end of file <?php $this->registerCssFile('/css/custom.css');?>
\ No newline at end of file
<?php <?php
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use \common\models\Settings; use \common\models\Settings;
use \common\modules\bids\models\Bid;
?>
?> ?>
<script type="text/javascript"> <script type="text/javascript">
...@@ -75,24 +80,60 @@ use \common\models\Settings; ...@@ -75,24 +80,60 @@ use \common\models\Settings;
<div class="row"> <div class="row">
<div class="col-md-12 col-xs-12 col-sm-12"> <div class="col-md-12 col-xs-12 col-sm-12">
<div class="sect_cont_block"> <div class="sect_cont_block">
<form class="sect_cont_form" id="form_foot"> <?php
<input type="text" placeholder="Ваше имя*" name="name" class="sect_cont_form__input field-input required alphanumeric"> $model = new Bid;
<input type="tel" placeholder="Телефон*" name="phone" class="sect_cont_form__input field-input required alphanumeric"> $model->scenario = Bid::SCENARIO_CALLBACK;
<textarea placeholder="Текст сообщения" class="sect_cont_form__textarea"></textarea>
$form = ActiveForm::begin([
'id' => 'form_foot',
'action' => '/',
'options' => [
'class' => 'sect_cont_form bids-form',
'enctype' => 'multipart/form-data'
],
]); ?>
<?php echo Html::hiddenInput('scenario', $model->scenario); ?>
<?php echo $form->field($model, 'name', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
'errorOptions' => []
])->textInput([
'placeholder' => 'Ваше имя*',
'class' => 'sect_cont_form__input'
]); ?>
<?php echo $form->field($model, 'phone', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
'errorOptions' => []
])->textInput([
'placeholder' => 'Телефон*',
'class' => 'sect_cont_form__input'
]); ?>
<?php echo $form->field($model, 'text')->textArea([
'placeholder' => 'Опишите в двух словах ваш проект',
'class' => 'sect_cont_form__textarea'
])->label(false); ?>
<div class="file-upload_block_cs"> <div class="file-upload_block_cs">
<div class="file_upload_bt_cs"> <div class="file_upload_bt_cs">
<div class="file-upload_cs"> <div class="file-upload_cs">
<label> <label>
<input type="file" name="file"> <?php echo $form->field($model, 'file', [
<span>Выбрать файл</span> 'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>'
</label> ])->fileInput(); ?>
<span>Выбрать файл</span>
</label>
</div> </div>
<input type="text" id="filename" class="filename_cs" disabled> <input type="text" id="filename" class="filename_cs" disabled>
<div class="file_drop_cs">Перетащите файл в данную область<br/> или выберите файл с компьютера</div> <div class="file_drop_cs">Перетащите файл в данную область<br/> или выберите файл с компьютера</div>
</div> </div>
</div> </div>
<button class="btn-default save-button">Отправить</button>
</form> <?php echo Html::submitButton('Отправить', ['class' => 'btn-default save-button']); ?>
<?php ActiveForm::end(); ?>
</div> </div>
</div> </div>
</div> </div>
......
.bids-form input,
.bids-form textarea {
margin-bottom: 9px;
}
.field-bid-file {
margin: 0;
}
.has-error input {
background: #fff url(../images/icon-fail.png) no-repeat 96% center;
border: 1px solid #E9A2A2;
}
\ No newline at end of file
$('.bids-form input[name="Bid[phone]"]').inputmask("phone", {
mask: "+7(999)999-99-99"
});
$('form.bids-form').on('beforeSubmit', function(e) {
var form = $(this), xhr = new XMLHttpRequest, filebool = false, file, data = new FormData();
form.find('input, textarea').each(function(){
data.append($(this).attr('name'), $(this).val());
});
if(form.find('input[type=file]').length) {
file = form.find('input[type=file]')[0].files[0];
filebool = !filebool;
data.append("Bid[file]", file);
}
xhr.open("POST", '/bids/bid/add', true);
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.send(data);
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4){
try
{
var response = JSON.parse(xhr.responseText);
}
catch(e)
{
var response = xhr.responseText;
}
if(response.success)
{
form.find('input[name!="scenario"], textarea').val('');
}
}
}
}).on('submit', function(e){
return false;
});
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment