<?php $__env->startSection('title', 'PrimeBilling subscription'); ?>

<?php $__env->startSection('header'); ?>
    <?php if (isset($component)) { $__componentOriginal111218edafe37a3ff745a947bea8c7e5 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal111218edafe37a3ff745a947bea8c7e5 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.isp-page-header','data' => ['title' => 'PrimeBilling subscription','module' => 'Platform billing','description' => 'Your organisation’s subscription to the PrimeBilling platform (separate from subscriber billing).']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('isp-page-header'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['title' => 'PrimeBilling subscription','module' => 'Platform billing','description' => 'Your organisation’s subscription to the PrimeBilling platform (separate from subscriber billing).']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal111218edafe37a3ff745a947bea8c7e5)): ?>
<?php $attributes = $__attributesOriginal111218edafe37a3ff745a947bea8c7e5; ?>
<?php unset($__attributesOriginal111218edafe37a3ff745a947bea8c7e5); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal111218edafe37a3ff745a947bea8c7e5)): ?>
<?php $component = $__componentOriginal111218edafe37a3ff745a947bea8c7e5; ?>
<?php unset($__componentOriginal111218edafe37a3ff745a947bea8c7e5); ?>
<?php endif; ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="space-y-6">
    <?php if(session('success')): ?>
        <div class="rounded-lg border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm text-emerald-900 dark:border-emerald-500/30 dark:bg-emerald-950/40 dark:text-emerald-100"><?php echo e(session('success')); ?></div>
    <?php endif; ?>
    <?php if(session('error')): ?>
        <div class="rounded-lg border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-900 dark:border-rose-500/30 dark:bg-rose-950/40 dark:text-rose-100"><?php echo e(session('error')); ?></div>
    <?php endif; ?>

    <div class="grid gap-6 lg:grid-cols-2">
        <div class="rounded-2xl border border-slate-200 bg-white p-6 shadow-sm dark:border-slate-700 dark:bg-slate-900">
            <h2 class="text-base font-semibold text-slate-900 dark:text-white">Current plan</h2>
            <?php if($isp->saasPlan): ?>
                <p class="mt-2 text-2xl font-bold text-indigo-600 dark:text-indigo-400"><?php echo e($isp->saasPlan->name); ?></p>
                <p class="mt-1 text-sm text-slate-600 dark:text-slate-300"><?php echo e($isp->saasPlan->description); ?></p>
                <dl class="mt-4 space-y-2 text-sm">
                    <div class="flex justify-between gap-4"><dt class="text-slate-500">Monthly (platform)</dt><dd class="font-medium">KES <?php echo e(number_format($isp->saasPlan->monthly_price, 2)); ?></dd></div>
                    <div class="flex justify-between gap-4"><dt class="text-slate-500">Status</dt><dd class="font-medium capitalize"><?php echo e(str_replace('_', ' ', $isp->saas_subscription_status)); ?></dd></div>
                    <?php if($isp->saas_trial_ends_at): ?>
                        <div class="flex justify-between gap-4"><dt class="text-slate-500">Trial ends</dt><dd class="font-medium"><?php echo e($isp->saas_trial_ends_at->timezone(config('app.timezone'))->format('M j, Y g:i A')); ?></dd></div>
                    <?php endif; ?>
                    <?php if($isp->saas_next_billing_at): ?>
                        <div class="flex justify-between gap-4"><dt class="text-slate-500">Next billing</dt><dd class="font-medium"><?php echo e($isp->saas_next_billing_at->timezone(config('app.timezone'))->format('M j, Y')); ?></dd></div>
                    <?php endif; ?>
                    <?php if($isp->saas_grace_ends_at): ?>
                        <div class="flex justify-between gap-4"><dt class="text-slate-500">Payment grace until</dt><dd class="font-medium"><?php echo e($isp->saas_grace_ends_at->timezone(config('app.timezone'))->format('M j, Y g:i A')); ?></dd></div>
                    <?php endif; ?>
                </dl>
            <?php else: ?>
                <p class="mt-2 text-sm text-slate-600 dark:text-slate-300">No SaaS plan is linked to this tenant yet. Complete onboarding or ask PrimeBilling support.</p>
            <?php endif; ?>
        </div>
        <div class="rounded-2xl border border-slate-200 bg-white p-6 shadow-sm dark:border-slate-700 dark:bg-slate-900">
            <h2 class="text-base font-semibold text-slate-900 dark:text-white">M-Pesa</h2>
            <p class="mt-2 text-sm text-slate-600 dark:text-slate-300">Automated STK uses your billing number on file: <span class="font-mono font-semibold"><?php echo e($isp->saas_billing_phone ?? '—'); ?></span></p>
            <p class="mt-3 text-xs text-slate-500">Platform collections use Daraja credentials configured in the server environment (<code>.env</code> / <code>config/services.php</code>), not your subscriber M-Pesa till.</p>
        </div>
    </div>

    <div class="rounded-2xl border border-slate-200 bg-white shadow-sm dark:border-slate-700 dark:bg-slate-900">
        <div class="border-b border-slate-100 px-6 py-4 dark:border-slate-700">
            <h2 class="text-base font-semibold text-slate-900 dark:text-white">Platform invoices</h2>
            <p class="text-sm text-slate-500">Invoices for PrimeBilling access. Use Pay to trigger an STK push for a pending invoice.</p>
        </div>
        <div class="isp-table-wrap">
            <table class="isp-table min-w-full text-sm">
                <thead class="bg-slate-50 text-left text-xs font-semibold uppercase text-slate-500 dark:bg-slate-800 dark:text-slate-400">
                    <tr>
                        <th class="px-6 py-3">Invoice</th>
                        <th class="px-6 py-3">Period</th>
                        <th class="px-6 py-3">Amount</th>
                        <th class="px-6 py-3">Status</th>
                        <th class="px-6 py-3"></th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-slate-100 dark:divide-slate-700">
                    <?php $__empty_1 = true; $__currentLoopData = $isp->platformSaasInvoices; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $inv): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <?php if (isset($component)) { $__componentOriginal693da8371f81527050c5488b27378bc6 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal693da8371f81527050c5488b27378bc6 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.listing-table.row','data' => ['href' => route('isp.platform-subscription.invoice', $inv),'target' => '_blank']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('listing-table.row'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['href' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(route('isp.platform-subscription.invoice', $inv)),'target' => '_blank']); ?>
                            <td class="px-6 py-3 font-mono text-xs"><?php echo e($inv->invoice_number); ?></td>
                            <td class="px-6 py-3 text-slate-600 dark:text-slate-300">
                                <?php echo e($inv->period_start?->format('M j, Y')); ?> — <?php echo e($inv->period_end?->format('M j, Y')); ?>

                            </td>
                            <td class="px-6 py-3 font-medium">KES <?php echo e(number_format($inv->totalAmount(), 2)); ?></td>
                            <td class="px-6 py-3 capitalize"><?php echo e($inv->status); ?></td>
                            <td class="px-6 py-3 whitespace-nowrap text-right">
                                <?php if (isset($component)) { $__componentOriginal35f57f4e82a16e7ad7641b9fb6c7f399 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal35f57f4e82a16e7ad7641b9fb6c7f399 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.table-actions','data' => ['width' => 'w-52']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('table-actions'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['width' => 'w-52']); ?>
                                    <?php if (isset($component)) { $__componentOriginal4bbb0a061de663e48c42cf83a926a23f = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal4bbb0a061de663e48c42cf83a926a23f = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.table-actions.link','data' => ['href' => route('isp.platform-subscription.invoice', $inv),'label' => 'View invoice','target' => '_blank']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('table-actions.link'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['href' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(route('isp.platform-subscription.invoice', $inv)),'label' => 'View invoice','target' => '_blank']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal4bbb0a061de663e48c42cf83a926a23f)): ?>
<?php $attributes = $__attributesOriginal4bbb0a061de663e48c42cf83a926a23f; ?>
<?php unset($__attributesOriginal4bbb0a061de663e48c42cf83a926a23f); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal4bbb0a061de663e48c42cf83a926a23f)): ?>
<?php $component = $__componentOriginal4bbb0a061de663e48c42cf83a926a23f; ?>
<?php unset($__componentOriginal4bbb0a061de663e48c42cf83a926a23f); ?>
<?php endif; ?>
                                    <?php if($inv->status === \App\Models\PlatformSaasInvoice::STATUS_PENDING): ?>
                                        <?php if (isset($component)) { $__componentOriginalb93ba26a658ff6e0007f90419915c4da = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalb93ba26a658ff6e0007f90419915c4da = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.table-actions.form','data' => ['action' => route('isp.platform-subscription.pay', $inv),'label' => 'Pay with M-Pesa','danger' => false]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('table-actions.form'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['action' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(route('isp.platform-subscription.pay', $inv)),'label' => 'Pay with M-Pesa','danger' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(false)]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalb93ba26a658ff6e0007f90419915c4da)): ?>
<?php $attributes = $__attributesOriginalb93ba26a658ff6e0007f90419915c4da; ?>
<?php unset($__attributesOriginalb93ba26a658ff6e0007f90419915c4da); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalb93ba26a658ff6e0007f90419915c4da)): ?>
<?php $component = $__componentOriginalb93ba26a658ff6e0007f90419915c4da; ?>
<?php unset($__componentOriginalb93ba26a658ff6e0007f90419915c4da); ?>
<?php endif; ?>
                                    <?php endif; ?>
                                 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal35f57f4e82a16e7ad7641b9fb6c7f399)): ?>
<?php $attributes = $__attributesOriginal35f57f4e82a16e7ad7641b9fb6c7f399; ?>
<?php unset($__attributesOriginal35f57f4e82a16e7ad7641b9fb6c7f399); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal35f57f4e82a16e7ad7641b9fb6c7f399)): ?>
<?php $component = $__componentOriginal35f57f4e82a16e7ad7641b9fb6c7f399; ?>
<?php unset($__componentOriginal35f57f4e82a16e7ad7641b9fb6c7f399); ?>
<?php endif; ?>
                            </td>
                         <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal693da8371f81527050c5488b27378bc6)): ?>
<?php $attributes = $__attributesOriginal693da8371f81527050c5488b27378bc6; ?>
<?php unset($__attributesOriginal693da8371f81527050c5488b27378bc6); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal693da8371f81527050c5488b27378bc6)): ?>
<?php $component = $__componentOriginal693da8371f81527050c5488b27378bc6; ?>
<?php unset($__componentOriginal693da8371f81527050c5488b27378bc6); ?>
<?php endif; ?>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr><td colspan="5" class="px-6 py-8 text-center text-slate-500">No platform invoices yet.</td></tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\ispbilling\resources\views/isp/platform-subscription/index.blade.php ENDPATH**/ ?>