1
|
|
|
<?php
|
2
|
|
|
/**
|
3
|
|
|
* @author Alexey Tatarinov <[email protected]>
|
4
|
|
|
* @link https://github.com/shogodev/argilla/
|
5
|
|
|
* @copyright Copyright © 2003-2015 Shogo
|
6
|
|
|
* @license http://argilla.ru/LICENSE
|
7
|
|
|
*/
|
8
|
|
|
class OrderController extends FController
|
9
|
|
|
{
|
10
|
|
|
const CLASS_WRAPPER = 'js-wrapper-basket';
|
11
|
|
|
|
12
|
|
|
public function actionFirstStep()
|
13
|
|
|
{
|
14
|
|
|
$this->breadcrumbs = array('Корзина');
|
15
|
|
|
|
16
|
|
|
if( Yii::app()->request->isAjaxRequest )
|
17
|
|
|
{
|
18
|
|
|
$this->forward('basket/ajax', false);
|
19
|
|
|
}
|
20
|
|
|
else
|
21
|
|
|
{
|
22
|
|
|
$this->basket->ajaxUrl = Yii::app()->createUrl('order/firstStep');
|
23
|
|
|
$this->basket->ajaxUpdate(self::CLASS_WRAPPER);
|
24
|
|
|
}
|
25
|
|
|
|
26
|
|
|
$this->renderBasketFirstStep(array());
|
27
|
|
|
}
|
28
|
|
|
|
29
|
|
|
public function actionSecondStep()
|
30
|
|
|
{
|
31
|
|
|
if( $this->basket->isEmpty() )
|
32
|
|
|
Yii::app()->request->redirect($this->createUrl('order/firstStep'));
|
33
|
|
|
|
34
|
|
|
$this->breadcrumbs = array('Корзина');
|
35
|
|
|
|
36
|
|
|
$orderForm = new FOrderForm('OrderForm', new Order());
|
37
|
|
|
|
38
|
|
|
$orderForm->ajaxValidation();
|
39
|
|
|
|
40
|
|
|
if( $orderForm->save() )
|
41
|
|
|
{
|
42
|
|
|
$orderForm->sendNotificationBackend();
|
43
|
|
|
$orderForm->sendNotification($orderForm->model->email);
|
44
|
|
|
|
45
|
|
|
$this->basket->clear();
|
46
|
|
|
|
47
|
|
|
echo CJSON::encode(array(
|
48
|
|
|
'status' => 'ok',
|
49
|
|
|
'redirect' => $orderForm->getSuccessUrl(),
|
50
|
|
|
));
|
51
|
|
|
|
52
|
|
|
Yii::app()->session['orderSuccess'] = true;
|
53
|
|
|
Yii::app()->session['orderId'] = $orderForm->model->id;
|
54
|
|
|
Yii::app()->end();
|
|
|
|
|
55
|
|
|
}
|
56
|
|
|
else
|
57
|
|
|
{
|
58
|
|
|
$this->render('second_step', array('form' => $orderForm, 'model' => $orderForm->model));
|
59
|
|
|
}
|
60
|
|
|
}
|
61
|
|
|
|
62
|
|
|
public function actionThirdStep()
|
63
|
|
|
{
|
64
|
|
|
if( $this->basket->isEmpty() && !Yii::app()->session->get('orderSuccess', false) )
|
65
|
|
|
Yii::app()->request->redirect($this->createUrl('order/firstStep'));
|
66
|
|
|
|
67
|
|
|
$orderId = Yii::app()->session['orderId'];
|
68
|
|
|
Yii::app()->session->remove('orderId');
|
69
|
|
|
Yii::app()->session->remove('orderSuccess');
|
70
|
|
|
|
71
|
|
|
$this->breadcrumbs = array('Корзина');
|
72
|
|
|
$this->render('third_step', array('orderId' => $orderId));
|
73
|
|
|
}
|
74
|
|
|
|
75
|
|
|
private function renderBasketFirstStep($data = array())
|
76
|
|
|
{
|
77
|
|
|
$view = $this->basket->isEmpty() ? 'empty' : 'first_step';
|
78
|
|
|
$this->onBeforeRender(new CEvent($this, array('data' => $data, 'view' => $view)));
|
79
|
|
|
|
80
|
|
|
$html = array(CHtml::openTag('div', array('id' => self::CLASS_WRAPPER)));
|
81
|
|
|
$html[] = $this->renderPartial($view, $data, true);
|
82
|
|
|
$html[] = CHtml::closeTag('div');
|
83
|
|
|
|
84
|
|
|
$output = implode("\n\r", $html);
|
85
|
|
|
|
86
|
|
|
if( !Yii::app()->request->isAjaxRequest )
|
87
|
|
|
{
|
88
|
|
|
$this->onBeforeRenderLayout(new CEvent($this, array('content' => $output)));
|
89
|
|
|
$output = $this->renderFile($this->getLayoutFile($this->layout), array('content' => $output), true);
|
90
|
|
|
$output = $this->processOutput($output);
|
91
|
|
|
}
|
92
|
|
|
|
93
|
|
|
echo $output;
|
94
|
|
|
}
|
95
|
|
|
} |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: