Reimplmement service changes going to the service__change table

This commit is contained in:
2023-05-06 13:53:14 +10:00
parent 691180b3f0
commit 013bb632d3
9 changed files with 181 additions and 26 deletions

View File

@@ -14,7 +14,7 @@
{{ $o->sid }}
@endsection
<!-- $o = App\Models\Service::class -->
<!-- $o = Service::class, $np = Product::class -->
@section('main-content')
<div class="row">
<div class="col-12 col-lg-4">
@@ -56,7 +56,7 @@
<!-- @todo TO DO LIMIT THIS TO OF THE SAME OFFERING TYPE AND SORT BY NAME -->
@foreach (\App\Models\Product::get() as $po)
@if (! $po->category || ($po->category !== $o->product->category)) @continue @endif
<option value="{{ $po->id }}" {{ $po->id == old('broadband.product_id',$po->exists ? Arr::get($o->order_info,'change_product_id') : NULL) ? 'selected' : '' }}>{{ $po->name }}</option>
<option value="{{ $po->id }}" {{ $po->id == old('broadband.product_id',$np->id) ? 'selected' : '' }}>{{ $po->name }}</option>
@endforeach
</select>
<span class="invalid-feedback" role="alert">
@@ -81,7 +81,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<input type="date" class="form-control @error('broadband.start_at') is-invalid @enderror" id="start_at" name="broadband[start_at]" value="{{ \Illuminate\Support\Arr::get($o->order_info,'change_date') ?? '' }}" required>
<input type="date" class="form-control @error('broadband.start_at') is-invalid @enderror" id="start_at" name="broadband[start_at]" value="{{ $np->pivot->effective_at ?? $np->pivot->ordered_at }}" required>
<span class="invalid-feedback" role="alert">
@error('broadband.start_at')
{{ $message }}
@@ -153,7 +153,7 @@
</div>
<div class="card-body">
@include('service.widget.internal',['o'=>$o,'p'=>\App\Models\Product::where('id',Arr::get($o->order_info,'change_product_id'))->singleOrFail()])
@include('service.widget.internal',['o'=>$o,'p'=>$np])
</div>
</div>
</div>
@@ -170,13 +170,14 @@
var pid = $('#product_id').val();
var start = $('#start_at').val();
var fee = $('#change_fee').val();
var price = $('#price').val();
$("div[id=transactions]").empty();
$.ajax({
type: 'POST',
dataType: 'html',
data: {broadband: {product_id: pid,start_at: start,change_fee: fee}},
data: {broadband: {product_id: pid,start_at: start,change_fee: fee,price: price}},
cache: false,
url: '{{ url('r/service_change_charges',[$o->id]) }}',
timeout: 2000,
@@ -205,6 +206,10 @@
pendingtrans();
});
$('#price').on('change',function() {
pendingtrans();
});
pendingtrans();
});
</script>

View File

@@ -89,7 +89,11 @@
</div>
@can('wholesaler')
<div class="tab-pane fade" id="internal" role="tabpanel">
@include('service.widget.internal',['o'=>$o,'p'=>new \App\Models\Product()])
@if(($x=$o->changes()->where('service__change.active',TRUE)->where('complete',FALSE)->get()->pop()))
@include('service.widget.internal',['o'=>$o,'p'=>$x])
@else
@include('service.widget.internal',['o'=>$o,'p'=>new \App\Models\Product()])
@endif
</div>
<div class="tab-pane fade {{ session()->pull('service_update') ? 'active show' : '' }}" id="update" role="tabpanel">

View File

@@ -49,7 +49,7 @@
<!-- @todo -->
<tr>
<th>Traffic</th>
<td>{{ $o->service->offering->allowance_string() }} GB @if(FALSE)(YY GB used month)@endif</td>
<td>{{ $o->service->offering->allowance_string() }} GB</td>
</tr>
<tr>
<th>IP4 Address</th>
@@ -73,6 +73,23 @@
<th>Cancel Notice</th>
<td>1 month @if($o->inContract())<small>(after {{ $o->service_expire->subMonth()->format('Y-m-d') }})</small>@endif</td>
</tr>
@if(($x=$o->service->changes()->where('service__change.active',TRUE)->where('complete',FALSE)->get()->pop()))
<tr>
<th>Pending Plan Change</th>
<td>{{ $x->name }}</td>
</tr>
<tr>
<th>Pending Submitted</th>
<td>{{ $x->pivot->ordered_at }}</td>
</tr>
@if($x->pivot->effective_at)
<tr>
<th>Pending Active</th>
<td>{{ $x->pivot->effective_at }}</td>
</tr>
@endif
@endif
</table>
</div>
</div>