| 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');
/**
* Members Controller
*
* @property Member $Member
* @property PaginatorComponent $Paginator
*/
class MembersController extends AppController {
/**
* admin_index method
*
* @return void
*/
public function admin_index() {
// default values for filtering
$conditions = array();
$keyword = '';
$this->_getCommonConditions($conditions, $keyword);
$this->Paginator->settings['conditions'] = $conditions;
$this->Member->recursive = 0;
$this->set('members', $this->Paginator->paginate());
$this->set('topicTitle', __('โครงการพิเศษ'));
$this->set('keyword', $keyword);
}
/**
* admin_view method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function admin_view($id = null) {
if (!$this->Member->exists($id)) {
throw new NotFoundException(__('Invalid member'));
}
$options = array('conditions' => array('Member.' . $this->Member->primaryKey => $id));
$this->set('member', $this->Member->find('first', $options));
}
/**
* admin_add method
*
* @return void
*/
public function admin_add() {
if ( $this->request->is('post') ) {
$this->Member->create();
if ( !$this->Member->save($this->request->data) ) {
$this->Session->setFlash(__('ไม่สมารถบันทึกโครงการพิเศษได้'), 'flash-fail' );
return $this->redirect(array('action' => 'index', 'admin' => true));
}
$this->Session->setFlash(__('บันทึกโครงการพเศษแล้ว'), 'flash-success');
return $this->redirect(array('action' => 'index', 'admin' => true));
}
$this->set('topicTitle', __('เพิ่มโครงการพเศษ'));
}
/**
* admin_edit method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function admin_edit( $id = null ) {
if ( !$this->Member->exists($id) ) {
throw new NotFoundException(__('ไม่พบโครงการพิเศษ'));
}
if ( $this->request->is('post') || $this->request->is('put') ) {
if ( !$this->Member->save( $this->request->data ) ) {
$this->Session->setFlash(__('ไม่สามารถบันทึกโครงการพิเศษได้'), 'flash-fail');
return $this->redirect(array('action' => 'index', 'admin' => true));
}
$this->Session->setFlash(__('บันทึกโครงการพิเศษแล้ว'), 'flash-success');
return $this->redirect(array('action' => 'index', 'admin' => true));
}
$options = array(
'conditions' => array(
'Member.' . $this->Member->primaryKey => $id
),
'recursive' => -1);
$this->request->data = $this->Member->find('first', $options);
$this->set('topicTitle', __('แก้ไขข้อมูลโครงการพิเศษ'));
}
/**
* admin_delete method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function admin_delete( $id = null ) {
$this->Member->id = $id;
if ( !$this->Member->exists() ) {
throw new NotFoundException(__('ไม่พบข้อมูลโครงการพิเศษ'));
}
$this->request->onlyAllow( 'post', 'delete' );
//Check `Member` use for organization?
//If use in somewhere not allowed to delete.
$this->loadModel( 'OrgMembership' );
$conditions = array( 'OrgMembership.member_id' => $id );
if ( $this->OrgMembership->hasAny( $conditions ) ) {
$this->Session->setFlash(__('โครงการพิเศษถูกใช้งานอยู่'), 'flash-fail');
$this->redirect(array('action' => 'index', 'admin' => true));
}
if ( !$this->Member->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));
}
public function admin_export() {
$this->set('topicTitle', __('โครงการพิเศษ'));
parent::admin_export();
}
}