production_ingredients.recipe_phase_id; Formular sendet die Phase je Zeile, Vorbelegung je Rohstoff|Phase. Altbestand ohne Phase wird nur einmal eingesetzt. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
41 lines
2.1 KiB
PHP
41 lines
2.1 KiB
PHP
@extends('layouts.layout-2')
|
|
|
|
@section('content')
|
|
<h4 class="font-weight-bold py-2 mb-2">
|
|
{{ __('Produktion bearbeiten') }} #{{ $model->id }}
|
|
@if ($model->isDraft())
|
|
<span class="badge badge-warning align-middle ml-1">{{ __('Entwurf') }}</span>
|
|
@endif
|
|
</h4>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<form method="post" action="{{ route('admin.inventory.productions.update', $model) }}" id="form-production">
|
|
@csrf
|
|
@method('PUT')
|
|
@include('admin.inventory.productions._form_fields', ['isEdit' => true])
|
|
|
|
<button type="submit" name="save_mode" value="complete" class="btn btn-primary" id="btn-submit-production">{{ __('Produktion abschließen') }}</button>
|
|
{{-- AP-43: „Zwischenspeichern" nur solange die Produktion noch nicht gebucht ist (Entwurf). --}}
|
|
@if ($model->isDraft())
|
|
<button type="submit" name="save_mode" value="draft" class="btn btn-outline-primary" id="btn-save-draft" formnovalidate>{{ __('Zwischenspeichern (Entwurf)') }}</button>
|
|
@endif
|
|
<a href="{{ route('admin.inventory.productions.show', $model) }}" class="btn btn-outline-secondary">{{ __('Abbrechen') }}</a>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
@endsection
|
|
|
|
@section('scripts')
|
|
@php
|
|
// AP-27: Zeilen je Charge (batch_key) zusammenfassen — mehrere Einkäufe derselben Charge = eine Formularzeile.
|
|
// F-04: Schlüssel = Rohstoff|Phase, damit ein Rohstoff in zwei Phasen je Phase seinen Anteil behält.
|
|
$existingLines = $model->productionIngredients->groupBy(fn ($l) => $l->formGroupKey())->map(function ($lines) {
|
|
return $lines
|
|
->groupBy(fn ($l) => $l->formBatchKey())
|
|
->map(fn ($group, $key) => ['batch_key' => $key, 'quantity_used' => (float) $group->sum('quantity_used')])
|
|
->values();
|
|
});
|
|
@endphp
|
|
@include('admin.inventory.productions._scripts', ['existingLines' => $existingLines, 'excludeProductionId' => $model->id])
|
|
@endsection
|