@extends('layouts.app') @section('title', __('offerandpromotion::lang.promotions') . ' - ' . __('offerandpromotion::lang.dashboard')) @section('content')

{{ __('offerandpromotion::lang.ai_powered_promotion_analytics') }}

{{ __('offerandpromotion::lang.smart_insights_on_who_used_promotions') }}

@component('components.widget', ['class' => 'box-primary'])
{!! Form::label('start_date', __('offerandpromotion::lang.start_date') . ':') !!} {!! Form::text('start_date', @format_date($start_date), ['class' => 'form-control date-picker', 'readonly', 'id' => 'start_date']) !!}
{!! Form::label('end_date', __('offerandpromotion::lang.end_date') . ':') !!} {!! Form::text('end_date', @format_date($end_date), ['class' => 'form-control date-picker', 'readonly', 'id' => 'end_date']) !!}
{!! Form::label('location_id', __('offerandpromotion::lang.location') . ':') !!} {!! Form::select('location_id', $locations ?? [], $location_id, ['class' => 'form-control select2', 'placeholder' => __('offerandpromotion::lang.all'), 'style' => 'width:100%', 'id' => 'location_filter']) !!}

{{ __('offerandpromotion::lang.back') }}
@endcomponent
@if(!empty($insights) && count($insights) > 0) @foreach($insights as $insight)

{{ $insight['title'] }}

{{ __('offerandpromotion::lang.ai_insight') }}

{{ $insight['message'] }}

{{ __('offerandpromotion::lang.recommendation') }}: {{ $insight['recommendation'] }}
@endforeach @endif
{{ __('offerandpromotion::lang.total_promotions_used') }} {{ $analytics['total_promotions_used'] }} {{ __('offerandpromotion::lang.different_promotions') }}
{{ __('offerandpromotion::lang.total_quantity_sold') }} {{ number_format($analytics['total_quantity'], 0) }} {{ __('offerandpromotion::lang.pieces_with_promotions') }}
{{ __('offerandpromotion::lang.total_discount_given') }} @format_currency($analytics['total_discount_given']) {{ __('offerandpromotion::lang.customer_savings') }}
{{ __('offerandpromotion::lang.total_customers') }} {{ $analytics['total_customers'] }} {{ __('offerandpromotion::lang.used_promotions') }}

{{ $analytics['total_invoices'] }}

{{ __('offerandpromotion::lang.total_invoices_with_promotions') }}

{{ $analytics['total_invoices'] > 0 ? number_format(($analytics['total_customers'] / $analytics['total_invoices']) * 100, 1) : 0 }}%

{{ __('offerandpromotion::lang.average_customers_per_invoice') }}

{{ $analytics['total_quantity'] > 0 ? number_format($analytics['total_quantity'] / max($analytics['total_invoices'], 1), 2) : 0 }}

{{ __('offerandpromotion::lang.avg_quantity_per_invoice') }}

@format_currency($analytics['total_invoices'] > 0 ? ($analytics['total_discount_given'] / $analytics['total_invoices']) : 0)

{{ __('offerandpromotion::lang.avg_discount_per_invoice') }}

{{ __('offerandpromotion::lang.daily_promotion_usage_trend') }}

{{ __('offerandpromotion::lang.top_10_promotions') }}

@forelse($analytics['top_promotions'] as $promo) @empty @endforelse
{{ __('offerandpromotion::lang.promotion') }} {{ __('offerandpromotion::lang.quantity') }} {{ __('offerandpromotion::lang.customers') }}
{{ $promo->promotion_name ?: $promo->product_name }}
{{ $promo->discount_percentage }}% off
{{ number_format($promo->total_quantity, 0) }} {{ $promo->customer_count }}
{{ __('offerandpromotion::lang.no_promotions_used_in_period') }}

{{ __('offerandpromotion::lang.top_customers_using_promotions') }}

@forelse($analytics['top_customers'] as $index => $customer) @empty @endforelse
# {{ __('offerandpromotion::lang.customer_name') }} {{ __('offerandpromotion::lang.invoices') }} {{ __('offerandpromotion::lang.total_quantity') }} {{ __('offerandpromotion::lang.total_discount') }} {{ __('offerandpromotion::lang.avg_discount_per_invoice_label') }}
{{ $index + 1 }} {{ $customer->customer_name }} @if($customer->supplier_business_name)
{{ $customer->supplier_business_name }} @endif
{{ $customer->invoice_count }} {{ number_format($customer->total_quantity, 0) }} @format_currency($customer->total_discount) @format_currency($customer->invoice_count > 0 ? ($customer->total_discount / $customer->invoice_count) : 0)
{{ __('offerandpromotion::lang.no_customers_used_promotions') }}
@endsection @section('javascript') @endsection