diff --git a/app/Http/Controllers/OrderController.php b/app/Http/Controllers/OrderController.php index f5f12a1..8c982f0 100644 --- a/app/Http/Controllers/OrderController.php +++ b/app/Http/Controllers/OrderController.php @@ -108,6 +108,7 @@ class OrderController extends Controller $so->ordered_by = Auth::id(); $so->active = FALSE; $so->model = $order ? get_class($order) : NULL; + $so->recur_schedule = $po->price_recur_default; if ($order && $order->order_info) { $so->order_info = $order->order_info; diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php index 09fec5e..0c8d212 100644 --- a/app/Http/Controllers/ProductController.php +++ b/app/Http/Controllers/ProductController.php @@ -28,6 +28,14 @@ class ProductController extends Controller ->sortBy('name') ->values(); + case 'App\Models\Product\Domain': + return Product\Domain::select(['id','supplier_item_id']) + ->with(['supplied.supplier_detail.supplier']) + ->get() + ->map(function($item) { return ['id'=>$item->id,'name'=>sprintf('%s: %s',$item->supplied->supplier_detail->supplier->name,$item->supplied->name)]; }) + ->sortBy('name') + ->values(); + case 'App\Models\Product\Email': return Product\Email::select(['id','supplier_item_id']) ->with(['supplied.supplier_detail.supplier']) diff --git a/app/Http/Controllers/ServiceController.php b/app/Http/Controllers/ServiceController.php index 267d1be..427cd8a 100644 --- a/app/Http/Controllers/ServiceController.php +++ b/app/Http/Controllers/ServiceController.php @@ -415,10 +415,12 @@ class ServiceController extends Controller $o->type->save(); - // @todo create a validator for service if ($request->post('invoice_next_at')) $o->invoice_next_at = $request->invoice_next_at; + if ($request->post('recur_schedule')) + $o->recur_schedule = $request->recur_schedule; + // Also update our service start_at date. // @todo We may want to make start_at/stop_at dynamic values calculated by the type records if ($request->post('start_at')) diff --git a/app/Http/Requests/ProductAddEdit.php b/app/Http/Requests/ProductAddEdit.php index ea49d93..71c6996 100644 --- a/app/Http/Requests/ProductAddEdit.php +++ b/app/Http/Requests/ProductAddEdit.php @@ -32,7 +32,7 @@ class ProductAddEdit extends FormRequest 'active' => 'sometimes|accepted', 'model' => 'sometimes|string', // @todo Check that it is a valid model type 'model_id' => 'sometimes|int', // @todo Check that it is a valid model type - 'accounting' => 'sometimes|string', + 'accounting' => 'nullable|string', ]; } } \ No newline at end of file diff --git a/app/Models/Product/Domain.php b/app/Models/Product/Domain.php index c66c86d..941ec68 100644 --- a/app/Models/Product/Domain.php +++ b/app/Models/Product/Domain.php @@ -12,6 +12,22 @@ final class Domain extends Type implements ProductItem { protected $table = 'product_domain'; + // Information required during the order process + protected array $order_attributes = [ + 'options.domain'=>[ + 'request'=>'options.domain', + 'key'=>'domain_name', + 'validation'=>'required|min:3', + 'validation_message'=>'Domain Name is a required field.', + ], + 'options.tld_id'=>[ + 'request'=>'options.tld_id', + 'key'=>'tld_id', + 'validation'=>'required|exists:tlds,id', + 'validation_message'=>'Domain TLD is a required field.', + ], + ]; + // The model that is referenced when this product is ordered protected string $order_model = ServiceDomain::class; diff --git a/app/Models/Service.php b/app/Models/Service.php index 184c461..58991be 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -800,7 +800,7 @@ class Service extends Model implements IDs */ public function getNameDetailAttribute() { - return ($this->type && $this->type->getServiceDescriptionAttribute()) ? $this->type->getServiceDescriptionAttribute() : 'No Description'; + return ($this->type && ($this->type->getServiceDescriptionAttribute() !== NULL)) ? $this->type->getServiceDescriptionAttribute() : 'No Description'; } /** diff --git a/app/Models/Service/Domain.php b/app/Models/Service/Domain.php index 7523408..83c57a8 100644 --- a/app/Models/Service/Domain.php +++ b/app/Models/Service/Domain.php @@ -28,11 +28,14 @@ class Domain extends Type return [ 'domain_name' => 'nullable|string|min:2', 'tld_id' => 'required|exists:tlds,id', - 'expire_at' => 'required|date', 'domain_registrar_id' => 'required|exists:domain_registrars,id', 'registrar_account' => 'nullable|string', 'registrar_ns' => 'nullable|string', 'registrar_username' => 'nullable|string', + 'connect_at' => 'nullable|date', + 'start_at' => 'nullable|date', + 'expire_at' => 'nullable|date|after:start_at', + 'recur_schedule' => 'nullable|int', // @todo insure value is at least 1 yr and not higher than Invoice::billing_periods ]; } diff --git a/database/migrations/2022_10_18_131249_domain_registrar_id_optional.php b/database/migrations/2022_10_18_131249_domain_registrar_id_optional.php new file mode 100644 index 0000000..c19ae92 --- /dev/null +++ b/database/migrations/2022_10_18_131249_domain_registrar_id_optional.php @@ -0,0 +1,28 @@ +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 }} - + @if($o->registrar) + + Registrar URL + {{ $o->registrar->whitelabel_url }} + + + Registrar Username + {{ $o->registrar_username }} + + + Registrar Password + {{ $o->registrar_password }} + + + Domain Auth + {{ $o->registrar_auth_password }} + + @endif @if($o->service_connect_date) Connected @@ -41,10 +43,12 @@ @endif - - Expires - {{ $o->expire_at->format('Y-m-d') }} ({{ $o->expire_at->diffInMonths() }} months) - + @if ($o->active) + + Expires + {{ $o->expire_at->format('Y-m-d') }} ({{ $o->expire_at->diffInMonths() }} months) + + @endif \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/service/widget/domain/update.blade.php b/resources/views/theme/backend/adminlte/service/widget/domain/update.blade.php index ccb0cd1..b1cce4a 100644 --- a/resources/views/theme/backend/adminlte/service/widget/domain/update.blade.php +++ b/resources/views/theme/backend/adminlte/service/widget/domain/update.blade.php @@ -95,6 +95,43 @@ +
+

Service Dates

+ +
+
+ @include('adminlte::widget.form_date',[ + 'label'=>'Registered Date', + 'id'=>'connect_at', + 'old'=>'phone.connect_at', + 'name'=>'phone[connect_at]', + 'value'=>$o->connect_at ? $o->connect_at->format('Y-m-d') : '', + ]) +
+ +
+ @include('adminlte::widget.form_date',[ + 'label'=>'Billing Start Date', + 'id'=>'invoice_next_at', + 'old'=>'invoice_next_at', + 'name'=>'invoice_next_at', + 'value'=>$o->service->invoice_next_at ? $o->service->invoice_next_at->format('Y-m-d') : ($o->connect_at ? $o->connect_at->format('Y-m-d') : ''), + ]) +
+ +
+ @include('adminlte::widget.form_select',[ + 'label'=>'Renew Term', + 'icon'=>'fas fa-calendar', + 'id'=>'recur_schedule', + 'old'=>'recur_schedule', + 'name'=>'recur_schedule', + 'options'=>collect(\App\Models\Invoice::billing_periods)->filter(function ($item) { return $item['interval'] >= 12; })->transform(function($item,$key) { return ['id'=>$key,'value'=>$item['name']]; }), + 'value'=>$o->service->recur_schedule ?? '', + ]) +
+
+ @section('page-scripts') @css(select2) @js(select2,autofocus) diff --git a/resources/views/theme/backend/adminlte/service/widget/information.blade.php b/resources/views/theme/backend/adminlte/service/widget/information.blade.php index 798cb48..79d913d 100644 --- a/resources/views/theme/backend/adminlte/service/widget/information.blade.php +++ b/resources/views/theme/backend/adminlte/service/widget/information.blade.php @@ -43,7 +43,7 @@ @if (($o->active OR $o->isPending()) AND ! $o->external_billing) Billed - {{ $o->billing_period }} + {{ $o->billing_interval_string }} @if($o->active AND $o->invoice_to) diff --git a/resources/views/theme/frontend/metronic/order/widget/order/domain.blade.php b/resources/views/theme/frontend/metronic/order/widget/order/domain.blade.php new file mode 100644 index 0000000..16a03f4 --- /dev/null +++ b/resources/views/theme/frontend/metronic/order/widget/order/domain.blade.php @@ -0,0 +1,19 @@ +
+ + +
+ + + {{ $errors->first('options.domain') }} +
+ +
+ + + {{ $errors->first('options.tld') }} +
+
\ No newline at end of file