| @@ -1,0 +1,120 @@ | ||
| 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 | + * Class handler for admin widget "orphan dates". | |
| 15 | + * | |
| 16 | + * @since 1.4.0 | |
| 17 | + */ | |
| 18 | +class VikBookingAdminWidgetOrphanDates extends VikBookingAdminWidget | |
| 19 | +{ | |
| 20 | + /** | |
| 21 | + * Class constructor will define the widget name and identifier. | |
| 22 | + */ | |
| 23 | + public function __construct() | |
| 24 | + { | |
| 25 | + // call parent constructor | |
| 26 | + parent::__construct(); | |
| 27 | + | |
| 28 | + $this->widgetName = JText::translate('VBO_W_ORPHDATES_TITLE'); | |
| 29 | + $this->widgetDescr = JText::translate('VBO_W_ORPHDATES_DESCR'); | |
| 30 | + $this->widgetId = basename(__FILE__, '.php'); | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * Define widget and icon and style name. | |
| 34 | + * | |
| 35 | + * @since 1.15.0 (J) - 1.5.0 (WP) | |
| 36 | + */ | |
| 37 | + $this->widgetIcon = '<i class="' . VikBookingIcons::i('exclamation-triangle') . '"></i>'; | |
| 38 | + $this->widgetStyleName = 'red'; | |
| 39 | + } | |
| 40 | + | |
| 41 | + public function render(?VBOMultitaskData $data = null) | |
| 42 | + { | |
| 43 | + $vbo_auth_pricing = JFactory::getUser()->authorise('core.vbo.pricing', 'com_vikbooking'); | |
| 44 | + if (!$vbo_auth_pricing) { | |
| 45 | + return; | |
| 46 | + } | |
| 47 | + | |
| 48 | + // check whether we are in the multitask panel | |
| 49 | + $is_multitask = $this->isMultitaskRendering(); | |
| 50 | + | |
| 51 | + ?> | |
| 52 | + <div class="vbo-admin-widget-wrapper vbo-admin-widget-wrapper-orphandates" style="<?php echo !$is_multitask ? 'display: none;' : ''; ?>"> | |
| 53 | + <div class="vbo-admin-widget-head"> | |
| 54 | + <h4><?php echo $this->vbo_app->createPopover(array('title' => JText::translate('VBORPHANSFOUND'), 'content' => JText::translate('VBORPHANSFOUNDSHELP'), 'icon_class' => VikBookingIcons::i('exclamation-triangle'))); ?> <span><?php echo JText::translate('VBORPHANSFOUND'); ?></span></h4> | |
| 55 | + </div> | |
| 56 | + <div class="vbo-orphans-info-list"> | |
| 57 | + <div style="min-height: 152px;"> | |
| 58 | + <div class="vbo-orphans-info-room"> | |
| 59 | + <h4> ----- </h4> | |
| 60 | + </div> | |
| 61 | + </div> | |
| 62 | + </div> | |
| 63 | + </div> | |
| 64 | + | |
| 65 | + <script type="text/JavaScript"> | |
| 66 | + jQuery(function() { | |
| 67 | + // check orphans (only if not disabled through the original cookie of the previous versions of Vik Booking) | |
| 68 | + var hideorphans = false; | |
| 69 | + var buiscuits = document.cookie; | |
| 70 | + if (buiscuits.length) { | |
| 71 | + var hideorphansck = "vboHideOrphans=1"; | |
| 72 | + if (buiscuits.indexOf(hideorphansck) >= 0) { | |
| 73 | + hideorphans = true; | |
| 74 | + } | |
| 75 | + } | |
| 76 | + if (!hideorphans) { | |
| 77 | + // make the request | |
| 78 | + var jqxhr = jQuery.ajax({ | |
| 79 | + type: "POST", | |
| 80 | + url: "<?php echo $this->getExecWidgetAjaxUri('index.php?option=com_vikbooking&task=orphanscount'); ?>", | |
| 81 | + data: { | |
| 82 | + tmpl: "component" | |
| 83 | + } | |
| 84 | + }).done(function(res) { | |
| 85 | + var obj_res = typeof res === 'string' ? JSON.parse(res) : res; | |
| 86 | + var orphans_list = ''; | |
| 87 | + for (var rid in obj_res) { | |
| 88 | + if (!obj_res.hasOwnProperty(rid)) { | |
| 89 | + continue; | |
| 90 | + } | |
| 91 | + orphans_list += '<div class="vbo-orphans-info-room">'; | |
| 92 | + orphans_list += ' <h4 class="vbo-orphans-roomname">'+obj_res[rid]['name']+'</h4>'; | |
| 93 | + orphans_list += ' <div class="vbo-orphans-info-dates">'; | |
| 94 | + for (var dind in obj_res[rid]['rdates']) { | |
| 95 | + if (!obj_res[rid]['rdates'].hasOwnProperty(dind)) { | |
| 96 | + continue; | |
| 97 | + } | |
| 98 | + orphans_list += ' <div class="vbo-orphans-info-date">'+obj_res[rid]['rdates'][dind]+'</div>'; | |
| 99 | + } | |
| 100 | + orphans_list += ' </div>'; | |
| 101 | + orphans_list += ' <div class="vbo-orphans-info-btn">'; | |
| 102 | + orphans_list += ' <a href="index.php?option=com_vikbooking&task=ratesoverv&cid[]='+rid+'&startdate='+obj_res[rid]['linkd']+'" class="btn btn-primary" target="_blank"><?php echo addslashes(JText::translate('VBORPHANSCHECKBTN')); ?></a>'; | |
| 103 | + orphans_list += ' </div>'; | |
| 104 | + orphans_list += '</div>'; | |
| 105 | + } | |
| 106 | + // populate content | |
| 107 | + if (orphans_list.length) { | |
| 108 | + jQuery('.vbo-orphans-info-list').html(orphans_list); | |
| 109 | + } | |
| 110 | + jQuery('.vbo-admin-widget-wrapper-orphandates').show(); | |
| 111 | + }).fail(function() { | |
| 112 | + console.log("orphanscount Request Failed"); | |
| 113 | + }); | |
| 114 | + } | |
| 115 | + // | |
| 116 | + }); | |
| 117 | + </script> | |
| 118 | + <?php | |
| 119 | + } | |
| 120 | +} | |