public function save(Request $request)
 {
     $input = $request->except('_token');
     foreach ($input as $key => $value) {
         try {
             Pengaturan::vset($key, $value);
         } catch (Exception $e) {
             return redirect()->route('pengaturan')->with('message', 'Salah satu data gagal diperbarui.');
         }
     }
     return redirect()->route('pengaturan')->with('message', 'Data berhasil diperbarui.');
 }
예제 #2
0
 public function setup(Request $request)
 {
     // Set semester
     $new = new Semester();
     $new->semester = $request->input('semester');
     $new->tahun_ajaran = $request->input('tahun_ajaran');
     $new->aktif = 1;
     $new->save();
     $input = $request->except(['_token', 'semester', 'tahun_ajaran']);
     // Set pengaturan
     foreach ($input as $key => $value) {
         Pengaturan::vset($key, $value);
     }
     // Cek apakah mata pelajaran wali kelas sudah ada, kalau belum, tambah
     $wk = Mapel::where('kelompok', 'WK')->get();
     if (!$wk) {
         App\Mapel::create(['nama' => 'Wali kelas', 'singkat' => 'WALI', 'kelompok' => 'WK']);
     }
     return redirect()->route('kelas.jurusan')->with('message', "Data semester dan informasi sekolah telah dikonfigurasi.");
 }
예제 #3
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']);
 }