From 4935a9f5ff1e7f01ffdb77d666135ad928c8324b Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 23 Apr 2020 17:38:09 +1000 Subject: [PATCH] Progress on order progress to provisioning --- app/Http/Controllers/ServiceController.php | 30 +++++- app/Models/Service.php | 73 +++++++++++++-- app/User.php | 1 - .../r/service/order/provision_plan.blade.php | 92 +++++++++++++++++++ .../r/service/widget/movement.blade.php | 14 ++- .../adminlte/u/service/order/cancel.blade.php | 2 +- .../service/widgets/broadband/order.blade.php | 26 +++++- .../u/service/widgets/information.blade.php | 6 ++ 8 files changed, 229 insertions(+), 15 deletions(-) create mode 100644 resources/views/theme/backend/adminlte/r/service/order/provision_plan.blade.php diff --git a/app/Http/Controllers/ServiceController.php b/app/Http/Controllers/ServiceController.php index b607fcc..ef39597 100644 --- a/app/Http/Controllers/ServiceController.php +++ b/app/Http/Controllers/ServiceController.php @@ -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]); } } \ No newline at end of file diff --git a/app/Models/Service.php b/app/Models/Service.php index 8ae2b81..10e302f 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -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); diff --git a/app/User.php b/app/User.php index 09beaea..c3c62f6 100644 --- a/app/User.php +++ b/app/User.php @@ -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']) diff --git a/resources/views/theme/backend/adminlte/r/service/order/provision_plan.blade.php b/resources/views/theme/backend/adminlte/r/service/order/provision_plan.blade.php new file mode 100644 index 0000000..63b8790 --- /dev/null +++ b/resources/views/theme/backend/adminlte/r/service/order/provision_plan.blade.php @@ -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 }} {{ $o->product->name }} +@endsection +@section('contentheader_description') + {{ $o->sname }}: {{ $o->sdesc }} +@endsection + +@section('main-content') +
+
+
+
+
Update Order Status: {{ $o->order_status }}
+
+ +
+ {{ csrf_field() }} + +
+
+ +
+
+
+ +
+ +
+
+
+ + @includeIf('u.service.widgets.'.$o->stype.'.order',['o'=>$o->type]) + +
+ +
+ +
+
+
+ + + +
+
+
+
+@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') + + +@append \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/r/service/widget/movement.blade.php b/resources/views/theme/backend/adminlte/r/service/widget/movement.blade.php index 89e143a..c1b2a53 100644 --- a/resources/views/theme/backend/adminlte/r/service/widget/movement.blade.php +++ b/resources/views/theme/backend/adminlte/r/service/widget/movement.blade.php @@ -29,9 +29,17 @@ {{ $o->name_short }} {{ $o->status }} - @if ($o->status == 'ORDER-SENT') - (#{{$o->order_info_reference}}) - @endif + @switch($o->status) + @case ('ORDER-SENT') +
(#{{ $o->order_info_reference }}) + @break; + @case ('PROVISION-PLANNED') +
({{ ($xx=$o->date_start) ? $xx->format('Y-m-d') : 'No Date' }}) + @break; + @case ('CANCEL-PENDING') +
({{ ($xx=$o->date_end) ? $xx->format('Y-m-d') : 'No Date' }}) + @break; + @endswitch {{ $o->product->name }} diff --git a/resources/views/theme/backend/adminlte/u/service/order/cancel.blade.php b/resources/views/theme/backend/adminlte/u/service/order/cancel.blade.php index fddfdd8..3d2b9a3 100644 --- a/resources/views/theme/backend/adminlte/u/service/order/cancel.blade.php +++ b/resources/views/theme/backend/adminlte/u/service/order/cancel.blade.php @@ -38,7 +38,7 @@
- + diff --git a/resources/views/theme/backend/adminlte/u/service/widgets/broadband/order.blade.php b/resources/views/theme/backend/adminlte/u/service/widgets/broadband/order.blade.php index 2ea73f9..f3e312d 100644 --- a/resources/views/theme/backend/adminlte/u/service/widgets/broadband/order.blade.php +++ b/resources/views/theme/backend/adminlte/u/service/widgets/broadband/order.blade.php @@ -1,5 +1,5 @@
- +
@@ -8,4 +8,28 @@
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
\ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/u/service/widgets/information.blade.php b/resources/views/theme/backend/adminlte/u/service/widgets/information.blade.php index 8b70139..fdd0e3c 100644 --- a/resources/views/theme/backend/adminlte/u/service/widgets/information.blade.php +++ b/resources/views/theme/backend/adminlte/u/service/widgets/information.blade.php @@ -27,6 +27,12 @@ {{ $o->order_info_reference ?? '' }} @endif + @if ($o->date_start AND $o->isPending()) + + Pending Connection + {{ $o->date_start->format('Y-m-d') }} + + @endif @if ($o->date_end) Cancellation Date