2024-12-12 18:18:26 +07:00
@ extends ( 'layouts.app' )
@ section ( 'title' )
Dashboard
@ endsection
@ section ( 'admin-content' )
< section class = " content-header " >
< div class = " container-fluid " >
< div class = " row mb-2 " >
< div class = " col-sm-6 " >
< h1 > Forms Up Country </ h1 >
</ div >
< div class = " col-sm-6 " >
< ol class = " breadcrumb float-sm-right " >
< li class = " breadcrumb-item " >< a href = " { { route('dashboard.index') }} " > Dashboard </ a ></ li >
</ li >
</ ol >
</ div >
</ div >
</ div >
</ section >
2024-12-24 11:40:49 +07:00
< section class = " content " >
< div class = " container-fluid " >
< div class = " row " >
<!-- Total Expense -->
< div class = " col-lg-4 col-6 " >
< div class = " small-box bg-info " >
< div class = " inner " >
< h3 > Rp {{ number_format ( $forms -> sum ( 'total' ), 0 , ',' , '.' ) }} </ h3 >
< p > Total Expense </ p >
</ div >
< div class = " icon " >
< i class = " fas fa-wallet " ></ i >
</ div >
</ div >
</ div >
<!-- Approved Expense -->
< div class = " col-lg-4 col-6 " >
< div class = " small-box bg-success " >
< div class = " inner " >
2025-01-02 17:59:33 +07:00
< h3 > Rp {{ number_format ( $forms -> whereIn ( 'status' , [ 'Approved' , 'Closed' ]) -> sum ( 'approved_total' ), 0 , ',' , '.' ) }} </ h3 >
2024-12-24 11:40:49 +07:00
< p > Approved Expenses </ p >
</ div >
< div class = " icon " >
< i class = " fas fa-check-circle " ></ i >
</ div >
</ div >
</ div >
<!-- Pending Expense -->
< div class = " col-lg-4 col-6 " >
< div class = " small-box bg-warning " >
< div class = " inner " >
< h3 class = " text-white " > Rp {{ number_format ( $forms -> where ( 'status' , 'On Progress' ) -> sum ( 'total' ), 0 , ',' , '.' ) }} </ h3 >
< p class = " text-white " > Pending Expenses </ p >
</ div >
< div class = " icon " >
< i class = " fas fa-hourglass-half " ></ i >
</ div >
</ div >
</ div >
</ div >
</ div >
</ section >
2024-12-12 18:18:26 +07:00
< section class = " content " >
< div class = " container-fluid " >
< div class = " card card-primary card-outline " >
< div class = " card-body " >
< h4 class = " header-title float-left " > List Data Forms Up Country Anda </ h4 >
< p class = " float-right mb-2 " >
2024-12-16 17:01:55 +07:00
@ if ( auth () -> user () -> can ( 'forms.country.create' ))
< a class = " btn btn-primary text-white " href = " { { route('forms.up-country.create') }} " >
Add New Expense Up Country
</ a >
@ endif
2024-12-12 18:18:26 +07:00
</ p >
< div class = " clearfix " ></ div >
< div class = " dataTables_wrapper dt-bootstrap4 mt-2 " >
@ include ( 'backend.layouts.partials.messages' )
2024-12-27 13:03:19 +07:00
< div class = " table-responsive " >
< table id = " dataTable "
class = " table table-bordered table-striped table-head-fixed dataTable dtr-inline "
style = " width:100% " >
< thead class = " bg-light text-capitalize " >
2024-12-16 17:01:55 +07:00
< tr >
2024-12-27 13:03:19 +07:00
< th > #</th>
2025-01-04 13:16:00 +07:00
< th > No Expense </ th >
2024-12-27 13:03:19 +07:00
< th > Nama </ th >
2025-01-08 14:12:45 +07:00
< th > Cabang </ th >
2024-12-27 13:03:19 +07:00
< th > Rayon </ th >
< th > Tanggal </ th >
< th > Tujuan </ th >
< th > Jarak </ th >
< th > Total </ th >
2025-01-02 17:59:33 +07:00
< th > Total Approved </ th >
2024-12-27 13:03:19 +07:00
< th > Account Number </ th >
< th > Status </ th >
2024-12-23 10:10:09 +07:00
@ if ( auth () -> user () -> can ( 'approval.approve' ))
2024-12-27 13:03:19 +07:00
< th > Approval </ th >
@ endif
@ if ( auth () -> user () -> can ( 'final_approval.approve' ))
< th > Final Approval </ th >
@ endif
< th > Aksi </ th >
</ tr >
</ thead >
< tbody >
@ php
use App\Helpers\NextCloudHelper ;
2025-01-07 17:23:42 +07:00
$role = auth () -> user () -> getRoleNames ()[ 0 ];
2024-12-27 13:03:19 +07:00
@ endphp
@ foreach ( $forms as $item )
< tr >
< td > {{ $loop -> iteration }} </ td >
2025-01-04 13:16:00 +07:00
< td > {{ $item -> expense_number }} </ td >
2024-12-27 13:03:19 +07:00
< td > {{ $item -> user -> name }} </ td >
2025-01-08 14:12:45 +07:00
< td > {{ $item -> user -> cabang -> cabang -> name }} </ td >
2024-12-27 13:03:19 +07:00
< td > {{ $item -> rayon -> code }} </ td >
< td > {{ \Carbon\Carbon :: parse ( $item -> tanggal ) -> locale ( 'id' ) -> isoFormat ( 'D MMMM Y' ) }} </ td >
< td > {{ $item -> tujuan }} </ td >
< td > {{ $item -> jarak }} km </ td >
< td > {{ number_format ( $item -> total , 0 , ',' , '.' ) }} </ td >
2025-01-02 17:59:33 +07:00
< td >
@ if ( $item -> approved_total )
{{ number_format ( $item -> approved_total , 0 , ',' , '.' ) }}
@ else
-
@ endif
</ td >
2024-12-27 13:03:19 +07:00
< td > {{ $item -> account_number }} </ td >
< td >
@ if ( $item -> status == 'On Progress' )
< span class = " badge badge-warning text-white " > {{ $item -> status }} </ span >
@ elseif ( $item -> status == 'Approved' || $item -> status == 'Final Approved' )
< span class = " badge badge-success text-white " > {{ $item -> status }} </ span >
2024-12-23 10:10:09 +07:00
@ else
2024-12-27 13:03:19 +07:00
< span class = " badge badge-danger text-white " > {{ $item -> status }} </ span >
@ endif
</ td >
@ if ( auth () -> user () -> can ( 'approval.approve' ))
< td >
{{ -- approve / reject button -- }}
@ if ( $item -> status == 'On Progress' )
2025-01-02 17:59:33 +07:00
< form action = " javascript:void(0); " class = " d-inline " >
< button type = " button "
2025-01-03 21:37:58 +07:00
class = " btn btn-success btn-sm open-approve-modal "
data - id = " { { route('forms.up-country.approve', $item->id ) }} " >
2024-12-27 13:03:19 +07:00
Approve
</ button >
</ form >
2025-01-02 17:59:33 +07:00
< 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?'); " >
2024-12-27 13:03:19 +07:00
@ csrf
@ method ( 'PUT' )
< button type = " submit " class = " btn btn-danger btn-sm " >
Reject
2024-12-23 10:10:09 +07:00
</ button >
</ form >
@ else
2024-12-27 13:03:19 +07:00
@ if ( $item -> approved_at )
{{ \Carbon\Carbon :: parse ( $item -> approved_at ) -> locale ( 'id' ) -> isoFormat ( 'D MMMM Y' ) }}
@ elseif ( $item -> rejected_at )
{{ \Carbon\Carbon :: parse ( $item -> rejected_at ) -> locale ( 'id' ) -> isoFormat ( 'D MMMM Y' ) }}
@ else
-
@ endif
2024-12-23 10:10:09 +07:00
@ endif
2024-12-27 13:03:19 +07:00
</ td >
2024-12-16 17:01:55 +07:00
@ endif
2024-12-27 13:03:19 +07:00
@ if ( auth () -> user () -> can ( 'final_approval.approve' ))
< td >
{{ -- approve / reject button -- }}
@ if ( $item -> status == 'Approved' && $item -> approved_at && ! $item -> final_approved_at )
< form action = " { { route('forms.up-country.final-approve', $item->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-success btn-sm " >
Final Approve
</ button >
</ form >
@ else
@ if ( $item -> final_approved_at && auth () -> user () -> can ( 'final_approval.open' ))
< form action = " { { route('forms.up-country.open', $item->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-success btn-sm " >
Open
</ button >
</ form >
@ elseif ( $item -> final_approved_at )
{{ \Carbon\Carbon :: parse ( $item -> approved_at ) -> locale ( 'id' ) -> isoFormat ( 'D MMMM Y' ) }}
@ else
-
@ endif
@ endif
</ td >
2024-12-16 17:01:55 +07:00
@ endif
2024-12-27 13:03:19 +07:00
< td >
2025-01-04 13:53:53 +07:00
@ if ( auth () -> user () -> can ( 'forms.country.view' ))
< a href = " { { route('forms.up-country.view', $item->id ) }} " class = " btn btn-primary btn-sm " >
< i class = " fas fa-eye text-white " ></ i >
</ a >
@ endif
2025-01-07 17:23:42 +07:00
@ if (( $role != 'Medical Representatif' && auth () -> user () -> can ( 'forms.country.edit' )) || ( $role == 'Medical Representatif' && $item -> status == 'On Progress' ))
2024-12-27 13:03:19 +07:00
< a href = " { { route('forms.up-country.edit', $item->id ) }} " class = " btn btn-warning btn-sm " >
< i class = " fas fa-edit text-white " ></ i >
</ a >
@ endif
2025-01-07 17:23:42 +07:00
@ if (( $role != 'Medical Representatif' && auth () -> user () -> can ( 'forms.country.delete' )) || ( $role == 'Medical Representatif' && $item -> status == 'On Progress' ))
2024-12-27 13:03:19 +07:00
< form action = " { { route('forms.up-country.destroy', $item->id ) }} " method = " POST " class = " d-inline " onsubmit = " return confirm('Are you sure you want to delete this item?'); " >
@ csrf
@ method ( 'DELETE' )
< button type = " submit " class = " btn btn-danger btn-sm " >
< i class = " fas fa-trash " ></ i >
</ button >
</ form >
@ endif
</ td >
</ tr >
@ endforeach
</ tbody >
</ table >
</ div >
2024-12-12 18:18:26 +07:00
</ div >
</ div >
</ div >
</ div >
</ section >
2025-01-02 17:59:33 +07:00
< section >
< div class = " modal fade " id = " approveModal " tabindex = " -1 " role = " dialog " aria - labelledby = " approveModalLabel " aria - hidden = " true " >
2025-01-02 18:32:09 +07:00
< div class = " modal-dialog modal-lg " role = " document " >
2025-01-02 17:59:33 +07:00
< div class = " modal-content " >
< form id = " approveForm " method = " POST " action = " " >
@ csrf
@ method ( 'PUT' )
< div class = " modal-header " >
< h5 class = " modal-title " id = " approveModalLabel " > Approve Item </ h5 >
< button type = " button " class = " close " data - dismiss = " modal " aria - label = " Close " >
< span aria - hidden = " true " >& times ; </ span >
</ button >
</ div >
< div class = " modal-body " >
<!-- Loading spinner -->
< div id = " loadingSpinner " class = " d-flex justify-content-center align-items-center " style = " height: 200px; " >
< div class = " spinner-border text-primary " role = " status " >
< span class = " sr-only " > Loading ...</ span >
</ div >
</ div >
<!-- Modal content ( hidden initially ) -->
< div id = " modalContent " class = " d-none " >
2025-01-02 18:32:09 +07:00
< p > Please review the details below :</ p >
< ul class = " list-group " >
< li class = " list-group-item " >
< strong > Expense Number :</ strong > < span id = " expense_number " ></ span >
</ li >
< li class = " list-group-item " >
< strong > User :</ strong > < span id = " user " ></ span >
</ li >
< li class = " list-group-item " >
< strong > Tipe :</ strong > Up Country
</ li >
< li class = " list-group-item " >
< strong > Rayon :</ strong > < span id = " rayon " ></ span >
</ li >
< li class = " list-group-item " >
< strong > Tanggal :</ strong > < span id = " tanggal " ></ span >
</ li >
< li class = " list-group-item " >
< strong > Tujuan :</ strong > < span id = " tujuan " ></ span >
</ li >
< li class = " list-group-item " >
< strong > Jarak :</ strong > < span id = " jarak " ></ span >
</ li >
< li class = " list-group-item " >
2025-01-03 21:37:58 +07:00
< strong > Bukti Allowance :</ strong > < span id = " bukti_allowance " ></ span >
2025-01-02 18:32:09 +07:00
</ li >
< li class = " list-group-item " >
2025-01-03 21:37:58 +07:00
< strong > Bukti Transport Dalam Kota :</ strong > < span id = " bukti_transport_dalkot " ></ span >
2025-01-02 18:32:09 +07:00
</ li >
< li class = " list-group-item " >
2025-01-03 21:37:58 +07:00
< strong > Bukti Transport Antar Kota :</ strong > < span id = " bukti_transport_ankot " ></ span >
</ li >
< li class = " list-group-item " >
< strong > Bukti Hotel :</ strong > < span id = " bukti_hotel " ></ span >
2025-01-02 18:32:09 +07:00
</ li >
</ ul >
< p class = " mt-2 " > Please select the items you want to approve :</ p >
2025-01-02 17:59:33 +07:00
< ul class = " list-group list-unstyled " >
2025-01-02 18:32:09 +07:00
< li >
< div class = " form-group " >
< div class = " custom-control custom-checkbox " >
< input type = " checkbox " class = " custom-control-input " id = " allowance " name = " allowance " >
< label class = " custom-control-label " for = " allowance " > Allowance ( < span id = " allowance_value " ></ span > ) </ label >
</ div >
</ div >
</ li >
< li >
< div class = " form-group " >
< div class = " custom-control custom-checkbox " >
< input type = " checkbox " class = " custom-control-input " id = " transport_dalkot " name = " transport_dalkot " >
< label class = " custom-control-label " for = " transport_dalkot " > Transport Dalkot ( < span id = " transport_dalkot_value " ></ span > ) </ label >
</ div >
2025-01-02 17:59:33 +07:00
</ div >
2025-01-02 18:32:09 +07:00
</ li >
< li >
< div class = " form-group " >
< div class = " custom-control custom-checkbox " >
< input type = " checkbox " class = " custom-control-input " id = " transport_ankot " name = " transport_ankot " >
< label class = " custom-control-label " for = " transport_ankot " > Transport Ankot ( < span id = " transport_ankot_value " ></ span > ) </ label >
</ div >
2025-01-02 17:59:33 +07:00
</ div >
2025-01-02 18:32:09 +07:00
</ li >
< li >
< div class = " form-group " >
< div class = " custom-control custom-checkbox " >
< input type = " checkbox " class = " custom-control-input " id = " hotel " name = " hotel " >
< label class = " custom-control-label " for = " hotel " > Hotel ( < span id = " hotel_value " ></ span > ) </ label >
</ div >
2025-01-02 17:59:33 +07:00
</ div >
2025-01-02 18:32:09 +07:00
</ li >
< li >
< div class = " form-group " >
< label for = " total " > Total </ label >
< input type = " text " class = " form-control " id = " total " name = " total " value = " 0 " readonly >
2025-01-02 17:59:33 +07:00
</ div >
2025-01-02 18:32:09 +07:00
</ li >
</ ul >
2025-01-02 17:59:33 +07:00
</ div >
</ div >
< div class = " modal-footer " >
< button type = " button " class = " btn btn-secondary " data - dismiss = " modal " > Cancel </ button >
< button type = " submit " class = " btn btn-primary " > Approve </ button >
</ div >
</ form >
</ div >
</ div >
</ div >
</ section >
2024-12-12 18:18:26 +07:00
@ endsection
2024-12-24 11:40:49 +07:00
@ section ( 'scripts' )
< script >
2025-01-02 17:59:33 +07:00
$ ( document ) . ready ( function () {
// Uncheck all checkboxes on page refresh
$ ( '.custom-control-input' ) . prop ( 'checked' , false );
if ( $ ( '#dataTable' ) . length ) {
$ ( '#dataTable' ) . DataTable ({
responsive : false ,
dom : 'Bfrtip' ,
2025-01-08 14:12:45 +07:00
buttons : [ 'excel' , 'pdf' , 'print' , 'colvis' ],
2025-01-02 17:59:33 +07:00
});
}
// Handle Approve Button Click
$ ( '.open-approve-modal' ) . on ( 'click' , function () {
const approveUrl = $ ( this ) . data ( 'id' );
// Show spinner and hide content initially
$ ( '#loadingSpinner' ) . show ();
$ ( '#modalContent' ) . addClass ( 'd-none' );
$ ( '#approveForm' ) . attr ( 'action' , approveUrl ); // Set the form action
2025-01-03 21:37:58 +07:00
$ ( '#loadingSpinner' ) . addClass ( 'd-flex' );
2025-01-02 17:59:33 +07:00
$ ( '#approveModal' ) . modal ( 'show' ); // Show the modal
// Get detail from /forms/up-country/detail/{id}
$ . get ( approveUrl . replace ( 'approve' , 'detail' ), function ( data ) {
const formatter = new Intl . NumberFormat ( 'id-ID' , {
style : 'currency' ,
currency : 'IDR' ,
minimumFractionDigits : 0
});
$ ( '#allowance_value' ) . text ( formatter . format ( data . allowance ));
$ ( '#transport_dalkot_value' ) . text ( formatter . format ( data . transport_dalkot ));
$ ( '#transport_ankot_value' ) . text ( formatter . format ( data . transport_ankot ));
$ ( '#hotel_value' ) . text ( formatter . format ( data . hotel ));
// Assign data values to checkboxes
$ ( '#allowance' ) . data ( 'value' , data . allowance );
$ ( '#transport_dalkot' ) . data ( 'value' , data . transport_dalkot );
$ ( '#transport_ankot' ) . data ( 'value' , data . transport_ankot );
$ ( '#hotel' ) . data ( 'value' , data . hotel );
// Detail data
$ ( '#user' ) . text ( data . user . name );
2025-01-02 18:32:09 +07:00
$ ( '#expense_number' ) . text ( data . expense_number );
2025-01-02 17:59:33 +07:00
$ ( '#rayon' ) . text ( data . rayon . code );
$ ( '#tanggal' ) . text ( new Date ( data . tanggal ) . toLocaleDateString ( 'id-ID' , {
year : 'numeric' ,
month : 'long' ,
day : 'numeric'
}));
$ ( '#tujuan' ) . text ( data . tujuan );
$ ( '#jarak' ) . text ( data . jarak + ' km' );
2025-01-03 21:37:58 +07:00
$ ( '#bukti_allowance' ) . html ( data . bukti_allowance ? '<a href="' + data . bukti_allowance + '" target="_blank">Download</a>' : '-' );
$ ( '#bukti_transport_dalkot' ) . html ( data . bukti_transport_dalkot ? '<a href="' + data . bukti_transport_dalkot + '" target="_blank">Download</a>' : '-' );
$ ( '#bukti_transport_ankot' ) . html ( data . bukti_transport_ankot ? '<a href="' + data . bukti_transport_ankot + '" target="_blank">Download</a>' : '-' );
$ ( '#bukti_hotel' ) . html ( data . bukti_hotel ? '<a href="' + data . bukti_hotel + '" target="_blank">Download</a>' : '-' );
2025-01-02 17:59:33 +07:00
// Hide spinner and show content
$ ( '#loadingSpinner' ) . hide ();
$ ( '#loadingSpinner' ) . removeClass ( 'd-flex' );
$ ( '#loadingSpinner' ) . addClass ( 'd-none' );
$ ( '#modalContent' ) . removeClass ( 'd-none' );
// Reset the total to zero
$ ( '#total' ) . val ( 0 );
});
});
// Update total dynamically
$ ( '.custom-control-input' ) . on ( 'change' , function () {
let total = 0 ;
// Calculate the total based on checked checkboxes
$ ( '.custom-control-input:checked' ) . each ( function () {
total += parseFloat ( $ ( this ) . data ( 'value' ) || 0 );
});
// Update the total field with formatted value
const formatter = new Intl . NumberFormat ( 'id-ID' , {
style : 'currency' ,
currency : 'IDR' ,
minimumFractionDigits : 0
});
$ ( '#total' ) . val ( formatter . format ( total ));
});
// Uncheck all checkboxes when the modal is closed
$ ( '#approveModal' ) . on ( 'hidden.bs.modal' , function () {
$ ( '.custom-control-input' ) . prop ( 'checked' , false ); // Uncheck all checkboxes
$ ( '#total' ) . val ( '0' ); // Reset total to 0
});
});
</ script >
2024-12-24 11:40:49 +07:00
@ endsection