<?php echo $__env->make('admin.layouts.header', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php echo $__env->make('admin.layouts.sidebar', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<div class="m-grid__item m-grid__item--fluid m-wrapper">
    <div class="m-subheader">
        <div class="d-flex align-items-center">
            <div class="mr-auto">
                <h3 class="m-subheader__title m-subheader__title--separator">
                    Partners
                </h3>
            </div>
            <a href="/admin/partner-system/partners/create" class="btn btn-accent m-btn m-btn--icon">
                <span><i class="fa fa-plus"></i>&nbsp; Add Partner</span>
            </a>
        </div>
    </div>

    <div class="m-content">
        <?php if(Session::has('success')): ?>
            <div class="alert alert-success alert-dismissible fade show" role="alert">
                <button type="button" class="close" data-dismiss="alert"></button>
                <?php echo e(Session::get('success')); ?>

            </div>
        <?php endif; ?>
        <?php if(Session::has('error')): ?>
            <div class="alert alert-danger alert-dismissible fade show" role="alert">
                <button type="button" class="close" data-dismiss="alert"></button>
                <?php echo e(Session::get('error')); ?>

            </div>
        <?php endif; ?>

        <div class="m-portlet m-portlet--mobile">
            <div class="m-portlet__head">
                <div class="m-portlet__head-caption">
                    <div class="m-portlet__head-title">
                        <span class="m-portlet__head-icon"><i class="fa fa-handshake-o"></i></span>
                        <h3 class="m-portlet__head-text">Partners <small class="text-muted">(<?php echo e($partners->total()); ?>)</small></h3>
                    </div>
                </div>
            </div>
            <div class="m-portlet__body">
                <div class="table-responsive">
                    <table class="table table-striped table-bordered m-table">
                        <thead>
                            <tr>
                                <th>Name</th>
                                <th>Company Type</th>
                                <th>City / State</th>
                                <th>Product</th>
                                <th>Created At</th>
                                <?php if(Session::has('Partner_Onboarding_Update|16-1-1') || Session::has('Partner_Onboarding_Config|16-1-2')): ?>
                                <th class="text-center">Actions</th>
                                <?php endif; ?>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $partners; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $partner): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td>
                                        <strong><?php echo e($partner->name); ?></strong>
                                    </td>
                                    <td><?php echo e($partner->company_type ?? '—'); ?></td>
                                    <td><?php echo e(collect([$partner->city, $partner->state])->filter()->implode(', ') ?: '—'); ?></td>
                                    <td><?php echo e($partner->product ?? '—'); ?></td>
                                    <td><?php echo e($partner->created_at->format('d M Y')); ?></td>
                                    <td class="text-center" style="white-space:nowrap;">
                                        <?php if(Session::has('Partner_Onboarding_Update|16-1-1')): ?>
                                        <a href="/admin/partner-system/partners/<?php echo e($partner->id); ?>/edit"
                                           class="btn btn-sm btn-outline-primary m-btn m-btn--icon" title="Edit">
                                            <i class="fa fa-pencil"></i>
                                        </a>
                                        <?php endif; ?>
                                        <?php if(Session::has('Partner_Onboarding_Config|16-1-2')): ?>
                                        <a href="/admin/partner-system/partners/<?php echo e($partner->id); ?>/config" class="btn btn-sm btn-outline-info m-btn m-btn--icon" title="Config">
                                            <i class="fa fa-cog"></i>
                                        </a>
                                        <?php endif; ?>
                                        <form style="display:none;" action="/admin/partner-system/partners/<?php echo e($partner->id); ?>/delete"
                                              method="POST" style="display:inline;"
                                              onsubmit="return confirm('Delete this partner?')">
                                            <?php echo e(csrf_field()); ?>

                                            <button type="submit" class="btn btn-sm btn-outline-danger m-btn m-btn--icon" title="Delete">
                                                <i class="fa fa-trash"></i>
                                            </button>
                                        </form>
                                    </td>
                                </tr>
                                <?php $__currentLoopData = $partner->children; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $child): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr style="background-color: #fcfcfc;">
                                        <td>
                                            <span style="padding-left: 20px;" class="text-muted">&hookrightarrow;</span>
                                            <strong><?php echo e($child->name); ?></strong>
                                        </td>
                                        <td><?php echo e($child->company_type ?? '—'); ?></td>
                                        <td><?php echo e(collect([$child->city, $child->state])->filter()->implode(', ') ?: '—'); ?></td>
                                        <td><?php echo e($child->product ?? '—'); ?></td>
                                        <td><?php echo e($child->created_at->format('d M Y')); ?></td>
                                        <td class="text-center" style="white-space:nowrap;">
                                            <?php if(Session::has('Partner_Onboarding_Update|16-1-1')): ?>
                                            <a href="/admin/partner-system/partners/<?php echo e($child->id); ?>/edit"
                                               class="btn btn-sm btn-outline-primary m-btn m-btn--icon" title="Edit">
                                                <i class="fa fa-pencil"></i>
                                            </a>
                                            <?php endif; ?>
                                            <?php if(Session::has('Partner_Onboarding_Config|16-1-2')): ?>
                                            <a href="/admin/partner-system/partners/<?php echo e($child->id); ?>/config" class="btn btn-sm btn-outline-info m-btn m-btn--icon" title="Config">
                                                <i class="fa fa-cog"></i>
                                            </a>
                                            <?php endif; ?>
                                            <form style="display:none;" action="/admin/partner-system/partners/<?php echo e($child->id); ?>/delete"
                                                  method="POST" style="display:inline;"
                                                  onsubmit="return confirm('Delete this partner?')">
                                                <?php echo e(csrf_field()); ?>

                                                <button type="submit" class="btn btn-sm btn-outline-danger m-btn m-btn--icon" title="Delete">
                                                    <i class="fa fa-trash"></i>
                                                </button>
                                            </form>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="6" class="text-center text-muted py-4">
                                        No partners found. <a href="/admin/partner-system/partners/create">Add one now</a>.
                                    </td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
                <div class="mt-3">
                    <?php echo e($partners->links()); ?>

                </div>
            </div>
        </div>
    </div>
</div>
<?php echo $__env->make('admin.layouts.footer', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
