diff --git a/app/Classes/SSL.php b/app/Classes/SSL.php index 96790a9..9cec4e3 100644 --- a/app/Classes/SSL.php +++ b/app/Classes/SSL.php @@ -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 * diff --git a/app/Interfaces/ProductSupplier.php b/app/Interfaces/ProductSupplier.php index 63e94fe..259f52c 100644 --- a/app/Interfaces/ProductSupplier.php +++ b/app/Interfaces/ProductSupplier.php @@ -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(); } \ No newline at end of file diff --git a/app/Models/DomainRegistrar.php b/app/Models/DomainRegistrar.php new file mode 100644 index 0000000..69a61ed --- /dev/null +++ b/app/Models/DomainRegistrar.php @@ -0,0 +1,10 @@ +product->base_cost+$this->allowance_cost())*1.1; } + + public function getSupplierAttribute() + { + return $this->getRelationValue('supplier'); + } } \ No newline at end of file diff --git a/app/Models/Product/Domain.php b/app/Models/Product/Domain.php index 7e20afe..d0b0ec8 100644 --- a/app/Models/Product/Domain.php +++ b/app/Models/Product/Domain.php @@ -30,4 +30,9 @@ class Domain extends ProductType implements ProductSupplier // N/A return 0; } + + public function getSupplierAttribute() + { + return ''; + } } \ No newline at end of file diff --git a/app/Models/Product/Host.php b/app/Models/Product/Host.php index 347908e..cdd961a 100644 --- a/app/Models/Product/Host.php +++ b/app/Models/Product/Host.php @@ -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 = ''; } \ No newline at end of file diff --git a/app/Models/Product/SSL.php b/app/Models/Product/SSL.php index 4bc36b5..874e980 100644 --- a/app/Models/Product/SSL.php +++ b/app/Models/Product/SSL.php @@ -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; + } } \ No newline at end of file diff --git a/app/Models/Product/Voip.php b/app/Models/Product/Voip.php index d486a64..f500361 100644 --- a/app/Models/Product/Voip.php +++ b/app/Models/Product/Voip.php @@ -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 = ''; } \ No newline at end of file diff --git a/app/Models/Service.php b/app/Models/Service.php index 1c56637..315038c 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -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 { diff --git a/app/Models/Service/Domain.php b/app/Models/Service/Domain.php index 1d977da..abf483a 100644 --- a/app/Models/Service/Domain.php +++ b/app/Models/Service/Domain.php @@ -32,7 +32,7 @@ class Domain extends ServiceType implements ServiceItem public function getServiceDescriptionAttribute(): string { // N/A - return ''; + return 'Domain Name'; } public function getServiceNameAttribute(): string diff --git a/app/Models/Service/Host.php b/app/Models/Service/Host.php index 4426b43..59b7630 100644 --- a/app/Models/Service/Host.php +++ b/app/Models/Service/Host.php @@ -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(); } } \ No newline at end of file diff --git a/app/Models/Service/SSL.php b/app/Models/Service/SSL.php index cbebb06..8f4b10e 100644 --- a/app/Models/Service/SSL.php +++ b/app/Models/Service/SSL.php @@ -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; + } } \ No newline at end of file diff --git a/database/factories/InvoiceItemFactory.php b/database/factories/InvoiceItemFactory.php index f67296f..f91cb4e 100644 --- a/database/factories/InvoiceItemFactory.php +++ b/database/factories/InvoiceItemFactory.php @@ -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(), diff --git a/resources/theme/backend/adminlte/a/service/widget/internal.blade.php b/resources/theme/backend/adminlte/a/service/widget/internal.blade.php index bf2e5c3..1be797d 100644 --- a/resources/theme/backend/adminlte/a/service/widget/internal.blade.php +++ b/resources/theme/backend/adminlte/a/service/widget/internal.blade.php @@ -24,7 +24,7 @@ Price${{ number_format($o->billing_monthly_price,2) }} (${{ number_format($o->billing_monthly_price*12,2) }} Annually) - @if($o->product->type) + @if($o->product->type AND $o->product->type->cost) Markup{{ number_format(($o->billing_monthly_price/$o->product->type->cost-1)*100,2) }}% diff --git a/resources/theme/backend/adminlte/u/service/widgets/host/details.blade.php b/resources/theme/backend/adminlte/u/service/widgets/host/details.blade.php new file mode 100644 index 0000000..dffc119 --- /dev/null +++ b/resources/theme/backend/adminlte/u/service/widgets/host/details.blade.php @@ -0,0 +1,57 @@ +
+ @if($o->service->isPending()) +
+
+ Pending +
+
+ @endif + +
+

Hosting Details

+
+ +
+ + + + + + @if($o->provider->whitelabel_url) + + + + + + + + + + + + + @endif + @if($o->service_connect_date) + + + + + @endif + @if ($o->inContract()) + + + + + + + + + + @endif + + + + +
Domain Name{{ $o->service_name }}
Hosting URL{{ $o->provider->whitelabel_url }}
Hosting Username{{ $o->host_username }}
Hosting Password{{ $o->host_password }}
Connected{{ $o->service_connect_date->format('Y-m-d') }}
Contract12 months ({{ ($x=$o->domain_expire)->diffForHumans() }})
Contract End{{ $x->format('Y-m-d') }}
Cancel NoticeBefore renewal
+
+
\ No newline at end of file diff --git a/resources/theme/backend/adminlte/u/service/widgets/ssl/details.blade.php b/resources/theme/backend/adminlte/u/service/widgets/ssl/details.blade.php new file mode 100644 index 0000000..756078e --- /dev/null +++ b/resources/theme/backend/adminlte/u/service/widgets/ssl/details.blade.php @@ -0,0 +1,26 @@ +
+ @if($o->service->isPending()) +
+
+ Pending +
+
+ @endif + +
+

SSL Details

+
+ +
+ + + + + + + + + +
Cert{{ $o->service_description }}
Cancel NoticeBefore renewal
+
+
\ No newline at end of file