2024-08-24 07:37:55 +00:00
|
|
|
<!-- $cso=Cost::class -->
|
2022-06-14 06:55:17 +00:00
|
|
|
@extends('adminlte::layouts.app')
|
|
|
|
|
|
|
|
@section('htmlheader_title')
|
2024-08-24 07:37:55 +00:00
|
|
|
Cost #{{ $cso->id }}
|
2022-06-14 06:55:17 +00:00
|
|
|
@endsection
|
|
|
|
|
|
|
|
@section('contentheader_title')
|
2024-08-24 07:37:55 +00:00
|
|
|
Cost #{{ $cso->id }}
|
2022-06-14 06:55:17 +00:00
|
|
|
@endsection
|
|
|
|
@section('contentheader_description')
|
|
|
|
|
|
|
|
@endsection
|
|
|
|
|
|
|
|
@php($cost = 0)
|
|
|
|
@php($charge = 0)
|
|
|
|
@section('main-content')
|
|
|
|
<div class="row">
|
2022-06-28 13:20:56 +00:00
|
|
|
<div class="col-12">
|
2022-06-14 06:55:17 +00:00
|
|
|
<div class="card card-dark">
|
|
|
|
<div class="card-body">
|
|
|
|
<table class="table table-striped" id="table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Category</th>
|
|
|
|
<th>Service</th>
|
|
|
|
<th>Active</th>
|
|
|
|
<th>From</th>
|
|
|
|
<th>To</th>
|
|
|
|
<th class="text-right">Base</th>
|
|
|
|
<th class="text-right">Excess</th>
|
|
|
|
<th class="text-right">Cost</th>
|
|
|
|
<th class="text-right">Charge</th>
|
|
|
|
<th class="text-right">Profit</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody>
|
|
|
|
|
|
|
|
<!-- Broadband -->
|
2024-08-24 07:37:55 +00:00
|
|
|
@foreach ($cso->broadbands->groupBy('service_broadband_id') as $oo)
|
2022-06-14 06:55:17 +00:00
|
|
|
<tr>
|
2024-08-24 07:37:55 +00:00
|
|
|
<td>Broadband</td>
|
2022-06-14 06:55:17 +00:00
|
|
|
<td>{{ $oo->first()->service->name }}</td>
|
|
|
|
<td>{{ $oo->first()->service->active ? 'YES' : 'NO' }}</td>
|
|
|
|
<td>{{ $oo->min('start_at')->format('Y-m-d') }}</td>
|
|
|
|
<td>{{ $oo->max('end_at')->format('Y-m-d') }}</td>
|
|
|
|
<td class="text-right">${{ number_format($a=$oo->sum('base'),2) }}</td>
|
|
|
|
<td class="text-right">${{ number_format($oo->sum('excess'),2) }}</td>
|
2024-08-24 07:37:55 +00:00
|
|
|
<td class="text-right">${{ number_format($x=$oo->sum('cost'),2) }}</td>
|
|
|
|
<td class="text-right">${{ number_format($b=$oo->first()->service->billing_charge_normalised,2) }}</td>
|
2022-06-14 06:55:17 +00:00
|
|
|
<td class="text-right {{ $b-$a < 0 ? 'text-danger' : '' }}">${{ number_format($b-$a,2) }}</td>
|
|
|
|
</tr>
|
2024-08-24 07:37:55 +00:00
|
|
|
@php($cost += $x)
|
|
|
|
@php($charge += $b)
|
2022-06-14 06:55:17 +00:00
|
|
|
@endforeach
|
|
|
|
|
|
|
|
<!-- Phone -->
|
2024-08-24 07:37:55 +00:00
|
|
|
@foreach ($cso->phones->groupBy('service_phone_id') as $oo)
|
2022-06-14 06:55:17 +00:00
|
|
|
<tr>
|
2024-08-24 07:37:55 +00:00
|
|
|
<td>Phone</td>
|
2022-06-14 06:55:17 +00:00
|
|
|
<td>{{ $oo->first()->service->name }}</td>
|
|
|
|
<td>{{ $oo->first()->service->active ? 'YES' : 'NO' }}</td>
|
|
|
|
<td>{{ $oo->min('start_at')->format('Y-m-d') }}</td>
|
|
|
|
<td>{{ $oo->max('end_at')->format('Y-m-d') }}</td>
|
|
|
|
<td class="text-right">${{ number_format($a=$oo->sum('base'),2) }}</td>
|
|
|
|
<td class="text-right">${{ number_format($oo->sum('excess'),2) }}</td>
|
2024-08-24 07:37:55 +00:00
|
|
|
<td class="text-right">${{ number_format($x=$oo->sum('cost'),2) }}</td>
|
|
|
|
<td class="text-right">${{ number_format($b=$oo->first()->service->billing_charge_normalised,2) }}</td>
|
2022-06-14 06:55:17 +00:00
|
|
|
<td class="text-right {{ $b-$a < 0 ? 'text-danger' : '' }}">${{ number_format($b-$a,2) }}</td>
|
|
|
|
</tr>
|
2024-08-24 07:37:55 +00:00
|
|
|
@php($cost += $x)
|
|
|
|
@php($charge += $b)
|
2022-06-14 06:55:17 +00:00
|
|
|
@endforeach
|
|
|
|
|
|
|
|
<!-- Generic -->
|
2024-08-24 07:37:55 +00:00
|
|
|
@foreach ($cso->generics->groupBy('service_generic_id') as $oo)
|
2022-06-14 06:55:17 +00:00
|
|
|
<tr>
|
2024-08-24 07:37:55 +00:00
|
|
|
<td>Generic</td>
|
|
|
|
<td>{{ ($xx=$oo->first()->service) ? $xx->name : '-' }}</td>
|
|
|
|
<td>{{ $xx ? ($xx->active ? 'YES' : 'NO') : '-' }}</td>
|
2022-06-14 06:55:17 +00:00
|
|
|
<td>{{ $oo->min('start_at')->format('Y-m-d') }}</td>
|
|
|
|
<td>{{ $oo->max('end_at')->format('Y-m-d') }}</td>
|
|
|
|
<td class="text-right">${{ number_format($a=$oo->sum('base'),2) }}</td>
|
|
|
|
<td class="text-right">${{ number_format($oo->sum('excess'),2) }}</td>
|
2024-08-24 07:37:55 +00:00
|
|
|
<td class="text-right">${{ number_format($x=$oo->sum('cost'),2) }}</td>
|
|
|
|
<td class="text-right">${{ number_format($b=($xx ? $xx->billing_monthly_price : 0),2) }}</td>
|
2022-06-14 06:55:17 +00:00
|
|
|
<td class="text-right {{ $b-$a < 0 ? 'text-danger' : '' }}">${{ number_format($b-$a,2) }}</td>
|
|
|
|
</tr>
|
2024-08-24 07:37:55 +00:00
|
|
|
|
|
|
|
@php($cost += $x)
|
2022-06-14 06:55:17 +00:00
|
|
|
@endforeach
|
|
|
|
|
|
|
|
</tbody>
|
|
|
|
<tfoot>
|
|
|
|
<tr>
|
|
|
|
<th colspan="7">TOTAL</th>
|
|
|
|
<th class="text-right">${{ number_format($cost,2) }}</th>
|
|
|
|
<th class="text-right">${{ number_format($charge,2) }}</th>
|
|
|
|
<td class="text-right {{ $charge-$cost < 0 ? 'text-danger' : '' }}">${{ number_format($charge-$cost,2) }}</td>
|
|
|
|
</tr>
|
|
|
|
</tfoot>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
@endsection
|
|
|
|
|
2024-08-24 07:37:55 +00:00
|
|
|
@pa(datatables,rowgroup)
|
2022-06-14 06:55:17 +00:00
|
|
|
|
2024-08-24 07:37:55 +00:00
|
|
|
@section('page-scripts')
|
2022-06-14 06:55:17 +00:00
|
|
|
<script>
|
2024-08-24 07:37:55 +00:00
|
|
|
function sum(data) {
|
|
|
|
return parseFloat(data.reduce((a,b)=>a+parseFloat(b.toString().replace(/\$/,'')),0)).toFixed(2);
|
|
|
|
}
|
|
|
|
|
2022-06-14 06:55:17 +00:00
|
|
|
$(document).ready(function() {
|
|
|
|
$('#table').DataTable({
|
|
|
|
order: [[0,'asc'],[1,'desc']],
|
2024-08-24 07:37:55 +00:00
|
|
|
rowGroup: {
|
|
|
|
dataSrc: 0,
|
|
|
|
startRender: function (rows,group) {
|
|
|
|
var allRows = rows.rows().data().filter(function(value) {
|
|
|
|
return value[0] === group;
|
|
|
|
});
|
|
|
|
|
|
|
|
return $('<tr/>')
|
|
|
|
.append('<td colspan="5">Totals for <strong>'+group+'</strong></td>')
|
|
|
|
.append('<td class="text-right">$'+sum(allRows.pluck(5))+'</td>')
|
|
|
|
.append('<td class="text-right">$'+sum(allRows.pluck(6))+'</td>')
|
|
|
|
.append('<td class="text-right">$'+sum(allRows.pluck(7))+'</td>')
|
|
|
|
.append('<td class="text-right">$'+sum(allRows.pluck(8))+'</td>')
|
|
|
|
.append('<td class="text-right">$'+sum(allRows.pluck(9))+'</td>');
|
|
|
|
},
|
|
|
|
}
|
2022-06-14 06:55:17 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
@append
|