ultimatepos/Modules/Tms/Resources/views/contact/partial/tab_js.blade.php

35 lines
1.3 KiB
PHP

<script type="text/javascript">
$(document).ready(function() {
var tmsContactLoaded = false;
$('a[href="#tms_tab"]').on('shown.bs.tab', function() {
if (tmsContactLoaded) return;
tmsContactLoaded = true;
loadTmsContactShipments();
});
function loadTmsContactShipments() {
var contactId = {{ $contact->id }};
$.get('{{ action([\Modules\Tms\Http\Controllers\ContactTmsController::class, 'shipments'], ['contact_id' => $contact->id]) }}', function(res) {
var tbody = $('#tms_contact_shipments_table tbody');
tbody.empty();
if (!res.data || !res.data.length) {
$('#tms_contact_shipments_empty').show();
return;
}
$('#tms_contact_shipments_empty').hide();
res.data.forEach(function(s) {
tbody.append('<tr>' +
'<td>' + s.ref_no + '</td>' +
'<td>' + s.status + '</td>' +
'<td>' + (s.driver || '—') + '</td>' +
'<td>' + (s.vehicle || '—') + '</td>' +
'<td>' + (s.scheduled_at || '—') + '</td>' +
'<td><a href="' + s.url + '" class="btn btn-xs btn-info"><i class="fa fa-eye"></i></a></td>' +
'</tr>');
});
});
}
});
</script>