Progress on order progress to provisioning

This commit is contained in:
Deon George 2020-04-23 17:38:09 +10:00
parent 3b168af492
commit 4935a9f5ff
No known key found for this signature in database
GPG Key ID: 7670E8DC27415254
8 changed files with 229 additions and 15 deletions

View File

@ -58,18 +58,44 @@ class ServiceController extends Controller
return $this->update_order_status($o);
case 'PROVISION-PLANNED':
if ($request->post()) {
foreach (['provision_notes'] as $key) {
$o->setOrderInfo($key,$request->post($key));
}
$o->date_start = $request->post('date_start');
$o->save();
foreach ($request->post($o->stype) as $k=>$v) {
$o->type->{$k} = $v;
}
$o->type->save();
return redirect()->to(url('u/service',$o->id))->with('updated','Order sent notes updated.');
}
return $this->update_provision_planned($o);
default:
abort(499,'Not yet implemented');
}
}
private function update_order_status(Service $o)
{
return View('r.service.order.sent',['o'=>$o]);
}
private function update_request_cancel(Service $o)
{
return View('u.service.order.cancel',['o'=>$o]);
}
private function update_order_status(Service $o)
private function update_provision_planned(Service $o)
{
return View('r.service.order.sent',['o'=>$o]);
return View('r.service.order.provision_plan',['o'=>$o]);
}
}

View File

@ -164,7 +164,38 @@ class Service extends Model
'title'=>'Send Order',
],
// Order Confirmed by Supplier
'ORDERED' => ['update_reference'=>'ORDER-SENT'],
'ORDERED' => [
'fail'=>false,
'next'=>[
'PROVISION-HOLD'=>['wholesaler'],
'PROVISION-PLANNED'=>['wholesaler'],
'PROVISIONED'=>['wholesaler'],
],
'system'=>FALSE,
'method'=>'action_ordered',
'title'=>'Service Ordered',
],
// Service confirmed by supplier, optional connection date
'PROVISION-PLANNED' => [
'fail'=>false,
'next'=>[
'PROVISIONED'=>['wholesaler'],
],
'system'=>FALSE,
'method'=>'action_provision_planned',
'title'=>'Provision Planned',
],
// Service has been provisioned by supplier
'PROVISIONED' => [
'fail'=>false,
'next'=>[
'ACTIVE'=>['wholesaler'],
],
'system'=>FALSE,
'method'=>'action_provisioned',
'title'=>'Provisioned',
],
// Service is Active
'ACTIVE' => [
'fail'=>FALSE,
'next'=>[
@ -175,6 +206,7 @@ class Service extends Model
'method'=>'action_active',
'title'=>'Service Active',
],
// Service to be Upgraded
'UPGRADE-REQUEST' => [
'fail'=>FALSE,
'next'=>[
@ -184,6 +216,7 @@ class Service extends Model
'method'=>FALSE,
'title'=>'Upgrade Service',
],
// Service to be Cancelled
'CANCEL-REQUEST' => [
'fail'=>FALSE,
'next'=>[
@ -436,7 +469,8 @@ class Service extends Model
$last = $this->getInvoiceToAttribute();
$date = $last
? $last->addDay()
: ($this->date_next_invoice ? $this->date_next_invoice->clone() : Carbon::now());
: ($this->date_next_invoice ? $this->date_next_invoice->clone()
: ($this->date_start ?: Carbon::now()));
return request()->wantsJson() ? $date->format('Y-m-d') : $date;
}
@ -843,6 +877,17 @@ class Service extends Model
throw new HttpException(301,url('u/service/cancel',$this->id));
}
/**
* Processing when service has been ordered.
*
* @return bool|null
*/
private function action_ordered(): ?bool
{
// N/A
return TRUE;
}
/**
* Process for an order when status ORDER-ACCEPT stage.
* This method should have the client confirm/accept the order, if it was placed by a reseller/wholesaler.
@ -859,8 +904,12 @@ class Service extends Model
* Action method when status ORDER_SENT
* This method redirects to a form, where updating the form will progress to the next stage.
*/
private function action_order_sent()
private function action_order_sent(string $next)
{
// We can proceed to the ordered status
if ($next == 'ORDERED' AND $this->order_info_reference)
return TRUE;
throw new HttpException(301,url('r/service/update',$this->id));
}
@ -875,6 +924,17 @@ class Service extends Model
return TRUE;
}
/**
* Action when supplier has confirmed provisioning.
*
* @param string $next
* @return bool
*/
private function action_provision_planned(string $next)
{
throw new HttpException(301,url('r/service/update',$this->id));
}
/**
* Process for an order when status SETUP-PAYMENT-WAIT stage.
* This method should collect any setup fees payment.
@ -939,13 +999,12 @@ class Service extends Model
// Can the current user do this role?
$cando = FALSE;
foreach ($roles as $role) {
if ($myrole < array_search($role,User::$role_order)) {
if ($myrole <= array_search($role,User::$role_order)) {
$cando = TRUE;
break;
}
}
//dd($action,$roles,$result);
if ($cando OR $result->get('system')) {
$next->put($action,$roles);
}
@ -981,7 +1040,7 @@ class Service extends Model
// If valid, call the method to confirm that the current stage is complete
if (method_exists($this,$current['method'])) {
try {
$result = $this->{$current['method']}();
$result = $this->{$current['method']}($stage);
// If we have a form to complete, we need to return with a URL, so we can catch that with an Exception
} catch (HttpException $e) {
@ -1225,7 +1284,7 @@ class Service extends Model
* @param string $key
* @param string $value
*/
public function setOrderInfo(string $key,string $value): void
public function setOrderInfo(string $key,?string $value): void
{
$x = is_null($this->order_info) ? collect() : $this->order_info;
$x->put($key,$value);

View File

@ -462,7 +462,6 @@ class User extends Authenticatable
public function client_service_movements(): DatabaseCollection
{
return Service::active()
->select(['id','account_id','product_id','order_status','model','order_info'])
->where('order_status','!=','ACTIVE')
->whereIN('account_id',$this->all_accounts()->pluck('id')->unique()->toArray())
->with(['account','product'])

View File

@ -0,0 +1,92 @@
@extends('adminlte::layouts.app')
@section('htmlheader_title')
{{ $o->sid }}
@endsection
@section('page_title')
{{ $o->sid }}
@endsection
@section('contentheader_title')
Service: {{ $o->sid }} <strong>{{ $o->product->name }}</strong>
@endsection
@section('contentheader_description')
{{ $o->sname }}: {{ $o->sdesc }}
@endsection
@section('main-content')
<div class="row">
<div class="col-6">
<div class="card">
<div class="card-header">
<div class="card-title">Update Order Status: {{ $o->order_status }}</div>
</div>
<form class="form-horizontal" method="post" action="{{ url('r/service/update',$o->id) }}">
{{ csrf_field() }}
<div class="card-body">
<div class="form-group row">
<label for="reference" class="col-sm-3 col-form-label text-right">Pending Connection</label>
<div class="col-sm-6">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<input type="text" class="form-control" id="datestart" name="date_start" value="{{ ($x=$o->date_start) ? $x->format('Y-m-d') : '' }}">
</div>
</div>
</div>
@includeIf('u.service.widgets.'.$o->stype.'.order',['o'=>$o->type])
<div class="form-group row">
<label for="notes" class="col-sm-2 col-form-label text-right">Notes</label>
<div class="col-sm-10">
<textarea class="textarea" name="provision_notes">{{ $o->order_provision_notes ?? '' }}</textarea>
</div>
</div>
</div>
<div class="card-footer">
<button type="reset" class="btn btn-secondary mr-2" onclick="window.history.go(-1); return false;">Cancel</button>
<button type="submit" class="btn btn-success">Submit</button>
</div>
</form>
</div>
</div>
</div>
@endsection
@section('page-scripts')
@css('//cdnjs.cloudflare.com/ajax/libs/summernote/0.8.12/summernote-bs4.css','summernote-css')
@js('//cdnjs.cloudflare.com/ajax/libs/summernote/0.8.12/summernote-bs4.js','summernote-js')
@js('//cdn.jsdelivr.net/momentjs/latest/moment.min.js','moment-js')
@js('//cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js','daterange-js')
@css('//cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css','daterange-css')
<script>
$(document).ready(function() {
$('#datestart').daterangepicker({
singleDatePicker: true,
showDropdowns: true,
locale: {
format: 'YYYY-MM-DD'
}
});
$('.textarea').summernote({
minHeight: 350,
toolbar: [
['style', ['style']],
['font', ['bold', 'underline', 'clear']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']],
['view', ['codeview', 'help']],
],
});
});
</script>
@append

View File

@ -29,9 +29,17 @@
<td>{{ $o->name_short }}</td>
<td>
{{ $o->status }}
@if ($o->status == 'ORDER-SENT')
(#{{$o->order_info_reference}})
@endif
@switch($o->status)
@case ('ORDER-SENT')
<br>(#{{ $o->order_info_reference }})
@break;
@case ('PROVISION-PLANNED')
<br>({{ ($xx=$o->date_start) ? $xx->format('Y-m-d') : 'No Date' }})
@break;
@case ('CANCEL-PENDING')
<br>({{ ($xx=$o->date_end) ? $xx->format('Y-m-d') : 'No Date' }})
@break;
@endswitch
</td>
<td>{{ $o->product->name }}</td>
</tr>

View File

@ -38,7 +38,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<input type="text" class="form-control" id="datestop" name="date_end" value="{{ ($x=$o->date_end) && $x->format('Y-m-d') ?? '' }}">
<input type="text" class="form-control" id="datestop" name="date_end" value="{{ ($x=$o->date_end) ? $x->format('Y-m-d') : '' }}">
</div>
</div>
</div>

View File

@ -1,5 +1,5 @@
<div class="form-group row">
<label for="reference" class="col-sm-2 col-form-label text-right">Service Number</label>
<label for="reference" class="col-sm-3 col-form-label text-right">Service Number</label>
<div class="col-sm-6">
<div class="input-group">
<div class="input-group-prepend">
@ -9,3 +9,27 @@
</div>
</div>
</div>
<div class="form-group row">
<label for="reference" class="col-sm-3 col-form-label text-right">Service Username</label>
<div class="col-sm-6">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
</div>
<input type="text" class="form-control" name="broadband[service_username]" value="{{ $o->service_username ?? '' }}">
</div>
</div>
</div>
<div class="form-group row">
<label for="reference" class="col-sm-3 col-form-label text-right">Service Password</label>
<div class="col-sm-6">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-lock"></i></span>
</div>
<input type="text" class="form-control" name="broadband[service_password]" value="{{ $o->service_password ?? '' }}">
</div>
</div>
</div>

View File

@ -27,6 +27,12 @@
<td>{{ $o->order_info_reference ?? '' }}</td>
</tr>
@endif
@if ($o->date_start AND $o->isPending())
<tr>
<th>Pending Connection</th>
<td>{{ $o->date_start->format('Y-m-d') }}</td>
</tr>
@endif
@if ($o->date_end)
<tr>
<th>Cancellation Date</th>