Exemplo n.º 1
0
 public function ralat(Request $request)
 {
     $this->validate($request, ['nis' => 'required|exists:siswa,nis', 'id_mapel' => 'required|exists:mapel,id', 'id_semester' => 'required|exists:semester,id']);
     $siswa = Siswa::where('nis', $request->input('nis'))->first();
     $check = NilaiAkhir::where('id_mapel', $request->input('id_mapel'))->where('id_siswa', $siswa->id)->where('id_semester', $request->input('id_semester'));
     $exist = $check->first();
     if ($exist) {
         $new = new NilaiAkhir();
         $new->id_mapel = $exist->id_mapel;
         $new->id_semester = $exist->id_semester;
         $new->id_siswa = $exist->id_siswa;
         $new->nilai_pengetahuan = $exist->nilai_pengetahuan;
         $new->nilai_keterampilan = $exist->nilai_keterampilan;
         $new->deskripsi_pengetahuan = $exist->deskripsi_pengetahuan;
         $new->deskripsi_keterampilan = $exist->deskripsi_keterampilan;
         if ($request->input('nilai_pengetahuan')) {
             $new->nilai_pengetahuan = $request->input('nilai_pengetahuan');
         }
         if ($request->input('deskripsi_pengetahuan')) {
             $new->deskripsi_pengetahuan = $request->input('deskripsi_pengetahuan');
         }
         if ($request->input('nilai_keterampilan')) {
             $new->nilai_keterampilan = $request->input('nilai_keterampilan');
         }
         if ($request->input('deskripsi_keterampilan')) {
             $new->deskripsi_keterampilan = $request->input('deskripsi_keterampilan');
         }
         $check->delete();
         if ($new->save()) {
             return redirect()->route('ralat')->with('message', 'Nilai berhasil diralat.');
         } else {
             return redirect()->route('ralat')->with('message', 'Nilai gagal diralat.');
         }
     }
 }
Exemplo n.º 2
0
 public static function get_table_data($request)
 {
     if ($request->input('semester')) {
         $semester = $request->input('semester');
         $ids = "siswa.id, ',', {$request->input('mapel')}, ',', {$semester}";
     } else {
         $semester = Semester::get_active_semester()->id;
         $ids = "siswa.id, ',', {$request->input('mapel')}";
     }
     $data = Siswa::select(DB::raw("\n            NULL as `no`,\n            siswa.nis,\n            siswa.nama,\n            sq_nilai_akhir.nilai_pengetahuan,\n            sq_nilai_akhir.nilai_keterampilan,\n            CONCAT({$ids}) as `id`\n        "))->leftJoin(DB::raw('(select id_siswa, nilai_pengetahuan, nilai_keterampilan FROM nilai_akhir WHERE id_semester = ' . $semester . ' AND id_mapel = ' . $request->input('mapel') . ') sq_nilai_akhir'), 'sq_nilai_akhir.id_siswa', '=', 'siswa.id')->where('siswa.id_kelas', $request->input('kelas'))->orderBy('siswa.nama', 'ASC')->get()->toArray();
     return ['data' => $data];
 }
Exemplo n.º 3
0
 public static function get_table_data($request)
 {
     if ($request->input('semester')) {
         $semester = $request->input('semester');
         $ids = "siswa.id, ',', {$semester}";
     } else {
         $semester = Semester::get_active_semester()->id;
         $ids = "siswa.id";
     }
     $data = Siswa::select(DB::raw("\n            NULL as `no`,\n            siswa.nis,\n            siswa.nama,\n            CONCAT('<i class=\"fa fa-', IF(LENGTH(sq_nilai_sikap.sikap) > 0, 'check-square', 'square'), '\"></i>') as `check`,\n            CONCAT({$ids}) as `id`\n        "))->leftJoin(DB::raw('(select id_siswa, LEFT(sikap, 1) as `sikap` FROM nilai_sikap WHERE id_semester = ' . $semester . ') sq_nilai_sikap'), 'sq_nilai_sikap.id_siswa', '=', 'siswa.id')->where('siswa.id_kelas', $request->input('kelas'))->orderBy('siswa.nama', 'ASC')->get()->toArray();
     return ['data' => $data];
 }
Exemplo n.º 4
0
 public static function get_table_data($request)
 {
     $semester = Semester::get_active_semester()->id;
     $ids = "siswa.id";
     if ($request != null) {
         if ($request->input('semester')) {
             $semester = $request->input('semester');
             $ids = "siswa.id, ',', {$semester}";
         }
     }
     $data = Siswa::select(DB::raw("\n            NULL as `no`,\n            siswa.nis,\n            siswa.nama,\n            COUNT(sq_pkl.id_siswa),\n            CONCAT({$ids}) as `id`\n        "))->leftJoin(DB::raw('(select id_siswa FROM pkl WHERE id_semester = ' . $semester . ') sq_pkl'), 'sq_pkl.id_siswa', '=', 'siswa.id')->where('siswa.id_kelas', $request->input('kelas'))->groupBy('siswa.id')->get()->toArray();
     return ['data' => $data];
 }
Exemplo n.º 5
0
 public function delete(Request $request)
 {
     $check = Siswa::where('id_kelas', $request->id)->first();
     if ($check) {
         return response("Ada siswa yang terdaftar di dalam kelas ini.", 422);
     }
     $kelas = Kelas::find($request->id);
     if ($kelas) {
         try {
             $kelas->delete();
         } catch (\Illuminate\Database\QueryException $e) {
             return response('Operasi gagal. Coba cek kembali, mungkin ada kesalahan atau data yang ingin ditambahkan sudah ada.', 422);
         }
         return response('Kelas telah dihapus.', 200);
     } else {
         return response('Kelas tidak ditemukan.', 422);
     }
 }
Exemplo n.º 6
0
 /**
  * Halaman utama bagi staf.
  */
 public function index()
 {
     // Ambil data semester yang aktif
     $pass['semester'] = Semester::get_active_semester();
     // Pengecekan
     // 0 = fine
     // 1 = warning
     // 2 = error
     // Cek apakah ada jurusan tercatat
     $pass['jurusan'] = Jurusan::all()->count();
     // Cek apakah kelas tingkat 1 sudah dibuat
     $kelas = Kelas::check_firstyears();
     $pass['kelas'] = $kelas;
     if ($kelas['total'] == 0) {
         $pass['kelas']['cek'] = 2;
     } elseif ($kelas['count'] < $kelas['jurusan']) {
         $pass['kelas']['cek'] = 1;
     } else {
         $pass['kelas']['cek'] = 0;
     }
     // Cek apakah ada kelas tingkat 1 yang kosong
     $siswa = Siswa::check_firstyears();
     $pass['siswa'] = $siswa;
     if ($siswa['siswa_tingkat_x'] <= 0) {
         $pass['siswa']['cek'] = 2;
     } elseif ($siswa['kelas_kosong'] > 0) {
         $pass['siswa']['cek'] = 1;
     } else {
         $pass['siswa']['cek'] = 0;
     }
     // Cek apakah semua mapel sudah memiliki angka KB untuk semester ini
     $pass['kb'] = KetuntasanBelajar::check();
     // Cek apakah ada guru yang belum mendapat asosiasi pengajaran
     $pass['mengajar'] = Mengajar::check();
     return view('panel', $pass);
 }
Exemplo n.º 7
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Siswa::find($id)->delete();
     return redirect(url('siswa'));
 }
Exemplo n.º 8
0
 public function get_nama_from_nis(Request $request)
 {
     $siswa = Siswa::where('nis', $request->nis)->first();
     return $siswa ? $siswa->nama : 'NIS tidak ditemukan.';
 }
Exemplo n.º 9
0
 /**
 * Remove the specified resource from storage.
 *
 * @param int $id
 * @return Response
 */
 public function destroy(Siswa $siswa)
 {
     $siswa->delete();
     return redirect('siswa');
 }
Exemplo n.º 10
0
 public function upload_save(Request $request)
 {
     $this->validate($request, ['excel' => 'required']);
     $inputFileName = $request->excel;
     try {
         $inputFileType = PHPExcel_IOFactory::identify($inputFileName);
         $objReader = PHPExcel_IOFactory::createReader($inputFileType);
         $objPHPExcel = $objReader->load($inputFileName);
     } catch (Exception $e) {
         die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage());
     }
     $sheet = $objPHPExcel->getSheet(0);
     $highestRow = $sheet->getHighestRow();
     $highestColumn = $sheet->getHighestColumn();
     $start = false;
     $data_count = 0;
     $errors = 0;
     $semester = Semester::get_active_semester()->id;
     $id_siswa = null;
     for ($row = 1; $row <= $highestRow; $row++) {
         $rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE);
         if (!$start) {
             if ($rowData[0][0] == "1" || $rowData[0][0] == "1.") {
                 $start = true;
             }
         }
         if ($start) {
             if (empty($rowData[0][3]) || empty($rowData[0][4])) {
                 continue;
             }
             $data_count++;
             $new = new Ekskul();
             if (!empty($rowData[0][1])) {
                 $siswa = Siswa::where('nis', $rowData[0][1])->first();
                 if (!$siswa) {
                     $errors++;
                     $id_siswa = null;
                     continue;
                 }
                 $id_siswa = $siswa->id;
             } else {
                 if ($id_siswa == null) {
                     continue;
                 }
             }
             $created = null;
             $check = Ekskul::where('ekstrakurikuler', $rowData[0][3])->where('id_siswa', $id_siswa)->where('id_semester', $semester);
             $old = $check->first();
             if ($old) {
                 $created = $old->created_at;
                 $check->delete();
             }
             $new->id_siswa = $id_siswa;
             $new->id_semester = $semester;
             $new->ekstrakurikuler = $rowData[0][3];
             $new->nilai = $rowData[0][4];
             if ($created) {
                 $new->created_at = $created;
             }
             try {
                 $new->save();
             } catch (\Illuminate\Database\QueryException $e) {
                 $errors++;
             }
         }
     }
     if (!$start) {
         $message = "Tidak ada data ditemukan. Pastikan kolom nomor ada pada kolom A dan dimulai dengan angka 1.";
     } else {
         $message = "Upload file selesai. Terbaca ada {$data_count} data. ";
         $message .= $errors > 0 ? "Ada masalah dengan {$errors} data, dan tidak dapat dimasukkan ke dalam database." : "Semua data berhasil ditambahkan.";
     }
     return redirect()->route('nilai.ekskul')->with('message', $message);
 }
Exemplo n.º 11
0
 public function upload_save(Request $request)
 {
     $this->validate($request, ['excel' => 'required']);
     $inputFileName = $request->excel;
     try {
         $inputFileType = PHPExcel_IOFactory::identify($inputFileName);
         $objReader = PHPExcel_IOFactory::createReader($inputFileType);
         $objPHPExcel = $objReader->load($inputFileName);
     } catch (Exception $e) {
         die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage());
     }
     $data_count = 0;
     $errors = 0;
     $semester = Semester::get_active_semester()->id;
     foreach ($objPHPExcel->getWorksheetIterator() as $sheet) {
         $highestRow = $sheet->getHighestRow();
         $highestColumn = $sheet->getHighestColumn();
         $start = false;
         for ($row = 1; $row <= $highestRow; $row++) {
             $rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE);
             if (!$start) {
                 // Start check
                 if ($rowData[0][0] == "1" || $rowData[0][0] == "1.") {
                     $start = true;
                 }
             }
             if ($start) {
                 $id_siswa = null;
                 $data_count++;
                 if (!empty($rowData[0][1])) {
                     $siswa = Siswa::where('nis', $rowData[0][1])->first();
                     if (!$siswa) {
                         $errors++;
                         $id_siswa = null;
                         continue;
                     }
                     $id_siswa = $siswa->id;
                 }
                 if (!$id_siswa) {
                     continue;
                 }
                 $new = new Absensi();
                 $created = null;
                 $check = Absensi::where('id_siswa', $id_siswa)->where('id_semester', $semester);
                 $old = $check->first();
                 if ($old) {
                     $created = $old->created_at;
                     $check->delete();
                 }
                 $new->id_siswa = $id_siswa;
                 $new->id_semester = $semester;
                 $new->sakit = $rowData[0][3] !== null ? $rowData[0][3] : null;
                 $new->izin = $rowData[0][4] !== null ? $rowData[0][4] : null;
                 $new->alpa = $rowData[0][5] !== null ? $rowData[0][5] : null;
                 if ($created) {
                     $new->created_at = $created;
                 }
                 try {
                     $new->save();
                 } catch (\Illuminate\Database\QueryException $e) {
                     $errors++;
                 }
             }
         }
     }
     $message = "Upload file selesai. Terbaca ada {$data_count} data. ";
     $message .= $errors > 0 ? "Ada masalah dengan {$errors} data, dan tidak dapat dimasukkan ke dalam database." : "Semua data berhasil ditambahkan.";
     return redirect()->route('absensi')->with('message', $message);
 }
Exemplo n.º 12
0
 public function pkl_datalist(Request $request)
 {
     $this->validate($request, ['id_siswa' => 'required|exists:siswa,id', 'id_semester' => 'required|exists:semester,id']);
     $data = Pkl::get_all_catatan($request->input('id_siswa'), $request->input('id_semester'));
     $siswa = Siswa::find($request->input('id_siswa'));
     $tbody = '';
     if (count($data) < 1) {
         $tbody = "<tr><td colspan='99'><center>Tidak ada catatan PKL.</center></td></tr>";
     } else {
         foreach ($data as $i) {
             $tbody .= '<tr><td>' . $i->mitra . '</td>' . '<td>' . $i->lokasi . '</td>' . '<td>' . $i->lama . '</td>' . '<td>' . $i->keterangan . '</td>' . "<td><span class='nobr'>[ <a href=\"javascript:lihat('" . $request->input('id_siswa') . "','" . htmlspecialchars($i->mitra) . "','" . htmlspecialchars($i->lokasi) . "','" . htmlspecialchars($request->input('id_semester')) . "')\">Lihat</a> ]</span> " . "</tr>";
         }
     }
     return ['data' => $tbody, 'siswa' => $siswa->nama];
 }
Exemplo n.º 13
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($nisn)
 {
     Siswa::where('NISN', $nisn)->delete();
     return redirect(route('getDaftarSiswa'));
 }
Exemplo n.º 14
0
 public static function get_table_data($request)
 {
     $data = Siswa::select(DB::raw("\n            NULL as `no`,\n            siswa.nis,\n            siswa.nama,\n            sq_absensi.sakit,\n            sq_absensi.izin,\n            sq_absensi.alpa,\n            siswa.id as `id`\n        "))->leftJoin(DB::raw('(select id_siswa, sakit, izin, alpa FROM absensi_tu WHERE id_semester = ' . Semester::get_active_semester()->id . ') sq_absensi'), 'sq_absensi.id_siswa', '=', 'siswa.id')->where('siswa.id_kelas', $request->input('kelas'))->orderBy('siswa.nama', 'ASC')->get()->toArray();
     return ['data' => $data];
 }
Exemplo n.º 15
0
 public function upload_save(Request $request)
 {
     $this->validate($request, ['id_mapel' => 'required|exists:mapel,id', 'excel' => 'required']);
     $inputFileName = $request->excel;
     try {
         $inputFileType = PHPExcel_IOFactory::identify($inputFileName);
         $objReader = PHPExcel_IOFactory::createReader($inputFileType);
         $objPHPExcel = $objReader->load($inputFileName);
     } catch (Exception $e) {
         die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage());
     }
     $data_count = 0;
     $errors = 0;
     $semester = Semester::get_active_semester()->id;
     foreach ($objPHPExcel->getWorksheetIterator() as $sheet) {
         $highestRow = $sheet->getHighestRow();
         $highestColumn = $sheet->getHighestColumn();
         $start = false;
         $id_mapel = $request->input('id_mapel');
         for ($row = 1; $row <= $highestRow; $row++) {
             $rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE);
             if (!$start) {
                 // Start check
                 if ($rowData[0][0] == "1" || $rowData[0][0] == "1.") {
                     $start = true;
                 }
                 // Mapel set
                 foreach ($rowData[0] as $colNum => $colVal) {
                     if (strpos(strtolower($colVal), 'mata pelajaran:') !== FALSE || strpos(strtolower($colVal), 'mapel:') !== FALSE) {
                         $c = Mapel::where('nama', 'LIKE', $rowData[0][$colNum + 1])->first();
                         if ($c) {
                             $id_mapel = $c->id;
                         }
                     }
                 }
             }
             if ($start) {
                 $id_siswa = null;
                 $data_count++;
                 if (!empty($rowData[0][1])) {
                     $siswa = Siswa::where('nis', $rowData[0][1])->first();
                     if (!$siswa) {
                         $errors++;
                         $id_siswa = null;
                         continue;
                     }
                     $id_siswa = $siswa->id;
                 }
                 if (!$id_siswa) {
                     continue;
                 }
                 $new = new NilaiAkhir();
                 $created = null;
                 $check = NilaiAkhir::where('id_mapel', $id_mapel)->where('id_siswa', $id_siswa)->where('id_semester', $semester);
                 $old = $check->first();
                 if ($old) {
                     $created = $old->created_at;
                     $check->delete();
                 }
                 $new->id_siswa = $id_siswa;
                 $new->id_mapel = $id_mapel;
                 $new->id_semester = $semester;
                 $new->nilai_pengetahuan = $rowData[0][3] ? $rowData[0][3] : null;
                 $new->deskripsi_pengetahuan = $rowData[0][4] ? $rowData[0][4] : null;
                 $new->nilai_keterampilan = $rowData[0][5] ? $rowData[0][5] : null;
                 $new->deskripsi_keterampilan = $rowData[0][6] ? $rowData[0][6] : null;
                 if ($created) {
                     $new->created_at = $created;
                 }
                 try {
                     $new->save();
                 } catch (\Illuminate\Database\QueryException $e) {
                     $errors++;
                 }
             }
         }
     }
     $message = "Upload file selesai. Terbaca ada {$data_count} data. ";
     $message .= $errors > 0 ? "Ada masalah dengan {$errors} data, dan tidak dapat dimasukkan ke dalam database." : "Semua data berhasil ditambahkan.";
     return redirect()->route('nilai.akhir')->with('message', $message);
 }
Exemplo n.º 16
0
 public function make(Request $request)
 {
     $docObj = new PhpWord();
     $schDetails = Pengaturan::get_school_details();
     $printLocDate = $request->input('tempat_tanggal');
     $headmaster = Pengaturan::get_headmaster();
     $semester = Semester::get_active_semester();
     $siswa_to_print = [];
     $nis_array = [];
     if ($request->input('siswa') == 'kelas') {
         $siswa_to_print = Siswa::where('id_kelas', $request->input('kelas'))->get();
     } elseif ($request->input('siswa') == 'nis') {
         $nis_array = explode(' ', $request->input('nis'));
         foreach ($nis_array as $nis) {
             if (count($range = explode('-', $nis)) == 2) {
                 $range = Siswa::whereBetween('nis', $range)->get();
                 foreach ($range as $get) {
                     $siswa_to_print[] = $get;
                 }
             } elseif ($get = Siswa::where('nis', $nis)->first()) {
                 $siswa_to_print[] = $get;
             } else {
                 return back()->with('message', "NIS {$nis} tidak ditemukan.");
             }
         }
     } else {
         return back();
     }
     if (count($siswa_to_print) < 1) {
         return back()->with('message', "Tidak ada data untuk dicetak.");
     }
     $id_kelas = 0;
     $mapel_list = null;
     foreach ($siswa_to_print as $siswa) {
         if ($siswa->id_kelas == null) {
             continue;
         }
         if (!Semester::is_active_latest()) {
             $siswa->kelas_link->tingkat -= Semester::get_year_difference();
         }
         if ($request->input('cover')) {
             $docObj = $this->wordHalamanCover($docObj, $siswa);
             $docObj = $this->wordHalamanDataSekolah($docObj, $schDetails);
         }
         if ($request->input('bio')) {
             $docObj = $this->wordHalamanBiodata($docObj, $siswa, $printLocDate, $headmaster);
         }
         if ($request->input('nilai')) {
             if ($id_kelas != $siswa->id_kelas) {
                 $id_kelas = $siswa->id_kelas;
                 $mapel_list = NilaiAkhir::get_mapel_list($id_kelas);
             }
             $sikap = NilaiSikap::get_nilai($siswa->id);
             $nilai['sikap'] = $sikap ? $sikap->sikap : "";
             $nilai['mapel'] = NilaiAkhir::get_all_nilai($siswa, $mapel_list);
             $absensi = Absensi::get_absensi($siswa->id);
             $nilai['absensi'] = ['sakit' => $absensi ? $absensi->sakit : null, 'izin' => $absensi ? $absensi->izin : null, 'alpa' => $absensi ? $absensi->alpa : null];
             $nilai['prestasi'] = Prestasi::get_for_print($siswa->id, $semester->id);
             $nilai['ekskul'] = Ekskul::get_for_print($siswa->id, $semester->id);
             $nilai['pkl'] = Pkl::get_for_print($siswa->id, $semester->id);
             $docObj = $this->wordHalamanNilai($docObj, $schDetails, $siswa, $nilai, $headmaster, $printLocDate, $semester);
         }
     }
     $objWriter = IOFactory::createWriter($docObj, 'Word2007');
     $fn = date('Y-n-j_His');
     if ($request->input('siswa') == 'kelas') {
         $kelas = Kelas::find($request->input('kelas'));
         if (!Semester::is_active_latest()) {
             $kelas->tingkat -= Semester::get_year_difference();
         }
         $fn .= "_" . $kelas->name(false);
     }
     if ($request->input('siswa') == 'nis') {
         $fn .= "_" . $nis_array[0] . '-' . $nis_array[count($nis_array) - 1];
     }
     $objWriter->save("print/{$fn}.docx");
     return Response::download("print/{$fn}.docx", "{$fn}.docx", ['Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document']);
 }