Merge branch 'main' of https://github.com/WDI-Ideas/cheerstothe_season_laravel11 into HritikCheers
This commit is contained in:
76
app/Console/Commands/SentScheduleNotification.php
Normal file
76
app/Console/Commands/SentScheduleNotification.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\IamPrincipal;
|
||||
use App\Models\NotificationDetails;
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use DateTime;
|
||||
use App\Helpers\onesignalhelper;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SentScheduleNotification extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:sent-schedule-notification';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'It will send Recommendation to users Based on stored Data';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$getAllPushNotifications = NotificationDetails::where('is_schedule', 1)
|
||||
->where('is_active', 0)
|
||||
->orderByDesc('id')
|
||||
->get();
|
||||
|
||||
$currentDateTime = new DateTime();
|
||||
|
||||
foreach ($getAllPushNotifications as $inAppNotificationItem) {
|
||||
|
||||
$storedDateTime = new DateTime($inAppNotificationItem->delivery_schedule);
|
||||
|
||||
$currentTime = $currentDateTime->format('Y-m-d H:i');
|
||||
$storedTime = $storedDateTime->format('Y-m-d H:i');
|
||||
|
||||
if ($currentTime == $storedTime) {
|
||||
$title = $inAppNotificationItem->type;
|
||||
$description = $inAppNotificationItem->description;
|
||||
$imagePath = $inAppNotificationItem->image;
|
||||
|
||||
$principalData = IamPrincipal::find($inAppNotificationItem->principal_xid);
|
||||
|
||||
if ($principalData && $principalData->one_signal_player_id) {
|
||||
OneSignalHelper::sendNotificationApi(
|
||||
$principalData->one_signal_player_id,
|
||||
$title,
|
||||
$description,
|
||||
'Dashboard Notification',
|
||||
$imagePath,
|
||||
$id = null
|
||||
);
|
||||
|
||||
Log::info("INAPP scheduled notification sent successfully");
|
||||
|
||||
$inAppNotificationItem->is_active = 1;
|
||||
$inAppNotificationItem->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
44
app/Exports/DashboardExportUser.php
Normal file
44
app/Exports/DashboardExportUser.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class DashboardExportUser implements FromCollection, WithHeadings
|
||||
{
|
||||
protected $recentTransactions;
|
||||
|
||||
public function __construct(array $recentTransactions)
|
||||
{
|
||||
$this->recentTransactions = $recentTransactions;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$serial = 1;
|
||||
$mappedTransactions = collect($this->recentTransactions)->map(function ($transaction) use (&$serial) {
|
||||
return [
|
||||
'Sr No.' => $serial++, // Increment serial number
|
||||
'Name' => $transaction['subscription']['first_name'] . ' ' . $transaction['subscription']['last_name'],
|
||||
'Customer Id' => $transaction['subscription']['id'],
|
||||
'Amount' => $transaction['amount'],
|
||||
'Payment Details' => $transaction['stripe_customer_id'], // Adjust as needed
|
||||
];
|
||||
});
|
||||
|
||||
return new Collection($mappedTransactions);
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Sr No.',
|
||||
'Name',
|
||||
'Customer Id',
|
||||
'Amount',
|
||||
'Payment Details',
|
||||
];
|
||||
}
|
||||
}
|
||||
52
app/Exports/DashboardSelectedExportUser.php
Normal file
52
app/Exports/DashboardSelectedExportUser.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\Subscriptions;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class DashboardSelectedExportUser implements FromCollection, WithHeadings
|
||||
{
|
||||
protected $ids;
|
||||
|
||||
public function __construct($ids)
|
||||
{
|
||||
$this->ids = explode(',', $ids);
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$selectedTransactions = Subscriptions::whereIn('id', $this->ids)
|
||||
->with('subscription')
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
$serial = 1;
|
||||
$mappedTransactions = collect($selectedTransactions)->map(function ($transaction) use (&$serial) {
|
||||
return [
|
||||
'Sr No.' => $serial++, // Increment serial number
|
||||
'Name' => $transaction['subscription']['first_name'] . ' ' . $transaction['subscription']['last_name'],
|
||||
'Customer Id' => $transaction['subscription']['id'],
|
||||
'Amount' => $transaction['amount'],
|
||||
'Payment Details' => $transaction['stripe_customer_id'], // Adjust as needed
|
||||
|
||||
];
|
||||
|
||||
});
|
||||
|
||||
return new Collection($mappedTransactions);
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Sr No.',
|
||||
'Name',
|
||||
'Customer Id',
|
||||
'Amount',
|
||||
'Payment Details',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -5,59 +5,54 @@ namespace App\Exports;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\IamPrincipal;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
||||
|
||||
class customer_export implements FromCollection , WithHeadings
|
||||
class customer_export implements FromCollection, WithHeadings
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$customers = IamPrincipal::where('principal_type_xid', 3)
|
||||
->select(
|
||||
'id',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'email_address',
|
||||
'date_of_birth',
|
||||
'state_xid',
|
||||
'phone_number'
|
||||
)
|
||||
->get();
|
||||
|
||||
|
||||
public function collection(){
|
||||
return IamPrincipal::where('principal_type_xid',3)
|
||||
->select('id',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'email_address',
|
||||
'date_of_birth',
|
||||
'state_xid',
|
||||
'phone_number'
|
||||
)
|
||||
->get()
|
||||
->map(function ($customer) {
|
||||
$serial = 1;
|
||||
return $customers->map(function ($customer) use (&$serial) {
|
||||
return [
|
||||
'id' => $customer->id,
|
||||
'first_name' => $customer->first_name,
|
||||
'last_name' => $customer->last_name,
|
||||
'Sr No.' => $serial++, // Increment serial number
|
||||
'id' => $customer->id,
|
||||
'first_name' => $customer->first_name,
|
||||
'last_name' => $customer->last_name,
|
||||
'email_address' => $customer->email_address,
|
||||
'date_of_birth'=> \Carbon\Carbon::parse($customer->date_of_birth)->format('m/d/Y'),
|
||||
'state_xid' => $customer->state->name ?? '', // Access the state name and handle null
|
||||
'phone_number' => $customer->phone_number,
|
||||
'date_of_birth' => \Carbon\Carbon::parse($customer->date_of_birth)->format('m/d/Y'),
|
||||
'state_xid' => $customer->state->name ?? '', // Access the state name and handle null
|
||||
'phone_number' => $customer->phone_number,
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
//function header in excel
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
// Function to provide the headings in Excel
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Sr No.',
|
||||
'User Id',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'email_address',
|
||||
'date_of_birth',
|
||||
'state_name',
|
||||
'phone_number'
|
||||
'First Name',
|
||||
'Last Name',
|
||||
'Email Address',
|
||||
'Date of Birth',
|
||||
'State Name',
|
||||
'Phone Number',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class customer_export_selected implements FromCollection, WithHeadings
|
||||
// Log the ids for debugging purposes
|
||||
Log::info('Fetching data for IDs: ' . implode(',', $this->ids));
|
||||
|
||||
$selected_customer = IamPrincipal::whereIn('id', $this->ids)
|
||||
$selected_customers = IamPrincipal::whereIn('id', $this->ids)
|
||||
->with('state:id,name') // Eager load the state relationship
|
||||
->orderBy('id', 'desc')
|
||||
->select(
|
||||
@@ -37,28 +37,32 @@ class customer_export_selected implements FromCollection, WithHeadings
|
||||
'state_xid',
|
||||
'phone_number'
|
||||
)
|
||||
->get()
|
||||
->map(function ($customer) {
|
||||
return [
|
||||
'id' => $customer->id,
|
||||
'first_name' => $customer->first_name,
|
||||
'last_name' => $customer->last_name,
|
||||
'email_address' => $customer->email_address,
|
||||
'date_of_birth' => \Carbon\Carbon::parse($customer->date_of_birth)->format('m/d/Y'), // Format the date
|
||||
'state_xid' => $customer->state->name ?? '', // Access the state name and handle null
|
||||
'phone_number' => $customer->phone_number,
|
||||
];
|
||||
});
|
||||
->get();
|
||||
|
||||
$serial = 1;
|
||||
$mappedCustomers = $selected_customers->map(function ($customer) use (&$serial) {
|
||||
return [
|
||||
'Sr No.' => $serial++, // Increment serial number
|
||||
'id' => $customer->id,
|
||||
'first_name' => $customer->first_name,
|
||||
'last_name' => $customer->last_name,
|
||||
'email_address' => $customer->email_address,
|
||||
'date_of_birth' => \Carbon\Carbon::parse($customer->date_of_birth)->format('m/d/Y'), // Format the date
|
||||
'state_xid' => $customer->state->name ?? '', // Access the state name and handle null
|
||||
'phone_number' => $customer->phone_number,
|
||||
];
|
||||
});
|
||||
|
||||
// Log the fetched data for debugging purposes
|
||||
Log::info('Fetched customer data: ' . $selected_customer->toJson());
|
||||
Log::info('Fetched customer data: ' . $mappedCustomers->toJson());
|
||||
|
||||
return new Collection($selected_customer);
|
||||
return new Collection($mappedCustomers);
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Sr No.',
|
||||
'User Id',
|
||||
'First Name',
|
||||
'Last Name',
|
||||
|
||||
@@ -24,7 +24,7 @@ class NotificationController extends Controller
|
||||
$page = $request->query('page', 1);
|
||||
|
||||
if ($customerIamId) {
|
||||
$notificationsData = NotificationDetails::where('principal_xid', $customerIamId)->orderBy('id', 'Desc')->get();
|
||||
$notificationsData = NotificationDetails::where('principal_xid', $customerIamId)->where('is_active', 1)->orderBy('id', 'Desc')->get();
|
||||
|
||||
$totalItems = $notificationsData->count();
|
||||
$totalPages = ceil($totalItems / $perPage);
|
||||
|
||||
@@ -8,6 +8,10 @@ use App\Models\IamPrincipal;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\ManageRestaurant;
|
||||
use App\Models\Subscriptions;
|
||||
use App\Exports\DashboardExportUser;
|
||||
use App\Exports\DashboardSelectedExportUser;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
@@ -17,14 +21,64 @@ class DashboardController extends Controller
|
||||
* Use : To show the dashboard.
|
||||
*/
|
||||
|
||||
// public function showDashboard(){
|
||||
|
||||
|
||||
// return view('Admin.dashboard');
|
||||
// }
|
||||
public function showDashboard()
|
||||
{
|
||||
// Monthly data
|
||||
|
||||
$dailyData = Subscriptions::select(DB::raw("COUNT(*) as count"), DB::raw("DATE(created_at) as date"))
|
||||
->whereBetween('created_at', [now()->subDays(7), now()]) // Fetch data for the last 7 days
|
||||
->groupBy(DB::raw("DATE(created_at)"))
|
||||
->orderBy(DB::raw("DATE(created_at)"))
|
||||
->pluck('count', 'date')
|
||||
->toArray();
|
||||
|
||||
$start_date = now()->subDays(7)->startOfDay();
|
||||
$end_date = now()->endOfDay();
|
||||
$formattedDailyData = [];
|
||||
while ($start_date <= $end_date) {
|
||||
$formattedDailyData[$start_date->format('Y-m-d')] = isset($dailyData[$start_date->format('Y-m-d')]) ? $dailyData[$start_date->format('Y-m-d')] : 0;
|
||||
$start_date->addDay();
|
||||
}
|
||||
|
||||
|
||||
$defaultData = Subscriptions::select(DB::raw("COUNT(*) as count"), DB::raw("MONTH(created_at) as month"))
|
||||
->whereYear('created_at', date('Y'))
|
||||
->groupBy(DB::raw("MONTH(created_at)"))
|
||||
->orderBy(DB::raw("MONTH(created_at)"))
|
||||
->pluck('count', 'month')
|
||||
->toArray();
|
||||
|
||||
$months = range(1, 12);
|
||||
$formattedDefaultData = [];
|
||||
foreach ($months as $month) {
|
||||
$formattedDefaultData[$month] = isset($defaultData[$month]) ? $defaultData[$month] : 0;
|
||||
}
|
||||
$quarterlyData = Subscriptions::select(
|
||||
DB::raw("COUNT(*) as count"),
|
||||
DB::raw("QUARTER(created_at) as quarter")
|
||||
)
|
||||
->whereYear('created_at', date('Y'))
|
||||
->groupBy(DB::raw("QUARTER(created_at)"))
|
||||
->orderBy(DB::raw("QUARTER(created_at)"))
|
||||
->pluck('count', 'quarter')
|
||||
->toArray();
|
||||
|
||||
// Ensure that $quarterlyData contains zeros for quarters with no data
|
||||
for ($i = 1; $i <= 4; $i++) {
|
||||
if (!isset($quarterlyData[$i])) {
|
||||
$quarterlyData[$i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the array by quarter keys
|
||||
ksort($quarterlyData);
|
||||
|
||||
// Fetching data for yearly option
|
||||
$yearlyData = Subscriptions::select(DB::raw("COUNT(*) as count"), DB::raw("YEAR(created_at) as year"))
|
||||
->groupBy(DB::raw("YEAR(created_at)"))
|
||||
->pluck('count', 'year')
|
||||
->toArray();
|
||||
|
||||
|
||||
$dataMonthlyWithType3 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("MONTH(created_at) as month"))
|
||||
->where('principal_type_xid', 3)
|
||||
->whereYear('created_at', date('Y'))
|
||||
@@ -78,7 +132,9 @@ class DashboardController extends Controller
|
||||
|
||||
$customerCount = IamPrincipal::where('principal_type_xid', '=', 3)->count();
|
||||
$restaurantCount = Subscriptions::where('is_active', 1)->count();
|
||||
$recent_transaction = Subscriptions::with('subscription')->get()->toArray();
|
||||
$dateTime = now();
|
||||
$formattedDateTime = $dateTime->format('Y-m-d H:i:s');
|
||||
$recent_transaction = Subscriptions::where('next_payment_date', '>=', $formattedDateTime)->with('subscription')->get()->toArray();
|
||||
|
||||
|
||||
return view('Admin.dashboard', compact(
|
||||
@@ -90,7 +146,38 @@ class DashboardController extends Controller
|
||||
'dataQuarterlyWithType4',
|
||||
'dataYearlyWithType3',
|
||||
'dataYearlyWithType4',
|
||||
'recent_transaction'
|
||||
'recent_transaction',
|
||||
'dailyData',
|
||||
'formattedDailyData',
|
||||
'defaultData',
|
||||
'formattedDefaultData',
|
||||
'quarterlyData',
|
||||
'yearlyData'
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayali Parab
|
||||
Created at : 08 July 2024
|
||||
Use : To Get Excel.
|
||||
*/
|
||||
|
||||
|
||||
public function exportRecentTransactions(Request $request)
|
||||
{
|
||||
try {
|
||||
if ($request->has('all_id')) {
|
||||
$recentTransaction = Subscriptions::with('subscription')->get()->toArray();
|
||||
return Excel::download(new DashboardExportUser($recentTransaction), 'recent_transactions.xlsx');
|
||||
}
|
||||
|
||||
$ids = $request->input('selected_id');
|
||||
$fileName = 'selected_customer_transaction_data.xlsx';
|
||||
return Excel::download(new DashboardSelectedExportUser($ids), $fileName);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['error' => 'Export failed. Something went wrong.'], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ class ManageCustomerController extends Controller
|
||||
{
|
||||
try {
|
||||
if ($request->has('all_id')) {
|
||||
return Excel::download(new customer_export, 'Passport_data.xlsx');
|
||||
return Excel::download(new customer_export, 'customer_data.xlsx');
|
||||
}
|
||||
|
||||
$ids = $request->selected_id;
|
||||
|
||||
@@ -10,6 +10,7 @@ use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Helpers\onesignalhelper;
|
||||
use App\Models\ManageState;
|
||||
use App\Models\Subscriptions;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ManageNotificationsController extends Controller
|
||||
@@ -25,6 +26,7 @@ class ManageNotificationsController extends Controller
|
||||
|
||||
if ($activeQuery == 4) { // for customer
|
||||
$notifications = NotificationDetails::with('Notification')
|
||||
->where('is_active', 1)
|
||||
->whereHas('Notification', function ($query) {
|
||||
$query->where('principal_type_xid', 3);
|
||||
})
|
||||
@@ -33,6 +35,7 @@ class ManageNotificationsController extends Controller
|
||||
->get();
|
||||
} else if ($activeQuery == 3) { // for restaurant
|
||||
$notifications = NotificationDetails::with('Notification')
|
||||
->where('is_active', 1)
|
||||
->whereHas('Notification', function ($query) {
|
||||
$query->where('principal_type_xid', 4);
|
||||
})
|
||||
@@ -43,6 +46,7 @@ class ManageNotificationsController extends Controller
|
||||
// return $notifications;
|
||||
} else {
|
||||
$notificationsOfType3 = NotificationDetails::with('Notification')
|
||||
->where('is_active', 1)
|
||||
->whereHas('Notification', function ($query) {
|
||||
$query->where('principal_type_xid', 3);
|
||||
})
|
||||
@@ -51,6 +55,7 @@ class ManageNotificationsController extends Controller
|
||||
->get();
|
||||
|
||||
$notificationsOfType4 = NotificationDetails::with('Notification')
|
||||
->where('is_active', 1)
|
||||
->whereHas('Notification', function ($query) {
|
||||
$query->where('principal_type_xid', 4);
|
||||
})
|
||||
@@ -80,6 +85,7 @@ class ManageNotificationsController extends Controller
|
||||
* Created at : 10 June 2024
|
||||
* Use : To add notification .
|
||||
*/
|
||||
|
||||
public function store_notificaton_data(Request $request)
|
||||
{
|
||||
try {
|
||||
@@ -102,61 +108,144 @@ class ManageNotificationsController extends Controller
|
||||
|
||||
$states = $request->states;
|
||||
|
||||
$userQuery = IamPrincipal::where('is_active', 1)
|
||||
$dateTime = now();
|
||||
$formattedDateTime = $dateTime->format('Y-m-d H:i:s');
|
||||
$iamPrincipals = Subscriptions::select('iam_principal_xid')
|
||||
->where('next_payment_date', '>=', $formattedDateTime)
|
||||
->get();
|
||||
|
||||
$iamPrincipalIds = $iamPrincipals->pluck('iam_principal_xid');
|
||||
|
||||
$subscribe = IamPrincipal::whereIn('id', $iamPrincipalIds)
|
||||
->where('is_active', 1)
|
||||
->where('notification_status', 1)
|
||||
->where('principal_type_xid', 3)
|
||||
->whereIn('state_xid', $states);
|
||||
->whereIn('state_xid', $states)
|
||||
->get();
|
||||
|
||||
if ($request->user_type == 1) {
|
||||
$allCustomerOneSignalIds = $userQuery->pluck('id');
|
||||
$allCustomerOneSignalIds = $subscribe->pluck('id');
|
||||
$UserData = IamPrincipal::whereIn('id', $allCustomerOneSignalIds)->get();
|
||||
|
||||
foreach ($UserData as $customerIdItem) {
|
||||
if ($customerIdItem->one_signal_player_id) {
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$customerIdItem->one_signal_player_id,
|
||||
$request->title,
|
||||
$request->description,
|
||||
'Dashboard Notification',
|
||||
$imagePath,
|
||||
$id = null
|
||||
);
|
||||
// user_type 1 = subscribed user
|
||||
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
|
||||
// Scheduled Notification
|
||||
NotificationDetails::create([
|
||||
'principal_xid' => $customerIdItem->id,
|
||||
'description' => $request->description,
|
||||
'type' => $request->title,
|
||||
'image' => $imagePath,
|
||||
'date_added' => $request->schedule_date,
|
||||
'is_schedule' => 1,
|
||||
'delivery_schedule' => $request->schedule_date,
|
||||
'is_active' => 0,
|
||||
|
||||
]);
|
||||
} else {
|
||||
// Immediate Notification
|
||||
if ($customerIdItem->one_signal_player_id) {
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$customerIdItem->one_signal_player_id,
|
||||
$request->title,
|
||||
$request->description,
|
||||
'Dashboard Notification',
|
||||
$imagePath,
|
||||
$id = null
|
||||
);
|
||||
}
|
||||
onesignalhelper::StoreNotificationDetails($customerIdItem->id, 'Notification', $request->title, $imagePath);
|
||||
}
|
||||
onesignalhelper::StoreNotificationDetails($customerIdItem->id, 'Notification', $request->title, $imagePath);
|
||||
}
|
||||
} elseif ($request->user_type == 2) {
|
||||
$allRestaurantOneSignalIds = $userQuery->pluck('id');
|
||||
//user_type 2 unsubscribed users
|
||||
$allPrincipalIds = IamPrincipal::where('principal_type_xid', 3)
|
||||
->pluck('id');
|
||||
|
||||
$subscribedIds = Subscriptions::select('iam_principal_xid')
|
||||
->where('next_payment_date', '>=', $formattedDateTime)
|
||||
->pluck('iam_principal_xid');
|
||||
|
||||
$unsubscribedIds = $allPrincipalIds->diff($subscribedIds);
|
||||
|
||||
$unsubscribedPrincipals = IamPrincipal::whereIn('id', $unsubscribedIds)
|
||||
->where('is_active', 1)
|
||||
->where('notification_status', 1)
|
||||
->whereIn('state_xid', $states)
|
||||
->get();
|
||||
|
||||
$allRestaurantOneSignalIds = $unsubscribedPrincipals->pluck('id');
|
||||
$restaurantData = IamPrincipal::whereIn('id', $allRestaurantOneSignalIds)->get();
|
||||
|
||||
foreach ($restaurantData as $restIdItem) {
|
||||
if ($restIdItem->one_signal_player_id) {
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$restIdItem->one_signal_player_id,
|
||||
$request->title,
|
||||
$request->description,
|
||||
'Dashboard Notification',
|
||||
$imagePath,
|
||||
$id = null
|
||||
);
|
||||
foreach ($restaurantData as $restaurantsData) {
|
||||
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
|
||||
// Scheduled Notification
|
||||
NotificationDetails::create([
|
||||
'principal_xid' => $restaurantsData->id,
|
||||
'description' => $request->description,
|
||||
'type' => $request->title,
|
||||
'image' => $imagePath,
|
||||
'date_added' => $request->schedule_date,
|
||||
'is_schedule' => 1,
|
||||
'delivery_schedule' => $request->schedule_date,
|
||||
'is_active' => 0,
|
||||
|
||||
|
||||
]);
|
||||
} else {
|
||||
// Immediate Notification
|
||||
if ($restaurantsData->one_signal_player_id) {
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$restaurantsData->one_signal_player_id,
|
||||
$request->title,
|
||||
$request->description,
|
||||
$request->title,
|
||||
$imagePath,
|
||||
$id = null
|
||||
);
|
||||
}
|
||||
onesignalhelper::StoreNotificationDetails($restaurantsData->id, 'Notification', $request->title, $imagePath);
|
||||
}
|
||||
onesignalhelper::StoreNotificationDetails($restIdItem->id, 'Notification', $request->title, $imagePath);
|
||||
}
|
||||
} elseif ($request->user_type == 3) {
|
||||
// user_type 3 = subscribed and unsubscribed users
|
||||
$userQuery = IamPrincipal::where('is_active', 1)
|
||||
->where('notification_status', 1)
|
||||
->where('principal_type_xid', 3)
|
||||
->whereIn('state_xid', $states);
|
||||
|
||||
$allUserOneSignalIds = $userQuery->pluck('id');
|
||||
$UserData = IamPrincipal::whereIn('id', $allUserOneSignalIds)->get();
|
||||
|
||||
foreach ($UserData as $userItem) {
|
||||
if ($userItem->one_signal_player_id) {
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$userItem->one_signal_player_id,
|
||||
$request->title,
|
||||
$request->description,
|
||||
'Dashboard Notification',
|
||||
$imagePath,
|
||||
$id = null
|
||||
);
|
||||
foreach ($UserData as $CustomerData) {
|
||||
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
|
||||
// Scheduled Notification
|
||||
NotificationDetails::create([
|
||||
'principal_xid' => $CustomerData->id,
|
||||
'description' => $request->description,
|
||||
'type' => $request->title,
|
||||
'image' => $imagePath,
|
||||
'date_added' => $request->schedule_date,
|
||||
'is_schedule' => 1,
|
||||
'delivery_schedule' => $request->schedule_date,
|
||||
'is_active' => 0,
|
||||
|
||||
|
||||
]);
|
||||
} else {
|
||||
// Immediate Notification
|
||||
if ($CustomerData->one_signal_player_id) {
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$CustomerData->one_signal_player_id,
|
||||
$request->title,
|
||||
$request->description,
|
||||
'Dashboard Notification',
|
||||
$imagePath,
|
||||
$id = null
|
||||
);
|
||||
}
|
||||
onesignalhelper::StoreNotificationDetails($CustomerData->id, 'Notification', $request->title, $imagePath);
|
||||
}
|
||||
onesignalhelper::StoreNotificationDetails($userItem->id, 'Notification', $request->title, $imagePath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,6 +261,7 @@ class ManageNotificationsController extends Controller
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Created By : Sayli Raut
|
||||
* Created at : 10 June 2024
|
||||
|
||||
@@ -21,19 +21,19 @@ class onesignalhelper
|
||||
'contents' => ['en' => $message],
|
||||
'headings' => ['en' => $title],
|
||||
'content_available' => true,
|
||||
'data' => [
|
||||
'content_type' => $content_type,
|
||||
'id' => $id,
|
||||
],
|
||||
// 'data' => [
|
||||
// 'content_type' => $content_type,
|
||||
// 'id' => $id,
|
||||
// ],
|
||||
'big_picture' => $imageUrl,
|
||||
|
||||
'external_id' => [$playerId]
|
||||
// 'external_id' => [$playerId],
|
||||
// 'authorization' => env('ONE_SIGNAL_AUTHORIZE')
|
||||
];
|
||||
|
||||
$result = OneSignal::sendPush($fields, null ,env('ONE_SIGNAL_APP_ID'));
|
||||
// Log::info($result);
|
||||
|
||||
Log::info("Notification sending To " . $playerId);
|
||||
Log::info($result);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,13 +66,6 @@ class onesignalhelper
|
||||
try {
|
||||
$currentUtcTime = Carbon::now();
|
||||
|
||||
// $data = new NotificationDetails();
|
||||
// $data->principal_xid = $customerId;
|
||||
// $data->type = $type;
|
||||
// $data->date_added = $currentUtcTime;
|
||||
// $data->description = $description;
|
||||
// $data->save();
|
||||
|
||||
$newRecord = NotificationDetails::create([
|
||||
'principal_xid' => $customerId,
|
||||
'type' => $type,
|
||||
|
||||
@@ -11,7 +11,7 @@ class NotificationDetails extends Model
|
||||
protected $table = "notification_details";
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'principal_xid', 'type', 'description', 'image', 'date_added'
|
||||
'principal_xid', 'type', 'description', 'image', 'date_added','is_schedule','delivery_schedule','is_active'
|
||||
];
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
@@ -12,6 +12,19 @@ class SubscriptionProducts extends Model
|
||||
protected $table = 'subscription_products';
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
protected $fillable =[
|
||||
'id',
|
||||
'product_name',
|
||||
'product_value',
|
||||
'product_details',
|
||||
'stripe_product_id',
|
||||
'stripe_price_id',
|
||||
'is_active',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'modified_by',
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,30 @@ class Subscriptions extends Model
|
||||
|
||||
protected $table = 'subscriptions';
|
||||
protected $guarded = [];
|
||||
protected $fillable =
|
||||
[
|
||||
'id',
|
||||
'subscription_product_xid',
|
||||
'iam_principal_xid',
|
||||
'amount',
|
||||
'stripe_customer_id',
|
||||
'payment_intent_id',
|
||||
'payment_intent_client_secret',
|
||||
'subscription_id',
|
||||
'subscription_status',
|
||||
'current_period_start',
|
||||
'current_period_end',
|
||||
'status',
|
||||
'next_payment_date',
|
||||
'is_cancelled_subscription',
|
||||
'cancelled_at',
|
||||
'is_active',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'modified_by',
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
|
||||
public function subscription()
|
||||
{
|
||||
@@ -19,11 +43,8 @@ class Subscriptions extends Model
|
||||
|
||||
|
||||
|
||||
public function iamPrincipal()
|
||||
{
|
||||
return $this->belongsTo(IamPrincipal::class, 'iam_principal_xid', 'id');
|
||||
public function iamPrincipal()
|
||||
{
|
||||
return $this->belongsTo(IamPrincipal::class, 'iam_principal_xid', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -112,8 +112,7 @@ class RestaurantApiServices
|
||||
public function DetailRestaurant($customerIamId, $id)
|
||||
{
|
||||
try {
|
||||
$rest = ManageRestaurant::with('operatingHours')->select('id', 'short_id', 'name', 'description', 'restaurant_id', 'address', 'image', 'bio', 'try_on_1', 'try_on_2', 'try_on_3', 'try_on_4', 'exclusion', 'latitude', 'longtitude')->where('short_id', $id)->where('is_active', '1')->first();
|
||||
|
||||
$rest = ManageRestaurant::with('operatingHours')->select('id', 'short_id', 'name', 'description', 'restaurant_id', 'address', 'image', 'bio', 'try_on_1', 'try_on_2', 'try_on_3', 'try_on_4', 'exclusion', 'latitude', 'longtitude', 'state_xid')->where('short_id', $id)->where('is_active', '1')->first();
|
||||
if ($rest) {
|
||||
$rest->image = ListingImageUrl('restaurant_images', $rest->image);
|
||||
|
||||
@@ -127,9 +126,19 @@ class RestaurantApiServices
|
||||
->where('is_redeem', "1")
|
||||
->first();
|
||||
|
||||
$Timeinterval = TimeInterval::where('manage_state_xid', $rest->state_xid)->first();
|
||||
$restTime = RestaurantTimeInterval::where('manage_restaurants_xid', $rest->id)->first();
|
||||
|
||||
$timeIntervalHours = $Timeinterval->time_hours;
|
||||
$restTimeHours = $restTime->time_hours;
|
||||
|
||||
$greaterTime = max($timeIntervalHours, $restTimeHours);
|
||||
|
||||
|
||||
|
||||
if ($redeem) {
|
||||
$rest->is_Redeemed = true;
|
||||
$rest->redeem_date = \Carbon\Carbon::parse($redeem->redeem_date)->addHours(4)->toDateTimeString();
|
||||
$rest->redeem_date = \Carbon\Carbon::parse($redeem->redeem_date)->addHours($greaterTime)->toDateTimeString();
|
||||
} else {
|
||||
$rest->is_Redeemed = false;
|
||||
$rest->redeem_date = null;
|
||||
@@ -252,6 +261,7 @@ class RestaurantApiServices
|
||||
|
||||
// Count the redeems within the state interval
|
||||
$redeemCountState = RedeemRestaurant::where('state_xid', $restaurant->state_xid)
|
||||
->where('iam_principal_xid', $customerIamId)
|
||||
->count();
|
||||
|
||||
if ($redeemCountState >= $stateMaxLimitation) {
|
||||
@@ -263,6 +273,8 @@ class RestaurantApiServices
|
||||
|
||||
// Count the redeems within the restaurant interval
|
||||
$redeemCountRestaurant = RedeemRestaurant::where('manage_restaurants_xid', $restaurant->id)
|
||||
->where('is_redeem', 1)
|
||||
->where('iam_principal_xid', $customerIamId)
|
||||
->count();
|
||||
|
||||
if ($redeemCountRestaurant >= $restaurantMaxLimitation) {
|
||||
@@ -271,6 +283,7 @@ class RestaurantApiServices
|
||||
|
||||
// Get the last redeem time
|
||||
$lastRedeem = RedeemRestaurant::where('iam_principal_xid', $customerIamId)
|
||||
->where('is_redeem', 1)
|
||||
->orderBy('redeem_date', 'desc')
|
||||
->first();
|
||||
|
||||
|
||||
@@ -40,28 +40,40 @@ class RestaurantApi_Service
|
||||
->where('principal_xid', $userDetail->id)
|
||||
->get();
|
||||
|
||||
// $restaurantDetails = [];
|
||||
$restaurantDetails = [];
|
||||
$isActive = true;
|
||||
$inactiveMessage = "";
|
||||
|
||||
foreach ($restaurantRoles as $restaurantRole) {
|
||||
$restaurant = ManageRestaurant::select('id', 'name', 'description', 'restaurant_id', 'address', 'image', 'bio', 'try_on_1', 'phone_number', 'try_on_2', 'try_on_3', 'try_on_4', 'exclusion', 'latitude', 'longtitude', 'is_active', 'created_by', 'modified_by', 'deleted_at', 'created_at', 'updated_at')
|
||||
->where('id', $restaurantRole->restaurant_xid)
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
if ($restaurant) {
|
||||
$restaurant->image = ListingImageUrl('restaurant_images', $restaurant->image);
|
||||
$restaurant->description = strip_tags($restaurant->description);
|
||||
|
||||
// $restaurantDetails[] = $restaurant;
|
||||
if ($restaurant->is_active == 0) {
|
||||
$isActive = false;
|
||||
$inactiveMessage = "Your restaurant is currently not participating in Cheers to the Season. Please reach out to contact@cheerstotheseason.com to re-enroll.";
|
||||
}
|
||||
|
||||
// Add restaurant details to the array
|
||||
$restaurantDetails[] = $restaurant;
|
||||
}
|
||||
}
|
||||
|
||||
// Construct response
|
||||
$response = [
|
||||
'user_detail' => $userDetail,
|
||||
'restaurant_details' => $restaurant,
|
||||
'restaurant_details' => $restaurantDetails,
|
||||
'is_active' => $isActive,
|
||||
];
|
||||
|
||||
if (!$isActive) {
|
||||
$response['message'] = $inactiveMessage;
|
||||
}
|
||||
|
||||
// Return JSON response with success message
|
||||
return jsonResponseWithSuccessMessageApi(__('auth.User_details_fetch'), $response, 200);
|
||||
} catch (Exception $ex) {
|
||||
@@ -74,6 +86,7 @@ class RestaurantApi_Service
|
||||
|
||||
|
||||
|
||||
|
||||
public function updateRestaurantDetail($restIamId, $request)
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -37,6 +37,7 @@ return Application::configure(basePath: dirname(__DIR__))
|
||||
})
|
||||
->withSchedule(function (Schedule $schedule) {
|
||||
$schedule->command('app:reinstate-restaurant')->everyMinute();
|
||||
$schedule->command('app:sent-schedule-notification')->everyMinute();
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions) {
|
||||
//
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
@extends('Admin.layouts.master')
|
||||
@section('content')
|
||||
@php
|
||||
$currentPage = 'dashboard';
|
||||
@endphp
|
||||
<div class="layout-px-spacing">
|
||||
<div class="middle-content container-xxl p-0">
|
||||
<div class="row layout-top-spacing ">
|
||||
<div class="top-tabel">
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<h6 class="card-title">Dashboard</h6>
|
||||
@php
|
||||
$currentPage = 'dashboard';
|
||||
@endphp
|
||||
<div class="layout-px-spacing">
|
||||
<div class="middle-content container-xxl p-0">
|
||||
<div class="row layout-top-spacing ">
|
||||
<div class="top-tabel">
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<h6 class="card-title">Dashboard</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 d-flex align-items-center gap-3 p-0 mb-4">
|
||||
<div class="col-6">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<a href="{{ route('manage.customer') }}">
|
||||
<h5>No of Customers</h5>
|
||||
<h2 class="m-0 font-weight-bold">{{ $customerCount }}</h2>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 d-flex align-items-center gap-3 p-0 mb-4">
|
||||
<div class="col-6">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<a href="{{ route('manage.customer') }}">
|
||||
<h5>No of Customers</h5>
|
||||
<h2 class="m-0 font-weight-bold">{{ $customerCount }}</h2>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{-- <div class="col-6">
|
||||
{{-- <div class="col-6">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
|
||||
@@ -105,7 +105,7 @@
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5>Recent Transactions</h5>
|
||||
<form method="POST" id="customer-form">
|
||||
<form action="{{ route('export.recent.transactions') }}" method="POST" id="customer-form">
|
||||
@csrf
|
||||
<input type="hidden" name="selected_id" id="ids" disabled>
|
||||
<input type="hidden" name="all_id" id="all_id" value="all" disabled>
|
||||
@@ -170,46 +170,43 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="payment-details-modal" tabindex="-1" role="dialog"
|
||||
aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document" style="max-width: 550px;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<div class="modal-header d-flex justify-content-between modal-title">
|
||||
<h5>View Details</h5>
|
||||
<button type="button pointer" class="btn-close" data-dismiss="modal"
|
||||
aria-label="Close">
|
||||
x
|
||||
</button>
|
||||
</div>
|
||||
<div class="row" style="padding: 0px 10px;">
|
||||
<div class="form-group subadmin-option col-md-12">
|
||||
<div class="payment-main-div">
|
||||
<div class="payment-inn-div">
|
||||
<p><strong>Name:</strong></p><span></span>
|
||||
</div>
|
||||
<div class="payment-inn-div">
|
||||
<p><strong>Price:</strong></p><span></span>
|
||||
</div>
|
||||
<div class="payment-inn-div">
|
||||
<p><strong>Subscription ID:</strong></p><span></span>
|
||||
</div>
|
||||
<div class="payment-inn-div">
|
||||
<p><strong>Stripe Customer Id:</strong></p><span></span>
|
||||
</div>
|
||||
<div class="payment-inn-div">
|
||||
<p><strong>Subscription Status:</strong></p><span></span>
|
||||
</div>
|
||||
<div class="payment-inn-div">
|
||||
<p><strong>Current Start Period:</strong></p><span></span>
|
||||
</div>
|
||||
<div class="payment-inn-div">
|
||||
<p><strong>Current End Period:</strong></p><span></span>
|
||||
</div>
|
||||
<div class="payment-inn-div">
|
||||
<p><strong>Next Period Date:</strong></p><span></span>
|
||||
</div>
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="payment-details-modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document" style="max-width: 550px;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<div class="modal-header d-flex justify-content-between modal-title">
|
||||
<h5>View Details</h5>
|
||||
<button type="button pointer" class="btn-close" data-dismiss="modal" aria-label="Close">
|
||||
x
|
||||
</button>
|
||||
</div>
|
||||
<div class="row" style="padding: 0px 10px;">
|
||||
<div class="form-group subadmin-option col-md-12">
|
||||
<div class="payment-main-div">
|
||||
<div class="payment-inn-div">
|
||||
<p><strong>Name:</strong></p><span></span>
|
||||
</div>
|
||||
<div class="payment-inn-div">
|
||||
<p><strong>Price:</strong></p><span></span>
|
||||
</div>
|
||||
<div class="payment-inn-div">
|
||||
<p><strong>Subscription ID:</strong></p><span></span>
|
||||
</div>
|
||||
<div class="payment-inn-div">
|
||||
<p><strong>Stripe Customer Id:</strong></p><span></span>
|
||||
</div>
|
||||
<div class="payment-inn-div">
|
||||
<p><strong>Subscription Status:</strong></p><span></span>
|
||||
</div>
|
||||
<div class="payment-inn-div">
|
||||
<p><strong>Current Start Period:</strong></p><span></span>
|
||||
</div>
|
||||
<div class="payment-inn-div">
|
||||
<p><strong>Current End Period:</strong></p><span></span>
|
||||
</div>
|
||||
<div class="payment-inn-div">
|
||||
<p><strong>Next Period Date:</strong></p><span></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -217,123 +214,146 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('section_script')
|
||||
<script>
|
||||
$('#zero-config').DataTable({
|
||||
"dom": "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'f>>>" +
|
||||
"<'table-responsive'tr>" +
|
||||
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
|
||||
"oLanguage": {
|
||||
"oPaginate": {
|
||||
"sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>',
|
||||
"sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>'
|
||||
},
|
||||
"sInfo": "Showing page PAGE of _PAGES_",
|
||||
"sSearch": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
|
||||
"sSearchPlaceholder": "Search...",
|
||||
"sLengthMenu": "Results : _MENU_",
|
||||
<script>
|
||||
$('#zero-config').DataTable({
|
||||
"dom": "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'f>>>" +
|
||||
"<'table-responsive'tr>" +
|
||||
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
|
||||
"oLanguage": {
|
||||
"oPaginate": {
|
||||
"sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>',
|
||||
"sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>'
|
||||
},
|
||||
"stripeClasses": [],
|
||||
"lengthMenu": [7, 10, 20, 50],
|
||||
"pageLength": 10
|
||||
});
|
||||
"sInfo": "Showing page PAGE of _PAGES_",
|
||||
"sSearch": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
|
||||
"sSearchPlaceholder": "Search...",
|
||||
"sLengthMenu": "Results : _MENU_",
|
||||
},
|
||||
"stripeClasses": [],
|
||||
"lengthMenu": [7, 10, 20, 50],
|
||||
"pageLength": 10
|
||||
});
|
||||
|
||||
$('#zero-config2').DataTable({
|
||||
"dom": "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'f>>>" +
|
||||
"<'table-responsive'tr>" +
|
||||
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
|
||||
"oLanguage": {
|
||||
"oPaginate": {
|
||||
"sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>',
|
||||
"sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>'
|
||||
},
|
||||
"sInfo": "Showing page PAGE of _PAGES_",
|
||||
"sSearch": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
|
||||
"sSearchPlaceholder": "Search...",
|
||||
"sLengthMenu": "Results : _MENU_",
|
||||
$('#zero-config2').DataTable({
|
||||
"dom": "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'f>>>" +
|
||||
"<'table-responsive'tr>" +
|
||||
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
|
||||
"oLanguage": {
|
||||
"oPaginate": {
|
||||
"sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>',
|
||||
"sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>'
|
||||
},
|
||||
"stripeClasses": [],
|
||||
"lengthMenu": [7, 10, 20, 50],
|
||||
"pageLength": 10
|
||||
"sInfo": "Showing page PAGE of _PAGES_",
|
||||
"sSearch": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
|
||||
"sSearchPlaceholder": "Search...",
|
||||
"sLengthMenu": "Results : _MENU_",
|
||||
},
|
||||
"stripeClasses": [],
|
||||
"lengthMenu": [7, 10, 20, 50],
|
||||
"pageLength": 10
|
||||
});
|
||||
|
||||
|
||||
$(function(e) {
|
||||
$("#select-all-ids").click(function() {
|
||||
$(".form-check-input").prop('checked', $(this).prop('checked'));
|
||||
});
|
||||
|
||||
|
||||
$(function(e) {
|
||||
$("#select-all-ids").click(function() {
|
||||
$(".form-check-input").prop('checked', $(this).prop('checked'));
|
||||
});
|
||||
|
||||
$(".form-check-input").click(function() {
|
||||
if (!$(this).prop('checked')) {
|
||||
$("#select-all-ids").prop('checked', false);
|
||||
} else {
|
||||
if ($(".form-check-input:checked").length === $(".form-check-input").length) {
|
||||
$("#select-all-ids").prop('checked', true);
|
||||
}
|
||||
$(".form-check-input").click(function() {
|
||||
if (!$(this).prop('checked')) {
|
||||
$("#select-all-ids").prop('checked', false);
|
||||
} else {
|
||||
if ($(".form-check-input:checked").length === $(".form-check-input").length) {
|
||||
$("#select-all-ids").prop('checked', true);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("click", "#download-selected", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var allIds = [];
|
||||
|
||||
// Iterate over each page of the DataTable
|
||||
var table = $('#zero-config').DataTable();
|
||||
for (var i = 0; i < table.page.info().pages; i++) {
|
||||
table.page(i).draw(false); // Switch to page i
|
||||
$('#zero-config tbody input:checked').each(function() {
|
||||
allIds.push($(this).val());
|
||||
});
|
||||
}
|
||||
|
||||
if (allIds.length > 0) {
|
||||
// If there are selected customers
|
||||
$('#ids').prop('disabled', false);
|
||||
$('#all_id').prop('disabled', true);
|
||||
$('#ids').val(allIds);
|
||||
// Now submit the form or perform download action
|
||||
$('#customer-form').submit(); // Or perform your download action here
|
||||
} else {
|
||||
// No customers selected
|
||||
toastr.error("Please select at least one customer to download.");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$(document).on("click", "#download_all", function(e) {
|
||||
$('#all_id').prop('disabled', false);
|
||||
$('#ids').prop('disabled', true);
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("click", ".more", function(e) {
|
||||
$(document).on("click", "#download-selected", function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('<button><ul class="navbar-item flex-row ms-lg-auto ms-0"><li class="nav-item dropdown action-dropdown order-lg-0 order-1"><a href="javascript:void(0);"class="nav-link dropdown-toggle user extra-btn" id="actionDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><div class="avatar-container"><div class="avatar avatar-sm avatar-mid avatar-indicators avatar-online"><h3>Export</h3></div></div></a><div class="dropdown-menu position-absolute" aria-labelledby="actionDropdown"><div class="dropdown-item"><a href="javascript:void(0)" id="download_all"><span>Download Overview</span></a></div><div class="dropdown-item"><a href="javascript:void(0)" id="download-selected"><span id="export">Download Selected</span></a></div></div></li></ul></button>')
|
||||
.insertBefore("#zero-config_filter label");
|
||||
|
||||
$("#zero-config").on("click", ".sub_admin_permission", function() {
|
||||
var Name = $(this).data('name');
|
||||
var Price = $(this).data('price');
|
||||
var SubID = $(this).data('subscription-id');
|
||||
var CustID = $(this).data('customer-id');
|
||||
var SubStatus = $(this).data('subscription-status');
|
||||
var startDate = $(this).data('start-date');
|
||||
var endDate = $(this).data('end-date');
|
||||
var nextDate = $(this).data('next-date');
|
||||
var formattedPrice = '$' + Price;
|
||||
var allIds = [];
|
||||
|
||||
// Iterate over each page of the DataTable
|
||||
var table = $('#zero-config').DataTable();
|
||||
for (var i = 0; i < table.page.info().pages; i++) {
|
||||
table.page(i).draw(false); // Switch to page i
|
||||
$('#zero-config tbody input:checked').each(function() {
|
||||
allIds.push($(this).val());
|
||||
});
|
||||
}
|
||||
|
||||
if (allIds.length > 0) {
|
||||
// If there are selected customers
|
||||
$('#ids').prop('disabled', false);
|
||||
$('#all_id').prop('disabled', true);
|
||||
$('#ids').val(allIds);
|
||||
// Now submit the form or perform download action
|
||||
$('#customer-form').submit(); // Or perform your download action here
|
||||
} else {
|
||||
// No customers selected
|
||||
toastr.error("Please select at least one customer to download.");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$(document).on("click", "#download_all", function(e) {
|
||||
$('#all_id').prop('disabled', false);
|
||||
$('#ids').prop('disabled', true);
|
||||
})
|
||||
});
|
||||
|
||||
$(document).on("click", ".more", function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// $('<button><ul class="navbar-item flex-row ms-lg-auto ms-0"><li class="nav-item dropdown action-dropdown order-lg-0 order-1"><a href="javascript:void(0);"class="nav-link dropdown-toggle user extra-btn" id="actionDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><div class="avatar-container"><div class="avatar avatar-sm avatar-mid avatar-indicators avatar-online"><h3>Export</h3></div></div></a><div class="dropdown-menu position-absolute" aria-labelledby="actionDropdown"><div class="dropdown-item"><a href="javascript:void(0)" id="download_all"><span>Download Overview</span></a></div><div class="dropdown-item"><a href="javascript:void(0)" id="download-selected"><span id="export">Download Selected</span></a></div></div></li></ul></button>')
|
||||
// .insertBefore("#zero-config_filter label");
|
||||
$('<button>' +
|
||||
'<ul class="navbar-item flex-row ms-lg-auto ms-0">' +
|
||||
'<li class="nav-item dropdown action-dropdown order-lg-0 order-1">' +
|
||||
'<a href="javascript:void(0);" class="nav-link dropdown-toggle user extra-btn" id="actionDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' +
|
||||
'<div class="avatar-container">' +
|
||||
'<div class="avatar avatar-sm avatar-mid avatar-indicators avatar-online">' +
|
||||
'<h3>Export</h3>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</a>' +
|
||||
'<div class="dropdown-menu position-absolute" aria-labelledby="actionDropdown">' +
|
||||
'<div class="dropdown-item">' +
|
||||
'<a href="javascript:void(0)" id="download_all"><span>Download Overview</span></a>' +
|
||||
'</div>' +
|
||||
'<div class="dropdown-item">' +
|
||||
'<a href="javascript:void(0)" id="download-selected"><span id="export">Download Selected</span></a>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</li>' +
|
||||
'</ul>' +
|
||||
'</button>').insertBefore("#zero-config_filter label");
|
||||
|
||||
|
||||
$("#zero-config").on("click", ".sub_admin_permission", function() {
|
||||
var Name = $(this).data('name');
|
||||
var Price = $(this).data('price');
|
||||
var SubID = $(this).data('subscription-id');
|
||||
var CustID = $(this).data('customer-id');
|
||||
var SubStatus = $(this).data('subscription-status');
|
||||
var startDate = $(this).data('start-date');
|
||||
var endDate = $(this).data('end-date');
|
||||
var nextDate = $(this).data('next-date');
|
||||
var formattedPrice = '$' + Price;
|
||||
|
||||
$('.subadmin-option span').eq(0).text(Name);
|
||||
$('.subadmin-option span').eq(1).text(formattedPrice);
|
||||
@@ -353,36 +373,36 @@
|
||||
var userChartData = getUserChartData('monthly');
|
||||
var userCategories = getUserChartCategories('monthly');
|
||||
|
||||
// Chart options
|
||||
var userOptions = {
|
||||
chart: {
|
||||
type: 'line',
|
||||
zoom: {
|
||||
enabled: false
|
||||
},
|
||||
toolbar: {
|
||||
show: false
|
||||
}
|
||||
// Chart options
|
||||
var userOptions = {
|
||||
chart: {
|
||||
type: 'line',
|
||||
zoom: {
|
||||
enabled: false
|
||||
},
|
||||
series: userChartData,
|
||||
xaxis: {
|
||||
categories: userCategories
|
||||
},
|
||||
stroke: {
|
||||
curve: 'smooth',
|
||||
width: [4, 4]
|
||||
toolbar: {
|
||||
show: false
|
||||
}
|
||||
};
|
||||
},
|
||||
series: userChartData,
|
||||
xaxis: {
|
||||
categories: userCategories
|
||||
},
|
||||
stroke: {
|
||||
curve: 'smooth',
|
||||
width: [4, 4]
|
||||
}
|
||||
};
|
||||
|
||||
// Create the chart
|
||||
var userChart = new ApexCharts(document.querySelector("#user-chart"), userOptions);
|
||||
userChart.render();
|
||||
// Create the chart
|
||||
var userChart = new ApexCharts(document.querySelector("#user-chart"), userOptions);
|
||||
userChart.render();
|
||||
|
||||
// Event listener for filter select element
|
||||
document.getElementById('graph-filter').addEventListener('change', function(event) {
|
||||
var selectedFilter = event.target.value;
|
||||
userChartData = getUserChartData(selectedFilter);
|
||||
userCategories = getUserChartCategories(selectedFilter);
|
||||
// Event listener for filter select element
|
||||
document.getElementById('graph-filter').addEventListener('change', function(event) {
|
||||
var selectedFilter = event.target.value;
|
||||
userChartData = getUserChartData(selectedFilter);
|
||||
userCategories = getUserChartCategories(selectedFilter);
|
||||
|
||||
userChart.updateSeries(userChartData);
|
||||
userChart.updateOptions({
|
||||
@@ -430,17 +450,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
function getUserChartCategories(filter) {
|
||||
switch (filter) {
|
||||
case 'monthly':
|
||||
return ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
||||
case 'quarterly':
|
||||
return ['Q1', 'Q2', 'Q3', 'Q4'];
|
||||
case 'yearly':
|
||||
return <?php echo json_encode(array_keys($dataYearlyWithType3)); ?>;
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
function getUserChartCategories(filter) {
|
||||
switch (filter) {
|
||||
case 'monthly':
|
||||
return ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
||||
case 'quarterly':
|
||||
return ['Q1', 'Q2', 'Q3', 'Q4'];
|
||||
case 'yearly':
|
||||
return <?php echo json_encode(array_keys($dataYearlyWithType3)); ?>;
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
@@ -186,6 +186,8 @@ $currentPage = 'manage-faq';
|
||||
<option value="">Select</option>
|
||||
<option value="1">Customer</option>
|
||||
<option value="2">Restaurant</option>
|
||||
<option value="3">Subscription</option>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" id="update_faq" class="download-btn-custom mt-4 mx-auto w-25">
|
||||
@@ -231,7 +233,7 @@ $currentPage = 'manage-faq';
|
||||
.insertBefore("#zero-config_filter label");
|
||||
|
||||
// Insert Filter dropdown
|
||||
$('<select id="filter" class="form-control"><option value="all">All</option><option value="1">Customer</option><option value="2">Restaurant</option></select>')
|
||||
$('<select id="filter" class="form-control"><option value="all">All</option><option value="1">Customer</option><option value="2">Restaurant</option><option value="3">Subscription</option></select>')
|
||||
.insertBefore("#zero-config_filter label");
|
||||
|
||||
// Filter FAQ
|
||||
@@ -246,7 +248,7 @@ $currentPage = 'manage-faq';
|
||||
} else {
|
||||
$("#faq-tbody tr").each(function() {
|
||||
var category = $(this).find('td:eq(3)').text().trim();
|
||||
if ((filterValue == 1 && category === 'Customer') || (filterValue == 2 && category === 'Restaurant')) {
|
||||
if ((filterValue == 1 && category === 'Customer') || (filterValue == 2 && category === 'Restaurant') || (filterValue == 3 && category === 'Subscription')) {
|
||||
$(this).show();
|
||||
} else {
|
||||
$(this).hide();
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
<div class="form-check form-check-sm form-check-custom form-check-solid me-3">
|
||||
<input class="form-check-input" type="radio" name="user_type"
|
||||
value="1" id="select-all-ids" />
|
||||
<label class="form-check-label" for="select-all-ids">Send to unsubscribed
|
||||
<label class="form-check-label" for="select-all-ids">Send to subscribed
|
||||
users who are in their respective states</label><br>
|
||||
<div id="dropdown-1"
|
||||
style="display: none; max-height: 200px; overflow-y: auto;">
|
||||
@@ -89,7 +89,8 @@
|
||||
</div>
|
||||
<input class="form-check-input" type="radio" name="user_type"
|
||||
id="select-popular-ids" value="2" />
|
||||
<label class="form-check-label" for="select-popular-ids">Send to subscribed
|
||||
<label class="form-check-label" for="select-popular-ids">Send to
|
||||
unsubscribed
|
||||
users who are in their respective states</label><br>
|
||||
<div id="dropdown-2"
|
||||
style="display: none; max-height: 200px; overflow-y: auto;">
|
||||
@@ -140,32 +141,29 @@
|
||||
<h6>Delivery Schedule</h6>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h6>When should this message start sending ?</h6>
|
||||
<div class="form-group radio-btn ">
|
||||
<h6>When should this message start sending?</h6>
|
||||
<div class="form-group radio-btn">
|
||||
<input type="radio" class="form-control" name="schedule_radio1"
|
||||
id="push_schedule_radi01" value="0">
|
||||
<label for="push_schedule_radi01"
|
||||
class="label">Immediately</label>
|
||||
</div>
|
||||
<div class="form-group radio-btn ">
|
||||
<div class="form-group radio-btn">
|
||||
<input type="radio" class="form-control" name="schedule_radio1"
|
||||
id="push_schedule_radi02" value="1">
|
||||
<label for="push_schedule_radi02" class="label">Specific
|
||||
Time</label>
|
||||
</div>
|
||||
<div class="form-group checkbox-btsss">
|
||||
<div class="form-group checkbox-btsss" style="display: none;">
|
||||
<input type="datetime-local" class="form-control"
|
||||
name="schedule_date" min="{{ date('Y-m-d\TH:i') }}">
|
||||
</div>
|
||||
|
||||
<label id="schedule_radio1-error" class="error-message"
|
||||
for="schedule_radio1"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-12">
|
||||
<button class="download-btn-custom mt-3 custom-width-10" type="submit"
|
||||
id="store_notification_btn">
|
||||
@@ -283,36 +281,46 @@
|
||||
});
|
||||
|
||||
|
||||
$('#push_user_radi01').click(function() {
|
||||
$('.radio-btn-checkbox').hide();
|
||||
$('.radio-btn-checkbox input[type="radio"]').prop('checked', false);
|
||||
});
|
||||
// Hide date and time input by default
|
||||
$('.checkbox-btsss').hide();
|
||||
|
||||
$('#push_user_radi02').click(function() {
|
||||
$('.radio-btn-checkbox').show();
|
||||
});
|
||||
|
||||
// Select specific time zone script
|
||||
// Show/hide date and time input based on radio button selection
|
||||
$('#push_schedule_radi01').click(function() {
|
||||
$('.checkbox-btsss').hide();
|
||||
$('#specificTime').val('');
|
||||
$('input[name="schedule_date"]').val(''); // Clear date and time input
|
||||
});
|
||||
|
||||
$('#push_schedule_radi02').click(function() {
|
||||
$('.checkbox-btsss').show();
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
function handleUserTypeChange() {
|
||||
var dropdown1 = document.getElementById('dropdown-1');
|
||||
var dropdown2 = document.getElementById('dropdown-2');
|
||||
var dropdown3 = document.getElementById('dropdown-3');
|
||||
var dropdowns = [
|
||||
document.getElementById('dropdown-1'),
|
||||
document.getElementById('dropdown-2'),
|
||||
document.getElementById('dropdown-3')
|
||||
];
|
||||
|
||||
dropdown1.style.display = this.value === '1' ? 'block' : 'none';
|
||||
dropdown2.style.display = this.value === '2' ? 'block' : 'none';
|
||||
dropdown3.style.display = this.value === '3' ? 'block' : 'none';
|
||||
dropdowns.forEach(function(dropdown, index) {
|
||||
if (index + 1 == this.value) {
|
||||
dropdown.style.display = 'block';
|
||||
toggleCheckboxes(dropdown, false);
|
||||
} else {
|
||||
dropdown.style.display = 'none';
|
||||
toggleCheckboxes(dropdown, true);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
function toggleCheckboxes(dropdown, disable) {
|
||||
var checkboxes = dropdown.querySelectorAll('.form-check-input');
|
||||
for (var i = 0; i < checkboxes.length; i++) {
|
||||
checkboxes[i].disabled = disable;
|
||||
}
|
||||
}
|
||||
|
||||
var userTypeRadios = document.getElementsByName('user_type');
|
||||
|
||||
@@ -96,20 +96,16 @@ $currentPage = 'manage-reports';
|
||||
|
||||
@section('section_script')
|
||||
<script>
|
||||
// Select the start and end date inputs
|
||||
var startDateInput = document.getElementById("startDate");
|
||||
var endDateInput = document.getElementById("endDate");
|
||||
|
||||
// Initialize Flatpickr for the date range with placeholders
|
||||
flatpickr(startDateInput, {
|
||||
flatpickr("#startDate", {
|
||||
dateFormat: "Y-m-d",
|
||||
onChange: function (selectedDates, dateStr) {
|
||||
// Set the minimum date for the end date input
|
||||
endDatePicker.set("minDate", dateStr);
|
||||
flatpickr("#endDate").set("minDate", dateStr);
|
||||
}
|
||||
});
|
||||
|
||||
var endDatePicker = flatpickr(endDateInput, {
|
||||
flatpickr("#endDate", {
|
||||
dateFormat: "Y-m-d",
|
||||
});
|
||||
|
||||
@@ -121,6 +117,7 @@ $currentPage = 'manage-reports';
|
||||
checkboxDiv.querySelectorAll('.state-checkbox').forEach(function(checkbox) {
|
||||
checkbox.disabled = true;
|
||||
});
|
||||
checkboxDiv.querySelector('.check-all').disabled = true;
|
||||
});
|
||||
var selectedPoint = this.value;
|
||||
document.querySelectorAll('.state-checkboxes[data-point="' + selectedPoint + '"]').forEach(function(checkboxDiv) {
|
||||
@@ -128,6 +125,7 @@ $currentPage = 'manage-reports';
|
||||
checkboxDiv.querySelectorAll('.state-checkbox').forEach(function(checkbox) {
|
||||
checkbox.disabled = false;
|
||||
});
|
||||
checkboxDiv.querySelector('.check-all').disabled = false;
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -142,8 +140,48 @@ $currentPage = 'manage-reports';
|
||||
});
|
||||
});
|
||||
|
||||
// Refresh page after download
|
||||
document.getElementById('reportForm').addEventListener('submit', function() {
|
||||
// Form validation before submission
|
||||
document.getElementById('reportForm').addEventListener('submit', function(event) {
|
||||
var selectedRadio = document.querySelector('input[name="reportType"]:checked');
|
||||
var selectedCheckboxes = document.querySelectorAll('.state-checkboxes.show .state-checkbox:checked');
|
||||
var startDate = document.getElementById("startDate").value;
|
||||
var endDate = document.getElementById("endDate").value;
|
||||
|
||||
if (!startDate) {
|
||||
event.preventDefault(); // Prevent form submission
|
||||
toastr.error('Please select a start date.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!endDate) {
|
||||
event.preventDefault(); // Prevent form submission
|
||||
toastr.error('Please select an end date.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!selectedRadio) {
|
||||
event.preventDefault(); // Prevent form submission
|
||||
toastr.error('Please select a report type.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (selectedCheckboxes.length === 0) {
|
||||
event.preventDefault(); // Prevent form submission
|
||||
toastr.error('Please select at least one record.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Add a timeout to ensure the form data is sent before refreshing
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
@@ -152,8 +190,7 @@ $currentPage = 'manage-reports';
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
.state-checkboxes-container {
|
||||
.state-checkboxes-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
<tr>
|
||||
<th>Sr No.</th>
|
||||
<th>Subscription ID</th>
|
||||
<th>User First Name</th>
|
||||
<th>User Last Name</th>
|
||||
<th>User Name</th>
|
||||
<th>State</th>
|
||||
<th>Created At</th>
|
||||
</tr>
|
||||
@@ -24,10 +23,9 @@
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $subscription->id }}</td>
|
||||
<td>{{ $subscription->iamPrincipal->first_name ?? 'N/A' }}</td>
|
||||
<td>{{ $subscription->iamPrincipal->last_name ?? 'N/A' }}</td>
|
||||
<td>{{ $subscription->iamPrincipal->first_name ?? 'N/A' }} {{ $subscription->iamPrincipal->last_name ?? 'N/A' }} </td>
|
||||
<td>{{ $subscription->iamPrincipal->state->name ?? 'N/A' }}</td>
|
||||
<td>{{ $subscription->created_at ?? 'N/A' }}</td>
|
||||
<td>{{\Carbon\Carbon::parse($subscription->created_at)->format('m-d-Y H:i')}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
@@ -38,8 +36,7 @@
|
||||
<tr>
|
||||
<th>Sr No.</th>
|
||||
<th>User ID</th>
|
||||
<th>First Name</th>
|
||||
<th>Last Name</th>
|
||||
<th>User Name</th>
|
||||
<th>State</th>
|
||||
<th>Created At</th>
|
||||
</tr>
|
||||
@@ -49,10 +46,10 @@
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $user->id }}</td>
|
||||
<td>{{ $user->first_name }}</td>
|
||||
<td>{{ $user->last_name }}</td>
|
||||
<td>{{ $user->first_name }} {{ $user->last_name }}</td>
|
||||
<td>{{ $user->state->name }}</td>
|
||||
<td>{{ $user->created_at }}</td>
|
||||
<td>{{ \Carbon\Carbon::parse($user->created_at)->format('m-d-Y H:i') }}</td>
|
||||
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
@@ -77,7 +74,7 @@
|
||||
<td>{{ $redemption->restaurant->name }}</td>
|
||||
<td>{{ $redemption->customer->first_name }} {{ $redemption->customer->last_name }}</td>
|
||||
<td>{{ $redemption->customer->state->name }}</td>
|
||||
<td>{{ $redemption->created_at }}</td>
|
||||
<td>{{\Carbon\Carbon::parse($redemption->created_at)->format('m-d-Y H:i')}} </td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
@@ -102,7 +99,7 @@
|
||||
<td>{{ $redemption->restaurant->name }}</td>
|
||||
<td>{{ $redemption->customer->first_name }} {{ $redemption->customer->last_name }}</td>
|
||||
<td>{{ $redemption->customer->state->name }}</td>
|
||||
<td>{{ $redemption->created_at }}</td>
|
||||
<td>{{\Carbon\Carbon::parse($redemption->created_at)->format('m-d-Y H:i')}} </td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
@@ -128,7 +125,7 @@
|
||||
<td>{{ $item->iamPrincipal->email_address }}</td>
|
||||
<td>{{ $item->iamPrincipal->state->name }}</td>
|
||||
<td>{{ $item->subscription_status }}</td>
|
||||
<td>{{ \Carbon\Carbon::parse($item->cancelled_at)->format('m-d-Y') }}</td>
|
||||
<td>{{ \Carbon\Carbon::parse($item->cancelled_at)->format('m-d-Y H:i') }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ Route::group(['middleware' => ['checkStatus']], function () {
|
||||
|
||||
|
||||
Route::get('/dashboard', [DashboardController::class, 'showDashboard'])->name('dashboard');
|
||||
Route::post('/export/recent-transactions', [DashboardController::class, 'exportRecentTransactions'])->name('export.recent.transactions');
|
||||
|
||||
Route::get('/profile', [ManageProfileController::class, 'index'])->name('profile');
|
||||
Route::post('/update_profile', [ManageProfileController::class, 'update_profile'])->name('update.profile');
|
||||
|
||||
Reference in New Issue
Block a user