Subversion Repositories SmartDukaan

Rev

Rev 13532 | Rev 13633 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13532 Rev 13591
Line 13... Line 13...
13
 *
13
 *
14
 * @var array
14
 * @var array
15
 */
15
 */
16
	public $components = array('Paginator');
16
	public $components = array('Paginator');
17
 
17
 
-
 
18
	public function beforeFilter() {
-
 
19
		parent::beforeFilter();
-
 
20
		$this->Auth->allow('add');
-
 
21
	}
-
 
22
	
18
/**
23
/**
19
 * index method
24
 * index method
20
 *
25
 *
21
 * @return void
26
 * @return void
22
 */
27
 */
23
	public function index() {
28
	public function index() {
-
 
29
		throw new NotFoundException(__('Access Denied'));
24
		$this->Order->recursive = 0;
30
		$this->Order->recursive = 0;
25
		$this->set('orders', $this->Paginator->paginate());
31
		$this->set('orders', $this->Paginator->paginate());
26
	}
32
	}
27
 
33
 
28
/**
34
/**
Line 31... Line 37...
31
 * @throws NotFoundException
37
 * @throws NotFoundException
32
 * @param string $id
38
 * @param string $id
33
 * @return void
39
 * @return void
34
 */
40
 */
35
	public function view($id = null) {
41
	public function view($id = null) {
-
 
42
		throw new NotFoundException(__('Access Denied'));
36
		if (!$this->Order->exists($id)) {
43
		if (!$this->Order->exists($id)) {
37
			throw new NotFoundException(__('Invalid order'));
44
			throw new NotFoundException(__('Invalid order'));
38
		}
45
		}
39
		$options = array('conditions' => array('Order.' . $this->Order->primaryKey => $id));
46
		$options = array('conditions' => array('Order.' . $this->Order->primaryKey => $id));
40
		$this->set('order', $this->Order->find('first', $options));
47
		$this->set('order', $this->Order->find('first', $options));
Line 47... Line 54...
47
 */
54
 */
48
	public function add() {
55
	public function add() {
49
		if ($this->request->is('post')) {
56
		if ($this->request->is('post')) {
50
			$this->Order->create();
57
			$this->Order->create();
51
			if ($this->Order->save($this->request->data)) {
58
			if ($this->Order->save($this->request->data)) {
52
				$this->Session->setFlash(__('The order has been saved.'));
59
				$result =array('success'=>true,'message'=>__('The order has been saved.'));
53
				return $this->redirect(array('action' => 'index'));
-
 
54
			} else {
60
			} else {
55
				$this->Session->setFlash(__('The order could not be saved. Please, try again.'));
61
				$result = array('success'=>false,'message'=>__('The order could not be saved. Please, try again.'));
56
			}
62
			}
57
		}
-
 
58
		$users = $this->Order->User->find('list');
63
			$this->response->type('json');
59
		$stores = $this->Order->Store->find('list');
64
			$this->layout = 'ajax';
-
 
65
			$this->set(array(
-
 
66
			    'result' => $result,
-
 
67
			    // 'callback' => $callback,
60
		$storeOrders = $this->Order->StoreOrder->find('list');
68
			    '_serialize' => array('result')
-
 
69
			));
61
		$this->set(compact('users', 'stores', 'storeOrders'));
70
			$this->render('/Elements/json');		
-
 
71
		}			
62
	}
72
	}
63
 
73
 
64
/**
74
/**
65
 * edit method
75
 * edit method
66
 *
76
 *
67
 * @throws NotFoundException
77
 * @throws NotFoundException
68
 * @param string $id
78
 * @param string $id
69
 * @return void
79
 * @return void
70
 */
80
 */
71
	public function edit($id = null) {
81
	public function edit($id = null) {
-
 
82
		throw new NotFoundException(__('Access Denied'));
72
		if (!$this->Order->exists($id)) {
83
		if (!$this->Order->exists($id)) {
73
			throw new NotFoundException(__('Invalid order'));
84
			throw new NotFoundException(__('Invalid order'));
74
		}
85
		}
75
		if ($this->request->is(array('post', 'put'))) {
86
		if ($this->request->is(array('post', 'put'))) {
76
			if ($this->Order->save($this->request->data)) {
87
			if ($this->Order->save($this->request->data)) {
Line 95... Line 106...
95
 * @throws NotFoundException
106
 * @throws NotFoundException
96
 * @param string $id
107
 * @param string $id
97
 * @return void
108
 * @return void
98
 */
109
 */
99
	public function delete($id = null) {
110
	public function delete($id = null) {
-
 
111
		throw new NotFoundException(__('Access Denied'));
100
		$this->Order->id = $id;
112
		$this->Order->id = $id;
101
		if (!$this->Order->exists()) {
113
		if (!$this->Order->exists()) {
102
			throw new NotFoundException(__('Invalid order'));
114
			throw new NotFoundException(__('Invalid order'));
103
		}
115
		}
104
		$this->request->onlyAllow('post', 'delete');
116
		$this->request->onlyAllow('post', 'delete');