X7ROOT File Manager
Current Path:
/home/hamdjcne/app.hamdalillahitravel.com/app/Controllers
home
/
hamdjcne
/
app.hamdalillahitravel.com
/
app
/
Controllers
/
ðŸ“
..
📄
.DS_Store
(6 KB)
📄
Accounts.php
(52.25 KB)
📄
Activity.php
(4.49 KB)
📄
Analytics.php
(12.22 KB)
📄
Api.php
(41.41 KB)
📄
Auth.php
(34.64 KB)
📄
BaseController.php
(1.77 KB)
📄
Dashboard.php
(42.95 KB)
📄
Notification.php
(6.22 KB)
📄
Order.php
(118.16 KB)
📄
Service.php
(61.77 KB)
📄
Settings.php
(40.13 KB)
📄
Staff.php
(67.17 KB)
📄
Tour.php
(32.09 KB)
📄
Wallets.php
(43.15 KB)
📄
Webhook.php
(5.14 KB)
Editing: Tour.php
<?php namespace App\Controllers; class Tour extends BaseController { //////// Schedule //////// public function package($param1='', $param2='', $param3='') { // check session login if($this->session->get('hdt_id') == ''){ $request_uri = uri_string(); $this->session->set('hdt_redirect', $request_uri); return redirect()->to(site_url('auth')); } $mod = 'tour/package'; $log_id = $this->session->get('hdt_id'); $switch_id = $this->session->get('switch_church_id'); $role_id = $this->Crud->read_field('id', $log_id, 'user', 'role_id'); $role = strtolower($this->Crud->read_field('id', $role_id, 'access_role', 'name')); $role_c = $this->Crud->module($role_id, $mod, 'create'); $role_r = $this->Crud->module($role_id, $mod, 'read'); $role_u = $this->Crud->module($role_id, $mod, 'update'); $role_d = $this->Crud->module($role_id, $mod, 'delete'); if($role_r == 0){ return redirect()->to(site_url('dashboard')); } $data['log_id'] = $log_id; $data['role'] = $role; $data['role_c'] = $role_c; $table = 'tours'; $form_link = site_url($mod); if($param1){$form_link .= '/'.$param1;} if($param2){$form_link .= '/'.$param2.'/';} if($param3){$form_link .= $param3;} // pass parameters to view $data['param1'] = $param1; $data['param2'] = $param2; $data['param3'] = $param3; $data['form_link'] = rtrim($form_link, '/'); $data['current_language'] = $this->session->get('current_language'); // manage record if ($param1 == 'manage') { // Prepare for delete if ($param2 == 'delete') { if ($param3) { $edit = $this->Crud->read_single('id', $param3, $table); if (!empty($edit)) { foreach ($edit as $e) { $data['d_id'] = $e->id; } } if ($this->request->getMethod() == 'post') { $del_id = $this->request->getVar('d_id'); $by = $this->Crud->read_field('id', $log_id, 'user', 'fullname'); $action = $by . ' deleted a tour package'; // Delete Tour if ($this->Crud->deletes('id', $del_id, $table) > 0) { // Delete related Itineraries $this->Crud->deletes('tour_id', $del_id, 'itinerary'); // Delete related Pricing $this->Crud->deletes('tour_id', $del_id, 'tour_prices'); // Save Activity Log $this->Crud->activity('tour', $del_id, $action); echo $this->Crud->msg('success', 'Tour deleted successfully.'); echo '<script>location.reload(false);</script>'; } else { echo $this->Crud->msg('danger', 'Please try again later.'); } die; } } } else { if (($param2 == 'edit' && $param3) || ($param2 == 'view' && $param3)) { $tour = $this->Crud->read_single('id', $param3, 'tours'); if (!empty($tour)) { $itineraries = $this->Crud->read_single_order('tour_id', $param3, 'itinerary', 'day_number', 'asc'); $prices = $this->Crud->read_single_order('tour_id', $param3, 'tour_prices', 'amount', 'asc'); $resp = [ 'status' => 'success', 'data' => [ 'id' => $tour[0]->id, 'title' => $tour[0]->title, 'tour_type' => $tour[0]->tour_type, 'group_size' => $tour[0]->group_size, 'language' => $tour[0]->language, 'location' => $tour[0]->location, 'start_date' => $tour[0]->start_date, 'end_date' => $tour[0]->end_date, 'description' => $tour[0]->description, 'inclusions' => $tour[0]->inclusions, 'exclusions' => $tour[0]->exclusions, 'requirements' => $tour[0]->requirements, 'payment_details' => $tour[0]->payment_details, 'terms_conditions' => $tour[0]->terms_conditions, 'itinerary' => $itineraries, 'prices' => $prices, 'thumnbail_url' => $tour[0]->thumbnail_url, 'gallery_images' => $tour[0]->gallery_images, ] ]; } else { $resp = [ 'status' => 'error', 'message' => 'Tour not found.' ]; } echo json_encode($resp); die; } if ($this->request->getMethod() == 'post') { // Collect POST fields $tour_id = $this->request->getVar('tour_id'); $title = $this->request->getVar('title'); $location = $this->request->getVar('location'); $tour_type = $this->request->getVar('tour_type'); $group_size = $this->request->getVar('group_size'); $language = $this->request->getVar('language'); $start_date = $this->request->getVar('start_date'); $end_date = $this->request->getVar('end_date'); $description = $this->request->getVar('description'); $inclusions = $this->request->getVar('inclusions'); $exclusions = $this->request->getVar('exclusions'); $payment_details = $this->request->getVar('payment_details'); $terms_conditions = $this->request->getVar('terms_conditions'); $requirements = $this->request->getVar('requirements'); // Upload Thumbnail $thumbnail = ''; $thumbnailFile = $this->request->getFile('thumbnail'); if ($thumbnailFile && $thumbnailFile->isValid() && !$thumbnailFile->hasMoved()) { $thumbnail = $thumbnailFile->getRandomName(); $thumbnailFile->move('uploads/tours/thumbnails/', $thumbnail); } // Upload Gallery $gallery = []; $galleryFiles = $this->request->getFiles(); if (isset($galleryFiles['gallery'])) { foreach ($galleryFiles['gallery'] as $file) { if ($file->isValid() && !$file->hasMoved()) { $galleryName = $file->getRandomName(); $file->move('uploads/tours/gallery/', $galleryName); $gallery[] = $galleryName; } } } // Build Main Tour Data $data = [ 'title' => $title, 'location' => $location, 'tour_type' => $tour_type, 'group_size' => $group_size, 'language' => $language, 'start_date' => date('Y-m-d', strtotime($start_date)), 'end_date' => date('Y-m-d', strtotime($end_date)), 'description' => $description, 'inclusions' => $inclusions, 'exclusions' => $exclusions, 'requirements' => $requirements, 'payment_details' => $payment_details, 'terms_conditions' => $terms_conditions, 'updated_at' => date('Y-m-d H:i:s'), ]; if (!empty($thumbnail)) { $data['thumbnail_url'] = $thumbnail; } if (!empty($gallery)) { $data['gallery_images'] = json_encode($gallery); // Save gallery as JSON } // Create or Update Tour if (!empty($tour_id)) { $this->Crud->updates('id', $tour_id, $table, $data); $currentTourId = $tour_id; } else { $data['reg_date'] = date('Y-m-d H:i:s'); $currentTourId = $this->Crud->create($table, $data); } if (!$currentTourId) { echo $this->Crud->msg('danger', 'Failed to save tour.'); die; } //------------------------- // Delete old Itineraries and Prices if Updating //------------------------- if (!empty($tour_id)) { $this->Crud->deletes('tour_id', $currentTourId, 'itinerary'); $this->Crud->deletes('tour_id',$currentTourId, 'tour_prices'); } //------------------------- // Save Itineraries //------------------------- $day_ranges = $this->request->getVar('day_range'); $day_titles = $this->request->getVar('day_title'); $day_descriptions = $this->request->getVar('day_description'); if (!empty($day_titles) && is_array($day_titles)) { foreach ($day_titles as $index => $day_title) { $itineraryData = [ 'tour_id' => $currentTourId, 'day_number' => $day_ranges[$index] ?? '', 'title' => $day_title, 'description' => $day_descriptions[$index] ?? '' ]; $this->Crud->create('itinerary', $itineraryData); // Your itinerary table } } //------------------------- // Save Pricing //------------------------- $price_labels = $this->request->getVar('price_label'); $amounts = $this->request->getVar('amount'); $starting_price = null; if (!empty($price_labels) && is_array($price_labels)) { foreach ($price_labels as $index => $label) { $amount = $amounts[$index] ?? 0; $priceData = [ 'tour_id' => $currentTourId, 'price_label' => $label, 'amount' => $amount ]; $this->Crud->create('tour_prices', $priceData); // Your pricing table // Find starting price (lowest price) if ($starting_price === null || $amount < $starting_price) { $starting_price = $amount; } } } //------------------------- // Update Tour with Starting Price //------------------------- if (!empty($starting_price)) { $this->Crud->updates('id', $currentTourId, $table, [ 'starting_price' => $starting_price, ]); } //------------------------- // Log Activity //------------------------- $by = $this->Crud->read_field('id', $log_id, 'user', 'fullname'); $action = (!empty($tour_id)) ? "$by updated a tour: $title" : "$by created a new tour: $title"; $this->Crud->activity('tour', $currentTourId, $action); echo $this->Crud->msg('success', 'Tour saved successfully.'); echo '<script>location.reload();</script>'; die; } } } if($param1 == 'createTourType'){ $tour_type = $this->request->getPost('tour_type'); if (empty($tour_type)) { return $this->response->setJSON(['status' => 'error']); } // Check if it already exists $exists = $this->Crud->check('name', $tour_type, 'tour_type'); if ($exists) { return $this->response->setJSON(['status' => 'exists']); } // Insert into DB $this->Crud->create('tour_type', ['name' => $tour_type]); return $this->response->setJSON(['status' => 'success']); } if ($param1 == 'load') { $limit = $param2; $offset = $param3; $rec_limit = 50; $item = ''; if (empty($limit)) { $limit = $rec_limit; } if (empty($offset)) { $offset = 0; } $status = $this->request->getPost('status') ?? ''; $search = $this->request->getPost('search'); $log_id = $this->session->get('hdt_id'); if (!$log_id) { $item = '<div class="text-center text-muted">Session Timeout! - Please login again</div>'; } else { $all_rec = $this->Crud->filter_tour('', '', $log_id, $status, $search); // ➡️ Adjusted: use tour filter $counts = !empty($all_rec) ? count($all_rec) : 0; $query = $this->Crud->filter_tour($limit, $offset, $log_id, $status, $search); // ➡️ Adjusted if (!empty($query)) { foreach ($query as $q) { $id = $q->id; $reg_date = date('M d, Y h:i A', strtotime($q->reg_date ?? $q->created_at)); $title = ucwords($q->title ?? ''); $location = ucwords($q->location ?? ''); $group_size = $q->group_size ?? '-'; $start_date = !empty($q->start_date) ? date('M d, Y', strtotime($q->start_date)) : '-'; $end_date = !empty($q->end_date) ? date('M d, Y', strtotime($q->end_date)) : '-'; $starting_price = !empty($q->starting_price) ? number_format($q->starting_price) : 'N/A'; $tour_type = ucfirst($this->Crud->read_field('id',$q->tour_type,'tour_type', 'name') ?? 'Package'); // Status badge (optional if you have a status field) $status_badge = '<span class="badge bg-success">Active</span>'; $duration = $this->Crud->date_diff($start_date, $end_date); // Action Buttons $all_btn = ' <a href="javascript:;" class="me-2 btn btn-icon btn-primary btn-active-color-light btn-sm" data-bs-toggle="tooltip" title="View Tour" onclick="viewTour('.$id.')" > <i class="ki-outline ki-eye fs-2"></i> </a> <a href="javascript:;" class="me-2 btn btn-icon btn-info btn-active-color-light btn-sm" data-bs-toggle="tooltip" title="Edit Tour" onclick="editTour('.$id.')" > <i class="ki-outline ki-pencil fs-2"></i> </a> <a href="javascript:;" class="pop btn btn-icon me-2 btn-danger btn-active-color-light btn-sm me-2" data-bs-toggle="tooltip" data-bs-placement="top" title="Delete Tor Package" pageTitle="Delete Tor Package '.$title.'" pageName="'.site_url($mod.'/manage/delete/'.$id).'"> <i class="ki-duotone ki-trash fs-2"><span class="path1"></span><span class="path2"></span><span class="path3"></span><span class="path4"></span><span class="path5"></span></i> </a> '; $item .= ' <tr> <td>'.$reg_date.'</td> <td>'.htmlspecialchars($title).'</td> <td>'.htmlspecialchars($location).'</td> <td>'.$duration.' Days</td> <td>'.$group_size.'</td> <td>'.$tour_type.'</td> <td>$'.$starting_price.'</td> <td> <div class="d-flex justify-content-end flex-shrink-0">'.$all_btn.'</div> </td> </tr> '; } } } // Build response if (empty($item)) { $resp['item'] = ' <tr> <td colspan="8"> <div class="text-center text-muted"> <br/><br/><br/> <i class="ki-outline ki-airplane" style="font-size:150px;"></i><br/><br/>No Tours Found </div> </td> </tr> '; } else { $resp['item'] = $item; } $resp['count'] = $counts; $more_record = $counts - ($offset + $rec_limit); $resp['left'] = $more_record; if ($counts > ($offset + $rec_limit)) { $resp['limit'] = $rec_limit; $resp['offset'] = $offset + $limit; } else { $resp['limit'] = 0; $resp['offset'] = 0; } echo json_encode($resp); die; } if($param1 == 'manage') { // view for form data posting return view($mod.'_form', $data); } else { // view for main page $data['title'] = 'Package - '.app_name; $data['page_active'] = $mod; return view($mod, $data); } } public function hotel($param1='', $param2='', $param3='') { // check session login if($this->session->get('hdt_id') == ''){ $request_uri = uri_string(); $this->session->set('hdt_redirect', $request_uri); return redirect()->to(site_url('auth')); } $mod = 'service/hotel'; $log_id = $this->session->get('hdt_id'); $switch_id = $this->session->get('switch_church_id'); $role_id = $this->Crud->read_field('id', $log_id, 'user', 'role_id'); $role = strtolower($this->Crud->read_field('id', $role_id, 'access_role', 'name')); $role_c = $this->Crud->module($role_id, $mod, 'create'); $role_r = $this->Crud->module($role_id, $mod, 'read'); $role_u = $this->Crud->module($role_id, $mod, 'update'); $role_d = $this->Crud->module($role_id, $mod, 'delete'); if($role_r == 0){ return redirect()->to(site_url('dashboard')); } $data['log_id'] = $log_id; $data['role'] = $role; $data['role_c'] = $role_c; $table = 'hotel_request'; $form_link = site_url($mod); if($param1){$form_link .= '/'.$param1;} if($param2){$form_link .= '/'.$param2.'/';} if($param3){$form_link .= $param3;} // pass parameters to view $data['param1'] = $param1; $data['param2'] = $param2; $data['param3'] = $param3; $data['form_link'] = rtrim($form_link, '/'); $data['current_language'] = $this->session->get('current_language'); // manage record if($param1 == 'manage') { // prepare for delete if($param2 == 'delete') { if($param3) { $edit = $this->Crud->read_single('id', $param3, $table); //echo var_dump($edit); if(!empty($edit)) { foreach($edit as $e) { $data['d_id'] = $e->id; } } if($this->request->getMethod() == 'post'){ $del_id = $this->request->getVar('d_id'); $by = $this->Crud->read_field('id', $log_id, 'user', 'fullname'); $action = $by.' deleted Flight Request '; if($this->Crud->deletes('id', $del_id, $table) > 0) { $this->Crud->activity('flight_request', $del_id, $action); echo $this->Crud->msg('success', 'Flight Request Deleted'); echo '<script>location.reload(false);</script>'; } else { echo $this->Crud->msg('danger', 'Please try later'); } die; } } } else { $data['isEdit'] = ''; // prepare for edit if($param2 == 'edit') { if($param3) { $edit = $this->Crud->read_single('id', $param3, $table); $data['isEdit'] = isset($edit); if(!empty($edit)) { foreach($edit as $hotel) { $data = [ 'isEdit' => true, 'e_id' => $hotel->id, 'e_city' => $hotel->city, 'e_country' => $hotel->country, 'e_check_in_date' => $hotel->check_in_date, 'e_check_out_date' => $hotel->check_out_date, 'e_rooms' => $hotel->rooms, 'e_adults' => $hotel->adults, 'e_children' => $hotel->children, 'e_infants' => $hotel->infants, 'e_special_requests' => $hotel->special_requests, 'e_status' => $hotel->booking_status ]; } } } } // prepare for view if ($param2 == 'view') { if ($param3) { $edit = $this->Crud->read_single('id', $param3, $table); if (!empty($edit)) { foreach ($edit as $hotel) { $data = [ 'isEdit' => true, 'e_id' => $hotel->id, 'e_city' => $hotel->city, 'e_location' => $hotel->city.' '.$hotel->country, 'e_check_in_date' => $hotel->check_in_date, 'e_check_out_date' => $hotel->check_out_date, 'e_rooms' => $hotel->rooms, 'e_adults' => $hotel->adults, 'e_children' => $hotel->children, 'e_infants' => $hotel->infants, 'e_special_requests' => $hotel->special_requests, 'e_status' => $hotel->booking_status ]; $data['e_created_at'] = $hotel->reg_date; $data['e_updated_date'] = $hotel->updated_at; } } } } if ($this->request->getMethod() == 'post') { $booking_id = $this->request->getVar('booking_id'); $city = $this->request->getVar('city'); $country = $this->request->getVar('country'); $check_in_date = $this->request->getVar('check_in_date'); $check_out_date = $this->request->getVar('check_out_date'); $rooms = $this->request->getVar('rooms'); $adults = $this->request->getVar('adults'); $children = $this->request->getVar('children'); $infants = $this->request->getVar('infants'); $special_requests = $this->request->getVar('special_requests'); $booking_status = $this->request->getVar('booking_status') ?? 'Pending'; // Build data array $data = [ 'user_id' => $log_id, 'city' => $city, 'country' => $country, 'check_in_date' => $check_in_date, 'check_out_date' => $check_out_date, 'rooms' => $rooms, 'adults' => $adults, 'children' => $children, 'infants' => $infants, 'special_requests' => $special_requests, 'booking_status' => $booking_status, 'updated_at' => date('Y-m-d H:i:s'), ]; // Create or Update if (!empty($booking_id)) { $updated = $this->Crud->updates('id', $booking_id, $table, $data); if ($updated > 0) { $by = $this->Crud->read_field('id', $log_id, 'user', 'fullname'); $action = $by . ' updated a hotel booking at ' . ucwords($city); $this->Crud->activity('hotel', $booking_id, $action); echo $this->Crud->msg('success', 'Hotel Booking Request updated'); echo '<script>location.reload();</script>'; } else { echo $this->Crud->msg('info', 'No changes made'); } } else { $data['reg_date'] = date('Y-m-d H:i:s'); $inserted = $this->Crud->create($table, $data); if ($inserted > 0) { $by = $this->Crud->read_field('id', $log_id, 'user', 'fullname'); $action = $by . ' booked a hotel in ' . ucwords($city); $this->Crud->activity('hotel', $inserted, $action); echo $this->Crud->msg('success', 'Hotel Booking Request created'); echo '<script>location.reload();</script>'; } else { echo $this->Crud->msg('danger', 'Failed to book hotel. Try again.'); } } die; } } } if ($param1 == 'load') { $limit = $param2; $offset = $param3; $rec_limit = 50; $item = ''; if (empty($limit)) { $limit = $rec_limit; } if (empty($offset)) { $offset = 0; } $status = $this->request->getPost('status') ?? ''; $search = $this->request->getPost('search'); $log_id = $this->session->get('hdt_id'); if (!$log_id) { $item = '<div class="text-center text-muted">Session Timeout! - Please login again</div>'; } else { $all_rec = $this->Crud->filter_hotel('', '', $log_id, $status, $search); $counts = !empty($all_rec) ? count($all_rec) : 0; $query = $this->Crud->filter_hotel($limit, $offset, $log_id, $status, $search); if (!empty($query)) { foreach ($query as $q) { $id = $q->id; $reg_date = date('M d, Y h:i A', strtotime($q->created_at ?? $q->reg_date)); $user = $this->Crud->read_field('id', $q->user_id, 'user', 'fullname'); $city = $q->city; $country = $q->country; $check_in = date('Y-m-d', strtotime($q->check_in_date)); $check_out = date('Y-m-d', strtotime($q->check_out_date)); $status = $q->booking_status; $rooms = $q->rooms; $adults = $q->adults; $children = $q->children; $infants = $q->infants; $guests = $adults + $children + $infants; // Status badge $status_badge = '<span class="badge bg-warning">Pending</span>'; if ($status === 'Confirmed') { $status_badge = '<span class="badge bg-success">Confirmed</span>'; } elseif ($status === 'Cancelled') { $status_badge = '<span class="badge bg-danger">Cancelled</span>'; } // Action buttons $all_btn = ' <a href="javascript:;" class="me-2 btn btn-icon btn-primary btn-active-color-light btn-sm" data-bs-toggle="tooltip" title="View Booking" onclick="ticket('.$id.')" > <i class="ki-outline ki-eye fs-2"></i> </a> '; $item .= ' <tr> <td>' . $reg_date . '</td> <td>' . ucwords($user) . '</td> <td>' . ucwords($city . ', ' . $country) . '</td> <td> <span class="text">Check-in: ' . $check_in . '<br>Check-out: ' . $check_out . '</span> </td> <td> <span class="text">Rooms: ' . $rooms . '<br>Guests: ' . $guests . '<br>' . $status_badge . '</span> </td> <td> <div class="d-flex justify-content-end flex-shrink-0">' . $all_btn . '</div> </td> </tr> '; } } } // echo $item; // Response setup if (empty($item)) { $resp['item'] = ' <tr> <td colspan="8"> <div class="text-center text-muted"> <br/><br/><br/> <i class="ki-outline ki-cheque" style="font-size:150px;"></i><br/><br/>' . translate_phrase('No Request Returned') . ' </div> </td> </tr> '; } else { $resp['item'] = $item; } $resp['count'] = $counts; $more_record = $counts - ($offset + $rec_limit); $resp['left'] = $more_record; if ($counts > ($offset + $rec_limit)) { $resp['limit'] = $rec_limit; $resp['offset'] = $offset + $limit; } else { $resp['limit'] = 0; $resp['offset'] = 0; } echo json_encode($resp); die; } // pass parameters to view $data['param1'] = $param1; $data['param2'] = $param2; $data['param3'] = $param3; $data['form_link'] = rtrim($form_link, '/'); $data['current_language'] = $this->session->get('current_language'); if($param1 == 'manage') { // view for form data posting return view($mod.'_form', $data); } else { // view for main page $data['title'] = 'Hotel Booking Request - '.app_name; $data['page_active'] = $mod; return view($mod, $data); } } public function ticket($param1='', $param2=''){ if ($param1 == 'load') { $id = $this->request->getPost('id') ?? ''; $type = $this->request->getPost('type'); $log_id = $this->session->get('hdt_id'); $user_id = $this->Crud->read_field('id', $id, $type.'_request', 'user_id'); $reg_date = $this->Crud->read_field('id', $id, $type.'_request', 'reg_date'); $adults = $this->Crud->read_field('id', $id, $type.'_request', 'adults'); $children = $this->Crud->read_field('id', $id, $type.'_request', 'children'); $infants = $this->Crud->read_field('id', $id, $type.'_request', 'infants'); $user = $this->Crud->read_field('id', $user_id, 'user', 'fullname'); $timez = $this->Crud->timespan(strtotime($reg_date)); $regdate = date('d F Y, h:iA', strtotime($reg_date)); if ($type === 'hotel') { $city = $this->Crud->read_field('id', $id, $type.'_request', 'city'); $country = $this->Crud->read_field('id', $id, $type.'_request', 'country'); $rooms = $this->Crud->read_field('id', $id, $type.'_request', 'rooms'); $hotel_location = $city.' '.$country; $check_in_date = date('d F Y', strtotime($this->Crud->read_field('id', $id, $type.'_request', 'check_in_date'))); $check_out_date = date('d F Y', strtotime($this->Crud->read_field('id', $id, $type.'_request', 'check_out_date'))); $special_request = $this->Crud->read_field('id', $id, $type.'_request', 'special_requests'); // Hotel Request Sentence $summary = "{$user} requested a hotel booking service in {$hotel_location}, "; $summary .= "for {$rooms} room(s), "; $summary .= "with {$adults} adult(s), {$children} child(ren), and {$infants} infant(s), "; $summary .= "checking in on {$check_in_date} and checking out on {$check_out_date}."; if (!empty($special_request)) { $summary .= " Specially requesting {$special_request}."; } } elseif ($type === 'flight') { $from_city = $this->Crud->read_field('id', $id, $type.'_request', 'from_city'); $to_city = $this->Crud->read_field('id', $id, $type.'_request', 'to_city'); $trip_type = $this->Crud->read_field('id', $id, $type.'_request', 'trip_type'); $travel_class = $this->Crud->read_field('id', $id, $type.'_request', 'travel_class'); $departure_date = $this->Crud->read_field('id', $id, $type.'_request', 'departure_date'); // Flight Request Sentence $summary = "{$user} requested a flight booking service from {$from_city} to {$to_city}, "; $summary .= "for a {$trip_type} trip in {$travel_class} class, "; $summary .= "departing on {$departure_date}"; if (!empty($return_date)) { $summary .= " and returning on {$return_date}"; } $summary .= ". Travel party includes {$adults} adult(s), {$children} child(ren), and {$infants} infant(s)."; if (!empty($special_request)) { $summary .= " Specially requesting {$special_request}."; } } else { // Default fallback $summary = "{$user} submitted a travel service request. Please review the details."; } $header = ' <!--begin::Title--> <h1 class="text-gray-800 fw-semibold">'.strtoupper($type.' Booking Request'). '- 00'.$id.'</h1> <!--end::Title--> <!--begin::Info--> <div class=""> <!--begin::Label--> <span class="fw-semibold text-muted me-6">Service: <a href="#" class="text-muted text-hover-primary">'.ucwords($type).'</a></span> <!--end::Label--> <!--begin::Label--> <span class="fw-semibold text-muted me-6">By: <a href="javascript:;" class="text-muted text-hover-primary">'.ucwords($user).'</a></span> <!--end::Label--> <!--begin::Label--> <span class="fw-semibold text-muted">Created: <span class="fw-bold text-gray-600 me-1">'.$timez.'</span>('.$regdate.')</span> <!--end::Label--> </div> <!--end::Info--> '; $body = ' <!--begin::Description--> <div class="mb-15 fs-5 fw-normal text-gray-800"> <!--begin::Text--> <div class="mb-5 fs-5">Hello,</div> <!--end::Text--> <!--begin::Text--> <div class="mb-10"> '.$summary.' </div> </div> <!--end::Description--> <!--begin::Input group--> <div class="mb-0"> <textarea class="form-control form-control-solid placeholder-gray-600 fw-bold fs-4 ps-9 pt-7" rows="6" name="message" id="ticket_message_'.$id.'" placeholder="Type Response"></textarea> <!--begin::Submit--> <button type="button" data-id="'.$id.'" data-type="'.$type.'" class="btn btn-primary mt-n20 mb-20 position-relative float-end me-7 message_btn">Send</button> <!--end::Submit--> </div> <!-- Response Message (hidden initially) --> <div id="message_response_'.$id.'" class="mt-3 text-success fw-semibold" style="display: none;"></div> '; $resp['header'] = $header; $resp['body'] = $body; echo json_encode($resp); die; } if ($param1 == 'get_message') { $id = $this->request->getPost('ticket_id'); $type = $this->request->getPost('type'); $query = $this->Crud->read2('request_type', $type, 'request_id', $id, 'request_message'); $item = ''; if (!empty($query)) { foreach ($query as $q) { $id = $q->id; $reg_date = date('M d, Y h:i A', strtotime($q->created_at ?? $q->reg_date)); $user = $this->Crud->read_field('id', $q->user_id, 'user', 'fullname'); $user_type = $q->user_type; $message = $q->message; $img = $this->Crud->image_name($user); $timeago = $this->Crud->timespan(strtotime($q->reg_date)); $item .= ' <div class="mb-9"> <!--begin::Card--> <div class="card card-bordered w-100"> <!--begin::Body--> <div class="card-body"> <!--begin::Wrapper--> <div class="w-100 d-flex flex-stack mb-8"> <!--begin::Container--> <div class="d-flex align-items-center f"> <!--begin::Author--> <div class="symbol symbol-50px me-5"> <div class="symbol-label fs-1 fw-bold bg-light-success text-success"> '.$img.' </div> </div> <!--end::Author--> <!--begin::Info--> <div class="d-flex flex-column fw-semibold fs-5 text-gray-600 text-gray-900"> <!--begin::Text--> <div class="d-flex align-items-center"> <!--begin::Username--> <a href="javascript:;" class="text-gray-800 fw-bold text-hover-primary fs-5 me-3">'.ucwords($user).'</a> <!--end::Username--> <span class="m-0"></span> </div> <!--end::Text--> <!--begin::Date--> <span class="text-muted fw-semibold fs-6">'.$timeago.'</span> <!--end::Date--> </div> <!--end::Info--> </div> </div> <!--end::Wrapper--> <!--begin::Desc--> <p class="fw-normal fs-5 text-gray-700 m-0"> '.ucwords($q->message).' </p> <!--end::Desc--> </div> <!--end::Body--> </div> <!--end::Card--> </div> '; } } // echo $item; // Response setup if (empty($item)) { $resp['item'] = ' <div class="text-center text-muted"> <br/><br/><br/> <i class="ki-outline ki-message-notif" style="font-size:150px;"></i><br/><br/>' . translate_phrase('No Message Returned') . ' </div> '; } else { $resp['item'] = $item; } echo json_encode($resp); die; } $log_id = $this->session->get('hdt_id'); if ($param1 == 'message'){ $request_id = $this->request->getPost('ticket_id'); $request_type = $this->request->getPost('type'); $message = $this->request->getPost('message'); $is_member = $this->Crud->read_field('id', $log_id, 'user', 'is_member'); $user_type = 'Admin'; if($is_member > 0){ $user_type = 'Member'; } $ins = [ 'user_id' => $log_id, 'user_type' => $user_type, 'request_id'=> $request_id, 'request_type' => $request_type, 'message' => $message, 'reg_date'=> date(fdate) ]; $ins_rec = $this->Crud->create('request_message', $ins); die; } } }
Upload File
Create Folder