H69UNtblNBNpha2dtB1Odn8qYp1Qk5NK2gi7yfceofo9N
/
home
/
ymswebso
/
public_html
/
buydotcom
/
app
/
Controller
/
Nama File / Folder
Size
Action
Component
--
NONE
StatesController.php
8.387KB
Hapus
Edit
Rename
<=Back
<?php class StatesController extends AppController { var $components = array('Session', 'RequestHandler', 'Paginator'); public $helpers = array('Html', 'Form'); public function fileterstatebycountry(){ if(isset($this->request->params['pass'][0])){ $country_id = $this->request->params['pass'][0]; }else{ $country_id = $this->request->params['pass'][0]; } $this->set('states', $this->State->find('all', array('conditions' => array('State.country_id' => $country_id), 'order' => 'State.name asc'))); } public function fileterstatebycountryinner(){ if(isset($this->request->params['pass'][0])){ $country_id = $this->request->params['pass'][0]; }else{ $country_id = $this->request->params['pass'][0]; } if(isset($this->request->params['pass'][1])){ $this->set('cls', $this->request->params['pass'][1]); }else{ $this->set('cls', ''); } if(isset($this->request->params['pass'][2])){ $this->set('field_name', $this->request->params['pass'][2]); }else{ $this->set('field_name', ''); } $this->set('states', $this->State->find('all', array('conditions' => array('State.country_id' => $country_id), 'order' => 'State.name asc'))); } // Here for Admin panael and code by Prabhakr public function admin_index() { if(!$this->Session->check('AdminUser')) { return $this->redirect(array('action' => '../users')); } $title_for_layout = 'States'; $this->set(compact('title_for_layout')); //echo '<pre>'; //print_r($this->request->params['named']); if(isset($this->request->params['pass'][0]) && $this->request->params['pass'][0] == 'ascending-by-id'){ $orderby = array('State.id' => 'asc'); if(isset($this->request->params['named']['page'])){ $this->set('idlink', '/admin/states/index/descending-by-id/page:'.$this->request->params['named']['page']); }else{ $this->set('idlink', '/admin/states/index/descending-by-id/'); } if(isset($this->request->params['named']['page'])){ $this->set('namelinke', '/admin/states/index/ascending-by-name/page:'.$this->request->params['named']['page']); }else{ $this->set('namelinke', '/admin/states/index/ascending-by-name/'); } $this->set('idsortcls', 'sorting_asc'); $this->set('namesortcls', 'sorting'); } elseif(isset($this->request->params['pass'][0]) && $this->request->params['pass'][0] == 'descending-by-id'){ $orderby = array('State.id' => 'desc'); if(isset($this->request->params['named']['page'])){ $this->set('idlink', '/admin/states/index/ascending-by-id/page:'.$this->request->params['named']['page']); }else{ $this->set('idlink', '/admin/states/index/ascending-by-id/'); } if(isset($this->request->params['named']['page'])){ $this->set('namelinke', '/admin/states/index/ascending-by-name/page:'.$this->request->params['named']['page']); }else{ $this->set('namelinke', '/admin/states/index/ascending-by-name/'); } $this->set('idsortcls', 'sorting_desc'); $this->set('namesortcls', 'sorting'); } elseif(isset($this->request->params['pass'][0]) && $this->request->params['pass'][0] == 'ascending-by-name'){ $orderby = array('State.state_name' => 'asc'); if(isset($this->request->params['named']['page'])){ $this->set('idlink', '/admin/states/index/ascending-by-id/page:'.$this->request->params['named']['page']); }else{ $this->set('idlink', '/admin/states/index/ascending-by-id/'); } if(isset($this->request->params['named']['page'])){ $this->set('namelinke', '/admin/states/index/descending-by-name/page:'.$this->request->params['named']['page']); }else{ $this->set('namelinke', '/admin/states/index/descending-by-name/'); } $this->set('idsortcls', 'sorting'); $this->set('namesortcls', 'sorting_asc'); } elseif(isset($this->request->params['pass'][0]) && $this->request->params['pass'][0] == 'descending-by-name'){ $orderby = array('State.state_name' => 'desc'); if(isset($this->request->params['named']['page'])){ $this->set('idlink', '/admin/states/index/ascending-by-id/page:'.$this->request->params['named']['page']); }else{ $this->set('idlink', '/admin/states/index/ascending-by-id/'); } if(isset($this->request->params['named']['page'])){ $this->set('namelinke', '/admin/states/index/ascending-by-name/page:'.$this->request->params['named']['page']); }else{ $this->set('namelinke', '/admin/states/index/ascending-by-name/'); } $this->set('idsortcls', 'sorting'); $this->set('namesortcls', 'sorting_desc'); } else{ $orderby = array('State.id' => 'desc'); if(isset($this->request->params['named']['page'])){ $this->set('idlink', '/admin/states/index/ascending-by-id/page:'.$this->request->params['named']['page']); }else{ $this->set('idlink', '/admin/states/index/ascending-by-id/'); } if(isset($this->request->params['named']['page'])){ $this->set('namelinke', '/admin/states/index/ascending-by-name/page:'.$this->request->params['named']['page']); }else{ $this->set('namelinke', '/admin/states/index/ascending-by-name/'); } $this->set('idsortcls', 'sorting'); $this->set('namesortcls', 'sorting'); } $this->paginate = array( 'limit' => 25, 'order' => $orderby ); $data = $this->paginate('State'); $this->set('states', $data); $this->loadModel('Country'); $this->set('countries', $this->Country->find('all', array('conditions' => array('Country.status' => '1')))); $this->set('TotalStates', $this->State->find('count')); if ($this->request->is('post')) { $this->State->create(); //print_r($this->request->data); if ($this->State->save($this->request->data)) { $this->Session->setFlash(__(' <div class="col-md-12 text-center" style="background-color:#FFFF94; color:green; padding:7px 15px; margin-bottom:15px; font-size:16px; font-weight:bold;">State has been added successfully.</div>')); return $this->redirect(array('action' => '../states')); } } } public function admin_delete($id) { if(!$this->Session->check('AdminUser')) { return $this->redirect(array('action' => '../users')); } if ($this->request->is('get')) { throw new MethodNotAllowedException(); } if ($this->State->delete($id)) { $this->Session->setFlash(__(' <div class="col-md-12 text-center" style="background-color:#FFFF94; color:green; padding:7px 15px; margin-top:15px; margin-bottom:15px; font-size:16px; font-weight:bold;">State has been deleted successfully.</div>')); return $this->redirect(array('action' => '../states')); } } public function admin_updatestatus() { if(!$this->Session->check('AdminUser')) { return $this->redirect(array('action' => '../users')); } //print_r($this->request->params['pass']); if($this->request->params['pass'][0]=='1') { $this->State->updateAll( array('status' => "'1'"), array('id' => $this->request->params['pass'][1])); } if($this->request->params['pass'][0]=='0') { $this->State->updateAll( array('status' => "'0'"), array('id' => $this->request->params['pass'][1])); } $this->Session->setFlash(__(' <div class="col-md-12 text-center" style="background-color:#FFFF94; color:green; padding:7px 15px; margin-top:15px; margin-bottom:15px; font-size:16px; font-weight:bold;">Status has been updated successfully.</div>')); return $this->redirect(array('action' => '../states')); if ($this->request->is('get')) { throw new MethodNotAllowedException(); } } public function admin_edit() { if(!$this->Session->check('AdminUser')) { return $this->redirect(array('action' => '../users')); } if ($this->request->is('post')) { $this->State->id = $this->request->data['id']; $this->State->save($this->request->data); //$this->State->updateAll( array('brand_name' => $this->request->data['brand_name'], 'status' => $this->request->data['status']), array('id' => $this->request->data['id'])); $this->Session->setFlash(__(' <div class="col-md-12 text-center" style="background-color:#FFFF94; color:green; padding:7px 15px; margin-top:15px; margin-bottom:15px; font-size:16px; font-weight:bold;">State has been updated successfully.</div>')); return $this->redirect(array('action' => '../states')); } if ($this->request->is('get')) { throw new MethodNotAllowedException(); } } } ?>
Liking