Added product report, showing just active products and number of services

This commit is contained in:
Deon George 2023-05-09 16:50:39 +09:00
parent b3539e6c7e
commit 45dd74aad4
5 changed files with 140 additions and 30 deletions

View File

@ -11,6 +11,11 @@ class ReportController extends Controller
return view('account/report');
}
public function products()
{
return view('product/report');
}
public function services()
{
return view('service/report');

View File

@ -0,0 +1,92 @@
@extends('adminlte::layouts.app')
@section('htmlheader_title')
Product List
@endsection
@section('page_title')
Product List
@endsection
@section('contentheader_title')
Product List
@endsection
@section('contentheader_description')
@endsection
@section('main-content')
<div class="col-md-12">
<div class="card">
<div class="card-body">
<table class="table table-sm table-striped" id="table">
<thead>
<tr>
<th>ID</th>
<th>Type</th>
<th>Product</th>
<th class="text-right">Services</th>
</tr>
</thead>
<tbody>
@foreach (\App\Models\Service::active()->with(['product.translate'])->get()->groupBy('product_id') as $s)
<tr>
<td><a href="{{ url('a/product/details',[($x=$s->first())->product_id]) }}">{{ $x->id }}</a></td>
<td>{{ $x->category_name }}</td>
<td>{{ $x->product->name }}</td>
<td class="text-right">{{ $s->count() }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
@endsection
@section('page-scripts')
@css(datatables,bootstrap4|fixedheader|responsive|rowgroup|buttons)
@js(datatables,bootstrap4|fixedheader|responsive|rowgroup|buttons)
<style>
tr.odd td:first-child,
tr.even td:first-child {
padding-left: 3em;
}
table.dataTable tr.dtrg-group.dtrg-level-1 td {
background-color: #e0e0e0;
color: #4c110f;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
$('#table').DataTable({
aLengthMenu: [
[25, 50, 100, 200, -1],
[25, 50, 100, 200, "All"]
],
paging: true,
pageLength: 25,
lengthChange: true,
searching: true,
ordering: true,
info: true,
autoWidth: false,
fixedHeader: true,
order: [
[1,'asc'],
[2,'asc'],
],
rowGroup: {
dataSrc: [1],
},
columnDefs: [
{
targets: [1],
visible: false,
},
],
});
});
</script>
@append

View File

@ -15,34 +15,38 @@
@section('main-content')
<div class="col-md-12">
<table class="table table-sm table-striped" id="table">
<thead>
<tr>
<th>ID</th>
<th>Service</th>
<th>Product</th>
<th class="text-right">Monthly</th>
<th class="text-right">Cost</th>
<th class="text-right">Traffic (GB)</th>
<th>Supplier</th>
</tr>
</thead>
<div class="card">
<div class="card-body">
<table class="table table-sm table-striped" id="table">
<thead>
<tr>
<th>ID</th>
<th>Service</th>
<th>Product</th>
<th class="text-right">Monthly</th>
<th class="text-right">Cost</th>
<th class="text-right">Traffic (GB)</th>
<th>Supplier</th>
</tr>
</thead>
<tbody>
{{-- @todo This query is expensive still --}}
@foreach (\App\Models\Service::active()->with(['type','product.type.supplied.supplier_detail.supplier','product.translate'])->get() as $o)
<tr>
<td><a href="{{ url('u/service',[$o->id]) }}">{{ $o->id }}</a></td>
<td>{{ $o->name }}</td>
<td>{{ $o->product->name }}</td>
<td class="text-right">{{ number_format($o->billing_monthly_price,2) }}</td>
<td class="text-right">{{ number_format($o->product->cost_normalized(),2) }}</td>
<td class="text-right">{{ $o->category == 'broadband' ? number_format($o->type->usage_summary(0)->sum()/1000,1) : '-' }}</td>
<td>{{ $o->product->supplier->name }}</td>
</tr>
@endforeach
</tbody>
</table>
<tbody>
{{-- @todo This query is expensive still --}}
@foreach (\App\Models\Service::active()->with(['type','product.type.supplied.supplier_detail.supplier','product.translate'])->get() as $o)
<tr>
<td><a href="{{ url('u/service',[$o->id]) }}">{{ $o->id }}</a></td>
<td>{{ $o->name }}</td>
<td>{{ $o->product->name }}</td>
<td class="text-right">{{ number_format($o->billing_monthly_price,2) }}</td>
<td class="text-right">{{ number_format($o->product->cost_normalized(),2) }}</td>
<td class="text-right">{{ $o->category == 'broadband' ? number_format($o->type->usage_summary(0)->sum()/1000,1) : '-' }}</td>
<td>{{ $o->product->supplier->name }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
@endsection

View File

@ -119,8 +119,8 @@
</ul>
</li>
<li class="nav-item has-treeview @if(preg_match('#^a/report/(accounts|services)#',$path))menu-open @else menu-closed @endif">
<a href="#" class="nav-link @if(preg_match('#^a/report/(accounts|services)#',$path)) active @endif">
<li class="nav-item has-treeview @if(preg_match('#^a/report/(accounts|products|services)#',$path))menu-open @else menu-closed @endif">
<a href="#" class="nav-link @if(preg_match('#^a/report/(accounts|products|services)#',$path)) active @endif">
<i class="nav-icon fas fa-list"></i> <p>REPORT<i class="fas fa-angle-left right"></i></p>
</a>
@ -132,10 +132,18 @@
</li>
</ul>
<ul class="nav nav-treeview">
<li class="nav-item">
<a href="{{ url('a/report/products') }}" class="nav-link @if(preg_match('#^a/report/products#',$path))active @endif">
<i class="nav-icon fas fa-barcode"></i> <p>Products</p>
</a>
</li>
</ul>
<ul class="nav nav-treeview">
<li class="nav-item">
<a href="{{ url('a/report/services') }}" class="nav-link @if(preg_match('#^a/report/services#',$path))active @endif">
<i class="nav-icon fas fa-barcode"></i> <p>Services</p>
<i class="nav-icon fas fa-layer-group"></i> <p>Services</p>
</a>
</li>
</ul>

View File

@ -103,6 +103,7 @@ Route::group(['middleware'=>['theme:adminlte-be','auth','role:wholesaler'],'pref
->where('oo','[0-9]+');
Route::get('report/accounts',[ReportController::class,'accounts']);
Route::get('report/products',[ReportController::class,'products']);
Route::get('report/services',[ReportController::class,'services']);
// Charges - @todo This should probably go to resellers
Route::match(['get','post'],'charge/addedit/{o?}',[AdminController::class,'charge_addedit']);