Subversion Repositories SmartDukaan

Rev

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

Rev 14509 Rev 14517
Line 45... Line 45...
45
 *
45
 *
46
 * @throws NotFoundException
46
 * @throws NotFoundException
47
 * @param string $id
47
 * @param string $id
48
 * @return void
48
 * @return void
49
 */
49
 */
50
	public function admin_view($id = null) {
50
	public function admin_search() {
51
		if (!$this->Exceptionalnlc->exists($id)) {
51
		$type = $this->request->query('type');
52
			throw new NotFoundException(__('Invalid exceptionalnlc'));
52
		$search = $this->request->query('search');				
53
		}
-
 
54
		$options = array('conditions' => array('Exceptionalnlc.' . $this->Exceptionalnlc->primaryKey => $id));
53
		$url = $this->apihost."Catalog/searchProducts/?class=".Inflector::pluralize($this->name)."&$type=$search";
-
 
54
		$response = $this->make_request($url,null);
-
 
55
		$this->set('negativedeals', $response);
-
 
56
		$this->set('page',1);
55
		$this->set('exceptionalnlc', $this->Exceptionalnlc->find('first', $options));
57
		$this->set('sources',$this->Store->find('list'));
-
 
58
		$this->render('admin_index');
56
	}
59
	}
57
 
-
 
58
/**
60
/**
59
 * admin_add method
61
 * admin_add method
60
 *
62
 *
61
 * @return void
63
 * @return void
62
 */
64
 */
63
	public function admin_add() {
65
	public function admin_add() {
64
		if ($this->request->is('post')) {
66
		if ($this->request->is('post')) {
65
			$this->request->data['ManualDeal']['startDate'] = 1000*mktime(0,0,0,$this->request->data['ManualDeal']['startDate']['month'],$this->request->data['ManualDeal']['startDate']['day'],$this->request->data['ManualDeal']['startDate']['year']);
67
			$this->request->data['ManualDeal']['startDate'] = 1000*mktime($this->request->data['ManualDeal']['startDate']['hour'],$this->request->data['ManualDeal']['startDate']['min'],0,$this->request->data['ManualDeal']['startDate']['month'],$this->request->data['ManualDeal']['startDate']['day'],$this->request->data['ManualDeal']['startDate']['year']);
66
			$this->request->data['ManualDeal']['endDate'] = 1000*mktime(0,0,0,$this->request->data['ManualDeal']['endDate']['month'],$this->request->data['ManualDeal']['endDate']['day'],$this->request->data['ManualDeal']['endDate']['year']);
68
			$this->request->data['ManualDeal']['endDate'] = 1000*mktime($this->request->data['ManualDeal']['endDate']['hour'],$this->request->data['ManualDeal']['endDate']['min'],0,$this->request->data['ManualDeal']['endDate']['month'],$this->request->data['ManualDeal']['endDate']['day'],$this->request->data['ManualDeal']['endDate']['year']);
67
			$url = $this->apihost."manualDeals/addManualDeals";
69
			$url = $this->apihost."manualDeals/addManualDeals";
68
			$jsonVar = json_encode($this->request->data['ManualDeal'], JSON_NUMERIC_CHECK );
70
			$jsonVar = json_encode($this->request->data['ManualDeal'], JSON_NUMERIC_CHECK );
69
			$response = $this->make_request($url,$jsonVar);
71
			$response = $this->make_request($url,$jsonVar);
70
			if (key($response)) {
72
			if (key($response)) {
71
				$this->Session->setFlash(current($response));
73
				$this->Session->setFlash(current($response));
Line 108... Line 110...
108
 * @throws NotFoundException
110
 * @throws NotFoundException
109
 * @param string $id
111
 * @param string $id
110
 * @return void
112
 * @return void
111
 */
113
 */
112
	public function admin_delete($id = null) {		
114
	public function admin_delete($id = null) {		
113
		// $this->request->onlyAllow('post', 'delete');
-
 
114
		if ($this->remove($id,'ManualDeals')) {
115
		if ($this->remove($id,'ManualDeals')) {
115
			$this->Session->setFlash(__('The manual deal has been deleted.'));
116
			$this->Session->setFlash(__('The manual deal has been deleted.'));
116
		} else {
117
		} else {
117
			$this->Session->setFlash(__('The manual could not be deleted. Please, try again.'));
118
			$this->Session->setFlash(__('The manual could not be deleted. Please, try again.'));
118
		}
119
		}