diff --git a/app/Http/Middleware/RestrictToRoleOne.php b/app/Http/Middleware/RestrictToRoleOne.php new file mode 100644 index 0000000..4ed279f --- /dev/null +++ b/app/Http/Middleware/RestrictToRoleOne.php @@ -0,0 +1,18 @@ +user(); + if ($user && $user->role == 1) { // Adjust 'role' based on your user model + return $next($request); + } + return redirect('/notifications')->with('error', 'Unauthorized access.'); + } +} \ No newline at end of file diff --git a/app/Livewire/MemberManagement/CardMemberList.php b/app/Livewire/MemberManagement/CardMemberList.php new file mode 100644 index 0000000..1eaf0de --- /dev/null +++ b/app/Livewire/MemberManagement/CardMemberList.php @@ -0,0 +1,51 @@ + '', + ]; + + public $members = []; + + public function mount() + { + $this->fetchMembers(); + } + + public function fetchMembers() + { + $url = 'https://api.example.com/member' . ($this->filters['status'] ? '?status=' . ($this->filters['status'] === 'active' ? 'active' : 'inactive') : ''); + + $this->members = $this->fetchFromApi($url); + } + + public function updatedFilters() + { + $this->resetPage(); + $this->fetchMembers(); + } + + private function fetchFromApi($url) + { + try { + $response = \Http::get($url); + return $response->json()['data'] ?? []; + } catch (\Exception $e) { + session()->flash('error', 'Failed to load members: ' . $e->getMessage()); + return []; + } + } + + public function render() + { + return view('livewire.card-member-list'); + } +} \ No newline at end of file diff --git a/app/Livewire/MemberManagement/CardMemberView.php b/app/Livewire/MemberManagement/CardMemberView.php new file mode 100644 index 0000000..7ace50d --- /dev/null +++ b/app/Livewire/MemberManagement/CardMemberView.php @@ -0,0 +1,31 @@ +member = $this->fetchFromApi("https://api.example.com/member/{$id}"); + } catch (\Exception $e) { + session()->flash('error', 'Failed to load member details: ' . $e->getMessage()); + return redirect()->route('card-members.list'); + } + } + + private function fetchFromApi($url) + { + $response = \Http::get($url); + return $response->json()['data'] ?? null; + } + + public function render() + { + return view('livewire.card-member-view', ['member' => $this->member]); + } +} \ No newline at end of file diff --git a/app/Livewire/MemberManagement/LockAccountList.php b/app/Livewire/MemberManagement/LockAccountList.php new file mode 100644 index 0000000..e32fcd5 --- /dev/null +++ b/app/Livewire/MemberManagement/LockAccountList.php @@ -0,0 +1,47 @@ +user()->role != 1) { + // $this->alert('error', 'Unauthorized access.'); + // return redirect('/'); + // } + $this->fetchAccounts(); + } + + public function fetchAccounts() + { + try { + $response = Http::get('https://api.example.com/member', [ + '_locked' => 1, + '_sort_by' => 'card_number', + '_sort_order' => 'asc', + ]); + if ($response->successful()) { + $this->accounts = $response->json()['data'] ?? []; + } else { + $this->alert('error', 'Failed to fetch locked accounts.'); + } + } catch (\Exception $e) { + $this->alert('error', 'An error occurred: ' . $e->getMessage()); + } + } + + public function render() + { + return view('livewire.member-management.lock-account-list')->layout('layouts.app', ['title' => 'Locked Accounts']); + } +} diff --git a/app/Livewire/MemberManagement/LockAccountView.php b/app/Livewire/MemberManagement/LockAccountView.php new file mode 100644 index 0000000..04b83e9 --- /dev/null +++ b/app/Livewire/MemberManagement/LockAccountView.php @@ -0,0 +1,67 @@ +id = $id; + // Placeholder role check + // if (auth()->user()->role != 1) { + // $this->alert('error', 'Unauthorized access.'); + // return redirect('/member-management/lock-account'); + // } + $this->fetchAccount(); + } + + public function fetchAccount() + { + try { + $response = Http::get("https://api.example.com/member/{$this->id}"); + if ($response->successful()) { + $this->userInfo = $response->json()['data'] ?? null; + } else { + $this->alert('error', 'Failed to fetch account data.'); + return redirect('/member-management/lock-account'); + } + } catch (\Exception $e) { + $this->alert('error', 'An error occurred: ' . $e->getMessage()); + return redirect('/member-management/lock-account'); + } + } + + public function activateAccount() + { + $this->loading = true; + + try { + $response = Http::post("https://api.example.com/memberActivate/{$this->id}"); + if ($response->successful()) { + $this->alert('success', 'Record was successfully updated.'); + return redirect('/member-management/lock-account'); + } else { + $this->alert('error', 'Failed to activate account.'); + } + } catch (\Exception $e) { + $this->alert('error', 'An error occurred: ' . $e->getMessage()); + } finally { + $this->loading = false; + } + } + + public function render() + { + return view('livewire.member-management.lock-account-view')->layout('layouts.app', ['title' => 'Locked Account Details']); + } +} diff --git a/app/Livewire/MyProfile/MyProfileView.php b/app/Livewire/MyProfile/MyProfileView.php new file mode 100644 index 0000000..4b95241 --- /dev/null +++ b/app/Livewire/MyProfile/MyProfileView.php @@ -0,0 +1,50 @@ +fetchProfile(); + } + + public function fetchProfile() + { + try { + $response = Http::post('https://api.example.com/adminProfile'); + if ($response->successful()) { + $this->userInfo = $response->json()['data'] ?? null; + } else { + $this->alert('error', 'Failed to fetch profile data.', ['duration' => 20000]); + $this->userInfo = null; + } + } catch (\Exception $e) { + $this->alert('error', 'An error occurred: ' . $e->getMessage(), ['duration' => 20000]); + $this->userInfo = null; + } + } + + public function getRoleLabel($role) + { + if ($role == '1') { + return 'System Admin'; + } elseif ($role == '3') { + return 'Super Admin'; + } + return 'Marketing Personnel'; + } + + public function render() + { + return view('livewire.my-profile.my-profile-view')->layout('layouts.app', ['title' => 'My Profile']); + } +} \ No newline at end of file diff --git a/app/Livewire/Notifications/NotificationList.php b/app/Livewire/Notifications/NotificationList.php new file mode 100644 index 0000000..3993128 --- /dev/null +++ b/app/Livewire/Notifications/NotificationList.php @@ -0,0 +1,47 @@ +user()->role != 1) { + // $this->alert('error', 'Unauthorized access.'); + // return redirect('/'); // Adjust redirect as needed + // } + $this->fetchNotifications(); + } + + public function fetchNotifications() + { + try { + $this->updating = true; + $response = Http::get('https://api.example.com/notification'); + if ($response->successful()) { + $this->notifications = $response->json()['data'] ?? []; + } else { + $this->alert('error', 'Failed to fetch notifications.'); + } + } catch (\Exception $e) { + $this->alert('error', 'An error occurred: ' . $e->getMessage()); + } finally { + $this->updating = false; + } + } + + public function render() + { + return view('livewire.notifications.notification-list')->layout('layouts.app', ['title' => 'Notifications']); + } +} diff --git a/app/Livewire/Notifications/NotificationsCreate.php b/app/Livewire/Notifications/NotificationsCreate.php new file mode 100644 index 0000000..aafa426 --- /dev/null +++ b/app/Livewire/Notifications/NotificationsCreate.php @@ -0,0 +1,87 @@ + 'required|string|max:255', + 'content' => 'required|string', + 'isScheduled' => 'required|in:true,false', + 'schedule' => 'required_if:isScheduled,true|nullable|date', + 'expiration' => 'required_if:isScheduled,true|nullable|date|after_or_equal:schedule', + ]; + + protected $messages = [ + 'subject.required' => 'Subject is required!', + 'content.required' => 'Content is required!', + 'isScheduled.required' => 'Schedule selection is required!', + 'schedule.required_if' => 'Schedule date is required when scheduled!', + 'expiration.required_if' => 'Expiration date is required when scheduled!', + 'expiration.after_or_equal' => 'Expiration must be on or after the schedule date!', + ]; + + public function mount() + { + // Placeholder role check + // if (auth()->user()->role != 1) { + // $this->alert('error', 'Unauthorized access.'); + // return redirect('/notifications'); + // } + } + + public function save() + { + $this->validate(); + + $this->loading = true; + + try { + $data = [ + 'subject' => $this->subject, + 'content' => $this->content, + 'isScheduled' => $this->isScheduled === 'true', + 'schedule' => $this->isScheduled === 'true' ? $this->schedule : null, + 'expiration' => $this->isScheduled === 'true' ? $this->expiration : null, + ]; + + $response = Http::post('https://api.example.com/notification', $data); + + if ($response->successful()) { + $this->alert('success', 'Notification created successfully!'); + return redirect('/notifications'); + } else { + $this->alert('error', 'Failed to create notification.'); + } + } catch (\Exception $e) { + $this->alert('error', 'An error occurred: ' . $e->getMessage()); + } finally { + $this->loading = false; + } + } + + public function cancel() + { + if (confirm('Are you sure you want to discard changes?')) { + return redirect('/notifications'); + } + } + + public function render() + { + return view('livewire.notifications.notifications-create')->layout('layouts.app', ['title' => 'Add Notification']); + } +} diff --git a/app/Livewire/PhotoSlider/PhotoSlider.php b/app/Livewire/PhotoSlider/PhotoSlider.php new file mode 100644 index 0000000..5d988c3 --- /dev/null +++ b/app/Livewire/PhotoSlider/PhotoSlider.php @@ -0,0 +1,13 @@ + '', + 'title' => '', + 'description' => '', + 'image' => null, + 'date_start' => '', + 'date_end' => '', + 'start_time' => '', + 'end_time' => '', + ]; + public $errors = []; + + public function mount() + { + $this->checkLimit(); + $this->fetchPromotions(); + } + + public function checkLimit() + { + try { + $response = Http::get('https://api.example.com/photoSliderCount'); + $this->photoSliderLimit = $response->json()['data'] >= 10; + } catch (\Exception $e) { + $this->photoSliderLimit = true; + session()->flash('error', 'Failed to check photo slider limit: ' . $e->getMessage()); + } + } + + public function fetchPromotions() + { + try { + $response = Http::get('https://api.example.com/getPromotions'); + $promotions = $response->json()['data'] ?? []; + $this->promotionsOptions = array_map(function ($item) { + return [ + 'label' => $item['title'], + 'value' => $item['promotion_uuid'], + 'date' => [ + 'dateStart' => $item['date_start'], + 'dateEnd' => $item['date_end'], + ], + ]; + }, $promotions); + } catch (\Exception $e) { + session()->flash('error', 'Failed to load promotions: ' . $e->getMessage()); + } + } + + public function fetchDate($id) + { + foreach ($this->promotionsOptions as $option) { + if ($option['value'] == $id) { + $this->dateStartEnd = [ + 'date_start' => $option['date']['dateStart'], + 'date_end' => $option['date']['dateEnd'], + ]; + break; + } + } + } + + public function autoFillDetails($id) + { + try { + $response = Http::get("https://api.example.com/promotion/{$id}"); + $data = $response->json()['data'] ?? []; + $this->form = array_merge($this->form, [ + 'title' => $data['title'] ?? '', + 'description' => $data['description'] ?? '', + 'image' => $data['image'] ?? '', + 'date_start' => Carbon::parse($data['date_start'])->format('Y-m-d'), + 'date_end' => Carbon::parse($data['date_end'])->format('Y-m-d'), + 'start_time' => Carbon::parse($data['date_start'])->format('H:i'), + 'end_time' => Carbon::parse($data['date_end'])->format('H:i'), + ]); + } catch (\Exception $e) { + session()->flash('error', 'Failed to autofill details: ' . $e->getMessage()); + } + } + + public function submit() + { + $this->validateForm(); + + $this->loading = true; + try { + $formData = new \GuzzleHttp\Psr7\MultipartStream([ + [ + 'name' => 'promotion_uuid', + 'contents' => $this->form['promotion_uuid'] ?? '', + ], + [ + 'name' => 'title', + 'contents' => $this->form['title'] ?? '', + ], + [ + 'name' => 'description', + 'contents' => $this->form['description'] ?? '', + ], + [ + 'name' => 'date_start', + 'contents' => Carbon::parse($this->form['date_start'] . ' ' . $this->form['start_time'])->format('Y-m-d\TH:i:s'), + ], + [ + 'name' => 'date_end', + 'contents' => Carbon::parse($this->form['date_end'] . ' ' . $this->form['end_time'])->format('Y-m-d\TH:i:s'), + ], + [ + 'name' => 'image', + 'contents' => $this->form['image'] ? fopen($this->form['image']->getPathname(), 'r') : '', + 'filename' => $this->form['image'] ? $this->form['image']->getClientOriginalName() : '', + ], + ]); + + $response = Http::withHeaders(['Content-Type' => 'multipart/form-data; boundary=' . $formData->getBoundary()]) + ->withBody($formData) + ->post('https://api.example.com/photoSlider'); + + if ($response->successful()) { + session()->flash('success', 'New record added.'); + $this->redirect(route('photo-slider.index')); + } + } catch (\Exception $e) { + session()->flash('error', 'Failed to create record: ' . $e->getMessage()); + } + $this->loading = false; + } + + public function validateForm() + { + $rules = [ + 'title' => 'required|max:128', + 'image' => 'required', + 'date_start' => 'required|date', + 'date_end' => 'required|date', + 'start_time' => 'required', + 'end_time' => 'required', + ]; + + $messages = [ + 'title.required' => 'Title is required!', + 'title.max' => 'Maximum character is 128.', + 'image.required' => 'Upload Image is required!', + 'date_start.required' => 'Start Appearance Date is required!', + 'date_end.required' => 'End Appearance Date is required!', + 'start_time.required' => 'Start Time is required!', + 'end_time.required' => 'End Time is required!', + ]; + + $this->errors = []; + try { + $this->validate($rules, $messages); + } catch (\Exception $e) { + $this->errors = collect($e->errors())->flatten()->toArray(); + throw $e; + } + } + + public function render() + { + return view('livewire.photo-slider.photo-slider-create'); + } +} \ No newline at end of file diff --git a/app/Livewire/PhotoSlider/PhotoSliderEdit.php b/app/Livewire/PhotoSlider/PhotoSliderEdit.php new file mode 100644 index 0000000..f384de9 --- /dev/null +++ b/app/Livewire/PhotoSlider/PhotoSliderEdit.php @@ -0,0 +1,204 @@ + '', + 'title' => '', + 'description' => '', + 'image' => null, + 'date_start' => '', + 'date_end' => '', + 'start_time' => '', + 'end_time' => '', + ]; + public $errors = []; + + public function mount($id) + { + $this->fetchSlider($id); + $this->fetchPromotions(); + } + + public function fetchSlider($id) + { + try { + $response = Http::get("https://api.example.com/photoSlider/{$id}"); + $this->slider = $response->json()['data'] ?? null; + if (!$this->slider) { + throw new \Exception('No data found'); + } + $this->form = [ + 'promotion_uuid' => $this->slider['promotion'] ? $this->slider['promotion']['promotion_uuid'] : '', + 'title' => $this->slider['title'] ?? '', + 'description' => $this->slider['description'] ?? '', + 'image' => $this->slider['image'] ?? null, + 'date_start' => Carbon::parse($this->slider['date_start'])->format('Y-m-d'), + 'date_end' => Carbon::parse($this->slider['date_end'])->format('Y-m-d'), + 'start_time' => Carbon::parse($this->slider['date_start'])->format('H:i'), + 'end_time' => Carbon::parse($this->slider['date_end'])->format('H:i'), + ]; + if ($this->slider['promotion']) { + $this->promotionsDefaultValue = [$this->slider['promotion']['title']]; + $this->promotionsDefaultKeyValue = [$this->slider['promotion']['promotion_uuid']]; + $this->dateStartEnd = [ + 'date_start' => $this->slider['promotion']['date_start'], + 'date_end' => $this->slider['promotion']['date_end'], + ]; + } + } catch (\Exception $e) { + session()->flash('error', 'Failed to load photo slider details: ' . $e->getMessage()); + $this->redirect(route('photo-slider.index')); + } + } + + public function fetchPromotions() + { + try { + $response = Http::get('https://api.example.com/getPromotions'); + $promotions = $response->json()['data'] ?? []; + $this->promotionsOptions = array_map(function ($item) { + return [ + 'label' => $item['title'], + 'value' => $item['promotion_uuid'], + 'date' => [ + 'dateStart' => $item['date_start'], + 'dateEnd' => $item['date_end'], + ], + ]; + }, $promotions); + } catch (\Exception $e) { + session()->flash('error', 'Failed to load promotions: ' . $e->getMessage()); + } + } + + public function fetchDate($id) + { + foreach ($this->promotionsOptions as $option) { + if ($option['value'] == $id) { + $this->dateStartEnd = [ + 'date_start' => $option['date']['dateStart'], + 'date_end' => $option['date']['dateEnd'], + ]; + break; + } + } + } + + public function autoFillDetails($id) + { + try { + $response = Http::get("https://api.example.com/promotion/{$id}"); + $data = $response->json()['data'] ?? []; + $this->form = array_merge($this->form, [ + 'title' => $data['title'] ?? '', + 'description' => $data['description'] ?? '', + 'image' => $data['image'] ?? '', + 'date_start' => Carbon::parse($data['date_start'])->format('Y-m-d'), + 'date_end' => Carbon::parse($data['date_end'])->format('Y-m-d'), + 'start_time' => Carbon::parse($data['date_start'])->format('H:i'), + 'end_time' => Carbon::parse($data['date_end'])->format('H:i'), + ]); + } catch (\Exception $e) { + session()->flash('error', 'Failed to autofill details: ' . $e->getMessage()); + } + } + + public function submit() + { + $this->validateForm(); + + $this->loading = true; + try { + $formData = new \GuzzleHttp\Psr7\MultipartStream([ + [ + 'name' => 'promotion_uuid', + 'contents' => $this->form['promotion_uuid'] ?? '', + ], + [ + 'name' => 'title', + 'contents' => $this->form['title'] ?? '', + ], + [ + 'name' => 'description', + 'contents' => $this->form['description'] ?? '', + ], + [ + 'name' => 'date_start', + 'contents' => Carbon::parse($this->form['date_start'] . ' ' . $this->form['start_time'])->format('Y-m-d\TH:i:s'), + ], + [ + 'name' => 'date_end', + 'contents' => Carbon::parse($this->form['date_end'] . ' ' . $this->form['end_time'])->format('Y-m-d\TH:i:s'), + ], + [ + 'name' => 'image', + 'contents' => $this->form['image'] instanceof \Livewire\TemporaryUploadedFile ? fopen($this->form['image']->getPathname(), 'r') : $this->form['image'], + 'filename' => $this->form['image'] instanceof \Livewire\TemporaryUploadedFile ? $this->form['image']->getClientOriginalName() : '', + ], + ]); + + $response = Http::withHeaders(['Content-Type' => 'multipart/form-data; boundary=' . $formData->getBoundary()]) + ->withBody($formData) + ->post("https://api.example.com/updatePhotoSlider/{$this->slider['photoslider_uuid']}"); + + if ($response->successful()) { + session()->flash('success', 'Record was successfully updated.'); + $this->redirect(route('photo-slider.index')); + } + } catch (\Exception $e) { + session()->flash('error', 'Failed to update record: ' . $e->getMessage()); + } + $this->loading = false; + } + + public function validateForm() + { + $rules = [ + 'title' => 'required|max:128', + 'image' => 'required', + 'date_start' => 'required|date', + 'date_end' => 'required|date', + 'start_time' => 'required', + 'end_time' => 'required', + ]; + + $messages = [ + 'title.required' => 'Title is required!', + 'title.max' => 'Maximum character is 128.', + 'image.required' => 'Upload Image is required!', + 'date_start.required' => 'Start Appearance Date is required!', + 'date_end.required' => 'End Appearance Date is required!', + 'start_time.required' => 'Start Time is required!', + 'end_time.required' => 'End Time is required!', + ]; + + $this->errors = []; + try { + $this->validate($rules, $messages); + } catch (\Exception $e) { + $this->errors = collect($e->errors())->flatten()->toArray(); + throw $e; + } + } + + public function render() + { + return view('livewire.photo-slider.photo-slider-edit'); + } +} \ No newline at end of file diff --git a/app/Livewire/PhotoSlider/PhotoSliderList.php b/app/Livewire/PhotoSlider/PhotoSliderList.php new file mode 100644 index 0000000..4e474d0 --- /dev/null +++ b/app/Livewire/PhotoSlider/PhotoSliderList.php @@ -0,0 +1,61 @@ +fetchSliders(); + $this->checkLimit(); + } + + public function fetchSliders() + { + try { + $this->sliders = $this->fetchFromApi('https://api.example.com/photoSlider?page=1&page_size=10&_sort_by=create_dt&_sort_order=desc'); + } catch (\Exception $e) { + session()->flash('error', 'Failed to load photo sliders: ' . $e->getMessage()); + } + } + + public function checkLimit() + { + try { + $response = \Http::get('https://api.example.com/photoSliderCount'); + $this->photoSliderLimit = $response->json()['data'] >= 10; + } catch (\Exception $e) { + $this->photoSliderLimit = true; // Default to true if API fails + } + } + + private function fetchFromApi($url) + { + $response = \Http::get($url); + return $response->json()['data'] ?? []; + } + + public function delete($uuid) + { + try { + $response = \Http::delete("https://api.example.com/photoSlider/{$uuid}"); + if ($response->successful()) { + session()->flash('success', 'Record was successfully deleted.'); + $this->fetchSliders(); + $this->checkLimit(); + } + } catch (\Exception $e) { + session()->flash('error', 'Failed to delete record: ' . $e->getMessage()); + } + } + + public function render() + { + return view('livewire.photo-slider.photo-slider-list'); + } +} \ No newline at end of file diff --git a/app/Livewire/PhotoSlider/PhotoSliderView.php b/app/Livewire/PhotoSlider/PhotoSliderView.php new file mode 100644 index 0000000..97f4a1c --- /dev/null +++ b/app/Livewire/PhotoSlider/PhotoSliderView.php @@ -0,0 +1,44 @@ +slider = $this->fetchFromApi("https://api.example.com/photoSlider/{$id}"); + } catch (\Exception $e) { + session()->flash('error', 'Failed to load photo slider details: ' . $e->getMessage()); + return redirect()->route('photo-slider.index'); + } + } + + private function fetchFromApi($url) + { + $response = \Http::get($url); + return $response->json()['data'] ?? null; + } + + public function delete($uuid) + { + try { + $response = \Http::delete("https://api.example.com/photoSlider/{$uuid}"); + if ($response->successful()) { + session()->flash('success', 'Record was successfully deleted.'); + return redirect()->route('photo-slider.index'); + } + } catch (\Exception $e) { + session()->flash('error', 'Failed to delete record: ' . $e->getMessage()); + } + } + + public function render() + { + return view('livewire.photo-slider.photo-slider-view', ['slider' => $this->slider]); + } +} \ No newline at end of file diff --git a/app/Livewire/Promotions/PromotionsCreate.php b/app/Livewire/Promotions/PromotionsCreate.php new file mode 100644 index 0000000..2f818cd --- /dev/null +++ b/app/Livewire/Promotions/PromotionsCreate.php @@ -0,0 +1,173 @@ + 'required|string|max:128', + 'description' => 'required|string|max:32000', + 'image' => 'required|image|mimes:jpg,png,gif|max:100', // 100KB + 'station_uuid' => 'nullable|array', + 'date_start' => 'required|date', + 'date_end' => 'required|date|after_or_equal:date_start', + 'start_time' => 'required', + 'end_time' => 'required', + 'is_toppromotion' => 'in:0,1', + 'is_gps' => 'in:0,1', + 'promo_type' => 'required|string', + ]; + + protected $messages = [ + 'title.required' => 'Title is required!', + 'title.max' => 'Maximum character is 128.', + 'description.required' => 'Description is required!', + 'description.max' => 'Maximum character is 32,000.', + 'image.required' => 'Upload Image is required!', + 'image.max' => 'Maximum file size is 100KB.', + 'date_start.required' => 'Start Date is required!', + 'date_end.required' => 'End Date is required!', + 'date_end.after_or_equal' => 'End Date must be on or after Start Date!', + 'start_time.required' => 'Start Time is required!', + 'end_time.required' => 'End Time is required!', + 'promo_type.required' => 'Promo Type is required!', + ]; + + public function mount() + { + $this->fetchBranches(); + $this->fetchPromoTypes(); + $this->checkTopPromotion(); + } + + public function fetchBranches() + { + try { + $response = Http::get('https://api.example.com/getStations'); + if ($response->successful()) { + $stations = $response->json()['data'] ?? []; + $this->branches = array_map(function ($station) { + return [ + 'value' => $station['station_uuid'], + 'label' => $station['description'], + ]; + }, $stations); + $this->branchesOptionsTwo = array_column($stations, 'description'); + } else { + $this->alert('error', 'Failed to fetch branches.'); + } + } catch (\Exception $e) { + $this->alert('error', 'An error occurred: ' . $e->getMessage()); + } + } + + public function fetchPromoTypes() + { + try { + $response = Http::get('https://api.example.com/promoTypes'); + if ($response->successful()) { + $this->promoTypes = array_map(function ($key, $value) { + return [ + 'value' => $key, + 'label' => $value, + ]; + }, array_keys($response->json()['data'] ?? []), $response->json()['data'] ?? []); + } else { + $this->alert('error', 'Failed to fetch promo types.'); + } + } catch (\Exception $e) { + $this->alert('error', 'An error occurred: ' . $e->getMessage()); + } + } + + public function checkTopPromotion() + { + try { + $response = Http::get('https://api.example.com/promotionDisableTopTwo'); + if ($response->successful()) { + $this->is_toppromotion_disabled = !($response->json()['data']['is_toppromotion'] === 'disable'); + } + } catch (\Exception $e) { + $this->alert('error', 'Failed to check top promotion status.'); + } + } + + public function save() + { + $this->validate(); + + $this->loading = true; + + try { + $data = [ + 'title' => $this->title, + 'description' => $this->description, + 'station_uuid' => json_encode($this->station_uuid), + 'date_start' => \Carbon\Carbon::parse($this->date_start . ' ' . $this->start_time)->format('Y-m-d\TH:i:s'), + 'date_end' => \Carbon\Carbon::parse($this->date_end . ' ' . $this->end_time)->format('Y-m-d\TH:i:s'), + 'is_toppromotion' => $this->is_toppromotion, + 'is_gps' => $this->is_gps, + 'promo_type' => $this->promo_type, + 'created_by' => auth()->user()->name ?? 'user', + ]; + + $response = Http::asMultipart(); + if ($this->image) { + $response = $response->attach('image', file_get_contents($this->image->getRealPath()), $this->image->getClientOriginalName()); + } + + $response = $response->post('https://api.example.com/promotion', $data); + + if ($response->successful()) { + $this->alert('success', 'New record added.'); + return redirect('/promotions'); + } else { + $this->alert('error', 'Failed to create promotion.'); + } + } catch (\Exception $e) { + $this->alert('error', 'An error occurred: ' . $e->getMessage()); + } finally { + $this->loading = false; + } + } + + public function cancel() + { + if (confirm('Are you sure you want to discard changes?')) { + return redirect('/promotions'); + } + } + + public function render() + { + return view('livewire.promotions.promotions-create', [ + 'branches' => $this->branches, + 'branchesOptionsTwo' => $this->branchesOptionsTwo, + 'promoTypes' => $this->promoTypes, + ])->layout('layouts.app', ['title' => 'Add Promotion']); + } +} \ No newline at end of file diff --git a/app/Livewire/Promotions/PromotionsEdit.php b/app/Livewire/Promotions/PromotionsEdit.php new file mode 100644 index 0000000..02838dc --- /dev/null +++ b/app/Livewire/Promotions/PromotionsEdit.php @@ -0,0 +1,198 @@ + 'required|string|max:128', + 'description' => 'required|string|max:32000', + 'image' => 'nullable|image|mimes:jpg,png,gif|max:100', // 100KB + 'station_uuid' => 'nullable|array', + 'date_start' => 'required|date', + 'date_end' => 'required|date|after_or_equal:date_start', + 'start_time' => 'required', + 'end_time' => 'required', + 'is_toppromotion' => 'in:0,1', + 'is_gps' => 'in:0,1', + 'promo_type' => 'required|string', + ]; + + protected $messages = [ + 'title.required' => 'Title is required!', + 'title.max' => 'Maximum character is 128.', + 'description.required' => 'Description is required!', + 'description.max' => 'Maximum character is 32,000.', + 'image.max' => 'Maximum file size is 100KB.', + 'date_start.required' => 'Start Date is required!', + 'date_end.required' => 'End Date is required!', + 'date_end.after_or_equal' => 'End Date must be on or after Start Date!', + 'start_time.required' => 'Start Time is required!', + 'end_time.required' => 'End Time is required!', + 'promo_type.required' => 'Promo Type is required!', + ]; + + public function mount($id) + { + $this->id = $id; + $this->fetchPromotion(); + $this->fetchBranches(); + $this->fetchPromoTypes(); + $this->checkTopPromotion(); + } + + public function fetchPromotion() + { + try { + $response = Http::get("https://api.example.com/promotion/{$this->id}"); + if ($response->successful()) { + $this->promotion = $response->json()['data']; + $this->title = $this->promotion['title'] ?? ''; + $this->description = $this->promotion['description'] ?? ''; + $this->station_uuid = array_column($this->promotion['stations'] ?? [], 'station_uuid'); + $this->date_start = \Carbon\Carbon::parse($this->promotion['date_start'])->format('Y-m-d'); + $this->date_end = \Carbon\Carbon::parse($this->promotion['date_end'])->format('Y-m-d'); + $this->start_time = \Carbon\Carbon::parse($this->promotion['date_start'])->format('H:i'); + $this->end_time = \Carbon\Carbon::parse($this->promotion['date_end'])->format('H:i'); + $this->is_toppromotion = $this->promotion['is_toppromotion'] ?? 0; + $this->is_gps = $this->promotion['is_gps'] ?? 0; + $this->promo_type = $this->promotion['promo_type']['id'] ?? ''; + } else { + $this->alert('error', 'Failed to fetch promotion data.'); + return redirect('/promotions'); + } + } catch (\Exception $e) { + $this->alert('error', 'An error occurred: ' . $e->getMessage()); + return redirect('/promotions'); + } + } + + public function fetchBranches() + { + try { + $response = Http::get('https://api.example.com/getStations'); + if ($response->successful()) { + $stations = $response->json()['data'] ?? []; + $this->branches = array_map(function ($station) { + return [ + 'value' => $station['station_uuid'], + 'label' => $station['description'], + ]; + }, $stations); + $this->branchesOptionsTwo = array_column($stations, 'description'); + } + } catch (\Exception $e) { + $this->alert('error', 'Failed to fetch branches.'); + } + } + + public function fetchPromoTypes() + { + try { + $response = Http::get('https://api.example.com/promoTypes'); + if ($response->successful()) { + $this->promoTypes = array_map(function ($key, $value) { + return [ + 'value' => $key, + 'label' => $value, + ]; + }, array_keys($response->json()['data'] ?? []), $response->json()['data'] ?? []); + } + } catch (\Exception $e) { + $this->alert('error', 'Failed to fetch promo types.'); + } + } + + public function checkTopPromotion() + { + try { + $response = Http::get("https://api.example.com/promotionDisableTopTwo?promotion_uuid={$this->id}"); + if ($response->successful()) { + $this->is_toppromotion_disabled = !($response->json()['data']['is_toppromotion'] === 'disable'); + } + } catch (\Exception $e) { + $this->alert('error', 'Failed to check top promotion status.'); + } + } + + public function save() + { + $this->validate(); + + $this->loading = true; + + try { + $data = [ + 'title' => $this->title, + 'description' => $this->description, + 'station_uuid' => json_encode($this->station_uuid), + 'date_start' => \Carbon\Carbon::parse($this->date_start . ' ' . $this->start_time)->format('Y-m-d\TH:i:s'), + 'date_end' => \Carbon\Carbon::parse($this->date_end . ' ' . $this->end_time)->format('Y-m-d\TH:i:s'), + 'is_toppromotion' => $this->is_toppromotion, + 'is_gps' => $this->is_gps, + 'promo_type' => $this->promo_type, + 'updated_by' => auth()->user()->name ?? 'user', + ]; + + $response = Http::asMultipart(); + if ($this->image) { + $response = $response->attach('image', file_get_contents($this->image->getRealPath()), $this->image->getClientOriginalName()); + } + + $response = $response->post("https://api.example.com/updatePromotion/{$this->id}", $data); + + if ($response->successful()) { + $this->alert('success', 'Promotion updated successfully!'); + return redirect('/promotions'); + } else { + $this->alert('error', 'Failed to update promotion.'); + } + } catch (\Exception $e) { + $this->alert('error', 'An error occurred: ' . $e->getMessage()); + } finally { + $this->loading = false; + } + } + + public function cancel() + { + if (confirm('Are you sure you want to discard changes?')) { + return redirect('/promotions'); + } + } + + public function render() + { + return view('livewire.promotions.promotions-edit', [ + 'branches' => $this->branches, + 'branchesOptionsTwo' => $this->branchesOptionsTwo, + 'promoTypes' => $this->promoTypes, + ])->layout('layouts.app', ['title' => 'Update Promotion']); + } +} \ No newline at end of file diff --git a/app/Livewire/Promotions/PromotionsList.php b/app/Livewire/Promotions/PromotionsList.php new file mode 100644 index 0000000..bd1f21b --- /dev/null +++ b/app/Livewire/Promotions/PromotionsList.php @@ -0,0 +1,55 @@ +fetchPromotions(); + } + + public function fetchPromotions() + { + try { + $response = Http::get('https://api.example.com/promotion'); + if ($response->successful()) { + $this->promotions = $response->json()['data'] ?? []; + } else { + $this->alert('error', 'Failed to fetch promotions.'); + } + } catch (\Exception $e) { + $this->alert('error', 'An error occurred: ' . $e->getMessage()); + } + } + + public function delete($id) + { + if (confirm('Are you sure you want to delete this promotion?')) { + try { + $response = Http::delete("https://api.example.com/promotion/{$id}"); + if ($response->successful()) { + $this->alert('success', 'Promotion deleted successfully!'); + $this->fetchPromotions(); + } else { + $this->alert('error', 'Failed to delete promotion.'); + } + } catch (\Exception $e) { + $this->alert('error', 'An error occurred: ' . $e->getMessage()); + } + } + } + + public function render() + { + return view('livewire.promotions.promotions-list')->layout('layouts.app', ['title' => 'Promotions']); + } +} diff --git a/app/Livewire/Promotions/PromotionsView.php b/app/Livewire/Promotions/PromotionsView.php new file mode 100644 index 0000000..2303050 --- /dev/null +++ b/app/Livewire/Promotions/PromotionsView.php @@ -0,0 +1,59 @@ +id = $id; + $this->fetchPromotion(); + } + + public function fetchPromotion() + { + try { + $response = Http::get("https://api.example.com/promotion/{$this->id}"); + if ($response->successful()) { + $this->promotion = $response->json()['data'] ?? null; + } else { + $this->alert('error', 'Failed to fetch promotion data.'); + return redirect('/promotions'); + } + } catch (\Exception $e) { + $this->alert('error', 'An error occurred: ' . $e->getMessage()); + return redirect('/promotions'); + } + } + + public function delete() + { + if (confirm('Are you sure you want to delete this promotion?')) { + try { + $response = Http::delete("https://api.example.com/promotion/{$this->id}"); + if ($response->successful()) { + $this->alert('success', 'Promotion deleted successfully!'); + return redirect('/promotions'); + } else { + $this->alert('error', 'Failed to delete promotion.'); + } + } catch (\Exception $e) { + $this->alert('error', 'An error occurred: ' . $e->getMessage()); + } + } + } + + public function render() + { + return view('livewire.promotions.promotions-view')->layout('layouts.app', ['title' => 'Promotion Details']); + } +} diff --git a/app/Livewire/Reports/MobileUsageList.php b/app/Livewire/Reports/MobileUsageList.php new file mode 100644 index 0000000..edf1f0f --- /dev/null +++ b/app/Livewire/Reports/MobileUsageList.php @@ -0,0 +1,42 @@ +fetchData(); + } + + public function fetchData() + { + try { + $this->updating = true; + $response = Http::get('https://api.example.com/reportMobileUsage'); + if ($response->successful()) { + $this->data = $response->json()['data'] ?? []; + } else { + $this->alert('error', 'Failed to fetch mobile usage report data.'); + } + } catch (\Exception $e) { + $this->alert('error', 'An error occurred: ' . $e->getMessage()); + } finally { + $this->updating = false; + } + } + + public function render() + { + return view('livewire.reports.mobile-usage-list')->layout('layouts.app', ['title' => 'Mobile Usage Report']); + } +} diff --git a/app/Livewire/Reports/RegistrationList.php b/app/Livewire/Reports/RegistrationList.php new file mode 100644 index 0000000..1a70caa --- /dev/null +++ b/app/Livewire/Reports/RegistrationList.php @@ -0,0 +1,42 @@ +fetchData(); + } + + public function fetchData() + { + try { + $this->updating = true; + $response = Http::get('https://api.example.com/reportRegistration'); + if ($response->successful()) { + $this->data = $response->json()['data'] ?? []; + } else { + $this->alert('error', 'Failed to fetch registration report data.'); + } + } catch (\Exception $e) { + $this->alert('error', 'An error occurred: ' . $e->getMessage()); + } finally { + $this->updating = false; + } + } + + public function render() + { + return view('livewire.reports.registration-list')->layout('layouts.app', ['title' => 'Registration Report']); + } +} diff --git a/app/Livewire/Reports/StationRatingList.php b/app/Livewire/Reports/StationRatingList.php new file mode 100644 index 0000000..d34b37d --- /dev/null +++ b/app/Livewire/Reports/StationRatingList.php @@ -0,0 +1,42 @@ +fetchData(); + } + + public function fetchData() + { + try { + $this->updating = true; + $response = Http::get('https://api.example.com/reportStationRatings'); + if ($response->successful()) { + $this->data = $response->json()['data'] ?? []; + } else { + $this->alert('error', 'Failed to fetch station rating report data.'); + } + } catch (\Exception $e) { + $this->alert('error', 'An error occurred: ' . $e->getMessage()); + } finally { + $this->updating = false; + } + } + + public function render() + { + return view('livewire.reports.station-rating-list')->layout('layouts.app', ['title' => 'Station Rating Report']); + } +} diff --git a/app/Livewire/Reports/TopUpList.php b/app/Livewire/Reports/TopUpList.php new file mode 100644 index 0000000..8b6a5bc --- /dev/null +++ b/app/Livewire/Reports/TopUpList.php @@ -0,0 +1,54 @@ +fetchData(); + } + + public function fetchData() + { + try { + $this->updating = true; + $response = Http::get('https://api.example.com/reportTopUp'); + if ($response->successful()) { + $this->data = $response->json()['data'] ?? []; + } else { + $this->alert('error', 'Failed to fetch top-up report data.'); + } + } catch (\Exception $e) { + $this->alert('error', 'An error occurred: ' . $e->getMessage()); + } finally { + $this->updating = false; + } + } + + public function render() + { + return view('livewire.reports.top-up-list')->layout('layouts.app', ['title' => 'Top-Up Usage Report']); + } + + // In TopUpList.php +public function exportCsv() +{ + $response = Http::get('https://api.example.com/reportTopUpExport'); + if ($response->successful()) { + return response($response->body()) + ->header('Content-Type', 'text/csv') + ->header('Content-Disposition', 'attachment; filename="TopUpUsageReport.csv"'); + } + $this->alert('error', 'Failed to export CSV.'); +} +} diff --git a/resources/views/livewire/member-management/card-member-list.blade.php b/resources/views/livewire/member-management/card-member-list.blade.php new file mode 100644 index 0000000..3e6e157 --- /dev/null +++ b/resources/views/livewire/member-management/card-member-list.blade.php @@ -0,0 +1,65 @@ +
+ + + @if(session('error')) +
+ {{ session('error') }} +
+ @endif + +
+
+
+ +
+ + + + + + + + + + + + + + + @foreach ($members as $member) + + + + + + + + + + @endforeach + +
Card NumberFirst NameLast NameBirthdayCard TypeStatusAction
{{ $member['card_number'] }}{{ $member['firstname'] }}{{ $member['lastname'] }}{{ \Carbon\Carbon::parse($member['birthdate'])->format('d-M-Y') }}{{ $member['card_type'] }}{{ $member['status'] === 'active' ? 'Active' : 'Inactive' }} + + View + +
+ +
+ +
+
+
+
\ No newline at end of file diff --git a/resources/views/livewire/member-management/card-member-view.blade.php b/resources/views/livewire/member-management/card-member-view.blade.php new file mode 100644 index 0000000..988a1d4 --- /dev/null +++ b/resources/views/livewire/member-management/card-member-view.blade.php @@ -0,0 +1,53 @@ +
+ + + @if(session('error')) +
+ {{ session('error') }} +
+ @endif + + @if($member) +
+
+
+

Details

+ +

Card Details

+
+
Card Number:
+
{{ $member['card_number'] }}
+
+
+
First Name:
+
{{ $member['firstname'] }}
+
+
+
Last Name:
+
{{ $member['lastname'] }}
+
+
+
Birthday:
+
{{ \Carbon\Carbon::parse($member['birthdate'])->format('d-M-Y') }}
+
+
+
Card Type:
+
{{ $member['card_type'] }}
+
+ +

Account Details

+
+
Account Status:
+
{{ $member['is_locked'] == 1 ? 'Locked' : 'Active' }}
+
+
+
Unlocked By:
+
{{ $member['unlocked_by'] }}
+
+
+
+
+ @else +

No member data found.

+ @endif +
\ No newline at end of file diff --git a/resources/views/livewire/member-management/lock-account-list.blade.php b/resources/views/livewire/member-management/lock-account-list.blade.php new file mode 100644 index 0000000..f84fbaa --- /dev/null +++ b/resources/views/livewire/member-management/lock-account-list.blade.php @@ -0,0 +1,45 @@ +@extends('layouts.app') + +@section('content') +
+
+
+

Locked Accounts

+
+
+ + + + + + + + + + + + + + @forelse ($accounts as $account) + + + + + + + + + + @empty + + + + @endforelse + +
Card NumberFirst NameLast NameBirthdayCard TypeStatusAction
{{ $account['card_number'] ?? 'N/A' }}{{ $account['firstname'] ?? 'N/A' }}{{ $account['lastname'] ?? 'N/A' }}{{ $account['birthdate'] ? \Carbon\Carbon::parse($account['birthdate'])->format('d-M-Y') : 'N/A' }}{{ $account['card_type'] ?? 'N/A' }}{{ $account['status'] == 'locked' ? 'Locked' : 'Locked' }} + View +
No locked accounts found.
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/livewire/member-management/lock-account-view.blade.php b/resources/views/livewire/member-management/lock-account-view.blade.php new file mode 100644 index 0000000..d9b9395 --- /dev/null +++ b/resources/views/livewire/member-management/lock-account-view.blade.php @@ -0,0 +1,60 @@ +@extends('layouts.app') + +@section('content') +
+
+
+

Locked Accounts

+ +
+
+ @if($userInfo) +
+
+
Card Details
+
+
Card Number:
+
{{ $userInfo['card_number'] ?? 'N/A' }}
+
+
+
First Name:
+
{{ $userInfo['firstname'] ?? 'N/A' }}
+
+
+
Last Name:
+
{{ $userInfo['lastname'] ?? 'N/A' }}
+
+
+
Birthday:
+
{{ $userInfo['birthdate'] ? \Carbon\Carbon::parse($userInfo['birthdate'])->format('d-M-Y') : 'N/A' }}
+
+
+
Card Type:
+
{{ $userInfo['card_type'] ?? 'N/A' }}
+
+
+
+
Account Details
+
+
Account Status:
+
{{ $userInfo['is_locked'] == 1 ? 'Locked' : 'Active' }}
+
+
+
Lock Account Description:
+
{{ $userInfo['reason'] ?? 'N/A' }}
+
+
+
Locked Date:
+
{{ $userInfo['lock_dt'] ? \Carbon\Carbon::parse($userInfo['lock_dt'])->format('d-M-Y') : 'N/A' }}
+
+
+
+ @else +

Loading account details...

+ @endif +
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/livewire/my-profile/my-profile-view.blade.php b/resources/views/livewire/my-profile/my-profile-view.blade.php new file mode 100644 index 0000000..8f61840 --- /dev/null +++ b/resources/views/livewire/my-profile/my-profile-view.blade.php @@ -0,0 +1,49 @@ +@extends('layouts.app') + +@section('content') +
+
+
+

My Profile

+
+
+ @if($userInfo) +
+
+ User Avatar +
+

+ {{ $userInfo['firstname'] ?? 'N/A' }} {{ $userInfo['lastname'] ?? 'N/A' }} +

+
+
+
+
My Information
+
+
Username:
+
{{ $userInfo['username'] ?? 'N/A' }}
+
+ +
+
+
Access Role
+
+
Role:
+
{{ $this->getRoleLabel($userInfo['role'] ?? null) }}
+
+
+
+ @else +

Loading profile data...

+ @endif +
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/livewire/notifications/notification-list.blade.php b/resources/views/livewire/notifications/notification-list.blade.php new file mode 100644 index 0000000..1b23047 --- /dev/null +++ b/resources/views/livewire/notifications/notification-list.blade.php @@ -0,0 +1,47 @@ +@extends('layouts.app') + +@section('content') +
+
+
+

Notifications

+ Add Notification +
+
+ + + + + + + + + + + + + @forelse ($notifications as $notification) + + + + + + + + + @empty + + + + @endforelse + +
IDSubjectContentIs ScheduledScheduleExpiration
{{ $notification['id'] ?? 'N/A' }}{{ $notification['subject'] ?? 'N/A' }}{{ $notification['content'] ?? 'N/A' }}{{ $notification['isScheduled'] ? 'Yes' : 'No' }}{{ $notification['schedule'] ? \Carbon\Carbon::parse($notification['schedule'])->format('M d, Y H:i') : 'N/A' }}{{ $notification['expiration'] ? \Carbon\Carbon::parse($notification['expiration'])->format('M d, Y H:i') : 'N/A' }}
No notifications found.
+ @if ($updating) +
+ Loading... +
+ @endif +
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/livewire/notifications/notifications-create.blade.php b/resources/views/livewire/notifications/notifications-create.blade.php new file mode 100644 index 0000000..96fa0f7 --- /dev/null +++ b/resources/views/livewire/notifications/notifications-create.blade.php @@ -0,0 +1,70 @@ +@extends('layouts.app') + +@section('content') +
+
+
+

Add Notification

+
+
+
+ @include('partials.header-form', [ + 'title' => $title, + 'loading' => $loading, + 'disabled' => false, + 'actionBtnName' => 'Submit', + ]) + +
+ +
+ + @error('subject')
{{ $message }}
@enderror +
+
+ +
+ +
+ + @error('content')
{{ $message }}
@enderror +
+
+ +
+ +
+
+ + +
+
+ + +
+ @error('isScheduled')
{{ $message }}
@enderror +
+
+ + @if ($isScheduled === 'true') +
+ +
+ + @error('schedule')
{{ $message }}
@enderror +
+
+ +
+ +
+ + @error('expiration')
{{ $message }}
@enderror +
+
+ @endif +
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/livewire/photo-slider/photo-slider-create.blade.php b/resources/views/livewire/photo-slider/photo-slider-create.blade.php new file mode 100644 index 0000000..7f9d3f7 --- /dev/null +++ b/resources/views/livewire/photo-slider/photo-slider-create.blade.php @@ -0,0 +1,101 @@ +
+

Photo Slider Content Details

+ + @if(session('error')) +
{{ session('error') }}
+ @endif + + @if(session('success')) +
{{ session('success') }}
+ @endif + + @if(!empty($errors)) +
+ +
+ @endif + +
+ @include('partials.header-form', [ + 'title' => 'Photo Slider', + 'action' => '#', + 'disabled' => $photoSliderLimit ? 'disabled' : '', + 'actionBtnName' => 'Submit', + 'cancelAction' => route('photo-slider.index'), + 'cancelBtnName' => 'Cancel' + ]) + +
+ +
+ + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + + Image Size: 1020 x 621
+ Maximum File Size: 100KB +
+ @if($form['image'] && is_string($form['image'])) + Preview + @endif +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+
+
\ No newline at end of file diff --git a/resources/views/livewire/photo-slider/photo-slider-edit.blade.php b/resources/views/livewire/photo-slider/photo-slider-edit.blade.php new file mode 100644 index 0000000..72b0435 --- /dev/null +++ b/resources/views/livewire/photo-slider/photo-slider-edit.blade.php @@ -0,0 +1,104 @@ +
+

Photo Slider Content Details

+ + @if(session('error')) +
{{ session('error') }}
+ @endif + + @if(session('success')) +
{{ session('success') }}
+ @endif + + @if(!empty($errors)) +
+ +
+ @endif + + @if($slider) +
+ @include('partials.header-form', [ + 'title' => 'Update Photo Slider', + 'action' => '#', + 'actionBtnName' => 'Submit', + 'cancelAction' => route('photo-slider.index'), + 'cancelBtnName' => 'Cancel' + ]) + +
+ +
+ + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + + Image Size: 1020 x 621
+ Maximum File Size: 100KB +
+ @if($form['image'] && is_string($form['image'])) + Preview + @endif +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+
+ @else +

No slider data found.

+ @endif +
\ No newline at end of file diff --git a/resources/views/livewire/photo-slider/photo-slider-list.blade.php b/resources/views/livewire/photo-slider/photo-slider-list.blade.php new file mode 100644 index 0000000..317dfac --- /dev/null +++ b/resources/views/livewire/photo-slider/photo-slider-list.blade.php @@ -0,0 +1,53 @@ +
+ @include('partials.header-form', [ + 'title' => 'Photo Slider', + 'action' => route('photo-slider.create'), + 'disabled' => $photoSliderLimit ? 'disabled' : '', + 'actionBtnName' => 'Add Content' + ]) + + @if(session('error')) +
{{ session('error') }}
+ @endif + + @if(session('success')) +
{{ session('success') }}
+ @endif + +
+
+ + + + + + + + + + + + @foreach ($sliders as $slider) + + + + + + + + @endforeach + +
TitleTypeStart DateEnd DateAction
{{ $slider['title'] }}{{ $slider['type'] }}{{ \Carbon\Carbon::parse($slider['date_start'])->format('d-M-Y') }}{{ \Carbon\Carbon::parse($slider['date_end'])->format('d-M-Y') }} + + Edit + + + + View + +
+
+
+
\ No newline at end of file diff --git a/resources/views/livewire/photo-slider/photo-slider-view.blade.php b/resources/views/livewire/photo-slider/photo-slider-view.blade.php new file mode 100644 index 0000000..e693145 --- /dev/null +++ b/resources/views/livewire/photo-slider/photo-slider-view.blade.php @@ -0,0 +1,78 @@ +
+ @include('partials.header-form', [ + 'title' => 'Photo Slider', + 'action' => route('photo-slider.edit', ['id' => $slider['photoslider_uuid'] ?? '']), + 'styleBtn' => 'background: white; border-color: rgb(184, 187, 201); color: rgb(101, 105, 127)', + 'actionBtnName' => 'Update', + 'deleteAction' => "delete('{{ $slider['photoslider_uuid'] ?? '' }}')", + 'deleteBtnName' => 'Delete' + ]) + + @if(session('error')) +
{{ session('error') }}
+ @endif + + @if(session('success')) +
{{ session('success') }}
+ @endif + + @if($slider) +
+
+
+ Slider Image +
+
+

Details

+

CONTENT DETAILS

+
+
Title:
+
{{ $slider['title'] }}
+
+
+
Description:
+
{{ $slider['description'] }}
+
+ +

SCHEDULE DETAILS

+
+
Start Appearance Date:
+
{{ \Carbon\Carbon::parse($slider['date_start'])->format('d-M-Y') }}
+
+
+
End Appearance Date:
+
{{ \Carbon\Carbon::parse($slider['date_end'])->format('d-M-Y') }}
+
+
+
Start Time:
+
{{ \Carbon\Carbon::parse($slider['date_start'])->format('H:i:s') }}
+
+
+
End Time:
+
{{ \Carbon\Carbon::parse($slider['date_end'])->format('H:i:s') }}
+
+
+
Created By:
+
{{ $slider['created_by'] }}
+
+
+
Date Created:
+
{{ \Carbon\Carbon::parse($slider['created_at'])->format('d-M-Y') }}
+
+
+
Last Updated By:
+
{{ $slider['updated_by'] }}
+
+
+
Last Date Updated:
+
{{ \Carbon\Carbon::parse($slider['updated_at'])->format('d-M-Y') }}
+
+
+
+
+ @else +

No slider data found.

+ @endif +
\ No newline at end of file diff --git a/resources/views/livewire/photo-slider/photo-slider.blade.php b/resources/views/livewire/photo-slider/photo-slider.blade.php new file mode 100644 index 0000000..99d93fe --- /dev/null +++ b/resources/views/livewire/photo-slider/photo-slider.blade.php @@ -0,0 +1,17 @@ +
+ @if(Request::is('home-page/photo-slider')) + + @elseif(Request::is('home-page/photo-slider/create')) + + @elseif(Request::is('home-page/photo-slider/edit/*')) + + @elseif(Request::is('home-page/photo-slider/view/*')) + + @endif + + @if(Request::is('/home-page/photo-slider')) + + @endif +
\ No newline at end of file diff --git a/resources/views/livewire/promotions/promotions-create.blade.php b/resources/views/livewire/promotions/promotions-create.blade.php new file mode 100644 index 0000000..ed875be --- /dev/null +++ b/resources/views/livewire/promotions/promotions-create.blade.php @@ -0,0 +1,20 @@ +@extends('layouts.app') + +@section('content') +
+
+
+

{{ $title }}

+
+
+ @include('partials.promotion-form', [ + 'branches' => $branches, + 'branchesOptionsTwo' => $branchesOptionsTwo, + 'promoTypes' => $promoTypes, + 'title' => $title, + 'loading' => $loading, + ]) +
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/livewire/promotions/promotions-edit.blade.php b/resources/views/livewire/promotions/promotions-edit.blade.php new file mode 100644 index 0000000..ed875be --- /dev/null +++ b/resources/views/livewire/promotions/promotions-edit.blade.php @@ -0,0 +1,20 @@ +@extends('layouts.app') + +@section('content') +
+
+
+

{{ $title }}

+
+
+ @include('partials.promotion-form', [ + 'branches' => $branches, + 'branchesOptionsTwo' => $branchesOptionsTwo, + 'promoTypes' => $promoTypes, + 'title' => $title, + 'loading' => $loading, + ]) +
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/livewire/promotions/promotions-list.blade.php b/resources/views/livewire/promotions/promotions-list.blade.php new file mode 100644 index 0000000..bdcb89d --- /dev/null +++ b/resources/views/livewire/promotions/promotions-list.blade.php @@ -0,0 +1,46 @@ +@extends('layouts.app') + +@section('content') +
+
+
+

Promotions

+ Add Content +
+
+ + + + + + + + + + + + + @forelse ($promotions as $promotion) + + + + + + + + + @empty + + + + @endforelse + +
TitleTypeStart DateEnd DateStatusAction
{{ $promotion['title'] ?? 'N/A' }}{{ $promotion['promo_type']['name'] ?? 'N/A' }}{{ \Carbon\Carbon::parse($promotion['date_start'])->format('d-M-Y') }}{{ \Carbon\Carbon::parse($promotion['date_end'])->format('d-M-Y') }}{{ $promotion['status'] ?? 'N/A' }} + Edit + + View +
No promotions found.
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/livewire/promotions/promotions-view.blade.php b/resources/views/livewire/promotions/promotions-view.blade.php new file mode 100644 index 0000000..f1d4616 --- /dev/null +++ b/resources/views/livewire/promotions/promotions-view.blade.php @@ -0,0 +1,104 @@ +@extends('layouts.app') + +@section('content') +
+
+
+

Promotion Details

+
+ Update + +
+
+
+ @if($promotion) +
+ @if($promotion['image']) + Promotion Image + @else +

No image available.

+ @endif +
+ +
+
Content Details
+
+
Title:
+
{{ $promotion['title'] ?? 'N/A' }}
+
+
+
Description:
+
{{ $promotion['description'] ?? 'N/A' }}
+
+
+
Branch:
+
+ @if($promotion['stations'] && count($promotion['stations']) > 0) + @foreach($promotion['stations'] as $station) + {{ $station['description'] }}@if(!$loop->last), @endif + @endforeach + @else + All + @endif +
+
+
+
Add in Top 2 Promos:
+
{{ $promotion['is_toppromotion'] == 1 ? 'Yes' : 'No' }}
+
+
+
Add in GPS:
+
{{ $promotion['is_gps'] == 1 ? 'Yes' : 'No' }}
+
+
+
Status:
+
{{ $promotion['status'] ?? 'N/A' }}
+
+
+
Promo Type:
+
{{ $promotion['promo_type']['name'] ?? 'N/A' }}
+
+
+ +
+
Schedule Details
+
+
Start Appearance Date:
+
{{ \Carbon\Carbon::parse($promotion['date_start'])->format('d-M-Y') }}
+
+
+
End Appearance Date:
+
{{ \Carbon\Carbon::parse($promotion['date_end'])->format('d-M-Y') }}
+
+
+
Start Time:
+
{{ \Carbon\Carbon::parse($promotion['date_start'])->format('H:i') }}
+
+
+
End Time:
+
{{ \Carbon\Carbon::parse($promotion['date_end'])->format('H:i') }}
+
+
+
Created By:
+
{{ $promotion['created_by'] ?? 'N/A' }}
+
+
+
Date Created:
+
{{ \Carbon\Carbon::parse($promotion['created_at'])->format('d-M-Y') }}
+
+
+
Last Updated By:
+
{{ $promotion['updated_by'] ?? 'N/A' }}
+
+
+
Last Updated Date:
+
{{ \Carbon\Carbon::parse($promotion['updated_at'])->format('d-M-Y') }}
+
+
+ @else +

Loading promotion details...

+ @endif +
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/livewire/reports/mobile-usage-list.blade.php b/resources/views/livewire/reports/mobile-usage-list.blade.php new file mode 100644 index 0000000..4108e4d --- /dev/null +++ b/resources/views/livewire/reports/mobile-usage-list.blade.php @@ -0,0 +1,42 @@ +@extends('layouts.app') + +@section('content') +
+
+
+

Mobile Usage Report

+
+
+ + + + + + + + + + + @forelse ($data as $item) + + + + + + + @empty + + + + @endforelse + +
DateActive Registered UsersInactive Registered UsersLocked Registered Users
{{ \Carbon\Carbon::parse($item['date'])->format('d-M-Y') }}{{ $item['active'] ?? '0' }}{{ $item['inactive'] ?? '0' }}{{ $item['locked'] ?? '0' }}
No data found.
+ @if ($updating) +
+ Loading... +
+ @endif +
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/livewire/reports/registration-list.blade.php b/resources/views/livewire/reports/registration-list.blade.php new file mode 100644 index 0000000..81315f2 --- /dev/null +++ b/resources/views/livewire/reports/registration-list.blade.php @@ -0,0 +1,40 @@ +@extends('layouts.app') + +@section('content') +
+
+
+

Registration Report

+
+
+ + + + + + + + + + @forelse ($data as $item) + + + + + + @empty + + + + @endforelse + +
DateNo. of Activated CardsNo. of Registered Members
{{ \Carbon\Carbon::parse($item['date'])->format('d-M-Y') }}{{ $item['activated'] ?? '0' }}{{ $item['registered'] ?? '0' }}
No data found.
+ @if ($updating) +
+ Loading... +
+ @endif +
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/livewire/reports/station-rating-list.blade.php b/resources/views/livewire/reports/station-rating-list.blade.php new file mode 100644 index 0000000..23d9227 --- /dev/null +++ b/resources/views/livewire/reports/station-rating-list.blade.php @@ -0,0 +1,44 @@ +@extends('layouts.app') + +@section('content') +
+
+
+

Station Rating Report

+
+
+ + + + + + + + + + + + @forelse ($data as $item) + + + + + + + + @empty + + + + @endforelse + +
Transaction Date & TimeCard NumberSales InvoiceStationRatings
{{ \Carbon\Carbon::parse($item['date'])->format('M d, Y H:i') }}{{ $item['card_number'] ?? 'N/A' }}{{ $item['invoice'] ?? 'N/A' }}{{ $item['station'] ?? 'N/A' }}{{ $item['rate'] ?? 'N/A' }}
No data found.
+ @if ($updating) +
+ Loading... +
+ @endif +
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/livewire/reports/top-up-list.blade.php b/resources/views/livewire/reports/top-up-list.blade.php new file mode 100644 index 0000000..e9dc943 --- /dev/null +++ b/resources/views/livewire/reports/top-up-list.blade.php @@ -0,0 +1,44 @@ +@extends('layouts.app') + +@section('content') +
+
+
+

Top-Up Usage Report

+
+
+

Top-Up Usage Report

+ +
+
+ + + + + + + + + + @forelse ($data as $item) + + + + + + @empty + + + + @endforelse + +
Transaction Date & TimeCard NumberTop-up Amount
{{ \Carbon\Carbon::parse($item['date'])->format('M d, Y H:i') }}{{ $item['card_number'] ?? 'N/A' }}{{ number_format($item['amount'], 2) }}
No data found.
+ @if ($updating) +
+ Loading... +
+ @endif +
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/partials/header-form.blade.php b/resources/views/partials/header-form.blade.php new file mode 100644 index 0000000..1ec22e4 --- /dev/null +++ b/resources/views/partials/header-form.blade.php @@ -0,0 +1,12 @@ +@include('partials.header-form', ['title' => 'My Profile', 'loading' => false, 'disabled' => true, 'actionBtnName' => '', 'cancelBtnName' => '']) + + +
+

{{ $title }}

+ @if(isset($action) && !$disabled) + {{ $actionBtnName }} + @endif + @if(isset($deleteAction)) + + @endif +
\ No newline at end of file diff --git a/resources/views/partials/promotion-form.blade.php b/resources/views/partials/promotion-form.blade.php new file mode 100644 index 0000000..5dd33ab --- /dev/null +++ b/resources/views/partials/promotion-form.blade.php @@ -0,0 +1,115 @@ +
+ @include('partials.header-form', ['title' => $title, 'loading' => $loading, 'disabled' => false, 'actionBtnName' => 'Submit']) + +
+ +
+ + @error('title')
{{ $message }}
@enderror +
+
+ +
+ +
+ + @error('description')
{{ $message }}
@enderror +
+
+ +
+ +
+ + Image Size: 1020 x 621, Maximum File Size: 100KB + @error('image')
{{ $message }}
@enderror +
+
+ +
+ +
+ + @error('station_uuid')
{{ $message }}
@enderror +
+
+ +
+ +
+ + @error('date_start')
{{ $message }}
@enderror +
+
+ +
+ +
+ + @error('date_end')
{{ $message }}
@enderror +
+
+ +
+ +
+ + @error('start_time')
{{ $message }}
@enderror +
+
+ +
+ +
+ + @error('end_time')
{{ $message }}
@enderror +
+
+ +
+ +
+
+ + +
+
+ + +
+ @error('is_toppromotion')
{{ $message }}
@enderror +
+
+ +
+ +
+ + @error('promo_type')
{{ $message }}
@enderror +
+
+ +
+ +
+
+ + +
+
+ + +
+ @error('is_gps')
{{ $message }}
@enderror +
+
+
\ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 7ee9a51..4e7b0f4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -59,6 +59,63 @@ use App\Livewire\StationLocator\BranchList; use App\Livewire\StationLocator\CreateBranch; use App\Livewire\StationLocator\EditBranch; +use App\Livewire\Reports\TopUpList; +use App\Livewire\Reports\StationRatingList; +use App\Livewire\Reports\MobileUsageList; +use App\Livewire\Reports\RegistrationList; + +use App\Livewire\Promotions\PromotionsList; +use App\Livewire\Promotions\PromotionsCreate; +use App\Livewire\Promotions\PromotionsEdit; +use App\Livewire\Promotions\PromotionsView; + +use App\Livewire\Notifications\NotificationList; +use App\Livewire\Notifications\NotificationsCreate; + +use App\Livewire\MyProfile\MyProfileView; + +use App\Livewire\MemberManagement\CardMemberList; +use App\Livewire\MemberManagement\CardMemberView; +use App\Livewire\MemberManagement\LockAccountList; +use App\Livewire\MemberManagement\LockAccountView; + + +use App\Http\Livewire\PhotoSlider\PhotoSlider; +use App\Http\Livewire\PhotoSlider\PhotoSliderView; +use App\Http\Livewire\PhotoSlider\PhotoSliderList; +use App\Http\Livewire\PhotoSlider\PhotoSliderCreate; +use App\Http\Livewire\PhotoSlider\PhotoSliderEdit; + + +// Route::get('/home-page/photo-slider', PhotoSlider::class)->name('photo-slider.index'); +// Route::get('/home-page/photo-slider/create', PhotoSlider::class)->name('photo-slider.create'); +// Route::get('/home-page/photo-slider/edit/{id}', PhotoSlider::class)->name('photo-slider.edit'); +// Route::get('/home-page/photo-slider/view/{id}', PhotoSliderView::class)->name('photo-slider.view'); + + +// Route::get('/member-management/card-member', CardMemberList::class)->name('member-management.card-member'); +// Route::get('/member-management/card-member/view/{id}', CardMemberView::class)->name('member-management.card-member.view'); +// Route::get('/member-management/lock-account', LockAccountList::class)->name('member-management.lock-account'); +// Route::get('/member-management/lock-account/view/{id}', LockAccountView::class)->name('member-management.lock-account.view'); + +// Route::get('/my-profile', MyProfileView::class)->name('my-profile.view'); + +// Route::get('/notifications', NotificationList::class)->name('notifications.list'); +// Route::get('/notifications/create', NotificationsCreate::class)->name('notifications.create'); + +// Route::get('/promotions', PromotionsList::class)->name('promotions.list'); +// Route::get('/promotions/create', PromotionsCreate::class)->name('promotions.create'); +// Route::get('/promotions/edit/{id}', PromotionsEdit::class)->name('promotions.edit'); +// Route::get('/promotions/view/{id}', PromotionsView::class)->name('promotions.view'); + +// Route::get('/reports/top-up', TopUpList::class)->name('reports.top-up'); +// Route::get('/reports/station-rating', StationRatingList::class)->name('reports.station-rating'); +// Route::get('/reports/mobile-report', MobileUsageList::class)->name('reports.mobile-report'); +// Route::get('/reports/registration-report', RegistrationList::class)->name('reports.registration-report'); +// Route::get('/reports', function () { +// return redirect('/reports/top-up'); +// }); + // Route::get('/fuels', FuelList::class)->name('fuels.list'); // Route::get('/fuels/create', CreateFuel::class)->name('fuels.create'); // Route::get('/fuels/view/{id}', EditFuel::class)->name('fuels.edit');