Skip to content

Instantly share code, notes, and snippets.

@destinydriven
Created March 4, 2015 20:21
Show Gist options
  • Save destinydriven/04f6dad91c0d8234cbef to your computer and use it in GitHub Desktop.
Save destinydriven/04f6dad91c0d8234cbef to your computer and use it in GitHub Desktop.
this method fetches the timesheet record based on $timesheet_id and is supposed to pass it to the element containing the bootstrap modal
public function fetch_timesheet($id = null) {
$this->autoRender = false;
$this->layout = 'ajax';
if(!$this->request->is('ajax')){
throw new MethodNotAllowedException(__('This method is not allowed within this context!'));
}
$options = array(
'conditions' => array('Timesheet.' . $this->Timesheet->primaryKey => $id),
'contain' => array(
'Employee' => array(
'fields' => array('id', 'name'),
'EmploymentData' => array(
'fields' => array('id', 'department_id'),
'Department' => array(
'fields' => array('id', 'name')
)
)
)
)
);
$this->Timesheet->recursive = -1;
$timesheet = $this->Timesheet->find('first', $options);
$view = new View($this, false);
//debug($timesheet) ; die;
$content = $view->element('/Timesheet/view_modal', $timesheet);
$view->append('modal', $content);
$this->set(compact('content','timesheet'));
$this->render('/Elements/Timesheet/view_modal');
return 'This is not allowed!';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment