<?php $__env->startSection('title', 'Customer Details'); ?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid">
    <div class="row mb-4">
        <div class="col-md-12">
            <div class="d-flex justify-content-between align-items-center">
                <h2 class="h3 mb-0">Customer Details</h2>
                <div>
                    <a href="<?php echo e(route('customers.index')); ?>" class="btn btn-secondary">
                        <i class="fas fa-arrow-left"></i> Back to List
                    </a>
                    <a href="<?php echo e(route('customers.edit', $customer)); ?>" class="btn btn-warning">
                        <i class="fas fa-edit"></i> Edit
                    </a>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    <h5 class="mb-0">Customer Information</h5>
                </div>
                <div class="card-body">
                    <div class="row">
                        <div class="col-md-6">
                            <table class="table table-sm">
                                <tr>
                                    <th width="40%">Customer Code:</th>
                                    <td><?php echo e($customer->customer_code); ?></td>
                                </tr>
                                <tr>
                                    <th>Name:</th>
                                    <td><?php echo e($customer->name); ?></td>
                                </tr>
                                <tr>
                                    <th>Phone:</th>
                                    <td><?php echo e($customer->phone); ?></td>
                                </tr>
                                <tr>
                                    <th>Email:</th>
                                    <td><?php echo e($customer->email ?? 'N/A'); ?></td>
                                </tr>
                                <tr>
                                    <th>Customer Type:</th>
                                    <td>
                                        <span class="badge badge-<?php echo e($customer->customer_type == 'installment' ? 'warning' : 'success'); ?>">
                                            <?php echo e(ucfirst($customer->customer_type)); ?>

                                        </span>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <div class="col-md-6">
                            <table class="table table-sm">
                                <tr>
                                    <th width="40%">Outstanding Balance:</th>
                                    <td>
                                        <span class="text-danger font-weight-bold">
                                            ৳<?php echo e(number_format($customer->outstanding_balance, 2)); ?>

                                        </span>
                                    </td>
                                </tr>
                                <tr>
                                    <th>Credit Limit:</th>
                                    <td>৳<?php echo e(number_format($customer->credit_limit, 2)); ?></td>
                                </tr>
                                <tr>
                                    <th>Discount Rate:</th>
                                    <td><?php echo e(number_format($customer->discount_rate, 2)); ?>%</td>
                                </tr>
                                <tr>
                                    <th>Status:</th>
                                    <td>
                                        <span class="badge badge-<?php echo e($customer->is_active ? 'success' : 'danger'); ?>">
                                            <?php echo e($customer->is_active ? 'Active' : 'Inactive'); ?>

                                        </span>
                                    </td>
                                </tr>
                                <tr>
                                    <th>Created At:</th>
                                    <td><?php echo e($customer->created_at->format('d M, Y h:i A')); ?></td>
                                </tr>
                            </table>
                        </div>
                    </div>
                    
                    <?php if($customer->address): ?>
                    <div class="mt-3">
                        <h6 class="text-muted">Address:</h6>
                        <div class="border rounded p-3 bg-light">
                            <?php echo e($customer->address); ?>

                        </div>
                    </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
        
        <div class="col-md-4">
            <div class="card">
                <div class="card-header">
                    <h5 class="mb-0">Quick Actions</h5>
                </div>
                <div class="card-body">
                    <div class="d-grid gap-2">
                        <a href="#" class="btn btn-primary">
                            <i class="fas fa-shopping-cart"></i> New Sale
                        </a>
                        <a href="<?php echo e(route('customers.statement', $customer)); ?>" class="btn btn-info">
                            <i class="fas fa-file-invoice"></i> View Statement
                        </a>
                        <button type="button" class="btn btn-warning" data-toggle="modal" data-target="#updateBalanceModal">
                            <i class="fas fa-money-bill-wave"></i> Update Balance
                        </button>
                        <?php if($customer->is_active): ?>
                            <form action="<?php echo e(route('customers.destroy', $customer)); ?>" method="POST" class="d-grid">
                                <?php echo csrf_field(); ?>
                                <?php echo method_field('DELETE'); ?>
                                <button type="submit" class="btn btn-danger" 
                                        onclick="return confirm('Are you sure you want to delete this customer?')">
                                    <i class="fas fa-trash"></i> Delete Customer
                                </button>
                            </form>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
            
            <!-- Balance Update Modal -->
            <div class="modal fade" id="updateBalanceModal" tabindex="-1" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <form action="<?php echo e(route('customers.update-balance', $customer)); ?>" method="POST">
                            <?php echo csrf_field(); ?>
                            <div class="modal-header">
                                <h5 class="modal-title">Update Balance</h5>
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                    <span aria-hidden="true">&times;</span>
                                </button>
                            </div>
                            <div class="modal-body">
                                <div class="form-group">
                                    <label for="outstanding_balance">Outstanding Balance</label>
                                    <input type="number" step="0.01" class="form-control" 
                                           id="outstanding_balance" name="outstanding_balance" 
                                           value="<?php echo e($customer->outstanding_balance); ?>" required>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
                                <button type="submit" class="btn btn-primary">Update</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/naowarin/walton.naowarinternational.my.id/resources/views/customers/show.blade.php ENDPATH**/ ?>