Commit 340aba89 by Triyah Fatmawati

Change connection to DB SIMEPK

parent 2af73e7a
......@@ -6,6 +6,8 @@
use App\Http\Controllers\Controller;
use App\Models\Admin\Penelaah;
use App\Models\Admin\Pengajuan;
use App\Models\VPenelaah;
use App\Models\VPengusul;
use Exception;
use Storage;
use Session;
......@@ -21,21 +23,27 @@ public function index(Request $request) {
$filter_periode = DB::table('ms_periode')->orderBy('periode','asc')->get();
Session::put('status', $request->status);
Session::put('periode', $request->periode);
Session::put('status', $request->status);
Session::put('periode', $request->periode);
if(empty(Session::get('status'))) {
if(empty(Session::get('periode'))){
$periode = DB::table('ms_periode')->where('is_aktif', 1)->first();
Session::put('periode', $periode->periode);
} else {
$periode = DB::table('ms_periode')->where('periode', Session::get('periode'))->first();
}
$pengusul = DB::table('bantuan_pengusul')
->whereBetween('tanggal_keputusan', [$periode->tanggal_awal, $periode->tanggal_akhir])
->get();
// v0
// $pengusul = DB::table('bantuan_pengusul')
// ->whereBetween('tanggal_keputusan', [$periode->tanggal_awal, $periode->tanggal_akhir])
// ->get();
// v1
$pengusul = VPengusul::with('penelaah')
->whereBetween('tanggal_keputusan', [$periode->tanggal_awal, $periode->tanggal_akhir])
->get();
} else {
......@@ -54,8 +62,15 @@ public function index(Request $request) {
$periode = DB::table('ms_periode')->where('periode', Session::get('periode'))->first();
}
$pengusul = DB::table('bantuan_pengusul')
->whereIn('id_pengajuan',$list)
// v0
// $pengusul = DB::table('bantuan_pengusul')
// ->whereIn('id_pengajuan',$list)
// ->whereBetween('tanggal_keputusan', [$periode->tanggal_awal, $periode->tanggal_akhir])
// ->get();
// v1
$pengusul = VPengusul::with('penelaah')
->whereIn('id_pengajuan', $list)
->whereBetween('tanggal_keputusan', [$periode->tanggal_awal, $periode->tanggal_akhir])
->get();
......@@ -67,10 +82,17 @@ public function index(Request $request) {
$periode = DB::table('ms_periode')->where('periode', Session::get('periode'))->first();
}
$pengusul = DB::table('bantuan_pengusul')
->whereNotIn('id_pengajuan',$list)
->whereBetween('tanggal_keputusan', [$periode->tanggal_awal, $periode->tanggal_akhir])
->get();
// v0
// $pengusul = DB::table('bantuan_pengusul')
// ->whereNotIn('id_pengajuan',$list)
// ->whereBetween('tanggal_keputusan', [$periode->tanggal_awal, $periode->tanggal_akhir])
// ->get();
// v1
$pengusul = VPengusul::with('penelaah')
->whereNotIn('id_pengajuan',$list)
->whereBetween('tanggal_keputusan', [$periode->tanggal_awal, $periode->tanggal_akhir])
->get();
}
......@@ -88,26 +110,26 @@ public function index(Request $request) {
}
public function store(Request $request){
$rule = [
'kategori' => 'required',
'file_ec' => 'required|mimes:pdf|max:3072',
'nosurat' => 'required'
];
$request->validate($rule, ValidationRule::getErrorMessage($rule));
DB::beginTransaction();
try{
if($request->hasFile('file_ec')){
$file = $request->file('file_ec');
$filename = $file->getClientOriginalName();
$path_dir = 'sipeka/file/';
$move = $request->file('file_ec')->move($path_dir,$filename);
// $cek = Storage::disk('uploads')->put('sipeka/'.$filename, file_get_contents($file->getRealPath()));
// dd($cek);
}
......@@ -122,15 +144,19 @@ public function store(Request $request){
'file_ec' => $filename,
'no_sk' => $request->nosurat,
];
Pengajuan::query()->create($transaksi);
$hasil = DB::table('tr_pengajuan')->where('id_pengajuan',$request->idpengajuan)->first();
$reviewer = DB::table('bantuan_penelaah')->where('id_pengajuan',$request->idpengajuan)->pluck('nik');
$hasil = Pengajuan::query()->create($transaksi);
// $hasil = DB::table('tr_pengajuan')->where('id_pengajuan',$request->idpengajuan)->first();
// v0
// $reviewer = DB::table('bantuan_penelaah')->where('id_pengajuan',$request->idpengajuan)->pluck('nik');
// v1
$reviewer = VPenelaah::where('id_pengajuan', $request->idpengajuan)->pluck('nik');
$count = DB::connection('isdm')->table('v_detil_pegawai')->whereIn('noktp',$reviewer)->select('noktp')->get();
if(count($count) >= 2){
foreach($count as $sdm){
$isdm = DB::connection('isdm')->table('v_detil_pegawai')->where('noktp',$sdm->noktp)->select('namalengkap','nip','namaparentsatker')->first();
......@@ -145,25 +171,25 @@ public function store(Request $request){
Penelaah::query()->create($saku);
}
} else {
foreach($count as $sdm){
$data['kosong'] = DB::table('bantuan_penelaah')->where('id_pengajuan',$request->idpengajuan)->where('nik','!=', $sdm->noktp)->first();
}
return view('transaksi-gagal', $data);
}
DB::commit();
return Redirect::route('transaksi.index')
->with('success', 'Data kategori berhasil diupdate');
}
catch(Exception $e){
Log::error($e);
DB::rollBack();
return Redirect::route('transaksi.index')
->with('error', 'Data Kategori gagal diupdate');
}
......
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class VPenelaah extends Model
{
protected $connection = 'epk';
protected $table = 'v_penelaah_v0';
protected $primaryKey = 'id_pengajuan';
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class VPengusul extends Model
{
protected $connection = 'epk';
protected $table = 'v_pengusul';
protected $primaryKey = 'id_pengajuan';
public function penelaah()
{
return $this->hasMany(VPenelaah::class, 'id_pengajuan', 'id_pengajuan');
}
}
......@@ -105,30 +105,46 @@
'schema' => 'public',
],
// 'epk' => [
// 'driver' => 'mysql',
// 'host' => env('DB_HOST_EPK', 'localhost'),
// 'port' => env('DB_PORT_EPK', '3306'),
// 'database' => env('DB_DATABASE_EPK', 'forge'),
// 'username' => env('DB_USERNAME_EPK', 'forge'),
// 'password' => env('DB_PASSWORD_EPK', ''),
// 'charset' => 'utf8',
// 'collation' => 'utf8_unicode_ci',
// 'prefix' => '',
// 'strict' => false,
// 'engine' => null,
// 'options' => [
// \PDO::MYSQL_ATTR_LOCAL_INFILE => true,
// ],
// ],
'epk' => [
'driver' => 'mysql',
'host' => env('DB_HOST_EPK', 'localhost'),
'host' => env('DB_HOST_EPK', '127.0.0.1'),
'port' => env('DB_PORT_EPK', '3306'),
'database' => env('DB_DATABASE_EPK', 'forge'),
'username' => env('DB_USERNAME_EPK', 'forge'),
'password' => env('DB_PASSWORD_EPK', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'prefix' => '',
'strict' => false,
'strict' => true,
'engine' => null,
'options' => [
\PDO::MYSQL_ATTR_LOCAL_INFILE => true,
],
],
'ssh' => [
'host' => env('SSH_HOST'),
'port' => env('SSH_PORT'),
'username' => env('SSH_USER'),
'key' => env('SSH_KEY'),
],
],
......
......@@ -53,7 +53,7 @@
</div>
</div>
</div>
<div class="table-responsive mb-4">
<table id="datatable" class="table data-table table-hover" style="width:100%">
......@@ -67,8 +67,8 @@
<th style="text-align: left">Peneliti</th>
<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">Kategori</th>
<th style="text-align: left">Klasifikasi</th>
<th style="text-align: left">Kategori</th>
</tr>
</thead>
<tbody>
......@@ -77,15 +77,19 @@
<tr>
<td>{{ $no }}</td>
<td style="text-align: left">{{ $item->judul }}</td>
<td style="text-align: left">{{ $item->peneliti_utama }}</td>
{{-- <td style="text-align: left">{{ $item->peneliti_utama }}</td> --}}
<td style="text-align: left">{{ $item->ketua }}</td>
<td style="text-align: left">{{ date('Y',strtotime($item->tanggal_keputusan)) }}</td>
@php
{{-- @php
$penelaah = DB::table('bantuan_penelaah')->where('id_pengajuan', $item->id_pengajuan)->get();
@endphp
@endphp --}}
<td style="text-align: left">
@foreach($penelaah as $p)
{{-- @foreach($penelaah as $p)
{{ $p->penelaah.";" }}<br><br>
@endforeach
@endforeach --}}
@foreach ($item->penelaah as $rev)
{{ $rev->penelaah.";" }}<br><br>
@endforeach
</td>
<td style="text-align: left">{{ $item->klasifikasi }}</td>
@php
......@@ -102,7 +106,7 @@
<td style="text-align: left">{{ $kat->nama_kategori }}</td>
@endif
</tr>
<!-- edit registrasi modal -->
<div class="modal fade" id="updateKategoriModal{{ $item->id_pengajuan }}" tabindex="-1" aria-labelledby="updateKategori" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg">
......@@ -122,7 +126,9 @@
</div>
<div class="col-md-12">
<label class="form-label" for="peneliti">Peneliti</label>
<input type="text" class="form-control" id="peneliti" name="peneliti" value="{{ $item->peneliti_utama }}" readonly />
{{-- <input type="text" class="form-control" id="peneliti" name="peneliti" value="{{ $item->peneliti_utama }}" readonly /> --}}
<input type="text" class="form-control" id="peneliti" name="peneliti" value="{{ $item->ketua }}" readonly />
</div>
<div class="col-md-6">
<label class="form-label" for="tahun">Tahun</label>
......
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