Commit 5e9f3657484f18a239d2d0f89412c8ad339b3776

Authored by Administrator
1 parent 71c4c77d

VItaliy 21.12.2015

upload
frontend/components/SiteSearch.php 0 → 100644
  1 +<?php
  2 +namespace frontend\components;
  3 +use frontend\models\SiteSearchForm;
  4 +use yii\base\Widget;
  5 +
  6 +
  7 +class SiteSearch extends Widget
  8 +{
  9 + public function init(){
  10 +
  11 + parent::init();
  12 +
  13 + }
  14 +
  15 +
  16 + public function run()
  17 + {
  18 + $model = new SiteSearchForm();
  19 + return $this->render('siteSearch', array('model'=>$model));
  20 + }
  21 +}
0 \ No newline at end of file 22 \ No newline at end of file
frontend/components/views/siteSearch.php 0 → 100644
  1 +<?php
  2 +use yii\widgets\ActiveForm;
  3 +use yii\helpers\Html;
  4 +use yii\helpers\Url;
  5 +?>
  6 +
  7 +<ul class="side_list">
  8 + <li class="by_articul"><a href="">По артикулу</a>
  9 + <div class="menu_search_down" style="display: none;">
  10 + <?php $form = ActiveForm::begin(['options' => ['enctype'=> 'multipart/form-data', 'class'=>'form-search'], 'action' => Url::toRoute('site/search'), 'method'=>'get']); ?>
  11 + <input type="text" placeholder="Поиск" class="input_search1">
  12 + <input type="submit" class="orange_small"><img src="/images/lunette.png"></input>
  13 + <a href="" class="full_search">Расширенный поиск</a>
  14 + <div class="search_span1_dropdown">
  15 +
  16 + <div class="registration_for_detail_search">
  17 + <div class="input">
  18 + <label for="area_search" class="area_label">Тип поиска:</label>
  19 + <select class="area_search">
  20 + <option value="" disabled="" selected="">точное совпадение</option>
  21 + <option value="2">Выбери меня!</option>
  22 + <option value="3">Выбери меня!</option>
  23 + <option value="5">Меня!</option>
  24 + <option value="4">Меня</option>
  25 + </select>
  26 + </div>
  27 +
  28 +
  29 + <div class="input">
  30 + <label for="number">Номер:</label>
  31 + <input type="text" name="number" id="number" class="input_width">
  32 + </div>
  33 + <div class="input">
  34 + <label for="crossnumber">Кросс номер:</label>
  35 + <input type="text" name="crossnumber" id="crossnumber" class="input_width">
  36 + </div>
  37 + <div class="input">
  38 + <label for="mark">Производитель:</label>
  39 + <input type="text" name="mark" id="mark" class="input_width">
  40 + </div>
  41 + <div class="input">
  42 + <label for="name">Наименование:</label>
  43 + <input type="text" name="name" id="name1" class="input_width">
  44 + </div>
  45 + </div>
  46 + </div>
  47 + <?php ActiveForm::end(); ?>
  48 + </div>
  49 + </li>
  50 + <li><a href="">По названию</a></li>
  51 + <li><a href="">По марке</a></li>
  52 + <li><a href="">VIN номеру</a></li>
  53 + <li style="width:130px"><a href="">Расходники для ТО</a></li>
  54 +
  55 +</ul>
  56 +
  57 +
  58 +<!--<div class="all-mramor-search">-->
  59 +<!-- --><?php //$form = ActiveForm::begin(['options' => ['enctype'=> 'multipart/form-data', 'class'=>'form-search'], 'action' => Url::toRoute('site/search'), 'method'=>'get']); ?>
  60 +<!---->
  61 +<!-- --><?//= $form->field($model, 'string',[
  62 +// 'options'=>
  63 +// [
  64 +// 'tag'=>'label',
  65 +// ],
  66 +// 'template' => "{input}",
  67 +// ])->textInput(['maxlength' => 255, 'placeholder' => 'Поиск','class'=>'mramor-search']) ?>
  68 +<!---->
  69 +<!-- <input class="search-text" type="submit" value="">-->
  70 +<!-- --><?php //ActiveForm::end(); ?>
  71 +<!--</div>-->
0 \ No newline at end of file 72 \ No newline at end of file
frontend/controllers/SiteController.php
@@ -5,22 +5,22 @@ use common\models\Accounts; @@ -5,22 +5,22 @@ use common\models\Accounts;
5 use frontend\models\AccountsForm; 5 use frontend\models\AccountsForm;
6 use common\models\News; 6 use common\models\News;
7 use common\models\Slider; 7 use common\models\Slider;
8 -use common\models\Team; 8 +
9 use common\models\TeamGroup; 9 use common\models\TeamGroup;
10 use Yii; 10 use Yii;
11 use common\models\UserLoginForm; 11 use common\models\UserLoginForm;
12 use frontend\models\PasswordResetRequestForm; 12 use frontend\models\PasswordResetRequestForm;
13 use frontend\models\ResetPasswordForm; 13 use frontend\models\ResetPasswordForm;
14 -use frontend\models\SignupForm;  
15 -use frontend\models\ContactForm; 14 +
16 use yii\base\InvalidParamException; 15 use yii\base\InvalidParamException;
17 use yii\web\BadRequestHttpException; 16 use yii\web\BadRequestHttpException;
18 use yii\web\Controller; 17 use yii\web\Controller;
19 18
20 -use yii\filters\VerbFilter;  
21 -use yii\filters\AccessControl;  
22 use common\models\Callback; 19 use common\models\Callback;
23 use common\components\MailWidget; 20 use common\components\MailWidget;
  21 +use frontend\models\SiteSearchForm;
  22 +use yii\db\Query;
  23 +use yii\data\ArrayDataProvider;
24 /** 24 /**
25 * Site controller 25 * Site controller
26 */ 26 */
@@ -45,6 +45,41 @@ class SiteController extends Controller @@ -45,6 +45,41 @@ class SiteController extends Controller
45 ]; 45 ];
46 } 46 }
47 47
  48 + public function actionSearch()
  49 + {
  50 + $this->layout = '/internal';
  51 + $search = new SiteSearchForm();
  52 + if ($search->load(Yii::$app->request->get()) && $search->validate()) {
  53 +// $query1 = (new Query())
  54 +// ->select('name, image, description, translit ')
  55 +// ->addSelect(["CONCAT('stone/view') AS url"])
  56 +// ->where(['like','name',$search->string])
  57 +// ->from('{{%stone}}');
  58 +//
  59 +// $query2 = (new Query())
  60 +// ->select('name, image, description, translit ')
  61 +// ->addSelect(["CONCAT('goods/one-item') AS url"])
  62 +// ->where(['like','name',$search->string])
  63 +// ->from('{{%goods}}');
  64 +//
  65 +// $dataProvider = new ArrayDataProvider([
  66 +// 'allModels' => $query1->union($query2)->all(),
  67 +// 'pagination' => [
  68 +// 'pageSize' => 6,
  69 +// ],
  70 +//
  71 +// ]);
  72 + $dataProvider = array();
  73 +
  74 + return $this->render('search', [
  75 +
  76 + 'dataProvider' => $dataProvider,
  77 + ]);
  78 +
  79 +
  80 + }
  81 + }
  82 +
48 /** 83 /**
49 * Displays homepage. 84 * Displays homepage.
50 * 85 *
frontend/models/SiteSearchForm.php 0 → 100644
  1 +<?php
  2 +namespace frontend\models;
  3 +
  4 +use yii\base\Model;
  5 +use Yii;
  6 +
  7 +class SiteSearchForm extends Model
  8 +{
  9 +
  10 + public $string;
  11 +
  12 +
  13 + public function rules()
  14 + {
  15 + return [
  16 + [['string'], 'required'],
  17 + ];
  18 + }
  19 +
  20 + public function attributeLabels()
  21 + {
  22 + return [
  23 + 'string',
  24 + ];
  25 + }
  26 +}
0 \ No newline at end of file 27 \ No newline at end of file
frontend/web/js/select.js
@@ -1097,178 +1097,178 @@ $(&#39;.steel&#39;).selectize({ @@ -1097,178 +1097,178 @@ $(&#39;.steel&#39;).selectize({
1097 return false; 1097 return false;
1098 } 1098 }
1099 }); 1099 });
1100 -  
1101 -  
1102 -$('#number').selectize({  
1103 - persist: false,  
1104 - maxItems: 1,  
1105 - valueField: 'vinvin',  
1106 - searchField: ['vinvin','vin_number'],  
1107 - options: [  
1108 - {vinvin:'12345', vin_number:'12345'},  
1109 - {vinvin:'34567',vin_number:'34567'},  
1110 - {vinvin:'75434',vin_number:'75434'}  
1111 - ],  
1112 - render: {  
1113 - item: function(item, escape) {  
1114 - return '<div>' +  
1115 - (item.vinvin ? '<span class="vinvin">' + escape(item.vinvin) + '</span>' : '')+  
1116 - (item.vin_number ? '<span class="vin_number">' + escape(item.vin_number) + '</span>' : '') +  
1117 - '</div>';  
1118 - },  
1119 - option: function(item, escape) {  
1120 - var label = item.vinvin || item.vin_number;  
1121 - var caption = item.vin ? item.vin_number : null;  
1122 - return '<div>' +  
1123 - '<span class="vin_value">' + escape(label) + '</span>' +  
1124 - (caption ? '<span class="caption">' + escape(caption) + '</span>' : '') +  
1125 - '</div>';  
1126 - }  
1127 - },  
1128 - createFilter: function(input) {  
1129 - var match, regex;  
1130 -  
1131 - // email@address.com  
1132 - regex = new RegExp('^' + REGEX_EMAIL + '$', 'i');  
1133 - match = input.match(regex);  
1134 - if (match) return !this.options.hasOwnProperty(match[0]);  
1135 -  
1136 - // name <email@address.com>  
1137 - regex = new RegExp('^([^<]*)\<' + REGEX_EMAIL + '\>$', 'i');  
1138 - match = input.match(regex);  
1139 - if (match) return !this.options.hasOwnProperty(match[2]);  
1140 -  
1141 - return false;  
1142 - },  
1143 - create: function(input) {  
1144 - if ((new RegExp('^' + REGEX_EMAIL + '$', 'i')).test(input)) {  
1145 - return {email: input};  
1146 - }  
1147 - var match = input.match(new RegExp('^([^<]*)\<' + REGEX_EMAIL + '\>$', 'i'));  
1148 - if (match) {  
1149 - return {  
1150 - vin : match[1],  
1151 - vin_number : $.trim(match[1])  
1152 - };  
1153 - }  
1154 - alert('Invalid email address.');  
1155 - return false;  
1156 - }  
1157 -});  
1158 -  
1159 -$('.input_search').selectize({  
1160 - persist: false,  
1161 - maxItems: 1,  
1162 - valueField: 'vinvin',  
1163 - searchField: ['vinvin','vin_number'],  
1164 - options: [  
1165 - {vinvin:'12345', vin_number:'12345'},  
1166 - {vinvin:'34567',vin_number:'34567'},  
1167 - {vinvin:'75434',vin_number:'75434'}  
1168 - ],  
1169 - render: {  
1170 - item: function(item, escape) {  
1171 - return '<div>' +  
1172 - (item.vinvin ? '<span class="vinvin">' + escape(item.vinvin) + '</span>' : '')+  
1173 - (item.vin_number ? '<span class="vin_number">' + escape(item.vin_number) + '</span>' : '') +  
1174 - '</div>';  
1175 - },  
1176 - option: function(item, escape) {  
1177 - var label = item.vinvin || item.vin_number;  
1178 - var caption = item.vin ? item.vin_number : null;  
1179 - return '<div>' +  
1180 - '<span class="vin_value">' + escape(label) + '</span>' +  
1181 - (caption ? '<span class="caption">' + escape(caption) + '</span>' : '') +  
1182 - '</div>';  
1183 - }  
1184 - },  
1185 - createFilter: function(input) {  
1186 - var match, regex;  
1187 -  
1188 - // email@address.com  
1189 - regex = new RegExp('^' + REGEX_EMAIL + '$', 'i');  
1190 - match = input.match(regex);  
1191 - if (match) return !this.options.hasOwnProperty(match[0]);  
1192 -  
1193 - // name <email@address.com>  
1194 - regex = new RegExp('^([^<]*)\<' + REGEX_EMAIL + '\>$', 'i');  
1195 - match = input.match(regex);  
1196 - if (match) return !this.options.hasOwnProperty(match[2]);  
1197 -  
1198 - return false;  
1199 - },  
1200 - create: function(input) {  
1201 - if ((new RegExp('^' + REGEX_EMAIL + '$', 'i')).test(input)) {  
1202 - return {email: input};  
1203 - }  
1204 - var match = input.match(new RegExp('^([^<]*)\<' + REGEX_EMAIL + '\>$', 'i'));  
1205 - if (match) {  
1206 - return {  
1207 - vin : match[1],  
1208 - vin_number : $.trim(match[1])  
1209 - };  
1210 - }  
1211 - alert('Invalid email address.');  
1212 - return false;  
1213 - }  
1214 -});  
1215 -  
1216 -$('.input_search1').selectize({  
1217 - persist: false,  
1218 - maxItems: 1,  
1219 - valueField: 'vinvin',  
1220 - searchField: ['vinvin','vin_number'],  
1221 - options: [  
1222 - {vinvin:'12345', vin_number:'12345'},  
1223 - {vinvin:'34567',vin_number:'34567'},  
1224 - {vinvin:'75434',vin_number:'75434'}  
1225 - ],  
1226 - render: {  
1227 - item: function(item, escape) {  
1228 - return '<div>' +  
1229 - (item.vinvin ? '<span class="vinvin">' + escape(item.vinvin) + '</span>' : '')+  
1230 - (item.vin_number ? '<span class="vin_number">' + escape(item.vin_number) + '</span>' : '') +  
1231 - '</div>';  
1232 - },  
1233 - option: function(item, escape) {  
1234 - var label = item.vinvin || item.vin_number;  
1235 - var caption = item.vin ? item.vin_number : null;  
1236 - return '<div>' +  
1237 - '<span class="vin_value">' + escape(label) + '</span>' +  
1238 - (caption ? '<span class="caption">' + escape(caption) + '</span>' : '') +  
1239 - '</div>';  
1240 - }  
1241 - },  
1242 - createFilter: function(input) {  
1243 - var match, regex;  
1244 -  
1245 - // email@address.com  
1246 - regex = new RegExp('^' + REGEX_EMAIL + '$', 'i');  
1247 - match = input.match(regex);  
1248 - if (match) return !this.options.hasOwnProperty(match[0]);  
1249 -  
1250 - // name <email@address.com>  
1251 - regex = new RegExp('^([^<]*)\<' + REGEX_EMAIL + '\>$', 'i');  
1252 - match = input.match(regex);  
1253 - if (match) return !this.options.hasOwnProperty(match[2]);  
1254 -  
1255 - return false;  
1256 - },  
1257 - create: function(input) {  
1258 - if ((new RegExp('^' + REGEX_EMAIL + '$', 'i')).test(input)) {  
1259 - return {email: input};  
1260 - }  
1261 - var match = input.match(new RegExp('^([^<]*)\<' + REGEX_EMAIL + '\>$', 'i'));  
1262 - if (match) {  
1263 - return {  
1264 - vin : match[1],  
1265 - vin_number : $.trim(match[1])  
1266 - };  
1267 - }  
1268 - alert('Invalid email address.');  
1269 - return false;  
1270 - }  
1271 -}); 1100 +//
  1101 +//
  1102 +//$('#number').selectize({
  1103 +// persist: false,
  1104 +// maxItems: 1,
  1105 +// valueField: 'vinvin',
  1106 +// searchField: ['vinvin','vin_number'],
  1107 +// options: [
  1108 +// {vinvin:'12345', vin_number:'12345'},
  1109 +// {vinvin:'34567',vin_number:'34567'},
  1110 +// {vinvin:'75434',vin_number:'75434'}
  1111 +// ],
  1112 +// render: {
  1113 +// item: function(item, escape) {
  1114 +// return '<div>' +
  1115 +// (item.vinvin ? '<span class="vinvin">' + escape(item.vinvin) + '</span>' : '')+
  1116 +// (item.vin_number ? '<span class="vin_number">' + escape(item.vin_number) + '</span>' : '') +
  1117 +// '</div>';
  1118 +// },
  1119 +// option: function(item, escape) {
  1120 +// var label = item.vinvin || item.vin_number;
  1121 +// var caption = item.vin ? item.vin_number : null;
  1122 +// return '<div>' +
  1123 +// '<span class="vin_value">' + escape(label) + '</span>' +
  1124 +// (caption ? '<span class="caption">' + escape(caption) + '</span>' : '') +
  1125 +// '</div>';
  1126 +// }
  1127 +// },
  1128 +// createFilter: function(input) {
  1129 +// var match, regex;
  1130 +//
  1131 +// // email@address.com
  1132 +// regex = new RegExp('^' + REGEX_EMAIL + '$', 'i');
  1133 +// match = input.match(regex);
  1134 +// if (match) return !this.options.hasOwnProperty(match[0]);
  1135 +//
  1136 +// // name <email@address.com>
  1137 +// regex = new RegExp('^([^<]*)\<' + REGEX_EMAIL + '\>$', 'i');
  1138 +// match = input.match(regex);
  1139 +// if (match) return !this.options.hasOwnProperty(match[2]);
  1140 +//
  1141 +// return false;
  1142 +// },
  1143 +// create: function(input) {
  1144 +// if ((new RegExp('^' + REGEX_EMAIL + '$', 'i')).test(input)) {
  1145 +// return {email: input};
  1146 +// }
  1147 +// var match = input.match(new RegExp('^([^<]*)\<' + REGEX_EMAIL + '\>$', 'i'));
  1148 +// if (match) {
  1149 +// return {
  1150 +// vin : match[1],
  1151 +// vin_number : $.trim(match[1])
  1152 +// };
  1153 +// }
  1154 +// alert('Invalid email address.');
  1155 +// return false;
  1156 +// }
  1157 +//});
  1158 +
  1159 +//$('.input_search').selectize({
  1160 +// persist: false,
  1161 +// maxItems: 1,
  1162 +// valueField: 'vinvin',
  1163 +// searchField: ['vinvin','vin_number'],
  1164 +// options: [
  1165 +// {vinvin:'12345', vin_number:'12345'},
  1166 +// {vinvin:'34567',vin_number:'34567'},
  1167 +// {vinvin:'75434',vin_number:'75434'}
  1168 +// ],
  1169 +// render: {
  1170 +// item: function(item, escape) {
  1171 +// return '<div>' +
  1172 +// (item.vinvin ? '<span class="vinvin">' + escape(item.vinvin) + '</span>' : '')+
  1173 +// (item.vin_number ? '<span class="vin_number">' + escape(item.vin_number) + '</span>' : '') +
  1174 +// '</div>';
  1175 +// },
  1176 +// option: function(item, escape) {
  1177 +// var label = item.vinvin || item.vin_number;
  1178 +// var caption = item.vin ? item.vin_number : null;
  1179 +// return '<div>' +
  1180 +// '<span class="vin_value">' + escape(label) + '</span>' +
  1181 +// (caption ? '<span class="caption">' + escape(caption) + '</span>' : '') +
  1182 +// '</div>';
  1183 +// }
  1184 +// },
  1185 +// createFilter: function(input) {
  1186 +// var match, regex;
  1187 +//
  1188 +// // email@address.com
  1189 +// regex = new RegExp('^' + REGEX_EMAIL + '$', 'i');
  1190 +// match = input.match(regex);
  1191 +// if (match) return !this.options.hasOwnProperty(match[0]);
  1192 +//
  1193 +// // name <email@address.com>
  1194 +// regex = new RegExp('^([^<]*)\<' + REGEX_EMAIL + '\>$', 'i');
  1195 +// match = input.match(regex);
  1196 +// if (match) return !this.options.hasOwnProperty(match[2]);
  1197 +//
  1198 +// return false;
  1199 +// },
  1200 +// create: function(input) {
  1201 +// if ((new RegExp('^' + REGEX_EMAIL + '$', 'i')).test(input)) {
  1202 +// return {email: input};
  1203 +// }
  1204 +// var match = input.match(new RegExp('^([^<]*)\<' + REGEX_EMAIL + '\>$', 'i'));
  1205 +// if (match) {
  1206 +// return {
  1207 +// vin : match[1],
  1208 +// vin_number : $.trim(match[1])
  1209 +// };
  1210 +// }
  1211 +// alert('Invalid email address.');
  1212 +// return false;
  1213 +// }
  1214 +//});
  1215 +//
  1216 +//$('.input_search1').selectize({
  1217 +// persist: false,
  1218 +// maxItems: 1,
  1219 +// valueField: 'vinvin',
  1220 +// searchField: ['vinvin','vin_number'],
  1221 +// options: [
  1222 +// {vinvin:'12345', vin_number:'12345'},
  1223 +// {vinvin:'34567',vin_number:'34567'},
  1224 +// {vinvin:'75434',vin_number:'75434'}
  1225 +// ],
  1226 +// render: {
  1227 +// item: function(item, escape) {
  1228 +// return '<div>' +
  1229 +// (item.vinvin ? '<span class="vinvin">' + escape(item.vinvin) + '</span>' : '')+
  1230 +// (item.vin_number ? '<span class="vin_number">' + escape(item.vin_number) + '</span>' : '') +
  1231 +// '</div>';
  1232 +// },
  1233 +// option: function(item, escape) {
  1234 +// var label = item.vinvin || item.vin_number;
  1235 +// var caption = item.vin ? item.vin_number : null;
  1236 +// return '<div>' +
  1237 +// '<span class="vin_value">' + escape(label) + '</span>' +
  1238 +// (caption ? '<span class="caption">' + escape(caption) + '</span>' : '') +
  1239 +// '</div>';
  1240 +// }
  1241 +// },
  1242 +// createFilter: function(input) {
  1243 +// var match, regex;
  1244 +//
  1245 +// // email@address.com
  1246 +// regex = new RegExp('^' + REGEX_EMAIL + '$', 'i');
  1247 +// match = input.match(regex);
  1248 +// if (match) return !this.options.hasOwnProperty(match[0]);
  1249 +//
  1250 +// // name <email@address.com>
  1251 +// regex = new RegExp('^([^<]*)\<' + REGEX_EMAIL + '\>$', 'i');
  1252 +// match = input.match(regex);
  1253 +// if (match) return !this.options.hasOwnProperty(match[2]);
  1254 +//
  1255 +// return false;
  1256 +// },
  1257 +// create: function(input) {
  1258 +// if ((new RegExp('^' + REGEX_EMAIL + '$', 'i')).test(input)) {
  1259 +// return {email: input};
  1260 +// }
  1261 +// var match = input.match(new RegExp('^([^<]*)\<' + REGEX_EMAIL + '\>$', 'i'));
  1262 +// if (match) {
  1263 +// return {
  1264 +// vin : match[1],
  1265 +// vin_number : $.trim(match[1])
  1266 +// };
  1267 +// }
  1268 +// alert('Invalid email address.');
  1269 +// return false;
  1270 +// }
  1271 +//});
1272 1272
1273 $('#number1').selectize({ 1273 $('#number1').selectize({
1274 persist: false, 1274 persist: false,