Subversion Repositories SmartDukaan

Rev

Rev 13958 | Rev 13994 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
13958 anikendra 1
<?php
2
App::uses('AppController', 'Controller');
3
/**
4
 * Orders Controller
5
 *
6
 * @property Order $Order
7
 * @property PaginatorComponent $Paginator
8
 */
9
class OrderTrackersController extends AppController {
10
 
11
/**
12
 * Components
13
 *
14
 * @var array
15
 */
16
	public $components = array('Paginator');
17
 
18
	public function beforeFilter() {		
19
		parent::beforeFilter();
20
		$this->Auth->allow('get','post');
21
		$this->apihost = Configure::read('pythonapihost');
22
	}
23
 
24
/**
25
 * get method
26
 *
27
 * @throws NotFoundException
28
 * @return void
29
 */
30
	public function get() {
31
		$storeId = $this->request->query('store_id');
32
		$userId = $this->request->query('user_id');
33
		$url = $this->apihost.'track/user/'.$userId.'?storeId='.$storeId;
34
		$result = $this->make_request($url,null);
35
		$this->response->type('json');
36
		$this->layout = 'ajax';
37
		$this->set(array(
38
		    'result' => $result,
39
		    // 'callback' => $callback,
40
		    '_serialize' => array('result')
41
		));
42
		$this->render('/Elements/json');
43
	}
44
 
45
	public function post() {
46
		$storeId = $this->request->query('store_id');
47
		$userId = $this->request->query('user_id');
48
		$this->log(print_r($this->request->data,1),'order_trackers');
49
		if ($this->request->is('post')) {
50
			$url = $this->apihost."/track/user/$userId?storeId=$storeId";
13992 anikendra 51
			$this->make_request($url,$this->request->data);
13958 anikendra 52
			$result = array('success'=>true,'message'=>'html stored');
53
			$this->response->type('json');
54
			$this->layout = 'ajax';
55
			$this->set(array(
56
			    'result' => $result,
57
			    '_serialize' => array('result')
58
			));
59
			$this->render('/Elements/json');		
60
		}			
61
	}
62
 
63
}