add remarks 1

This commit is contained in:
Fiqh Pratama
2025-10-12 19:14:17 +07:00
parent 9952968d82
commit 6b2e658070
9 changed files with 295 additions and 75 deletions
@@ -837,13 +837,18 @@ class FormUpCountryController extends Controller
return redirect()->back();
}
public function reject($id)
public function reject(Request $request, $id)
{
$this->checkAuthorization(auth()->user(), ['approval.reject']);
$request->validate([
'remarks' => 'required|string|max:500',
]);
$form = FormUpCountry::findOrfail($id);
$form->update([
'status' => 'Rejected'
'status' => 'Rejected',
'remarks' => $request->remarks,
]);
$heads = $form->user->getCabangAndRegionHead();
@@ -936,4 +941,4 @@ class FormUpCountryController extends Controller
session()->flash('success', 'Form has been deleted.');
return redirect()->back();
}
}
}
@@ -716,13 +716,18 @@ class FormVehicleController extends Controller
return redirect()->back();
}
public function reject($id)
public function reject(Request $request, $id)
{
$this->checkAuthorization(auth()->user(), ['approval.reject']);
$request->validate([
'remarks' => 'required|string|max:500',
]);
$form = FormVehicleRunningCost::findOrfail($id);
$form->update([
'status' => 'Rejected'
'status' => 'Rejected',
'remarks' => $request->remarks,
]);
$heads = $form->user->getCabangAndRegionHead();
@@ -815,4 +820,4 @@ class FormVehicleController extends Controller
session()->flash('success', 'Form has been deleted.');
return redirect()->back();
}
}
}
+1
View File
@@ -34,6 +34,7 @@ class FormUpCountry extends Model
'uc_plan',
'account_number',
'status',
'remarks',
'approved_at',
'approved2_at',
'approved_by',
+1
View File
@@ -25,6 +25,7 @@ class FormVehicleRunningCost extends Model
'account_number',
'type',
'status',
'remarks',
'approved_at',
'approved2_at',
'approved_by',
@@ -116,13 +116,11 @@
</button>
</form>
<form action="{{ route('forms.up-country.reject', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to reject this form?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-danger btn-sm">
Reject
</button>
</form>
<button type="button"
class="btn btn-danger btn-sm open-reject-modal"
data-action="{{ route('forms.up-country.reject', $form->id) }}">
Reject
</button>
@else
@if ($form->approved_at)
{{ \Carbon\Carbon::parse($form->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@@ -277,13 +275,11 @@
</button>
</form>
<form action="{{ route('forms.vehicle.reject', $form->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to reject this form?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-danger btn-sm">
<button type="button"
class="btn btn-danger btn-sm open-reject-modal"
data-action="{{ route('forms.vehicle.reject', $form->id) }}">
Reject
</button>
</form>
@else
@if ($form->approved_at)
{{ \Carbon\Carbon::parse($form->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@@ -824,6 +820,35 @@
</div>
</div>
</section>
<section>
<div class="modal fade" id="rejectModal" tabindex="-1" role="dialog" aria-labelledby="rejectModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form id="rejectForm" method="POST" action="">
@csrf
@method('PUT')
<div class="modal-header">
<h5 class="modal-title" id="rejectModalLabel">Reject Expense</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="rejectRemarks">Remarks <span class="text-danger">*</span></label>
<textarea class="form-control" name="remarks" id="rejectRemarks" rows="3" required></textarea>
</div>
<p class="mb-0 text-muted small">Pengajuan akan ditolak setelah Anda mengirimkan catatan ini.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-danger">Reject</button>
</div>
</form>
</div>
</div>
</div>
</section>
@endsection
@section('scripts')
@@ -844,5 +869,21 @@
if ($('#dataTable-form_others').length) {
$('#dataTable-form_others').DataTable({ responsive: false });
}
$(document).on('click', '.open-reject-modal', function () {
const rejectUrl = $(this).data('action');
$('#rejectForm').attr('action', rejectUrl);
$('#rejectRemarks').val('');
$('#rejectModal').modal('show');
});
$('#rejectModal').on('shown.bs.modal', function () {
$('#rejectRemarks').trigger('focus');
});
$('#rejectModal').on('hidden.bs.modal', function () {
$('#rejectForm').attr('action', '');
$('#rejectRemarks').val('');
});
</script>
@endsection
@@ -166,13 +166,11 @@
</button>
</form>
<form action="{{ route('forms.up-country.reject', $item->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to reject this item?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-danger btn-sm">
Reject
</button>
</form>
<button type="button"
class="btn btn-danger btn-sm open-reject-modal"
data-action="{{ route('forms.up-country.reject', $item->id) }}">
Reject
</button>
@endif
@endif
@if ($item->approved_at)
@@ -193,13 +191,11 @@
</button>
</form>
<form action="{{ route('forms.up-country.reject', $item->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to reject this item?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-danger btn-sm">
Reject
</button>
</form>
<button type="button"
class="btn btn-danger btn-sm open-reject-modal"
data-action="{{ route('forms.up-country.reject', $item->id) }}">
Reject
</button>
@endif
@endif
@if ($item->approved2_at)
@@ -470,6 +466,35 @@
</div>
</div>
</section>
<section>
<div class="modal fade" id="rejectModal" tabindex="-1" role="dialog" aria-labelledby="rejectModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form id="rejectForm" method="POST" action="">
@csrf
@method('PUT')
<div class="modal-header">
<h5 class="modal-title" id="rejectModalLabel">Reject Expense</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="rejectRemarks">Remarks <span class="text-danger">*</span></label>
<textarea class="form-control" name="remarks" id="rejectRemarks" rows="3" required></textarea>
</div>
<p class="mb-0 text-muted small">Pengajuan akan ditolak setelah Anda mengirimkan catatan ini.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-danger">Reject</button>
</div>
</form>
</div>
</div>
</div>
</section>
@endsection
@section('scripts')
@@ -514,6 +539,24 @@
});
}
// Handle Reject Button Click
$(document).on('click', '.open-reject-modal', function () {
const rejectUrl = $(this).data('action');
$('#rejectForm').attr('action', rejectUrl);
$('#rejectRemarks').val('');
$('#rejectModal').modal('show');
});
$('#rejectModal').on('shown.bs.modal', function () {
$('#rejectRemarks').trigger('focus');
});
$('#rejectModal').on('hidden.bs.modal', function () {
$('#rejectForm').attr('action', '');
$('#rejectRemarks').val('');
});
// <script>
//$(document).ready(function () {
@@ -109,23 +109,19 @@
@if (auth()->user()->can('approval.approve') && $form->status == 'On Progress')
<button type="button" class="btn btn-success final-approve-modal" data-id="{{ route('forms.up-country.approve', $form->id) }}">Approve 1</button>
<form action="{{ route('forms.up-country.reject', $form->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to approve this item?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-danger">
Reject
</button>
</form>
<button type="button"
class="btn btn-danger open-reject-modal"
data-action="{{ route('forms.up-country.reject', $form->id) }}">
Reject
</button>
@elseif(auth()->user()->can('approval2.approve') && $form->status == 'Approved 1')
<button type="button" class="btn btn-success open-approve-modal" data-id="{{ route('forms.up-country.approve2', $form->id) }}">Approve 2</button>
<form action="{{ route('forms.up-country.reject', $form->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to approve this item?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-danger">
Reject
</button>
</form>
<button type="button"
class="btn btn-danger open-reject-modal"
data-action="{{ route('forms.up-country.reject', $form->id) }}">
Reject
</button>
@elseif(auth()->user()->can('final_approval.approve') && $form->status == 'Approved 2')
<button type="button" class="btn btn-primary open-approve-modal" data-id="{{ route('forms.up-country.final-approve', $form->id) }}">Final Approve</button>
@endif
@@ -337,6 +333,35 @@
</div>
</div>
</section>
<section>
<div class="modal fade" id="rejectModal" tabindex="-1" role="dialog" aria-labelledby="rejectModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form id="rejectForm" method="POST" action="">
@csrf
@method('PUT')
<div class="modal-header">
<h5 class="modal-title" id="rejectModalLabel">Reject Expense</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="rejectRemarks">Remarks <span class="text-danger">*</span></label>
<textarea class="form-control" name="remarks" id="rejectRemarks" rows="3" required></textarea>
</div>
<p class="mb-0 text-muted small">Pengajuan akan ditolak setelah Anda mengirimkan catatan ini.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-danger">Reject</button>
</div>
</form>
</div>
</div>
</div>
</section>
@endsection
@section('scripts')
@@ -383,6 +408,22 @@
</script>
<script>
$(document).on('click', '.open-reject-modal', function () {
const rejectUrl = $(this).data('action');
$('#rejectForm').attr('action', rejectUrl);
$('#rejectRemarks').val('');
$('#rejectModal').modal('show');
});
$('#rejectModal').on('shown.bs.modal', function () {
$('#rejectRemarks').trigger('focus');
});
$('#rejectModal').on('hidden.bs.modal', function () {
$('#rejectForm').attr('action', '');
$('#rejectRemarks').val('');
});
// Handle Approve Button Click
$(document).on('click', '.open-approve-modal', function() {
const approveUrl = $(this).data('id');
@@ -185,13 +185,11 @@
</button>
</form>
<form action="{{ route('forms.vehicle.reject', $item->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to reject this item?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-danger btn-sm">
Reject
</button>
</form>
<button type="button"
class="btn btn-danger btn-sm open-reject-modal"
data-action="{{ route('forms.vehicle.reject', $item->id) }}">
Reject
</button>
@endif
@endif
@if ($item->approved_at)
@@ -212,13 +210,11 @@
</button>
</form>
<form action="{{ route('forms.vehicle.reject', $item->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to reject this item?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-danger btn-sm">
Reject
</button>
</form>
<button type="button"
class="btn btn-danger btn-sm open-reject-modal"
data-action="{{ route('forms.vehicle.reject', $item->id) }}">
Reject
</button>
@endif
@endif
@if ($item->approved2_at)
@@ -432,6 +428,35 @@
</div>
</div>
</section>
<section>
<div class="modal fade" id="rejectModal" tabindex="-1" role="dialog" aria-labelledby="rejectModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form id="rejectForm" method="POST" action="">
@csrf
@method('PUT')
<div class="modal-header">
<h5 class="modal-title" id="rejectModalLabel">Reject Expense</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="rejectRemarks">Remarks <span class="text-danger">*</span></label>
<textarea class="form-control" name="remarks" id="rejectRemarks" rows="3" required></textarea>
</div>
<p class="mb-0 text-muted small">Pengajuan akan ditolak setelah Anda mengirimkan catatan ini.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-danger">Reject</button>
</div>
</form>
</div>
</div>
</div>
</section>
@endsection
@section('scripts')
@@ -472,6 +497,23 @@
});
}
// Handle Reject Button Click
$(document).on('click', '.open-reject-modal', function () {
const rejectUrl = $(this).data('action');
$('#rejectForm').attr('action', rejectUrl);
$('#rejectRemarks').val('');
$('#rejectModal').modal('show');
});
$('#rejectModal').on('shown.bs.modal', function () {
$('#rejectRemarks').trigger('focus');
});
$('#rejectModal').on('hidden.bs.modal', function () {
$('#rejectForm').attr('action', '');
$('#rejectRemarks').val('');
});
// Handle Approve Button Click
$(document).on('click', '.open-approve-modal', function() {
const approveUrl = $(this).data('id');
@@ -603,4 +645,4 @@
});
});
</script>
@endsection
@endsection
@@ -94,23 +94,19 @@
@if (auth()->user()->can('approval.approve') && $form->status == 'On Progress')
<button type="button" class="btn btn-success final-approve-modal" data-id="{{ route('forms.vehicle.approve', $form->id) }}">Approve 1</button>
<form action="{{ route('forms.vehicle.reject', $form->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to approve this item?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-danger">
Reject
</button>
</form>
<button type="button"
class="btn btn-danger open-reject-modal"
data-action="{{ route('forms.vehicle.reject', $form->id) }}">
Reject
</button>
@elseif(auth()->user()->can('approval2.approve') && $form->status == 'Approved 1')
<button type="button" class="btn btn-success open-approve-modal" data-id="{{ route('forms.vehicle.approve2', $form->id) }}">Approve 2</button>
<form action="{{ route('forms.vehicle.reject', $form->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to approve this item?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-danger">
Reject
</button>
</form>
<button type="button"
class="btn btn-danger open-reject-modal"
data-action="{{ route('forms.vehicle.reject', $form->id) }}">
Reject
</button>
@elseif(auth()->user()->can('final_approval.approve') && $form->status == 'Approved 2')
<button type="button" class="btn btn-primary open-approve-modal" data-id="{{ route('forms.vehicle.final-approve', $form->id) }}">Final Approve</button>
@endif
@@ -265,6 +261,35 @@
</div>
</div>
</section>
<section>
<div class="modal fade" id="rejectModal" tabindex="-1" role="dialog" aria-labelledby="rejectModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form id="rejectForm" method="POST" action="">
@csrf
@method('PUT')
<div class="modal-header">
<h5 class="modal-title" id="rejectModalLabel">Reject Expense</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="rejectRemarks">Remarks <span class="text-danger">*</span></label>
<textarea class="form-control" name="remarks" id="rejectRemarks" rows="3" required></textarea>
</div>
<p class="mb-0 text-muted small">Pengajuan akan ditolak setelah Anda mengirimkan catatan ini.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-danger">Reject</button>
</div>
</form>
</div>
</div>
</div>
</section>
@endsection
@section('scripts')
@@ -279,6 +304,22 @@
</script>
<script>
$(document).on('click', '.open-reject-modal', function () {
const rejectUrl = $(this).data('action');
$('#rejectForm').attr('action', rejectUrl);
$('#rejectRemarks').val('');
$('#rejectModal').modal('show');
});
$('#rejectModal').on('shown.bs.modal', function () {
$('#rejectRemarks').trigger('focus');
});
$('#rejectModal').on('hidden.bs.modal', function () {
$('#rejectForm').attr('action', '');
$('#rejectRemarks').val('');
});
$(document).on('click', '.open-approve-modal', function() {
const approveUrl = $(this).data('id');