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')
Invoice | @@ -29,49 +29,49 @@
---|
No invoices due
- @endif -No invoices due
+ @endif +ID | Date | Amount |
---|
No payments recorded
- @endif -No payments recorded
+ @endif +ID | -Category | -Service | -Product | -Status | -Next Invoice | -
---|---|---|---|---|---|
Count {{ $user->services_active->count() }} | -- |
No services active
- @endif -No services active
+ @endif +
+ 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
+