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.php
323 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 | JHtml::fetch('bootstrap.tooltip', '.hasTooltip'); |
| 15 | JHtml::fetch('vaphtml.assets.select2'); |
| 16 | JHtml::fetch('vaphtml.assets.toast', 'bottom-right'); |
| 17 | |
| 18 | $params = $this->params; |
| 19 | |
| 20 | $vik = VAPApplication::getInstance(); |
| 21 | |
| 22 | /** |
| 23 | * Prepares CodeMirror editor scripts for being used |
| 24 | * via Javascript/AJAX. |
| 25 | * |
| 26 | * @wponly |
| 27 | */ |
| 28 | $vik->prepareEditor('codemirror'); |
| 29 | |
| 30 | /** |
| 31 | * Trigger event to display custom HTML. |
| 32 | * In case it is needed to include any additional fields, |
| 33 | * it is possible to create a plugin and attach it to an event |
| 34 | * called "onDisplayViewConfig". The event method receives the |
| 35 | * view instance as argument. |
| 36 | * |
| 37 | * @since 1.6.6 |
| 38 | */ |
| 39 | $forms = $this->onDisplayView(); |
| 40 | |
| 41 | /** |
| 42 | * Recover selected tab from the browser cookie. |
| 43 | * |
| 44 | * @since 1.7 |
| 45 | */ |
| 46 | $this->selectedTab = JFactory::getApplication()->input->cookie->get('vikappointments_config_tab', 1, 'uint'); |
| 47 | |
| 48 | $tabs = $custTabs = array(); |
| 49 | |
| 50 | // build default tabs: global, e-mail, currency, shop, listings |
| 51 | $tabs[] = JText::translate('VAPCONFIGTABNAME1'); |
| 52 | $tabs[] = JText::translate('VAPCONFIGGLOBTITLE5'); |
| 53 | $tabs[] = JText::translate('VAPCONFIGGLOBTITLE6'); |
| 54 | $tabs[] = JText::translate('VAPCONFIGGLOBTITLE8'); |
| 55 | $tabs[] = JText::translate('VAPCONFIGGLOBTITLE15'); |
| 56 | |
| 57 | /** |
| 58 | * Iterate all form items to be displayed as custom tabs within the nav bar. |
| 59 | * |
| 60 | * @since 1.6.6 |
| 61 | */ |
| 62 | foreach ($forms as $tabName => $tabForms) |
| 63 | { |
| 64 | // include tab |
| 65 | $custTabs[] = JText::translate($tabName); |
| 66 | } |
| 67 | |
| 68 | // make sure the selected tab is still available |
| 69 | if ($this->selectedTab > count($tabs) + count($custTabs)) |
| 70 | { |
| 71 | // reset to first tab |
| 72 | $this->selectedTab = 1; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Render modal before the configuration because the |
| 77 | * media manager might be used by fields located in |
| 78 | * different sections. |
| 79 | * |
| 80 | * @since 1.7 |
| 81 | */ |
| 82 | echo JHtml::fetch('vaphtml.mediamanager.modal'); |
| 83 | ?> |
| 84 | |
| 85 | <div class="configuration-panel"> |
| 86 | |
| 87 | <div id="configuration-navbar"> |
| 88 | <ul> |
| 89 | <?php |
| 90 | foreach (array_merge($tabs, $custTabs) as $i => $tab) |
| 91 | { |
| 92 | $key = $i + 1; |
| 93 | ?> |
| 94 | <li id="vaptabli<?php echo $key; ?>" class="vaptabli<?php echo ($this->selectedTab == $key ? ' vapconfigtabactive' : ''); ?>" data-id="<?php echo $key; ?>"> |
| 95 | <a href="javascript: void(0);"><?php echo $tab; ?></a> |
| 96 | </li> |
| 97 | <?php |
| 98 | } |
| 99 | ?> |
| 100 | </ul> |
| 101 | </div> |
| 102 | |
| 103 | <?php |
| 104 | // print config search bar |
| 105 | // VAPLoader::import('libraries.widget.layout'); |
| 106 | // echo UIWidgetLayout::getInstance('searchbar')->display(); |
| 107 | ?> |
| 108 | |
| 109 | <div id="configuration-body"> |
| 110 | |
| 111 | <form name="adminForm" id="adminForm" action="index.php" method="post" enctype="multipart/form-data"> |
| 112 | |
| 113 | <?php |
| 114 | // display default tab panes |
| 115 | echo $this->loadTemplate('global'); |
| 116 | echo $this->loadTemplate('email'); |
| 117 | echo $this->loadTemplate('currency'); |
| 118 | echo $this->loadTemplate('shop'); |
| 119 | echo $this->loadTemplate('listings'); |
| 120 | |
| 121 | $i = 0; |
| 122 | |
| 123 | /** |
| 124 | * Iterate all form items to be displayed as new panels of custom tabs. |
| 125 | * |
| 126 | * @since 1.6.6 |
| 127 | */ |
| 128 | foreach ($forms as $formName => $formHtml) |
| 129 | { |
| 130 | // sanitize form name |
| 131 | $key = count($tabs) + (++$i); |
| 132 | |
| 133 | ?> |
| 134 | <div id="vaptabview<?php echo $key; ?>" class="vaptabview" style="<?php echo ($this->selectedTab != $key ? 'display: none;' : ''); ?>"> |
| 135 | <?php echo $formHtml; ?> |
| 136 | </div> |
| 137 | <?php |
| 138 | } |
| 139 | ?> |
| 140 | |
| 141 | <?php echo JHtml::fetch('form.token'); ?> |
| 142 | |
| 143 | <input type="hidden" name="option" value="com_vikappointments" /> |
| 144 | <input type="hidden" name="task" value=""/> |
| 145 | </form> |
| 146 | |
| 147 | </div> |
| 148 | |
| 149 | </div> |
| 150 | |
| 151 | <!-- Define role to detect the supported hook --> |
| 152 | <!-- {"rule":"customizer","event":"onDisplayViewConfig","type":"tab"} --> |
| 153 | |
| 154 | <?php |
| 155 | // email template modal |
| 156 | echo JHtml::fetch( |
| 157 | 'bootstrap.renderModal', |
| 158 | 'jmodal-managetmpl', |
| 159 | array( |
| 160 | 'title' => JText::translate('VAPJMODALEMAILTMPL'), |
| 161 | 'closeButton' => true, |
| 162 | 'keyboard' => false, |
| 163 | 'bodyHeight' => 80, |
| 164 | 'url' => '', |
| 165 | 'footer' => '<button type="button" class="btn" data-role="file.savecopy">' . JText::translate('VAPSAVEASCOPY') . '</button>' |
| 166 | . '<button type="button" class="btn btn-success" data-role="file.save">' . JText::translate('JAPPLY') . '</button>', |
| 167 | ) |
| 168 | ); |
| 169 | ?> |
| 170 | |
| 171 | <!-- SCRIPT --> |
| 172 | |
| 173 | <?php |
| 174 | echo JLayoutHelper::render('configuration.script', array()); |
| 175 | ?> |
| 176 | |
| 177 | <script> |
| 178 | |
| 179 | var SELECTED_MAIL_TMPL_FIELD = null; |
| 180 | |
| 181 | jQuery(function($) { |
| 182 | $('select.short').select2({ |
| 183 | minimumResultsForSearch: -1, |
| 184 | allowClear: false, |
| 185 | width: 100, |
| 186 | }); |
| 187 | |
| 188 | $('select.small-medium').select2({ |
| 189 | minimumResultsForSearch: -1, |
| 190 | allowClear: false, |
| 191 | width: 150, |
| 192 | }); |
| 193 | |
| 194 | $('select.medium').select2({ |
| 195 | minimumResultsForSearch: -1, |
| 196 | allowClear: false, |
| 197 | width: 200, |
| 198 | }); |
| 199 | |
| 200 | $('select.medium-large').select2({ |
| 201 | minimumResultsForSearch: -1, |
| 202 | allowClear: false, |
| 203 | width: 250, |
| 204 | }); |
| 205 | |
| 206 | $('select.large').select2({ |
| 207 | minimumResultsForSearch: -1, |
| 208 | allowClear: false, |
| 209 | width: 300, |
| 210 | }); |
| 211 | |
| 212 | $('button[data-role="file.save"]').on('click', () => { |
| 213 | // trigger click of save button contained in managefile view |
| 214 | window.modalFileSaveButton.click(); |
| 215 | }); |
| 216 | |
| 217 | $('button[data-role="file.savecopy"]').on('click', () => { |
| 218 | // trigger click of savecopy button contained in managefile view |
| 219 | window.modalFileSaveCopyButton.click(); |
| 220 | }); |
| 221 | |
| 222 | $('#jmodal-managetmpl').on('hidden', () => { |
| 223 | // check if the file was saved |
| 224 | if (window.modalSavedFile) { |
| 225 | let selector = $('select[name="mailtmpl"],select[name="adminmailtmpl"],select[name="empmailtmpl"],select[name="cancmailtmpl"],select[name="waitlistmailtmpl"],select[name="packmailtmpl"]'); |
| 226 | |
| 227 | // insert file in all template dropdowns |
| 228 | if (addTemplateFileIntoSelect(window.modalSavedFile, selector)) { |
| 229 | // auto-select new option for the related select |
| 230 | $(SELECTED_MAIL_TMPL_FIELD).select2('val', window.modalSavedFile.name); |
| 231 | } |
| 232 | } |
| 233 | }); |
| 234 | |
| 235 | const addTemplateFileIntoSelect = (file, selector) => { |
| 236 | if (selector.find('option[value="' + file.name + '"]').length) { |
| 237 | // file already in list |
| 238 | return false; |
| 239 | } |
| 240 | |
| 241 | // prettify name |
| 242 | let name = file.name.replace(/\.php$/, ''); |
| 243 | name = name.replace(/[_-]+/g, ' '); |
| 244 | name = name.split(' ').map((s) => { |
| 245 | return s.charAt(0).toUpperCase() + s.slice(1); |
| 246 | }).join(' '); |
| 247 | |
| 248 | // insert new option within the select |
| 249 | $(selector).each(function() { |
| 250 | $(this).append('<option value="' + file.name + '" data-path="' + file.path + '">' + name + '</option>'); |
| 251 | }); |
| 252 | |
| 253 | return true; |
| 254 | } |
| 255 | }); |
| 256 | |
| 257 | // lock/unlock an input starting from the specified link |
| 258 | |
| 259 | function lockUnlockInput(link) { |
| 260 | var input = jQuery(link).prev(); |
| 261 | |
| 262 | if (input.prop('readonly')) { |
| 263 | input.prop('readonly', false); |
| 264 | |
| 265 | jQuery(link).find('i').removeClass('fa-lock'); |
| 266 | jQuery(link).find('i').addClass('fa-unlock-alt'); |
| 267 | } else { |
| 268 | input.prop('readonly', true); |
| 269 | |
| 270 | jQuery(link).find('i').removeClass('fa-unlock-alt'); |
| 271 | jQuery(link).find('i').addClass('fa-lock'); |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | // MAIL TEMPLATE |
| 276 | |
| 277 | function vapOpenMailTemplateModal(id) { |
| 278 | // register related dropdown |
| 279 | SELECTED_MAIL_TMPL_FIELD = jQuery('select[name="' + id + '"]'); |
| 280 | |
| 281 | // get file name |
| 282 | var file = SELECTED_MAIL_TMPL_FIELD.val(); |
| 283 | // build path of selected file |
| 284 | var path = '<?php echo addslashes(VAPHELPERS . DIRECTORY_SEPARATOR . 'mail_tmpls' . DIRECTORY_SEPARATOR); ?>' + file; |
| 285 | |
| 286 | // create management URL |
| 287 | let url = 'index.php?option=com_vikappointments&tmpl=component&task=file.edit&cid[]=' + btoa(path); |
| 288 | |
| 289 | vapOpenJModal('managetmpl', url, true); |
| 290 | } |
| 291 | |
| 292 | // MAIL PREVIEW |
| 293 | |
| 294 | /** |
| 295 | * Opens a new browser page to display a preview of the selected mail template. |
| 296 | * |
| 297 | * @param string id The unique ID of the e-mail template (select name). |
| 298 | * @param string alias The template alias (e.g. customer). |
| 299 | * |
| 300 | * @since 1.7 |
| 301 | */ |
| 302 | function goToMailPreview(id, alias) { |
| 303 | // define base URL |
| 304 | var url = '<?php echo $vik->addUrlCsrf('index.php?option=com_vikappointments&task=configuration.mailpreview&tmpl=component'); ?>'; |
| 305 | // append template alias |
| 306 | url += '&alias=' + alias; |
| 307 | // extract mail template from select |
| 308 | url += '&file=' + jQuery('select[name="' + id + '"]').val(); |
| 309 | // always use current language |
| 310 | url += '&langtag=<?php echo JFactory::getLanguage()->getTag(); ?>'; |
| 311 | |
| 312 | // open URL in a blank tab of the browser |
| 313 | window.open(url, '_blank'); |
| 314 | } |
| 315 | |
| 316 | // MODAL BOXES |
| 317 | |
| 318 | function vapOpenJModal(id, url, jqmodal) { |
| 319 | <?php echo $vik->bootOpenModalJS(); ?> |
| 320 | } |
| 321 | |
| 322 | </script> |
| 323 |