Exemple #1
0
<?php
/**
 * Created by PhpStorm.
 * User: Ivanna
 * Date: 16.06.2015
 * Time: 17:47
 */

    $this->breadcrumbs=array(
        'Викладачі'=>array('index'),
        'Ролі викладача'
    );
?>

    <link type="text/css" rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/css/roles.css" />
    <p class="header">Ролі викладача <?php echo $name;?></p>
<?php
for ($i = count($roles)-1; $i > 0; $i--){
    echo '<div class="atts">'.TeacherHelper::getRoleTitle($roles[$i]['role']).'</div>';
    $atts = RoleAttribute::model()->type($roles[$i]['role'])->findAll();
    for($j=0;$j<count($atts);$j++){
        echo '<div class="params">'.($j+1).". ".$atts[$j]->name_ua.' = '.TeacherHelper::getTeacherAttributeValue($teacherId,$atts[$j]->id).'</div>';
    }
}
?>

 public function actionAddRoleAttribute($role){
     $model=new RoleAttribute;
     if(isset($_POST['RoleAttribute']))
     {
         $model->attributes=$_POST['RoleAttribute'];
         if($model->save())
             $this->redirect(array('viewRoleAttribute','id'=>$model->id));
     }
     $model->role = $role;
     $this->render('addRoleAttribute',array(
         'model'=>$model,
     ));
 }
	/**
	 * Returns the data model based on the primary key given in the GET variable.
	 * If the data model is not found, an HTTP exception will be raised.
	 * @param integer $id the ID of the model to be loaded
	 * @return RoleAttribute the loaded model
	 * @throws CHttpException
	 */
	public function loadModel($id)
	{
		$model=RoleAttribute::model()->findByPk($id);
		if($model===null)
			throw new CHttpException(404,'The requested page does not exist.');
		return $model;
	}