<?php $__env->startSection('title','Parties'); ?>
<?php $__env->startSection('page_title','Parties'); ?>
<?php $__env->startSection('content'); ?>
<div class="page-head"><div><h1>Customers, Vendors & Parties</h1><p>One legal entity can carry separate customer and vendor roles and ledgers.</p></div><?php if(auth()->user()->hasPermission('parties.create')): ?><a class="btn btn-primary" href="<?php echo e(route('parties.create')); ?>">+ Add Party</a><?php endif; ?></div>
<div class="card"><div class="toolbar"><form class="search"><input class="control" name="search" value="<?php echo e(request('search')); ?>" placeholder="Search name, TRN, phone or email"><select class="control" name="role" style="max-width:180px"><option value="">All roles</option><?php $__currentLoopData = \App\Enums\PartyRoleType::cases(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $role): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($role->value); ?>" <?php if(request('role')===$role->value): echo 'selected'; endif; ?>><?php echo e(ucwords(str_replace('_',' ',$role->value))); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select><button class="btn btn-secondary">Filter</button></form><span class="muted"><?php echo e($parties->total()); ?> parties</span></div>
<div class="table-wrap"><table class="table"><thead><tr><th>Party</th><th>Roles</th><th>TRN</th><th>Contact</th><th>Credit Terms</th><th>Status</th><th>Actions</th></tr></thead><tbody>
<?php $__empty_1 = true; $__currentLoopData = $parties; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $party): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><tr><td><strong><?php echo e($party->legal_name); ?></strong><?php if($party->trade_name): ?><div class="muted"><?php echo e($party->trade_name); ?></div><?php endif; ?></td><td><?php $__currentLoopData = $party->roles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $role): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><span class="badge badge-blue"><?php echo e(ucwords(str_replace('_',' ',$role->role->value ?? $role->role))); ?></span> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></td><td><?php echo e($party->trn ?: '—'); ?></td><td><?php echo e($party->phone ?: '—'); ?><div class="muted"><?php echo e($party->email); ?></div></td><td><?php echo e(number_format((float)$party->credit_limit,2)); ?> / <?php echo e($party->credit_period_days); ?> days</td><td><span class="badge <?php echo e($party->is_active?'badge-green':'badge-red'); ?>"><?php echo e($party->is_active?'Active':'Inactive'); ?></span></td><td><div class="actions"><a class="btn btn-secondary btn-sm" href="<?php echo e(route('parties.show',$party)); ?>">View</a><?php if(auth()->user()->hasPermission('parties.edit_draft')): ?><a class="btn btn-secondary btn-sm" href="<?php echo e(route('parties.edit',$party)); ?>">Edit</a><?php endif; ?></div></td></tr><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><tr><td colspan="7" class="empty">No parties found.</td></tr><?php endif; ?>
</tbody></table></div><?php echo e($parties->links()); ?></div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/cbo/public_html/resources/views/parties/index.blade.php ENDPATH**/ ?>