e47109b0
Anastasia
- support
|
1
2
3
4
5
6
7
8
9
10
11
|
<?php
/**
* Created by PhpStorm.
* User: stes
* Date: 14.06.18
* Time: 13:40
*/
namespace frontend\controllers;
use common\models\Book;
|
32162c17
Anastasia
- add buy a book
|
12
|
use common\models\Buy;
|
e47109b0
Anastasia
- support
|
13
|
use common\models\Support;
|
9afd152f
Anastasia
- support from main
|
14
15
16
|
use frontend\helpers\Url;
use frontend\models\SearchModel;
use yii\data\ActiveDataProvider;
|
e47109b0
Anastasia
- support
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
use yii\web\Controller;
class SupportController extends Controller
{
public function actionIndex($book_id = null){
$model = new Support([
'book_id' => $book_id,
'status' => 0
]);
$book = Book::find()->with('author')->where(['id' => $book_id])->one();
if ($model->load(\Yii::$app->request->post()) and $model->save()){
\Yii::$app->session->setFlash('success', 'Дякуємо за ваш запит. Найближчим часом, наш менеджер зв\'яжеться з Вами для уточнення деталей');
return $this->redirect(['site/index']);
}
return $this->render('index', [
'model' => $model,
'book' => $book
]);
}
|
9afd152f
Anastasia
- support from main
|
36
|
public function actionSearch(){
|
6a07bb2b
Виталий
support form
|
37
38
|
return $this->render('search');
}
|
9afd152f
Anastasia
- support from main
|
39
40
41
42
43
44
45
|
public function actionSearchResult()
{
$model = new SearchModel();
if ($model->load(\Yii::$app->request->post())){
$booksIds = $model->search();
if (count($booksIds) == 1){
|
ed7ff609
Anastasia
- bug fix in search1
|
46
|
return $this->redirect(Url::to(['support/index', 'book_id' => $booksIds[0]]));
|
9afd152f
Anastasia
- support from main
|
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
}else{
$dataProvider = new ActiveDataProvider(
[
'query' => Book::find()
->with(
[
'author',
'alias',
]
)
->where([ 'status' => Book::STATUS_ACTIVE ])->andWhere(['book.id' => $booksIds]),
'pagination' => [
'pageSize' => 10,
],
]
);
return $this->render(
'search-result',
[
'dataProvider' => $dataProvider,
]
);
}
}
}
|
32162c17
Anastasia
- add buy a book
|
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
public function actionBuy($book_id = null){
$model = new Buy([
'book_id' => $book_id,
'status' => 0
]);
$book = Book::find()->with('author')->where(['id' => $book_id])->one();
if ($model->load(\Yii::$app->request->post()) and $model->save()){
\Yii::$app->session->setFlash('success', 'Дякуємо за ваш запит. Найближчим часом, наш менеджер зв\'яжеться з Вами для уточнення деталей');
return $this->redirect(['site/index']);
}
return $this->render('buy', [
'model' => $model,
'book' => $book
]);
}
|
e47109b0
Anastasia
- support
|
89
|
}
|