40 lines
1.8 KiB
PHP
40 lines
1.8 KiB
PHP
<script type="text/javascript">
|
|
$(function() {
|
|
var mmContactLoaded = false;
|
|
|
|
$('a[href="#maintenance_tab"]').on('shown.bs.tab', function() {
|
|
if (mmContactLoaded) return;
|
|
mmContactLoaded = true;
|
|
loadContactMaintenance();
|
|
});
|
|
|
|
function loadContactMaintenance() {
|
|
var contactId = {{ $contact->id }};
|
|
$.get('{{ action([\Modules\Maintenance\Http\Controllers\ContactMaintenanceController::class, 'equipment'], ['contact_id' => $contact->id]) }}', function(res) {
|
|
$('#mm_contact_summary').show();
|
|
$('#mm_eq_count').text(res.equipment.length);
|
|
$('#mm_proj_count').text(res.projects.length);
|
|
$('#mm_line_count').text(res.lines.length);
|
|
$('#mm_wo_count').text(res.open_work_orders);
|
|
|
|
var html = '';
|
|
if (!res.equipment.length) {
|
|
html = '<tr><td colspan="6" class="text-center text-muted">@lang('maintenance::lang.no_records')</td></tr>';
|
|
} else {
|
|
$.each(res.equipment, function(i, eq) {
|
|
html += '<tr>';
|
|
html += '<td>' + (eq.code || '—') + '</td>';
|
|
html += '<td>' + (eq.name || '—') + '</td>';
|
|
html += '<td>' + (eq.production_line ? eq.production_line.name : '—') + '</td>';
|
|
html += '<td>' + (eq.status_label || eq.status || '—') + '</td>';
|
|
html += '<td>' + (eq.health_percentage != null ? eq.health_percentage + '%' : '—') + '</td>';
|
|
html += '<td><a href="{{ url('maintenance/equipment') }}/' + eq.id + '" class="btn btn-xs btn-info"><i class="fa fa-eye"></i></a></td>';
|
|
html += '</tr>';
|
|
});
|
|
}
|
|
$('#mm_contact_equipment_body').html(html);
|
|
});
|
|
}
|
|
});
|
|
</script>
|