Subversion Repositories SmartDukaan

Rev

Rev 13992 | Rev 14016 | 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";
13994 anikendra 51
			$params = array('url'=>$$this->request->data['url'],'html'=>$this->request->data['html']);
52
			$jsonVar = json_encode($params);
53
			return $this->make_request($url,$jsonVar);
54
			// $this->make_request($url,$this->request->data);
13958 anikendra 55
			$result = array('success'=>true,'message'=>'html stored');
56
			$this->response->type('json');
57
			$this->layout = 'ajax';
58
			$this->set(array(
59
			    'result' => $result,
60
			    '_serialize' => array('result')
61
			));
62
			$this->render('/Elements/json');		
63
		}			
64
	}
65
 
66
}