iya ndak muncul gan gambarnya,tapi itu udah tak jelasin gan gambaran tabelnya
baru mulai buat gan,di controlernya masih kode asli hasil generate gii
class PenugasanmengajarController extends Controller
{
public $layout='//layouts/column2';
public function filters()
{
return array(
'rights',
//'accessControl', // perform access control for CRUD operations
//'postOnly + delete', // we only allow deletion via POST request
);
}
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view' actions
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('create','createdosen','createasesor','update','updatedosen','updateasesor'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete' actions
'actions'=>array('admin','delete'),
'users'=>array('admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
public function actionView($id,$id2,$id3,$id4)
{
$this->render('view',array(
'model'=>$this->loadModel($id,$id2,$id3,$id4),
));
}
public function actionCreate()
{
$model=new Penugasanmengajar;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Penugasanmengajar']))
{
$model->attributes=$_POST['Penugasanmengajar'];
if($model->save())
$this->redirect(array('view','id'=>$model->nidn));
}
$this->render('create',array(
'model'=>$model,
));
}
public function actionCreatedosen()
{
$model=new Penugasanmengajar;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Penugasanmengajar']))
{
$model->attributes=$_POST['Penugasanmengajar'];
if($model->save())
$this->redirect(array('view','id'=>$model->nidn));
}
$this->render('createdosen',array(
'model'=>$model,
));
}
public function actionCreateasesor()
{
$model=new Penugasanmengajar;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Penugasanmengajar']))
{
$model->attributes=$_POST['Penugasanmengajar'];
if($model->save())
$this->redirect(array('view','id'=>$model->nidn));
}
$this->render('createasesor',array(
'model'=>$model,
));
}
public function actionUpdate($id,$id2,$id3,$id4)
{
$model=$this->loadModel($id,$id2,$id3,$id4);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Penugasanmengajar']))
{
$model->attributes=$_POST['Penugasanmengajar'];
if($model->save())
$this->redirect(array('view','id'=>$model->nidn,'id2'=>$model->kode_mata_kuliah,'id3'=>$model->sk_penugasan,'id4'=>$model->kelas));
}
$this->render('update',array(
'model'=>$model,
));
}
public function actionUpdatedosen($id,$id2,$id3,$id4)
{
$model=$this->loadModel($id,$id2,$id3,$id4);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Penugasanmengajar']))
{
$model->attributes=$_POST['Penugasanmengajar'];
if($model->save())
$this->redirect(array('view','id'=>$model->nidn,'id2'=>$model->kode_mata_kuliah,'id3'=>$model->sk_penugasan,'id4'=>$model->kelas));
}
$this->render('updatedosen',array(
'model'=>$model,
));
}
public function actionUpdateasesor($id,$id2,$id3,$id4)
{
$model=$this->loadModel($id,$id2,$id3,$id4);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Penugasanmengajar']))
{
$model->attributes=$_POST['Penugasanmengajar'];
if($model->save())
$this->redirect(array('view','id'=>$model->nidn,'id2'=>$model->kode_mata_kuliah,'id3'=>$model->sk_penugasan,'id4'=>$model->kelas));
}
$this->render('updateasesor',array(
'model'=>$model,
));
}
public function actionDelete($id,$id2,$id3,$id4)
{
if (Yii::app()->request->isPostRequest){
$this->loadModel($id,$id2,$id3,$id4)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}
else
throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
}
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Penugasanmengajar');
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
public function actionAdmin()
{
$model=new Penugasanmengajar('search');
$model->unsetAttributes(); //clear any default values
if(isset($_GET['Penugasanmengajar']))
$model->attributes=$_GET['Penugasanmengajar'];
$this->render('admin',array(
'model'=>$model,
));
}
public function loadModel($id,$id2,$id3,$id4)
{
$model=Penugasanmengajar::model()->findByAttributes(array('nidn'=>$id,'kode_mata_kuliah'=>$id2,'sk_penugasan'=>$id3,'kelas'=>$id4));
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='penugasan-mengajar-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
}