| Server IP : 180.180.241.3 / Your IP : 216.73.216.35 Web Server : Microsoft-IIS/7.5 System : Windows NT NETWORK-NHRC 6.1 build 7601 (Windows Server 2008 R2 Standard Edition Service Pack 1) i586 User : IUSR ( 0) PHP Version : 5.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /AppServ/www/app/Controller/ |
Upload File : |
<?php
App::uses('AppController', 'Controller');
/**
* Offers Controller
*
* @property Offer $Offer
* @property PaginatorComponent $Paginator
*/
class OffersController extends AppController {
/**
* List all offer from database
*
* @author 3Musketeers <3musketeersteam@gmail.com>
* @since 23 September 2013
*/
public function admin_index() {
// default values for filtering
$conditions = array();
$keyword = '';
$this->_getCommonConditions($conditions, $keyword);
$this->Paginator->settings['conditions'] = $conditions;
$this->Offer->recursive = 0;
$this->set('offers', $this->Paginator->paginate());
$this->set('topicTitle', __('ข้อเสนอ'));
$this->set('keyword', $keyword);
}
/**
* Add offer information
*
* @author 3Musketeers <3musketeersteam@gmail.com>
* @since 23 September 2013
*/
public function admin_add() {
if ( $this->request->is('post') ) {
$this->Offer->create();
if ( !$this->Offer->save($this->request->data) ) {
$this->Session->setFlash(__('ไม่สามารถบันทึกข้อมูลข้อเสนอได้ กรุณาลองใหม่อีกครั้ง'), 'flash-fail');
$this->redirect(array('action' => 'index', 'admin' => true));
}
$this->Session->setFlash(__('บันทึกข้อมูลข้อเสนอสำเร็จ'), 'flash-success');
$this->redirect(array('action' => 'index', 'admin' => true));
}
$this->set('topicTitle', __('เพิ่มข้อเสนอ'));
}
/**
* Edit offer information
*
* @throws NotFoundException if not found any offer
* @param string $id offer's id.
* @author 3Musketeers <3Musketeersteam@gmail.com>
* @since 23 September 2013
*/
public function admin_edit($id = null) {
if (!$this->Offer->exists($id)) {
throw new NotFoundException(__('ไม่พบข้อมูลข้อเสนอ'));
}
if ( $this->request->is('post') || $this->request->is('put') ) {
$this->Offer->id = $id;
if ( !$this->Offer->save($this->request->data) ) {
$this->Session->setFlash(__('ไม่สามารถบันทึกข้อมูลข้อเสนอได้ กรุณาลองใหม่อีกครั้ง'), 'flash-fail');
$this->redirect(array('action' => 'index', 'admin' => true));
}
$this->Session->setFlash(__('บันทึกข้อมูลข้อเสนอสำเร็จ'), 'flash-success');
$this->redirect(array('action' => 'index', 'admin' => true));
}
$this->Offer->recursive = -1;
$offer = $this->Offer->findById($id);
$this->set('offer', $offer);
$this->set('topicTitle', __('แก้ไขข้อมูล: ') . $offer['Offer']['name']);
}
/**
* Remove offer information accually just set `is_activated` to false in `AppModel::before_filter()`
*
* @throws NotFoundException if notfound any offer
* @param string $id offer's id
* @author 3Musketeers <3musketeersteam@gmail.com>
* @since 23 September 2013
*/
public function admin_delete($id = null) {
$this->Offer->id = $id;
if ( !$this->Offer->exists() ) {
throw new NotFoundException(__('ไม่พบข้อมูลข้อเสนอ'));
}
$this->request->onlyAllow('post', 'delete');
if ( !$this->Offer->delete() ) {
$this->Session->setFlash(__('ไม่สามารถเปลี่ยนสถานะข้อมูลข้อเสนอได้ กรุณาลองใหม่อีกครั้ง'), 'flash-fail');
$this->redirect(array('action' => 'index', 'admin' => true));
}
$this->Session->setFlash(__('เปลี่ยนสถานะข้อเสนอสำเร็จ'), 'flash-success');
$this->redirect(array('action' => 'index', 'admin' => true));
}
// export data to csv files
// @see http://bakery.cakephp.org/articles/jeroendenhaan/2010/04/23/exporting-data-to-csv-the-cakephp-way
public function admin_export() {
$this->set('topicTitle', __('ข้อเสนอ'));
parent::admin_export();
}
}