@extends('admin.layouts.app') @push('css') @endpush @section('content')

Editar Publicación @if($publication->ml_id) ({{ $publication->ml_id }}) @endif

{{-- Columna principal --}}
@csrf @method('PUT') {{-- Datos de publicación --}}
Datos de Publicación
El título es lo primero que ven los compradores 0/70
@error('titu_publ') {{ $message }} @enderror
@error('subt_publ') {{ $message }} @enderror
@error('deta_publ') {{ $message }} @enderror
@error('gara_publ') {{ $message }} @enderror
@error('condition') {{ $message }} @enderror
free_shipping) ? 'checked' : '' }}>
@error('free_shipping') {{ $message }} @enderror
{{-- Imágenes --}}
Imágenes (máx. 7)
@for($i = 0; $i <= 6; $i++) @php $field = $i == 0 ? 'url_image' : 'url_image' . $i; $val = old($field, $publication->$field); @endphp
@if($val)
@if($i > 0) @endif @if($i < 6) @endif
@else
Vacío
@endif
{{ $i == 0 ? 'Principal' : 'Imagen ' . $i }}
@endfor

@if($publication->url_video) @php preg_match('/(?:youtu\.be\/|youtube\.com\/(?:watch\?.*v=|embed\/|v\/))([^&?\s]+)/', $publication->url_video, $ytMatch); $ytId = $ytMatch[1] ?? null; @endphp @if($ytId)
@endif @endif
{{-- Observaciones --}}
{{-- Atributos ML (solo publicaciones publicadas) --}} @if($publication->isPublished())
Atributos ML
@if(count($publication->attributes_list) > 0) @foreach($publication->attributes_list as $attr) @php $attrId = $attr['id'] ?? ''; $attrName = $attr['name'] ?? $attrId; $attrValue = $attr['value_name'] ?? ''; $attrValueId = $attr['value_id'] ?? ''; $catAttr = collect($categoryAttributes ?? [])->firstWhere('id', $attrId); $allowedValues = $catAttr['values'] ?? []; $tags = $catAttr['tags'] ?? []; $isReadonly = isset($tags['read_only']) && $tags['read_only']; @endphp
@if($attrName !== $attrId && $attrId)
{{ $attrId }} @endif
@if($isReadonly) @elseif(count($allowedValues) > 0) @else @endif
@endforeach @else

Sin atributos. Hacé click en "Sync desde ML" para cargar las características.

@endif
@endif {{-- Precio, Stock, Tipo, Categoría en el form --}}
$
@error('prec_publ') {{ $message }} @enderror
@error('cant_publ') {{ $message }} @enderror
{{-- Categoría ML inline --}}
{{-- Costos y Margen --}}
Costos y Margen
{{-- Precio ML --}}

Precio ML

${{ number_format($publication->prec_publ ?? 0, 2, ',', '.') }}

{{-- Costo con IVA --}}

Costo (c/IVA)

@if($publication->cost_snapshot > 0) ${{ number_format($publication->cost_snapshot, 2, ',', '.') }}
{{ $publication->cost_snapshot_at ? $publication->cost_snapshot_at->format('d/m/Y H:i') : '' }} @else Sin datos @endif

{{-- Margen --}}

Margen

@if($publication->cost_snapshot > 0) @php $margin = $publication->computed_margin; @endphp

{{ number_format($margin, 1, ',', '.') }}%

@else

@endif
{{-- Ganancia por unidad --}}

Ganancia x Unidad

@if($publication->cost_snapshot > 0) @php $ganancia = ($publication->prec_publ ?? 0) - $publication->cost_snapshot; @endphp

${{ number_format($ganancia, 2, ',', '.') }}

@else

@endif
{{-- Refresh button --}} @if(isset($publication->id))
@csrf Toma el costo actual del producto desde el sistema desktop.
@endif {{-- Info about ML commissions --}}
Nota: El margen mostrado es bruto (Precio ML - Costo). No incluye comisiones de MercadoLibre (~11-13% según tipo de publicación) ni costos de envío.
{{-- Columna lateral --}}
{{-- Estado --}}
Estado
@switch($publication->estado) @case('active') Activa @break @case('paused') Pausada @break @case('closed') Cerrada @break @default Borrador @endswitch @if($publication->fe_estado) desde {{ $publication->fe_estado->format('d/m/Y') }} @endif
@if($publication->isPublished())
ML ID: @if($publication->ml_link) {{ $publication->ml_id }} @else {{ $publication->ml_id }} @endif
@endif
Producto: {{ $publication->co_arti }}
@if($publication->stock)
Stock físico: {{ $publication->stock->WW_STCK ?? 0 }}
@endif
Vendidas: {{ number_format($publication->cant_vend) }}
Sync: @if($publication->sincro == 1) OK @elseif($publication->sincro == 2) Error @else Pendiente @endif
@if($publication->last_synced_at)
Último sync: {{ $publication->last_synced_at->format('d/m/Y H:i') }}
@endif @if($publication->shipping_mode)
Envío: {{ $publication->free_shipping ? 'Gratis' : 'A cargo del comprador' }} ({{ $publication->shipping_mode }})
@endif @if($publication->isPublished())
Sync Stock
sync_stock ? 'checked' : '' }} onchange="toggleSyncFlag({{ $publication->id }}, 'stock', this.checked)">
Sync Precio
sync_price ? 'checked' : '' }} onchange="toggleSyncFlag({{ $publication->id }}, 'price', this.checked)">
@endif
{{-- Acciones según estado --}}
@if(!$publication->isPublished())
@csrf
@endif @if($publication->estado == 'active')
@csrf
@endif @if($publication->estado == 'paused')
@csrf
@endif @if($publication->isPublished() && $publication->estado != 'closed')
@csrf
@endif @if($publication->isPublished())
Gestionar Imágenes en ML
@csrf
@csrf
@endif @if(!$publication->isPublished())
@csrf @method('DELETE')
@endif
{{-- Tipo publicación --}}
Tipo
@php $currentType = old('tipo_publ', $publication->tipo_publ); @endphp
Premium
Gold Pro
Gold
Gratis
{{-- Producto asociado --}} @if($publication->stock)
Producto
Código: {{ $publication->co_arti }}
Descripción: {{ $publication->stock->DESCRI ?? '-' }}
Barras: {{ $publication->stock->CO_BARRA ?? '-' }}
Stock: {{ $publication->stock->WW_STCK ?? 0 }}
Precio Unitario: ${{ number_format($publication->stock->IM_UNITA ?? 0, 2, ',', '.') }}
Precio MLA: ${{ number_format($publication->stock->IM_MLA_VTA ?? 0, 2, ',', '.') }}
Ver Producto
@endif {{-- Métricas / Visitas --}} @if($publication->isPublished())
Métricas
Click en "Cargar" para consultar visitas desde ML.
{{-- Links a ML --}} @php $mlItemClean = str_replace('-', '', $publication->ml_id); @endphp
@endif {{-- Costos por tipo de publicación --}} @if($publication->isPublished())
Costos
@php $tipoActual = $publication->tipo_publ; $costos = [ 'gold_special' => ['label' => 'Gold Special', 'pct' => '~13% + envío', 'color' => 'primary', 'icon' => 'ri-vip-crown-line'], 'gold_pro' => ['label' => 'Gold Pro', 'pct' => '~11% + envío', 'color' => 'warning', 'icon' => 'ri-medal-line'], 'gold' => ['label' => 'Gold', 'pct' => '~10%', 'color' => 'secondary', 'icon' => 'ri-award-line'], 'silver' => ['label' => 'Silver', 'pct' => '~8%', 'color' => 'info', 'icon' => 'ri-copper-coin-line'], 'free' => ['label' => 'Gratis', 'pct' => 'Sin cargo', 'color' => 'success', 'icon' => 'ri-price-tag-line'], ]; @endphp
@foreach($costos as $tipo => $info)
{{ $info['label'] }} @if($tipoActual == $tipo) Actual @endif {{ $info['pct'] }}
@endforeach
Porcentajes aproximados. ML calcula costos exactos por cada venta (cargos, cuotas, envío e impuestos).
@php $mlItemClean2 = $mlItemClean ?? str_replace('-', '', $publication->ml_id); @endphp Ver costos exactos en ML
@endif
@endsection @push('js') @endpush