PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | admin/views/sampledata/tmpl/default.php +125 -0 1.6.3 → 1.8.16 View file →
@@ -1,0 +1,125 @@
1 +<?php
2 +/**
3 + * @package VikBooking
4 + * @subpackage com_vikbooking
5 + * @author Alessio Gaggii - e4j - Extensionsforjoomla.com
6 + * @copyright Copyright (C) 2018 e4j - Extensionsforjoomla.com. All rights reserved.
7 + * @license GNU General Public License version 2 or later; see LICENSE
8 + * @link https://vikwp.com
9 + */
10 +
11 +defined('ABSPATH') or die('No script kiddies please!');
12 +
13 +?>
14 +
15 +<form action="admin.php" method="post" name="adminForm" id="adminForm">
16 + <input type="hidden" name="option" value="com_vikbooking" />
17 + <input type="hidden" name="task" value="" />
18 +</form>
19 +
20 +<div class="vbo-dashboard-firstsetup-container vbo-sampledata-container">
21 + <div class="vbo-dashboard-firstsetup-head">
22 + <h3><?php echo JText::translate('VBO_SAMPLEDATA_INSTALL'); ?></h3>
23 + <h4><?php echo JText::translate('VBO_SAMPLEDATA_INTRO_DESCR'); ?></h4>
24 + <h4><?php echo JText::translate('VBO_SAMPLEDATA_INTRO_SUBDESCR'); ?></h4>
25 + </div>
26 + <div class="vbo-dashboard-firstsetup-body">
27 + <div class="vbo-dashboard-firstsetup-task">
28 + <div class="vbo-dashboard-firstsetup-task-wrap">
29 + <div class="vbo-dashboard-firstsetup-task-details">
30 + <select id="vik-sample-data-list">
31 + <option value="">- <?php echo JText::translate('VBODASHINSTSAMPLEDBTN'); ?></option>
32 + </select>
33 + </div>
34 + <div class="vbo-dashboard-firstsetup-task-action">
35 + <button type="button" class="btn vbo-sampledata-btn" id="vik-sample-data-install" disabled><?php echo JText::translate('VBO_SAMPLEDATA_INSTALL'); ?></button>
36 + </div>
37 + </div>
38 + </div>
39 + </div>
40 +</div>
41 +
42 +<script type="text/javascript">
43 +
44 + jQuery(function() {
45 +
46 + // populate sample data options
47 + jQuery.ajax({
48 + type: "POST",
49 + url: "admin-ajax.php",
50 + data: {
51 + action: "vikbooking",
52 + task: "sampledata.load"
53 + }
54 + }).done(function(res) {
55 + try {
56 + var obj_res = JSON.parse(res);
57 + if (obj_res && obj_res.length) {
58 + for (var i in obj_res) {
59 + if (!obj_res.hasOwnProperty(i)) {
60 + continue;
61 + }
62 + jQuery('#vik-sample-data-list').append('<option value="' + obj_res[i]['id'] + '">' + obj_res[i]['title'] + '</option>');
63 + }
64 + } else {
65 + alert('No Sample Data available for installation.');
66 + console.info('No Sample Data available for installation.', obj_res);
67 + }
68 + } catch(err) {
69 + alert('An error occurred loading the Sample Data available.');
70 + console.error('Sample Data: could not parse JSON response', err, res);
71 + }
72 + }).fail(function(err) {
73 + alert('An error occurred. Please reload the page.');
74 + console.error(err);
75 + });
76 + //
77 +
78 + jQuery('#vik-sample-data-list').on('change', function() {
79 + jQuery('#vik-sample-data-install').prop('disabled', (!jQuery(this).val().length));
80 + });
81 +
82 + jQuery('#vik-sample-data-install').click(function() {
83 + if (jQuery(this).prop('disabled') === true) {
84 + return false;
85 + }
86 +
87 + // start installation
88 + jQuery(this).prop('disabled', true).prepend('<?php VikBookingIcons::e('refresh', 'fa-spin'); ?> ');
89 +
90 + jQuery.ajax({
91 + type: "POST",
92 + url: "admin-ajax.php",
93 + data: {
94 + action: "vikbooking",
95 + task: "sampledata.install",
96 + sample_data_id: jQuery('#vik-sample-data-list').val()
97 + }
98 + }).done(function(res) {
99 + try {
100 + var obj_res = JSON.parse(res);
101 + if (!obj_res || !obj_res.status) {
102 + console.error(res);
103 + if (obj_res && obj_res.error) {
104 + alert(obj_res.error);
105 + } else {
106 + alert('Could not install sample data. Please check your console for the full error description.');
107 + }
108 + }
109 + } catch(err) {
110 + console.error('Unable to install Sample Data.', err, res);
111 + alert('Unable to install Sample Data.');
112 + }
113 +
114 + // always redirect to the dashboard page
115 + document.location.href = 'admin.php?page=vikbooking';
116 + }).fail(function(err) {
117 + console.error(err);
118 + alert('An error occurred installing the sample data. Please try again.');
119 + document.location.href = 'admin.php?page=vikbooking&view=sampledata';
120 + });
121 + });
122 +
123 + });
124 +
125 +</script>