@extends('layout.app') @push('styles') @endpush @php // Resolved once for the whole page. A @can costs ~1 ms (Spatie rebuilds the user's // permission set on each check) and checkSettings() a cache lookup — inside a loop // over hundreds of managers that alone was seconds of render time. $u = auth()->user(); $canResellerType = $u->canany(['reseller_type', 'specific_management_services']); $canRemarkView = $u->can('manager-remark-view'); $canUniqueCode = $u->can('manager_unique_code'); $canViewCommission = $u->can('view-commission'); $canRecharge = $u->can('reseller-recharge'); $canSecurityAmount = $u->can('security-amount-entry'); $canPackagePermission = $u->canany(['package-permission', 'specific_management_services']); $canEditReseller = $u->can('reseller_edit') || $u->can('manager-accounts-edit'); $canViewHistory = $u->can('view-reseller-history'); $canSmsGateway = $u->can('reseller-sms-getway'); $canDeleteOnline = $u->can('delete-online-client-from-pop-manager'); $cannotSpecificMgmt = ! $u->can('specific_management_services'); $isSuperAdmin = $u->id == 1; $setOnlineRecharge = checkSettings('reseller-online-recharge') == 'enable'; $setPaidOption = checkSettings('reseller-recharge-paid-option') == 'enable'; $setManagerStatus = checkSettings('manager_status') == 'enable'; $setSecurityAmount = checkSettings('securityAmountManagement') == 'enable'; $setClientOnlineRech = checkSettings('ResellerClientOnlineRecharge') == 'enable'; $setVatCommission = globalPermission('commission_from_manager_pop') && checkSettings('vat_deduct_from_payment_for_commission_calculation') === 'enable'; $setCustomSmsGateway = globalPermission('customResellerSmsGatewaySetup'); $apiInUse = checkAPI(); // Manager Miscellaneous Expense (resellers.commission_percentage) — shown and // searchable only where the feature is switched on and the user holds the permission. $setMiscExpense = checkSettings('manager-commission-percentage') == 'enable'; $canMiscExpense = $u->can('manager-miscellaneous-expense-search'); $showMiscExpense = $setMiscExpense && $canMiscExpense; // Manager approval: a new manager is added inactive and goes live only once someone // with manager-approve signs it off. Off by default, so nothing shows up until the // manager_approval setting is switched on. $setApproval = checkSettings('manager_approval') == 'enable'; $canApprove = $setApproval && $u->can('manager-approve'); // Approval states and the badge each one wears, both in the filter summary and in // the Approval column. Rejected managers are only visible via the filter. $approvalLabels = \App\Models\Reseller::APPROVAL_STATUSES; $approvalBadges = [ \App\Models\Reseller::APPROVAL_PENDING => 'badge-warning', \App\Models\Reseller::APPROVAL_MODIFICATION => 'badge-info', \App\Models\Reseller::APPROVAL_APPROVED => 'badge-success', \App\Models\Reseller::APPROVAL_REJECTED => 'badge-danger', ]; // Total Due is a per-manager lookup; keying it once beats scanning the whole // collection inside every row. $dueByReseller = collect($due)->keyBy('reseller_id'); @endphp @section('content')
| ID | Manager Name | @if ($canResellerType) | Reseller Type | @endifAddress | Contact No | Balance | @if ($showMiscExpense)Manager Miscellaneous Expense | @endif @if ($setVatCommission)VAT % | Commission % | @endif @if ($setPaidOption)Total Due | @endif @if ($canRemarkView)Remark | @endif @if ($setManagerStatus)Status | @endif @if ($setApproval)Approval | @endif @if ($canUniqueCode)Unique Code | @endif|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {{ $r->id }} | {{ $r->name }} | @if ($cannotSpecificMgmt && $setOnlineRecharge && $r->enable_online_recharge) Online Recharge @endif | @if ($canResellerType){{ $r->reseller_type }} | @endif{{ $r->address }} | {{ $r->contact }} | {{ $r->balance[0]['amount'] ?? 0 }} | @if ($showMiscExpense)@if ($r->commission_percentage > 0) {{ rtrim(rtrim(number_format($r->commission_percentage, 2), '0'), '.') }}% @else — @endif | @endif @if ($setVatCommission){{ $r->vat ?? 0 }}% | {{ $r->commission_percentage ?? 0 }}% | @endif @if ($setPaidOption)@if ($d = $dueByReseller->get($r->id)) {{ $d->tamount - $d->tpaid }} @endif | @endif @if ($canRemarkView){{ $r->remark ?? '' }} | @endif @if ($setManagerStatus){{ $r->status == 'active' ? 'Active' : 'Inactive' }} | @endif @if ($setApproval)@php $rStatus = $r->approval_status ?: \App\Models\Reseller::APPROVAL_APPROVED; @endphp {{ $approvalLabels[$rStatus] ?? $rStatus }} @if ($r->approval_remark && $rStatus !== \App\Models\Reseller::APPROVAL_APPROVED) @endif | @endif @if ($canUniqueCode){{ $r->manager_unique_code ?? '' }} | @endif
{{-- data-display="static" keeps Popper out of it, so the script
below can place the menu over the scroll box itself. --}}
|