public function assignTrainingAction() { $id = $this->getSanParam('id'); $this->view->assign('id', $id); require_once 'models/table/Training.php'; require_once 'models/table/OptionList.php'; $training = new Training(); $rows = $training->find($id); $row = $rows->current(); $this->view->assign('training', $row); $this->view->assign('training_name', $training->getCourseName($id)); $evaluations = OptionList::suggestionList('evaluation', array('id', 'title')); $this->view->assign('evaluations', $evaluations); //find currently selected $evalTable = new OptionList(array('name' => 'evaluation_to_training')); $select = $evalTable->select()->from('evaluation_to_training', array('evaluation_id'))->where('training_id = ' . $id); $row = $evalTable->fetchRow($select); if ($row) { $this->view->assign('evaluation_id', $row->evaluation_id); } $request = $this->getRequest(); if ($request->isPost()) { $status = ValidationContainer::instance(); $evaluation_id = $this->getSanParam('evaluation_id'); $status->setStatusMessage(t('The evaluation has been assigned.')); $eval_id = $this->getSanParam('evaluation_id'); require_once 'models/table/MultiOptionList.php'; MultiOptionList::updateOptions('evaluation_to_training', 'evaluation', 'training_id', $id, 'evaluation_id', array($eval_id => $eval_id)); $status->setRedirect('/training/edit/id/' . $id); $this->sendData($status); } }
/** * [editTraining description] * @param [type] $train_id [description] * @return [type] [description] */ public function editTraining($train_id) { $roles = Roles::all(); $rs = Training::find($train_id); $target_arr = explode(',', $rs->target); return View::make('train.edit')->with('result', $rs)->with('arr_target', $target_arr)->with('roles', $roles); }