PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.6.4
VikBooking Hotel Booking Engine & PMS v1.6.4
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
vikbooking / admin / helpers / widgets / last_reservations.php

last_reservations.php in VikBooking Hotel Booking Engine & PMS 1.6.4, at admin/helpers/widgets/last_reservations.php

127 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 "last reservations".
15 *
16 * @since 1.4.0
17 */
18 class VikBookingAdminWidgetLastReservations 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_LASTRES_TITLE');
29 $this->widgetDescr = JText::translate('VBO_W_LASTRES_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('concierge-bell') . '"></i>';
38 $this->widgetStyleName = 'pink';
39 }
40
41 public function render(VBOMultitaskData $data = null)
42 {
43 $dbo = JFactory::getDbo();
44
45 $lastreservations = array();
46
47 $q = "SELECT `o`.`id`,`o`.`custdata`,`o`.`status`,`o`.`days`,`o`.`checkin`,`o`.`checkout`,`o`.`roomsnum`,`o`.`country`,(SELECT CONCAT_WS(' ',`or`.`t_first_name`,`or`.`t_last_name`) FROM `#__vikbooking_ordersrooms` AS `or` WHERE `or`.`idorder`=`o`.`id` LIMIT 1) AS `nominative`,(SELECT SUM(`or`.`adults`) FROM `#__vikbooking_ordersrooms` AS `or` WHERE `or`.`idorder`=`o`.`id`) AS `tot_adults`,(SELECT SUM(`or`.`children`) FROM `#__vikbooking_ordersrooms` AS `or` WHERE `or`.`idorder`=`o`.`id`) AS `tot_children` FROM `#__vikbooking_orders` AS `o` WHERE `o`.`closure`=0 ORDER BY `o`.`id` DESC LIMIT 10;";
48 $dbo->setQuery($q);
49 $dbo->execute();
50 if ($dbo->getNumRows() > 0) {
51 $lastreservations = $dbo->loadAssocList();
52 }
53
54 if (!count($lastreservations)) {
55 return;
56 }
57 ?>
58 <div class="vbo-admin-widget-wrapper">
59 <div class="vbo-admin-widget-head">
60 <h4><?php VikBookingIcons::e('far fa-bell'); ?> <span><?php echo JText::translate('VBDASHLASTRES'); ?></span></h4>
61 </div>
62 <div class="vbo-dashboard-next-bookings table-responsive">
63 <table class="table">
64 <thead>
65 <tr class="vbo-dashboard-today-checkout-firstrow">
66 <th class="left"><?php echo JText::translate('VBDASHUPRESONE'); ?></th>
67 <th class="left"><?php echo JText::translate('VBCUSTOMERNOMINATIVE'); ?></th>
68 <th class="left"><?php echo JText::translate('VBDASHUPRESTWO'); ?></th>
69 <th class="left"><?php echo JText::translate('VBDASHUPRESTHREE'); ?></th>
70 <th class="left"><?php echo JText::translate('VBDASHUPRESFIVE'); ?></th>
71 </tr>
72 </thead>
73 <tbody>
74 <?php
75 foreach ($lastreservations as $nbk => $next) {
76 $totpeople_str = $next['tot_adults']." ".($next['tot_adults'] > 1 ? JText::translate('VBMAILADULTS') : JText::translate('VBMAILADULT')).($next['tot_children'] > 0 ? ", ".$next['tot_children']." ".($next['tot_children'] > 1 ? JText::translate('VBMAILCHILDREN') : JText::translate('VBMAILCHILD')) : "");
77 $room_names = array();
78 $rooms = VikBooking::loadOrdersRoomsData($next['id']);
79 foreach ($rooms as $rr) {
80 $room_names[] = $rr['room_name'];
81 }
82 if ($next['roomsnum'] == 1) {
83 $roomstr = '<span class="vbo-smalltext">'.$room_names[0].'</span>';
84 } else {
85 $roomstr = '<span class="hasTooltip vbo-tip-small" title="'.addslashes(implode(', ', $room_names)).'">'.$next['roomsnum'].'</span>';
86 }
87 if ($next['status'] == 'confirmed') {
88 $ord_status = '<span class="label label-success vbo-status-label">'.JText::translate('VBCONFIRMED').'</span>';
89 } elseif ($next['status'] == 'standby') {
90 $ord_status = '<span class="label label-warning vbo-status-label">'.JText::translate('VBSTANDBY').'</span>';
91 } else {
92 $ord_status = '<span class="label label-error vbo-status-label" style="background-color: #d9534f;">'.JText::translate('VBCANCELLED').'</span>';
93 }
94 $nominative = strlen($next['nominative']) > 1 ? $next['nominative'] : VikBooking::getFirstCustDataField($next['custdata']);
95 $country_flag = '';
96 if (file_exists(VBO_ADMIN_PATH.DS.'resources'.DS.'countries'.DS.$next['country'].'.png')) {
97 $country_flag = '<img src="'.VBO_ADMIN_URI.'resources/countries/'.$next['country'].'.png'.'" title="'.$next['country'].'" class="vbo-country-flag vbo-country-flag-left"/>';
98 }
99 ?>
100 <tr class="vbo-dashboard-today-checkout-rows">
101 <td align="left"><a href="index.php?option=com_vikbooking&amp;task=editorder&amp;cid[]=<?php echo $next['id']; ?>"><?php echo $next['id']; ?></a></td>
102 <td align="left"><?php echo $country_flag.$nominative; ?></td>
103 <td align="left"><?php echo $roomstr; ?></td>
104 <td align="left"><?php echo date(str_replace("/", $this->datesep, $this->df), $next['checkin']) . ' - &times;' . $next['days']; ?></td>
105 <td align="left"><?php echo $ord_status; ?></td>
106 </tr>
107 <?php
108 }
109 ?>
110 </tbody>
111 </table>
112 </div>
113 </div>
114
115 <script type="text/javascript">
116 jQuery(document).ready(function() {
117 if (jQuery.isFunction(jQuery.fn.tooltip)) {
118 jQuery(".hasTooltip").tooltip();
119 } else {
120 jQuery.fn.tooltip = function(){};
121 }
122 });
123 </script>
124 <?php
125 }
126 }
127