| 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 "rooms locked". |
| 15 |
* |
| 16 |
* @since 1.4.0 |
| 17 |
*/ |
| 18 |
class VikBookingAdminWidgetRoomsLocked 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_ROOMSLOCK_TITLE'); |
| 29 |
$this->widgetDescr = JText::translate('VBO_W_ROOMSLOCK_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('lock') . '"></i>'; |
| 38 |
$this->widgetStyleName = 'orange'; |
| 39 |
} |
| 40 |
|
| 41 |
public function render(?VBOMultitaskData $data = null) |
| 42 |
{ |
| 43 |
$dbo = JFactory::getDbo(); |
| 44 |
|
| 45 |
$rooms_locked = array(); |
| 46 |
|
| 47 |
// clean up the expired pending records |
| 48 |
$q = "DELETE FROM `#__vikbooking_tmplock` WHERE `until`<" . time() . ";"; |
| 49 |
$dbo->setQuery($q); |
| 50 |
$dbo->execute(); |
| 51 |
|
| 52 |
// get all future rooms locked |
| 53 |
$q = "SELECT `lock`.*,`r`.`name`,(SELECT CONCAT_WS(' ',`or`.`t_first_name`,`or`.`t_last_name`) FROM `#__vikbooking_ordersrooms` AS `or` WHERE `lock`.`idorder`=`or`.`idorder` LIMIT 1) AS `nominative` FROM `#__vikbooking_tmplock` AS `lock` LEFT JOIN `#__vikbooking_rooms` `r` ON `lock`.`idroom`=`r`.`id` WHERE `lock`.`until`>".time()." ORDER BY `lock`.`id` DESC;"; |
| 54 |
$dbo->setQuery($q); |
| 55 |
$dbo->execute(); |
| 56 |
if ($dbo->getNumRows() > 0) { |
| 57 |
$rooms_locked = $dbo->loadAssocList(); |
| 58 |
} |
| 59 |
|
| 60 |
if (!count($rooms_locked) && is_null($data)) { |
| 61 |
// do not display any contents in the dashboard, but do it in the multitask panel |
| 62 |
return; |
| 63 |
} |
| 64 |
?> |
| 65 |
<div class="vbo-admin-widget-wrapper"> |
| 66 |
<div class="vbo-admin-widget-head"> |
| 67 |
<h4><?php echo $this->widgetIcon; ?> <span><?php echo JText::translate('VBDASHROOMSLOCKED'); ?> (<?php echo count($rooms_locked); ?>)</span></h4> |
| 68 |
</div> |
| 69 |
<?php |
| 70 |
if (count($rooms_locked)) { |
| 71 |
?> |
| 72 |
<div class="vbo-dashboard-rooms-locked table-responsive"> |
| 73 |
<table class="table"> |
| 74 |
<tr class="vbo-dashboard-rooms-locked-firstrow"> |
| 75 |
<td class="center"><?php echo JText::translate('VBDASHBOOKINGID'); ?></td> |
| 76 |
<td class="center"><?php echo JText::translate('VBDASHROOMNAME'); ?></td> |
| 77 |
<td class="center"><?php echo JText::translate('VBCUSTOMERNOMINATIVE'); ?></td> |
| 78 |
<td class="center"><?php echo JText::translate('VBDASHLOCKUNTIL'); ?></td> |
| 79 |
<td class="center"> </td> |
| 80 |
</tr> |
| 81 |
<?php |
| 82 |
foreach ($rooms_locked as $lock) { |
| 83 |
?> |
| 84 |
<tr class="vbo-dashboard-rooms-locked-rows"> |
| 85 |
<td class="center"> |
| 86 |
<a href="index.php?option=com_vikbooking&task=editorder&cid[]=<?php echo $lock['idorder']; ?>" class="vbo-bookingid" target="_blank"><?php echo $lock['idorder']; ?></a> |
| 87 |
</td> |
| 88 |
<td class="center"><?php echo $lock['name']; ?></td> |
| 89 |
<td class="center"><?php echo $lock['nominative']; ?></td> |
| 90 |
<td class="center"><?php echo date(str_replace("/", $this->datesep, $this->df).' H:i', $lock['until']); ?></td> |
| 91 |
<td class="center"> |
| 92 |
<button type="button" class="btn btn-danger" onclick="if (confirm('<?php echo addslashes(JText::translate('VBDELCONFIRM')); ?>')) location.href='index.php?option=com_vikbooking&task=unlockrecords&cid[]=<?php echo $lock['id']; ?>';"><?php echo JText::translate('VBDASHUNLOCK'); ?></button> |
| 93 |
</td> |
| 94 |
</tr> |
| 95 |
<?php |
| 96 |
} |
| 97 |
?> |
| 98 |
</table> |
| 99 |
</div> |
| 100 |
<?php |
| 101 |
} |
| 102 |
?> |
| 103 |
</div> |
| 104 |
<?php |
| 105 |
} |
| 106 |
} |
| 107 |
|