Minor display fixes, link to old site

This commit is contained in:
Deon George 2018-07-16 15:06:43 +10:00
parent 64b6c09b8f
commit 1821810570
No known key found for this signature in database
GPG Key ID: 7670E8DC27415254
21 changed files with 375 additions and 203 deletions

80
app/Classes/SSL.php Normal file
View File

@ -0,0 +1,80 @@
<?php
namespace App\Classes;
class SSL
{
// Our CSR
private $csr_pem = NULL;
// Our Certificate
private $crt = [];
private $crt_pem = NULL;
// Our Key
private $key_pem = NULL;
/**
* @param $key
* @return null
* @throws \Exception
*/
public function __get($key)
{
switch($key)
{
case 'cn': return $this->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;
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace App\Exceptions;
use Exception;
class SSLUnknownAttribute extends Exception
{
}

View File

@ -27,4 +27,18 @@ class UserHomeController extends Controller
abort(500,'Unknown role: ',Auth::user()->role()); abort(500,'Unknown role: ',Auth::user()->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));
}
} }

View File

@ -12,12 +12,14 @@ class Payment extends Model
protected $appends = [ protected $appends = [
'date_paid', 'date_paid',
'payment_id_url',
'total', 'total',
]; ];
protected $visible = [ protected $visible = [
'date_paid', 'date_paid',
'id', 'id',
'payment_id_url',
'total', 'total',
]; ];
@ -36,6 +38,16 @@ class Payment extends Model
return $this->date_payment->format('Y-m-d'); 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('<a href="/u/payment/view/%s">%s</a>',$this->id,$this->payment_id);
}
public function getTotalAttribute() public function getTotalAttribute()
{ {
return sprintf('%3.'.$this->currency()->rounding.'f',$this->total_amt); return sprintf('%3.'.$this->currency()->rounding.'f',$this->total_amt);

View File

@ -119,7 +119,7 @@ class Service extends Model
public function getServiceIdAttribute() 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() public function getServiceIdUrlAttribute()

View File

@ -2,17 +2,12 @@
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use App\Models\Service_Model as Model;
class ServiceAdsl extends Model class ServiceAdsl extends Model
{ {
protected $table = 'ab_service__adsl'; protected $table = 'ab_service__adsl';
public function service()
{
return $this->belongsTo(Service::class);
}
public function getNameAttribute() public function getNameAttribute()
{ {
return $this->service_number; return $this->service_number;

View File

@ -2,17 +2,12 @@
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use App\Models\Service_Model as Model;
class ServiceDomain extends Model class ServiceDomain extends Model
{ {
protected $table = 'ab_service__domain'; protected $table = 'ab_service__domain';
public function service()
{
return $this->belongsTo(Service::class);
}
public function tld() public function tld()
{ {
return $this->belongsTo(DomainTld::class,'domain_tld_id'); return $this->belongsTo(DomainTld::class,'domain_tld_id');

View File

@ -2,17 +2,12 @@
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use App\Models\Service_Model as Model;
class ServiceHost extends Model class ServiceHost extends Model
{ {
protected $table = 'ab_service__hosting'; protected $table = 'ab_service__hosting';
public function service()
{
return $this->belongsTo(Service::class);
}
public function getNameAttribute() public function getNameAttribute()
{ {
return sprintf('%s',$this->domain_name); return sprintf('%s',$this->domain_name);

View File

@ -2,25 +2,39 @@
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use App\Models\Service_Model as Model;
use App\Classes\SSL;
class ServiceSsl extends Model class ServiceSsl extends Model
{ {
protected $table = 'ab_service__ssl'; protected $table = 'ab_service__ssl';
protected $_o = NULL;
public function service()
{
return $this->belongsTo(Service::class);
}
public function tld() public function tld()
{ {
return $this->belongsTo(DomainTld::class,'domain_tld_id'); 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() public function getNameAttribute()
{ {
// @todo Merge in SSL functions from old site return $this->ssl->cn;
return 'SSL';
} }
} }

View File

@ -2,17 +2,12 @@
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use App\Models\Service_Model as Model;
class ServiceVoip extends Model class ServiceVoip extends Model
{ {
protected $table = 'ab_service__voip'; protected $table = 'ab_service__voip';
public function service()
{
return $this->belongsTo(Service::class);
}
public function getNameAttribute() public function getNameAttribute()
{ {
return $this->service_number; return $this->service_number;

View File

@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Abstract Base Model for Services
*/
abstract class Service_Model extends Model
{
public function service()
{
return $this->belongsTo(Service::class);
}
/**
* The name of the server, that will appear on invoices/service displays
* @return mixed
*/
abstract public function getNameAttribute();
}

View File

@ -97,7 +97,7 @@ class User extends Authenticatable
return $this->invoices return $this->invoices
->where('active',TRUE) ->where('active',TRUE)
->sortBy('id') ->sortBy('id')
->transform(function ($item) { if ($item->due) return $item; }) ->transform(function ($item) { if ($item->due > 0) return $item; })
->reverse() ->reverse()
->filter(); ->filter();
} }

View File

@ -14,12 +14,23 @@
@section('main-content') @section('main-content')
<div class="content"> <div class="content">
<div class="row"> <div class="row">
@if ($user->accounts->count() > 2)
<div class="col-sm-3">
<div class="info-box">
<span class="info-box-icon bg-orange"><i class="fa fa-user"></i></span>
<div class="info-box-content">
<span class="info-box-text">Accounts Linked</span>
<span class="info-box-number">{{ $user->accounts->count() }}</span>
</div>
</div>
</div>
@endif
<div class="col-sm-3"> <div class="col-sm-3">
<div class="info-box"> <div class="info-box">
<span class="info-box-icon bg-red"><i class="fa fa-dollar"></i></span> <span class="info-box-icon bg-red"><i class="fa fa-dollar"></i></span>
<div class="info-box-content"> <div class="info-box-content">
<span class="info-box-text">Account Balance</span> <span class="info-box-text">Account Balance</span>
<span class="info-box-number"><small>$</small>{{ number_format($user->invoices_due->sum('due'),2) }}</span> <span class="info-box-number"><small>$</small> {{ number_format($user->invoices_due->sum('due'),2) }}</span>
</div> </div>
</div> </div>
</div> </div>
@ -28,16 +39,16 @@
<span class="info-box-icon bg-green"><i class="fa fa-clone"></i></span> <span class="info-box-icon bg-green"><i class="fa fa-clone"></i></span>
<div class="info-box-content"> <div class="info-box-content">
<span class="info-box-text">Active Services</span> <span class="info-box-text">Active Services</span>
<span class="info-box-number">{{ $user->services_active->count() }}</span> <span class="info-box-number">{{ $user->services_active->count() }} <small>/{{ $user->services->count() }}</small></span>
</div> </div>
</div> </div>
</div> </div>
<div class="col-sm-3"> <div class="col-sm-3">
<div class="info-box"> <div class="info-box">
<span class="info-box-icon bg-blue"><i class="fa fa-dollar"></i></span> <span class="info-box-icon bg-blue"><i class="fa fa-hashtag"></i></span>
<div class="info-box-content"> <div class="info-box-content">
<span class="info-box-text">Invoices Due</span> <span class="info-box-text">Invoices Due</span>
<span class="info-box-number"><small>$</small>{{ number_format($user->invoices_due->sum('due'),2) }}</span> <span class="info-box-number">{{ $user->invoices_due->count() }}</span>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,17 +1,17 @@
<div class="box box-info small"> <div class="box box-info small">
<div class="box-header"> <div class="box-header">
<h3 class="box-title">Invoices Due</h3> <h3 class="box-title">Invoices Due</h3>
<div class="box-tools pull-right"> <div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse"> <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
<i class="fa fa-minus"></i></button> <i class="fa fa-minus"></i></button>
<button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove"> <button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
<i class="fa fa-times"></i></button> <i class="fa fa-times"></i></button>
</div> </div>
</div> </div>
<div class="box-body"> <div class="box-body">
@if ($user->invoices_due->count()) @if ($user->invoices_due->count())
<table class="table table-bordered table-striped table-hover" id="invoices" style="width: 100%;"> <table class="table table-bordered table-striped table-hover" id="invoices" style="width: 100%;">
<thead> <thead>
<tr> <tr>
<th>Invoice</th> <th>Invoice</th>
@ -29,49 +29,49 @@
<th>&nbsp;</th> <th>&nbsp;</th>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>
@else @else
<p>No invoices due</p> <p>No invoices due</p>
@endif @endif
</div> </div>
</div> </div>
@section('page-scripts') @section('page-scripts')
@css('https://cdn.datatables.net/responsive/2.2.1/css/responsive.dataTables.min.css') @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') @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/responsive/2.2.1/js/dataTables.responsive.min.js')
@js('https://cdn.datatables.net/rowgroup/1.0.2/js/dataTables.rowGroup.min.js') @js('https://cdn.datatables.net/rowgroup/1.0.2/js/dataTables.rowGroup.min.js')
<style> <style>
table.dataTable { table.dataTable {
width: 100%; width: 100%;
} }
table.dataTable td { table.dataTable td {
outline: none; outline: none;
} }
</style> </style>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$('#invoices').DataTable( { $('#invoices').DataTable( {
responsive: true, responsive: true,
ajax: { ajax: {
url: "/api/u/invoices" url: "/api/u/invoices"
}, },
columns: [ columns: [
{ data: "invoice_id_url" }, { data: "invoice_id_url" },
{ data: "total" }, { data: "total" },
{ data: "due" }, { data: "due" },
{ data: "date_due" } { data: "date_due" }
], ],
language: { language: {
emptyTable: "No Invoices Due" emptyTable: "No Invoices Due"
}, },
order: [3, 'asc'] order: [3, 'asc']
}); });
$('#invoices tbody').on('click','tr', function () { $('#invoices tbody').on('click','tr', function () {
$(this).toggleClass('selected'); $(this).toggleClass('selected');
}); });
}); });
</script> </script>
@append @append

View File

@ -1,64 +1,66 @@
<div class="box box-notice small"> <div class="box box-notice small">
<div class="box-header"> <div class="box-header">
<h3 class="box-title">Payment History</h3> <h3 class="box-title">Payment History</h3>
<div class="box-tools pull-right"> <div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse"> <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
<i class="fa fa-minus"></i></button> <i class="fa fa-minus"></i></button>
<button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove"> <button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
<i class="fa fa-times"></i></button> <i class="fa fa-times"></i></button>
</div> </div>
</div> </div>
<div class="box-body"> <div class="box-body">
@if ($user->payment_history->count()) @if ($user->payment_history->count())
<table class="table table-bordered table-striped table-hover" id="payments" style="width: 100%;"> <table class="table table-bordered table-striped table-hover" id="payments" style="width: 100%;">
<thead> <thead>
<tr> <tr>
<th>ID</th>
<th>Date</th> <th>Date</th>
<th>Amount</th> <th>Amount</th>
</tr> </tr>
</thead> </thead>
</table> </table>
@else @else
<p>No payments recorded</p> <p>No payments recorded</p>
@endif @endif
</div> </div>
</div> </div>
@section('page-scripts') @section('page-scripts')
@css('https://cdn.datatables.net/responsive/2.2.1/css/responsive.dataTables.min.css') @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') @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/responsive/2.2.1/js/dataTables.responsive.min.js')
@js('https://cdn.datatables.net/rowgroup/1.0.2/js/dataTables.rowGroup.min.js') @js('https://cdn.datatables.net/rowgroup/1.0.2/js/dataTables.rowGroup.min.js')
<style> <style>
table.dataTable { table.dataTable {
width: 100%; width: 100%;
} }
table.dataTable td { table.dataTable td {
outline: none; outline: none;
} }
</style> </style>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$('#payments').DataTable( { $('#payments').DataTable( {
responsive: true, responsive: true,
ajax: { ajax: {
url: "/api/u/payments" url: "/api/u/payments"
}, },
columns: [ columns: [
{ data: "date_paid" }, { data: "payment_id_url" },
{ data: "total" }, { data: "date_paid" },
], { data: "total" },
language: { ],
emptyTable: "No Payments On File" language: {
}, emptyTable: "No Payments On File"
order: [0, 'desc'] },
}); order: [0, 'desc']
});
$('#payments tbody').on('click','tr', function () { $('#payments tbody').on('click','tr', function () {
$(this).toggleClass('selected'); $(this).toggleClass('selected');
}); });
}); });
</script> </script>
@append @append

View File

@ -1,38 +1,38 @@
<div class="box box-success small"> <div class="box box-success small">
<div class="box-header"> <div class="box-header">
<h3 class="box-title">Services</h3> <h3 class="box-title">Services</h3>
<div class="box-tools pull-right"> <div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse"> <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
<i class="fa fa-minus"></i></button> <i class="fa fa-minus"></i></button>
<button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove"> <button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
<i class="fa fa-times"></i></button> <i class="fa fa-times"></i></button>
</div> </div>
</div> </div>
<div class="box-body"> <div class="box-body">
@if ($user->services_active->count()) @if ($user->services_active->count())
<table class="table table-bordered table-striped table-hover" id="services" style="width: 100%;"> <table class="table table-bordered table-striped table-hover" id="services" style="width: 100%;">
<thead> <thead>
<tr> <tr>
<th>ID</th> <th>ID</th>
<th>Category</th> <th>Category</th>
<th>Service</th> <th>Service</th>
<th>Product</th> <th>Product</th>
<th>Status</th> <th>Status</th>
<th>Next Invoice</th> <th>Next Invoice</th>
</tr> </tr>
</thead> </thead>
<tfoot> <tfoot>
<tr> <tr>
<th>Count {{ $user->services_active->count() }}</th> <th>Count {{ $user->services_active->count() }}</th>
<th colspan="5">&nbsp;</th> <th colspan="5">&nbsp;</th>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>
@else @else
<p>No services active</p> <p>No services active</p>
@endif @endif
</div> </div>
</div> </div>
@section('page-scripts') @section('page-scripts')
@ -47,39 +47,39 @@
} }
</style> </style>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$('#services').DataTable( { $('#services').DataTable( {
rowGroup: { rowGroup: {
dataSrc: 'product_name', dataSrc: 'product_name',
startRender: null, startRender: null,
endRender: function ( rows, group ) { endRender: function ( rows, group ) {
return rows.count()+' x ' + group; return rows.count()+' x ' + group;
}, },
}, },
orderFixed: [3, 'asc'], orderFixed: [3, 'asc'],
responsive: true, responsive: true,
ajax: { ajax: {
url: "/api/u/services" url: "/api/u/services"
}, },
columns: [ columns: [
{ data: "service_id_url" }, { data: "service_id_url" },
{ data: "category" }, { data: "category" },
{ data: "service_name" }, { data: "service_name" },
{ data: "product_name" }, { data: "product_name" },
{ data: "status" }, { data: "status" },
{ data: "next_invoice" } { data: "next_invoice" }
], ],
language: { language: {
emptyTable: "No Active Services" emptyTable: "No Active Services"
}, },
order: [5, 'asc'] order: [5, 'asc']
}); });
$('#services tbody').on('click','tr', function () { $('#services tbody').on('click','tr', function () {
$(this).toggleClass('selected'); $(this).toggleClass('selected');
//var data = table.row(this).data(); //var data = table.row(this).data();
//window.location.href = '/u/service/view/'+data.id; //window.location.href = '/u/service/view/'+data.id;
}); });
}); });
</script> </script>
@append @append

View File

@ -0,0 +1,27 @@
@extends('adminlte::layouts.errors')
@section('htmlheader_title')
{{ trans('adminlte_lang::message.servererror') }}
@endsection
@section('main-content')
<div class="error-page">
<h2 class="headline text-red">307</h2>
<div class="error-content">
<h3><i class="fa fa-warning text-red"></i> Oops! Not updated yet!</h3>
<p>
That data is still on the old site. You'll be redirected in <b>5</b> seconds.<br>
(You might be asked to login again.) <br>
Here: <a href="{{ $exception->getMessage() }}"><b>{{ $exception->getMessage() }}</b></a><br>
Back to <a href="{{ url('home') }}">home</a>
</p>
<br>
</div>
</div><!-- /.error-page -->
<script type="text/javascript">
setTimeout(function () {
window.location.href = '{{ $exception->getMessage() }}';
}, 5000);
</script>
@append

View File

@ -34,3 +34,4 @@ Route::group(['middleware'=>['theme:metronic-fe']], function() {
Route::demoAccess('/uc-access'); Route::demoAccess('/uc-access');
Route::redirect('/under-construction','http://www.graytech.net.au'); Route::redirect('/under-construction','http://www.graytech.net.au');
Route::get('/u/{type}/{action}/{id}','UserHomeController@oldsite');