/**
     * Creates a new Uploadedforms model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
    public function actionCreate()
    {
		if(Yii::$app->user->can('create-uploadedforms'))
		{
			$model = new Uploadedforms();
			
			if ($model->load(Yii::$app->request->post())) {
				
				$model->file = UploadedFile::getInstance($model,'file');
				if($model->file != null)
				{
					$fileName = md5(time()).$model->fileName." ofScholarID ".$model->uploaded_scholar_id." FileName ".$model->file->name;
					$model->file->saveAs('Forms/'.$fileName);	
					$model->uploadedForm = 'Forms/'.$fileName;
			//		$filePath = 'Forms'.'\'.$fileName.'.'.$model->file->extension;
				}
				$model->uploaded_by = Yii::$app->user->identity->username;			
				$model->save();
				// return $this->redirect($model->uploadedForm)->send();
				return $this->redirect(['view', 'id' => $model->id]);
			} else {
				return $this->render('create', [
					'model' => $model,
				]);
			}
		}
		else
		{
			throw new ForbiddenHttpException;
		}
    }
 /**
  * Creates a new Uploadedforms model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Uploadedforms();
     if ($model->load(Yii::$app->request->post())) {
         $fileName = $model->fileName . $model->uploaded_scholar_id;
         $model->file = UploadedFile::getInstance($model, 'file');
         if ($model->file != null) {
             $model->file->saveAs('Forms/' . $fileName . '.' . $model->file->extension);
             $model->uploadedForm = 'Forms/' . $fileName . '.' . $model->file->extension;
         }
         $model->save();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
    /**
     * Creates a new Uploadedforms model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
    public function actionCreate()
    {	
		$username=Yii::$app->user->identity->username;
		$users = User::find()->all();
		$scholars = Scholars::find()->all();
		$model = new Uploadedforms();
		foreach($users as $user){
		foreach($scholars as $scholar){
			if($user->username==$username&&$user->id==$scholar->scholar_id){
			$model->uploaded_scholar_id=$scholar->scholar_id;
			if ($model->load(Yii::$app->request->post())) {
			$fileName = $model->fileName.$model->uploaded_scholar_id;
			$model->file = UploadedFile::getInstance($model,'file');
			if($model->file != null)
			{
				$model->file->saveAs('uploads/'.$fileName.'.'.$model->file->extension);	
				$model->uploadedForm = 'uploads/'.$fileName.'.'.$model->file->extension;	
			}			
			$model->save();
            return $this->redirect(['index', 'id' => $model->id]);
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
			}
			
			}
				
		}
			
		
    }