default.php
3 days ago
default_currency.php
3 days ago
default_currency_details.php
3 days ago
default_currency_providers.php
3 days ago
default_email.php
3 days ago
default_email_attachments.php
3 days ago
default_email_mail.php
3 days ago
default_email_notifications.php
3 days ago
default_email_template.php
3 days ago
default_global.php
3 days ago
default_global_calendars.php
3 days ago
default_global_columns.php
3 days ago
default_global_gdpr.php
3 days ago
default_global_sync.php
3 days ago
default_global_system.php
3 days ago
default_global_timezone.php
3 days ago
default_global_zip.php
3 days ago
default_listings.php
3 days ago
default_listings_employees.php
3 days ago
default_listings_services.php
3 days ago
default_shop.php
3 days ago
default_shop_details.php
3 days ago
default_shop_invoice.php
3 days ago
default_shop_packages.php
3 days ago
default_shop_recurrence.php
3 days ago
default_shop_reviews.php
3 days ago
default_shop_subscriptions.php
3 days ago
default_shop_waitlist.php
3 days ago
index.html
3 days ago
default_global_sync.php
228 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments |
| 4 | * @subpackage core |
| 5 | * @author E4J s.r.l. |
| 6 | * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved. |
| 7 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 | * @link https://vikwp.com |
| 9 | */ |
| 10 | |
| 11 | // No direct access |
| 12 | defined('ABSPATH') or die('No script kiddies please!'); |
| 13 | |
| 14 | $params = $this->params; |
| 15 | |
| 16 | $vik = VAPApplication::getInstance(); |
| 17 | |
| 18 | /** |
| 19 | * Trigger event to display custom HTML. |
| 20 | * In case it is needed to include any additional fields, |
| 21 | * it is possible to create a plugin and attach it to an event |
| 22 | * called "onDisplayViewConfigGlobalSync". The event method |
| 23 | * receives the view instance as argument. |
| 24 | * |
| 25 | * @since 1.7 |
| 26 | */ |
| 27 | $forms = $this->onDisplayView('GlobalSync'); |
| 28 | |
| 29 | ?> |
| 30 | |
| 31 | <div class="config-fieldset"> |
| 32 | |
| 33 | <div class="config-fieldset-body"> |
| 34 | |
| 35 | <!-- ADMIN SYNC URL - Response --> |
| 36 | <?php |
| 37 | $sync_url = 'index.php?option=com_vikappointments&task=appsync&key=' . $params['synckey']; |
| 38 | |
| 39 | /** |
| 40 | * Route Sync URL for external usage. |
| 41 | * |
| 42 | * @since 1.7 |
| 43 | */ |
| 44 | $sync_url = $vik->routeForExternalUse($sync_url); |
| 45 | |
| 46 | $help = $vik->createPopover(array( |
| 47 | 'title' => JText::translate('VAPMANAGECONFIG63'), |
| 48 | 'content' => JText::translate('VAPICSURL'), |
| 49 | )); |
| 50 | |
| 51 | echo $vik->openControl(JText::translate('VAPMANAGECONFIG63') . $help); ?> |
| 52 | <div> |
| 53 | <input type="text" value="<?php echo $sync_url; ?>" size="64" id="syncurl" readonly /> |
| 54 | </div> |
| 55 | |
| 56 | <div style="margin-top: 5px;"> |
| 57 | <button type="button" class="btn" id="syncurlsubscr"> |
| 58 | <i class="fas fa-calendar-plus"></i> |
| 59 | <?php echo JText::translate('VAPSUBSCRIBE'); ?> |
| 60 | </button> |
| 61 | |
| 62 | <button type="button" class="btn" id="syncurlcopy"> |
| 63 | <i class="fas fa-copy"></i> |
| 64 | <?php echo JText::translate('VAPCOPY'); ?> |
| 65 | </button> |
| 66 | </div> |
| 67 | <?php echo $vik->closeControl(); ?> |
| 68 | |
| 69 | <!-- SYNC PASSWORD - Text --> |
| 70 | <?php echo $vik->openControl(JText::translate('VAPMANAGECONFIG64')); ?> |
| 71 | <input type="text" name="synckey" id="synckey" value="<?php echo $this->escape($params['synckey']); ?>" size="40" maxlength="32" /> |
| 72 | <?php echo $vik->closeControl(); ?> |
| 73 | |
| 74 | <!-- Define role to detect the supported hook --> |
| 75 | <!-- {"rule":"customizer","event":"onDisplayViewConfigGlobalSync","key":"basic","type":"field"} --> |
| 76 | |
| 77 | <?php |
| 78 | /** |
| 79 | * Look for any additional fields to be pushed within |
| 80 | * the Global > Appointments Sync > Sync fieldset. |
| 81 | * |
| 82 | * @since 1.7 |
| 83 | */ |
| 84 | if (isset($forms['basic'])) |
| 85 | { |
| 86 | echo $forms['basic']; |
| 87 | |
| 88 | // unset details form to avoid displaying it twice |
| 89 | unset($forms['basic']); |
| 90 | } |
| 91 | ?> |
| 92 | |
| 93 | </div> |
| 94 | |
| 95 | </div> |
| 96 | |
| 97 | <!-- Define role to detect the supported hook --> |
| 98 | <!-- {"rule":"customizer","event":"onDisplayViewConfigGlobalSync","type":"fieldset"} --> |
| 99 | |
| 100 | <?php |
| 101 | /** |
| 102 | * Iterate remaining forms to be displayed as new fieldsets |
| 103 | * within the Global > Sync tab. |
| 104 | * |
| 105 | * @since 1.7 |
| 106 | */ |
| 107 | foreach ($forms as $formTitle => $formHtml) |
| 108 | { |
| 109 | ?> |
| 110 | <div class="config-fieldset"> |
| 111 | |
| 112 | <div class="config-fieldset-head"> |
| 113 | <h3><?php echo JText::translate($formTitle); ?></h3> |
| 114 | </div> |
| 115 | |
| 116 | <div class="config-fieldset-body"> |
| 117 | <?php echo $formHtml; ?> |
| 118 | </div> |
| 119 | |
| 120 | </div> |
| 121 | <?php |
| 122 | } |
| 123 | ?> |
| 124 | |
| 125 | <div id="sync-dialog-confirm" style="display: none;"> |
| 126 | |
| 127 | <p><?php echo JText::translate('VAPSYNCUBSCRICS'); ?></p> |
| 128 | |
| 129 | <div> |
| 130 | <select id="syncurl-subscr-driver"> |
| 131 | <option></option> |
| 132 | <option value="apple">Apple iCal</option> |
| 133 | <option value="google">Google Calendar</option> |
| 134 | </select> |
| 135 | </div> |
| 136 | |
| 137 | </div> |
| 138 | |
| 139 | <?php |
| 140 | JText::script('VAPCOPIED'); |
| 141 | JText::script('VAPSUBSCRIBE'); |
| 142 | JText::script('JCANCEL'); |
| 143 | JText::script('VAP_SELECT_USE_DEFAULT_X'); |
| 144 | ?> |
| 145 | |
| 146 | <script> |
| 147 | |
| 148 | jQuery(function($) { |
| 149 | |
| 150 | $('#syncurlsubscr').click(() => { |
| 151 | dialog.show(); |
| 152 | }); |
| 153 | |
| 154 | $('#syncurlcopy').click(() => { |
| 155 | copyToClipboard($('#syncurl')[0]).then(() => { |
| 156 | ToastMessage.enqueue(Joomla.JText._('VAPCOPIED')); |
| 157 | }); |
| 158 | }); |
| 159 | |
| 160 | $('#synckey').on('change', function() { |
| 161 | var input = $('#syncurl'); |
| 162 | |
| 163 | if (input.length == 0) { |
| 164 | return; |
| 165 | } |
| 166 | |
| 167 | var url = input.val(); |
| 168 | url = url.substr(0, url.lastIndexOf('=') + 1) + $(this).val(); |
| 169 | input.val(url); |
| 170 | }); |
| 171 | |
| 172 | var dialog = new VikConfirmDialog('#sync-dialog-confirm'); |
| 173 | |
| 174 | // add confirm button |
| 175 | dialog.addButton(Joomla.JText._('VAPSUBSCRIBE'), function(args, event) { |
| 176 | // get selected driver |
| 177 | var driver = $('#syncurl-subscr-driver').val(); |
| 178 | |
| 179 | // get sync URL |
| 180 | var url = $('#syncurl').val().trim(); |
| 181 | |
| 182 | switch (driver) { |
| 183 | // Apple iCal |
| 184 | case 'apple': |
| 185 | // replace HTTP(s) with WEBCAL |
| 186 | url = url.replace(/^https?:\/\//, 'webcal://'); |
| 187 | break; |
| 188 | |
| 189 | // Google Calendar |
| 190 | case 'google': |
| 191 | // replace HTTP(s) with WEBCAL |
| 192 | url = url.replace(/^https?:\/\//, 'webcal://'); |
| 193 | // encode URL and prepend Google Calendar renderer |
| 194 | url = 'https://www.google.com/calendar/render?cid=' + encodeURIComponent(url); |
| 195 | break; |
| 196 | |
| 197 | // driver not selected/supported |
| 198 | default: |
| 199 | // prevent closure |
| 200 | return false; |
| 201 | } |
| 202 | |
| 203 | dialog.dispose(); |
| 204 | |
| 205 | setTimeout(function() { |
| 206 | // open subscription URL in a new browser page |
| 207 | window.open(url, '_blank'); |
| 208 | }, 256); |
| 209 | }, false); |
| 210 | |
| 211 | // add cancel button |
| 212 | dialog.addButton(Joomla.JText._('JCANCEL')); |
| 213 | |
| 214 | // pre-build dialog |
| 215 | dialog.build(); |
| 216 | |
| 217 | $('#syncurl-subscr-driver').select2({ |
| 218 | minimumResultsForSearch: -1, |
| 219 | placeholder: '--', |
| 220 | allowClear: true, |
| 221 | width: '100%', |
| 222 | }); |
| 223 | |
| 224 | $('.select2-drop').css('z-index', '99999'); |
| 225 | }); |
| 226 | |
| 227 | </script> |
| 228 |