diff --git a/app/Config/Routes.php b/app/Config/Routes.php index bc302dd..f16ef5a 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -1387,6 +1387,10 @@ $routes->group('setting', static function($routes) { $routes->post('admin/nursing-station/save', 'Setting\\NursingStation::save'); $routes->post('admin/nursing-station/delete', 'Setting\\NursingStation::delete'); $routes->get('admin/nursing-station/list_json', 'Setting\\NursingStation::list_json'); + $routes->get('admin/opd-queue-tv', 'Setting\\OpdQueueSetting::index'); + $routes->post('admin/opd-queue-tv/save', 'Setting\\OpdQueueSetting::save'); + $routes->post('admin/opd-queue-tv/upload-banner', 'Setting\\OpdQueueSetting::uploadBanner'); + $routes->post('admin/opd-queue-tv/delete-banner', 'Setting\\OpdQueueSetting::deleteBanner'); $routes->get('admin/bed-management', 'Setting\\BedManagement::index', ['filter' => $settingsBedFilter]); $routes->get('admin/departments', 'Setting\\BedManagement::departments', ['filter' => $settingsBedFilter]); $routes->post('admin/departments/save', 'Setting\\BedManagement::saveDepartment', ['filter' => $settingsBedFilter]); diff --git a/app/Controllers/Api/v1/DoctorApi.php b/app/Controllers/Api/v1/DoctorApi.php index 402f773..fd88e70 100644 --- a/app/Controllers/Api/v1/DoctorApi.php +++ b/app/Controllers/Api/v1/DoctorApi.php @@ -823,6 +823,17 @@ class DoctorApi extends BaseController $allTrackers = array_merge($docTokens, $deptTokens); // 3. Hospital Advertisements & Doctor Showcase Slides + $adsJsonRow = $db->table('hospital_setting')->select('s_value')->where('s_name', 'TV_QUEUE_ADS_JSON')->get(1)->getRowArray(); + $customAdsList = !empty($adsJsonRow['s_value']) ? json_decode($adsJsonRow['s_value'], true) : []; + $activeCustomAds = []; + if (is_array($customAdsList)) { + foreach ($customAdsList as $cad) { + if (!isset($cad['enabled']) || (int)$cad['enabled'] === 1) { + $activeCustomAds[] = $cad; + } + } + } + $ads = []; $adId = 1; @@ -840,36 +851,64 @@ class DoctorApi extends BaseController ]; } - // Hospital Service Advertisements - $ads[] = [ - 'id' => $adId++, - 'type' => 'hospital_ad', - 'title' => 'In-House 24/7 Pharmacy', - 'tagline' => '100% Genuine Medicines & Fastest Counter Dispense', - 'image_url' => base_url('assets/img/slides-1.jpg'), - 'description' => 'Discounts on prescription billing. Doorstep delivery available for senior citizens and admitted patients.' - ]; - $ads[] = [ - 'id' => $adId++, - 'type' => 'hospital_ad', - 'title' => 'Advanced Radiology & Imaging Center', - 'tagline' => 'Digital X-Ray, 32-Slice CT Scan & 4D Ultrasound', - 'image_url' => base_url('assets/img/slides-2.jpg'), - 'description' => 'Accurate high-precision diagnostic imaging with immediate digital report generation.' - ]; - $ads[] = [ - 'id' => $adId++, - 'type' => 'hospital_ad', - 'title' => '24x7 Emergency & Critical Care ICU', - 'tagline' => 'Fully Equipped Ventilators, Cardiac Monitors & Trauma Team', - 'image_url' => base_url('assets/img/slides-3.jpg'), - 'description' => 'Round-the-clock emergency medical services with dedicated ICU & Operation Theater.' - ]; + // Add Active Custom Admin Uploaded Ad Banners + if (!empty($activeCustomAds)) { + foreach ($activeCustomAds as $cad) { + $ads[] = [ + 'id' => $adId++, + 'type' => $cad['type'] ?? 'hospital_ad', + 'title' => $cad['title'] ?? 'Hospital Service', + 'tagline' => $cad['tagline'] ?? '', + 'image_url' => !empty($cad['relative_image_url']) ? base_url($cad['relative_image_url']) : ($cad['image_url'] ?? base_url('assets/img/slides-1.jpg')), + 'description' => $cad['description'] ?? '' + ]; + } + } else { + // Default Service Banners + $ads[] = [ + 'id' => $adId++, + 'type' => 'hospital_ad', + 'title' => 'In-House 24/7 Pharmacy', + 'tagline' => '100% Genuine Medicines & Fastest Counter Dispense', + 'image_url' => base_url('assets/img/slides-1.jpg'), + 'description' => 'Discounts on prescription billing. Doorstep delivery available for senior citizens and admitted patients.' + ]; + $ads[] = [ + 'id' => $adId++, + 'type' => 'hospital_ad', + 'title' => 'Advanced Radiology & Imaging Center', + 'tagline' => 'Digital X-Ray, 32-Slice CT Scan & 4D Ultrasound', + 'image_url' => base_url('assets/img/slides-2.jpg'), + 'description' => 'Accurate high-precision diagnostic imaging with immediate digital report generation.' + ]; + $ads[] = [ + 'id' => $adId++, + 'type' => 'hospital_ad', + 'title' => '24x7 Emergency & Critical Care ICU', + 'tagline' => 'Fully Equipped Ventilators, Cardiac Monitors & Trauma Team', + 'image_url' => base_url('assets/img/slides-3.jpg'), + 'description' => 'Round-the-clock emergency medical services with dedicated ICU & Operation Theater.' + ]; + } + + // Fetch Ticker & Left Ad Settings + $tickerRow = $db->table('hospital_setting')->select('s_value')->where('s_name', 'TV_QUEUE_FOOTER_TICKER')->get(1)->getRowArray(); + $leftAdTextRow = $db->table('hospital_setting')->select('s_value')->where('s_name', 'TV_QUEUE_LEFT_AD_TEXT')->get(1)->getRowArray(); + $leftAdImgRow = $db->table('hospital_setting')->select('s_value')->where('s_name', 'TV_QUEUE_LEFT_AD_IMAGE')->get(1)->getRowArray(); + $leftAdEnabledRow = $db->table('hospital_setting')->select('s_value')->where('s_name', 'TV_QUEUE_LEFT_AD_ENABLED')->get(1)->getRowArray(); + + $hospNameRow = $db->table('hospital_setting')->select('s_value')->where('s_name', 'H_Name')->get(1)->getRowArray(); return $this->response->setJSON([ 'status' => 1, - 'hospital_name' => 'E-Atria Multispeciality Hospital', + 'hospital_name' => !empty($hospNameRow['s_value']) ? $hospNameRow['s_value'] : 'E-Atria Multispeciality Hospital', 'server_time' => date('d-m-Y h:i:s A'), + 'footer_ticker' => !empty($tickerRow['s_value']) ? $tickerRow['s_value'] : 'Welcome to E-Atria Multispeciality Hospital. Please observe your token number on the screen. Voice announcements will call your turn. For assistance, contact the help desk. • Emergency Helpline: +91-9876543210 • 24/7 Pharmacy & Ambulance Services Available', + 'left_ad' => [ + 'enabled' => ($leftAdEnabledRow['s_value'] ?? '1') === '1', + 'text' => $leftAdTextRow['s_value'] ?? '24x7 Emergency ICU & Ambulance Available', + 'image_url' => !empty($leftAdImgRow['s_value']) ? base_url($leftAdImgRow['s_value']) : '' + ], 'trackers' => $allTrackers, 'ads' => $ads ]); diff --git a/app/Controllers/Setting/OpdQueueSetting.php b/app/Controllers/Setting/OpdQueueSetting.php new file mode 100644 index 0000000..60bd8c2 --- /dev/null +++ b/app/Controllers/Setting/OpdQueueSetting.php @@ -0,0 +1,193 @@ +db = db_connect(); + } + + public function index() + { + $tickerText = $this->getSetting('TV_QUEUE_FOOTER_TICKER', 'Welcome to E-Atria Multispeciality Hospital. Please observe your token number on the screen. Voice announcements will call your turn. For assistance, contact the help desk. • Emergency Helpline: +91-9876543210 • 24/7 Pharmacy & Ambulance Services Available'); + + $leftAdText = $this->getSetting('TV_QUEUE_LEFT_AD_TEXT', '24x7 Emergency & Trauma Center • ICU & Ventilator Available'); + $leftAdImage = $this->getSetting('TV_QUEUE_LEFT_AD_IMAGE', ''); + $leftAdEnabled = $this->getSetting('TV_QUEUE_LEFT_AD_ENABLED', '1'); + + $adsJson = $this->getSetting('TV_QUEUE_ADS_JSON', ''); + $customAds = []; + if ($adsJson !== '') { + $customAds = json_decode($adsJson, true) ?: []; + } + + return view('Setting/Admin/opd_queue_setting', [ + 'footer_ticker' => $tickerText, + 'left_ad_text' => $leftAdText, + 'left_ad_image' => $leftAdImage, + 'left_ad_enabled' => $leftAdEnabled, + 'custom_ads' => $customAds + ]); + } + + public function save() + { + if (!$this->request->isAJAX()) { + return $this->response->setJSON(['status' => 0, 'message' => 'Invalid request']); + } + + $post = $this->request->getPost(); + $ticker = trim((string) ($post['footer_ticker'] ?? '')); + $leftAdText = trim((string) ($post['left_ad_text'] ?? '')); + $leftAdEnabled = isset($post['left_ad_enabled']) ? '1' : '0'; + + if ($ticker !== '') { + $this->setSetting('TV_QUEUE_FOOTER_TICKER', $ticker); + } + $this->setSetting('TV_QUEUE_LEFT_AD_TEXT', $leftAdText); + $this->setSetting('TV_QUEUE_LEFT_AD_ENABLED', $leftAdEnabled); + + // Handle Left Bottom Ad Image Upload + $leftAdFile = $this->request->getFile('left_ad_image_file'); + if ($leftAdFile && $leftAdFile->isValid() && !$leftAdFile->hasMoved()) { + $ext = strtolower($leftAdFile->getExtension()); + if (in_array($ext, ['jpg', 'jpeg', 'png', 'webp'])) { + $targetDir = FCPATH . 'assets/images/tv_ads'; + if (!is_dir($targetDir)) @mkdir($targetDir, 0775, true); + + $newName = 'left_ad_' . date('Ymd_His') . '.' . $ext; + $leftAdFile->move($targetDir, $newName); + $this->setSetting('TV_QUEUE_LEFT_AD_IMAGE', 'assets/images/tv_ads/' . $newName); + } + } + + return $this->response->setJSON([ + 'status' => 1, + 'message' => 'OPD Queue TV Display settings updated successfully!' + ]); + } + + public function uploadBanner() + { + if (!$this->request->isAJAX()) { + return $this->response->setJSON(['status' => 0, 'message' => 'Invalid request']); + } + + $post = $this->request->getPost(); + $title = trim((string) ($post['title'] ?? '')); + $tagline = trim((string) ($post['tagline'] ?? '')); + $description = trim((string) ($post['description'] ?? '')); + $enabled = isset($post['enabled']) ? 1 : 0; + $slideType = trim((string) ($post['slide_type'] ?? 'hospital_ad')); + + $file = $this->request->getFile('banner_image'); + $imageUrl = ''; + + if ($file && $file->isValid() && !$file->hasMoved()) { + $ext = strtolower($file->getExtension()); + if (in_array($ext, ['jpg', 'jpeg', 'png', 'webp'])) { + $targetDir = FCPATH . 'assets/images/tv_ads'; + if (!is_dir($targetDir)) @mkdir($targetDir, 0775, true); + + $newName = 'ad_' . date('Ymd_His') . '_' . mt_rand(1000, 9999) . '.' . $ext; + $file->move($targetDir, $newName); + $imageUrl = 'assets/images/tv_ads/' . $newName; + } + } + + if ($imageUrl === '' && !empty($post['existing_image_url'])) { + $imageUrl = $post['existing_image_url']; + } + + if ($title === '') { + return $this->response->setJSON(['status' => 0, 'message' => 'Banner Title is required']); + } + + $adsJson = $this->getSetting('TV_QUEUE_ADS_JSON', ''); + $customAds = json_decode($adsJson, true) ?: []; + + $newSlide = [ + 'id' => time() . mt_rand(10, 99), + 'type' => $slideType, + 'title' => $title, + 'tagline' => $tagline, + 'description' => $description, + 'image_url' => $imageUrl !== '' ? base_url($imageUrl) : base_url('assets/img/slides-1.jpg'), + 'relative_image_url' => $imageUrl, + 'enabled' => $enabled + ]; + + $customAds[] = $newSlide; + $this->setSetting('TV_QUEUE_ADS_JSON', json_encode($customAds, JSON_UNESCAPED_SLASHES)); + + return $this->response->setJSON([ + 'status' => 1, + 'message' => 'Right Side Advertisement Banner added successfully!' + ]); + } + + public function deleteBanner() + { + if (!$this->request->isAJAX()) { + return $this->response->setJSON(['status' => 0, 'message' => 'Invalid request']); + } + + $post = $this->request->getPost(); + $bannerId = (int) ($post['banner_id'] ?? 0); + + $adsJson = $this->getSetting('TV_QUEUE_ADS_JSON', ''); + $customAds = json_decode($adsJson, true) ?: []; + $updatedAds = []; + + foreach ($customAds as $ad) { + if ((int) ($ad['id'] ?? 0) !== $bannerId) { + $updatedAds[] = $ad; + } + } + + $this->setSetting('TV_QUEUE_ADS_JSON', json_encode($updatedAds, JSON_UNESCAPED_SLASHES)); + + return $this->response->setJSON([ + 'status' => 1, + 'message' => 'Advertisement slide removed successfully!' + ]); + } + + private function getSetting(string $name, string $default = ''): string + { + $row = $this->db->table('hospital_setting') + ->select('s_value') + ->where('s_name', $name) + ->get(1) + ->getRowArray(); + + return trim((string) ($row['s_value'] ?? $default)); + } + + private function setSetting(string $name, string $value): bool + { + $existing = $this->db->table('hospital_setting') + ->select('id') + ->where('s_name', $name) + ->get(1) + ->getRowArray(); + + if ($existing) { + return $this->db->table('hospital_setting') + ->where('id', (int) $existing['id']) + ->update(['s_value' => $value]); + } else { + return $this->db->table('hospital_setting')->insert([ + 's_name' => $name, + 's_value' => $value + ]); + } + } +} diff --git a/app/Views/Setting/Admin/index.php b/app/Views/Setting/Admin/index.php index 3b67281..bad9a3f 100644 --- a/app/Views/Setting/Admin/index.php +++ b/app/Views/Setting/Admin/index.php @@ -100,6 +100,12 @@ ABDM Report Doctors +
+ + + OPD Queue TV + +
diff --git a/app/Views/Setting/Admin/opd_queue_setting.php b/app/Views/Setting/Admin/opd_queue_setting.php new file mode 100644 index 0000000..2fb140e --- /dev/null +++ b/app/Views/Setting/Admin/opd_queue_setting.php @@ -0,0 +1,210 @@ +
+ + +
+ +
+
+
+ Footer Scrolling Ticker Text +
+
+
+
+ + + This message scrolls continuously across the bottom of the TV screen. +
+ +
+ +
+ Left-Side Bottom Ad Space Settings +
+ +
+ > + +
+ +
+ + +
+ +
+ + + +
+ Current Banner: + +
+ +
+ + +
+
+
+
+ + +
+
+
+ Right-Side Showcase Ad Banners +
+
+
+
Add New Right-Side Showcase Slide
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+ +
+ +
Configured Right-Side Slides
+
+ +
+ No custom ad slides uploaded yet. Default system slides are active. +
+ +
+ +
+
+ + + +
No Img
+ +
+
+ +
+
+
+ +
+
+ +
+ +
+
+
+
+
+
+ + diff --git a/public/App/Queue/index.html b/public/App/Queue/index.html index 3f0fd75..1efb69d 100644 --- a/public/App/Queue/index.html +++ b/public/App/Queue/index.html @@ -289,6 +289,13 @@
+ + +