Пример #1
0
 public function afterSave($insert, $changedAttributes)
 {
     $absensi = Absensi::deleteAll(['id_peserta' => $this->id]);
     foreach ($this->events as $id_event) {
         $absensi = new Absensi();
         $absensi->id_peserta = $this->id;
         $absensi->id_event = $id_event;
         $absensi->kehadiran = 0;
         $absensi->save();
     }
 }
Пример #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Absensi::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'id_peserta' => $this->id_peserta, 'id_event' => $this->id_event, 'kehadiran' => $this->kehadiran]);
     return $dataProvider;
 }
Пример #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAbsensis()
 {
     return $this->hasMany(Absensi::className(), ['id_event' => 'id'])->join('inner join', 'peserta', 'id_peserta = peserta.id')->orderBy('peserta.nama');
 }
Пример #4
0
 public function showabsensi(Request $request)
 {
     $input = $request->all();
     $mahasiswa = Models\Absensi::getAbsen($input['jurusan'], $input['bulan'], $input['tahun']);
     return response()->json($mahasiswa);
 }
Пример #5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     $absensi = Absensi::find($id);
     if ($absensi->delete()) {
         return response()->json(array('success' => TRUE));
     }
 }
Пример #6
0
 public function actionRefresh()
 {
     $id = Yii::$app->request->get('id');
     $model = Absensi::findOne($id);
     if ($model != null) {
         if ($model->kehadiran == 1) {
             $model->kehadiran = 0;
             $model->save();
         } else {
             //hadir
             $subject = "Terima Kasih Telah Hadir di Seminar Unpar Career Expo";
             $content = "Dear {$model->idPeserta->nama}, <br>\n\t            Terima kasih telah hadir di seminar <b>{$model->idEvent->nama}</b>.<br>\n\t\t\t\tMudah-mudahan dapat bermanfaat untuk Anda.<br>\n\t\t\t\tJika ada masukan untuk seminarnya jangan ragu untuk mengirimkannya ke email career.expo@unpar.ac.id<br><br>\n\t            Best regards,<br>Panitia Unpar Career Expo & Seminar";
             $model->kehadiran = 1;
             $model->save();
             Yii::$app->mailer->compose()->setFrom(Yii::$app->params['adminEmail'])->setHtmlBody($content)->setSubject($subject)->setTo($model->idPeserta->email)->send();
         }
     }
     return $this->redirect(Yii::$app->request->referrer);
 }