Subversion Repositories SmartDukaan

Rev

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

Rev 13579 Rev 13583
Line 47... Line 47...
47
		));
47
		));
48
		$this->render('/Elements/jsonp');
48
		$this->render('/Elements/jsonp');
49
	}
49
	}
50
 
50
 
51
	public function deals(){
51
	public function deals(){
-
 
52
		$likedDeals = $disLikedDeals = array();
52
		$this->loadModel('Api');
53
		$this->loadModel('Api');
53
		$apideals = $this->Api->getCategoryDeals($this->Auth->User('id'),1);
54
		$apideals = $this->Api->getCategoryDeals($this->Auth->User('id'),1);
54
		$categorydeals = $apideals['products'];
55
		$categorydeals = $apideals['products'];
-
 
56
		$myactions = $this->Api->getMyActions($this->Auth->User('id'));		
-
 
57
		if(!empty($myactions)) {
-
 
58
			foreach ($myactions['actions'] as $key => $value) {
-
 
59
				if($value['UserAction']['action'] == 'like'){
-
 
60
					$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
-
 
61
				}else{
-
 
62
					$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
-
 
63
				}
-
 
64
			}
-
 
65
		}
55
		$rows = sizeof($categorydeals);
66
		$rows = sizeof($categorydeals);
56
		if($rows>=1){
67
		if($rows>=1){
57
			$this->set('deals',$categorydeals);
68
			$this->set('deals',$categorydeals);
-
 
69
			$this->set('likedDeals',$likedDeals);
-
 
70
			$this->set('disLikedDeals',$disLikedDeals);
58
			$this->render('categorydeals');
71
			$this->render('categorydeals');
59
		}else{
72
		}else{
60
			foreach ($categorydeals as $key => $dealarr) {
73
			foreach ($categorydeals as $key => $dealarr) {
61
				foreach ($dealarr as $key => $deal) {
74
				foreach ($dealarr as $key => $deal) {
62
					$deals[] = $deal[0];
75
					$deals[] = $deal[0];
63
				}				
76
				}				
64
			}
77
			}
65
			$this->set(compact('deals'));
78
			$this->set(compact('deals','likedDeals','disLikedDeals'));
66
		}		
79
		}		
67
	}
80
	}
68
/*
81
/*
69
	*
82
	*
70
 * view method
83
 * view method
Line 72... Line 85...
72
 * @throws NotFoundException
85
 * @throws NotFoundException
73
 * @param string $id
86
 * @param string $id
74
 * @return void
87
 * @return void
75
 */
88
 */
76
	public function view($id = null) {
89
	public function view($id = null) {
-
 
90
		$likedDeals = $disLikedDeals = array();
77
		if (!$this->Category->exists($id)) {
91
		if (!$this->Category->exists($id)) {
78
			throw new NotFoundException(__('Invalid category'));
92
			throw new NotFoundException(__('Invalid category'));
79
		}
93
		}
-
 
94
		$page = $this->request->query('page');
-
 
95
		if(!isset($page)){
-
 
96
			$page = 1;
-
 
97
		}	
80
		$this->loadModel('Api');
98
		$this->loadModel('Api');
81
		$apideals = $this->Api->getDealsByCategory($this->Auth->User('id'),$id,1);
99
		$apideals = $this->Api->getDealsByCategory($this->Auth->User('id'),$id,1);
82
		$deals = $apideals['products'];
100
		$deals = $apideals['products'];
-
 
101
		$myactions = $this->Api->getMyActions($this->Auth->User('id'));
-
 
102
		if(!empty($myactions)) {
-
 
103
			foreach ($myactions['actions'] as $key => $value) {
-
 
104
				if($value['UserAction']['action'] == 'like'){
-
 
105
					$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
-
 
106
				}else{
-
 
107
					$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
-
 
108
				}
-
 
109
			}
-
 
110
		}
83
		$this->set(compact('deals','id'));
111
		$this->set(compact('deals','id','likedDeals','disLikedDeals','page'));
84
	}
112
	}
85
 
113
 
86
	public function getdeals($id = null) {
114
	public function getdeals($id = null) {
-
 
115
		$likedDeals = $disLikedDeals = array();
87
		$this->layout = 'ajax';
116
		$this->layout = 'ajax';
88
		$page = $this->request->query('page');
117
		$page = $this->request->query('page');
89
		if(!isset($page)){
118
		if(!isset($page)){
90
			$page = 1;
119
			$page = 1;
91
		}
120
		}
Line 93... Line 122...
93
			throw new NotFoundException(__('Invalid category'));
122
			throw new NotFoundException(__('Invalid category'));
94
		}
123
		}
95
		$this->loadModel('Api');
124
		$this->loadModel('Api');
96
		$apideals = $this->Api->getDealsByCategory($this->Auth->User('id'),$id,$page);
125
		$apideals = $this->Api->getDealsByCategory($this->Auth->User('id'),$id,$page);
97
		$deals = $apideals['products'];
126
		$deals = $apideals['products'];
-
 
127
		$myactions = $this->Api->getMyActions($this->Auth->User('id'));
-
 
128
		if(!empty($myactions)) {
-
 
129
			foreach ($myactions['actions'] as $key => $value) {
-
 
130
				if($value['UserAction']['action'] == 'like'){
-
 
131
					$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
-
 
132
				}else{
-
 
133
					$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
-
 
134
				}
-
 
135
			}
-
 
136
		}
98
		$this->set(compact('deals','id','page'));
137
		$this->set(compact('deals','id','page','likedDeals','disLikedDeals'));
99
		$this->render('/Elements/categorydeals');
138
		$this->render('/Elements/categorydeals');
100
	}
139
	}
101
/**
140
/**
102
 * add method
141
 * add method
103
 *
142
 *