| Line 12... |
Line 12... |
| 12 |
* Components
|
12 |
* Components
|
| 13 |
*
|
13 |
*
|
| 14 |
* @var array
|
14 |
* @var array
|
| 15 |
*/
|
15 |
*/
|
| 16 |
public $components = array('Paginator');
|
16 |
public $components = array('Paginator');
|
| - |
|
17 |
public $apihost;
|
| - |
|
18 |
public $limit;
|
| 17 |
|
19 |
|
| 18 |
public function beforeFilter() {
|
20 |
public function beforeFilter() {
|
| 19 |
parent::beforeFilter();
|
21 |
parent::beforeFilter();
|
| 20 |
$this->Auth->allow('bycategory','category','mine');
|
22 |
$this->Auth->allow('bycategory','category','mine');
|
| 21 |
$callback = $this->request->query('callback');
|
23 |
$callback = $this->request->query('callback');
|
| - |
|
24 |
$this->apihost = Configure::read('pythonapihost');
|
| - |
|
25 |
$this->limit = Configure::read('dealsperpage');
|
| 22 |
}
|
26 |
}
|
| 23 |
|
27 |
|
| 24 |
public function mine() {
|
28 |
public function mine() {
|
| 25 |
$userId = $this->request->query('user_id');
|
29 |
$userId = $this->request->query('user_id');
|
| 26 |
if(isset($userId) && !empty($userId)){
|
30 |
if(isset($userId) && !empty($userId)){
|
| Line 33... |
Line 37... |
| 33 |
$this->loadModel('Api');
|
37 |
$this->loadModel('Api');
|
| 34 |
$page = $this->request->query('page');
|
38 |
$page = $this->request->query('page');
|
| 35 |
if(!isset($page)){
|
39 |
if(!isset($page)){
|
| 36 |
$page = 1;
|
40 |
$page = 1;
|
| 37 |
}
|
41 |
}
|
| 38 |
$title_for_layout = "Get Cashback on favourite";
|
42 |
$offset = ($page - 1) * $this->limit;
|
| 39 |
$description = "Get cashback on your favourite products. Mouth watering deals";
|
- |
|
| - |
|
43 |
|
| 40 |
$apideals = $this->Api->getDeals($this->Auth->User('id'));
|
44 |
// $apideals = $this->Api->getDeals($this->Auth->User('id'));
|
| 41 |
$deals = $apideals['products'];
|
45 |
// $deals = $apideals['products'];
|
| - |
|
46 |
$url = $this->apihost.'deals/'.$this->Auth->User('id').'?categoryId=0&limit='.$this->limit.'&offset='.$offset;
|
| - |
|
47 |
$deals = $this->make_request($url,null);
|
| - |
|
48 |
// debug($deals);
|
| 42 |
$myactions = $this->Api->getMyActions($this->Auth->User('id'));
|
49 |
$myactions = $this->Api->getMyActions($this->Auth->User('id'));
|
| 43 |
if(!empty($myactions)) {
|
50 |
if(!empty($myactions)) {
|
| 44 |
foreach ($myactions['actions'] as $key => $value) {
|
51 |
foreach ($myactions['actions'] as $key => $value) {
|
| 45 |
if($value['UserAction']['action'] == 'like'){
|
52 |
if($value['UserAction']['action'] == 'like'){
|
| 46 |
$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
|
53 |
$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
|
| 47 |
}else{
|
54 |
}else{
|
| 48 |
$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
|
55 |
$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
|
| 49 |
}
|
56 |
}
|
| 50 |
}
|
57 |
}
|
| 51 |
}
|
58 |
}
|
| - |
|
59 |
$title_for_layout = "Get Cashback on favourite";
|
| - |
|
60 |
$description = "Get cashback on your favourite products. Mouth watering deals";
|
| 52 |
$this->set(compact('page', 'title_for_layout', 'description', 'deals', 'likedDeals','disLikedDeals'));
|
61 |
$this->set(compact('page', 'title_for_layout', 'description', 'deals', 'likedDeals','disLikedDeals'));
|
| 53 |
$this->render('/Pages/home');
|
62 |
$this->render('/Pages/home');
|
| 54 |
}
|
63 |
}
|
| 55 |
|
64 |
|
| 56 |
public function getdeals() {
|
65 |
public function getdeals() {
|
| Line 58... |
Line 67... |
| 58 |
$this->layout = 'ajax';
|
67 |
$this->layout = 'ajax';
|
| 59 |
$this->loadModel('Api');
|
68 |
$this->loadModel('Api');
|
| 60 |
$page = $this->request->query('page');
|
69 |
$page = $this->request->query('page');
|
| 61 |
if(!isset($page)){
|
70 |
if(!isset($page)){
|
| 62 |
$page = 1;
|
71 |
$page = 1;
|
| 63 |
}
|
72 |
}
|
| 64 |
$title_for_layout = "Get Cashback on favourite";
|
73 |
$offset = ($page - 1) * $this->limit;
|
| 65 |
$description = "Get cashback on your favourite products.Mouth watering deals";
|
- |
|
| 66 |
$apideals = $this->Api->getDeals($this->Auth->User('id'),$page);
|
74 |
// $apideals = $this->Api->getDeals($this->Auth->User('id'),$page);
|
| 67 |
$deals = $apideals['products'];
|
75 |
// $deals = $apideals['products'];
|
| - |
|
76 |
$url = $this->apihost.'deals/'.$this->Auth->User('id').'?categoryId=0&limit='.$this->limit.'&offset='.$offset;
|
| - |
|
77 |
$deals = $this->make_request($url,null);
|
| 68 |
$myactions = $this->Api->getMyActions($this->Auth->User('id'));
|
78 |
$myactions = $this->Api->getMyActions($this->Auth->User('id'));
|
| 69 |
if(!empty($myactions)) {
|
79 |
if(!empty($myactions)) {
|
| 70 |
foreach ($myactions['actions'] as $key => $value) {
|
80 |
foreach ($myactions['actions'] as $key => $value) {
|
| 71 |
if($value['UserAction']['action'] == 'like'){
|
81 |
if($value['UserAction']['action'] == 'like'){
|
| 72 |
$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
|
82 |
$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
|
| 73 |
}else{
|
83 |
}else{
|
| 74 |
$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
|
84 |
$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
|
| 75 |
}
|
85 |
}
|
| 76 |
}
|
86 |
}
|
| 77 |
}
|
87 |
}
|
| - |
|
88 |
$title_for_layout = "Get Cashback on your favourite products";
|
| - |
|
89 |
$description = "Get cashback on your favourite products. Mouth watering deals";
|
| 78 |
$this->set(compact('page', 'title_for_layout', 'description', 'deals', 'likedDeals','disLikedDeals'));
|
90 |
$this->set(compact('page', 'title_for_layout', 'description', 'deals', 'likedDeals','disLikedDeals'));
|
| 79 |
$this->render('/Elements/deals');
|
91 |
$this->render('/Elements/deals');
|
| 80 |
}
|
92 |
}
|
| 81 |
/**
|
93 |
/**
|
| 82 |
* index method
|
94 |
* index method
|