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>
35 lines
1.9 KiB
PHP
35 lines
1.9 KiB
PHP
@extends('layouts.layout-2')
|
|
|
|
@section('content')
|
|
<h4 class="font-weight-bold py-2 mb-2">{{ __('Neue Produktion') }}</h4>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<form method="post" action="{{ route('admin.inventory.productions.store') }}" id="form-production">
|
|
@csrf
|
|
@include('admin.inventory.productions._form_fields', ['isEdit' => false])
|
|
|
|
<button type="submit" name="save_mode" value="complete" class="btn btn-primary" id="btn-submit-production">{{ __('Produktion abschließen') }}</button>
|
|
{{-- AP-43: Zwischenspeichern als Entwurf — ohne Pflichtfeld-/Bestandsprüfung, bucht keinen Bestand. --}}
|
|
<button type="submit" name="save_mode" value="draft" class="btn btn-outline-primary" id="btn-save-draft" formnovalidate>{{ __('Zwischenspeichern (Entwurf)') }}</button>
|
|
<a href="{{ route('admin.inventory.productions.index') }}" 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
|
|
? $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' => null])
|
|
@endsection
|