Update supplier/cost with components
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<!-- $o = Supplier::class -->
|
||||
@use(Carbon\Carbon)
|
||||
|
||||
<!-- $spo=Supplier::class -->
|
||||
@extends('adminlte::layouts.app')
|
||||
|
||||
@section('htmlheader_title')
|
||||
@@ -9,47 +11,44 @@
|
||||
Add Cost
|
||||
@endsection
|
||||
@section('contentheader_description')
|
||||
{{ $o->name }}
|
||||
{{ $spo->name }}
|
||||
@endsection
|
||||
|
||||
@section('main-content')
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="col-12 col-sm-9 col-md-7 col-lg-6">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form class="g-0 needs-validation" method="POST" action="{{ url('a/supplier/cost/new',[$o->id]) }}" enctype="multipart/form-data">
|
||||
@include('adminlte::widget.success')
|
||||
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-8">
|
||||
<h3>{{ $spo->name }}</h3>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<x-leenooks::button.success class="float-right"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 col-sm-9 col-md-6 col-xl-5">
|
||||
@include('adminlte::widget.form_date',[
|
||||
'label'=>'Invoice Date',
|
||||
'icon'=>'fas fa-calendar',
|
||||
'id'=>'billed_at',
|
||||
'old'=>'billed_at',
|
||||
'name'=>'billed_at',
|
||||
'value'=>\Carbon\Carbon::now()->format('Y-m-d'),
|
||||
])
|
||||
<div class="col-12">
|
||||
<x-leenooks::form.date id="billed_at" name="billed_at" icon="fa-calendar" label="Invoice Date" old="billed_at" :value="Carbon::now()->format('Y-m-d')"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 col-sm-9 col-md-6 col-xl-5">
|
||||
@include('adminlte::widget.form_file',[
|
||||
'label'=>'Invoice File',
|
||||
'icon'=>'fas fa-file',
|
||||
'id'=>'file',
|
||||
'name'=>'file',
|
||||
])
|
||||
<div class="col-12">
|
||||
<x-leenooks::form.file name="file" icon="fa-file" label="Invoice File"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
@can('wholesaler')
|
||||
<button type="submit" name="submit" class="btn btn-success mr-0 float-right">@if ($site->exists)Save @else Add @endif</button>
|
||||
@endcan
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<x-leenooks::button.reset/>
|
||||
<x-leenooks::button.submit class="float-right">Save</x-leenooks::button.submit>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
@@ -1,18 +1,17 @@
|
||||
<!-- $o = Cost::class -->
|
||||
<!-- $cso=Cost::class -->
|
||||
@extends('adminlte::layouts.app')
|
||||
|
||||
@section('htmlheader_title')
|
||||
Cost #{{ $o->id }}
|
||||
Cost #{{ $cso->id }}
|
||||
@endsection
|
||||
|
||||
@section('contentheader_title')
|
||||
Cost #{{ $o->id }}
|
||||
Cost #{{ $cso->id }}
|
||||
@endsection
|
||||
@section('contentheader_description')
|
||||
|
||||
@endsection
|
||||
|
||||
<!-- $o = App\Models\Costs -->
|
||||
@php($cost = 0)
|
||||
@php($charge = 0)
|
||||
@section('main-content')
|
||||
@@ -39,96 +38,57 @@
|
||||
<tbody>
|
||||
|
||||
<!-- Broadband -->
|
||||
<tr>
|
||||
<td>Broadband</td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>{{ $o->broadbands->min('start_at')->format('Y-m-d') }}</td>
|
||||
<td>{{ $o->broadbands->max('end_at')->format('Y-m-d') }}</td>
|
||||
<td class="text-right">${{ number_format($a=$o->broadbands->sum('base'),2) }}</td>
|
||||
<td class="text-right">${{ number_format($o->broadbands->sum('excess'),2) }}</td>
|
||||
<td class="text-right">${{ number_format($x=$o->broadbands->sum('cost'),2) }}</td>
|
||||
<td class="text-right">${{ number_format($b=$o->broadbands->sum('service.billing_monthly_price'),2) }}</td>
|
||||
<td class="text-right {{ $b-$a < 0 ? 'text-danger' : '' }}">${{ number_format($b-$a,2) }}</td>
|
||||
</tr>
|
||||
@php($cost += $x)
|
||||
@php($charge += $b)
|
||||
|
||||
@foreach ($o->broadbands->groupBy('service_broadband_id') as $oo)
|
||||
@foreach ($cso->broadbands->groupBy('service_broadband_id') as $oo)
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>Broadband</td>
|
||||
<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>
|
||||
<td class="text-right">${{ number_format($oo->sum('cost'),2) }}</td>
|
||||
<td class="text-right">${{ number_format($b=$oo->first()->service->billing_monthly_price,2) }}</td>
|
||||
<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>
|
||||
<td class="text-right {{ $b-$a < 0 ? 'text-danger' : '' }}">${{ number_format($b-$a,2) }}</td>
|
||||
</tr>
|
||||
@php($cost += $x)
|
||||
@php($charge += $b)
|
||||
@endforeach
|
||||
|
||||
<!-- Phone -->
|
||||
<tr>
|
||||
<td>Phone</td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>{{ $o->phones->min('start_at')->format('Y-m-d') }}</td>
|
||||
<td>{{ $o->phones->max('end_at')->format('Y-m-d') }}</td>
|
||||
<td class="text-right">${{ number_format($a=$o->phones->sum('base'),2) }}</td>
|
||||
<td class="text-right">${{ number_format($o->phones->sum('excess'),2) }}</td>
|
||||
<td class="text-right">${{ number_format($x=$o->phones->sum('cost'),2) }}</td>
|
||||
<td class="text-right">${{ number_format($b=$o->phones->sum('service.billing_monthly_price'),2) }}</td>
|
||||
<td class="text-right {{ $b-$a < 0 ? 'text-danger' : '' }}">${{ number_format($b-$a,2) }}</td>
|
||||
</tr>
|
||||
@php($cost += $x)
|
||||
@php($charge += $b)
|
||||
|
||||
@foreach ($o->phones->groupBy('service_phone_id') as $oo)
|
||||
@foreach ($cso->phones->groupBy('service_phone_id') as $oo)
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>Phone</td>
|
||||
<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>
|
||||
<td class="text-right">${{ number_format($oo->sum('cost'),2) }}</td>
|
||||
<td class="text-right">${{ number_format($b=$oo->first()->service->billing_monthly_price,2) }}</td>
|
||||
<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>
|
||||
<td class="text-right {{ $b-$a < 0 ? 'text-danger' : '' }}">${{ number_format($b-$a,2) }}</td>
|
||||
</tr>
|
||||
@php($cost += $x)
|
||||
@php($charge += $b)
|
||||
@endforeach
|
||||
|
||||
<!-- Generic -->
|
||||
<tr>
|
||||
<td>Generic</td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>{{ ($x=$o->generics)->count() ? $x->min('start_at')->format('Y-m-d') : '-' }}</td>
|
||||
<td>{{ $x->count() ? $x->max('end_at')->format('Y-m-d') : '-' }}</td>
|
||||
<td class="text-right">${{ number_format($a=$o->generics->sum('base'),2) }}</td>
|
||||
<td class="text-right">${{ number_format($o->generics->sum('excess'),2) }}</td>
|
||||
<td class="text-right">${{ number_format($x=$o->generics->sum('cost'),2) }}</td>
|
||||
<td class="text-right">$0.00</td>
|
||||
<td class="text-right {{ 0-$a < 0 ? 'text-danger' : '' }}">${{ number_format(0-$a,2) }}</td>
|
||||
</tr>
|
||||
|
||||
@php($cost += $x)
|
||||
|
||||
@foreach ($o->generics->groupBy('service_generic_id') as $oo)
|
||||
@foreach ($cso->generics->groupBy('service_generic_id') as $oo)
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>{{ ($x=$oo->first()->service) ? $x->name : '-' }}</td>
|
||||
<td>{{ $x ? ($x->active ? 'YES' : 'NO') : '-' }}</td>
|
||||
<td>Generic</td>
|
||||
<td>{{ ($xx=$oo->first()->service) ? $xx->name : '-' }}</td>
|
||||
<td>{{ $xx ? ($xx->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>
|
||||
<td class="text-right">${{ number_format($oo->sum('cost'),2) }}</td>
|
||||
<td class="text-right">${{ number_format($b=$x ? $x->billing_monthly_price : 0,2) }}</td>
|
||||
<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>
|
||||
<td class="text-right {{ $b-$a < 0 ? 'text-danger' : '' }}">${{ number_format($b-$a,2) }}</td>
|
||||
</tr>
|
||||
|
||||
@php($cost += $x)
|
||||
@endforeach
|
||||
|
||||
</tbody>
|
||||
@@ -147,18 +107,33 @@
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('page-scripts')
|
||||
@css(datatables,bootstrap4|rowgroup)
|
||||
@js(datatables,bootstrap4|rowgroup)
|
||||
@pa(datatables,rowgroup)
|
||||
|
||||
@section('page-scripts')
|
||||
<script>
|
||||
function sum(data) {
|
||||
return parseFloat(data.reduce((a,b)=>a+parseFloat(b.toString().replace(/\$/,'')),0)).toFixed(2);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#table').DataTable({
|
||||
order: [[0,'asc'],[1,'desc']],
|
||||
});
|
||||
rowGroup: {
|
||||
dataSrc: 0,
|
||||
startRender: function (rows,group) {
|
||||
var allRows = rows.rows().data().filter(function(value) {
|
||||
return value[0] === group;
|
||||
});
|
||||
|
||||
$('tbody').on('click','tr', function () {
|
||||
$(this).toggleClass('selected');
|
||||
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>');
|
||||
},
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
@@ -1,24 +1,9 @@
|
||||
<!-- $o = Supplier::class -->
|
||||
<!-- $spo=Supplier::class -->
|
||||
@use(App\Models\Cost)
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<div class="form-group has-validation">
|
||||
<label for="cost_id">Supplier Invoice</label>
|
||||
<select class="form-control form-control-border" id="cost_id" name="cost_id">
|
||||
<option value=""></option>
|
||||
<option value="">Add New</option>
|
||||
@foreach(\App\Models\Cost::where('supplier_id',$o->id)->orderBy('billed_at','DESC')->get() as $oo)
|
||||
<option value="{{ $oo->id }}">{{ $oo->billed_at->format('Y-m-d') }}: ${{ number_format($oo->total,2) }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('name')
|
||||
{{ $message }}
|
||||
@else
|
||||
Date is required.
|
||||
@enderror
|
||||
</span>
|
||||
<span class="input-helper">Suppliers Invoice</span>
|
||||
</div>
|
||||
<x-leenooks::form.select name="cost_id" icon="fa-list" label="Supplier Invoice" helper="Supplier invoice" addnew="Add New" :options="Cost::where('supplier_id',$spo->id)->orderBy('billed_at','DESC')->get()->map(fn($item,$key)=>['id'=>$item->id,'value'=>sprintf('%s: $%s',$item->billed_at->format('Y-m-d'),number_format($item->total,2))])"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -27,7 +12,7 @@
|
||||
$(document).ready(function() {
|
||||
$('#cost_id')
|
||||
.on('change',function(item) {
|
||||
window.location.href = '{{ url('a/supplier/cost') }}/'+(item.target.value ? item.target.value : 'new/'+{{ $o->id }});
|
||||
window.location.href = '{{ url('a/supplier/cost') }}/'+(item.target.value !== 'new' ? item.target.value : 'new/'+{{ $spo->id }});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user