Ejemplo n.º 1
0
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     //userCv
     $user = User::findOne(['id' => $model->user_id]);
     $model->username = $user->username;
     $tarievenDag = UserTarievenDag::findOne(['user_id' => $model->user_id, 'naam' => 'Dagdienst']);
     $tarievenNacht = UserTarievenNacht::findOne(['user_id' => $model->user_id, 'naam' => 'Nachtdienst']);
     $tarievenWeekend = UserTarievenWeekend::findOne(['user_id' => $model->user_id, 'naam' => 'Weekenddienst']);
     $reisTarief = UserReistarief::findOne(['user_id' => $model->user_id]);
     $uploadMdl = new UploadForm();
     $uploadMdl->init($model->user_id);
     // convert  string to array
     $model->branch_discipline = explode(',', $model->branch_discipline);
     $model->branch_specialisatie = explode(',', $model->branch_specialisatie);
     if (!isset($tarievenDag)) {
         $tarievenDag = new UserTarieven();
     }
     if (!isset($tarievenNacht)) {
         $tarievenNacht = new UserTarieven();
     }
     if (!isset($tarievenWeekend)) {
         $tarievenWeekend = new UserTarieven();
     }
     if (!isset($reisTarief)) {
         $reisTarief = new UserReistarief();
     }
     //$userCvDocs = UserCvDocs::find()->where(['user_id' =>$model->user_id])->asArray()->all();
     if ($model->load(Yii::$app->request->post())) {
         //uplaod files to user dir
         $uploadMdl->docFiles = UploadedFile::getInstances($uploadMdl, 'docFiles');
         $uploadMdl->upload($model->user_id);
         // convert array's to string comma seperated
         $model->branch_discipline = implode(',', $model->branch_discipline);
         $model->branch_specialisatie = implode(',', $model->branch_specialisatie);
         $model->save(false);
         $tarievenDag->load(Yii::$app->request->post());
         $tarievenWeekend->user_id = $model->user_id;
         $tarievenDag->naam = 'Dagdienst';
         $tarievenDag->omschrijving = 'Dagdienst';
         $tarievenDag->save(false);
         $tarievenNacht->load(Yii::$app->request->post());
         $tarievenNacht->user_id = $model->user_id;
         $tarievenNacht->naam = 'Nachtdienst';
         $tarievenNacht->omschrijving = 'Nachtdienst';
         $tarievenNacht->save(false);
         $tarievenWeekend->load(Yii::$app->request->post());
         $tarievenWeekend->user_id = $model->user_id;
         $tarievenWeekend->naam = 'Weekenddienst';
         $tarievenWeekend->omschrijving = 'Weekenddienst';
         $tarievenWeekend->save(false);
         $reisTarief->load(Yii::$app->request->post());
         $reisTarief->user_id = $model->user_id;
         $tarievenDag->save(false);
         $uploadMdl = new UploadForm();
         $uploadMdl->init($model->user_id);
     }
     return $this->render('update', ['model' => $model, 'company' => Company::findOne(['user_id' => Yii::$app->user->id]), 'disciplines' => BranchDisciplines::allOmschrijvingen(), 'specialisaties' => BranchSpecialisaties::allOmschrijvingen(), 'user' => $user, 'tarievenDag' => $tarievenDag, 'tarievenNacht' => $tarievenNacht, 'tarievenWeekend' => $tarievenWeekend, 'reisTarief' => $reisTarief, 'uploadMdl' => $uploadMdl]);
 }
Ejemplo n.º 2
0
 public function actionDelDoc($id)
 {
     $model = $this->findModel($id);
     $user = User::findOne(['id' => $model->user_id]);
     $model->username = $user->username;
     $model->deletePdfFile();
     return $this->render('update', ['model' => $model, 'company' => Company::findOne(['user_id' => Yii::$app->user->id]), 'disciplines' => BranchDisciplines::allOmschrijvingen(), 'specialisaties' => BranchSpecialisaties::allOmschrijvingen(), 'user' => $user]);
 }