@extends('layouts.master') @section('page_title', 'Activity Log Report') @section('title', 'Activity Log Report') @section('main_item', 'Reports') @section('sub_item', 'Activity Log Report') @section('content')
| Changed At | Category | Description | User | Note | Action |
|---|---|---|---|---|---|
| {{ $log->created_at->format('d-m-Y H:i:s') ?? '' }} | {{ $log->subject && $log->subject instanceof \App\Grn ? 'Purchase' : ($log->subject && $log->subject instanceof \App\SalePayment ? 'Sale Payment' : ($log->subject && $log->subject instanceof \App\PurchasePayment ? 'Purchase Payment' : (Str::contains($log->subject_type, '\\') ? Str::beforeLast(class_basename($log->subject_type), '#') : 'Unknown'))) }} | @if ($log->description == 'created') Created @elseif ($log->description == 'updated') Updated @elseif ($log->description == 'deleted') Deleted @endif | {{ $log->user->username ?? '' }} |
@php
// Delivery badge colour
$statusBadgeMap = [
'pending' => 'Pending',
'dispatched' => 'Dispatched',
'returned' => 'Returned',
'delivered' => 'Delivered',
'canceled' => 'Canceled',
'reshedule' => 'Reschedule',
'reshedule_diliverd' => 'Reschedule & Delivered',
'' => 'N/A',
];
//Payment badge colour
$paymentBadgeMap = [
'pending' => 'Pending',
'due' => 'Due',
'online' => 'Online',
'paid' => 'Paid',
'partial' => 'Partial',
'canceled' => 'Canceled',
'returned' => 'Returned',
'returened' => 'Returned',
'' => 'N/A',
];
//call status badge colour
$callStatusBadgeMap = [
'pending' => 'Pending',
'confirm' => 'Confirm',
'not_confirm' => 'Not Confirm',
'cancel' => 'Cancel Order',
'hold_oders' => 'Hold Order',
'' => 'Not Available',
];
@endphp
@if ($log->subject && $log->subject instanceof \App\Sale)
@php
$sale = $log->subject;
$auditLogCreatedAt = $log->created_at;
//from delivery_logs table take the top 2(desc) records on or before the created date of activity log
$deliveryLogs = \App\DeliveryLog::where('sale_id', $sale->id)
->where('created_at', '<=', $auditLogCreatedAt)
->orderBy('created_at', 'desc')
->take(2)
->get();
//reverse for asc order
$deliveryLogs = $deliveryLogs->reverse();
//colour the delivery_status according to the deliveryStatusBadge function
$deliveryStatusBadge = 'N/A';
if ($deliveryLogs->count() > 0) {
$deliveryStatusBadge = $deliveryLogs->map(function ($log) use ($statusBadgeMap) {
return $statusBadgeMap[$log->delivery_status] ?? $statusBadgeMap[''];
})->implode(' --> ');
}
//from payment_logs table take the top 2(desc) records on or before the created date of activity log
$paymentLogs = \App\PaymentLog::where('sale_id', $sale->id)
->where('created_at', '<=', $auditLogCreatedAt)
->orderBy('created_at', 'desc')
->take(2)
->get();
//reverse for asc order
$paymentLogs = $paymentLogs->reverse();
//colour the payment_status according to the paymentBadgeMap function
$paymentStatusBadge = 'N/A';
if ($paymentLogs->count() > 0) {
$paymentStatusBadge = $paymentLogs->map(function ($log) use ($paymentBadgeMap) {
// If the payment status is 'due', change it to 'pending'
$status = $log->payment_status == 'due' ? 'pending' : $log->payment_status;
return $paymentBadgeMap[$status] ?? $paymentBadgeMap[''];
})->implode(' --> ');
}
// Fetch Call Statuses
$callStatuses = \App\CallStatus::where('sale_id', $sale->id)
->where('created_at', '<=', $auditLogCreatedAt)
->orderBy('created_at', 'desc')
->take(2)
->get();
$callStatuses = $callStatuses->reverse();
$callStatusDisplay = 'N/A';
if ($callStatuses->count() > 0) {
$callStatusDisplay = $callStatuses->map(function ($status) use ($callStatusBadgeMap) {
return $callStatusBadgeMap[$status->call_status] ?? $callStatusBadgeMap[''];
})->implode(' --> ');
}
@endphp
Invoice No: {{ $sale->invoice_no ?? '' }}
Call Status: {!! $callStatusDisplay !!}
Delivery Status: {!! $deliveryStatusBadge !!}
Invoice Total: Rs {{ number_format($sale->invoice_nettotal ?? 0, 2) }}
Payment Status: {!! $paymentStatusBadge !!}
@elseif ($log->subject && ($log->subject instanceof \App\Grn))
@php
// Purchase Details
$grn = $log->subject;
$auditLogCreatedAt = $log->created_at;
//from purchase_logs table take the top 2(desc) records on or before the created date of activity log
$purchaseLogs = \App\PurchaseLog::where('purchase_id', $grn->id)
->where('created_at', '<=', $auditLogCreatedAt)
->orderBy('created_at', 'desc')
->take(2)
->get();
//reverse for asc order
$purchaseLogs = $purchaseLogs->reverse();
//colour the purchase_status according to the paymentStatusBadge function
$paymentStatusBadge = 'N/A';
if ($purchaseLogs->count() > 0) {
$paymentStatusBadge = $purchaseLogs->map(function ($log) use ($paymentBadgeMap) {
return $paymentBadgeMap[$log->payment_status] ?? $paymentBadgeMap[''];
})->implode(' --> ');
}
@endphp
Reference No: {{ $grn->ref_no ?? '' }}
Payment Status: {!! $paymentStatusBadge !!}
Net Total: Rs {{ number_format($grn->grn_nettotal ?? 0, 2) }}
@elseif ($log->subject && $log->subject instanceof \App\Expense)
@php
// Expense Details
$expense = $log->subject;
$expenseCategoryName = $expense->expenses_category->name ?? '';
$auditLogCreatedAt = $log->created_at;
//from expenses_logs table take the top 2(desc) records on or before the created date of activity log
$expenseLogs = \App\ExpenseLog::where('expense_id', $expense->id)
->where('created_at', '<=', $auditLogCreatedAt)
->orderBy('created_at', 'desc')
->take(2)
->get();
//reverse for asc order
$expenseLogs = $expenseLogs->reverse();
//colour the payment_status according to the paymentStatusBadge function
$statusBadge = 'N/A';
if ($expenseLogs->count() > 0) {
$statusBadge = $expenseLogs->map(function ($log) use ($paymentBadgeMap) {
return $paymentBadgeMap[$log->payment_status] ?? $paymentBadgeMap[''];
})->implode(' --> ');
}
@endphp
Reference No: {{ $expense->ref_no ?? '' }}
Amount: Rs {{ number_format($expense->amount ?? 0, 2) }}
Status: {!! $statusBadge !!}
Category: {{ $expenseCategoryName }}
@endif
|