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

32 lines
1.4 KiB
PHP

<script type="text/javascript">
$(function() {
var scContactLoaded = false;
$('a[href="#supplychain_tab"]').on('shown.bs.tab', function() {
if (scContactLoaded) return;
scContactLoaded = true;
loadContactScorecards();
});
function loadContactScorecards() {
$.get('{{ action([\Modules\SupplyChain\Http\Controllers\SupplierScorecardController::class, 'contactScorecards'], $contact->id) }}', function(res) {
var html = '';
if (!res.scorecards || !res.scorecards.length) {
html = '<tr><td colspan="5" class="text-center text-muted">@lang('supplychain::lang.no_records')</td></tr>';
} else {
$.each(res.scorecards, function(i, sc) {
html += '<tr>';
html += '<td>' + (sc.period || '—') + '</td>';
html += '<td>' + (sc.overall_score != null ? sc.overall_score : '—') + '</td>';
html += '<td>' + (sc.otif_score != null ? sc.otif_score : '—') + '</td>';
html += '<td>' + (sc.quality_score != null ? sc.quality_score : '—') + '</td>';
html += '<td><span class="label ' + (sc.risk_class || 'label-default') + '">' + (sc.risk_label || '—') + '</span></td>';
html += '</tr>';
});
}
$('#sc_contact_scorecards_body').html(html);
});
}
});
</script>