Commit b702422a by Siti Aisah

tarik saku

parent 685c324f
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Support\ValidationRule;
use App\Http\Controllers\Controller;
use App\Models\Admin\Pengajuan;
use Exception;
use Storage;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redirect;
class SakuController extends Controller
{
public function index() {
$pengusul = DB::table('bantuan_pengusul')->get();
$kategori = DB::table('ms_kategori')->orderBy('kode_kategori','asc')->get();
$data = [
'pengusul' => $pengusul,
'kategori' => $kategori
];
return view('transaksi.index', $data);
}
}
<?php
namespace App\Http\Controllers;
namespace App\Http\Controllers\Admin;
use App\Http\Support\ValidationRule;
use App\Http\Controllers\Controller;
use App\Models\Admin\Penelaah;
use App\Models\Admin\Pengajuan;
use Exception;
use Storage;
......@@ -28,42 +29,58 @@ public function index() {
}
public function store(Request $request){
$rule = [
'kategori' => 'required',
'file_ec' => 'required',
'nosurat' => 'required'
];
$request->validate($rule, ValidationRule::getErrorMessage($rule));
DB::beginTransaction();
if($request->hasFile('file_ec')){
$file = $request->file('file_ec');
$filename = $file->getClientOriginalName();
Storage::disk('uploads')->put('sipeka/'.$filename, file_get_contents($file->getRealPath()));
}
try{
$transaksi = [
'id_pengajuan' => $request->idpengajuan,
'judul' => $request->judul,
'pengusul' => $request->pengusul,
'klasifikasi' => $request->klasifikasi,
'tahun' => $request->tahun,
'id_kategori' => $request->kategori,
'file_ec' => $filename,
'no_sk' => $request->nosurat,
];
Pengajuan::query()->create($transaksi);
DB::commit();
return Redirect::route('transaksi.index')
// if($request->hasFile('file_ec')){
// $file = $request->file('file_ec');
// $filename = $file->getClientOriginalName();
// Storage::disk('uploads')->put('sipeka/'.$filename, file_get_contents($file->getRealPath()));
// }
try{
$transaksi = [
'id_pengajuan' => $request->idpengajuan,
'judul' => $request->judul,
'pengusul' => $request->pengusul,
'klasifikasi' => $request->klasifikasi,
'tahun' => $request->tahun,
'id_kategori' => $request->kategori,
// 'file_ec' => $filename,
'no_sk' => $request->nosurat,
];
Pengajuan::query()->create($transaksi);
$hasil = DB::table('tr_pengajuan')->where('id_pengajuan',$request->idpengajuan)->get();
$reviewer = DB::table('bantuan_penelaah')->where('id_pengajuan',$request->idpengajuan)->get();
foreach($reviewer as $r){
$isdm = DB::connection('isdm')->table('v_detil_pegawai')->where('noktp',$r->nik)->select('namalengkap','nip')->first();
$saku = [
'id_pengajuan' => $hasil->id,
'nik' => $r->nik,
'nama' => $isdm->namalengkap,
'nip' => $isdm->nip
];
Penelaah::query()->create($saku);
}
DB::commit();
return Redirect::route('transaksi.index')
->with('success', 'Data kategori berhasil diupdate');
}
catch(Exception $e){
......@@ -71,7 +88,7 @@ public function store(Request $request){
DB::rollBack();
return Redirect::route('transaksi.index')
->with('error', 'Data kategori gagal diupdate');
->with('error', 'Data kategori gagal diupdate');
}
}
}
......@@ -15,5 +15,11 @@ class Penelaah extends Model
protected $table = 'tr_penelaah';
protected $keyType = 'string';
protected $guarded = [];
protected $fillable = [
'id',
'id_pengajuan',
'nik',
'nama',
'nip'
];
}
......@@ -13,7 +13,7 @@
<ul class="dropdown-menu" data-bs-popper="none">
<li data-menu="" class="{{ (request()->getRequestUri() == "/transaksi") ? 'active' : '' }}"><a href="{{ route('transaksi.index') }}" class="dropdown-item d-flex align-items-center" data-bs-toggle="" data-i18n="Email" ><i data-feather="check-square"></i><span data-i18n="Email">Update Kategori</span></a>
</li>
<li data-menu="" class="{{ (request()->is('pasien/antrian')) ? 'active' : '' }}"><a href="#" class="dropdown-item d-flex align-items-center" data-bs-toggle="" data-i18n="Todo" ><i data-feather='log-in'></i><span data-i18n="Todo">Tarik Data SAKU</span></a>
<li data-menu="" class="{{ (request()->getRequestUri() == "/saku") ? 'active' : '' }}"><a href="{{ route('saku.index') }}" class="dropdown-item d-flex align-items-center" data-bs-toggle="" data-i18n="Todo" ><i data-feather='log-in'></i><span data-i18n="Todo">Tarik Data SAKU</span></a>
</li>
</ul>
</li>
......
......@@ -35,7 +35,7 @@
<th style="text-align: left">Tahun</th>
<th style="text-align: left">Reviewer</th>
<th style="text-align: left">Klasifikasi</th>
<th style="text-align: left">Update Kategori</th>
<th style="text-align: left">Kategori</th>
</tr>
</thead>
<tbody>
......@@ -54,9 +54,19 @@
@endforeach
</td>
<td style="text-align: left">{{ $item->klasifikasi }}</td>
@php
$pengajuan = DB::table('tr_pengajuan')->where('id_pengajuan',$item->id_pengajuan)->first();
@endphp
@if(empty($pengajuan))
<td>
<button type="button" class="btn btn-warning btn-sm" data-bs-toggle="modal" data-bs-target="#updateKategoriModal{{ $item->id_pengajuan }}"><i data-feather='edit'></i></button>
</td>
@else
@php
$kat = DB::table('ms_kategori')->where('id',$pengajuan->id_kategori)->first();
@endphp
<td style="text-align: left">{{ $kat->nama_kategori }}</td>
@endif
</tr>
<!-- edit registrasi modal -->
......
<?php
use App\Http\Controllers\Admin\KategoriController;
use App\Http\Controllers\TransaksiController;
use App\Http\Controllers\Admin\TransaksiController;
use App\Http\Controllers\Admin\SakuController;
use Illuminate\Support\Facades\Route;
/*
......@@ -24,5 +25,6 @@
// Admin
Route::resource('kategori', KategoriController::class);
Route::resource('transaksi', TransaksiController::class);
Route::resource('saku', SakuController::class);
// End of Admin
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment