Commit 4fa7e3ab by Farendi Giotivano R.P

data master & profile

parents f675d949 341c9acd
......@@ -45,11 +45,19 @@ class KekayaanIntelController extends Controller
Validator::make($data, KekayaanIntelektual::RULES, KekayaanIntelektual::ERROR_MESSAGES)->validate();
try {
$biodata = Biodata::query()->where('nidn', $request->nidn)->firstOrFail();
$data['userid_created'] = Auth::user()->id;
$data['userid_updated'] = Auth::user()->id;
KekayaanIntelektual::query()->create($data);
alert()->success('Berhasil', 'Kekayaan intelektual berhasil disimpan');
} catch (Exception $ex) {
alert()->error('Gagal', 'Kekayaan intelektual gagal disimpan');
return redirect()->back()->withInput();
}
......@@ -104,8 +112,15 @@ class KekayaanIntelController extends Controller
$biodata = Biodata::query()->where('nidn', $request->nidn)->firstOrFail();
$kekayaan = KekayaanIntelektual::query()->findOrFail(decrypt($id));
$data['userid_updated'] = Auth::user()->id;
$kekayaan->update($data);
alert()->success('Berhasil', 'Kekayaan intelektual berhasil disimpan');
} catch (Exception $ex) {
alert()->error('Gagal', 'Kekayaan intelektual gagal disimpan');
return redirect()->back()->withInput();
}
......@@ -124,7 +139,12 @@ class KekayaanIntelController extends Controller
try {
$kekayaan = KekayaanIntelektual::query()->findOrFail(decrypt($id));
$kekayaan->delete();
alert()->success('Berhasil', 'Kekayaan intelektual berhasil dihapus');
} catch (Exception $ex) {
alert()->error('Gagal', 'Kekayaan intelektual gagal dihapus');
}
return redirect()->route('kekayaanintelek.index');
......
......@@ -10,6 +10,8 @@ use App\Models\User\PenelitiAsing;
use Exception;
use Illuminate\Http\Request;
use Validator;
use Alert;
use Illuminate\Support\Facades\Auth;
class PenelitiAsingController extends Controller
{
......@@ -21,6 +23,7 @@ class PenelitiAsingController extends Controller
public function index()
{
$data['rs'] = PenelitiAsing::query()->with(['negara', 'bidang'])->orderBy('updated_at')->get();
return view('user.penelitiasing.index', $data);
}
......@@ -49,7 +52,9 @@ class PenelitiAsingController extends Controller
public function store(Request $request)
{
$data = $request->except('_token');
Validator::make($data, PenelitiAsing::RULES, PenelitiAsing::ERROR_MESSAGES)->validate();
$data['bidang_id'] = decrypt($data['bidang_id']);
$data['negara_id'] = decrypt($data['negara_id']);
$data['userid_created'] = Auth::user()->id;
......@@ -57,9 +62,15 @@ class PenelitiAsingController extends Controller
try{
PenelitiAsing::query()->create($data);
Alert::success('Berhasil', 'Peneliti asing berhasil disimpan');
return redirect()->route('penelitiasing.index');
}
catch(Exception $ex){
alert()->error('Gagal', 'Peneliti asing gagal disimpan');
return redirect()->back()->withInput();
}
}
......@@ -111,9 +122,15 @@ class PenelitiAsingController extends Controller
try{
PenelitiAsing::query()->find(decrypt($id))->update($data);
alert()->success('Berhasil', 'Peneliti asing berhasil disimpan');
return redirect()->route('penelitiasing.index');
}
catch(Exception $ex){
alert()->error('Gagal', 'Peneliti asing gagal disimpan');
return redirect()->back()->withInput();
}
}
......@@ -129,9 +146,15 @@ class PenelitiAsingController extends Controller
{
try{
PenelitiAsing::query()->find(decrypt($id))->delete();
alert()->success('Berhasil', 'Peneliti asing berhasil dihapus');
return redirect()->route('penelitiasing.index');
}
catch(Exception $ex){
alert()->error('Berhasil', 'Peneliti asing gagal dihapus');
return redirect()->route('penelitiasing.index');
}
}
......
......@@ -14,6 +14,7 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Validator;
use Alert;
class PenelitianSumberDanaController extends Controller
{
......@@ -99,6 +100,7 @@ class PenelitianSumberDanaController extends Controller
return view('user.penelitiansumber.create_anggota', $data);
}
else if($request->next_state == 'finish' && count($anggota) > 0){
return redirect()->route('penelitiansumber.index');
}
}
......@@ -176,9 +178,15 @@ class PenelitianSumberDanaController extends Controller
try{
PenelitianSumber::query()->find(decrypt($id))->update($data);
alert()->success('Berhasil', 'Penelitian sumber dana berhasil disimpan');
return redirect()->route('penelitiansumber.index');
}
catch(Exception $ex){
alert()->error('Gagal', 'Penelitian sumber dana gagal disimpan');
return redirect()->back()->withInput();
}
}
......@@ -192,19 +200,27 @@ class PenelitianSumberDanaController extends Controller
*/
public function destroy($id)
{
try{
DB::beginTransaction();
DB::beginTransaction();
try{
$penelitian = PenelitianSumber::query()->find(decrypt($id));
$penelitian->anggota()->delete();
$penelitian->delete();
DB::commit();
alert()->success('Berhasil', 'Penelitian sumber dana berhasil dihapus');
return redirect()->route('penelitiansumber.index');
}
catch(Exception $ex){
DB::rollBack();
alert()->error('Gagal', 'Penelitian sumber dana gagal dihapus');
return redirect()->route('penelitiansumber.index');
}
}
......@@ -212,21 +228,18 @@ class PenelitianSumberDanaController extends Controller
public function simpanAnggota(Request $request, $id)
{
$allAnggota = PenelitianSumberAnggota::where('penelitiansumber_id', decrypt($id))->get();
$anggota = $allAnggota->where('nidn', $request->nidn);
$ketua = $allAnggota->where('peran', PenelitianSumberAnggota::KEANGGOTAAN[PenelitianSumberAnggota::KETUA_KEY]);
$ketua = $allAnggota->where('peran', PenelitianSumberAnggota::KEANGGOTAAN['k']);
if( count($ketua) > 0 && $request->keanggotaan == PenelitianSumberAnggota::KEANGGOTAAN['k']){
if( count($ketua) > 0 && $request->keanggotaan == PenelitianSumberAnggota::KEANGGOTAAN[PenelitianSumberAnggota::KETUA_KEY]){
return response('Ketua tidak boleh lebih dari satu', 500);
}
if(count($anggota) < 1){
$dosen = Biodata::query()->where('nidn', $request->nidn)->first();
$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'){
......@@ -247,6 +260,7 @@ class PenelitianSumberDanaController extends Controller
return view('user.penelitiansumber.row_anggota', $data);
}
catch(Exception $ex){
return response('Data yang diberikan tidak lengkap atau tidak valid', 500);
}
}
......
......@@ -8,6 +8,7 @@ use Exception;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Validator;
use Alert;
class PublikasiArtikelController extends Controller
{
......@@ -19,7 +20,13 @@ class PublikasiArtikelController extends Controller
public function index(Request $request)
{
$data['tingkat'] = $request->tingkat;
$data['rs'] = PublikasiArtikel::query()->with('biodata')->where('jenis', strtoupper(substr($request->tingkat, 0, 1)))->orderBy('updated_at', 'desc')->get();
$data['rs'] = PublikasiArtikel::query()
->with('biodata')
->where('jenis', strtoupper(substr($request->tingkat, 0, 1)))
->orderBy('updated_at', 'desc')
->get();
return view('user.publikasiartikel.index', $data);
}
......@@ -32,6 +39,7 @@ class PublikasiArtikelController extends Controller
{
$data['tingkat'] = $request->tingkat;
$data['edit'] = false;
return view('user.publikasiartikel.create', $data);
}
......@@ -44,7 +52,9 @@ class PublikasiArtikelController extends Controller
public function store(Request $request)
{
$data = $request->except('_token');
Validator::make($data, PublikasiArtikel::RULES, PublikasiArtikel::ERROR_MESSAGES)->validate();
$jenis = $data['jenis'];
$data['userid_created'] = Auth::user()->id;
$data['userid_updated'] = Auth::user()->id;
......@@ -52,10 +62,15 @@ class PublikasiArtikelController extends Controller
try{
PublikasiArtikel::query()->create($data);
alert()->success('Berhasil', 'Publikasi artikel berhasil disimpan');
return redirect()->intended('publikasiartikel?tingkat='.$jenis);
}
catch(Exception $ex){
dd($ex);
alert()->error('Gagal', 'Publikasi artikel gagal disimpan');
return redirect()->back()->withInput();
}
}
......@@ -82,6 +97,7 @@ class PublikasiArtikelController extends Controller
$data['data'] = PublikasiArtikel::query()->find(decrypt($id));
$data['tingkat'] = $data['data']->jenis == 'R' ? 'Regional' : ($data['data']->jenis == 'N' ? 'Nasional' : ($data['data']->jenis == 'I' ? 'Internasional' : ''));
$data['edit'] = true;
return view('user.publikasiartikel.create', $data);
}
......@@ -95,7 +111,9 @@ class PublikasiArtikelController extends Controller
public function update(Request $request, $id)
{
$data = $request->except('_token');
Validator::make($data, PublikasiArtikel::RULES, PublikasiArtikel::ERROR_MESSAGES)->validate();
$jenis = $data['jenis'];
$data['userid_created'] = Auth::user()->id;
$data['userid_updated'] = Auth::user()->id;
......@@ -103,9 +121,15 @@ class PublikasiArtikelController extends Controller
try{
PublikasiArtikel::query()->find(decrypt($id))->update($data);
alert()->success('Berhasil', 'Publikasi artikel berhasil disimpan');
return redirect()->intended('publikasiartikel?tingkat='.$jenis);
}
catch(Exception $ex){
alert()->error('Gagal', 'Publikasi artikel gagal disimpan');
return redirect()->back()->withInput();
}
}
......@@ -120,9 +144,15 @@ class PublikasiArtikelController extends Controller
{
try{
PublikasiArtikel::query()->find(decrypt($id))->delete();
alert()->success('Berhasil', 'Publikasi artikel berhasil dihapus');
return redirect()->back();
}
catch(Exception $ex){
alert()->success('Gagal', 'Publikasi artikel gagal dihapus');
return redirect()->back();
}
}
......
......@@ -11,6 +11,7 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Validator;
use Alert;
class PublikasiJurnalController extends Controller
{
......@@ -111,9 +112,9 @@ class PublikasiJurnalController extends Controller
$anggota = $allAnggota->where('nidn', $request->nidn);
$ketua = $allAnggota->where('peran', PublikasiJurnalAnggota::KEANGGOTAAN['k']);
$ketua = $allAnggota->where('peran', PublikasiJurnalAnggota::KEANGGOTAAN[PublikasiJurnalAnggota::KETUA_KEY]);
if( count($ketua) > 0 && $request->keanggotaan == PublikasiJurnalAnggota::KEANGGOTAAN['k']){
if( count($ketua) > 0 && $request->keanggotaan == PublikasiJurnalAnggota::KEANGGOTAAN[PublikasiJurnalAnggota::KETUA_KEY]){
return response('Ketua tidak boleh lebih dari satu', 500);
}
......@@ -206,6 +207,7 @@ class PublikasiJurnalController extends Controller
{
$data['data'] = PublikasiJurnal::query()->find(decrypt($id));
$data['edit'] = true;
return view('user.publikasijurnal.create', $data);
}
......@@ -227,9 +229,15 @@ class PublikasiJurnalController extends Controller
try{
PublikasiJurnal::query()->find(decrypt($id))->update($data);
alert()->success('Berhasil', 'Publikasi Jurnal berhasil disimpan');
return redirect()->route('publikasijurnal.index');
}
catch(Exception $ex){
alert()->error('Gagal', 'Publikasi Jurnal gagal disimpan');
return redirect()->back()->withInput();
}
}
......@@ -242,19 +250,25 @@ class PublikasiJurnalController extends Controller
*/
public function destroy($id)
{
DB::beginTransaction();
try{
DB::beginTransaction();
$penelitian = PublikasiJurnal::query()->find(decrypt($id));
$penelitian->anggota()->delete();
$penelitian->delete();
DB::commit();
alert()->success('Berhasil', 'Publikasi Jurnal berhasil dihapus');
return redirect()->route('publikasijurnal.index');
}
catch(Exception $ex){
DB::rollBack();
alert()->success('Berhasil', 'Publikasi Jurnal berhasil dihapus');
return redirect()->route('publikasijurnal.index');
}
}
......
......@@ -33,10 +33,13 @@ class PenelitianSumberAnggota extends Model
];
public const KEANGGOTAAN = [
'k'=>'Ketua',
'a'=>'Anggota'
PenelitianSumberAnggota::KETUA_KEY =>'Ketua',
PenelitianSumberAnggota::ANGGOTA_KEY =>'Anggota'
];
public const KETUA_KEY = 'K';
public const ANGGOTA_KEY = 'A';
public function biodata()
{
return $this->belongsTo(Biodata::class, 'nidn', 'nidn');
......
......@@ -34,10 +34,13 @@ class PublikasiJurnalAnggota extends Model
];
public const KEANGGOTAAN = [
'k'=>'Ketua',
'a'=>'Anggota'
PenelitianSumberAnggota::KETUA_KEY =>'Ketua',
PenelitianSumberAnggota::ANGGOTA_KEY =>'Anggota'
];
public const KETUA_KEY = 'K';
public const ANGGOTA_KEY = 'A';
public function biodata()
{
return $this->belongsTo(Biodata::class, 'nidn', 'nidn');
......
......@@ -141,7 +141,11 @@
url:"{{ route('admin.remove-role') }}",
type:"POST",
dataType:"html",
data:{user_id:user_id, role_id:role_id, _token:token},
data:{
user_id:user_id,
role_id:role_id,
_token:token
},
success: function(result){
$(element).parent().parent().remove();
}
......@@ -154,7 +158,11 @@
url:"{{ route('admin.add-role') }}",
type:"POST",
dataType:"html",
data:{user_id:user_id, role_id:role_id, _token:token},
data:{
user_id:user_id,
role_id:role_id,
_token:token
},
success: function(result){
$('#'+user_token).append(result);
}
......
......@@ -151,7 +151,6 @@
feather.replace();
</script>
@include('sweet::alert')
{{-- <script src="{{ url('theme/plugins/sweetalerts/promise-polyfill.js') }}"></script>
......
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