@extends(backpack_view('blank')) @section('content') @php $locale = request()->query('_locale', app()->getLocale()); $isSpanish = $locale === 'es'; // English values are the canonical values submitted by the form. $productTypes = [ 'Originator Brand' => $isSpanish ? 'Marca original' : 'Originator Brand', 'Generic' => $isSpanish ? 'Genérico' : 'Generic', 'Biosimilar' => 'Biosimilar', 'Biocomparable' => 'Biocomparable', 'API Only' => $isSpanish ? 'Solo API' : 'API Only', 'Special Import/Named Patient' => $isSpanish ? 'Importación especial / paciente nominal' : 'Special Import/Named Patient', 'Govt Procurement Only' => $isSpanish ? 'Solo para compras gubernamentales' : 'Govt Procurement Only', ]; // Normalize translated product-type labels to canonical English values. $spanishToEnglish = [ 'Marca original' => 'Originator Brand', 'Genérico' => 'Generic', 'Solo API' => 'API Only', 'Importación especial / paciente nominal' => 'Special Import/Named Patient', 'Solo para compras gubernamentales' => 'Govt Procurement Only', ]; // Read a translatable value from JSON, an array, or a string. $localizedValue = function ($value) use ($locale) { if (is_string($value)) { $decoded = json_decode($value, true); if (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) { return $decoded[$locale] ?? $decoded['en'] ?? ''; } } if (is_array($value)) { return $value[$locale] ?? $value['en'] ?? ''; } return $value ?? ''; }; @endphp

{{ $isSpanish ? 'Edición masiva de productos' : 'Bulk Edit Products' }}

@csrf
@foreach($products as $product) @php $productType = $localizedValue($product->product_type); $brandNames = $localizedValue($product->brand_names); $genericName = $localizedValue($product->generic_name); $therapeuticClass = $localizedValue($product->therapeutic_class); // Handle values saved in either English or Spanish. $canonicalProductType = $spanishToEnglish[$productType] ?? $productType; // Retain user input after validation errors. $oldProductType = old( 'products.'.$product->id.'.product_type', $canonicalProductType ); $oldProductType = $spanishToEnglish[$oldProductType] ?? $oldProductType; @endphp @endforeach
ID {{ $isSpanish ? 'Nombre genérico' : 'Generic Name' }} {{ $isSpanish ? 'Nombres comerciales' : 'Brand Names' }} {{ $isSpanish ? 'Tipo de producto' : 'Product Type' }} {{ $isSpanish ? 'Concentración' : 'Strength' }} {{ $isSpanish ? 'Clase terapéutica' : 'Therapeutic Class' }} {{ $isSpanish ? 'Precio' : 'Price' }} {{ $isSpanish ? 'Costo de adquisición mayorista (WAC)' : 'WAC (Wholesale Acquisition Costs)' }}
{{ $product->id }} {{ $genericName }}
{{ $isSpanish ? 'Volver' : 'Back' }}
@endsection