From aeacb726dde8004b48dc8c9ec5ffbb220f024b02 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 18 Sep 2018 12:37:04 +1000 Subject: [PATCH] Added command line send/reject for orders --- app/Console/Commands/OrderReject.php | 58 +++++++++++++++++++ app/Console/Commands/OrderSend.php | 58 +++++++++++++++++++ app/Mail/OrderRequestApprove.php | 2 +- app/Mail/OrderRequestReject.php | 42 ++++++++++++++ app/Models/Service.php | 10 ++++ .../adminlte/r/service_movements.blade.php | 6 +- .../views/email/admin/order/reject.blade.php | 30 ++++++++++ 7 files changed, 202 insertions(+), 4 deletions(-) create mode 100644 app/Console/Commands/OrderReject.php create mode 100644 app/Console/Commands/OrderSend.php create mode 100644 app/Mail/OrderRequestReject.php create mode 100644 resources/views/email/admin/order/reject.blade.php diff --git a/app/Console/Commands/OrderReject.php b/app/Console/Commands/OrderReject.php new file mode 100644 index 0000000..6744d16 --- /dev/null +++ b/app/Console/Commands/OrderReject.php @@ -0,0 +1,58 @@ +argument('service')); + + Mail::to($so->orderby->email)->sendNow(new OrderRequestReject($so,$this->argument('reason'))); + + if (Mail::failures()) { + dump('Failure?'); + + dump(Mail::failures()); + } + + $so->order_status = 'ORDER-REJECTED'; + $so->order_info = array_merge($so->order_info,['reason'=>$this->argument('reason')]); + $so->save(); + } +} \ No newline at end of file diff --git a/app/Console/Commands/OrderSend.php b/app/Console/Commands/OrderSend.php new file mode 100644 index 0000000..e6fab57 --- /dev/null +++ b/app/Console/Commands/OrderSend.php @@ -0,0 +1,58 @@ +argument('service')); + + // @todo TO get from DB + Mail::to('help@graytech.net.au')->sendNow(new OrderRequestApprove($so)); + + if (Mail::failures()) { + dump('Failure?'); + + dump(Mail::failures()); + } + + $so->order_status = 'ORDER-SENT'; + $so->save(); + } +} \ No newline at end of file diff --git a/app/Mail/OrderRequestApprove.php b/app/Mail/OrderRequestApprove.php index a291319..6c0eae8 100644 --- a/app/Mail/OrderRequestApprove.php +++ b/app/Mail/OrderRequestApprove.php @@ -50,6 +50,6 @@ class OrderRequestApprove extends Mailable return $this ->markdown('email.admin.order.approve') ->subject($subject) - ->with(['site'=>config('SITE_SETUP')]); + ->with(['site'=>$this->service->site]); } } \ No newline at end of file diff --git a/app/Mail/OrderRequestReject.php b/app/Mail/OrderRequestReject.php new file mode 100644 index 0000000..9ce5471 --- /dev/null +++ b/app/Mail/OrderRequestReject.php @@ -0,0 +1,42 @@ +service = $o; + $this->reason = $reason; + } + + /** + * Build the message. + * + * @return $this + */ + public function build() + { + return $this + ->markdown('email.admin.order.reject') + ->subject(sprintf('Your order: #%s was rejected',$this->service->id)) + ->with(['site'=>$this->service->site]); + } +} \ No newline at end of file diff --git a/app/Models/Service.php b/app/Models/Service.php index ec03ee7..8c00112 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -56,6 +56,16 @@ class Service extends Model return $this->belongsTo(Account::class); } + public function orderby() + { + return $this->belongsTo(Account::class); + } + + public function site() + { + return $this->belongsTo(Site::class); + } + public function service_adsl() { return $this->belongsTo(ServiceAdsl::class,'id','service_id'); diff --git a/resources/theme/backend/adminlte/r/service_movements.blade.php b/resources/theme/backend/adminlte/r/service_movements.blade.php index 3814080..c59e247 100644 --- a/resources/theme/backend/adminlte/r/service_movements.blade.php +++ b/resources/theme/backend/adminlte/r/service_movements.blade.php @@ -68,7 +68,7 @@ language: { emptyTable: "No Active Clients" }, - order: [1, 'asc'], + order: [3, 'asc'], rowGroup: { dataSrc: 'account_name', startRender: null, @@ -76,7 +76,7 @@ return rows.count()+' x ' + group; }, }, - orderFixed: [4, 'asc'] + orderFixed: [1, 'asc'] }); $('#service_movements tbody').on('click','tr', function () { @@ -84,4 +84,4 @@ }); }); -@append +@append \ No newline at end of file diff --git a/resources/views/email/admin/order/reject.blade.php b/resources/views/email/admin/order/reject.blade.php new file mode 100644 index 0000000..2a5dd97 --- /dev/null +++ b/resources/views/email/admin/order/reject.blade.php @@ -0,0 +1,30 @@ +@component('mail::message',['site'=>$site]) +# Your order was rejected. + +@component('mail::panel') + +@component('mail::table') + | Service | Details | + | :---------- | :---------------- | + | Account | {{ $service->account_name }} ({!! $service->account->account_id_url !!}) | + | Service ID | {!! $service->service_id_url !!} | + | Product | {{ $service->product_name }} | + @switch($service->category) + @case('ADSL') + | Address | {{ $service->service_adsl->service_address }} | + @break; + @case('VOIP') + | Address | {{ $service->service_voip->service_address }} | + | Supplier Details | {{ join(':',$service->order_info) }} | + @break; + @endswitch + +@endcomponent + +**REASON:** {{ $reason }} + +@endcomponent + +Thanks,
+{{ config('app.name') }} +@endcomponent \ No newline at end of file