| 1 |
<?php |
| 2 |
/** |
| 3 |
* Setup Wizard - Complete Step |
| 4 |
* |
| 5 |
* @package Yatra |
| 6 |
*/ |
| 7 |
|
| 8 |
defined('ABSPATH') || exit; |
| 9 |
?> |
| 10 |
|
| 11 |
<div class="yatra-setup-step yatra-setup-complete"> |
| 12 |
<form method="post"> |
| 13 |
<?php wp_nonce_field('yatra-setup'); ?> |
| 14 |
|
| 15 |
<div class="yatra-setup-step-content"> |
| 16 |
<div class="yatra-setup-complete-icon"> |
| 17 |
<span class="dashicons dashicons-yes-alt"></span> |
| 18 |
</div> |
| 19 |
|
| 20 |
<h2><?php esc_html_e('Setup Complete!', 'yatra'); ?></h2> |
| 21 |
<p class="yatra-setup-description"> |
| 22 |
<?php esc_html_e('Congratulations! Your Yatra travel booking site is now ready to go. Complete your setup with sample data and explore premium features.', 'yatra'); ?> |
| 23 |
</p> |
| 24 |
|
| 25 |
<!-- Sample Data Import --> |
| 26 |
<div class="yatra-setup-sample-data"> |
| 27 |
<div class="yatra-setup-card"> |
| 28 |
<div class="yatra-setup-card-header"> |
| 29 |
<span class="dashicons dashicons-download"></span> |
| 30 |
<h3><?php esc_html_e('Import Sample Data', 'yatra'); ?></h3> |
| 31 |
</div> |
| 32 |
<div class="yatra-setup-card-body"> |
| 33 |
<p><?php esc_html_e('Get started quickly with pre-configured trips, destinations, and sample content. Perfect for testing and learning how Yatra works.', 'yatra'); ?></p> |
| 34 |
<ul class="yatra-sample-data-includes"> |
| 35 |
<li><span class="dashicons dashicons-yes"></span> <?php esc_html_e('5 Sample Trips with Images', 'yatra'); ?></li> |
| 36 |
<li><span class="dashicons dashicons-yes"></span> <?php esc_html_e('Popular Destinations', 'yatra'); ?></li> |
| 37 |
<li><span class="dashicons dashicons-yes"></span> <?php esc_html_e('Activities & Categories', 'yatra'); ?></li> |
| 38 |
<li><span class="dashicons dashicons-yes"></span> <?php esc_html_e('Sample Reviews & Ratings', 'yatra'); ?></li> |
| 39 |
</ul> |
| 40 |
<label class="yatra-checkbox-label"> |
| 41 |
<input type="checkbox" name="import_sample_data" value="yes"> |
| 42 |
<span><?php esc_html_e('Yes, import sample data to get started quickly', 'yatra'); ?></span> |
| 43 |
</label> |
| 44 |
</div> |
| 45 |
</div> |
| 46 |
</div> |
| 47 |
|
| 48 |
<!-- Premium Features --> |
| 49 |
<div class="yatra-setup-premium-features"> |
| 50 |
<h3 class="yatra-premium-heading"> |
| 51 |
<span class="dashicons dashicons-star-filled"></span> |
| 52 |
<?php esc_html_e('Unlock Premium Features', 'yatra'); ?> |
| 53 |
</h3> |
| 54 |
<p class="yatra-premium-description"> |
| 55 |
<?php esc_html_e('Take your travel booking business to the next level with Yatra Pro premium features:', 'yatra'); ?> |
| 56 |
</p> |
| 57 |
|
| 58 |
<div class="yatra-premium-features-grid"> |
| 59 |
<div class="yatra-premium-feature"> |
| 60 |
<span class="dashicons dashicons-chart-line"></span> |
| 61 |
<h4><?php esc_html_e('Dynamic Pricing', 'yatra'); ?></h4> |
| 62 |
<p><?php esc_html_e('Adjust prices based on demand, season, and availability', 'yatra'); ?></p> |
| 63 |
</div> |
| 64 |
<div class="yatra-premium-feature"> |
| 65 |
<span class="dashicons dashicons-tickets-alt"></span> |
| 66 |
<h4><?php esc_html_e('Discount Coupons', 'yatra'); ?></h4> |
| 67 |
<p><?php esc_html_e('Create promotional codes and special offers', 'yatra'); ?></p> |
| 68 |
</div> |
| 69 |
<div class="yatra-premium-feature"> |
| 70 |
<span class="dashicons dashicons-money-alt"></span> |
| 71 |
<h4><?php esc_html_e('Partial Payments', 'yatra'); ?></h4> |
| 72 |
<p><?php esc_html_e('Allow customers to pay deposits and installments', 'yatra'); ?></p> |
| 73 |
</div> |
| 74 |
<div class="yatra-premium-feature"> |
| 75 |
<span class="dashicons dashicons-email"></span> |
| 76 |
<h4><?php esc_html_e('Email Notifications', 'yatra'); ?></h4> |
| 77 |
<p><?php esc_html_e('Automated booking confirmations and reminders', 'yatra'); ?></p> |
| 78 |
</div> |
| 79 |
<div class="yatra-premium-feature"> |
| 80 |
<span class="dashicons dashicons-pdf"></span> |
| 81 |
<h4><?php esc_html_e('PDF Invoices', 'yatra'); ?></h4> |
| 82 |
<p><?php esc_html_e('Generate professional invoices and vouchers', 'yatra'); ?></p> |
| 83 |
</div> |
| 84 |
<div class="yatra-premium-feature"> |
| 85 |
<span class="dashicons dashicons-calendar-alt"></span> |
| 86 |
<h4><?php esc_html_e('Google Calendar Sync', 'yatra'); ?></h4> |
| 87 |
<p><?php esc_html_e('Sync bookings with Google Calendar automatically', 'yatra'); ?></p> |
| 88 |
</div> |
| 89 |
<div class="yatra-premium-feature"> |
| 90 |
<span class="dashicons dashicons-admin-multisite"></span> |
| 91 |
<h4><?php esc_html_e('Multi-Currency', 'yatra'); ?></h4> |
| 92 |
<p><?php esc_html_e('Accept payments in multiple currencies', 'yatra'); ?></p> |
| 93 |
</div> |
| 94 |
<div class="yatra-premium-feature"> |
| 95 |
<span class="dashicons dashicons-analytics"></span> |
| 96 |
<h4><?php esc_html_e('Advanced Reports', 'yatra'); ?></h4> |
| 97 |
<p><?php esc_html_e('Detailed analytics and business insights', 'yatra'); ?></p> |
| 98 |
</div> |
| 99 |
</div> |
| 100 |
|
| 101 |
<div class="yatra-premium-cta"> |
| 102 |
<a href="https://wpyatra.com/pricing" target="_blank" class="button button-primary button-large"> |
| 103 |
<span class="dashicons dashicons-star-filled"></span> |
| 104 |
<?php esc_html_e('Upgrade to Yatra Pro', 'yatra'); ?> |
| 105 |
</a> |
| 106 |
<p class="yatra-premium-note"> |
| 107 |
<?php esc_html_e('30-day money-back guarantee • Priority support included', 'yatra'); ?> |
| 108 |
</p> |
| 109 |
</div> |
| 110 |
</div> |
| 111 |
|
| 112 |
<div class="yatra-setup-next-steps"> |
| 113 |
<div class="yatra-setup-next-step"> |
| 114 |
<span class="dashicons dashicons-location-alt"></span> |
| 115 |
<div class="yatra-setup-next-step-content"> |
| 116 |
<h3><?php esc_html_e('Create Your First Trip', 'yatra'); ?></h3> |
| 117 |
<p><?php esc_html_e('Start by adding your travel packages and trip offerings.', 'yatra'); ?></p> |
| 118 |
<a href="<?php echo esc_url(admin_url('admin.php?page=yatra&subpage=trips')); ?>" class="button"> |
| 119 |
<?php esc_html_e('Add Trip', 'yatra'); ?> |
| 120 |
</a> |
| 121 |
</div> |
| 122 |
</div> |
| 123 |
|
| 124 |
<div class="yatra-setup-next-step"> |
| 125 |
<span class="dashicons dashicons-admin-settings"></span> |
| 126 |
<div class="yatra-setup-next-step-content"> |
| 127 |
<h3><?php esc_html_e('Configure Settings', 'yatra'); ?></h3> |
| 128 |
<p><?php esc_html_e('Fine-tune your booking settings, payment gateways, and more.', 'yatra'); ?></p> |
| 129 |
<a href="<?php echo esc_url(admin_url('admin.php?page=yatra&subpage=settings')); ?>" class="button"> |
| 130 |
<?php esc_html_e('Go to Settings', 'yatra'); ?> |
| 131 |
</a> |
| 132 |
</div> |
| 133 |
</div> |
| 134 |
|
| 135 |
<div class="yatra-setup-next-step"> |
| 136 |
<span class="dashicons dashicons-book"></span> |
| 137 |
<div class="yatra-setup-next-step-content"> |
| 138 |
<h3><?php esc_html_e('Read Documentation', 'yatra'); ?></h3> |
| 139 |
<p><?php esc_html_e('Learn more about Yatra features and best practices.', 'yatra'); ?></p> |
| 140 |
<a href="https://wpyatra.com/docs" target="_blank" class="button"> |
| 141 |
<?php esc_html_e('View Docs', 'yatra'); ?> |
| 142 |
</a> |
| 143 |
</div> |
| 144 |
</div> |
| 145 |
|
| 146 |
<div class="yatra-setup-next-step"> |
| 147 |
<span class="dashicons dashicons-star-filled"></span> |
| 148 |
<div class="yatra-setup-next-step-content"> |
| 149 |
<h3><?php esc_html_e('Upgrade to Pro', 'yatra'); ?></h3> |
| 150 |
<p><?php esc_html_e('Unlock advanced features like dynamic pricing, coupons, and more.', 'yatra'); ?></p> |
| 151 |
<a href="https://wpyatra.com/pricing" target="_blank" class="button button-primary"> |
| 152 |
<?php esc_html_e('View Pro Features', 'yatra'); ?> |
| 153 |
</a> |
| 154 |
</div> |
| 155 |
</div> |
| 156 |
</div> |
| 157 |
|
| 158 |
<div class="yatra-setup-support"> |
| 159 |
<h3><?php esc_html_e('Need Help?', 'yatra'); ?></h3> |
| 160 |
<p> |
| 161 |
<?php |
| 162 |
printf( |
| 163 |
/* translators: 1: support URL, 2: documentation URL */ |
| 164 |
__('Visit our <a href="%1$s" target="_blank">support forum</a> or check out the <a href="%2$s" target="_blank">documentation</a> for help.', 'yatra'), |
| 165 |
'https://wpyatra.com/support', |
| 166 |
'https://wpyatra.com/docs' |
| 167 |
); |
| 168 |
?> |
| 169 |
</p> |
| 170 |
</div> |
| 171 |
</div> |
| 172 |
|
| 173 |
</div> |
| 174 |
|
| 175 |
<div class="yatra-setup-actions"> |
| 176 |
<button type="submit" class="button button-primary button-large" name="save_step" value="complete" onclick="handleCompleteSetup(event)"> |
| 177 |
<?php esc_html_e('Complete Setup', 'yatra'); ?> |
| 178 |
</button> |
| 179 |
</div> |
| 180 |
</form> |
| 181 |
</div> |
| 182 |
|
| 183 |
<script> |
| 184 |
function handleCompleteSetup(event) { |
| 185 |
const checkbox = document.querySelector('input[name="import_sample_data"]'); |
| 186 |
const button = event.target; |
| 187 |
|
| 188 |
if (checkbox && checkbox.checked) { |
| 189 |
event.preventDefault(); |
| 190 |
|
| 191 |
// Show loading state |
| 192 |
button.disabled = true; |
| 193 |
button.innerHTML = '<?php esc_html_e('Importing Sample Data...', 'yatra'); ?>'; |
| 194 |
|
| 195 |
// Call the same API as Tools.tsx |
| 196 |
fetch('<?php echo rest_url('yatra/v1/sample-data/import'); ?>', { |
| 197 |
method: 'POST', |
| 198 |
headers: { |
| 199 |
'Content-Type': 'application/json', |
| 200 |
'X-WP-Nonce': '<?php echo wp_create_nonce('wp_rest'); ?>' |
| 201 |
}, |
| 202 |
body: JSON.stringify({ |
| 203 |
data_types: [], // Import all data types |
| 204 |
overwrite: false |
| 205 |
}) |
| 206 |
}) |
| 207 |
.then(response => response.json()) |
| 208 |
.then(data => { |
| 209 |
if (data.success) { |
| 210 |
// Show success message |
| 211 |
const successDiv = document.createElement('div'); |
| 212 |
successDiv.className = 'notice notice-success is-dismissible'; |
| 213 |
successDiv.style.marginTop = '20px'; |
| 214 |
successDiv.innerHTML = '<p><?php echo esc_html(__('Sample data imported successfully! Completing setup...', 'yatra')); ?></p>'; |
| 215 |
button.parentNode.insertBefore(successDiv, button); |
| 216 |
|
| 217 |
// Show detailed counts if available |
| 218 |
if (data.data) { |
| 219 |
const counts = data.data; |
| 220 |
const details = Object.keys(counts) |
| 221 |
.filter(key => counts[key] > 0) |
| 222 |
.map(key => `${key}: ${counts[key]}`) |
| 223 |
.join(', '); |
| 224 |
|
| 225 |
if (details) { |
| 226 |
const detailsDiv = document.createElement('div'); |
| 227 |
detailsDiv.style.marginTop = '10px'; |
| 228 |
detailsDiv.style.fontSize = '12px'; |
| 229 |
detailsDiv.style.color = '#6b7280'; |
| 230 |
detailsDiv.innerHTML = '<strong><?php esc_html_e('Imported:', 'yatra'); ?></strong> ' + details; |
| 231 |
button.parentNode.insertBefore(detailsDiv, button); |
| 232 |
} |
| 233 |
} |
| 234 |
|
| 235 |
// Submit form after successful import |
| 236 |
setTimeout(() => { |
| 237 |
button.form.submit(); |
| 238 |
}, 2000); |
| 239 |
} else { |
| 240 |
throw new Error(data.message || '<?php esc_html_e('Import failed', 'yatra'); ?>'); |
| 241 |
} |
| 242 |
}) |
| 243 |
.catch(error => { |
| 244 |
console.error('Sample data import error:', error); |
| 245 |
|
| 246 |
// Show error message |
| 247 |
const errorDiv = document.createElement('div'); |
| 248 |
errorDiv.className = 'notice notice-error is-dismissible'; |
| 249 |
errorDiv.style.marginTop = '20px'; |
| 250 |
errorDiv.innerHTML = '<p><?php echo esc_html(__('Failed to import sample data. Setup will continue without sample data.', 'yatra')); ?></p>'; |
| 251 |
button.parentNode.insertBefore(errorDiv, button); |
| 252 |
|
| 253 |
// Continue with setup after error |
| 254 |
setTimeout(() => { |
| 255 |
button.form.submit(); |
| 256 |
}, 2000); |
| 257 |
}); |
| 258 |
} else { |
| 259 |
// No sample data import requested, just submit form |
| 260 |
return true; |
| 261 |
} |
| 262 |
} |
| 263 |
</script> |
| 264 |
|