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(); return redirect()->back();
} }
public function reject($id) public function reject(Request $request, $id)
{ {
$this->checkAuthorization(auth()->user(), ['approval.reject']); $this->checkAuthorization(auth()->user(), ['approval.reject']);
$request->validate([
'remarks' => 'required|string|max:500',
]);
$form = FormUpCountry::findOrfail($id); $form = FormUpCountry::findOrfail($id);
$form->update([ $form->update([
'status' => 'Rejected' 'status' => 'Rejected',
'remarks' => $request->remarks,
]); ]);
$heads = $form->user->getCabangAndRegionHead(); $heads = $form->user->getCabangAndRegionHead();
@@ -716,13 +716,18 @@ class FormVehicleController extends Controller
return redirect()->back(); return redirect()->back();
} }
public function reject($id) public function reject(Request $request, $id)
{ {
$this->checkAuthorization(auth()->user(), ['approval.reject']); $this->checkAuthorization(auth()->user(), ['approval.reject']);
$request->validate([
'remarks' => 'required|string|max:500',
]);
$form = FormVehicleRunningCost::findOrfail($id); $form = FormVehicleRunningCost::findOrfail($id);
$form->update([ $form->update([
'status' => 'Rejected' 'status' => 'Rejected',
'remarks' => $request->remarks,
]); ]);
$heads = $form->user->getCabangAndRegionHead(); $heads = $form->user->getCabangAndRegionHead();
+1
View File
@@ -34,6 +34,7 @@ class FormUpCountry extends Model
'uc_plan', 'uc_plan',
'account_number', 'account_number',
'status', 'status',
'remarks',
'approved_at', 'approved_at',
'approved2_at', 'approved2_at',
'approved_by', 'approved_by',
+1
View File
@@ -25,6 +25,7 @@ class FormVehicleRunningCost extends Model
'account_number', 'account_number',
'type', 'type',
'status', 'status',
'remarks',
'approved_at', 'approved_at',
'approved2_at', 'approved2_at',
'approved_by', 'approved_by',
@@ -116,13 +116,11 @@
</button> </button>
</form> </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?');"> <button type="button"
@csrf class="btn btn-danger btn-sm open-reject-modal"
@method('PUT') data-action="{{ route('forms.up-country.reject', $form->id) }}">
<button type="submit" class="btn btn-danger btn-sm">
Reject Reject
</button> </button>
</form>
@else @else
@if ($form->approved_at) @if ($form->approved_at)
{{ \Carbon\Carbon::parse($form->approved_at)->locale('id')->isoFormat('D MMMM Y') }} {{ \Carbon\Carbon::parse($form->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@@ -277,13 +275,11 @@
</button> </button>
</form> </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?');"> <button type="button"
@csrf class="btn btn-danger btn-sm open-reject-modal"
@method('PUT') data-action="{{ route('forms.vehicle.reject', $form->id) }}">
<button type="submit" class="btn btn-danger btn-sm">
Reject Reject
</button> </button>
</form>
@else @else
@if ($form->approved_at) @if ($form->approved_at)
{{ \Carbon\Carbon::parse($form->approved_at)->locale('id')->isoFormat('D MMMM Y') }} {{ \Carbon\Carbon::parse($form->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@@ -824,6 +820,35 @@
</div> </div>
</div> </div>
</section> </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 @endsection
@section('scripts') @section('scripts')
@@ -844,5 +869,21 @@
if ($('#dataTable-form_others').length) { if ($('#dataTable-form_others').length) {
$('#dataTable-form_others').DataTable({ responsive: false }); $('#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> </script>
@endsection @endsection
@@ -166,13 +166,11 @@
</button> </button>
</form> </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?');"> <button type="button"
@csrf class="btn btn-danger btn-sm open-reject-modal"
@method('PUT') data-action="{{ route('forms.up-country.reject', $item->id) }}">
<button type="submit" class="btn btn-danger btn-sm">
Reject Reject
</button> </button>
</form>
@endif @endif
@endif @endif
@if ($item->approved_at) @if ($item->approved_at)
@@ -193,13 +191,11 @@
</button> </button>
</form> </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?');"> <button type="button"
@csrf class="btn btn-danger btn-sm open-reject-modal"
@method('PUT') data-action="{{ route('forms.up-country.reject', $item->id) }}">
<button type="submit" class="btn btn-danger btn-sm">
Reject Reject
</button> </button>
</form>
@endif @endif
@endif @endif
@if ($item->approved2_at) @if ($item->approved2_at)
@@ -470,6 +466,35 @@
</div> </div>
</div> </div>
</section> </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 @endsection
@section('scripts') @section('scripts')
@@ -515,6 +540,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> // <script>
//$(document).ready(function () { //$(document).ready(function () {
@@ -109,23 +109,19 @@
@if (auth()->user()->can('approval.approve') && $form->status == 'On Progress') @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> <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?');"> <button type="button"
@csrf class="btn btn-danger open-reject-modal"
@method('PUT') data-action="{{ route('forms.up-country.reject', $form->id) }}">
<button type="submit" class="btn btn-danger">
Reject Reject
</button> </button>
</form>
@elseif(auth()->user()->can('approval2.approve') && $form->status == 'Approved 1') @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> <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?');"> <button type="button"
@csrf class="btn btn-danger open-reject-modal"
@method('PUT') data-action="{{ route('forms.up-country.reject', $form->id) }}">
<button type="submit" class="btn btn-danger">
Reject Reject
</button> </button>
</form>
@elseif(auth()->user()->can('final_approval.approve') && $form->status == 'Approved 2') @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> <button type="button" class="btn btn-primary open-approve-modal" data-id="{{ route('forms.up-country.final-approve', $form->id) }}">Final Approve</button>
@endif @endif
@@ -337,6 +333,35 @@
</div> </div>
</div> </div>
</section> </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 @endsection
@section('scripts') @section('scripts')
@@ -383,6 +408,22 @@
</script> </script>
<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 // Handle Approve Button Click
$(document).on('click', '.open-approve-modal', function() { $(document).on('click', '.open-approve-modal', function() {
const approveUrl = $(this).data('id'); const approveUrl = $(this).data('id');
@@ -185,13 +185,11 @@
</button> </button>
</form> </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?');"> <button type="button"
@csrf class="btn btn-danger btn-sm open-reject-modal"
@method('PUT') data-action="{{ route('forms.vehicle.reject', $item->id) }}">
<button type="submit" class="btn btn-danger btn-sm">
Reject Reject
</button> </button>
</form>
@endif @endif
@endif @endif
@if ($item->approved_at) @if ($item->approved_at)
@@ -212,13 +210,11 @@
</button> </button>
</form> </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?');"> <button type="button"
@csrf class="btn btn-danger btn-sm open-reject-modal"
@method('PUT') data-action="{{ route('forms.vehicle.reject', $item->id) }}">
<button type="submit" class="btn btn-danger btn-sm">
Reject Reject
</button> </button>
</form>
@endif @endif
@endif @endif
@if ($item->approved2_at) @if ($item->approved2_at)
@@ -432,6 +428,35 @@
</div> </div>
</div> </div>
</section> </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 @endsection
@section('scripts') @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 // Handle Approve Button Click
$(document).on('click', '.open-approve-modal', function() { $(document).on('click', '.open-approve-modal', function() {
const approveUrl = $(this).data('id'); const approveUrl = $(this).data('id');
@@ -94,23 +94,19 @@
@if (auth()->user()->can('approval.approve') && $form->status == 'On Progress') @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> <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?');"> <button type="button"
@csrf class="btn btn-danger open-reject-modal"
@method('PUT') data-action="{{ route('forms.vehicle.reject', $form->id) }}">
<button type="submit" class="btn btn-danger">
Reject Reject
</button> </button>
</form>
@elseif(auth()->user()->can('approval2.approve') && $form->status == 'Approved 1') @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> <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?');"> <button type="button"
@csrf class="btn btn-danger open-reject-modal"
@method('PUT') data-action="{{ route('forms.vehicle.reject', $form->id) }}">
<button type="submit" class="btn btn-danger">
Reject Reject
</button> </button>
</form>
@elseif(auth()->user()->can('final_approval.approve') && $form->status == 'Approved 2') @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> <button type="button" class="btn btn-primary open-approve-modal" data-id="{{ route('forms.vehicle.final-approve', $form->id) }}">Final Approve</button>
@endif @endif
@@ -265,6 +261,35 @@
</div> </div>
</div> </div>
</section> </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 @endsection
@section('scripts') @section('scripts')
@@ -279,6 +304,22 @@
</script> </script>
<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() { $(document).on('click', '.open-approve-modal', function() {
const approveUrl = $(this).data('id'); const approveUrl = $(this).data('id');