update
parent
35dc949f9e
commit
f055b22ba8
|
|
@ -73,16 +73,17 @@ class DataAktivitasController implements HasMiddleware
|
||||||
|
|
||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
$data = $this->fileService->find($id);
|
$datas['data'] = $this->fileService->find($id);
|
||||||
if ($data) {
|
// dd($datas['data']);
|
||||||
$data['storagePath'] = 'data_aktivitas/' . $data->sector . '/' . $data->inventory_year;
|
if ($datas['data']->file_upload) {
|
||||||
|
$datas['storagePath'] = 'data_aktivitas/' . $datas['data']->sector . '/' . $datas['data']->inventory_year;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['sectors'] = $this->fileService->getSectors();
|
$datas['sectors'] = $this->fileService->getSectors();
|
||||||
$data['route'] = $this->route;
|
$datas['route'] = $this->route;
|
||||||
$data['title'] = $this->title;
|
$datas['title'] = $this->title;
|
||||||
|
|
||||||
return view($this->template.'.edit', $data);
|
return view($this->template.'.edit', $datas);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(Request $request, $id)
|
public function update(Request $request, $id)
|
||||||
|
|
@ -117,7 +118,7 @@ class DataAktivitasController implements HasMiddleware
|
||||||
$storagePath = 'data_aktivitas/' . $data->sector . '/' . $data->inventory_year;
|
$storagePath = 'data_aktivitas/' . $data->sector . '/' . $data->inventory_year;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->fileService->destroy($cms, $storagePath);
|
$this->fileService->destroy($data, $storagePath);
|
||||||
|
|
||||||
return redirect()->route($this->route.'.index')->with('success', 'File Data Aktivitas berhasil dihapus.');
|
return redirect()->route($this->route.'.index')->with('success', 'File Data Aktivitas berhasil dihapus.');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
@ -138,20 +139,23 @@ class DataAktivitasController implements HasMiddleware
|
||||||
|
|
||||||
public function grid(Request $request)
|
public function grid(Request $request)
|
||||||
{
|
{
|
||||||
|
// dd($request->all());
|
||||||
$_data = [];
|
$_data = [];
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
$scope = $user->getScope();
|
$scope = $user->getScope();
|
||||||
$data = CmsFileDataAktivitas::rowActive();
|
$data = CmsFileDataAktivitas::rowActive();
|
||||||
|
// dd($data->get());
|
||||||
if ($scope === LingkupAksesData::INTERNAL->value) {
|
if ($scope === LingkupAksesData::INTERNAL->value) {
|
||||||
|
dd('a');
|
||||||
$data->whereHas('creator', function ($q) use ($user) {
|
$data->whereHas('creator', function ($q) use ($user) {
|
||||||
$q->where('agency_id', $user->agency_id);
|
$q->where('agency_id', $user->agency_id);
|
||||||
});
|
});
|
||||||
} else if ($scope === '') {
|
} else if ($scope === '') {
|
||||||
$data->where('created_by', null);
|
// $data->where('created_by', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Apply category filter if a category is selected
|
// Apply category filter if a category is selected
|
||||||
if ($request->has('sectorFilter') && $request->sectorFilter != '' && $request->sectorFilter != 'SEMUA SEKTOR') {
|
if ($request->has('sectorFilter') && $request->sectorFilter != '' && $request->sectorFilter != 'SEMUA SEKTOR') {
|
||||||
$data = $data->where('sector', $request->sectorFilter);
|
$data = $data->where('sector', $request->sectorFilter);
|
||||||
|
|
@ -181,9 +185,9 @@ class DataAktivitasController implements HasMiddleware
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($row->file_upload) {
|
if ($row->file_upload) {
|
||||||
$storagePath = 'data_aktivitas/' . $row->sector . '/' . $row->inventory_year;
|
$storagePath = 'storage/data_aktivitas/' . $row->sector . '/' . $row->inventory_year;
|
||||||
$file = '<a href="' . Storage::url($storagePath . '/' . $row->file_upload) . '" class="btn btn-info">
|
$file = '<a href="' . asset($storagePath . '/' . $row->file_upload) . '" class="btn btn-sm w-100 btn-info">
|
||||||
<i class="ti ti-download"></i>
|
<i class="bx bx-download"></i>
|
||||||
</a>';
|
</a>';
|
||||||
} else {
|
} else {
|
||||||
$file = '<span class="badge badge-secondary">No File</span>';
|
$file = '<span class="badge badge-secondary">No File</span>';
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@ use Yajra\DataTables\DataTables;
|
||||||
|
|
||||||
class PeraturanController implements HasMiddleware
|
class PeraturanController implements HasMiddleware
|
||||||
{
|
{
|
||||||
|
protected $title = 'Data Pengumuman';
|
||||||
|
protected $template = 'modules.setting.file-peraturan';
|
||||||
|
protected $route = 'modules.pengaturan.pengumuman';
|
||||||
protected $fileService;
|
protected $fileService;
|
||||||
|
|
||||||
public function __construct(PeraturanService $fileService)
|
public function __construct(PeraturanService $fileService)
|
||||||
|
|
@ -29,42 +32,18 @@ class PeraturanController implements HasMiddleware
|
||||||
|
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
if ($request->ajax()) {
|
$datas['route'] = $this->route;
|
||||||
$query = $this->fileService->getAll();
|
$datas['title'] = $this->title;
|
||||||
|
|
||||||
$result = datatables()->of($query)
|
return view($this->template.'.index',$datas);
|
||||||
->addColumn('file_upload', function ($row) {
|
|
||||||
if ($row->file_upload) {
|
|
||||||
$storagePath = 'peraturan';
|
|
||||||
return '<a href="' . Storage::url($storagePath . '/' . $row->file_upload) . '" class="btn btn-info">
|
|
||||||
<i class="ti ti-download"></i>
|
|
||||||
</a>';
|
|
||||||
} else {
|
|
||||||
return '<span class="badge badge-secondary">No File</span>';
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->addColumn('action', function ($data) {
|
|
||||||
$actionBtn = '<a href="' . route('peraturan.edit', $data->id) . '" class="btn btn-primary">Edit</a>';
|
|
||||||
$actionBtn .= ' <form method="POST" action="' . route('peraturan.destroy', $data->id) . '" style="display: inline">';
|
|
||||||
$actionBtn .= csrf_field();
|
|
||||||
$actionBtn .= method_field('DELETE');
|
|
||||||
$actionBtn .= '<button type="submit" class="btn btn-danger" onclick="return confirm(\'Are you sure?\')">Delete</button>';
|
|
||||||
$actionBtn .= '</form>';
|
|
||||||
return $actionBtn;
|
|
||||||
})
|
|
||||||
->rawColumns(['file_upload', 'action'])
|
|
||||||
->make(true);
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('setting.file-peraturan.index');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
return view('setting.file-peraturan.create');
|
$datas['route'] = $this->route;
|
||||||
|
$datas['title'] = $this->title;
|
||||||
|
return view($this->template.'.create',$datas);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
|
|
@ -79,7 +58,7 @@ class PeraturanController implements HasMiddleware
|
||||||
try {
|
try {
|
||||||
$this->fileService->save($request->all());
|
$this->fileService->save($request->all());
|
||||||
|
|
||||||
return redirect()->route('peraturan.index')->with('success', 'File Pengumuman / File Peraturan-Peraturan berhasil diupload.');
|
return redirect()->route($this->route.'.index')->with('success', 'File Pengumuman / File Peraturan-Peraturan berhasil diupload.');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return back()->withErrors(['error' => 'File Pengumuman / File Peraturan-Peraturan gagal disimpan. Silakan coba lagi. Error: ' . $e->getMessage()]);
|
return back()->withErrors(['error' => 'File Pengumuman / File Peraturan-Peraturan gagal disimpan. Silakan coba lagi. Error: ' . $e->getMessage()]);
|
||||||
}
|
}
|
||||||
|
|
@ -87,12 +66,13 @@ class PeraturanController implements HasMiddleware
|
||||||
|
|
||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
$data = $this->fileService->find($id);
|
$datas['data'] = $this->fileService->find($id);
|
||||||
if ($data) {
|
if ($datas['data']) {
|
||||||
$data['storagePath'] = 'peraturan';
|
$datas['storagePath'] = 'peraturan';
|
||||||
}
|
}
|
||||||
|
$datas['route'] = $this->route;
|
||||||
return view('setting.file-peraturan.edit', compact('data'));
|
$datas['title'] = $this->title;
|
||||||
|
return view($this->template.'.edit', $datas);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(Request $request, $id)
|
public function update(Request $request, $id)
|
||||||
|
|
@ -110,7 +90,7 @@ class PeraturanController implements HasMiddleware
|
||||||
|
|
||||||
$this->fileService->save($data);
|
$this->fileService->save($data);
|
||||||
|
|
||||||
return redirect()->route('peraturan.index')->with('success', 'File Pengumuman / File Peraturan-Peraturan berhasil diperbarui.');
|
return redirect()->route($this->route.'.index')->with('success', 'File Pengumuman / File Peraturan-Peraturan berhasil diperbarui.');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return back()->withErrors(['error' => 'File Pengumuman / File Peraturan-Peraturan gagal diperbarui. Silakan coba lagi. Error: ' . $e->getMessage()]);
|
return back()->withErrors(['error' => 'File Pengumuman / File Peraturan-Peraturan gagal diperbarui. Silakan coba lagi. Error: ' . $e->getMessage()]);
|
||||||
}
|
}
|
||||||
|
|
@ -124,11 +104,49 @@ class PeraturanController implements HasMiddleware
|
||||||
$storagePath = 'peraturan';
|
$storagePath = 'peraturan';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->fileService->destroy($cms, $storagePath);
|
$this->fileService->destroy($data, $storagePath);
|
||||||
|
|
||||||
return redirect()->route('unit.index')->with('success', 'File Pengumuman / File Peraturan-Peraturan berhasil dihapus.');
|
return redirect()->route($this->route.'.index')->with('success', 'File Pengumuman / File Peraturan-Peraturan berhasil dihapus.');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return back()->withErrors(['error' => 'File Pengumuman / File Peraturan-Peraturan gagal dihapus. Silakan coba lagi. Error: ' . $e->getMessage()]);
|
return back()->withErrors(['error' => 'File Pengumuman / File Peraturan-Peraturan gagal dihapus. Silakan coba lagi. Error: ' . $e->getMessage()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function grid(Request $request)
|
||||||
|
{
|
||||||
|
// dd($request->all());
|
||||||
|
$_data = [];
|
||||||
|
$data = $this->fileService->getAll();
|
||||||
|
|
||||||
|
foreach ($data as $key => $row) {
|
||||||
|
|
||||||
|
$btn = '<a href="' . route($this->route.'.edit', $row->id) . '" class="btn btn-sm btn-primary">Edit</a>';
|
||||||
|
$btn .= ' <form method="POST" action="' . route($this->route.'.destroy', $row->id) . '" style="display: inline">';
|
||||||
|
$btn .= csrf_field();
|
||||||
|
$btn .= method_field('DELETE');
|
||||||
|
$btn .= '<button type="submit" class="btn btn-sm btn-danger" onclick="return confirm(\'Are you sure?\')">Delete</button>';
|
||||||
|
$btn .= '</form>';
|
||||||
|
|
||||||
|
if ($row->file_upload) {
|
||||||
|
$storagePath = 'storage/peraturan';
|
||||||
|
$file = '<a href="' . asset($storagePath . '/' . $row->file_upload) . '" class="btn btn-sm w-100 btn-info">
|
||||||
|
<i class="bx bx-download"></i>
|
||||||
|
</a>';
|
||||||
|
} else {
|
||||||
|
$file = '<span class="badge badge-secondary">No File</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$_data[] = [
|
||||||
|
'no' => $key+1,
|
||||||
|
'file' => $file,
|
||||||
|
'name' => $row->name,
|
||||||
|
'description' => $row->description,
|
||||||
|
'action' => @$btn,
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($_data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
/Applications/MAMP/htdocs/sigd_new/storage/app/public
|
||||||
|
|
@ -99,7 +99,7 @@
|
||||||
id="file_document" name="file_document">
|
id="file_document" name="file_document">
|
||||||
@if ($data->file_upload)
|
@if ($data->file_upload)
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<a href="{{ Storage::url($data->storagePath . '/' . $data->file_upload) }}"
|
<a href="{{ asset('storage/'.$storagePath . '/' . $data->file_upload) }}"
|
||||||
class="btn btn-success" download>Download File</a>
|
class="btn btn-success" download>Download File</a>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,6 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@if (session('success'))
|
|
||||||
<div class="alert alert-success">
|
|
||||||
{{ session('success') }}
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-2 pr-1" id="inventoryYearContainer">
|
<div class="col-md-2 pr-1" id="inventoryYearContainer">
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
@extends('layouts.master')
|
@extends('layouts.master')
|
||||||
|
|
||||||
@section('title', 'Upload Pengumuman / File Peraturan-Peraturan')
|
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<h5 class="mb-0 font-weight-bold">Upload Pengumuman / File Peraturan-Peraturan</h5>
|
<h5 class="mb-0 font-weight-bold">{{ @$title }}</h5>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
@ -15,7 +13,7 @@
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<form method="POST" action="{{ route('peraturan.store') }}" enctype="multipart/form-data">
|
<form method="POST" action="{{ route($route.'.store') }}" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
@ -54,7 +52,7 @@
|
||||||
{{-- Jenis file yang dibolehkan: pdf, PDF, jpg, JPG, jpeg, JPEG, png, PNG --}}
|
{{-- Jenis file yang dibolehkan: pdf, PDF, jpg, JPG, jpeg, JPEG, png, PNG --}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a href="{{ route('peraturan.index') }}" class="btn btn-secondary">Kembali</a>
|
<a href="{{ route($route.'.index') }}" class="btn btn-secondary">Kembali</a>
|
||||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,14 @@
|
||||||
@extends('layouts.master')
|
@extends('layouts.master')
|
||||||
|
|
||||||
@section('title', 'Edit Pengumuman / File Peraturan-Peraturan')
|
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<h5 class="mb-0 font-weight-bold">Edit Pengumuman / File Peraturan-Peraturan</h5>
|
<h5 class="mb-0 font-weight-bold">{{ @$title }}</h5>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@if ($errors->has('error'))
|
|
||||||
<div class="alert alert-danger">
|
|
||||||
{{ $errors->first('error') }}
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
<form method="POST" action="{{ route('peraturan.update', $data->id) }}" enctype="multipart/form-data">
|
<form method="POST" action="{{ route($route.'.update', $data->id) }}" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
@method('PUT')
|
@method('PUT')
|
||||||
|
|
||||||
|
|
@ -47,7 +40,7 @@
|
||||||
id="file_document" name="file_document">
|
id="file_document" name="file_document">
|
||||||
@if ($data->file_upload)
|
@if ($data->file_upload)
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<a href="{{ Storage::url($data->storagePath . '/' . $data->file_upload) }}"
|
<a href="{{ asset('storage/'.$storagePath . '/' . $data->file_upload) }}"
|
||||||
class="btn btn-success" download>Download File</a>
|
class="btn btn-success" download>Download File</a>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
@ -61,7 +54,7 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a href="{{ route('peraturan.index') }}" class="btn btn-secondary">Kembali</a>
|
<a href="{{ route($route.'.index') }}" class="btn btn-secondary">Kembali</a>
|
||||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,38 @@
|
||||||
@extends('layouts.master')
|
@extends('layouts.master')
|
||||||
|
|
||||||
@section('title', 'List Pengumuman / File Peraturan-Peraturan')
|
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<h5 class="mb-0 font-weight-bold">List Pengumuman / File Peraturan-Peraturan</h5>
|
<h5 class="mb-0 font-weight-bold">{{ @$title }}</h5>
|
||||||
<a href="{{ route('peraturan.create') }}" class="btn btn-primary float-right">Upload</a>
|
<a href="{{ route($route.'.create') }}" class="btn btn-primary float-right">Upload</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@if (session('success'))
|
|
||||||
<div class="alert alert-success">
|
|
||||||
{{ session('success') }}
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table align-items-center mb-0 display" id="data-table" style="width:100%">
|
<table class="table w-100"
|
||||||
<thead>
|
data-search="true"
|
||||||
|
data-toggle="table"
|
||||||
|
data-pagination="true"
|
||||||
|
data-toolbar="#toolbar"
|
||||||
|
data-show-refresh="false"
|
||||||
|
data-url="{{route($route.'.grid')}}"
|
||||||
|
data-ajax-options='{"xhrFields": {"withCredentials": true}}'
|
||||||
|
data-sort-name="ids"
|
||||||
|
data-sort-order="desc"
|
||||||
|
data-page-size="10"
|
||||||
|
data-id-field="id"
|
||||||
|
id="grid-data">
|
||||||
|
<thead class="table-primary text-primary">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Judul</th>
|
<th data-width="150" data-field="action">#</th>
|
||||||
<th scope="col" width="5%">File</th>
|
<th data-field="name">Judul</th>
|
||||||
<th scope="col">Keterangan</th>
|
<th data-field="file">File</th>
|
||||||
<th scope="col" width="15%">Aksi</th>
|
<th data-field="description">Keterangan</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody></tbody>
|
||||||
</tbody>
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -36,37 +40,4 @@
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('js')
|
@section('js')
|
||||||
<script>
|
|
||||||
$(document).ready(function() {
|
|
||||||
var table = $('#data-table').DataTable({
|
|
||||||
pageLength: 10,
|
|
||||||
responsive: true,
|
|
||||||
serverSide: true,
|
|
||||||
scrollX: true,
|
|
||||||
searchDelay: 1000,
|
|
||||||
ajax: {
|
|
||||||
url: '{{ route('peraturan.index') }}',
|
|
||||||
},
|
|
||||||
columns: [{
|
|
||||||
data: 'name',
|
|
||||||
name: 'name'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: 'file_upload',
|
|
||||||
name: 'file_upload',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: 'description',
|
|
||||||
name: 'description'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: 'action',
|
|
||||||
name: 'action',
|
|
||||||
orderable: false,
|
|
||||||
searchable: false
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue