/**
  * Creates a new Inscricao model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($idcandidato, $idcurso)
 {
     $model = new Inscricao();
     $model->candidato_idcandidato = $idcandidato;
     $model->curso_idcurso = $idcurso;
     $candidatoSearch = new CandidatoSearch();
     $candidatoProvider = $candidatoSearch->search(Yii::$app->request->queryParams);
     $provaSearch = new ProvaInscricaoSearch();
     if ($idcandidato > 0) {
         $provaSearch->idcandidato = $model->candidato_idcandidato;
     }
     $provaProvider = $provaSearch->search(Yii::$app->request->queryParams);
     $cursoSearch = new CursoSearch();
     $cursoProvider = $cursoSearch->search(Yii::$app->request->queryParams);
     // if ($model->load(Yii::$app->request->post()) && $model->save()) {
     if ($req = Yii::$app->request->post()) {
         $model->provasIds = (array) Yii::$app->request->post('selection');
         $model->save();
         if ($model->errors) {
             return $this->render('create', ['model' => $model, 'candidatoSearch' => $candidatoSearch, 'candidatoProvider' => $candidatoProvider, 'provaSearch' => $provaSearch, 'provaProvider' => $provaProvider, 'cursoSearch' => $cursoSearch, 'cursoProvider' => $cursoProvider, 'tabelaNotas' => $this->tabelaNotas($model->candidato)]);
         }
         return $this->redirect(['view', 'id' => $model->idinscricao]);
     } else {
         return $this->render('create', ['model' => $model, 'candidatoSearch' => $candidatoSearch, 'candidatoProvider' => $candidatoProvider, 'provaSearch' => $provaSearch, 'provaProvider' => $provaProvider, 'cursoSearch' => $cursoSearch, 'cursoProvider' => $cursoProvider, 'tabelaNotas' => $this->tabelaNotas($model->candidato)]);
     }
     /*$model = new Inscricao();
      	$model->candidato_idcandidato = $idcandidato;
      	$model->data = '2016-03-02 00:00:00';
      	
      	if ($model->save()) {
      		return $this->redirect(['inscricao/curso', 'idinscricao' => $model->idinscricao]);
      	} else {
      		throw new NotSupportedException('Não consegue salvar. '.$model->data);
      		//throw new NotFoundHttpException('Não consegue salvar. '.$model->candidato_idcandidato);
      	}*/
 }
 /**
  * Lists all Curso models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new CursoSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }