f6e211e4
Administrator
finish work part 1
|
1
2
3
4
5
6
|
<?php
$this->renderPartial('//snippets/headerGallery');
$cs = Yii::app()->getClientScript();
$cs->registerCssFile('/bower_components/select2/dist/css/select2.min.css');
|
4c373a79
Administrator
ашкые
|
7
8
|
$cs->registerCssFile('/css/bootstrap/css/bootstrap-theme.min.css');
|
f6e211e4
Administrator
finish work part 1
|
9
|
|
4c373a79
Administrator
ашкые
|
10
11
12
13
|
$cs->registerScriptFile('/bower_components/jquery/dist/jquery.min.js');
$cs->registerScriptFile('/bower_components/select2/dist/js/select2.min.js');
$cs->registerScriptFile('/bower_components/jquery-validation/dist/jquery.validate.min.js');
$cs->registerScriptFile('/css/bootstrap/js/bootstrap.min.js');
|
f6e211e4
Administrator
finish work part 1
|
14
15
16
17
18
19
20
21
22
23
24
|
?>
<div class="wrapper content-wrapper sto-filter">
<div class="col-wrapper">
<div class="col10">
<h1><?php echo CHtml::encode($this->pageName)?></h1>
<div class="text-content">
<?php echo $content ?>
</div>
|
f6e211e4
Administrator
finish work part 1
|
25
|
|
4c373a79
Administrator
ашкые
|
26
27
28
29
|
<form id="select-filter-form">
<div class="row">
<div class="col3">
<select id="brand" name="StoFilter[brand]">
|
9f115bdf
Administrator
ашкые
|
30
|
<option class="default" disabled selected>Марка</option>
|
4c373a79
Administrator
ашкые
|
31
32
33
34
35
36
37
|
<?php foreach($brands as $brand):?>
<option value="<?= $brand->brand ?>"><?= $brand->brand ?></option>
<?php endforeach;?>
</select>
</div>
<div class="col3">
<select id="model" disabled name="StoFilter[model]">
|
9f115bdf
Administrator
ашкые
|
38
|
<option class="default" disabled selected>Модель</option>
|
4c373a79
Administrator
ашкые
|
39
40
41
42
|
</select>
</div>
<div class="col3">
<select id="engine" disabled name="StoFilter[engine]">
|
9f115bdf
Administrator
ашкые
|
43
|
<option class="default" disabled selected>Двигатель</option>
|
4c373a79
Administrator
ашкые
|
44
45
46
|
</select>
</div>
|
f6e211e4
Administrator
finish work part 1
|
47
|
</div>
|
4c373a79
Administrator
ашкые
|
48
49
50
|
<div class="row">
<div class="col3">
<select id="drive_unit" disabled name="StoFilter[drive_unit]">
|
9f115bdf
Administrator
ашкые
|
51
|
<option class="default" disabled selected>Привод</option>
|
4c373a79
Administrator
ашкые
|
52
53
54
55
|
</select>
</div>
<div class="col3">
<select id="transmission" disabled name="StoFilter[transmission]">
|
9f115bdf
Administrator
ашкые
|
56
|
<option class="default" disabled selected>Коробка</option>
|
4c373a79
Administrator
ашкые
|
57
58
59
60
|
</select>
</div>
<div class="col3">
<select id="fuel_type" disabled name="StoFilter[fuel_type]">
|
9f115bdf
Administrator
ашкые
|
61
|
<option class="default" disabled selected>Тип топлива</option>
|
4c373a79
Administrator
ашкые
|
62
63
64
|
</select>
</div>
|
f6e211e4
Administrator
finish work part 1
|
65
|
</div>
|
4c373a79
Administrator
ашкые
|
66
67
68
|
<div class="row">
<div class="col3">
<select id="mileage" disabled name="mileage">
|
9f115bdf
Administrator
ашкые
|
69
|
<option class="default" disabled selected>Пробег</option>
|
4c373a79
Administrator
ашкые
|
70
71
|
</select>
</div>
|
f6e211e4
Administrator
finish work part 1
|
72
|
</div>
|
4c373a79
Administrator
ашкые
|
73
74
|
<input type="hidden" id="sto_filter_id" name="sto_filter_id" value="">
</form>
|
f6e211e4
Administrator
finish work part 1
|
75
|
|
f6e211e4
Administrator
finish work part 1
|
76
77
78
|
<div class="row">
<div class="to-table">
|
f6e211e4
Administrator
finish work part 1
|
79
|
|
f6e211e4
Administrator
finish work part 1
|
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
</div>
</div>
</div>
<div class="col2">
<p class="section-title"><?php echo Yii::t('site','Есть вопросы?');?></p>
<div class="text-content">
<?php echo Yii::t('site','Обращайтесь к вашему персональному консультанту (акции)!');?>
</div>
<?php $this->renderPartial('//snippets/sidebarContacts');?>
</div>
</div>
</div>
<script type="text/javascript">
|
4c373a79
Administrator
ашкые
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
$('select').select2({
minimumResultsForSearch: Infinity
});
$('#sto-form').validate({
rules:{
phone:{
number: true
}
},
messages:{
name: "Введите ваше имя",
phone: {
required: "Введите ваш новер телефона",
number: "Неверный формат"
},
email: {
required: "Введите ваш email",
email: "Неверный формат"
}
}
});
$('#sto-form').submit(function(e){
e.preventDefault();
var error = $(this).find('input.error').length;
if(!error){
var $text = $('.to-table').html();
var $name = $('#exampleInputName').val();
var $email = $('#exampleInputEmail').val();
var $phone = $('#exampleInputPhone').val();
$.post( "/<?= Yii::app()->language?>/ajaxStoFilter/send", {text:$text, name:$name, phone:$phone, email:$email}, function( data ) {
console.log(data);
});
}
});
|
9f115bdf
Administrator
ашкые
|
140
141
142
143
144
145
146
147
|
$('body').on('click', '.active-select', function(){
$(this).siblings('select').find('.default').attr('selected','selected').trigger('change');
});
|
4c373a79
Administrator
ашкые
|
148
149
150
151
|
var insertOptions = function(result, id){
var select = $("#"+id);
|
9f115bdf
Administrator
ашкые
|
152
153
|
|
4c373a79
Administrator
ашкые
|
154
155
156
157
158
159
160
161
162
163
164
|
select.prop("disabled", false);
var data_select = select.val();
var options = select.find('option').remove();
options.splice(1, options.length-1);
select.append(options);
for(property in result[id]){
|
9f115bdf
Administrator
ашкые
|
165
166
167
168
169
170
|
if(data_select ==property.trim() ){
select.parent('.col3').append('<div class="active-select">X</div>');
|
4c373a79
Administrator
ашкые
|
171
172
173
174
175
176
|
select.append($('<option>', {
value: property,
text : property,
selected: true
}));
} else {
|
9f115bdf
Administrator
ашкые
|
177
|
|
4c373a79
Administrator
ашкые
|
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
select.append($('<option>', {
value: property,
text : property
}));
}
}
};
function countFullPrice(){
var fullPrice = +$('#total-require-price').html() + +$('#priceTotalCars').html();
$('#full_sto_price').html(fullPrice);
}
$('body').on('click', '.optional-row', function(){
if($(this).prop( "checked" )){
$(this).attr('checked','checked');
var price = $(this).parents('tr').find('.optional_row_price').html().replace(' грн.','');
var priceTotalCars = +$('#priceTotalCars').html();
priceTotalCars += +price;
$('#priceTotalCars').html(priceTotalCars);
countFullPrice();
} else {
$(this).removeAttr('checked');
var price = $(this).parents('tr').find('.optional_row_price').html().replace(' грн.','');
var priceTotalCars = +$('#priceTotalCars').html();
priceTotalCars -= +price;
$('#priceTotalCars').html(priceTotalCars);
countFullPrice();
}
});
$('select').change(function(){
if($(this).attr('id') ==='mileage' ){
var id = $('#sto_filter_id').val();
var dist = $(this).val();
$.post( "/<?= Yii::app()->language?>/ajaxStoFilter/renderPriceList", {id:id, dist:dist}, function( data ) {
$('.to-table').empty();
$('.to-table').html(data);
var $requirePrice = 0;
$(".require-table").find('.require-price').each(function(){
var val = $(this).html().replace(' грн.','');
$requirePrice += +val;
});
$('#total-require-price').html($requirePrice);
countFullPrice();
})
} else {
var $form = $('#select-filter-form').serialize();
$.get( "/<?= Yii::app()->language?>/ajaxStoFilter/filter/?"+$form, function( data ) {
var result = JSON.parse(data);
|
9f115bdf
Administrator
ашкые
|
261
|
$('body').find('.active-select').remove();
|
4c373a79
Administrator
ашкые
|
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
if(Object.keys(result.model).length){
insertOptions(result, 'model');
}
if(Object.keys(result.engine).length){
insertOptions(result, 'engine');
}
if(Object.keys(result.drive_unit).length){
insertOptions(result, 'drive_unit');
}
if(Object.keys(result.transmission).length){
insertOptions(result, 'transmission');
}
if(Object.keys(result.fuel_type).length){
insertOptions(result, 'fuel_type');
}
if((result.mileage !== undefined) && Object.keys(result.mileage).length){
insertOptions(result, 'mileage');
$('#sto_filter_id').val(result.id);
}
});
}
});
</script>
|