PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.6
Yatra – Travel Booking & Tour Operator Software v3.0.6
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
yatra / templates / partials / single-trip / content-downloads.php

content-downloads.php in Yatra – Travel Booking & Tour Operator Software 3.0.6, at templates/partials/single-trip/content-downloads.php

150 lines 8.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) {
3 exit;
4 }
5
6 // Downloads Section - List View with Download Icons
7 // Expected variables: $trip
8 ?>
9 <section class="yatra-trip-section" id="downloads">
10 <h2 class="yatra-trip-section-title">
11 <?php yatra_render_tab_icon($tab->icon ?? null, 'download', 'yatra-trip-section-title-icon', $tab->label ?? __('Downloads', 'yatra')); ?>
12 <?php echo esc_html(isset($tab->label) ? $tab->label : __('Downloads', 'yatra')); ?>
13 </h2>
14
15 <div class="yatra-downloads-container">
16 <div class="yatra-downloads-list">
17 <?php
18 $downloads = $trip->getDownloadableItems();
19 foreach ($downloads as $download): ?>
20 <div class="yatra-download-item" data-download-id="<?php echo esc_attr($download->id); ?>">
21 <div class="yatra-download-icon">
22 <?php
23 // Get appropriate icon based on file type
24 $fileIcon = 'file-text'; // default
25 if (!empty($download->file_type)) {
26 $fileType = strtolower($download->file_type);
27 if (strpos($fileType, 'pdf') !== false) {
28 $fileIcon = 'file-text';
29 } elseif (strpos($fileType, 'image') !== false) {
30 $fileIcon = 'image';
31 } elseif (strpos($fileType, 'video') !== false) {
32 $fileIcon = 'video';
33 } elseif (strpos($fileType, 'audio') !== false) {
34 $fileIcon = 'music';
35 } elseif (strpos($fileType, 'zip') !== false || strpos($fileType, 'rar') !== false) {
36 $fileIcon = 'archive';
37 } elseif (strpos($fileType, 'doc') !== false || strpos($fileType, 'word') !== false) {
38 $fileIcon = 'file-text';
39 } elseif (strpos($fileType, 'xls') !== false || strpos($fileType, 'excel') !== false) {
40 $fileIcon = 'file-text';
41 } elseif (strpos($fileType, 'ppt') !== false || strpos($fileType, 'powerpoint') !== false) {
42 $fileIcon = 'file-text';
43 }
44 }
45 echo yatra_svg_icon($fileIcon, 'yatra-download-file-icon');
46 ?>
47 </div>
48
49 <div class="yatra-download-content">
50 <h3 class="yatra-download-title">
51 <?php echo esc_html($download->title); ?>
52 </h3>
53
54 <?php if (!empty($download->description)): ?>
55 <p class="yatra-download-description">
56 <?php echo esc_html($download->description); ?>
57 </p>
58 <?php endif; ?>
59
60 <div class="yatra-download-meta">
61 <?php if (!empty($download->file_size)): ?>
62 <span class="yatra-download-file-size">
63 <?php
64 $fileSize = $download->file_size;
65 if ($fileSize >= 1048576) {
66 echo esc_html(round($fileSize / 1048576, 2) . ' MB');
67 } elseif ($fileSize >= 1024) {
68 echo esc_html(round($fileSize / 1024, 2) . ' KB');
69 } else {
70 echo esc_html($fileSize . ' bytes');
71 }
72 ?>
73 </span>
74 <?php endif; ?>
75
76 <?php if (!empty($download->file_type)): ?>
77 <span class="yatra-download-file-type">
78 <?php echo esc_html(strtoupper($download->file_type)); ?>
79 </span>
80 <?php endif; ?>
81 </div>
82 </div>
83
84 <div class="yatra-download-action">
85 <?php if ($download->is_downloadable): ?>
86 <?php
87 $visibility = $download->visibility ?? 'booked_only';
88 $canDownload = false;
89 $downloadBtnText = __('Download', 'yatra');
90 $downloadBtnClass = 'yatra-download-btn';
91
92 // Check visibility permissions
93 if ($visibility === 'public') {
94 $canDownload = true;
95 } elseif ($visibility === 'logged_in') {
96 if (is_user_logged_in()) {
97 $canDownload = true;
98 } else {
99 $downloadBtnText = __('Login to Download', 'yatra');
100 $downloadBtnClass .= ' yatra-download-btn-disabled';
101 }
102 } elseif ($visibility === 'booked_only') {
103 // Check if user has booking for this trip
104 $userBookings = [];
105 if (is_user_logged_in()) {
106 // Get user's bookings for this trip
107 $customer_id = get_current_user_id();
108 // In a real implementation, you'd query bookings here
109 // For now, we'll show a message
110 $downloadBtnText = __('Booking Required', 'yatra');
111 $downloadBtnClass .= ' yatra-download-btn-disabled';
112 } else {
113 $downloadBtnText = __('Login & Booking Required', 'yatra');
114 $downloadBtnClass .= ' yatra-download-btn-disabled';
115 }
116 }
117
118 // Add data attributes for JavaScript
119 $dataAttrs = sprintf(
120 'data-download-id="%s" data-visibility="%s"',
121 esc_attr($download->id),
122 esc_attr($visibility)
123 );
124
125 if ($canDownload): ?>
126 <a href="#" class="<?php echo esc_attr($downloadBtnClass); ?>" <?php echo $dataAttrs; ?>>
127 <?php echo yatra_svg_icon('download', 'yatra-download-btn-icon'); ?>
128 <?php echo esc_html($downloadBtnText); ?>
129 </a>
130 <?php else: ?>
131 <span class="<?php echo esc_attr($downloadBtnClass); ?>" <?php echo $dataAttrs; ?>>
132 <?php echo yatra_svg_icon('lock', 'yatra-download-btn-icon'); ?>
133 <?php echo esc_html($downloadBtnText); ?>
134 </span>
135 <?php endif; ?>
136 <?php endif; ?>
137 </div>
138 </div>
139 <?php endforeach; ?>
140 <?php if (empty($downloads)): ?>
141 <div class="yatra-no-downloads">
142 <p class="text-gray-500 text-center py-8">
143 <?php echo esc_html__('No downloads available for this trip.', 'yatra'); ?>
144 </p>
145 </div>
146 <?php endif; ?>
147 </div>
148 </div>
149 </section>
150