From a3284c968805665a59a453c6bdf54eecc6b4b742 Mon Sep 17 00:00:00 2001 From: sayliraut Date: Mon, 12 Aug 2024 15:56:04 +0530 Subject: [PATCH] changes --- app/Exports/customer_export.php | 5 +- app/Exports/customer_export_selected.php | 4 +- .../Admin/ManageCustomerController.php | 1 - .../assets/js/admin/manage_customer/main.js | 76 ++++++++++- .../manage_customer/customer.blade.php | 123 +----------------- .../customer_restaurants.blade.php | 31 +++-- 6 files changed, 103 insertions(+), 137 deletions(-) diff --git a/app/Exports/customer_export.php b/app/Exports/customer_export.php index da2ceeb..993f3f5 100644 --- a/app/Exports/customer_export.php +++ b/app/Exports/customer_export.php @@ -29,7 +29,9 @@ class customer_export implements FromCollection, WithHeadings $serial = 1; return $customers->map(function ($customer) use (&$serial) { - $isSubscribed = $customer->isSubscribed->count() > 0 ? 'Subscribed' : 'Unsubscribed'; + $subscription = $customer->isSubscribed->first(); + $isSubscribed = $subscription && $subscription->status == 'complete' ? 'Subscribed' : 'Unsubscribed'; + return [ 'Sr No.' => $serial++, // Increment serial number 'id' => $customer->id, @@ -44,6 +46,7 @@ class customer_export implements FromCollection, WithHeadings }); } + // Function to provide the headings in Excel public function headings(): array { diff --git a/app/Exports/customer_export_selected.php b/app/Exports/customer_export_selected.php index 5a3a6eb..6d2eaaa 100644 --- a/app/Exports/customer_export_selected.php +++ b/app/Exports/customer_export_selected.php @@ -1,4 +1,5 @@ map(function ($customer) use (&$serial) { - $isSubscribed = $customer->isSubscribed->isNotEmpty() ? 'Subscribed' : 'Unsubscribed'; + $subscription = $customer->isSubscribed->first(); + $isSubscribed = $subscription && $subscription->status == 'complete' ? 'Subscribed' : 'Unsubscribed'; return [ 'Sr No.' => $serial++, // Increment serial number 'id' => $customer->id, diff --git a/app/Http/Controllers/Admin/ManageCustomerController.php b/app/Http/Controllers/Admin/ManageCustomerController.php index d3069b4..03f1358 100644 --- a/app/Http/Controllers/Admin/ManageCustomerController.php +++ b/app/Http/Controllers/Admin/ManageCustomerController.php @@ -304,7 +304,6 @@ class ManageCustomerController extends Controller { try { $redeemDetails = RedeemRestaurant::with('restaurant', 'customer')->where('iam_principal_xid', $id)->get(); - // return $redeemDetails; return view('Admin.pages.manage_users.manage_customer.customer_restaurants', compact('redeemDetails')); } catch (Exception $e) { Log::error("Error getting restaurant details: " . $e->getMessage()); diff --git a/public/assets/js/admin/manage_customer/main.js b/public/assets/js/admin/manage_customer/main.js index 9cc5ba0..b4688e3 100644 --- a/public/assets/js/admin/manage_customer/main.js +++ b/public/assets/js/admin/manage_customer/main.js @@ -19,6 +19,11 @@ $('#zero-config').DataTable({ ] }); +$(document).ready(function() { + $('') + .insertBefore("#zero-config_filter label"); +}); + $(document).on("click", ".cust_archive_btn", function () { var data_id = $(this).data('id'); $('#archive_id').val(data_id); @@ -116,7 +121,7 @@ $(function (e) { $('#all_id').prop('disabled', true); $('#ids').val(allIds); // Now submit the form or perform download action - $('#customer-form').submit(); + $('#customer-form').submit(); // console.log(allIds); // return; // Or perform your download action here @@ -126,9 +131,6 @@ $(function (e) { } }); - - - $(document).on("click", "#download_all", function (e) { $('#all_id').prop('disabled', false); $('#ids').prop('disabled', true); @@ -142,12 +144,78 @@ $(document).on("click", ".more", function (e) { }); +$(document).on('click', "#delete_customer_user_id", function() { + var delete_customer_user_id = $(this).data('id'); + $("#customer_delete").val(delete_customer_user_id); +}) +$(document).on('click', '#delete_customer_user', function(e) { + let base_url = url_path; + e.preventDefault(); + $.ajaxSetup({ + headers: { + 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') + } + }); + var id = $('#customer_delete').val(); + $('#delete_customer_user').text('Please wait...'); + $('#delete_customer_user').attr('disabled', true); + $.ajax({ + type: 'POST', + url: 'delete_customer_user/' + id, + success: function(result) { + if (result.status == 200) { + toastr.success('Customer Deleted Sucessfully'); + setTimeout(function() { + window.location.href = base_url + "/manage-customer"; + }, 2000); + } else { + toastr.error('Something Went Wrong'); + setTimeout(function() { + window.location.href = base_url + "/manage-customer"; + }, 2000); + } + } + }); +}); +$(document).on('click', "#unsubscribe_id", function() { + var unsubscribe_id = $(this).data('id'); + $("#unsubscribe_id").val(unsubscribe_id); +}) +$(document).on('click', '#unsubscibed', function(e) { + let base_url = url_path; + e.preventDefault(); + $.ajaxSetup({ + headers: { + 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') + } + }); + var id = $('#unsubscribe_id').val(); + $('#unsubscibed').text('Please wait...'); + $('#unsubscibed').attr('disabled', true); + $.ajax({ + type: 'POST', + url: 'unsubscibed/' + id, + success: function(result) { + if (result.status == 200) { + toastr.success('Customer Unsubscribed Sucessfully'); + setTimeout(function() { + window.location.href = base_url + "/manage-customer"; + }, 2000); + } else { + toastr.error('Something Went Wrong'); + setTimeout(function() { + window.location.href = base_url + "/manage-customer"; + }, 2000); + } + } + }); +}); 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 caf41c4..618f969 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 @@ -151,8 +151,9 @@ title="Edit" /> @if ($customer['is_subscribed']) - + Unsubscribe @@ -164,7 +165,8 @@ @endif Delete @@ -219,7 +221,8 @@ @@ -231,116 +234,4 @@ @section('section_script') - - - - - @endsection diff --git a/resources/views/Admin/pages/manage_users/manage_customer/customer_restaurants.blade.php b/resources/views/Admin/pages/manage_users/manage_customer/customer_restaurants.blade.php index 2ef880e..bb8b58b 100644 --- a/resources/views/Admin/pages/manage_users/manage_customer/customer_restaurants.blade.php +++ b/resources/views/Admin/pages/manage_users/manage_customer/customer_restaurants.blade.php @@ -46,8 +46,8 @@ @foreach ($redeemDetails as $redeemDetail) {{ $loop->iteration }} - {{ $redeemDetail->restaurant->name }} - {{ $redeemDetail->restaurant->name ?? 'N/A' }} + @if (!is_null($redeemDetail->redeem_date)) @@ -58,21 +58,24 @@ {{-- {{ $redeemDetail->count }} --}} +
+ + +
+ -->
- - + +