| 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');
|
| 14016 |
anikendra |
48 |
$this->log('storeId '.print_r($storeId,1),'order_trackers');
|
|
|
49 |
$this->log('userId '.print_r($userId,1),'order_trackers');
|
| 13958 |
anikendra |
50 |
if ($this->request->is('post')) {
|
| 14937 |
amit.gupta |
51 |
if($this->request->data['zip']){
|
|
|
52 |
$this->request->data['rawhtml'] = gzuncompress(base64_decode($this->request->data['rawhtml']));
|
|
|
53 |
}
|
| 14016 |
anikendra |
54 |
$this->log(print_r($this->request->data,1),'order_trackers');
|
|
|
55 |
$url = $this->apihost.'track/user/'.$userId.'?storeId='.$storeId;
|
|
|
56 |
$this->log($url,'order_trackers');
|
| 14139 |
anikendra |
57 |
$params = array('url'=>urlencode($this->request->data['url']),'html'=>urlencode($this->request->data['html']));
|
| 14016 |
anikendra |
58 |
//$jsonVar = json_encode($params,JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE);
|
|
|
59 |
//$this->log(print_r($jsonVar,1),'order_trackers');
|
| 14139 |
anikendra |
60 |
$result = $this->post_request($url,$params);
|
| 14016 |
anikendra |
61 |
//$result = array('success'=>true,'message'=>'html stored');
|
| 13958 |
anikendra |
62 |
$this->response->type('json');
|
|
|
63 |
$this->layout = 'ajax';
|
|
|
64 |
$this->set(array(
|
|
|
65 |
'result' => $result,
|
|
|
66 |
'_serialize' => array('result')
|
|
|
67 |
));
|
|
|
68 |
$this->render('/Elements/json');
|
|
|
69 |
}
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
}
|