Commit 17604d85e65739676ac89693c6a53c36f3c1ac67

Authored by alex
2 parents 5953b4fa ca4d9c90

Merge branch 'master' of gitlab.artweb.com.ua:steska/clinica into clinica_khonko

# Conflicts:
#	frontend/controllers/SiteController.php
#	frontend/views/layouts/main.php
#	frontend/views/service/view.php
#	frontend/views/site/index.php
common/config/main.php
@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
28 ], 28 ],
29 'components' => [ 29 'components' => [
30 'cache' => [ 30 'cache' => [
31 - 'class' => 'yii\caching\DummyCache', 31 + 'class' => 'yii\caching\FileCache',
32 ], 32 ],
33 'i18n' => [ 33 'i18n' => [
34 'translations' => [ 34 'translations' => [
frontend/controllers/ServiceController.php
@@ -20,14 +20,14 @@ @@ -20,14 +20,14 @@
20 public function actionView($id){ 20 public function actionView($id){
21 $model = $this->findModel($id); 21 $model = $this->findModel($id);
22 if ($model->parent_id == null){ 22 if ($model->parent_id == null){
23 - $others = Service::find()->where(['parent_id' => $model->id])->with('services.language.alias')->all(); 23 + $others = Service::find()->where(['parent_id' => $model->id])->with(['services.language.alias', 'language.alias'])->all();
24 if (empty($others)){ 24 if (empty($others)){
25 - $others = Service::find()->where(['parent_id' => null, 'status' => true])->all(); 25 + $others = Service::find()->where(['parent_id' => null, 'status' => true])->with(['services.language.alias', 'language.alias'])->all();
26 } 26 }
27 }elseif ($model->level == 1){ 27 }elseif ($model->level == 1){
28 - $others = Service::find()->where(['parent_id' => $model->parent_id])->with('services.language.alias')->all(); 28 + $others = Service::find()->where(['parent_id' => $model->parent_id])->with(['services.language.alias', 'language.alias'])->all();
29 }else{ 29 }else{
30 - $others = Service::find()->where(['parent_id' => (new Query())->select('parent_id')->from('service')->where(['id' => $model->parent_id])])->with('services.language.alias')->all(); 30 + $others = Service::find()->where(['parent_id' => (new Query())->select('parent_id')->from('service')->where(['id' => $model->parent_id])])->with(['services.language.alias', 'language.alias'])->all();
31 } 31 }
32 32
33 33
@@ -82,13 +82,13 @@ @@ -82,13 +82,13 @@
82 $model = Service::find() 82 $model = Service::find()
83 ->where(['id' => $id, 'status' => true]) 83 ->where(['id' => $id, 'status' => true])
84 ->with(['language.alias', 'prices' => function (ActiveQuery $query){ 84 ->with(['language.alias', 'prices' => function (ActiveQuery $query){
85 - $query->where(['status' => true])->orderBy('sort'); 85 + $query->where(['status' => true])->with('language')->orderBy('sort');
86 }, 'comments' => function (ActiveQuery $query){ 86 }, 'comments' => function (ActiveQuery $query){
87 $query->where(['status' => true]); 87 $query->where(['status' => true]);
88 }, 'questions' => function (ActiveQuery $query){ 88 }, 'questions' => function (ActiveQuery $query){
89 $query->where(['status' => true])->with('doctor'); 89 $query->where(['status' => true])->with('doctor');
90 },'packages' => function (ActiveQuery $query){ 90 },'packages' => function (ActiveQuery $query){
91 - $query->with(['image', 'language'])->where(['status' => true]); 91 + $query->with(['image', 'language.alias'])->where(['status' => true]);
92 }])->one(); 92 }])->one();
93 if (empty($model)){ 93 if (empty($model)){
94 throw new NotFoundHttpException('Model not found'); 94 throw new NotFoundHttpException('Model not found');
frontend/controllers/SiteController.php
@@ -62,34 +62,70 @@ @@ -62,34 +62,70 @@
62 */ 62 */
63 public function actionIndex() 63 public function actionIndex()
64 { 64 {
65 - $slides = Slide::find()->with('language')->where(['status' => true])->orderBy('sort')->with('language.image')->all();  
66 - $services = Service::find()->where(['is not' ,'image_id', NULL])->andWhere(  
67 - [  
68 - 'status' => true,  
69 - 'level' => 0,  
70 - ]  
71 - )  
72 - ->with(  
73 - [  
74 - 'image',  
75 - 'language.alias',  
76 - 'services' => function (ActiveQuery $query) {  
77 - $query->where(['status' => true])->with(['language.alias']);  
78 - },  
79 - ]  
80 - )->orderBy([ new Expression('sort ASC NULLS LAST') ])  
81 - ->all();  
82 - $comments = Comment::find()->where(['status' => true, 'on_main' => true])->limit(6)->all(); 65 + $slides = Slide::find()
  66 + ->with('language')
  67 + ->where([ 'status' => true ])
  68 + ->orderBy('sort')
  69 + ->with('language.image')
  70 + ->all();
  71 + $services = Service::find()
  72 + ->where(
  73 + [
  74 + 'is not',
  75 + 'image_id',
  76 + null,
  77 + ]
  78 + )
  79 + ->andWhere(
  80 + [
  81 + 'status' => true,
  82 + 'level' => 0,
  83 + ]
  84 + )
  85 + ->with(
  86 + [
  87 + 'image',
  88 + 'language.alias',
  89 + 'services' => function (ActiveQuery $query) {
  90 + $query->where([ 'status' => true ])
  91 + ->with([ 'language.alias' ]);
  92 + },
  93 + ]
  94 + )
  95 + ->orderBy([ new Expression('sort ASC NULLS LAST') ])
  96 + ->all();
  97 + $comments = Comment::find()
  98 + ->where(
  99 + [
  100 + 'status' => true,
  101 + 'on_main' => true,
  102 + ]
  103 + )
  104 + ->limit(6)
  105 + ->all();
83 106
84 - $package = Package::find()->with(['language.alias'])->where(['status' => true])->orderBy('sort')->limit(3)->all(); 107 + $package = Package::find()
  108 + ->with(
  109 + [
  110 + 'language.alias',
  111 + 'image',
  112 + ]
  113 + )
  114 + ->where([ 'status' => true ])
  115 + ->orderBy('sort')
  116 + ->limit(3)
  117 + ->all();
85 $settings = Settings::getInstance(); 118 $settings = Settings::getInstance();
86 - return $this->render('index', [  
87 - 'slides' => $slides,  
88 - 'services' => $services,  
89 - 'comments' => $comments,  
90 - 'settings' => $settings,  
91 - 'package' => $package  
92 - ]); 119 + return $this->render(
  120 + 'index',
  121 + [
  122 + 'slides' => $slides,
  123 + 'services' => $services,
  124 + 'comments' => $comments,
  125 + 'settings' => $settings,
  126 + 'package' => $package,
  127 + ]
  128 + );
93 } 129 }
94 130
95 /** 131 /**
@@ -104,8 +140,8 @@ @@ -104,8 +140,8 @@
104 return $this->render( 140 return $this->render(
105 'contact', 141 'contact',
106 [ 142 [
107 - 'contact' => $contact,  
108 - 'settings' => $settings 143 + 'contact' => $contact,
  144 + 'settings' => $settings,
109 ] 145 ]
110 ); 146 );
111 } 147 }
@@ -186,115 +222,159 @@ @@ -186,115 +222,159 @@
186 } 222 }
187 } 223 }
188 } 224 }
189 - public function actionPrices(){  
190 - $services = Service::find()->innerJoinWith(['prices' => function (ActiveQuery $query){  
191 - $query->where(['price.status' => true]);  
192 - }])->all(); 225 + public function actionPrices()
  226 + {
  227 + $services = Service::find()
  228 + ->innerJoinWith(
  229 + [
  230 + 'prices' => function (ActiveQuery $query) {
  231 + $query->where([ 'price.status' => true ])
  232 + ->with('language');
  233 + },
  234 + ]
  235 + )
  236 + ->with('language.alias')
  237 + ->all();
193 238
194 - return $this->render('prices', [  
195 - 'services' => $services,  
196 - ]); 239 + return $this->render(
  240 + 'prices',
  241 + [
  242 + 'services' => $services,
  243 + ]
  244 + );
197 } 245 }
198 246
199 -  
200 - public function actionPage1(){ 247 + public function actionPage1()
  248 + {
201 return $this->render('page1'); 249 return $this->render('page1');
202 } 250 }
203 -  
204 - public function actionPage2(){ 251 +
  252 + public function actionPage2()
  253 + {
205 return $this->render('page2'); 254 return $this->render('page2');
206 } 255 }
207 256
208 - public function actionPage22(){ 257 + public function actionPage22()
  258 + {
209 return $this->render('page2-2'); 259 return $this->render('page2-2');
210 } 260 }
211 261
212 - public function actionPage23(){ 262 + public function actionPage23()
  263 + {
213 return $this->render('page2-3'); 264 return $this->render('page2-3');
214 } 265 }
215 -  
216 - public function actionPage3(){ 266 +
  267 + public function actionPage3()
  268 + {
217 return $this->render('page3'); 269 return $this->render('page3');
218 } 270 }
219 -  
220 - public function actionPage4(){ 271 +
  272 + public function actionPage4()
  273 + {
221 return $this->render('page4'); 274 return $this->render('page4');
222 } 275 }
223 -  
224 - public function actionPage5(){ 276 +
  277 + public function actionPage5()
  278 + {
225 return $this->render('page5'); 279 return $this->render('page5');
226 } 280 }
227 -  
228 - public function actionPage6(){ 281 +
  282 + public function actionPage6()
  283 + {
229 return $this->render('page6'); 284 return $this->render('page6');
230 } 285 }
231 286
232 287
233 288
234 # ะ’ะพะฟั€ะพั/ะพั‚ะฒะตั‚ 289 # ะ’ะพะฟั€ะพั/ะพั‚ะฒะตั‚
235 - public function actionQuestions($service_id = null){ 290 + public function actionQuestions($service_id = null)
  291 + {
236 Language::getCurrent(); 292 Language::getCurrent();
237 293
238 - if (\Yii::$app->request->isAjax){ 294 + if (\Yii::$app->request->isAjax) {
239 Yii::$app->response->format = Response::FORMAT_JSON; 295 Yii::$app->response->format = Response::FORMAT_JSON;
240 $model = new Question(); 296 $model = new Question();
241 $model->scenario = Question::SCENARIO_QUESTION; 297 $model->scenario = Question::SCENARIO_QUESTION;
242 - if ($model->load(\Yii::$app->request->post()) and $model->save()){ 298 + if ($model->load(\Yii::$app->request->post()) and $model->save()) {
243 return [ 299 return [
244 - 'status' => true,  
245 - 'message' => 'ะกะฟะฐัะธะฑะพ ะทะฐ ะ’ะฐัˆ ะฒะพะฟั€ะพั' 300 + 'status' => true,
  301 + 'message' => 'ะกะฟะฐัะธะฑะพ ะทะฐ ะ’ะฐัˆ ะฒะพะฟั€ะพั',
246 ]; 302 ];
247 - }else{ 303 + } else {
248 return [ 304 return [
249 - 'status' => false,  
250 - 'message' => 'ะžัˆะธะฑะบะฐ' 305 + 'status' => false,
  306 + 'message' => 'ะžัˆะธะฑะบะฐ',
251 ]; 307 ];
252 } 308 }
253 } 309 }
254 - $dataProvider = new ActiveDataProvider([  
255 - 'query' => Question::find()->where(['status' => true])->andFilterWhere(['service_id' => $service_id])->with(['doctor.language']),  
256 - 'pagination' => [  
257 - 'pageSize' => 10,  
258 - ],  
259 - ]);  
260 - $services = Service::find()->where(['status' => true])->andWhere(['parent_id' => null])->all(); 310 + $dataProvider = new ActiveDataProvider(
  311 + [
  312 + 'query' => Question::find()
  313 + ->where([ 'status' => true ])
  314 + ->andFilterWhere([ 'service_id' => $service_id ])
  315 + ->with([ 'doctor.language' ]),
  316 + 'pagination' => [
  317 + 'pageSize' => 10,
  318 + ],
  319 + ]
  320 + );
  321 + $services = Service::find()
  322 + ->where([ 'status' => true ])
  323 + ->andWhere([ 'parent_id' => null ])
  324 + ->with('language')
  325 + ->all();
261 $route = []; 326 $route = [];
262 - foreach ($services as $service){  
263 - $route[] = Json::encode(['site/questions', 'service_id' => $service->id]); 327 + foreach ($services as $service) {
  328 + $route[] = Json::encode(
  329 + [
  330 + 'site/questions',
  331 + 'service_id' => $service->id,
  332 + ]
  333 + );
264 } 334 }
265 $route [] = '{"0":"site/questions"}'; 335 $route [] = '{"0":"site/questions"}';
266 - $alias = Alias::find()->where(['route' => $route])->andWhere(['language_id' => Language::getCurrent()->id])->indexBy('route')->asArray()->all();  
267 - return $this->render('questions', [  
268 - 'dataProvider' => $dataProvider,  
269 - 'services' => $services,  
270 - 'service_id' => $service_id,  
271 - 'alias' => $alias  
272 - ]); 336 + $alias = Alias::find()
  337 + ->where([ 'route' => $route ])
  338 + ->andWhere([ 'language_id' => Language::getCurrent()->id ])
  339 + ->indexBy('route')
  340 + ->asArray()
  341 + ->all();
  342 + return $this->render(
  343 + 'questions',
  344 + [
  345 + 'dataProvider' => $dataProvider,
  346 + 'services' => $services,
  347 + 'service_id' => $service_id,
  348 + 'alias' => $alias,
  349 + ]
  350 + );
273 } 351 }
274 -  
275 - public function actionComments($service_id = null){  
276 352
277 - if (\Yii::$app->request->isAjax){ 353 + public function actionComments($service_id = null)
  354 + {
  355 +
  356 + if (\Yii::$app->request->isAjax) {
278 Yii::$app->response->format = Response::FORMAT_JSON; 357 Yii::$app->response->format = Response::FORMAT_JSON;
279 $model = new Comment(); 358 $model = new Comment();
280 #if ($model->load(\Yii::$app->request->post()) and $model->save()){ 359 #if ($model->load(\Yii::$app->request->post()) and $model->save()){
281 - if ($model->load(\Yii::$app->request->post())){  
282 - if(!$model->entity_id)$model->entity_id=0;  
283 - $model->entity=Service::className(); 360 + if ($model->load(\Yii::$app->request->post())) {
  361 + if (!$model->entity_id) {
  362 + $model->entity_id = 0;
  363 + }
  364 + $model->entity = Service::className();
284 $model->save(); 365 $model->save();
285 return [ 366 return [
286 - 'status' => true,  
287 - 'message' => 'ะกะฟะฐัะธะฑะพ ะทะฐ ะ’ะฐัˆ ะพั‚ะทั‹ะฒ. ะŸะพัะปะต ะฟั€ะพะฒะตั€ะบะธ ะผะพะดะตั€ะฐั‚ะพั€ะพะผ ะพะฝ ะฟะพัะฒะธั‚ัŒัั ะฝะฐ ัะฐะนั‚ะต' 367 + 'status' => true,
  368 + 'message' => 'ะกะฟะฐัะธะฑะพ ะทะฐ ะ’ะฐัˆ ะพั‚ะทั‹ะฒ. ะŸะพัะปะต ะฟั€ะพะฒะตั€ะบะธ ะผะพะดะตั€ะฐั‚ะพั€ะพะผ ะพะฝ ะฟะพัะฒะธั‚ัŒัั ะฝะฐ ัะฐะนั‚ะต',
288 ]; 369 ];
289 - }else{ 370 + } else {
290 return [ 371 return [
291 - 'status' => false,  
292 - 'message' => 'ะžัˆะธะฑะบะฐ' 372 + 'status' => false,
  373 + 'message' => 'ะžัˆะธะฑะบะฐ',
293 ]; 374 ];
294 } 375 }
295 } 376 }
296 377
297 -  
298 # ะฟะพะดะบะพั€ะตะบั‚ะธั€ะพะฒะฐะป ะปะพะณะธะบัƒ ะดะปั ัะพั…ั€ะฐะฝั€ะตะฝะธั ะฒ ะ‘ะ”/ะฒั‹ะดะฐั‡ะธ ะฒะพะฟั€ะพัะพะฒ ั ะบะฐั‚ะตะณะพั€ะธะธ "ะžะฑั‰ะธะต ะฒะพะฟั€ะพัั‹" 378 # ะฟะพะดะบะพั€ะตะบั‚ะธั€ะพะฒะฐะป ะปะพะณะธะบัƒ ะดะปั ัะพั…ั€ะฐะฝั€ะตะฝะธั ะฒ ะ‘ะ”/ะฒั‹ะดะฐั‡ะธ ะฒะพะฟั€ะพัะพะฒ ั ะบะฐั‚ะตะณะพั€ะธะธ "ะžะฑั‰ะธะต ะฒะพะฟั€ะพัั‹"
299 # ะทะฐะบั€ะตะฟะธะป ะทะฐ ะฝะธะผะธ entity_id=0 379 # ะทะฐะบั€ะตะฟะธะป ะทะฐ ะฝะธะผะธ entity_id=0
300 if($service_id==null)$service_id=0; 380 if($service_id==null)$service_id=0;
@@ -316,5 +396,34 @@ @@ -316,5 +396,34 @@
316 'services' => $services, 396 'services' => $services,
317 'service_id' => $service_id 397 'service_id' => $service_id
318 ]); 398 ]);
  399 + if ($service_id == null) {
  400 + $service_id = 0;
  401 + }
  402 + $dataProvider = new ActiveDataProvider(
  403 + [
  404 + 'query' => Comment::find()
  405 + ->where([ 'status' => true ])
  406 + ->andWhere([ 'entity' => Service::className() ])
  407 + ->andFilterWhere([ 'entity_id' => $service_id ]),
  408 + //'SELECT * FROM \"comment\" WHERE (\"status\"=TRUE) AND (\"entity\"=\'common\\models\\Service\')'
  409 + 'pagination' => [
  410 + 'pageSize' => 10,
  411 + ],
  412 + ]
  413 + );
  414 + $services = Service::find()
  415 + ->where([ 'status' => true ])
  416 + ->andWhere([ 'parent_id' => null ])
  417 + ->with('language')
  418 + ->all();
  419 +
  420 + return $this->render(
  421 + 'comments',
  422 + [
  423 + 'dataProvider' => $dataProvider,
  424 + 'services' => $services,
  425 + 'service_id' => $service_id,
  426 + ]
  427 + );
319 } 428 }
320 } 429 }
frontend/views/layouts/main.php
@@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
34 34
35 35
36 36
37 - 37 +
38 AppAsset::register($this); 38 AppAsset::register($this);
39 SliderAsset::register($this); 39 SliderAsset::register($this);
40 $user = \Yii::$app->user->identity; 40 $user = \Yii::$app->user->identity;
@@ -55,7 +55,14 @@ @@ -55,7 +55,14 @@
55 [ 55 [
56 'language.alias', 56 'language.alias',
57 'services' => function (ActiveQuery $query) { 57 'services' => function (ActiveQuery $query) {
58 - $query->where(['status' => true])->with(['language.alias']); 58 + $query->where(['status' => true])->with(
  59 + [
  60 + 'language.alias',
  61 + 'services' => function (ActiveQuery $query) {
  62 + $query->where(['status' => true])->with(['language.alias']);
  63 + },
  64 + ]
  65 + );
59 }, 66 },
60 ] 67 ]
61 )->orderBy('sort') 68 )->orderBy('sort')
@@ -134,24 +141,22 @@ $this->registerMetaTag( @@ -134,24 +141,22 @@ $this->registerMetaTag(
134 <!DOCTYPE html > 141 <!DOCTYPE html >
135 <html xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html" lang="<?= \Yii::$app->language ?>"> 142 <html xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html" lang="<?= \Yii::$app->language ?>">
136 <head> 143 <head>
137 -  
138 - <meta charset="utf-8">  
139 - <!-- Global site tag (gtag.js) - Google Analytics -->  
140 - <script async src="https://www.googletagmanager.com/gtag/js?id=UA-120861020-1"></script>  
141 - <script>  
142 - window.dataLayer = window.dataLayer || [];  
143 - function gtag(){dataLayer.push(arguments);}  
144 - gtag('js', new Date());  
145 -  
146 - gtag('config', 'UA-120861020-1');  
147 - </script>  
148 - <!-- Google Tag Manager -->  
149 - <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':  
150 - new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],  
151 - j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=  
152 - 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);  
153 - })(window,document,'script','dataLayer','GTM-N6R7982');</script>  
154 - <!-- End Google Tag Manager --> 144 + <!-- Global site tag (gtag.js) - Google Analytics -->
  145 + <script async src="https://www.googletagmanager.com/gtag/js?id=UA-120861020-1"></script>
  146 + <script>
  147 + window.dataLayer = window.dataLayer || [];
  148 + function gtag(){dataLayer.push(arguments);}
  149 + gtag('js', new Date());
  150 +
  151 + gtag('config', 'UA-120861020-1');
  152 + </script>
  153 + <!-- Google Tag Manager -->
  154 + <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
  155 + new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
  156 + j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
  157 + 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
  158 + })(window,document,'script','dataLayer','GTM-N6R7982');</script>
  159 + <!-- End Google Tag Manager -->
155 <meta charset="<?= \Yii::$app->charset ?>"> 160 <meta charset="<?= \Yii::$app->charset ?>">
156 <meta name="viewport" content="width=device-width"> 161 <meta name="viewport" content="width=device-width">
157 <link type="image/x-icon" href="favicon.ico" rel="icon"> 162 <link type="image/x-icon" href="favicon.ico" rel="icon">
@@ -161,10 +166,10 @@ $this-&gt;registerMetaTag( @@ -161,10 +166,10 @@ $this-&gt;registerMetaTag(
161 <?php $this->head() ?> 166 <?php $this->head() ?>
162 </head> 167 </head>
163 <body id="body"> 168 <body id="body">
164 - <!-- Google Tag Manager (noscript) -->  
165 - <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-N6R7982"  
166 - height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>  
167 - <!-- End Google Tag Manager (noscript) --> 169 + <!-- Google Tag Manager (noscript) -->
  170 + <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-N6R7982"
  171 + height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
  172 + <!-- End Google Tag Manager (noscript) -->
168 <?php $this->beginBody() ?> 173 <?php $this->beginBody() ?>
169 <div class="transition-loader"> 174 <div class="transition-loader">
170 <div class="transition-loader-inner"> 175 <div class="transition-loader-inner">
@@ -201,8 +206,6 @@ $this-&gt;registerMetaTag( @@ -201,8 +206,6 @@ $this-&gt;registerMetaTag(
201 ->renderImage( 206 ->renderImage(
202 [ 207 [
203 'alt' => $settings->name, 208 'alt' => $settings->name,
204 - #'alt'=>\Yii::t('app','ABC short'),  
205 - 'title'=>\Yii::t('app','ABC short'),  
206 ] 209 ]
207 ); 210 );
208 } 211 }
@@ -654,7 +657,7 @@ $this-&gt;registerMetaTag( @@ -654,7 +657,7 @@ $this-&gt;registerMetaTag(
654 $layoutMicrodata['contactPoint']['telephone'.$key]=$phone; 657 $layoutMicrodata['contactPoint']['telephone'.$key]=$phone;
655 }} 658 }}
656 659
657 - 660 +
658 $settings->email; 661 $settings->email;
659 $microdata=new MicrodataFabric(); 662 $microdata=new MicrodataFabric();
660 $pageMicrodata=$microdata::createJsonFromOrganization($layoutMicrodata)->toJson(); 663 $pageMicrodata=$microdata::createJsonFromOrganization($layoutMicrodata)->toJson();
frontend/views/package/view.php
@@ -4,10 +4,22 @@ @@ -4,10 +4,22 @@
4 * @var \yii\web\View $this; 4 * @var \yii\web\View $this;
5 */ 5 */
6 use common\models\Package; 6 use common\models\Package;
  7 + use yii\web\View;
  8 +
7 $seo = \Yii::$app->get('seo'); 9 $seo = \Yii::$app->get('seo');
8 $this->params[ 'entity'] = Package::className(); 10 $this->params[ 'entity'] = Package::className();
9 $this->params['entity_id'] = $package->id; 11 $this->params['entity_id'] = $package->id;
10 $this->params['breadcrumbs'][] = (!empty($seo->h1)) ? $seo->h1 :$package->title; 12 $this->params['breadcrumbs'][] = (!empty($seo->h1)) ? $seo->h1 :$package->title;
  13 +
  14 + $js = <<<JS
  15 + $(document).on('beforeSubmit', '#visit-form', function() {
  16 + window.dataLayer = window.dataLayer || [];
  17 + window.dataLayer.push({'event': 'formsend_package'});
  18 + console.log('push');
  19 + return true;
  20 + });
  21 +JS;
  22 + $this->registerJs($js, View::POS_LOAD);
11 ?> 23 ?>
12 24
13 25
frontend/views/service/view.php
@@ -14,6 +14,8 @@ @@ -14,6 +14,8 @@
14 use artbox\core\models\Language; 14 use artbox\core\models\Language;
15 15
16 16
  17 + use yii\web\View;
  18 +
17 $seo = \Yii::$app->get('seo'); 19 $seo = \Yii::$app->get('seo');
18 $this->params['entity'] = Service::className(); 20 $this->params['entity'] = Service::className();
19 $this->params['entity_id'] = $model->id; 21 $this->params['entity_id'] = $model->id;
@@ -50,6 +52,54 @@ @@ -50,6 +52,54 @@
50 52
51 53
52 $aliases = Alias::find()->where(['route' => '{"0":"site/questions"}'])->indexBy('route')->andWhere(['language_id' => Language::getCurrent()->id])->asArray()->all(); 54 $aliases = Alias::find()->where(['route' => '{"0":"site/questions"}'])->indexBy('route')->andWhere(['language_id' => Language::getCurrent()->id])->asArray()->all();
  55 +
  56 +
  57 + $js = <<<JS
  58 + $(document).on('beforeSubmit', '#comment-form', function() {
  59 + window.dataLayer = window.dataLayer || [];
  60 + dataLayer.push({'event': 'formsend_review'});
  61 + console.log('push');
  62 + return true;
  63 + });
  64 +
  65 +$(document).on('beforeSubmit', '#question-form', function() {
  66 + window.dataLayer = window.dataLayer || [];
  67 + dataLayer.push({'event': 'formsend_question'});
  68 + console.log('push');
  69 + return true;
  70 + });
  71 +
  72 +
  73 + $(document).on('beforeSubmit', '#visit-form', function() {
  74 + window.dataLayer = window.dataLayer || [];
  75 + var service_id = {$model->id};
  76 + var parent_id = {$model->parent_id};
  77 + if (service_id == 4 || parent_id == 4){
  78 + window.dataLayer.push({'event': 'formsend_dermatologiya'});
  79 + }
  80 + if (service_id == 16 || parent_id == 16){
  81 + dataLayer.push({'event': 'formsend_vedenie-beremennosti'});
  82 + }
  83 + if (service_id == 22 || parent_id == 22){
  84 + dataLayer.push({'event': 'formsend_lechenie-besplodiya'});
  85 + }
  86 + if (service_id == 21 || parent_id == 21){
  87 + dataLayer.push({'event': 'formsend_labioplastika'});
  88 + }
  89 + if (service_id == 19 || parent_id == 19){
  90 + dataLayer.push({'event': 'formsend_zabolevaniya-sheyki-matki'});
  91 + }
  92 + if (service_id == 20 || parent_id == 20){
  93 + dataLayer.push({'event': 'formsend_polovye-infekcii'});
  94 + }
  95 + console.log('push');
  96 + return true;
  97 + });
  98 +JS;
  99 +
  100 + $this->registerJs($js, View::POS_LOAD);
  101 +
  102 +
53 $this->params[ 'breadcrumbs' ][] = (!empty($seo->h1)) ? $seo->h1 :$model->title; 103 $this->params[ 'breadcrumbs' ][] = (!empty($seo->h1)) ? $seo->h1 :$model->title;
54 ?> 104 ?>
55 <?=$microdata;?> 105 <?=$microdata;?>
frontend/views/site/index.php
@@ -163,9 +163,7 @@ JS; @@ -163,9 +163,7 @@ JS;
163 <?php foreach ($package as $item){?> 163 <?php foreach ($package as $item){?>
164 <div class="col-xs-12 col-sm-4 package-offers-wr"> 164 <div class="col-xs-12 col-sm-4 package-offers-wr">
165 <a href="<?=Url::to(['alias' => $item->alias])?>"> 165 <a href="<?=Url::to(['alias' => $item->alias])?>">
166 - <div class="img">  
167 - <?php #die(var_dump($item->language->attributes)); ?>  
168 - <?=ImageHelper::set(($item->image) ? $item->image->getPath() : null) 166 + <div class="img"><?=ImageHelper::set(($item->image) ? $item->image->getPath() : null)
169 ->cropResize(388, 240) 167 ->cropResize(388, 240)
170 ->quality(84) 168 ->quality(84)
171 ->renderImage()?></div> 169 ->renderImage()?></div>
frontend/web/js/script.js
@@ -381,7 +381,7 @@ $(document).ready(function() { @@ -381,7 +381,7 @@ $(document).ready(function() {
381 $('.categories-home .img').click(function () { 381 $('.categories-home .img').click(function () {
382 var link = $(this).parent().find('.categories-home-links-title a').attr('href'); 382 var link = $(this).parent().find('.categories-home-links-title a').attr('href');
383 document.location.href = link; 383 document.location.href = link;
384 - }) 384 + });
385 var scrollPos = $(window).scrollTop(); 385 var scrollPos = $(window).scrollTop();
386 var windHeight = $(window).height(); 386 var windHeight = $(window).height();
387 var bl = $('.section-box-2'); 387 var bl = $('.section-box-2');
@@ -460,6 +460,14 @@ $(document).ready(function() { @@ -460,6 +460,14 @@ $(document).ready(function() {
460 var form = $(this); 460 var form = $(this);
461 var id = form.attr('id'); 461 var id = form.attr('id');
462 var url = form.attr('action'); 462 var url = form.attr('action');
  463 + window.dataLayer = window.dataLayer || [];
  464 + if (id == 'total_question_form'){
  465 + dataLayer.push({'event': 'formsend_question'});
  466 + console.log('formsend_question');
  467 + }else{
  468 + dataLayer.push({'event': 'formsend_review'});
  469 + console.log('formsend_review');
  470 + }
463 $.post( 471 $.post(
464 $(this).attr("action"), $(this).serialize(), function(data) { 472 $(this).attr("action"), $(this).serialize(), function(data) {
465 document.getElementById(id).reset(); 473 document.getElementById(id).reset();