🤩 File Manager - Mr.X
PHP:
8.3.33
Server:
Apache
OS:
Linux 5.14.0-611.49.1.el9_7.x86_64
User:
websparkit
Navigate
Upload:
Upload
New File
New Folder
Editing:financials.blade.php
<x-app-layout> <x-slot name="header"> <h2 class="text-xl font-semibold leading-tight text-white"> {{ __('Financial Dashboard') }} </h2> </x-slot> <div class="py-8"> <div class="mx-auto max-w-7xl sm:px-6 lg:px-8 space-y-8"> {{-- Flash Messages --}} @if (session('success')) <div class="rounded-lg border border-green-200 bg-green-50 p-4"> <div class="flex items-center"> <svg class="h-5 w-5 text-green-500 mr-2" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/></svg> <p class="text-sm font-medium text-green-800">{{ session('success') }}</p> </div> </div> @endif @if (session('error')) <div class="rounded-lg border border-red-200 bg-red-50 p-4"> <div class="flex items-center"> <svg class="h-5 w-5 text-red-500 mr-2" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z" clip-rule="evenodd"/></svg> <p class="text-sm font-medium text-red-800">{{ session('error') }}</p> </div> </div> @endif {{-- ============================================================ --}} {{-- Summary Cards --}} {{-- ============================================================ --}} <div class="grid grid-cols-1 gap-5 sm:grid-cols-3"> {{-- Total Revenue --}} <div class="overflow-hidden rounded-lg bg-white shadow-sm ring-1 ring-gray-900/5"> <div class="p-6"> <div class="flex items-center"> <div class="flex-shrink-0 rounded-lg bg-orange p-3"> <svg class="h-7 w-7 text-white" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M2.25 18L9 11.25l4.306 4.307a11.95 11.95 0 015.814-5.519l2.74-1.22m0 0l-5.94-2.28m5.94 2.28l-2.28 5.941"/></svg> </div> <div class="ml-5"> <p class="text-sm font-medium text-gray-500">Total Revenue</p> <p class="mt-1 text-2xl font-bold text-navy">Rs{{ number_format($totalRevenue, 2) }}</p> </div> </div> </div> <div class="bg-orange/5 px-6 py-2"> <p class="text-xs text-orange font-medium">Across all projects</p> </div> </div> {{-- Total Expenses --}} <div class="overflow-hidden rounded-lg bg-white shadow-sm ring-1 ring-gray-900/5"> <div class="p-6"> <div class="flex items-center"> <div class="flex-shrink-0 rounded-lg bg-red-600 p-3"> <svg class="h-7 w-7 text-white" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M2.25 6L9 12.75l4.286-4.286a11.948 11.948 0 014.306 6.43l.776 2.898m0 0l3.182-5.511m-3.182 5.51l-5.511-3.181"/></svg> </div> <div class="ml-5"> <p class="text-sm font-medium text-gray-500">Total Expenses</p> <p class="mt-1 text-2xl font-bold text-red-600">Rs{{ number_format($totalExpenses, 2) }}</p> </div> </div> </div> <div class="bg-red-50 px-6 py-2"> <p class="text-xs text-red-500 font-medium">All operational costs</p> </div> </div> {{-- Profit --}} <div class="overflow-hidden rounded-lg bg-white shadow-sm ring-1 ring-gray-900/5"> <div class="p-6"> <div class="flex items-center"> <div class="flex-shrink-0 rounded-lg {{ $profit >= 0 ? 'bg-green-600' : 'bg-red-600' }} p-3"> @if($profit >= 0) <svg class="h-7 w-7 text-white" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M12 6v12m-3-2.818l.879.659c1.171.879 3.07.879 4.242 0 1.172-.879 1.172-2.303 0-3.182C13.536 12.219 12.768 12 12 12c-.725 0-1.45-.22-2.003-.659-1.106-.879-1.106-2.303 0-3.182s2.9-.879 4.006 0l.415.33M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg> @else <svg class="h-7 w-7 text-white" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"/></svg> @endif </div> <div class="ml-5"> <p class="text-sm font-medium text-gray-500">Net Profit</p> <p class="mt-1 text-2xl font-bold {{ $profit >= 0 ? 'text-green-700' : 'text-red-600' }}"> {{ $profit >= 0 ? '' : '-' }}Rs{{ number_format(abs($profit), 2) }} </p> </div> </div> </div> <div class="{{ $profit >= 0 ? 'bg-green-50' : 'bg-red-50' }} px-6 py-2 flex justify-between items-center"> <p class="text-xs {{ $profit >= 0 ? 'text-green-600' : 'text-red-500' }} font-medium"> {{ $profit >= 0 ? 'Profitable' : 'Operating at a loss' }} </p> @if($profit > 0) <button type="button" onclick="document.getElementById('distribution-modal').classList.remove('hidden')" class="text-xs text-navy hover:underline font-bold"> View Distribution </button> @endif </div> </div> </div> {{-- Profit Distribution Modal --}} @if($profit > 0) <div id="distribution-modal" class="hidden fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50"> <div class="relative top-20 mx-auto p-5 border w-full max-w-md shadow-lg rounded-md bg-white"> <div class="mt-3 text-center"> <div class="mx-auto flex items-center justify-center h-12 w-12 rounded-full bg-green-100"> <svg class="h-6 w-6 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg> </div> <h3 class="text-lg leading-6 font-medium text-gray-900 mt-4">Profit Distribution</h3> <p class="text-sm text-gray-500 mb-4">Total Net Profit: Rs{{ number_format($profit, 2) }}</p> <div class="mt-2 text-left space-y-4"> {{-- Partner 1: Admin/CEO 40% --}} <div class="p-3 bg-orange/5 rounded-lg border border-orange/20"> <div class="flex justify-between text-sm font-medium mb-1"> <span class="text-gray-700">Partner 1: Admin / Asanga CEO (40%)</span> <span class="text-orange font-bold">Rs{{ number_format($partner1Share, 2) }}</span> </div> <div class="w-full bg-gray-200 rounded-full h-2"> <div class="bg-orange h-2 rounded-full" style="width: 40%"></div> </div> </div> {{-- Partner 2: Tech Lead 40% --}} <div class="p-3 bg-navy/5 rounded-lg border border-navy/20"> <div class="flex justify-between text-sm font-medium mb-1"> <span class="text-gray-700">Partner 2: Tech Lead / Sanura (40%)</span> <span class="text-navy font-bold">Rs{{ number_format($partner2Share, 2) }}</span> </div> <div class="w-full bg-gray-200 rounded-full h-2"> <div class="bg-navy h-2 rounded-full" style="width: 40%"></div> </div> </div> {{-- Company Reserve 20% --}} <div class="p-3 bg-green-50 rounded-lg border border-green-200"> <div class="flex justify-between text-sm font-medium mb-1"> <span class="text-gray-700">Company Emergency Fund (20%)</span> <span class="text-green-700 font-bold">Rs{{ number_format($companyReserve, 2) }}</span> </div> <div class="w-full bg-gray-200 rounded-full h-2"> <div class="bg-green-500 h-2 rounded-full" style="width: 20%"></div> </div> </div> </div> <div class="mt-6"> <button type="button" onclick="document.getElementById('distribution-modal').classList.add('hidden')" class="w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-navy sm:text-sm"> Close </button> </div> </div> </div> </div> @endif {{-- ============================================================ --}} {{-- Date Filter for Payments --}} {{-- ============================================================ --}} <div class="overflow-hidden rounded-lg bg-white shadow-sm ring-1 ring-gray-900/5"> <div class="border-b border-gray-100 bg-gray-50/50 px-6 py-4"> <h3 class="text-base font-semibold text-navy">Payment Report</h3> </div> <div class="p-6"> <form method="GET" action="{{ route('admin.financials') }}" class="flex gap-4 items-end mb-6"> <div> <label class="block text-sm font-medium text-gray-700 mb-1">From</label> <input type="date" name="date_from" value="{{ $dateFrom }}" class="block w-full rounded-lg border-gray-300 shadow-sm focus:border-orange focus:ring-orange sm:text-sm"> </div> <div> <label class="block text-sm font-medium text-gray-700 mb-1">To</label> <input type="date" name="date_to" value="{{ $dateTo }}" class="block w-full rounded-lg border-gray-300 shadow-sm focus:border-orange focus:ring-orange sm:text-sm"> </div> <button type="submit" class="px-4 py-2 bg-navy text-white rounded-md text-sm font-medium hover:bg-navy-dark">Filter</button> </form> @if($filteredPayments->count() > 0) <div class="overflow-x-auto"> <table class="min-w-full divide-y divide-gray-200"> <thead> <tr class="bg-gray-50"> <th class="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-500">Date</th> <th class="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-500">Project</th> <th class="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-500">Client</th> <th class="px-4 py-3 text-right text-xs font-semibold uppercase tracking-wider text-gray-500">Amount</th> <th class="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-500">Status</th> </tr> </thead> <tbody class="divide-y divide-gray-100"> @foreach($filteredPayments as $payment) <tr> <td class="px-4 py-3 text-sm text-gray-600">{{ $payment->paid_at->format('M d, Y') }}</td> <td class="px-4 py-3 text-sm font-medium text-navy">{{ $payment->project->name ?? '—' }}</td> <td class="px-4 py-3 text-sm text-gray-600">{{ $payment->client->name ?? '—' }}</td> <td class="px-4 py-3 text-sm text-right font-semibold text-navy">Rs{{ number_format($payment->amount, 2) }}</td> <td class="px-4 py-3"> <span class="inline-flex items-center rounded-full px-2 py-0.5 text-xs font-semibold {{ $payment->status === 'confirmed' ? 'bg-green-100 text-green-800' : ($payment->status === 'rejected' ? 'bg-red-100 text-red-800' : 'bg-yellow-100 text-yellow-800') }}"> {{ ucfirst($payment->status) }} </span> </td> </tr> @endforeach </tbody> </table> </div> <div class="mt-4 pt-4 border-t flex justify-end"> <span class="text-sm font-semibold text-navy">Total: Rs{{ number_format($filteredPayments->where('status', 'confirmed')->sum('amount'), 2) }}</span> </div> @else <p class="text-sm text-gray-500 text-center py-4">No payments found for this date range.</p> @endif </div> </div> {{-- ============================================================ --}} {{-- Add Expense Form --}} {{-- ============================================================ --}} <div class="overflow-hidden rounded-lg bg-white shadow-sm ring-1 ring-gray-900/5"> <div class="border-b border-gray-100 bg-gradient-to-r from-navy to-navy-dark px-6 py-4"> <h3 class="text-base font-semibold text-white">Add New Expense</h3> </div> <div class="p-6"> <form action="{{ route('admin.expense.store') }}" method="POST"> @csrf <div class="grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-4"> <div> <label for="category" class="block text-sm font-medium text-navy mb-1.5">Category</label> <select name="category" id="category" required class="block w-full rounded-lg border-gray-300 shadow-sm transition focus:border-orange focus:ring-orange sm:text-sm"> <option value="">Select category</option> <option value="server" {{ old('category') === 'server' ? 'selected' : '' }}>Server</option> <option value="facebook_marketing" {{ old('category') === 'facebook_marketing' ? 'selected' : '' }}>Facebook Marketing</option> <option value="google_ads" {{ old('category') === 'google_ads' ? 'selected' : '' }}>Google Ads</option> <option value="salary" {{ old('category') === 'salary' ? 'selected' : '' }}>Salary</option> <option value="software" {{ old('category') === 'software' ? 'selected' : '' }}>Software</option> <option value="office" {{ old('category') === 'office' ? 'selected' : '' }}>Office</option> <option value="other" {{ old('category') === 'other' ? 'selected' : '' }}>Other</option> </select> </div> <div> <label for="amount" class="block text-sm font-medium text-navy mb-1.5">Amount (Rs)</label> <input type="number" name="amount" id="amount" step="0.01" min="0" required value="{{ old('amount') }}" placeholder="0.00" class="block w-full rounded-lg border-gray-300 shadow-sm transition focus:border-orange focus:ring-orange sm:text-sm"> </div> <div> <label for="description" class="block text-sm font-medium text-navy mb-1.5">Description</label> <input type="text" name="description" id="description" value="{{ old('description') }}" placeholder="Expense description" class="block w-full rounded-lg border-gray-300 shadow-sm transition focus:border-orange focus:ring-orange sm:text-sm"> </div> <div> <label for="date" class="block text-sm font-medium text-navy mb-1.5">Date</label> <input type="date" name="date" id="date" required value="{{ old('date', now()->format('Y-m-d')) }}" class="block w-full rounded-lg border-gray-300 shadow-sm transition focus:border-orange focus:ring-orange sm:text-sm"> </div> </div> <div class="mt-5 flex justify-end"> <button type="submit" class="inline-flex items-center gap-2 rounded-lg bg-orange px-5 py-2.5 text-sm font-semibold text-white shadow-sm transition hover:bg-orange-dark focus:outline-none focus:ring-2 focus:ring-orange focus:ring-offset-2"> <svg class="h-4 w-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15"/></svg> Add Expense </button> </div> </form> </div> </div> {{-- ============================================================ --}} {{-- Expenses Table --}} {{-- ============================================================ --}} <div class="overflow-hidden rounded-lg bg-white shadow-sm ring-1 ring-gray-900/5"> <div class="border-b border-gray-100 bg-gray-50/50 px-6 py-4"> <h3 class="text-base font-semibold text-navy">Expenses</h3> </div> <div class="overflow-x-auto"> @if($expenses->count() > 0) <table class="min-w-full divide-y divide-gray-200"> <thead> <tr class="bg-gray-50"> <th class="px-6 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-500">Date</th> <th class="px-6 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-500">Category</th> <th class="px-6 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-500">Description</th> <th class="px-6 py-3 text-right text-xs font-semibold uppercase tracking-wider text-gray-500">Amount</th> </tr> </thead> <tbody class="divide-y divide-gray-100 bg-white"> @foreach($expenses as $expense) <tr class="transition hover:bg-gray-50/50"> <td class="whitespace-nowrap px-6 py-4 text-sm text-gray-600"> {{ \Carbon\Carbon::parse($expense->date)->format('M d, Y') }} </td> <td class="whitespace-nowrap px-6 py-4"> @php $catStyles = [ 'server' => 'bg-blue-100 text-blue-800', 'facebook_marketing' => 'bg-purple-100 text-purple-800', 'google_ads' => 'bg-indigo-100 text-indigo-800', 'salary' => 'bg-green-100 text-green-800', 'software' => 'bg-cyan-100 text-cyan-800', 'office' => 'bg-amber-100 text-amber-800', 'other' => 'bg-gray-100 text-gray-700', ]; $catStyle = $catStyles[$expense->category] ?? 'bg-gray-100 text-gray-700'; @endphp <span class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold {{ $catStyle }}"> {{ ucfirst(str_replace('_', ' ', $expense->category)) }} </span> </td> <td class="px-6 py-4 text-sm text-gray-600">{{ $expense->description ?? '—' }}</td> <td class="whitespace-nowrap px-6 py-4 text-right text-sm font-semibold text-red-600"> Rs{{ number_format($expense->amount, 2) }} </td> </tr> @endforeach </tbody> </table> @else <div class="flex flex-col items-center justify-center py-16 text-center"> <svg class="h-16 w-16 text-gray-300 mb-4" fill="none" stroke="currentColor" stroke-width="1" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M2.25 18.75a60.07 60.07 0 0115.797 2.101c.727.198 1.453-.342 1.453-1.096V18.75M3.75 4.5v.75A.75.75 0 013 6h-.75m0 0v-.375c0-.621.504-1.125 1.125-1.125H20.25M2.25 6v9m18-10.5v.75c0 .414.336.75.75.75h.75m-1.5-1.5h.375c.621 0 1.125.504 1.125 1.125v9.75c0 .621-.504 1.125-1.125 1.125h-.375m1.5-1.5H21a.75.75 0 00-.75.75v.75m0 0H3.75m0 0h-.375a1.125 1.125 0 01-1.125-1.125V15m1.5 1.5v-.75A.75.75 0 003 15h-.75M15 10.5a3 3 0 11-6 0 3 3 0 016 0zm3 0h.008v.008H18V10.5zm-12 0h.008v.008H6V10.5z"/></svg> <h3 class="text-sm font-semibold text-gray-900 mb-1">No expenses recorded</h3> <p class="text-sm text-gray-500">Use the form above to add your first expense.</p> </div> @endif </div> </div> {{-- ============================================================ --}} {{-- Project Financials Table --}} {{-- ============================================================ --}} <div class="overflow-hidden rounded-lg bg-white shadow-sm ring-1 ring-gray-900/5"> <div class="border-b border-gray-100 bg-gray-50/50 px-6 py-4"> <h3 class="text-base font-semibold text-navy">Project Financials</h3> </div> <div class="overflow-x-auto"> @if($projectFinancials->count() > 0) <table class="min-w-full divide-y divide-gray-200"> <thead> <tr class="bg-gray-50"> <th class="px-6 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-500">Project</th> <th class="px-6 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-500">Client</th> <th class="px-6 py-3 text-right text-xs font-semibold uppercase tracking-wider text-gray-500">Budget</th> <th class="px-6 py-3 text-right text-xs font-semibold uppercase tracking-wider text-gray-500">Amount Paid</th> <th class="px-6 py-3 text-right text-xs font-semibold uppercase tracking-wider text-gray-500">Balance Due</th> <th class="px-6 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-500">Status</th> </tr> </thead> <tbody class="divide-y divide-gray-100 bg-white"> @foreach($projectFinancials as $pf) @php $confirmedPaid = $pf->payments->where('status', 'confirmed')->sum('amount'); $balance = ($pf->budget ?? 0) - $confirmedPaid; @endphp <tr class="transition hover:bg-gray-50/50"> <td class="whitespace-nowrap px-6 py-4 text-sm font-medium text-navy"> {{ $pf->name }} </td> <td class="whitespace-nowrap px-6 py-4 text-sm text-gray-600"> {{ $pf->client->name ?? '—' }} </td> <td class="whitespace-nowrap px-6 py-4 text-right text-sm text-gray-600"> Rs{{ number_format($pf->budget ?? 0, 2) }} </td> <td class="whitespace-nowrap px-6 py-4 text-right text-sm font-medium text-green-700"> Rs{{ number_format($confirmedPaid, 2) }} </td> <td class="whitespace-nowrap px-6 py-4 text-right text-sm font-medium {{ $balance > 0 ? 'text-red-600' : 'text-green-700' }}"> Rs{{ number_format($balance, 2) }} </td> <td class="whitespace-nowrap px-6 py-4"> @php $finStatusStyles = [ 'paid' => 'bg-green-100 text-green-800', 'partial' => 'bg-yellow-100 text-yellow-800', 'unpaid' => 'bg-red-100 text-red-800', ]; $finStyle = $finStatusStyles[$pf->payment_status ?? 'unpaid'] ?? 'bg-gray-100 text-gray-700'; @endphp <span class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold {{ $finStyle }}"> {{ ucfirst($pf->payment_status ?? 'Unpaid') }} </span> </td> </tr> @endforeach </tbody> </table> @else <div class="flex flex-col items-center justify-center py-16 text-center"> <svg class="h-16 w-16 text-gray-300 mb-4" fill="none" stroke="currentColor" stroke-width="1" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M2.25 12.75V12A2.25 2.25 0 014.5 9.75h15A2.25 2.25 0 0121.75 12v.75m-8.69-6.44l-2.12-2.12a1.5 1.5 0 00-1.061-.44H4.5A2.25 2.25 0 002.25 6v12a2.25 2.25 0 002.25 2.25h15A2.25 2.25 0 0021.75 18V9a2.25 2.25 0 00-2.25-2.25h-5.379a1.5 1.5 0 01-1.06-.44z"/></svg> <h3 class="text-sm font-semibold text-gray-900 mb-1">No project financials</h3> <p class="text-sm text-gray-500">Financial data will appear here once projects are created.</p> </div> @endif </div> </div> </div> </div> </x-app-layout>
Save Changes
Cancel
Create New File
Create New Folder