Subversion Repositories SmartDukaan

Rev

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

Rev 14561 Rev 16493
Line 38... Line 38...
38
		$this->loadModel('Store');
38
		$this->loadModel('Store');
39
		$this->set('sources',$this->Store->find('list'));
39
		$this->set('sources',$this->Store->find('list'));
40
		$this->set('page',$page);
40
		$this->set('page',$page);
41
	}
41
	}
42
 
42
 
-
 
43
	public function admin_dealpoints() {
-
 
44
		$page = $this->request->query('page');
-
 
45
		if(!isset($page)){
-
 
46
			$page = 1;
-
 
47
		}
-
 
48
		$limit = Configure::read('admindashboardlimit');
-
 
49
		$offset = ($page - 1)*$limit;
-
 
50
		$url = $this->apihost."dealPoints/getDealPoints/?limit=$limit&offset=$offset";
-
 
51
		$response = $this->make_request($url,null);
-
 
52
		$this->set('negativedeals', $response);
-
 
53
		$this->loadModel('Store');
-
 
54
		$this->set('sources',$this->Store->find('list'));
-
 
55
		$this->set('page',$page);
-
 
56
	}
-
 
57
 
-
 
58
	public function admin_add_dealpoints() {
-
 
59
		if ($this->request->is('post')) {
-
 
60
			$this->request->data['ManualDeals']['startDate'] = 1000*mktime($this->request->data['ManualDeals']['startDate']['hour'],$this->request->data['ManualDeals']['startDate']['min'],0,$this->request->data['ManualDeals']['startDate']['month'],$this->request->data['ManualDeals']['startDate']['day'],$this->request->data['ManualDeals']['startDate']['year']);
-
 
61
			$this->request->data['ManualDeals']['endDate'] = 1000*mktime($this->request->data['ManualDeals']['endDate']['hour'],$this->request->data['ManualDeals']['endDate']['min'],0,$this->request->data['ManualDeals']['endDate']['month'],$this->request->data['ManualDeals']['endDate']['day'],$this->request->data['ManualDeals']['endDate']['year']);
-
 
62
			$url = $this->apihost."dealPoints/addDealPoints";
-
 
63
			$data = $this->request->data['ManualDeals'];
-
 
64
			$url = $this->generateMultiUrl($url,$data);
-
 
65
			$jsonVar = json_encode($data, JSON_NUMERIC_CHECK );
-
 
66
			$response = $this->make_request($url,$jsonVar);
-
 
67
			if (key($response)) {
-
 
68
				$this->Session->setFlash(current($response));
-
 
69
				return $this->redirect(array('action' => 'dealpoints'));
-
 
70
			} else {
-
 
71
				$this->Session->setFlash(current($response));
-
 
72
			}	
-
 
73
		}
-
 
74
	}
-
 
75
 
43
/**
76
/**
44
 * admin_view method
77
 * admin_view method
45
 *
78
 *
46
 * @throws NotFoundException
79
 * @throws NotFoundException
47
 * @param string $id
80
 * @param string $id
Line 119... Line 152...
119
		} else {
152
		} else {
120
			$this->Session->setFlash(__('The manual could not be deleted. Please, try again.'));
153
			$this->Session->setFlash(__('The manual could not be deleted. Please, try again.'));
121
		}
154
		}
122
		return $this->redirect(array('action' => 'index'));
155
		return $this->redirect(array('action' => 'index'));
123
	}
156
	}
-
 
157
 
-
 
158
	public function admin_delete_dealpoint($id=null) {
-
 
159
		if ($this->remove($id,'DealPoints')) {
-
 
160
			$this->Session->setFlash(__('The deal point has been deleted.'));
-
 
161
		} else {
-
 
162
			$this->Session->setFlash(__('The deal pointcould not be deleted. Please, try again.'));
-
 
163
		}
-
 
164
		return $this->redirect(array('action' => 'dealpoints'));
-
 
165
	}
124
}
166
}