From 182181057018fab8248d8f49a155f6d9cf9c09e8 Mon Sep 17 00:00:00 2001 From: Deon George Date: Mon, 16 Jul 2018 15:06:43 +1000 Subject: [PATCH] Minor display fixes, link to old site --- app/Classes/SSL.php | 80 +++++++++++ app/Exceptions/SSLUnknownAttribute.php | 9 ++ app/Http/Controllers/UserHomeController.php | 14 ++ app/Models/Payment.php | 12 ++ app/Models/Service.php | 2 +- app/Models/ServiceAdsl.php | 7 +- app/Models/ServiceDomain.php | 7 +- app/Models/ServiceHost.php | 7 +- app/Models/ServiceSsl.php | 30 ++-- app/Models/ServiceVoip.php | 7 +- app/Models/Service_Model.php | 22 +++ app/User.php | 2 +- .../site/js/bootstrap3-typeahead.min.js | 0 .../adminlte => }/site/js/fastclick.min.js | 0 .../site/js/jquery.slimscroll.min.js | 0 .../theme/backend/adminlte/home.blade.php | 19 ++- .../adminlte/widgets/invoices_due.blade.php | 100 +++++++------- .../widgets/payment_history.blade.php | 104 +++++++------- .../widgets/services_active.blade.php | 128 +++++++++--------- resources/views/errors/307.blade.php | 27 ++++ routes/web.php | 1 + 21 files changed, 375 insertions(+), 203 deletions(-) create mode 100644 app/Classes/SSL.php create mode 100644 app/Exceptions/SSLUnknownAttribute.php create mode 100644 app/Models/Service_Model.php rename public/{theme/backend/adminlte => }/site/js/bootstrap3-typeahead.min.js (100%) rename public/{theme/backend/adminlte => }/site/js/fastclick.min.js (100%) rename public/{theme/backend/adminlte => }/site/js/jquery.slimscroll.min.js (100%) create mode 100644 resources/views/errors/307.blade.php diff --git a/app/Classes/SSL.php b/app/Classes/SSL.php new file mode 100644 index 0000000..c5e7b71 --- /dev/null +++ b/app/Classes/SSL.php @@ -0,0 +1,80 @@ +cn(); + default: + throw new \App\Exceptions\SSLUnknownAttribute($key); + } + } + + private function cn() + { + $subject = array_get($this->crt,'subject'); + + if (! $subject AND $this->csr_pem) { + $subject = openssl_csr_get_subject($this->csr_pem); + } + + return isset($subject['CN']) ? $subject['CN'] : NULL; + } + + /** + * Add CSR + * + * @param $value + * @return mixed + */ + public function csr($value) + { + $this->csr_pem = $value; + + return $this; + } + + /** + * Add certificate + * + * @param $value + * @return mixed + */ + public function crt($value) + { + $this->crt_pem = $value; + $this->crt = openssl_x509_parse($this->crt); + + return $this; + } + + /** + * Add the Key + * + * @param $value + * @return mixed + */ + public function key($value) + { + $this->key_pem = $value; + + return $this; + } +} \ No newline at end of file diff --git a/app/Exceptions/SSLUnknownAttribute.php b/app/Exceptions/SSLUnknownAttribute.php new file mode 100644 index 0000000..d0ca155 --- /dev/null +++ b/app/Exceptions/SSLUnknownAttribute.php @@ -0,0 +1,9 @@ +role()); } } + + /** + * Helper to redirect to the old site, when functions are not available in this one. + * + * @param $type + * @param $action + * @param $id + * @return void + * @deprecated @todo Remove once all functions added + */ + public function oldsite($type,$action,$id) + { + abort(307,sprintf('http://www.graytech.net.au/u/%s/%s/%s',$type,$action,$id)); + } } \ No newline at end of file diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 7285094..131f036 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -12,12 +12,14 @@ class Payment extends Model protected $appends = [ 'date_paid', + 'payment_id_url', 'total', ]; protected $visible = [ 'date_paid', 'id', + 'payment_id_url', 'total', ]; @@ -36,6 +38,16 @@ class Payment extends Model return $this->date_payment->format('Y-m-d'); } + public function getPaymentIdAttribute() + { + return sprintf('%02s-%04s+%05s',$this->site_id,$this->account_id,$this->id); + } + + public function getPaymentIdUrlAttribute() + { + return sprintf('%s',$this->id,$this->payment_id); + } + public function getTotalAttribute() { return sprintf('%3.'.$this->currency()->rounding.'f',$this->total_amt); diff --git a/app/Models/Service.php b/app/Models/Service.php index bc62731..4151fda 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -119,7 +119,7 @@ class Service extends Model public function getServiceIdAttribute() { - return sprintf('%02s-%05s',$this->site_id,$this->id); + return sprintf('%02s-%04s.%05s',$this->site_id,$this->account_id,$this->id); } public function getServiceIdUrlAttribute() diff --git a/app/Models/ServiceAdsl.php b/app/Models/ServiceAdsl.php index 62867e7..e8fd01d 100644 --- a/app/Models/ServiceAdsl.php +++ b/app/Models/ServiceAdsl.php @@ -2,17 +2,12 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Model; +use App\Models\Service_Model as Model; class ServiceAdsl extends Model { protected $table = 'ab_service__adsl'; - public function service() - { - return $this->belongsTo(Service::class); - } - public function getNameAttribute() { return $this->service_number; diff --git a/app/Models/ServiceDomain.php b/app/Models/ServiceDomain.php index 1c49d2f..ad1bdf3 100644 --- a/app/Models/ServiceDomain.php +++ b/app/Models/ServiceDomain.php @@ -2,17 +2,12 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Model; +use App\Models\Service_Model as Model; class ServiceDomain extends Model { protected $table = 'ab_service__domain'; - public function service() - { - return $this->belongsTo(Service::class); - } - public function tld() { return $this->belongsTo(DomainTld::class,'domain_tld_id'); diff --git a/app/Models/ServiceHost.php b/app/Models/ServiceHost.php index c2e245f..542b8dc 100644 --- a/app/Models/ServiceHost.php +++ b/app/Models/ServiceHost.php @@ -2,17 +2,12 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Model; +use App\Models\Service_Model as Model; class ServiceHost extends Model { protected $table = 'ab_service__hosting'; - public function service() - { - return $this->belongsTo(Service::class); - } - public function getNameAttribute() { return sprintf('%s',$this->domain_name); diff --git a/app/Models/ServiceSsl.php b/app/Models/ServiceSsl.php index a45b285..aff8c5a 100644 --- a/app/Models/ServiceSsl.php +++ b/app/Models/ServiceSsl.php @@ -2,25 +2,39 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Model; +use App\Models\Service_Model as Model; +use App\Classes\SSL; class ServiceSsl extends Model { protected $table = 'ab_service__ssl'; - - public function service() - { - return $this->belongsTo(Service::class); - } + protected $_o = NULL; public function tld() { return $this->belongsTo(DomainTld::class,'domain_tld_id'); } + public function getSSLAttribute() + { + if (is_null($this->_o)) + { + $this->_o = new SSL; + + if ($this->cert) + $this->_o->crt($this->cert); + if ($this->csr) + $this->_o->csr($this->csr); + if ($this->pk) + $this->_o->key($this->pk); + + } + + return $this->_o; + } + public function getNameAttribute() { - // @todo Merge in SSL functions from old site - return 'SSL'; + return $this->ssl->cn; } } \ No newline at end of file diff --git a/app/Models/ServiceVoip.php b/app/Models/ServiceVoip.php index 0f1dcce..99536f6 100644 --- a/app/Models/ServiceVoip.php +++ b/app/Models/ServiceVoip.php @@ -2,17 +2,12 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Model; +use App\Models\Service_Model as Model; class ServiceVoip extends Model { protected $table = 'ab_service__voip'; - public function service() - { - return $this->belongsTo(Service::class); - } - public function getNameAttribute() { return $this->service_number; diff --git a/app/Models/Service_Model.php b/app/Models/Service_Model.php new file mode 100644 index 0000000..1949c8d --- /dev/null +++ b/app/Models/Service_Model.php @@ -0,0 +1,22 @@ +belongsTo(Service::class); + } + + /** + * The name of the server, that will appear on invoices/service displays + * @return mixed + */ + abstract public function getNameAttribute(); +} \ No newline at end of file diff --git a/app/User.php b/app/User.php index 5cec98a..c13946e 100644 --- a/app/User.php +++ b/app/User.php @@ -97,7 +97,7 @@ class User extends Authenticatable return $this->invoices ->where('active',TRUE) ->sortBy('id') - ->transform(function ($item) { if ($item->due) return $item; }) + ->transform(function ($item) { if ($item->due > 0) return $item; }) ->reverse() ->filter(); } diff --git a/public/theme/backend/adminlte/site/js/bootstrap3-typeahead.min.js b/public/site/js/bootstrap3-typeahead.min.js similarity index 100% rename from public/theme/backend/adminlte/site/js/bootstrap3-typeahead.min.js rename to public/site/js/bootstrap3-typeahead.min.js diff --git a/public/theme/backend/adminlte/site/js/fastclick.min.js b/public/site/js/fastclick.min.js similarity index 100% rename from public/theme/backend/adminlte/site/js/fastclick.min.js rename to public/site/js/fastclick.min.js diff --git a/public/theme/backend/adminlte/site/js/jquery.slimscroll.min.js b/public/site/js/jquery.slimscroll.min.js similarity index 100% rename from public/theme/backend/adminlte/site/js/jquery.slimscroll.min.js rename to public/site/js/jquery.slimscroll.min.js diff --git a/resources/theme/backend/adminlte/home.blade.php b/resources/theme/backend/adminlte/home.blade.php index 5e5e5c4..3522ade 100644 --- a/resources/theme/backend/adminlte/home.blade.php +++ b/resources/theme/backend/adminlte/home.blade.php @@ -14,12 +14,23 @@ @section('main-content')
+ @if ($user->accounts->count() > 2) +
+
+ +
+ Accounts Linked + {{ $user->accounts->count() }} +
+
+
+ @endif
Account Balance - ${{ number_format($user->invoices_due->sum('due'),2) }} + $ {{ number_format($user->invoices_due->sum('due'),2) }}
@@ -28,16 +39,16 @@
Active Services - {{ $user->services_active->count() }} + {{ $user->services_active->count() }} /{{ $user->services->count() }}
- +
Invoices Due - ${{ number_format($user->invoices_due->sum('due'),2) }} + {{ $user->invoices_due->count() }}
diff --git a/resources/theme/backend/adminlte/widgets/invoices_due.blade.php b/resources/theme/backend/adminlte/widgets/invoices_due.blade.php index 3e40c8a..57ca5a3 100644 --- a/resources/theme/backend/adminlte/widgets/invoices_due.blade.php +++ b/resources/theme/backend/adminlte/widgets/invoices_due.blade.php @@ -1,17 +1,17 @@
-
-

Invoices Due

-
- - -
-
+
+

Invoices Due

+
+ + +
+
-
- @if ($user->invoices_due->count()) - +
+ @if ($user->invoices_due->count()) +
@@ -29,49 +29,49 @@ -
Invoice 
- @else -

No invoices due

- @endif -
+ + @else +

No invoices due

+ @endif +
@section('page-scripts') - @css('https://cdn.datatables.net/responsive/2.2.1/css/responsive.dataTables.min.css') - @css('https://cdn.datatables.net/rowgroup/1.0.2/css/rowGroup.dataTables.min.css') - @js('https://cdn.datatables.net/responsive/2.2.1/js/dataTables.responsive.min.js') - @js('https://cdn.datatables.net/rowgroup/1.0.2/js/dataTables.rowGroup.min.js') + @css('https://cdn.datatables.net/responsive/2.2.1/css/responsive.dataTables.min.css') + @css('https://cdn.datatables.net/rowgroup/1.0.2/css/rowGroup.dataTables.min.css') + @js('https://cdn.datatables.net/responsive/2.2.1/js/dataTables.responsive.min.js') + @js('https://cdn.datatables.net/rowgroup/1.0.2/js/dataTables.rowGroup.min.js') - - -@append \ No newline at end of file + $('#invoices tbody').on('click','tr', function () { + $(this).toggleClass('selected'); + }); + }); + +@append diff --git a/resources/theme/backend/adminlte/widgets/payment_history.blade.php b/resources/theme/backend/adminlte/widgets/payment_history.blade.php index a72ad08..433a0a9 100644 --- a/resources/theme/backend/adminlte/widgets/payment_history.blade.php +++ b/resources/theme/backend/adminlte/widgets/payment_history.blade.php @@ -1,64 +1,66 @@
-
-

Payment History

-
- - -
-
+
+

Payment History

+
+ + +
+
-
- @if ($user->payment_history->count()) - +
+ @if ($user->payment_history->count()) +
+ -
ID Date Amount
- @else -

No payments recorded

- @endif -
+ + @else +

No payments recorded

+ @endif +
@section('page-scripts') - @css('https://cdn.datatables.net/responsive/2.2.1/css/responsive.dataTables.min.css') - @css('https://cdn.datatables.net/rowgroup/1.0.2/css/rowGroup.dataTables.min.css') - @js('https://cdn.datatables.net/responsive/2.2.1/js/dataTables.responsive.min.js') - @js('https://cdn.datatables.net/rowgroup/1.0.2/js/dataTables.rowGroup.min.js') + @css('https://cdn.datatables.net/responsive/2.2.1/css/responsive.dataTables.min.css') + @css('https://cdn.datatables.net/rowgroup/1.0.2/css/rowGroup.dataTables.min.css') + @js('https://cdn.datatables.net/responsive/2.2.1/js/dataTables.responsive.min.js') + @js('https://cdn.datatables.net/rowgroup/1.0.2/js/dataTables.rowGroup.min.js') - - -@append \ No newline at end of file + $('#payments tbody').on('click','tr', function () { + $(this).toggleClass('selected'); + }); + }); + +@append diff --git a/resources/theme/backend/adminlte/widgets/services_active.blade.php b/resources/theme/backend/adminlte/widgets/services_active.blade.php index 1dc804d..958823f 100644 --- a/resources/theme/backend/adminlte/widgets/services_active.blade.php +++ b/resources/theme/backend/adminlte/widgets/services_active.blade.php @@ -1,38 +1,38 @@
-
-

Services

-
- - -
-
+
+

Services

+
+ + +
+
-
- @if ($user->services_active->count()) - - - +
+ @if ($user->services_active->count()) +
+ + - - - - - - - - - - - - - -
IDCategoryServiceProductStatusNext Invoice
Count {{ $user->services_active->count() }} 
- @else -

No services active

- @endif -
+ Category + Service + Product + Status + Next Invoice + + + + + Count {{ $user->services_active->count() }} +   + + + + @else +

No services active

+ @endif +
@section('page-scripts') @@ -47,39 +47,39 @@ } @append \ No newline at end of file diff --git a/resources/views/errors/307.blade.php b/resources/views/errors/307.blade.php new file mode 100644 index 0000000..78b54fe --- /dev/null +++ b/resources/views/errors/307.blade.php @@ -0,0 +1,27 @@ +@extends('adminlte::layouts.errors') + +@section('htmlheader_title') + {{ trans('adminlte_lang::message.servererror') }} +@endsection + +@section('main-content') +
+

307

+
+

Oops! Not updated yet!

+

+ That data is still on the old site. You'll be redirected in 5 seconds.
+ (You might be asked to login again.)
+ Here: {{ $exception->getMessage() }}
+ Back to home +

+
+
+
+ + +@append \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index f1fbca6..6396b9f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -34,3 +34,4 @@ Route::group(['middleware'=>['theme:metronic-fe']], function() { Route::demoAccess('/uc-access'); Route::redirect('/under-construction','http://www.graytech.net.au'); +Route::get('/u/{type}/{action}/{id}','UserHomeController@oldsite'); \ No newline at end of file