<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('heading', null, []); ?> <?php echo e($supplier->name); ?> <?php $__env->endSlot(); ?>

    <div class="mb-4 flex items-center gap-2 text-sm text-gray-500">
        <a href="<?php echo e(route('suppliers.index')); ?>" class="hover:text-gray-700">Suppliers</a>
        <svg class="h-4 w-4 text-gray-300" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5"/></svg>
        <span><?php echo e($supplier->name); ?></span>
    </div>

    <?php if($supplier->is_flagged): ?>
    <div class="mb-5 rounded-xl border border-red-200 bg-red-50 p-4 flex items-start gap-3">
        <svg class="mt-0.5 h-5 w-5 flex-shrink-0 text-red-500" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"/></svg>
        <div>
            <p class="font-semibold text-red-800">This supplier is flagged</p>
            <?php if($supplier->flag_reason): ?>
                <p class="mt-0.5 text-sm text-red-700"><?php echo e($supplier->flag_reason); ?></p>
            <?php endif; ?>
        </div>
    </div>
    <?php endif; ?>

    <div class="grid grid-cols-1 gap-6 lg:grid-cols-3">
        
        <div class="lg:col-span-2 space-y-4">
            <div class="rounded-xl border border-gray-100 bg-white shadow-sm overflow-hidden">
                <div class="px-5 py-4 border-b border-gray-50 flex items-center justify-between">
                    <h3 class="font-semibold text-gray-900">Transaction History</h3>
                    <span class="text-sm text-gray-400"><?php echo e($receipts->total()); ?> receipt(s)</span>
                </div>
                <table class="w-full text-sm">
                    <thead class="bg-gray-50 text-xs uppercase tracking-wider text-gray-500">
                        <tr>
                            <th class="px-5 py-3 text-left">Date</th>
                            <th class="px-5 py-3 text-left">Item</th>
                            <th class="px-5 py-3 text-right">Qty</th>
                            <th class="px-5 py-3 text-left">Notes</th>
                            <th class="px-5 py-3 text-left">Logged By</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y divide-gray-50">
                        <?php $__empty_1 = true; $__currentLoopData = $receipts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $r): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr class="hover:bg-gray-50">
                            <td class="px-5 py-3 text-gray-900"><?php echo e($r->movement_date->format('d M Y')); ?></td>
                            <td class="px-5 py-3">
                                <?php if($r->item): ?>
                                    <a href="<?php echo e(route('inventory.show', $r->item)); ?>" class="text-primary-600 hover:underline">
                                        <?php echo e($r->item->item_name); ?>

                                    </a>
                                <?php else: ?>
                                    <span class="text-gray-400">—</span>
                                <?php endif; ?>
                            </td>
                            <td class="px-5 py-3 text-right font-semibold text-green-700">
                                +<?php echo e(number_format(abs($r->quantity), 2)); ?>

                                <?php if($r->item): ?> <?php echo e($r->item->unit); ?> <?php endif; ?>
                            </td>
                            <td class="px-5 py-3 text-xs text-gray-500"><?php echo e($r->notes ?: '—'); ?></td>
                            <td class="px-5 py-3 text-xs text-gray-500"><?php echo e($r->logger?->name ?? '—'); ?></td>
                        </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr><td colspan="5" class="px-5 py-6 text-center text-gray-400">No receipts recorded from this supplier.</td></tr>
                        <?php endif; ?>
                    </tbody>
                </table>
                <div class="px-5 py-3"><?php echo e($receipts->links()); ?></div>
            </div>
        </div>

        
        <div class="space-y-4">
            
            <div class="rounded-xl border border-gray-100 bg-white p-5 shadow-sm">
                <div class="mb-4 flex items-center justify-between">
                    <h3 class="font-semibold text-gray-900">Supplier Info</h3>
                    <a href="<?php echo e(route('suppliers.edit', $supplier)); ?>" class="text-xs text-primary-600 hover:underline">Edit</a>
                </div>
                <dl class="space-y-2 text-sm">
                    <?php if($supplier->business_name): ?>
                    <div>
                        <dt class="text-xs text-gray-500 uppercase tracking-wide">Business</dt>
                        <dd class="font-medium text-gray-900"><?php echo e($supplier->business_name); ?></dd>
                    </div>
                    <?php endif; ?>
                    <?php if($supplier->nickname): ?>
                    <div>
                        <dt class="text-xs text-gray-500 uppercase tracking-wide">Known As</dt>
                        <dd class="text-gray-700"><?php echo e($supplier->nickname); ?></dd>
                    </div>
                    <?php endif; ?>
                    <?php if($supplier->phone): ?>
                    <div>
                        <dt class="text-xs text-gray-500 uppercase tracking-wide mb-1">Phone</dt>
                        <dd class="flex items-center gap-2">
                            <span class="text-gray-700"><?php echo e($supplier->phone); ?></span>
                            <a href="tel:<?php echo e($supplier->phone); ?>"
                               class="inline-flex items-center gap-1 rounded-md border border-gray-200 bg-gray-50 px-2 py-0.5 text-xs font-medium text-gray-600 hover:bg-gray-100">
                                <svg class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M2.25 6.75c0 8.284 6.716 15 15 15h2.25a2.25 2.25 0 002.25-2.25v-1.372c0-.516-.351-.966-.852-1.091l-4.423-1.106c-.44-.11-.902.055-1.173.417l-.97 1.293c-.282.376-.769.542-1.21.38a12.035 12.035 0 01-7.143-7.143c-.162-.441.004-.928.38-1.21l1.293-.97c.363-.271.527-.734.417-1.173L6.963 3.102a1.125 1.125 0 00-1.091-.852H4.5A2.25 2.25 0 002.25 4.5v2.25z"/></svg>
                                Call
                            </a>
                            <?php if($supplier->wa_number && (!$supplier->whatsapp || $supplier->whatsapp === $supplier->phone)): ?>
                            <a href="https://wa.me/<?php echo e($supplier->wa_number); ?>" target="_blank" rel="noopener"
                               class="inline-flex items-center gap-1 rounded-md border border-green-200 bg-green-50 px-2 py-0.5 text-xs font-medium text-green-700 hover:bg-green-100">
                                <svg class="h-3 w-3" fill="currentColor" viewBox="0 0 24 24"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347z"/><path d="M12 0C5.373 0 0 5.373 0 12c0 2.127.558 4.122 1.532 5.852L.057 23.57a.75.75 0 00.914.914l5.717-1.475A11.94 11.94 0 0012 24c6.627 0 12-5.373 12-12S18.627 0 12 0zm0 21.75a9.713 9.713 0 01-4.93-1.347l-.353-.21-3.664.945.97-3.567-.228-.367A9.714 9.714 0 012.25 12c0-5.376 4.374-9.75 9.75-9.75S21.75 6.624 21.75 12 17.376 21.75 12 21.75z"/></svg>
                                WhatsApp
                            </a>
                            <?php endif; ?>
                        </dd>
                    </div>
                    <?php endif; ?>
                    <?php if($supplier->whatsapp && $supplier->whatsapp !== $supplier->phone): ?>
                    <div>
                        <dt class="text-xs text-gray-500 uppercase tracking-wide mb-1">WhatsApp</dt>
                        <dd class="flex items-center gap-2">
                            <span class="text-gray-700"><?php echo e($supplier->whatsapp); ?></span>
                            <?php if($supplier->wa_number): ?>
                            <a href="https://wa.me/<?php echo e($supplier->wa_number); ?>" target="_blank" rel="noopener"
                               class="inline-flex items-center gap-1 rounded-md border border-green-200 bg-green-50 px-2 py-0.5 text-xs font-medium text-green-700 hover:bg-green-100">
                                <svg class="h-3 w-3" fill="currentColor" viewBox="0 0 24 24"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347z"/><path d="M12 0C5.373 0 0 5.373 0 12c0 2.127.558 4.122 1.532 5.852L.057 23.57a.75.75 0 00.914.914l5.717-1.475A11.94 11.94 0 0012 24c6.627 0 12-5.373 12-12S18.627 0 12 0zm0 21.75a9.713 9.713 0 01-4.93-1.347l-.353-.21-3.664.945.97-3.567-.228-.367A9.714 9.714 0 012.25 12c0-5.376 4.374-9.75 9.75-9.75S21.75 6.624 21.75 12 17.376 21.75 12 21.75z"/></svg>
                                Chat on WhatsApp
                            </a>
                            <?php endif; ?>
                        </dd>
                    </div>
                    <?php endif; ?>
                    <?php if($supplier->email): ?>
                    <div>
                        <dt class="text-xs text-gray-500 uppercase tracking-wide">Email</dt>
                        <dd class="text-gray-700 break-all"><?php echo e($supplier->email); ?></dd>
                    </div>
                    <?php endif; ?>
                    <?php if($supplier->address): ?>
                    <div>
                        <dt class="text-xs text-gray-500 uppercase tracking-wide">Address</dt>
                        <dd class="text-gray-700"><?php echo e($supplier->address); ?></dd>
                    </div>
                    <?php endif; ?>
                    <?php if($supplier->landmark): ?>
                    <div>
                        <dt class="text-xs text-gray-500 uppercase tracking-wide">Landmark</dt>
                        <dd class="text-gray-700"><?php echo e($supplier->landmark); ?></dd>
                    </div>
                    <?php endif; ?>
                    <div class="border-t border-gray-50 pt-2">
                        <dt class="text-xs text-gray-500 uppercase tracking-wide">Total Receipts</dt>
                        <dd class="font-semibold text-gray-900"><?php echo e($receipts->total()); ?></dd>
                    </div>
                    <?php if($totalSpend > 0): ?>
                    <div>
                        <dt class="text-xs text-gray-500 uppercase tracking-wide">Est. Total Spend</dt>
                        <dd class="font-semibold text-green-700">₦<?php echo e(number_format($totalSpend)); ?></dd>
                    </div>
                    <?php endif; ?>
                </dl>
            </div>

            
            <?php if($supplier->notes): ?>
            <div class="rounded-xl border border-gray-100 bg-white p-5 shadow-sm">
                <h3 class="font-semibold text-gray-900 mb-2 text-sm">Notes</h3>
                <p class="text-sm text-gray-600 whitespace-pre-wrap"><?php echo e($supplier->notes); ?></p>
            </div>
            <?php endif; ?>

            
            <div class="rounded-xl border border-gray-100 bg-white p-5 shadow-sm">
                <h3 class="font-semibold text-gray-900 mb-3 text-sm">Integrity Label</h3>
                <form method="POST" action="<?php echo e(route('suppliers.flag', $supplier)); ?>" x-data="{ open: <?php echo e($supplier->is_flagged ? 'false' : 'true'); ?> }">
                    <?php echo csrf_field(); ?>
                    <?php if(!$supplier->is_flagged): ?>
                    <div x-show="open" class="space-y-2 mb-3">
                        <label class="block text-xs font-medium text-gray-600">Reason for flagging (optional)</label>
                        <textarea name="flag_reason" rows="2"
                                  class="w-full rounded-lg border-gray-200 text-xs focus:border-red-500 focus:ring-red-500"
                                  placeholder="e.g. Delivered short-weight bags, overcharged on last order…"></textarea>
                    </div>
                    <button type="submit"
                            class="w-full rounded-lg border border-red-200 bg-red-50 py-2 text-sm font-medium text-red-700 hover:bg-red-100">
                        ⚑ Flag This Supplier
                    </button>
                    <?php else: ?>
                    <p class="text-xs text-gray-500 mb-3">Reason: <span class="italic"><?php echo e($supplier->flag_reason ?: 'none given'); ?></span></p>
                    <button type="submit"
                            class="w-full rounded-lg border border-green-200 bg-green-50 py-2 text-sm font-medium text-green-700 hover:bg-green-100">
                        ✓ Remove Flag
                    </button>
                    <?php endif; ?>
                </form>
            </div>

            
            <form method="POST" action="<?php echo e(route('suppliers.destroy', $supplier)); ?>"
                  onsubmit="return confirm('Delete this supplier? Their transaction history will be preserved.')">
                <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                <button type="submit" class="w-full rounded-lg border border-gray-200 py-2 text-xs text-gray-400 hover:border-red-200 hover:text-red-500">
                    Delete Supplier
                </button>
            </form>
        </div>
    </div>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH C:\laragon\www\farm\resources\views\suppliers\show.blade.php ENDPATH**/ ?>