@extends('layouts.app') @section('title', __('rma.create_rma')) @section('content')

@lang('rma.create_rma')

@lang('rma.create_intro')

@lang('rma.rma_cases')
@if($errors->any())
@endif @if(empty($sale))
@lang('rma.select_invoice_guidance')
@component('components.widget', ['class' => 'box-primary', 'title' => '1. '.__('rma.select_invoice')])
Start with the original sale. This keeps the return tied to the correct customer, quantities, and warranty.
@lang('messages.date') @lang('sale.invoice_no') @lang('contact.customer') @lang('purchase.business_location') @lang('sale.total') @lang('messages.action')
@endcomponent @endif @if(!empty($sale)) {!! Form::open(['url' => action([\App\Http\Controllers\RmaController::class, 'store']), 'method' => 'post', 'files' => true, 'id' => 'rma_create_form']) !!} @component('components.widget', ['class' => 'box-primary', 'title' => '1. '.__('rma.case_details')])

@lang('rma.case_setup_guidance')

{!! Form::hidden('sale_id', $sale->id) !!}
@lang('rma.sale_invoice'):
{{ $sale->invoice_no }}
@lang('rma.customer'):
{{ optional($sale->contact)->supplier_business_name ?: optional($sale->contact)->name }}
@lang('purchase.business_location'):
{{ optional($sale->location)->name }}
{!! Form::label('after_sales_location_id', __('rma.after_sales_location') . ':') !!} {!! Form::select('after_sales_location_id', $business_locations, $default_after_sales_location_id ?? $sale->location_id, ['class' => 'form-control select2', 'style' => 'width:100%']) !!}
@endcomponent @component('components.widget', ['class' => 'box-primary', 'title' => '2. '.__('rma.selected_items')])

@lang('rma.select_items_guidance')

@foreach($sale->sell_lines as $sell_line) @php $unit_name = optional($sell_line->sub_unit)->short_name ?: optional(optional($sell_line->product)->unit)->short_name; $variation_parts = []; if (optional($sell_line->product)->type == 'variable' && !empty($sell_line->variations) && !empty($sell_line->variations->product_variation)) { $variation_parts[] = $sell_line->variations->product_variation->name; if ($sell_line->variations->name !== $sell_line->variations->product_variation->name) { $variation_parts[] = $sell_line->variations->name; } } @endphp @endforeach
@lang('product.product_name') @lang('rma.available_qty') @lang('rma.quantity') @lang('rma.issue_type') @lang('rma.reason') @lang('rma.issue_note') @lang('rma.condition_note') @lang('rma.warranty') @lang('rma.picture')
@if($sell_line->available_rma_quantity > 0) {!! Form::checkbox("items[$sell_line->id][selected]", 1, old("items.$sell_line->id.selected"), ['class' => 'rma-item-selected']) !!} @endif {{ optional($sell_line->product)->name }} @if(!empty($variation_parts))
{{ implode(' - ', $variation_parts) }} @endif
{{ @format_quantity($sell_line->available_rma_quantity) }} {{ $unit_name }} {!! Form::number("items[$sell_line->id][quantity]", old("items.$sell_line->id.quantity"), ['class' => 'form-control rma-quantity', 'step' => '0.01', 'min' => '0', 'max' => $sell_line->available_rma_quantity, 'data-max' => $sell_line->available_rma_quantity, 'data-error-message' => __('rma.quantity_exceeds_available', ['qty' => @format_quantity($sell_line->available_rma_quantity)])]) !!} @error("items.$sell_line->id.quantity") {{ $message }} @enderror {!! Form::select("items[$sell_line->id][issue_type]", \App\RmaItem::issueTypes(), null, ['class' => 'form-control select2', 'style' => 'width:100%', 'placeholder' => __('messages.please_select')]) !!} {!! Form::select("items[$sell_line->id][reason]", \App\RmaItem::intakeReasons(), null, ['class' => 'form-control select2', 'style' => 'width:100%', 'placeholder' => __('messages.please_select')]) !!} {!! Form::textarea("items[$sell_line->id][issue_note]", null, ['class' => 'form-control', 'rows' => 2]) !!} {!! Form::textarea("items[$sell_line->id][condition_note]", null, ['class' => 'form-control', 'rows' => 2]) !!} {{ $sell_line->warranty_details['status'] }} @if(!empty($sell_line->warranty_details['expires_at']))
{{ @format_datetime($sell_line->warranty_details['expires_at']) }} @endif
@endcomponent @component('components.widget', ['class' => 'box-primary', 'title' => '3. Review and Create'])

@lang('rma.review_create_guidance')

{!! Form::label('internal_note', __('rma.internal_note') . ':') !!} {!! Form::textarea('internal_note', old('internal_note'), ['class' => 'form-control', 'rows' => 3, 'placeholder' => 'Optional note for your team']) !!}
@lang('messages.cancel')
@endcomponent {!! Form::close() !!} @endif
@endsection @section('javascript') @endsection