diff --git a/app/Exports/CustomerExportSelected.php b/app/Exports/CustomerExportSelected.php deleted file mode 100644 index bcc92cc..0000000 --- a/app/Exports/CustomerExportSelected.php +++ /dev/null @@ -1,56 +0,0 @@ -ids = $ids; - } - - /** - * @return \Illuminate\Support\Collection - */ - public function collection() - { - $selectedCareIds = explode(',', $this->ids); - - $selected_customer = IamPrincipal::whereIn('id', $selectedCareIds) - ->orderBy('id', 'Desc') - ->select( - 'first_name', - 'email_address', - 'date_of_birth', - 'phone_number' - ) - ->get(); - return $selected_customer; - } - - /** - * @return array - */ - public function headings(): array - { - return [ - 'first_name', - 'email_address', - 'date_of_birth', - 'phone_number' - ]; - } -} - - - - diff --git a/app/Exports/customer_export_selected.php b/app/Exports/customer_export_selected.php new file mode 100644 index 0000000..bea8598 --- /dev/null +++ b/app/Exports/customer_export_selected.php @@ -0,0 +1,52 @@ +ids = $ids; + } + + /** + * @return \Illuminate\Support\Collection + */ + public function collection() + { + + $selectedCareIds = explode(',', $this->ids); + + $selected_customer = IamPrincipal::whereIn('id', $selectedCareIds) + ->orderBy('id', 'Desc') + ->select( + 'first_name', + 'email_address', + 'date_of_birth', + 'phone_number' + ) + ->get(); + return $selected_customer; + } + + //function header in excel + public function headings(): array + { + return [ + 'first_name', + 'email_address', + 'date_of_birth', + 'phone_number' + ]; + } + + +} diff --git a/app/Http/Controllers/Admin/ManageCustomerController.php b/app/Http/Controllers/Admin/ManageCustomerController.php index e84fb64..a5dce87 100644 --- a/app/Http/Controllers/Admin/ManageCustomerController.php +++ b/app/Http/Controllers/Admin/ManageCustomerController.php @@ -219,24 +219,44 @@ class ManageCustomerController extends Controller } + public function exportSelectedCustomer(Request $request) + { + // dd($request->all()); + + + try { + if ($request->has('all_id')) { + return Excel::download(new customer_export, 'Passport_data.xlsx'); + } + + $ids = $request->selected_id; + // dd( $ids); + $fileName = 'selected_customer_data.xlsx'; + return Excel::download(new customer_export_selected($ids), $fileName); + } catch (\Exception $e) { + return response()->json(['error' => 'Export failed. Something went wrong.'], 500); + } + } + // public function exportSelectedCustomer(Request $request) // { - - // try { - - // if ($request->has('all_id')) { - // return Excel::download(new customer_export, 'Passport_data.xlsx'); - // } - - // $ids = $request->selected_id; - - // $fileName = 'selected_customer_data.xlsx'; - // return Excel::download(new customer_export_selected($ids), $fileName); - // } catch (\Exception $e) { - // return response()->json(['error' => 'Export failed. Something went wrong.'], 500); + // $data=null; + // $type = $request->input('type'); // 'overview' or 'selected' + + // if ($type === 'overview') { + // // Fetch all data from the database + // $data = IamPrincipal::all(); + // } elseif ($type === 'selected') { + // // Fetch selected data based on IDs + // $selectedIds = $request->input('selected_ids'); + // $data = IamPrincipal ::whereIn('id', $selectedIds)->get(); // } + + // // Generate Excel + // return Excel::download(new customer_export($data), 'customers.xlsx'); // } + /* Created By : Sayali Parab Created at : 28 May 2024 diff --git a/public/assets/js/admin/manage_customer/main.js b/public/assets/js/admin/manage_customer/main.js index a21b60f..9134ad6 100644 --- a/public/assets/js/admin/manage_customer/main.js +++ b/public/assets/js/admin/manage_customer/main.js @@ -140,3 +140,11 @@ $(document).on("click", ".more", function (e) { + + + + + + + + diff --git a/resources/views/Admin/pages/manage_users/manage_customer/customer.blade.php b/resources/views/Admin/pages/manage_users/manage_customer/customer.blade.php index 3ed96d7..ed06943 100644 --- a/resources/views/Admin/pages/manage_users/manage_customer/customer.blade.php +++ b/resources/views/Admin/pages/manage_users/manage_customer/customer.blade.php @@ -1,266 +1,184 @@ @extends('Admin.layouts.master') @section('content') - @php - $currentPage = 'manage-customer'; - @endphp - + /* Ensuring the table does not overflow */ + table { + width: 100%; + overflow-x: auto; + } + -
-
-
-
-
-
-
Manage Customers
-
-
+
+
+
+
+
+
+
Manage Customers
+
+
-
-
-
-
- @csrf - - - - - + +
+
+ + @csrf + -
- - - - - - - - + +
Sr noFull NameUser IDEmail IdRedeemed RestaurantDate of birthPhone NumberLocation
+ + - - - + + + + + + + + + - - @foreach ($customers as $customer) - + + + - - - + + @foreach ($customers as $customer) + + + + + - - - + + + - - - + + + - + - - - - @endforeach - + + + + @endforeach + -
+
+ +
+
Action
Sr noFull NameUser IDEmail IdRedeemed RestaurantDate of birthPhone NumberLocation
Action
{{ $loop->iteration }}{{ $customer->first_name }} {{ $customer->last_name }} -
+
+ +
+
{{ $loop->iteration }}{{ $customer->first_name }} {{ $customer->last_name }} + {{ $customer->id }}{{ $customer->email_address }} - View - {{ $customer->id }}{{ $customer->email_address }} + View + {{ \Carbon\Carbon::parse($customer->date_of_birth)->format('d/m/Y') }}{{ $customer->phone_number }}{{ $customer->state ? $customer->state->name : 'No state assigned' }}{{ \Carbon\Carbon::parse($customer->date_of_birth)->format('d/m/Y') }}{{ $customer->phone_number }}{{ $customer->state ? $customer->state->name : 'No state assigned' }} - - View - - - Edit - - - Archive - -
+ + View + + + Edit + + + Archive + +
-
+ + -
-
+
+
-