Ejemplo n.º 1
0
 /**
  * Creates a new Siswa model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Siswa();
     $nilai = new Nilai();
     $post = Yii::$app->request->post();
     if ($model->load($post)) {
         $tgllahir = strtotime($post['Siswa']['thn'] . '-' . $post['Siswa']['bln'] . '-' . $post['Siswa']['tgl']);
         $model->tgl_lahir = date('Y-m-d', $tgllahir);
         $foto = UploadedFile::getInstance($model, 'foto');
         if ($foto) {
             $ext = end(explode(".", $foto->name));
             $extt = $foto->extension;
             $model->foto = Yii::$app->security->generateRandomString() . "." . $extt;
         }
         if ($model->save()) {
             if ($foto) {
                 mkdir('uploads/foto_siswa', 0777, true);
                 $foto->saveAs('uploads/foto_siswa/' . $model->foto);
             }
             $signUp = new \frontend\models\SignupForm();
             $signUp->username = $model->email;
             $signUp->email = $model->email;
             $signUp->password = $model->password;
             $signUp->level = 'Siswa';
             $mapel = MatapelajaranGuru::find()->all();
             foreach ($mapel as $key => $value) {
                 $nilai->nis = $model->nis;
                 $nilai->id_matapelajaran = $value->id_matapelajaran_guru;
                 $nilai->tahun_ajaran = $_POST['Nilai']['tahun_ajaran'];
                 if ($nilai->save()) {
                     $nilai = new Nilai();
                 }
             }
             if ($signUp->signup()) {
                 Yii::$app->session->setFlash('success', 'Simpan Berhasil');
             } else {
                 Yii::$app->session->setFlash('warning', 'Simpan Gagal');
             }
             return $this->redirect(['index']);
         } else {
             Yii::$app->session->setFlash('warning', 'Failed');
         }
     } else {
         return $this->render('create', ['model' => $model, 'nilai' => $nilai]);
     }
 }
Ejemplo n.º 2
0
 public function postSimpan($hari)
 {
     // dd(request()->all());
     foreach (request()->input('nilai') as $parId => $nilai) {
         foreach ($nilai as $jni => $nl) {
             Nilai::setNilai($parId, $jni, $hari, $nl);
         }
     }
     return response()->json(['status' => true]);
 }
Ejemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Nilai::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // if(Yii::$app->user->identity->level=='guru'){
     //     $nip = app\model\Data::nip_guru();
     // }
     $query->andFilterWhere(['id_nilai' => $this->id_nilai, 'id_matapelajaran' => $this->id_matapelajaran, 'nilai' => $this->nilai]);
     $query->andFilterWhere(['like', 'nis', $this->nis])->andFilterWhere(['like', 'tahun_ajaran', $this->tahun_ajaran]);
     return $dataProvider;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getNilais()
 {
     return $this->hasMany(Nilai::className(), ['id_matapelajaran' => 'id_matapelajaran_guru']);
 }
Ejemplo n.º 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getNilais()
 {
     return $this->hasMany(Nilai::className(), ['nis' => 'nis']);
 }
Ejemplo n.º 6
0
 /**
  * Finds the Nilai model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Nilai the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Nilai::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }