From d833450b139a474eabab4ef9099a0139b3836349 Mon Sep 17 00:00:00 2001 From: OniiCoder Date: Mon, 5 Feb 2024 09:58:01 +0000 Subject: [PATCH] Some fixes --- ..._create_pamtechoga_organizations_table.php | 3 + ...000004_create_pamtechoga_drivers_table.php | 1 + ..._000006_create_pamtechoga_depots_table.php | 1 + .../views/models/branches/index.blade.php | 42 +++++----- .../views/models/dashboard/index.blade.php | 8 +- .../views/models/depot-orders/form.blade.php | 14 +++- .../views/models/depot-orders/index.blade.php | 76 ++----------------- .../views/models/depot-pickups/form.blade.php | 24 +++--- .../models/depot-pickups/index.blade.php | 7 +- resources/views/models/drivers/form.blade.php | 6 ++ .../views/models/drivers/index.blade.php | 2 +- resources/views/models/orders/form.blade.php | 17 ++++- resources/views/models/orders/index.blade.php | 7 +- .../views/models/organizations/form.blade.php | 30 +++++++- resources/views/models/sales/index.blade.php | 8 +- src/Http/Livewire/DepotOrdersForm.php | 1 + src/Http/Livewire/DepotOrdersIndex.php | 2 +- src/Http/Livewire/DepotPickupsForm.php | 2 +- src/Http/Livewire/DepotPickupsIndex.php | 2 +- src/Http/Livewire/DriversForm.php | 1 + src/Http/Livewire/DriversIndex.php | 2 +- src/Http/Livewire/OrdersForm.php | 3 +- src/Http/Livewire/OrdersIndex.php | 2 +- src/Http/Livewire/OrganizationsForm.php | 32 ++++++++ ...anizationLoginInstructionsNotification.php | 1 + src/Services/DateFilters.php | 8 +- src/Traits/DateFilter.php | 14 +++- 27 files changed, 182 insertions(+), 134 deletions(-) diff --git a/database/migrations/2023_05_17_000000_create_pamtechoga_organizations_table.php b/database/migrations/2023_05_17_000000_create_pamtechoga_organizations_table.php index 06d329b..5b2d491 100644 --- a/database/migrations/2023_05_17_000000_create_pamtechoga_organizations_table.php +++ b/database/migrations/2023_05_17_000000_create_pamtechoga_organizations_table.php @@ -19,6 +19,9 @@ public function up() $table->string('slug'); $table->string('phone'); $table->string('email'); + $table->string('contact_person_name')->nullable(); + $table->string('contact_person_phone')->nullable(); + $table->dateTime('contact_person_dob')->nullable(); $table->json('meta')->nullable(); $table->dateTime('created_at')->nullable(); $table->dateTime('updated_at')->nullable(); diff --git a/database/migrations/2023_05_17_000004_create_pamtechoga_drivers_table.php b/database/migrations/2023_05_17_000004_create_pamtechoga_drivers_table.php index 410be23..4429c15 100644 --- a/database/migrations/2023_05_17_000004_create_pamtechoga_drivers_table.php +++ b/database/migrations/2023_05_17_000004_create_pamtechoga_drivers_table.php @@ -16,6 +16,7 @@ public function up() Schema::create('pamtechoga_drivers', function (Blueprint $table) { $table->increments('id'); $table->string('name'); + $table->string('nickname')->nullable(); $table->string('phone'); $table->string('email')->nullable(); $table->string('address'); diff --git a/database/migrations/2023_05_17_000006_create_pamtechoga_depots_table.php b/database/migrations/2023_05_17_000006_create_pamtechoga_depots_table.php index f386532..03443ae 100644 --- a/database/migrations/2023_05_17_000006_create_pamtechoga_depots_table.php +++ b/database/migrations/2023_05_17_000006_create_pamtechoga_depots_table.php @@ -18,6 +18,7 @@ public function up() $table->string('name'); $table->text('address'); $table->json('meta')->nullable(); + $table->dateTime('order_date')->nullable(); $table->dateTime('created_at')->nullable(); $table->dateTime('updated_at')->nullable(); }); diff --git a/resources/views/models/branches/index.blade.php b/resources/views/models/branches/index.blade.php index 86c1e00..9c06b33 100644 --- a/resources/views/models/branches/index.blade.php +++ b/resources/views/models/branches/index.blade.php @@ -40,30 +40,32 @@ @foreach($models as $branch) - - @if($this->shouldShowColumn('address')) - - {{ $branch->address }} - - @endisset + @if($branch->organization) + + @if($this->shouldShowColumn('address')) + + {{ $branch->address }} + + @endisset - @if($this->shouldShowColumn('organization')) - - {{ $branch->organization->name }} - - @endif + @if($this->shouldShowColumn('organization')) + + {{ $branch->organization->name }} + + @endif - @if($this->shouldShowColumn('updated_at')) - - {{ $branch->updated_at->toFormattedDateString() }} - - @endisset + @if($this->shouldShowColumn('updated_at')) + + {{ $branch->updated_at->toFormattedDateString() }} + + @endisset - - Edit - - + + Edit + + + @endif @endforeach diff --git a/resources/views/models/dashboard/index.blade.php b/resources/views/models/dashboard/index.blade.php index b51b037..4adaaee 100644 --- a/resources/views/models/dashboard/index.blade.php +++ b/resources/views/models/dashboard/index.blade.php @@ -55,26 +55,26 @@ {{-- $totalPMSDepotOrdersVolume = DepotOrder::join('pamtechoga_products','pamtechoga_products.id', '=', 'pamtechoga_depot_orders.product_id')--}} {{-- ->where('pamtechoga_depot_orders.status', '<>', 'CANCELED')--}} -{{-- ->where('pamtechoga_products.type', 'PMS')--}} +{{-- ->where('pamtechoga_products.type', 'LIKE', 'PMS%')--}} {{-- ->sum('pamtechoga_depot_orders.volume');--}} {{-- $totalPMSDepotPickupsVolume = DepotPickup::join('pamtechoga_customer_orders','pamtechoga_customer_orders.id', '=', 'pamtechoga_depot_pickups.depot_order_id')--}} {{-- ->join('pamtechoga_products','pamtechoga_products.id', '=', 'pamtechoga_customer_orders.product_id')--}} {{-- ->where('pamtechoga_depot_pickups.status', '<>', 'CANCELED')--}} -{{-- ->where('pamtechoga_products.type', 'PMS')--}} +{{-- ->where('pamtechoga_products.type', 'LIKE', 'PMS%')--}} {{-- ->sum('pamtechoga_depot_pickups.volume_assigned');--}} {{-- $totalVolumeOfPMSAtDepot = $totalPMSDepotOrdersVolume - $totalPMSDepotPickupsVolume;--}} {{-- $totalAGODepotOrdersVolume = DepotOrder::join('pamtechoga_products','pamtechoga_products.id', '=', 'pamtechoga_depot_orders.product_id')--}} {{-- ->where('pamtechoga_depot_orders.status', '<>', 'CANCELED')--}} -{{-- ->where('pamtechoga_products.type', 'AGO')--}} +{{-- ->where('pamtechoga_products.type', 'LIKE', 'AGO%')--}} {{-- ->sum('pamtechoga_depot_orders.volume');--}} {{-- $totalAGODepotPickupsVolume = DepotPickup::join('pamtechoga_customer_orders','pamtechoga_customer_orders.id', '=', 'pamtechoga_depot_pickups.depot_order_id')--}} {{-- ->join('pamtechoga_products','pamtechoga_products.id', '=', 'pamtechoga_customer_orders.product_id')--}} {{-- ->where('pamtechoga_depot_pickups.status', '<>', 'CANCELED')--}} -{{-- ->where('pamtechoga_products.type', 'AGO')--}} +{{-- ->where('pamtechoga_products.type', 'LIKE', 'AGO%')--}} {{-- ->sum('pamtechoga_depot_pickups.volume_assigned');--}} {{-- $totalVolumeOfAGOAtDepot = $totalAGODepotOrdersVolume - $totalAGODepotPickupsVolume;--}} diff --git a/resources/views/models/depot-orders/form.blade.php b/resources/views/models/depot-orders/form.blade.php index 54f357d..7078bd6 100644 --- a/resources/views/models/depot-orders/form.blade.php +++ b/resources/views/models/depot-orders/form.blade.php @@ -17,6 +17,18 @@ + + diff --git a/resources/views/models/depot-orders/index.blade.php b/resources/views/models/depot-orders/index.blade.php index ec185bc..346040b 100644 --- a/resources/views/models/depot-orders/index.blade.php +++ b/resources/views/models/depot-orders/index.blade.php @@ -1,72 +1,6 @@ - -{{--@php--}} -{{-- use Illuminate\Support\Facades\DB;--}} -{{-- use Vibraniuum\Pamtechoga\Models\Order;--}} -{{-- use Vibraniuum\Pamtechoga\Models\DepotOrder;--}} -{{-- use Vibraniuum\Pamtechoga\Models\DepotPickup;--}} -{{-- use Vibraniuum\Pamtechoga\Models\Product;--}} -{{-- use Vibraniuum\Pamtechoga\Models\Organization;--}} - -{{-- $totalDepotOrdersAmount = DepotOrder::where('status', '<>', 'CANCELED')--}} -{{-- //->whereBetween('pamtechoga_customer_orders.created_at', [$startDate, $endDate])--}} -{{-- ->select(DB::raw('SUM(volume * unit_price) AS total'))--}} -{{-- ->first();--}} -{{-- $totalDepotOrders = DepotOrder::where('status', '<>', 'CANCELED')->count();--}} -{{-- $totalDepotOrdersVolume = DepotOrder::where('status', '<>', 'CANCELED')->sum('volume');--}} - -{{-- $ordersBreakDownByProduct = Order::select( 'pamtechoga_customer_orders.product_id', 'pamtechoga_products.type', DB::raw('SUM(pamtechoga_customer_orders.volume) as total'))--}} -{{-- ->join('pamtechoga_products','pamtechoga_products.id', '=', 'pamtechoga_customer_orders.product_id')--}} -{{-- ->where('status', '<>', 'CANCELED')--}} -{{-- //->whereBetween('pamtechoga_customer_orders.created_at', [$startDate, $endDate])--}} -{{-- ->groupBy('product_id')--}} -{{-- ->get();--}} - -{{-- $totalPMSDepotOrdersVolume = DepotOrder::join('pamtechoga_products','pamtechoga_products.id', '=', 'pamtechoga_depot_orders.product_id')--}} -{{-- ->where('pamtechoga_depot_orders.status', '<>', 'CANCELED')--}} -{{-- ->where('pamtechoga_products.type', 'PMS')--}} -{{-- ->sum('pamtechoga_depot_orders.volume');--}} - -{{-- $totalPMSDepotPickupsVolume = DepotPickup::join('pamtechoga_customer_orders','pamtechoga_customer_orders.id', '=', 'pamtechoga_depot_pickups.depot_order_id')--}} -{{-- ->join('pamtechoga_products','pamtechoga_products.id', '=', 'pamtechoga_customer_orders.product_id')--}} -{{-- ->where('pamtechoga_depot_pickups.status', '<>', 'CANCELED')--}} -{{-- ->where('pamtechoga_products.type', 'PMS')--}} -{{-- ->sum('pamtechoga_depot_pickups.volume_assigned');--}} - -{{-- $totalVolumeOfPMSAtDepot = $totalPMSDepotOrdersVolume - $totalPMSDepotPickupsVolume;--}} - -{{-- $totalAGODepotOrdersVolume = DepotOrder::join('pamtechoga_products','pamtechoga_products.id', '=', 'pamtechoga_depot_orders.product_id')--}} -{{-- ->where('pamtechoga_depot_orders.status', '<>', 'CANCELED')--}} -{{-- ->where('pamtechoga_products.type', 'AGO')--}} -{{-- ->sum('pamtechoga_depot_orders.volume');--}} - -{{-- $totalAGODepotPickupsVolume = DepotPickup::join('pamtechoga_customer_orders','pamtechoga_customer_orders.id', '=', 'pamtechoga_depot_pickups.depot_order_id')--}} -{{-- ->join('pamtechoga_products','pamtechoga_products.id', '=', 'pamtechoga_customer_orders.product_id')--}} -{{-- ->where('pamtechoga_depot_pickups.status', '<>', 'CANCELED')--}} -{{-- ->where('pamtechoga_products.type', 'AGO')--}} -{{-- ->sum('pamtechoga_depot_pickups.volume_assigned');--}} - -{{-- $totalVolumeOfAGOAtDepot = $totalAGODepotOrdersVolume - $totalAGODepotPickupsVolume;--}} - -{{-- $totalVolumeOfPMSInTrucks = $totalAGODepotOrdersVolume - $totalAGODepotPickupsVolume;--}} - -{{-- $deliveredOrdersVolumeByProduct = Order::select( 'pamtechoga_customer_orders.product_id', 'pamtechoga_products.type', DB::raw('SUM(pamtechoga_customer_orders.volume) as total'))--}} -{{-- ->join('pamtechoga_products','pamtechoga_products.id', '=', 'pamtechoga_customer_orders.product_id')--}} -{{-- ->where('status', '=', 'DELIVERED')--}} -{{-- ->orWhere('status', '=', 'DISPATCHED')--}} -{{-- //->whereBetween('pamtechoga_customer_orders.created_at', [$startDate, $endDate])--}} -{{-- ->groupBy('product_id')--}} -{{-- ->get();--}} - -{{-- $totalVolumeOfLoadedProductPickup = function ($type) {--}} -{{-- DepotPickup::join('pamtechoga_customer_orders','pamtechoga_customer_orders.id', '=', 'pamtechoga_depot_pickups.depot_order_id')--}} -{{-- ->join('pamtechoga_products','pamtechoga_products.id', '=', 'pamtechoga_customer_orders.product_id')--}} -{{-- ->where('pamtechoga_depot_pickups.status', '<>', 'CANCELED')--}} -{{-- ->where('pamtechoga_depot_pickups.status', '=', 'LOADED') // Ask Pamtech if LOADed means it is already in the truck or still at the depot.--}} -{{-- ->where('pamtechoga_products.type', $type)--}} -{{-- ->sum('pamtechoga_depot_pickups.volume_assigned');--}} -{{-- }--}} - -{{--@endphp--}} +@php + use Carbon\Carbon; +@endphp @endif - @if($this->shouldShowColumn('updated_at')) + @if($this->shouldShowColumn('order_date')) - {{ $data->updated_at->toFormattedDateString() }} + {{ Carbon::parse($data->order_date)->toFormattedDateString() }} @endisset diff --git a/resources/views/models/depot-pickups/form.blade.php b/resources/views/models/depot-pickups/form.blade.php index c8ca045..fcd24fe 100644 --- a/resources/views/models/depot-pickups/form.blade.php +++ b/resources/views/models/depot-pickups/form.blade.php @@ -28,17 +28,17 @@ @endforeach - +{{-- --}} @foreach($this->allDrivers() as $data) - + @endforeach diff --git a/resources/views/models/depot-pickups/index.blade.php b/resources/views/models/depot-pickups/index.blade.php index f7a9277..6257726 100644 --- a/resources/views/models/depot-pickups/index.blade.php +++ b/resources/views/models/depot-pickups/index.blade.php @@ -1,3 +1,6 @@ +@php + use Carbon\Carbon; +@endphp - {{ $data->updated_at->toFormattedDateString() }} + {{ Carbon::parse($data->loaded_datetime)->toFormattedDateString() }} @endisset diff --git a/resources/views/models/drivers/form.blade.php b/resources/views/models/drivers/form.blade.php index 47c82d6..0df25f9 100644 --- a/resources/views/models/drivers/form.blade.php +++ b/resources/views/models/drivers/form.blade.php @@ -23,6 +23,12 @@ help="Name of the driver." /> + + @if($this->shouldShowColumn('name')) - {{ $data->name }} + {{ $data->name }} ({{ $data->nickname ?? '' }}) @endisset diff --git a/resources/views/models/orders/form.blade.php b/resources/views/models/orders/form.blade.php index 553fd9c..b261326 100644 --- a/resources/views/models/orders/form.blade.php +++ b/resources/views/models/orders/form.blade.php @@ -1,3 +1,6 @@ +@php + use Carbon\Carbon; +@endphp + @foreach($this->allDepotOrders() as $data) - + @endforeach diff --git a/resources/views/models/orders/index.blade.php b/resources/views/models/orders/index.blade.php index 438ff3e..45fcd0a 100644 --- a/resources/views/models/orders/index.blade.php +++ b/resources/views/models/orders/index.blade.php @@ -1,3 +1,6 @@ +@php + use Carbon\Carbon; +@endphp - {{ $data->updated_at->toFormattedDateString() }} + {{ Carbon::parse($data->order_date)->toFormattedDateString() }} @endisset diff --git a/resources/views/models/organizations/form.blade.php b/resources/views/models/organizations/form.blade.php index 28c9df2..b114c9f 100644 --- a/resources/views/models/organizations/form.blade.php +++ b/resources/views/models/organizations/form.blade.php @@ -10,8 +10,8 @@ x-on:keydown.ctrl.s.window.prevent="$wire.call('save')" {{-- For PC --}} > -{{-- @include('lego::models._includes.forms.page-actions')--}} -
+ @include('lego::models._includes.forms.page-actions') +
Send login instructions
@@ -47,6 +47,32 @@ + + + + + + + + + where('pamtechoga_depot_orders.status', '<>', 'CANCELED')--}} -{{-- ->where('pamtechoga_products.type', 'PMS')--}} +{{-- ->where('pamtechoga_products.type', 'LIKE', 'PMS%')--}} {{-- ->sum('pamtechoga_depot_orders.volume');--}} {{-- $totalPMSDepotPickupsVolume = DepotPickup::join('pamtechoga_customer_orders','pamtechoga_customer_orders.id', '=', 'pamtechoga_depot_pickups.depot_order_id')--}} {{-- ->join('pamtechoga_products','pamtechoga_products.id', '=', 'pamtechoga_customer_orders.product_id')--}} {{-- ->where('pamtechoga_depot_pickups.status', '<>', 'CANCELED')--}} -{{-- ->where('pamtechoga_products.type', 'PMS')--}} +{{-- ->where('pamtechoga_products.type', 'LIKE', 'PMS%')--}} {{-- ->sum('pamtechoga_depot_pickups.volume_assigned');--}} {{-- $totalVolumeOfPMSAtDepot = $totalPMSDepotOrdersVolume - $totalPMSDepotPickupsVolume;--}} {{-- $totalAGODepotOrdersVolume = DepotOrder::join('pamtechoga_products','pamtechoga_products.id', '=', 'pamtechoga_depot_orders.product_id')--}} {{-- ->where('pamtechoga_depot_orders.status', '<>', 'CANCELED')--}} -{{-- ->where('pamtechoga_products.type', 'AGO')--}} +{{-- ->where('pamtechoga_products.type', 'LIKE', 'AGO%')--}} {{-- ->sum('pamtechoga_depot_orders.volume');--}} {{-- $totalAGODepotPickupsVolume = DepotPickup::join('pamtechoga_customer_orders','pamtechoga_customer_orders.id', '=', 'pamtechoga_depot_pickups.depot_order_id')--}} {{-- ->join('pamtechoga_products','pamtechoga_products.id', '=', 'pamtechoga_customer_orders.product_id')--}} {{-- ->where('pamtechoga_depot_pickups.status', '<>', 'CANCELED')--}} -{{-- ->where('pamtechoga_products.type', 'AGO')--}} +{{-- ->where('pamtechoga_products.type', 'LIKE', 'AGO%')--}} {{-- ->sum('pamtechoga_depot_pickups.volume_assigned');--}} {{-- $totalVolumeOfAGOAtDepot = $totalAGODepotOrdersVolume - $totalAGODepotPickupsVolume;--}} diff --git a/src/Http/Livewire/DepotOrdersForm.php b/src/Http/Livewire/DepotOrdersForm.php index 509fbf0..9788060 100644 --- a/src/Http/Livewire/DepotOrdersForm.php +++ b/src/Http/Livewire/DepotOrdersForm.php @@ -24,6 +24,7 @@ public function rules() 'model.volume' => 'required', 'model.unit_price' => 'required', 'model.trucking_expense' => 'required', + 'model.order_date' => 'required', ]; } diff --git a/src/Http/Livewire/DepotOrdersIndex.php b/src/Http/Livewire/DepotOrdersIndex.php index 1c7d0fd..31e5bcc 100644 --- a/src/Http/Livewire/DepotOrdersIndex.php +++ b/src/Http/Livewire/DepotOrdersIndex.php @@ -32,7 +32,7 @@ public function columns(): array 'volume' => 'Volume (Litres)', 'status' => 'Status', 'unit_price' => 'Unit Price (NGN)', - 'updated_at' => 'Last updated', + 'order_date' => 'Date Ordered', ]; } diff --git a/src/Http/Livewire/DepotPickupsForm.php b/src/Http/Livewire/DepotPickupsForm.php index e633618..75ac6ab 100644 --- a/src/Http/Livewire/DepotPickupsForm.php +++ b/src/Http/Livewire/DepotPickupsForm.php @@ -18,7 +18,7 @@ public function rules() 'model.status' => 'required', 'model.driver_id' => 'required', 'model.volume_assigned' => 'required', - 'model.pickup_datetime' => 'nullable', +// 'model.pickup_datetime' => 'nullable', 'model.loaded_datetime' => 'nullable', ]; } diff --git a/src/Http/Livewire/DepotPickupsIndex.php b/src/Http/Livewire/DepotPickupsIndex.php index 92bbab3..7e162ea 100644 --- a/src/Http/Livewire/DepotPickupsIndex.php +++ b/src/Http/Livewire/DepotPickupsIndex.php @@ -21,7 +21,7 @@ public function columns(): array 'status' => 'Status', 'unit_price' => 'Unit Price (NGN)', 'driver' => 'Driver', - 'updated_at' => 'Last updated', + 'loaded_datetime' => 'Date Loaded', ]; } diff --git a/src/Http/Livewire/DriversForm.php b/src/Http/Livewire/DriversForm.php index dc1df2c..78e71c8 100644 --- a/src/Http/Livewire/DriversForm.php +++ b/src/Http/Livewire/DriversForm.php @@ -15,6 +15,7 @@ public function rules() { return [ 'model.name' => 'required', + 'model.nickname' => 'nullable', 'model.phone' => 'required', 'model.email' => 'nullable', 'model.address' => 'required', diff --git a/src/Http/Livewire/DriversIndex.php b/src/Http/Livewire/DriversIndex.php index b1243aa..dd43f1e 100644 --- a/src/Http/Livewire/DriversIndex.php +++ b/src/Http/Livewire/DriversIndex.php @@ -16,7 +16,7 @@ public function model(): string public function columns(): array { return [ - 'name' => 'Name', + 'name' => 'Name (Nickname)', 'phone' => 'Phone', 'email' => 'Email', 'truck' => 'Truck', diff --git a/src/Http/Livewire/OrdersForm.php b/src/Http/Livewire/OrdersForm.php index 77aefba..0d4e474 100644 --- a/src/Http/Livewire/OrdersForm.php +++ b/src/Http/Livewire/OrdersForm.php @@ -18,6 +18,7 @@ class OrdersForm extends Form public function rules() { return [ + 'model.order_date' => 'nullable', 'model.depot_order_id' => 'nullable', 'model.product_id' => 'required', 'model.status' => 'required', @@ -92,7 +93,7 @@ public function calculateValue($type) public function allDepotOrders() { - return DepotOrder::all(); + return DepotOrder::orderBy('created_at', 'desc')->get(); } public function allProducts() diff --git a/src/Http/Livewire/OrdersIndex.php b/src/Http/Livewire/OrdersIndex.php index 13e34fb..a14580b 100644 --- a/src/Http/Livewire/OrdersIndex.php +++ b/src/Http/Livewire/OrdersIndex.php @@ -33,7 +33,7 @@ public function columns(): array 'unit_price' => 'Unit Price (NGN)', 'amount' => 'Amount (NGN)', 'status' => 'Status', - 'updated_at' => 'Last updated', + 'order_date' => 'Date Ordered', ]; } diff --git a/src/Http/Livewire/OrganizationsForm.php b/src/Http/Livewire/OrganizationsForm.php index 2e83b9a..408bc9a 100644 --- a/src/Http/Livewire/OrganizationsForm.php +++ b/src/Http/Livewire/OrganizationsForm.php @@ -8,9 +8,13 @@ use Illuminate\Support\Facades\Hash; use Vibraniuum\Pamtechoga\Events\OrganizationLoginInstructions; use Vibraniuum\Pamtechoga\Models\Branch; +use Vibraniuum\Pamtechoga\Models\Order; use Vibraniuum\Pamtechoga\Models\Organization; use Helix\Lego\Models\User; use Vibraniuum\Pamtechoga\Models\OrganizationUser; +use Vibraniuum\Pamtechoga\Models\Payment; +use Vibraniuum\Pamtechoga\Models\Review; +use Vibraniuum\Pamtechoga\Models\SupportMessage; class OrganizationsForm extends Form { @@ -33,6 +37,9 @@ public function rules() 'model.slug' => [new SlugRule($this->model)], 'model.phone' => 'required', 'model.email' => 'required', + 'model.contact_person_name' => 'nullable', + 'model.contact_person_phone' => 'nullable', + 'model.contact_person_dob' => 'nullable', ]; } @@ -123,6 +130,30 @@ public function view() return 'pamtechoga::models.organizations.form'; } + public function deleting() + { + // delete branches + Branch::where('organization_id', $this->model->id)->delete(); + + // delete customer orders + Order::where('organization_id', $this->model->id)->delete(); + + // delete payments + Payment::where('organization_id', $this->model->id)->delete(); + + // delete organization users + OrganizationUser::where('organization_id', $this->model->id)->delete(); + + // delete notifiacations + + // delete reviews + Review::where('organization_id', $this->model->id)->delete(); + + // delete support messages + SupportMessage::where('organization_id', $this->model->id)->delete(); + + } + public function model(): string { return Organization::class; @@ -137,6 +168,7 @@ public function sendLoginInstructions() { OrganizationLoginInstructions::dispatch([ 'email' => $this->model->email, + 'organizationName' => $this->model->name, ]); $this->confetti(); diff --git a/src/Listeners/SendOrganizationLoginInstructionsNotification.php b/src/Listeners/SendOrganizationLoginInstructionsNotification.php index c3bff93..7dc5b8f 100644 --- a/src/Listeners/SendOrganizationLoginInstructionsNotification.php +++ b/src/Listeners/SendOrganizationLoginInstructionsNotification.php @@ -31,6 +31,7 @@ public function handle(OrganizationLoginInstructions $event) { Mail::send('emails.pamtechoga.login-instructions', [ 'email' => $event->data['email'], + 'organizationName' => $event->data['organizationName'], ], function($message) use ($event) { $message->to($event->data['email']); $message->from('contact@vibraniuumtech.com', 'Login instructions for Pamtech OGA'); diff --git a/src/Services/DateFilters.php b/src/Services/DateFilters.php index 6e77251..12f3ceb 100644 --- a/src/Services/DateFilters.php +++ b/src/Services/DateFilters.php @@ -55,26 +55,26 @@ $totalPMSDepotOrdersVolume = DepotOrder::join('pamtechoga_products','pamtechoga_products.id', '=', 'pamtechoga_depot_orders.product_id') ->where('pamtechoga_depot_orders.status', '<>', 'CANCELED') - ->where('pamtechoga_products.type', 'PMS') + ->where('pamtechoga_products.type', 'LIKE', 'PMS%') ->sum('pamtechoga_depot_orders.volume'); $totalPMSDepotPickupsVolume = DepotPickup::join('pamtechoga_customer_orders','pamtechoga_customer_orders.id', '=', 'pamtechoga_depot_pickups.depot_order_id') ->join('pamtechoga_products','pamtechoga_products.id', '=', 'pamtechoga_customer_orders.product_id') ->where('pamtechoga_depot_pickups.status', '<>', 'CANCELED') - ->where('pamtechoga_products.type', 'PMS') + ->where('pamtechoga_products.type', 'LIKE', 'PMS%') ->sum('pamtechoga_depot_pickups.volume_assigned'); $totalVolumeOfPMSAtDepot = $totalPMSDepotOrdersVolume - $totalPMSDepotPickupsVolume; $totalAGODepotOrdersVolume = DepotOrder::join('pamtechoga_products','pamtechoga_products.id', '=', 'pamtechoga_depot_orders.product_id') ->where('pamtechoga_depot_orders.status', '<>', 'CANCELED') - ->where('pamtechoga_products.type', 'AGO') + ->where('pamtechoga_products.type', 'LIKE', 'AGO%') ->sum('pamtechoga_depot_orders.volume'); $totalAGODepotPickupsVolume = DepotPickup::join('pamtechoga_customer_orders','pamtechoga_customer_orders.id', '=', 'pamtechoga_depot_pickups.depot_order_id') ->join('pamtechoga_products','pamtechoga_products.id', '=', 'pamtechoga_customer_orders.product_id') ->where('pamtechoga_depot_pickups.status', '<>', 'CANCELED') - ->where('pamtechoga_products.type', 'AGO') + ->where('pamtechoga_products.type', 'LIKE', 'AGO%') ->sum('pamtechoga_depot_pickups.volume_assigned'); $totalVolumeOfAGOAtDepot = $totalAGODepotOrdersVolume - $totalAGODepotPickupsVolume; diff --git a/src/Traits/DateFilter.php b/src/Traits/DateFilter.php index 9816dc8..e3c7dcf 100644 --- a/src/Traits/DateFilter.php +++ b/src/Traits/DateFilter.php @@ -130,29 +130,35 @@ public function applyFilter() $this->totalPMSDepotOrdersVolume = DepotOrder::join('pamtechoga_products', 'pamtechoga_products.id', '=', 'pamtechoga_depot_orders.product_id') ->where('pamtechoga_depot_orders.status', '<>', 'CANCELED') - ->where('pamtechoga_products.type', 'PMS') + ->where('pamtechoga_products.type', 'LIKE', 'PMS%') // ->whereBetween('pamtechoga_depot_orders.created_at', [$this->startDate, $this->endDate]) ->sum('pamtechoga_depot_orders.volume'); +// dd($this->totalPMSDepotOrdersVolume); + + $this->totalPMSDepotPickupsVolume = DepotPickup::join('pamtechoga_customer_orders', 'pamtechoga_customer_orders.id', '=', 'pamtechoga_depot_pickups.depot_order_id') ->join('pamtechoga_products', 'pamtechoga_products.id', '=', 'pamtechoga_customer_orders.product_id') ->where('pamtechoga_depot_pickups.status', '<>', 'CANCELED') - ->where('pamtechoga_products.type', 'PMS') + ->where('pamtechoga_products.type', 'LIKE', 'PMS%') // ->whereBetween('pamtechoga_depot_pickups.created_at', [$this->startDate, $this->endDate]) ->sum('pamtechoga_depot_pickups.volume_assigned'); $this->totalVolumeOfPMSAtDepot = $this->totalPMSDepotOrdersVolume - $this->totalPMSDepotPickupsVolume; +// dd($this->totalPMSDepotOrdersVolume); + + $this->totalAGODepotOrdersVolume = DepotOrder::join('pamtechoga_products', 'pamtechoga_products.id', '=', 'pamtechoga_depot_orders.product_id') ->where('pamtechoga_depot_orders.status', '<>', 'CANCELED') - ->where('pamtechoga_products.type', 'AGO') + ->where('pamtechoga_products.type', 'LIKE', 'AGO%') // ->whereBetween('pamtechoga_products.created_at', [$this->startDate, $this->endDate]) ->sum('pamtechoga_depot_orders.volume'); $this->totalAGODepotPickupsVolume = DepotPickup::join('pamtechoga_customer_orders', 'pamtechoga_customer_orders.id', '=', 'pamtechoga_depot_pickups.depot_order_id') ->join('pamtechoga_products', 'pamtechoga_products.id', '=', 'pamtechoga_customer_orders.product_id') ->where('pamtechoga_depot_pickups.status', '<>', 'CANCELED') - ->where('pamtechoga_products.type', 'AGO') + ->where('pamtechoga_products.type', 'LIKE', 'AGO%') // ->whereBetween('pamtechoga_products.created_at', [$this->startDate, $this->endDate]) ->sum('pamtechoga_depot_pickups.volume_assigned');