@extends('layouts.app') @section('content') @include('proedge.admin.discounts._styles') @php $hasFilters = request()->hasAny(['keyword', 'discount_type', 'status', 'partner']); @endphp
@include('proedge.admin.discounts._flash')
@include('proedge.admin.discounts._panel_head', [ 'title' => 'Offers', 'addTarget' => 'modal_add_offer', 'addTooltip' => 'Click here to add a new offer', 'hasFilters' => $hasFilters, 'extra' => [ [ 'target' => 'modal_apply_offer', 'tooltip' => 'Give an offer to one customer', 'icon' => 'user', ], [ 'target' => 'modal_remove_discount', 'tooltip' => 'Remove a discount from a customer', 'icon' => 'erase', ], ], ])
{{-- Filters --}}
Reset

@include('proedge.admin.discounts._summary')
@include('proedge.admin.discounts._th', ['field' => 'name', 'label' => 'Name']) @include('proedge.admin.discounts._th', ['field' => 'duration', 'label' => 'Duration']) @include('proedge.admin.discounts._th', ['field' => 'partner', 'label' => 'Partner']) @include('proedge.admin.discounts._th', ['field' => 'codes_count', 'label' => 'Codes']) @include('proedge.admin.discounts._th', ['field' => 'redemptions_count', 'label' => 'Used']) @include('proedge.admin.discounts._th', ['field' => 'is_active', 'label' => 'Status']) @forelse($offers as $offer) @empty @endforelse
DiscountPlansBudgetIn Stripe Options
@if($offer->description) {{-- Hovering the name shows the note, the same as the Offer column on Promo Codes. Escaped: it is free text an admin typed. --}} {{ $offer->name }} {{ $offer->description }} @else {{ $offer->name }} @endif {{ $offer->summary ?: $offer->discount_type }} {{-- The same words the Add Offer form uses. "Once" and "Forever" on their own read as a number of payments, which they are not: a customer who renews early has more payments than months. --}} @if($offer->duration === 'months') {{ $offer->duration_in_months }} calendar month{{ $offer->duration_in_months == 1 ? '' : 's' }} @elseif($offer->duration === 'forever') Every renewal @else Signup payment only @endif {{-- No rows means every plan, which is what an offer created before plans were tiered will show. --}} @forelse($offer->plans as $offerPlan) {{ $offerPlan->name }} @empty All plans @endforelse {{ $offer->partner ?: '—' }} {{ $offer->codes_count }} {{ $offer->redemptions_count }} @if($offer->budget_cap) {{ number_format((float) $offer->budget_used, 2) }} / {{ number_format((float) $offer->budget_cap, 2) }} @else — @endif @if($offer->is_active) Active @else Inactive @endif @if($offer->auto_apply) @if($offer->usable_public_codes_count > 0) {{-- Worth its own badge: this one applies to customers who never asked for it. --}} Automatic @else {{-- Checkout applies an automatic offer by handing out one of its codes. With none live and unreserved there is nothing to hand out, and it silently does nothing. --}} Automatic — no code yet, won't apply @endif @endif @if($offer->externalId()) {{ $offer->externalId() }} @else trial — no coupon @endif {{-- Only the fields Stripe will still accept a change to. The percentage, amount and duration are fixed when the coupon is created, so they are shown on the row but never editable. --}}
@csrf
@if($offer->redemptions_count > 0) {{-- The ledger points at this offer and rule_snapshot is the only record of what was given, so it stays. --}} in use @else @php // Built here and JSON-encoded below, so the name is escaped // for JavaScript: an apostrophe in an offer name would // otherwise end the string and stop the handler compiling, // which submits the form with no confirmation at all. $deleteWarning = 'Delete ' . $offer->name . ($offer->codes_count ? ' and its ' . $offer->codes_count . ' code(s)' : '') . " from Poolpix and from Stripe?\n\nThis cannot be undone."; @endphp
@csrf
@endif
@if($hasFilters) No offers match those filters. @else No offers yet. Use the + button to create one, or run php artisan discounts:sync in poolpix-website-api to import anything that already exists in Stripe. @endif
{{-- Bootstrap 3 numbered pagination, matching Leads. The app's default template is Tailwind, which this panel does not load, so it fell back to bare Previous / Next links. --}} {{ $offers->links('pagination::default') }}
@include('proedge.modal.discount.add_offer') @include('proedge.modal.discount.apply_offer') @include('proedge.modal.discount.edit_offer') @include('proedge.modal.discount.remove_discount') @endsection @section('scripts') @endsection