default.php
5 days ago
default_details.php
5 days ago
default_details_calendar.php
5 days ago
default_details_calendar_modal.php
5 days ago
default_details_contact.php
5 days ago
default_details_employee.php
5 days ago
default_details_notifications.php
5 days ago
default_details_visibility.php
5 days ago
default_fields.php
5 days ago
default_workdays.php
5 days ago
default_workdays_import.php
5 days ago
default_workdays_import_sample.php
5 days ago
default_workdays_import_upload.php
5 days ago
default_workdays_modal.php
5 days ago
index.html
5 days ago
default_workdays_import_sample.php
104 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 | // load list of supported types |
| 15 | VAPLoader::import('libraries.worktime.import.manager'); |
| 16 | $types = VAPWorktimeImportManager::getSupportedTypes(); |
| 17 | |
| 18 | $vik = VAPApplication::getInstance(); |
| 19 | |
| 20 | if (!$types) |
| 21 | { |
| 22 | // no supported types... |
| 23 | echo $vik->alert(JText::translate('JGLOBAL_NO_MATCHING_RESULTS')); |
| 24 | return; |
| 25 | } |
| 26 | |
| 27 | $lookup = array_map(function($t) |
| 28 | { |
| 29 | return $t->getSample(); |
| 30 | }, $types); |
| 31 | |
| 32 | ?> |
| 33 | |
| 34 | <div class="vap-worktime-import-wrapper"> |
| 35 | |
| 36 | <div class="import-types"> |
| 37 | <div class="btn-group"> |
| 38 | <?php |
| 39 | foreach ($types as $k => $t) |
| 40 | { |
| 41 | ?> |
| 42 | <button type="button" class="btn" data-type="<?php echo $this->escape($k); ?>"> |
| 43 | <?php echo strtoupper($k); ?> |
| 44 | </button> |
| 45 | <?php |
| 46 | } |
| 47 | ?> |
| 48 | </div> |
| 49 | </div> |
| 50 | |
| 51 | <div class="import-editor" id="wd-import-editor" style="display: none;"> |
| 52 | <?php echo $vik->getCodeMirror('worktime_editor_sample', ''); ?> |
| 53 | </div> |
| 54 | |
| 55 | <?php echo $vik->alert(JText::translate('VAP_WORKTIME_IMPORT_SAMPLE_TIP'), 'info', $dismiss = false, ['id' => 'wd-import-tip']); ?> |
| 56 | |
| 57 | </div> |
| 58 | |
| 59 | <script> |
| 60 | |
| 61 | (function($) { |
| 62 | 'use strict'; |
| 63 | |
| 64 | // create lookup |
| 65 | const typesLookup = <?php echo json_encode($lookup); ?>; |
| 66 | |
| 67 | $(function() { |
| 68 | $('.vap-worktime-import-wrapper .import-types button[data-type]').on('click', function() { |
| 69 | let type = $(this).data('type'); |
| 70 | |
| 71 | if (!typesLookup.hasOwnProperty(type)) { |
| 72 | return false; |
| 73 | } |
| 74 | |
| 75 | $('#wd-import-tip').hide(); |
| 76 | $('#wd-import-editor').show(); |
| 77 | |
| 78 | $(this).siblings().removeClass('active'); |
| 79 | $(this).addClass('active'); |
| 80 | |
| 81 | let editor = Joomla.editors.instances.worktime_editor_sample; |
| 82 | |
| 83 | // update value |
| 84 | editor.setValue(typesLookup[type]); |
| 85 | |
| 86 | // check if we have code mirror |
| 87 | if (editor.element && editor.element.codemirror) { |
| 88 | editor = editor.element.codemirror; |
| 89 | } |
| 90 | |
| 91 | if (editor.setOption) { |
| 92 | // update language mode |
| 93 | editor.setOption('mode', type === 'json' ? 'javascript' : type); |
| 94 | } |
| 95 | |
| 96 | if (editor.refresh) { |
| 97 | editor.refresh(); |
| 98 | } |
| 99 | }); |
| 100 | }); |
| 101 | })(jQuery); |
| 102 | |
| 103 | </script> |
| 104 |