diff --git a/app/Interfaces/ServiceItem.php b/app/Interfaces/ServiceItem.php index d15897a..1de5743 100644 --- a/app/Interfaces/ServiceItem.php +++ b/app/Interfaces/ServiceItem.php @@ -17,4 +17,11 @@ interface ServiceItem * @return string */ public function getServiceNameAttribute():string; + + /** + * Is this service in a contract + * + * @return bool + */ + public function inContract(): bool; } \ No newline at end of file diff --git a/app/Models/Base/ServiceType.php b/app/Models/Base/ServiceType.php index e5a998c..2d6310f 100644 --- a/app/Models/Base/ServiceType.php +++ b/app/Models/Base/ServiceType.php @@ -17,7 +17,7 @@ abstract class ServiceType extends Model */ public function service() { - return $this->morphOne(Service::class,'type','model','id'); + return $this->morphOne(Service::class,'type','model','id','service_id'); } /** SCOPES */ diff --git a/app/Models/Product/Domain.php b/app/Models/Product/Domain.php index 8f432ef..7e20afe 100644 --- a/app/Models/Product/Domain.php +++ b/app/Models/Product/Domain.php @@ -2,11 +2,32 @@ namespace App\Models\Product; +use Illuminate\Support\Collection; + +use App\Interfaces\ProductSupplier; +use App\Models\Base\ProductType; use App\Traits\NextKey; -class Domain extends \App\Models\Base\ProductType +class Domain extends ProductType implements ProductSupplier { use NextKey; - const RECORD_ID = ''; + + public function allowance(): Collection + { + // N/A + return collect(); + } + + public function allowance_string(): string + { + // N/A + return ''; + } + + public function getCostAttribute(): float + { + // N/A + return 0; + } } \ No newline at end of file diff --git a/app/Models/Service/Adsl.php b/app/Models/Service/Adsl.php index f0b9118..eef377e 100644 --- a/app/Models/Service/Adsl.php +++ b/app/Models/Service/Adsl.php @@ -15,22 +15,11 @@ class Adsl extends ServiceType implements ServiceItem use NextKey; const RECORD_ID = 'service__adsl'; - // @todo column service_id can be removed. - protected $table = 'ab_service__adsl'; protected $dates = [ 'service_connect_date', 'service_contract_date' ]; - - /** - * The service this belongs to - * - * @return BelongsTo|MorphOne - */ - public function service() - { - return $this->belongsTo(Service::class); - } + protected $table = 'ab_service__adsl'; /** SCOPES */ diff --git a/app/Models/Service/Domain.php b/app/Models/Service/Domain.php index cbb5ac9..1d977da 100644 --- a/app/Models/Service/Domain.php +++ b/app/Models/Service/Domain.php @@ -2,23 +2,46 @@ namespace App\Models\Service; +use App\Models\Base\ServiceType; +use App\Models\DomainRegistrar; +use App\Models\DomainTld; +use App\Interfaces\ServiceItem; use App\Traits\NextKey; -class Domain extends \App\Models\Base\ServiceType +class Domain extends ServiceType implements ServiceItem { use NextKey; const RECORD_ID = 'service__domain'; + protected $dates = [ + 'domain_expire', + ]; protected $table = 'ab_service__domain'; protected $with = ['tld']; - public function tld() + public function registrar() { - return $this->belongsTo(\App\Models\DomainTld::class,'domain_tld_id'); + return $this->belongsTo(DomainRegistrar::class,'domain_registrar_id'); } - public function getNameAttribute() + public function tld() { - return sprintf('%s.%s',$this->domain_name,$this->tld->name); + return $this->belongsTo(DomainTld::class,'domain_tld_id'); + } + + public function getServiceDescriptionAttribute(): string + { + // N/A + return ''; + } + + public function getServiceNameAttribute(): string + { + return sprintf('%s.%s',strtoupper($this->domain_name),strtoupper($this->tld->name)); + } + + public function inContract(): bool + { + return $this->domain_expire->isFuture(); } } \ No newline at end of file diff --git a/app/Models/Service/Voip.php b/app/Models/Service/Voip.php index 4dd7e6d..72e0ca9 100644 --- a/app/Models/Service/Voip.php +++ b/app/Models/Service/Voip.php @@ -11,6 +11,10 @@ class Voip extends ServiceType implements ServiceItem use NextKey; const RECORD_ID = 'service__adsl'; + protected $dates = [ + 'service_connect_date', + 'service_contract_date', + ]; protected $table = 'ab_service__voip'; /** @@ -32,4 +36,9 @@ class Voip extends ServiceType implements ServiceItem { return $this->service_number; } + + public function inContract(): bool + { + return $this->service_contract_date AND $this->service_contract_date->addMonths($this->contract_term)->isFuture(); + } } \ No newline at end of file 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 6120612..bf2e5c3 100644 --- a/resources/theme/backend/adminlte/a/service/widget/internal.blade.php +++ b/resources/theme/backend/adminlte/a/service/widget/internal.blade.php @@ -1,28 +1,32 @@ - + - + + @if($o->product->type) + + + + + + + + + + + + + + + @endif - - - - - - - - - - - - - - - - - - + + @if($o->product->type) + + + + @endif
Supplier{{ $o->product->type->supplier->name }}Supplier{{ $o->product->type ? $o->product->type->supplier->name : 'Supplier Unknown' }}
Supplier Product#{{ $o->product_id }}: {{ $o->product->type->product->product_id }}Supplier Product#{{ $o->product_id }}: {{ $o->product->type ? $o->product->type->product->product_id : 'Product Unknown' }}
Supplier Setup${{ number_format($o->product->type->product->setup_cost*1.1,2) }}
Supplier Cost${{ number_format($o->product->type->cost,2) }}
Supplier Contract{{ $o->product->type->product->contract_term }} months
Supplier Min Cost${{ number_format((($x=$o->product->type->product)->setup_cost+$x->base_cost*$x->contract_term)*1.1,2) }}
Supplier Setup${{ number_format($o->product->type->product->setup_cost*1.1,2) }}
Supplier Cost${{ number_format($o->product->type->cost,2) }}
Supplier Contract{{ $o->product->type->product->contract_term }} months
Supplier Min Cost${{ number_format((($x=$o->product->type->product)->setup_cost+$x->base_cost*$x->contract_term)*1.1,2) }}
Price${{ number_format($o->billing_monthly_price,2) }}
Markup{{ number_format(($o->billing_monthly_price/$o->product->type->cost-1)*100,2) }}%Price${{ number_format($o->billing_monthly_price,2) }} (${{ number_format($o->billing_monthly_price*12,2) }} Annually)
Markup{{ number_format(($o->billing_monthly_price/$o->product->type->cost-1)*100,2) }}%
\ No newline at end of file diff --git a/resources/theme/backend/adminlte/u/service/widgets/domain/details.blade.php b/resources/theme/backend/adminlte/u/service/widgets/domain/details.blade.php new file mode 100644 index 0000000..7c8b819 --- /dev/null +++ b/resources/theme/backend/adminlte/u/service/widgets/domain/details.blade.php @@ -0,0 +1,59 @@ +
+ @if($o->service->isPending()) +
+
+ Pending +
+
+ @endif + +
+

Domain Details

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + @if($o->service_connect_date) + + + + + @endif + @if ($o->inContract()) + + + + + + + + + + @endif + + + + +
Domain Name{{ $o->service_name }}
Registrar URL{{ $o->registrar->whitelabel_url }}
Registrar Username{{ $o->registrar_username }}
Registrar Password{{ $o->registrar_password }}
Domain Auth{{ $o->registrar_auth_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/voip/details.blade.php b/resources/theme/backend/adminlte/u/service/widgets/voip/details.blade.php new file mode 100644 index 0000000..41adf57 --- /dev/null +++ b/resources/theme/backend/adminlte/u/service/widgets/voip/details.blade.php @@ -0,0 +1,68 @@ +
+ @if($o->service->isPending()) +
+
+ Pending +
+
+ @endif + +
+

VOIP Details

+
+ +
+ + + + + + + + + + + + + + + + + + @if($o->service_connect_date) + + + + + @endif + + @if($o->technology) + + + + + @endif + + @if($o->service->product->type) + + + + + @endif + @if ($o->inContract()) + + + + + + + + + @endif + + + + +
Address{{ $o->service_description }}
Service Number{{ $o->service_name }}
Service Username{{ $o->service_username }}
Service Password{{ $o->service_password }}
Connected{{ $o->service_connect_date->format('Y-m-d') }}
Technology{{ $o->technology }}
Traffic{{ $o->service->product->type->allowance_string() }} GB @if(FALSE)(YY GB used month)@endif
Contract{{ $o->contract_term }} months ({{ ($x=$o->service_contract_date->addMonths($o->contract_term))->diffForHumans() }})
Contract End{{ $x->format('Y-m-d') }}
Cancel Notice1 month @if($o->inContract())(after {{ $o->service_contract_date->addMonths($o->contract_term-1)->format('Y-m-d') }})@endif
+
+
\ No newline at end of file