ultimatepos/Modules/Maintenance/Resources/views/rebuilds/show.blade.php

184 lines
10 KiB
PHP

@extends('layouts.app')
@section('title', $rebuild->title)
@section('content')
@include('maintenance::layouts.nav')
@php $util = app(\Modules\Maintenance\Utils\MaintenanceUtil::class); @endphp
<section class="content no-print mt-page">
<div class="mt-page-header">
<h1>
{{ $rebuild->title }}
<small class="text-muted"><code>{{ $rebuild->rebuild_number }}</code></small>
</h1>
<div>
@can('maintenance.rebuild.update')
@if($rebuild->status === 'draft')
<form method="post" action="{{ action([\Modules\Maintenance\Http\Controllers\RebuildController::class, 'start'], [$rebuild->id]) }}" style="display:inline;">
@csrf
<button type="submit" class="btn btn-success"><i class="fa fa-play"></i> @lang('maintenance::lang.rebuild_start')</button>
</form>
@elseif(!in_array($rebuild->status, ['completed', 'cancelled', 'on_hold']))
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#mm_advance_modal">
<i class="fa fa-forward"></i> @lang('maintenance::lang.rebuild_advance_phase')
</button>
<form method="post" action="{{ action([\Modules\Maintenance\Http\Controllers\RebuildController::class, 'hold'], [$rebuild->id]) }}" style="display:inline;">
@csrf
<button type="submit" class="btn btn-warning">@lang('maintenance::lang.rebuild_hold')</button>
</form>
@endif
@if(!in_array($rebuild->status, ['completed', 'cancelled']))
<form method="post" action="{{ action([\Modules\Maintenance\Http\Controllers\RebuildController::class, 'cancel'], [$rebuild->id]) }}" style="display:inline;" onsubmit="return confirm('@lang('maintenance::lang.confirm_cancel_rebuild')')">
@csrf
<button type="submit" class="btn btn-danger">@lang('maintenance::lang.rebuild_cancel')</button>
</form>
@endif
<a href="{{ action([\Modules\Maintenance\Http\Controllers\RebuildController::class, 'edit'], [$rebuild->id]) }}" class="btn btn-primary">@lang('maintenance::lang.edit')</a>
@endcan
<a href="{{ action([\Modules\Maintenance\Http\Controllers\RebuildController::class, 'index']) }}" class="btn btn-default">@lang('maintenance::lang.back')</a>
</div>
</div>
<div class="row">
<div class="col-md-8">
<div class="mt-card">
<div class="mt-card-header"><h3 class="mt-card-title">@lang('maintenance::lang.rebuild_workflow')</h3></div>
<div class="mt-card-body">
<div class="progress" style="height:22px;margin-bottom:20px;">
<div class="progress-bar progress-bar-success" style="width:{{ $rebuild->progress_percent }}%;min-width:2em;">
{{ $rebuild->progress_percent }}%
</div>
</div>
<ul class="list-group">
@foreach($rebuild->phases as $phase)
@php
$badge = 'default';
if ($phase->status === 'completed') { $badge = 'success'; }
elseif ($phase->status === 'in_progress') { $badge = 'primary'; }
@endphp
<li class="list-group-item {{ $phase->status === 'in_progress' ? 'list-group-item-info' : '' }}">
<span class="badge badge-{{ $badge }}">{{ $phase->status === 'in_progress' ? __('maintenance::lang.status_in_progress') : ($phase->status === 'completed' ? __('maintenance::lang.status_completed') : __('maintenance::lang.status_pending')) }}</span>
<strong>{{ $phase->title }}</strong>
@if($phase->actual_start)
<small class="text-muted"> {{ $util->formatDate($phase->actual_start) }}@if($phase->actual_end) {{ $util->formatDate($phase->actual_end) }}@endif</small>
@endif
@if($phase->notes)<br><small>{{ $phase->notes }}</small>@endif
</li>
@endforeach
</ul>
</div>
</div>
@if($rebuild->workOrders->isNotEmpty())
<div class="mt-card">
<div class="mt-card-header"><h3 class="mt-card-title">@lang('maintenance::lang.work_orders')</h3></div>
<div class="mt-card-body">
<table class="table table-striped">
<thead><tr><th>@lang('maintenance::lang.work_order_number')</th><th>@lang('maintenance::lang.equipment')</th><th>@lang('maintenance::lang.status')</th></tr></thead>
<tbody>
@foreach($rebuild->workOrders as $wo)
<tr>
<td><a href="{{ action([\Modules\Maintenance\Http\Controllers\WorkOrderController::class, 'show'], [$wo->id]) }}">{{ $wo->work_order_number }}</a></td>
<td>{{ $wo->equipment?->name ?? '—' }}</td>
<td>{{ $util->statusLabel($wo->status) }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@endif
</div>
<div class="col-md-4">
<div class="mt-card">
<div class="mt-card-header"><h3 class="mt-card-title">@lang('maintenance::lang.basic_info')</h3></div>
<div class="mt-card-body">
<table class="table table-condensed">
<tr><th>@lang('maintenance::lang.status')</th><td>{{ $statuses[$rebuild->status] ?? $rebuild->status }}</td></tr>
<tr><th>@lang('maintenance::lang.scope_type')</th><td>{{ $rebuild->scope_type === 'production_line' ? __('maintenance::lang.scope_production_line') : __('maintenance::lang.scope_equipment') }}</td></tr>
<tr><th>@lang('maintenance::lang.production_line')</th><td>{{ $rebuild->productionLine?->name ?? '—' }}</td></tr>
<tr><th>@lang('maintenance::lang.supervisor')</th><td>{{ $rebuild->supervisor ? trim($rebuild->supervisor->first_name.' '.($rebuild->supervisor->last_name ?? '')) : '—' }}</td></tr>
<tr><th>@lang('maintenance::lang.planned_start')</th><td>{{ $util->formatDate($rebuild->planned_start_date) ?? '—' }}</td></tr>
<tr><th>@lang('maintenance::lang.planned_end')</th><td>{{ $util->formatDate($rebuild->planned_end_date) ?? '—' }}</td></tr>
<tr><th>@lang('maintenance::lang.estimated_cost')</th><td>{{ $util->formatMoney($rebuild->estimated_cost) }}</td></tr>
<tr><th>@lang('maintenance::lang.actual_cost')</th><td>{{ $util->formatMoney($rebuild->actual_cost) }}</td></tr>
</table>
@if($rebuild->reason)<p><strong>@lang('maintenance::lang.rebuild_reason'):</strong> {{ $rebuild->reason }}</p>@endif
@if($rebuild->description)<p><strong>@lang('maintenance::lang.description'):</strong> {{ $rebuild->description }}</p>@endif
</div>
</div>
<div class="mt-card">
<div class="mt-card-header"><h3 class="mt-card-title">@lang('maintenance::lang.equipment') ({{ $rebuild->equipmentItems->count() }})</h3></div>
<div class="mt-card-body">
<ul class="list-unstyled">
@foreach($rebuild->equipmentItems as $eq)
<li style="margin-bottom:8px;">
<a href="{{ action([\Modules\Maintenance\Http\Controllers\EquipmentController::class, 'show'], [$eq->id]) }}">{{ $eq->name }}</a>
@if($eq->pivot->pre_rebuild_health)<br><small class="text-muted">@lang('maintenance::lang.health_before'): {{ $eq->pivot->pre_rebuild_health }}%</small>@endif
</li>
@endforeach
</ul>
</div>
</div>
</div>
</div>
@if(!empty($materialPanel))
<div class="row" style="margin-top:20px;">
<div class="col-md-12">
@include('maintenance::materials.panel', $materialPanel)
</div>
</div>
@endif
@if(!empty($missionPanel))
<div class="row" style="margin-top:20px;">
<div class="col-md-12">
@include('maintenance::field_missions.panel', $missionPanel)
</div>
</div>
@endif
</section>
@can('maintenance.rebuild.update')
<div class="modal fade" id="mm_advance_modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
{!! Form::open(['url' => action([\Modules\Maintenance\Http\Controllers\RebuildController::class, 'advancePhase'], [$rebuild->id]), 'method' => 'post']) !!}
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">@lang('maintenance::lang.rebuild_advance_phase')</h4>
</div>
<div class="modal-body">
<div class="form-group">
{!! Form::label('notes', __('maintenance::lang.phase_notes') . ':') !!}
{!! Form::textarea('notes', null, ['class' => 'form-control', 'rows' => 3]) !!}
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">@lang('maintenance::lang.close')</button>
<button type="submit" class="btn btn-success">@lang('maintenance::lang.rebuild_complete_phase')</button>
</div>
{!! Form::close() !!}
</div>
</div>
</div>
@endcan
@endsection
@section('javascript')
<script>
$(function(){
$('.select2').select2();
$('#fm_mission_panel .fm_item_type').on('change', function() {
var t = $(this).val();
$('#fm_mission_panel .fm_field_spare').toggle(t === 'spare_part');
$('#fm_mission_panel .fm_field_tool').toggle(t === 'tool');
});
});
</script>
@endsection