publikasi jurnal

parent bf5a22d7
......@@ -275,7 +275,7 @@ class PenelitianSumberDanaController extends Controller
if (!is_null($dosen) && $request->name == 'dosen') {
$store['jenis'] = $dosen->jenis;
$store['nama'] = $dosen->nama;
$store['nama'] = $dosen->name;
} elseif (is_null($dosen) && $request->name == 'non_dosen') {
$store['jenis'] = 'l';
......
......@@ -3,7 +3,13 @@
namespace App\Http\Controllers\User;
use App\Http\Controllers\Controller;
use App\Models\Biodata;
use App\Models\User\PublikasiJurnal;
use App\Models\User\PublikasiJurnalAnggota;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Validator;
class PublikasiJurnalController extends Controller
{
......@@ -14,8 +20,8 @@ class PublikasiJurnalController extends Controller
*/
public function index()
{
//
return view('user.publikasijurnal.index');
$data['rs'] = PublikasiJurnal::query()->orderBy('updated_at', 'desc')->get();
return view('user.publikasijurnal.index', $data);
}
/**
......@@ -26,7 +32,8 @@ class PublikasiJurnalController extends Controller
public function create()
{
//
return view('user.publikasijurnal.create');
$data['edit'] = false;
return view('user.publikasijurnal.create', $data);
}
/**
......@@ -37,7 +44,144 @@ class PublikasiJurnalController extends Controller
*/
public function store(Request $request)
{
//
$data = $request->except('_token');
Validator::make($data, PublikasiJurnal::RULES, PublikasiJurnal::ERROR_MESSAGES)->validate();
$data['userid_created'] = Auth::user()->id;
$data['userid_updated'] = Auth::user()->id;
$data['halaman'] = abs($data['halaman1']).'-'.abs($data['halaman2']);
try{
$publikasi = PublikasiJurnal::query()->create($data);
return redirect()->route('publikasijurnal.next-form', ['id' => encrypt($publikasi->id)]);
}
catch(Exception $ex){
return redirect()->back()->withInput();
}
return redirect()->back()->withInput();
}
public function nextForm(Request $request, $id)
{
$anggota = PublikasiJurnalAnggota::query()->with('biodata')->where('publikasijurnal_id', decrypt($id))->get();
if(count($anggota) < 1 || is_null($request->next_state)){
$data['id'] = $id;
$data['keanggotaan'] = PublikasiJurnalAnggota::KEANGGOTAAN;
$data['dosen_anggota'] = $anggota->whereNotNull('nidn');
$data['non_dosen_anggota'] = $anggota->whereNull('nidn');
return view('user.publikasijurnal.create_anggota', $data);
}
else if($request->next_state == 'finish' && count($anggota) > 0){
return redirect()->route('publikasijurnal.index');
}
}
public function editAnggota(Request $request, $id)
{
$anggota = PublikasiJurnalAnggota::query()->with('biodata')->where('publikasijurnal_id', decrypt($id))->get();
$data['id'] = $id;
$data['keanggotaan'] = PublikasiJurnalAnggota::KEANGGOTAAN;
$data['dosen_anggota'] = $anggota->whereIn('jenis', ['t', 'd']);
$data['non_dosen_anggota'] = $anggota->whereIn('jenis', ['l']);
return view('user.publikasijurnal.create_anggota', $data);
}
public function deleteAnggota(Request $request)
{
try{
$anggota = PublikasiJurnalAnggota::query()->find(decrypt($request->id))->delete();
return response('Success', 200);
}
catch(Exception $ex){
return response('Error', 500);
}
}
public function simpanAnggota(Request $request, $id)
{
$allAnggota = PublikasiJurnalAnggota::where('publikasijurnal_id', decrypt($id))->get();
$anggota = $allAnggota->where('nidn', $request->nidn);
$ketua = $allAnggota->where('peran', PublikasiJurnalAnggota::KEANGGOTAAN['k']);
if( count($ketua) > 0 && $request->keanggotaan == PublikasiJurnalAnggota::KEANGGOTAAN['k']){
return response('Ketua tidak boleh lebih dari satu', 500);
}
if(count($anggota) < 1 || is_null($request->nidn)){
$dosen = null;
if(!is_null($request->nidn)){
$dosen = Biodata::query()->where('nidn', $request->nidn)->first();
}
$data = $this->arrayDataAnggota($request);
$store = $this->getStoredArrayDataAnggota($request, $id, $dosen);
if(is_null($dosen) && $request->name == 'dosen'){
return response('NIDN tidak terdaftar sebagai dosen atau belum tervalidasi', 500);
}
elseif(!is_null($dosen) && $request->name == 'non_dosen'){
return response('NIDN terdaftar sebagai dosen', 500);
}
try{
Validator::make($store, PublikasiJurnalAnggota::RULES, PublikasiJurnalAnggota::ERROR_MESSAGES)->validate();
$anggota = PublikasiJurnalAnggota::query()->create($store);
$data['id'] = $anggota->id;
return view('user.publikasijurnal.row_anggota', $data);
}
catch(Exception $ex){
return response('Data yang diberikan tidak lengkap atau tidak valid', 500);
}
}
return response('Data sudah ada', 500);
}
private function arrayDataAnggota(Request $request)
{
$data['no'] = $request->no;
$data['nama'] = $request->nama;
$data['keanggotaan'] = $request->keanggotaan;
$data['prodi'] = $request->prodi;
$data['nidn'] = encrypt($request->nidn);
$data['name'] = $request->name;
return $data;
}
public function getStoredArrayDataAnggota(Request $request, $id, $dosen)
{
$store['publikasijurnal_id'] = decrypt($id);
$store['nidn'] = $request->nidn;
$store['peran'] = $request->keanggotaan;
if (!is_null($dosen) && $request->name == 'dosen') {
$store['jenis'] = $dosen->jenis;
$store['nama'] = $dosen->name;
} elseif (is_null($dosen) && $request->name == 'non_dosen') {
$store['jenis'] = 'l';
$store['institusi'] = $request->prodi;
$store['nama'] = $request->nama;
}
return $store;
}
/**
......@@ -59,7 +203,9 @@ class PublikasiJurnalController extends Controller
*/
public function edit($id)
{
//
$data['data'] = PublikasiJurnal::query()->find(decrypt($id));
$data['edit'] = true;
return view('user.publikasijurnal.create', $data);
}
/**
......@@ -71,7 +217,20 @@ class PublikasiJurnalController extends Controller
*/
public function update(Request $request, $id)
{
//
$data = $request->except('_token');
Validator::make($data, PublikasiJurnal::RULES, PublikasiJurnal::ERROR_MESSAGES)->validate();
$data['userid_updated'] = Auth::user()->id;
$data['halaman'] = abs($data['halaman1']).'-'.abs($data['halaman2']);
try{
PublikasiJurnal::query()->find(decrypt($id))->update($data);
return redirect()->route('publikasijurnal.index');
}
catch(Exception $ex){
return redirect()->back()->withInput();
}
}
/**
......
<?php
namespace App\Models\User;
use App\Traits\UuidTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class PublikasiJurnal extends Model
{
use HasFactory;
use UuidTrait;
public $incrementing = false;
protected $table = 'publikasijurnal';
protected $keyType = 'string';
protected $fillable = ['judul', 'nama_jurnal', 'nomor', 'issn', 'volume', 'halaman', 'url', 'userid_created', 'user_id_updated'];
public const RULES = [
'judul' => 'required',
'nama_jurnal' => 'required',
'nomor' => 'required',
'issn' => 'required',
'volume' => 'required',
'halaman1' => 'required',
'halaman2' => 'required',
'url' => 'required'
];
public const ERROR_MESSAGES = [
'judul.required' => 'judul tidak boleh kosong',
'nama_jurnal.required' => 'nama jurnal tidak boleh kosong',
'nomor.required' => 'nomor tidak boleh kosong',
'issn.required' => 'issn tidak boleh kosong',
'volume.required' => 'volume tidak boleh kosong',
'halaman1.required' => 'halaman tidak boleh kosong',
'halaman2.required' => 'halaman tidak boleh kosong',
'url.required' => 'url tidak boleh kosong'
];
public function anggota()
{
return $this->hasMany(PublikasiJurnalAnggota::class, 'publikasijurnal_id', 'id');
}
}
<?php
namespace App\Models\User;
use App\Models\Biodata;
use App\Traits\UuidTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class PublikasiJurnalAnggota extends Model
{
use HasFactory;
use UuidTrait;
public $incrementing = false;
protected $table = 'publikasijurnal_anggota';
protected $keyType = 'string';
protected $fillable = [
'nama', 'publikasijurnal_id', 'nidn', 'peran', 'tugas', 'institusi', 'jenis', 'userid_created', 'userid_updated', 'created_at', 'updated_at',
];
public const RULES = [
'nama' => 'required',
'publikasijurnal_id' => 'required',
'peran' => 'required',
'jenis' => 'required'
];
public const ERROR_MESSAGES = [
'nama.required' => 'nama tidak boleh kosong',
'publikasijurnal_id.required' => 'publikasijurnal tidak boleh kosong',
'peran.required' => 'peran tidak boleh kosong',
'jenis' => 'jenis tidak boleh kosong'
];
public const KEANGGOTAAN = [
'k'=>'Ketua',
'a'=>'Anggota'
];
public function biodata()
{
return $this->belongsTo(Biodata::class, 'nidn', 'nidn');
}
}
......@@ -134,8 +134,8 @@
<div class="account-settings-footer">
<div class="as-footer-container">
<button id="multiple-reset" class="btn btn-warning">Batal</button>
<button id="multiple-messages" class="btn btn-primary">Simpan</button>
<a href="{{ route('publikasijurnal.index') }}" id="multiple-reset" class="btn btn-warning">Batal</a>
<button type="submit" id="multiple-messages" class="btn btn-primary">Simpan</button>
</div>
</div>
</form>
......
......@@ -18,6 +18,7 @@
<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing">
<div class="widget-content widget-content-area br-6">
<div class="table-responsive mb-4 mt-4">
<a href="{{ url('penelitiansumber/create') }}" class="btn btn-primary mb-2"><i data-feather="file-plus"></i> Tambah</a>
<table id="zero-config" class="table table-hover" style="width:100%">
<thead>
<tr>
......
......@@ -18,130 +18,43 @@
<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing">
<div class="widget-content widget-content-area br-6">
<div class="table-responsive mb-4 mt-4">
<a href="{{ url('publikasijurnal/create') }}" class="btn btn-primary mb-2"><i data-feather="file-plus"></i> Tambah</a>
<table id="zero-config" class="table table-hover" style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
<th>No.</th>
<th>Judul</th>
<th>Nama Jurnal</th>
<th>ISSN</th>
<th>Volume</th>
<th>Nomor</th>
<th>Halaman</th>
<th>URL</th>
<th>Aksi</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011/07/25</td>
<td>$170,750</td>
</tr>
<tr>
<td>Ashton Cox</td>
<td>Junior Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2009/01/12</td>
<td>$86,000</td>
</tr>
<tr>
<td>Cedric Kelly</td>
<td>Senior Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td>
<td>2012/03/29</td>
<td>$433,060</td>
</tr>
<tr>
<td>Airi Satou</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>33</td>
<td>2008/11/28</td>
<td>$162,700</td>
</tr>
<tr>
<td>Brielle Williamson</td>
<td>Integration Specialist</td>
<td>New York</td>
<td>61</td>
<td>2012/12/02</td>
<td>$372,000</td>
</tr>
<tr>
<td>Herrod Chandler</td>
<td>Sales Assistant</td>
<td>San Francisco</td>
<td>59</td>
<td>2012/08/06</td>
<td>$137,500</td>
</tr>
<tr>
<td>Rhona Davidson</td>
<td>Integration Specialist</td>
<td>Tokyo</td>
<td>55</td>
<td>2010/10/14</td>
<td>$327,900</td>
</tr>
<tr>
<td>Colleen Hurst</td>
<td>Javascript Developer</td>
<td>San Francisco</td>
<td>39</td>
<td>2009/09/15</td>
<td>$205,500</td>
</tr>
<tr>
<td>Sonya Frost</td>
<td>Software Engineer</td>
<td>Edinburgh</td>
<td>23</td>
<td>2008/12/13</td>
<td>$103,600</td>
</tr>
<tr>
<td>Jena Gaines</td>
<td>Office Manager</td>
<td>London</td>
<td>30</td>
<td>2008/12/19</td>
<td>$90,560</td>
</tr>
<tr>
<td>Quinn Flynn</td>
<td>Support Lead</td>
<td>Edinburgh</td>
<td>22</td>
<td>2013/03/03</td>
<td>$342,000</td>
</tr>
<tr>
<td>Charde Marshall</td>
<td>Regional Director</td>
<td>San Francisco</td>
<td>36</td>
<td>2008/10/16</td>
<td>$470,600</td>
</tr>
<tr>
<td>Haley Kennedy</td>
<td>Senior Marketing Designer</td>
<td>London</td>
<td>43</td>
<td>2012/12/18</td>
<td>$313,500</td>
</tr>
@foreach ($rs as $item)
<tr>
<td>{{ $loop->iteration }}</td>
<td>{{ $item->judul }}</td>
<td>{{ $item->nama_jurnal }}</td>
<td>{{ $item->issn }}</td>
<td>{{ $item->volume }}</td>
<td>{{ $item->nomor }}</td>
<td>{{ $item->halaman }}</td>
<td>{{ $item->url }}</td>
<td>
<a class="btn btn-sm btn-warning" href="{{ route('publikasijurnal.edit', ['publikasijurnal' => encrypt($item->id)]) }}">Edit</a>
<a class="btn btn-sm btn-warning" href="{{ route('publikasijurnal.edit-anggota', ['id' => encrypt($item->id)]) }}">Edit Anggota</a>
<button class="btn btn-sm btn-danger delete" type="button" data-target="form_penelitian_{{ $loop->iteration }}">Hapus</button>
<form id="form_penelitian_{{ $loop->iteration }}" action="{{ route('publikasijurnal.destroy', ['publikasijurnal' => encrypt($item->id)]) }}" method="POST">
{{ method_field('DELETE') }}
@csrf
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
......
@php
$token = Str::random(10)
@endphp
<tr id="{{ $name }}_{{ $token }}">
<td>{{ $no }}</td>
<td>{{ $nama }}</td>
<td>
{{ $prodi }}
</td>
<td class="text-center">{{ $keanggotaan }}</td>
<td>
<button class="btn btn-sm btn-danger" type="button" onclick="deleteAnggota('{{ encrypt($id) }}', '{{ $name }}_{{ $token }}')">Hapus</button>
</td>
</tr>
......@@ -46,15 +46,22 @@ Route::middleware(['auth:sanctum', 'verified'])->group(function () {
Route::resource('/fasilitas', FasilitasController::class);
Route::resource('/kekayaanintelek', KekayaanIntelController::class);
Route::resource('/kontrakkerja', KontrakKerjaController::class);
Route::resource('/penelitiansumber', PenelitianSumberDanaController::class);
Route::get('/penelitiansumber/next-form/{id}', [PenelitianSumberDanaController::class, 'nextForm'])->name('penelitiansumber.next-form');
Route::get('/penelitiansumber/edit-anggota/{id}', [PenelitianSumberDanaController::class, 'editAnggota'])->name('penelitiansumber.edit-anggota');
Route::post('/penelitiansumber/simpan-anggota/{id}', [PenelitianSumberDanaController::class, 'simpanAnggota'])->name('penelitiansumber.simpan-anggota');
Route::post('/penelitiansumber/delete-anggota', [PenelitianSumberDanaController::class, 'deleteAnggota'])->name('penelitiansumber.delete-anggota');
Route::post('/penelitiansumber/cek-simpan-anggota', [PenelitianSumberDanaController::class, 'cekSimpanAnggota'])->name('penelitiansumber.cek-simpan-anggota');
Route::resource('/penelitiasing', PenelitiAsingController::class);
Route::resource('/publikasiartikel', PublikasiArtikelController::class);
Route::resource('/publikasijurnal', PublikasiJurnalController::class);
Route::get('/publikasijurnal/next-form/{id}', [PublikasiJurnalController::class, 'nextForm'])->name('publikasijurnal.next-form');
Route::get('/publikasijurnal/edit-anggota/{id}', [PublikasiJurnalController::class, 'editAnggota'])->name('publikasijurnal.edit-anggota');
Route::post('/publikasijurnal/simpan-anggota/{id}', [PublikasiJurnalController::class, 'simpanAnggota'])->name('publikasijurnal.simpan-anggota');
Route::post('/publikasijurnal/delete-anggota', [PublikasiJurnalController::class, 'deleteAnggota'])->name('publikasijurnal.delete-anggota');
Route::resource('/penyelenggaraseminar', PenyelenggaraanSeminarController::class);
Route::resource('/stafpendukung', StafPendukungController::class);
Route::resource('/unitbisnis', UnitBisnisController::class);
......
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