Subversion Repositories SmartDukaan

Rev

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

Rev 14509 Rev 14517
Line 43... Line 43...
43
 *
43
 *
44
 * @throws NotFoundException
44
 * @throws NotFoundException
45
 * @param string $id
45
 * @param string $id
46
 * @return void
46
 * @return void
47
 */
47
 */
48
	public function admin_view($id = null) {
48
	public function admin_search() {
49
		if (!$this->Exceptionalnlc->exists($id)) {
49
		$type = $this->request->query('type');
50
			throw new NotFoundException(__('Invalid exceptionalnlc'));
50
		$search = $this->request->query('search');				
51
		}
-
 
52
		$options = array('conditions' => array('Exceptionalnlc.' . $this->Exceptionalnlc->primaryKey => $id));
51
		$url = $this->apihost."Catalog/searchProducts/?class=".Inflector::pluralize($this->name)."&$type=$search";
-
 
52
		$response = $this->make_request($url,null);
53
		$this->set('exceptionalnlc', $this->Exceptionalnlc->find('first', $options));
53
		$this->set('negativedeals', $response);
-
 
54
		$this->set('page',1);
-
 
55
		$this->render('admin_index');
54
	}
56
	}
55
 
-
 
56
/**
57
/**
57
 * admin_add method
58
 * admin_add method
58
 *
59
 *
59
 * @return void
60
 * @return void
60
 */
61
 */
61
	public function admin_new() {
62
	public function admin_new() {
62
		if ($this->request->is('post')) {
63
		if ($this->request->is('post')) {
63
			debug($this->request->data);
-
 
64
			$url = $this->apihost."negativeDeals/addNegativeDeals";
64
			$url = $this->apihost."negativeDeals/addNegativeDeals";
65
			$jsonVar = json_encode($this->request->data['NegativeDeal'], JSON_NUMERIC_CHECK );
65
			$jsonVar = json_encode($this->request->data['NegativeDeal'], JSON_NUMERIC_CHECK );
66
			$response = $this->make_request($url,$jsonVar);
66
			$response = $this->make_request($url,$jsonVar);
67
			if (key($response)) {
67
			if (key($response)) {
68
				$this->Session->setFlash(current($response));
68
				$this->Session->setFlash(current($response));
Line 104... Line 104...
104
 * @param string $id
104
 * @param string $id
105
 * @return void
105
 * @return void
106
 */
106
 */
107
 
107
 
108
	public function admin_delete($id = null) {		
108
	public function admin_delete($id = null) {		
109
		// $this->request->onlyAllow('post', 'delete');
-
 
110
		if ($this->remove($id,'NegativeDeals')) {
109
		if ($this->remove($id,'NegativeDeals')) {
111
			$this->Session->setFlash(__('The negative deal has been deleted.'));
110
			$this->Session->setFlash(__('The negative deal has been deleted.'));
112
		} else {
111
		} else {
113
			$this->Session->setFlash(__('The negative could not be deleted. Please, try again.'));
112
			$this->Session->setFlash(__('The negative could not be deleted. Please, try again.'));
114
		}
113
		}