Subversion Repositories SmartDukaan

Rev

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

Rev 13579 Rev 13758
Line 150... Line 150...
150
 * @throws NotFoundException
150
 * @throws NotFoundException
151
 * @param string $id
151
 * @param string $id
152
 * @return void
152
 * @return void
153
 */
153
 */
154
	public function admin_edit($id = null) {
154
	public function admin_edit($id = null) {
-
 
155
		$this->response->type('json');
-
 
156
		$this->layout = 'ajax';
155
		if (!$this->Brand->exists($id)) {
157
		if (!$this->Brand->exists($id)) {
156
			throw new NotFoundException(__('Invalid brand'));
158
			throw new NotFoundException(__('Invalid brand'));
157
		}
159
		}
158
		if ($this->request->is(array('post', 'put'))) {
160
		if ($this->request->is(array('post', 'put'))) {
159
			if ($this->Brand->save($this->request->data)) {
161
			if ($this->Brand->save($this->request->data)) {
160
				$this->Session->setFlash(__('The brand has been saved.'));
162
				$result = array('success'=>true,'message'=>'The brand has been edited');
161
				return $this->redirect(array('action' => 'index'));
-
 
162
			} else {
163
			} else {
163
				$this->Session->setFlash(__('The brand could not be saved. Please, try again.'));
164
				$result = array('success'=>false,'message'=>'The brand could not be edited. Try again later');
164
			}
165
			}
165
		} else {
166
		} 
-
 
167
	 	$this->set(array(
166
			$options = array('conditions' => array('Brand.' . $this->Brand->primaryKey => $id));
168
		    'result' => $result,
167
			$this->request->data = $this->Brand->find('first', $options);
169
		    '_serialize' => array('result')
168
		}
170
		)); 
-
 
171
		$this->render('/Elements/json');  
169
	}
172
	}
170
 
173
 
171
/**
174
/**
172
 * admin_delete method
175
 * admin_delete method
173
 *
176
 *