setIconTitle("fa fa-graduation-cap"); } public function index(Request $request) { $method = $request->method(); $this->setTitle("Data BOS Omspan"); $this->setIconTitle("fa fa-graduation-cap"); $this->siteTitle = "Daftar"; return view('data_omspan.index'); } public function upload(Request $request) { $method = $request->method(); $this->setTitle("Data BOS Omspan"); $this->setSubtitle("Upload File"); $this->setIconTitle("fas fa-upload"); if ($request->isMethod('post')) { $req = $request->all(); try{ $this->validate($request, [ 'file' => 'required|mimes:xls,xlsx', ]); $file = $request->file('file'); $subJenisDana = $request->optJenisDana; $ta = $request->ta; $tujuan_upload = 'uploadFiles'; $file->move($tujuan_upload,$file->getClientOriginalName()); DB::beginTransaction(); // DataUploadBosOmspan::truncate(); Excel::import(new ImportDataBos($ta), $tujuan_upload."/".$file->getClientOriginalName()); DB::commit(); return redirect(URL::to("/data-omspan/upload/"))->with('success','Data berhasil diupload, Silahkan validasi data terlebih dahulu!'); } catch(\Exception $e) { // throw new \Exception($e->getMessage()); DB::rollBack(); abort(500, $e->getMessage()); // return redirect(URL::to("/upload-data/".$typeDana))->with('error',$e->getMessage()); } } $this->siteTitle = "Upload Data"; return view('data_omspan.upload'); } public function datatable(Request $request) { $post = $request->all(); $offset = $post["start"]; $limit = $post["length"]; $src = isset($post["search"])?$post["search"]["value"]:""; $dataFilter=0; $data = DataBosOmspan::orderBy("created_at","ASC"); if (!empty($src)){ $data->whereRaw("( LOWER(kanwil) LIKE '%".strtolower($src)."%' OR LOWER(kppn) LIKE '%".strtolower($src)."%' OR LOWER(lokasi_kewenangan) LIKE '%".strtolower($src)."%' OR LOWER(jenis_bos) LIKE '%".strtolower($src)."%' OR LOWER(no_rekening_nama_rekening) LIKE '%".strtolower($src)."%' OR LOWER(npsn) LIKE '%".strtolower($src)."%' OR LOWER(no_tgl_sp2d_detail) LIKE '%".strtolower($src)."%' OR LOWER(status_sekolah) LIKE '%".strtolower($src)."%' )"); } $dataFilter = $data->count(); $dataTotal = DataBosOmspan::count(); return response()->json([ "recordsTotal" => $dataTotal, "recordsFiltered" => $dataFilter, "data"=> $data->skip($offset)->take($limit)->get() ]); } public function uploadDatatable(Request $request) { $post = $request->all(); $offset = $post["start"]; $limit = $post["length"]; $src = isset($post["search"])?$post["search"]["value"]:""; $dataFilter=0; $data = DataUploadBosOmspan::orderBy("created_at","ASC"); if (!empty($src)){ $data->whereRaw("( LOWER(kanwil) LIKE '%".strtolower($src)."%' OR LOWER(kppn) LIKE '%".strtolower($src)."%' OR LOWER(lokasi_kewenangan) LIKE '%".strtolower($src)."%' OR LOWER(jenis_bos) LIKE '%".strtolower($src)."%' OR LOWER(no_rekening_nama_rekening) LIKE '%".strtolower($src)."%' OR LOWER(npsn) LIKE '%".strtolower($src)."%' OR LOWER(no_tgl_sp2d_detail) LIKE '%".strtolower($src)."%' OR LOWER(status_sekolah) LIKE '%".strtolower($src)."%' )"); } $dataFilter = $data->count(); $dataTotal = DataUploadBosOmspan::count(); return response()->json([ "recordsTotal" => $dataTotal, "recordsFiltered" => $dataFilter, "data"=> $data->skip($offset)->take($limit)->get() ]); } public function uploadValidate(Request $request) { try{ DB::beginTransaction(); DB::statement("DELETE FROM DATA_BOS_OMSPAN WHERE EXISTS( SELECT * FROM DATA_UPLOAD_BOS_OMSPAN WHERE (tahun = ".getTA()." AND DATA_BOS_OMSPAN.no_tgl_sp2d_detail = DATA_UPLOAD_BOS_OMSPAN.no_tgl_sp2d_detail) )"); DB::statement("INSERT INTO DATA_BOS_OMSPAN( tahun, kanwil, kppn, lokasi_kewenangan, lokasi_sekolah, no_tgl_sk, jenis_bos, tahap, gelombang, npsn_nama_sekolah, jenis_satuan_pendidikan, status_sekolah, bank, no_rekening_nama_rekening, npsn, rekening, nama, jenjang_sekolah, no_tgl_sp2d_detail, no_sp2d, tgl_sp2d, status, nilai, pagu, jmlh_siswa, ket_retur, created_at ) SELECT tahun, kanwil, kppn, lokasi_kewenangan, lokasi_sekolah, no_tgl_sk, jenis_bos, tahap, gelombang, npsn_nama_sekolah, jenis_satuan_pendidikan, status_sekolah, bank, no_rekening_nama_rekening, npsn, rekening, nama, jenjang_sekolah, no_tgl_sp2d_detail, no_sp2d, tgl_sp2d, status, nilai, pagu, jmlh_siswa, ket_retur, CURRENT_TIMESTAMP FROM DATA_UPLOAD_BOS_OMSPAN"); DataUploadBosOmspan::truncate(); DB::commit(); return redirect(URL::to("/data-omspan/upload"))->with('success','Data Omspan berhasil diupload.'); }catch(\Exception $e){ throw new \Exception($e->getMessage()); DB::rollBack(); return redirect(URL::to("/data-omspan/upload"))->with('error',$e->getMessage()); } } }