Work on SSL and Host accounts
This commit is contained in:
parent
8311bfc268
commit
9ab30086fc
@ -24,6 +24,7 @@ class SSL
|
||||
switch($key)
|
||||
{
|
||||
case 'cn': return $this->cn();
|
||||
case 'dn': return $this->dn();
|
||||
default:
|
||||
throw new \App\Exceptions\SSLUnknownAttribute($key);
|
||||
}
|
||||
@ -67,6 +68,29 @@ class SSL
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function dn()
|
||||
{
|
||||
$dn = '';
|
||||
|
||||
if ($this->crt_pem) {
|
||||
$this->crt = openssl_x509_parse($this->crt_pem);
|
||||
$dn = Arr::get($this->crt,'name');
|
||||
}
|
||||
|
||||
if (! $dn AND $this->csr_pem) {
|
||||
$dna = openssl_csr_get_subject($this->csr_pem);
|
||||
|
||||
foreach ($dna as $k=>$v) {
|
||||
if ($dn)
|
||||
$dn .= ',';
|
||||
|
||||
$dn .= sprintf('%s=%s',$k,$v);
|
||||
}
|
||||
}
|
||||
|
||||
return $dn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the Key
|
||||
*
|
||||
|
@ -25,4 +25,14 @@ interface ProductSupplier {
|
||||
* @return float
|
||||
*/
|
||||
public function getCostAttribute(): float;
|
||||
|
||||
/**
|
||||
* Return the supplier class
|
||||
* If there is a model relationship return:
|
||||
* return $this->getRelationValue('supplier');
|
||||
* otherwise return a stdClass with name
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSupplierAttribute();
|
||||
}
|
10
app/Models/DomainRegistrar.php
Normal file
10
app/Models/DomainRegistrar.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DomainRegistrar extends Model
|
||||
{
|
||||
protected $table = 'ab_domain_registrar';
|
||||
}
|
10
app/Models/HostServer.php
Normal file
10
app/Models/HostServer.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class HostServer extends Model
|
||||
{
|
||||
protected $table = 'ab_host_server';
|
||||
}
|
@ -151,4 +151,9 @@ class Adsl extends ProductType implements ProductSupplier
|
||||
// @todo Tax shouldnt be hard coded
|
||||
return ($this->product->base_cost+$this->allowance_cost())*1.1;
|
||||
}
|
||||
|
||||
public function getSupplierAttribute()
|
||||
{
|
||||
return $this->getRelationValue('supplier');
|
||||
}
|
||||
}
|
@ -30,4 +30,9 @@ class Domain extends ProductType implements ProductSupplier
|
||||
// N/A
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getSupplierAttribute()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Models\Product;
|
||||
|
||||
use App\Models\Base\ProductType;
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class Host extends \App\Models\Base\ProductType
|
||||
class Host extends ProductType
|
||||
{
|
||||
use NextKey;
|
||||
|
||||
const RECORD_ID = '';
|
||||
}
|
@ -32,4 +32,23 @@ class SSL extends ProductType implements ProductSupplier
|
||||
// N/A
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getProductAttribute()
|
||||
{
|
||||
$o = new \stdClass();
|
||||
$o->product_id = 'INT';
|
||||
$o->setup_cost = 0;
|
||||
$o->base_cost = 0;
|
||||
$o->contract_term = 0; // @todo
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
public function getSupplierAttribute()
|
||||
{
|
||||
$o = new \stdClass();
|
||||
$o->name = 'Internal';
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Models\Product;
|
||||
|
||||
use App\Models\Base\ProductType;
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class Voip extends \App\Models\Base\ProductType
|
||||
class Voip extends ProductType
|
||||
{
|
||||
use NextKey;
|
||||
|
||||
const RECORD_ID = '';
|
||||
}
|
@ -819,7 +819,7 @@ class Service extends Model
|
||||
}
|
||||
|
||||
// If the service is active, there will be service charges
|
||||
if ((! $this->invoice_items->filter(function($item) { return $item->item_type==0 AND ! $item->exists; })->sum('total'))
|
||||
if ((! $this->invoice_items->filter(function($item) { return $item->item_type==0 AND ! $item->exists; })->count())
|
||||
AND ($this->active OR $this->isPending()))
|
||||
{
|
||||
do {
|
||||
|
@ -32,7 +32,7 @@ class Domain extends ServiceType implements ServiceItem
|
||||
public function getServiceDescriptionAttribute(): string
|
||||
{
|
||||
// N/A
|
||||
return '';
|
||||
return 'Domain Name';
|
||||
}
|
||||
|
||||
public function getServiceNameAttribute(): string
|
||||
|
@ -2,17 +2,45 @@
|
||||
|
||||
namespace App\Models\Service;
|
||||
|
||||
use App\Interfaces\ServiceItem;
|
||||
use App\Models\Base\ServiceType;
|
||||
use App\Models\DomainTld;
|
||||
use App\Models\HostServer;
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class Host extends \App\Models\Base\ServiceType
|
||||
class Host extends ServiceType implements ServiceItem
|
||||
{
|
||||
use NextKey;
|
||||
const RECORD_ID = 'service__hosting';
|
||||
|
||||
protected $dates = [
|
||||
'host_expire',
|
||||
];
|
||||
protected $table = 'ab_service__hosting';
|
||||
|
||||
public function getNameAttribute()
|
||||
public function provider()
|
||||
{
|
||||
return sprintf('%s',$this->domain_name);
|
||||
return $this->belongsTo(HostServer::class,'host_server_id');
|
||||
}
|
||||
|
||||
public function tld()
|
||||
{
|
||||
return $this->belongsTo(DomainTld::class,'domain_tld_id');
|
||||
}
|
||||
|
||||
public function getServiceDescriptionAttribute(): string
|
||||
{
|
||||
// N/A
|
||||
return 'Hosting';
|
||||
}
|
||||
|
||||
public function getServiceNameAttribute(): string
|
||||
{
|
||||
return sprintf('%s.%s',strtoupper($this->domain_name),strtoupper($this->tld->name));
|
||||
}
|
||||
|
||||
public function inContract(): bool
|
||||
{
|
||||
return $this->host_expire->isFuture();
|
||||
}
|
||||
}
|
@ -2,9 +2,11 @@
|
||||
|
||||
namespace App\Models\Service;
|
||||
|
||||
use App\Interfaces\ServiceItem;
|
||||
use App\Models\Base\ServiceType;
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class SSL extends \App\Models\Base\ServiceType
|
||||
class SSL extends ServiceType implements ServiceItem
|
||||
{
|
||||
use NextKey;
|
||||
const RECORD_ID = 'service__ssl';
|
||||
@ -13,15 +15,9 @@ class SSL extends \App\Models\Base\ServiceType
|
||||
|
||||
protected $_o = NULL;
|
||||
|
||||
public function tld()
|
||||
{
|
||||
return $this->belongsTo(DomainTld::class,'domain_tld_id');
|
||||
}
|
||||
|
||||
public function getSSLAttribute()
|
||||
{
|
||||
if (is_null($this->_o))
|
||||
{
|
||||
if (is_null($this->_o)) {
|
||||
$this->_o = new \App\Classes\SSL;
|
||||
|
||||
if ($this->cert)
|
||||
@ -30,14 +26,24 @@ class SSL extends \App\Models\Base\ServiceType
|
||||
$this->_o->csr($this->csr);
|
||||
if ($this->pk)
|
||||
$this->_o->key($this->pk);
|
||||
|
||||
}
|
||||
|
||||
return $this->_o;
|
||||
}
|
||||
|
||||
public function getNameAttribute()
|
||||
public function getServiceDescriptionAttribute(): string
|
||||
{
|
||||
return $this->ssl->dn;
|
||||
}
|
||||
|
||||
public function getServiceNameAttribute(): string
|
||||
{
|
||||
return $this->ssl->cn;
|
||||
}
|
||||
|
||||
public function inContract(): bool
|
||||
{
|
||||
// N/A
|
||||
return FALSE;
|
||||
}
|
||||
}
|
@ -6,9 +6,14 @@ use Leenooks\Carbon as Carbon;
|
||||
$factory->define(App\Models\InvoiceItem::class, function (Faker $faker) {
|
||||
return [
|
||||
'id'=>1,
|
||||
'price_base'=>100,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->afterMaking(App\Models\InvoiceItem::class, function ($item,$faker) {
|
||||
$item->exists = TRUE;
|
||||
});
|
||||
|
||||
// Weekly
|
||||
$factory->state(App\Models\InvoiceItem::class,'week',[
|
||||
'date_start'=>Carbon::now()->startOfWeek(),
|
||||
|
@ -24,7 +24,7 @@
|
||||
<tr>
|
||||
<th>Price</th><td>${{ number_format($o->billing_monthly_price,2) }} <small>(${{ number_format($o->billing_monthly_price*12,2) }} Annually)</small></td>
|
||||
</tr>
|
||||
@if($o->product->type)
|
||||
@if($o->product->type AND $o->product->type->cost)
|
||||
<tr>
|
||||
<th>Markup</th><td>{{ number_format(($o->billing_monthly_price/$o->product->type->cost-1)*100,2) }}%</td>
|
||||
</tr>
|
||||
|
@ -0,0 +1,57 @@
|
||||
<div class="card">
|
||||
@if($o->service->isPending())
|
||||
<div class="ribbon-wrapper ribbon-lg">
|
||||
<div class="ribbon bg-warning">
|
||||
Pending
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="card-header bg-gray-dark">
|
||||
<h3 class="card-title">Hosting Details</h3>
|
||||
</div>
|
||||
|
||||
<div class="card-body bg-gray-dark">
|
||||
<table class="table table-sm">
|
||||
<tr>
|
||||
<th>Domain Name</th>
|
||||
<td>{{ $o->service_name }}</td>
|
||||
</tr>
|
||||
@if($o->provider->whitelabel_url)
|
||||
<tr>
|
||||
<th>Hosting URL</th>
|
||||
<td><a href="{{ $o->provider->whitelabel_url }}" target="_blank" class="text-white">{{ $o->provider->whitelabel_url }}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Hosting Username</th>
|
||||
<td>{{ $o->host_username }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Hosting Password</th>
|
||||
<td>{{ $o->host_password }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
@if($o->service_connect_date)
|
||||
<tr>
|
||||
<th>Connected</th>
|
||||
<td>{{ $o->service_connect_date->format('Y-m-d') }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
@if ($o->inContract())
|
||||
<tr>
|
||||
<th>Contract</th>
|
||||
<!-- @todo -->
|
||||
<td>12 months <small>({{ ($x=$o->domain_expire)->diffForHumans() }})</small></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Contract End</th>
|
||||
<td>{{ $x->format('Y-m-d') }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
<tr>
|
||||
<th>Cancel Notice</th>
|
||||
<td>Before renewal</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,26 @@
|
||||
<div class="card">
|
||||
@if($o->service->isPending())
|
||||
<div class="ribbon-wrapper ribbon-lg">
|
||||
<div class="ribbon bg-warning">
|
||||
Pending
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="card-header bg-gray-dark">
|
||||
<h3 class="card-title">SSL Details</h3>
|
||||
</div>
|
||||
|
||||
<div class="card-body bg-gray-dark">
|
||||
<table class="table table-sm">
|
||||
<tr>
|
||||
<th>Cert</th>
|
||||
<td>{{ $o->service_description }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Cancel Notice</th>
|
||||
<td>Before renewal</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user