Update
This commit is contained in:
@@ -1,119 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Models\DataUploadBosOmspan;
|
||||
use App\Models\UploadData;
|
||||
use App\Imports\ImportDataBos;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
class UploadDataController extends Controller
|
||||
{
|
||||
public function __construct(){
|
||||
$this->siteTitle = "Upload Data";
|
||||
parent::__construct();
|
||||
$this->setIconTitle("fa fa-share");
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$method = $request->method();
|
||||
$this->setTitle("Upload Data");
|
||||
$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("/admin/upload-data/"))->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('admin.upload_data.index');
|
||||
}
|
||||
|
||||
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(kode_skpd) LIKE '%".strtolower($src)."%'
|
||||
// OR LOWER(nama_skpd) LIKE '%".strtolower($src)."%'
|
||||
// OR LOWER(kode_rekening) LIKE '%".strtolower($src)."%'
|
||||
// OR LOWER(nama_rekening) 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();
|
||||
|
||||
UploadData::where("tahun",getTA())->delete();
|
||||
DB::statement("INSERT INTO upload_data(tahun,kode_skpd,kode_rekening,total_lra)
|
||||
SELECT tahun,kode_skpd,kode_rekening,total_lra FROM tmp_upload_data ");
|
||||
|
||||
$skpds = DB::table('tmp_upload_data')->distinct()->select('kode_skpd')->get();
|
||||
foreach($skpds as $skpd){
|
||||
// CEK MAIN INDIKATOR
|
||||
$txIndikator = TxIndikator::firstOrCreate(["tahun"=>getTA(),"kode_skpd"=>$skpd->kode_skpd],[
|
||||
"status_approval"=>3, // Operator
|
||||
]);
|
||||
|
||||
$calculation = new CalculationIndikator($txIndikator->id);
|
||||
$calculation->rasio();
|
||||
$calculation->summary();
|
||||
}
|
||||
TempUploadData::truncate();
|
||||
DB::commit();
|
||||
return redirect(URL::to("/admin/upload-data"))->with('success','Data Realisasi belanja berhasil diupload.');
|
||||
}catch(\Exception $e){
|
||||
throw new \Exception($e->getMessage());
|
||||
DB::rollBack();
|
||||
return redirect(URL::to("/admin/upload-data"))->with('error',$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Models\DataUploadBosOmspan;
|
||||
use App\Models\DataBosOmspan;
|
||||
use App\Models\UploadData;
|
||||
use App\Imports\ImportDataBos;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
class DataBosOmspanController extends Controller
|
||||
{
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->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("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
|
||||
)
|
||||
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
|
||||
FROM DATA_UPLOAD_BOS_OMSPAN
|
||||
WHERE NOT EXISTS(
|
||||
SELECT *
|
||||
FROM DATA_BOS_OMSPAN
|
||||
WHERE (tahun ='".getTA()."' AND DATA_BOS_OMSPAN.no_tgl_sp2d_detail = DATA_UPLOAD_BOS_OMSPAN.no_tgl_sp2d_detail)
|
||||
)");
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user