PluginProbe
VikBooking Hotel Booking Engine & PMS / trunk
VikBooking Hotel Booking Engine & PMS vtrunk
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 1.7.3 All 36 releases
vikbooking / admin / helpers / widgets / next_bookings.php

next_bookings.php in VikBooking Hotel Booking Engine & PMS trunk, at admin/helpers/widgets/next_bookings.php

117 lines 5.5 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 "next bookings".
15 *
16 * @since 1.14 (J) - 1.4.0 (WP)
17 */
18 class VikBookingAdminWidgetNextBookings 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_NEXTRES_TITLE');
29 $this->widgetDescr = JText::translate('VBO_W_NEXTRES_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('stopwatch') . '"></i>';
38 $this->widgetStyleName = 'light-orange';
39 }
40
41 public function render(?VBOMultitaskData $data = null)
42 {
43 $dbo = JFactory::getDbo();
44
45 $today_end_ts = mktime(23, 59, 59, date("n"), date("j"), date("Y"));
46
47 $q = "SELECT `o`.`id`,`o`.`custdata`,`o`.`status`,`o`.`days`,`o`.`checkin`,`o`.`checkout`,`o`.`roomsnum`,`o`.`country`,`o`.`type`,(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`.`status`!='cancelled' AND `o`.`checkin`>".$today_end_ts." AND `o`.`closure`=0 ORDER BY `o`.`checkin` ASC LIMIT 10;";
48
49 $dbo->setQuery($q);
50 $nextreservations = $dbo->loadAssocList();
51
52 if (!$nextreservations) {
53 return;
54 }
55 ?>
56 <div class="vbo-admin-widget-wrapper">
57 <div class="vbo-admin-widget-head">
58 <h4><?php echo $this->widgetIcon; ?> <span><?php echo JText::translate('VBDASHUPCRES'); ?></span></h4>
59 </div>
60 <div class="vbo-dashboard-next-bookings table-responsive">
61 <table class="table">
62 <thead>
63 <tr class="vbo-dashboard-today-checkout-firstrow">
64 <th class="left"><?php echo JText::translate('VBDASHUPRESONE'); ?></th>
65 <th class="left"><?php echo JText::translate('VBCUSTOMERNOMINATIVE'); ?></th>
66 <th class="left"><?php echo JText::translate('VBDASHUPRESTWO'); ?></th>
67 <th class="left"><?php echo JText::translate('VBDASHUPRESTHREE'); ?></th>
68 <th class="center"><?php echo JText::translate('VBDASHUPRESFIVE'); ?></th>
69 </tr>
70 </thead>
71 <tbody>
72 <?php
73 foreach ($nextreservations as $nbk => $next) {
74 $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')) : "");
75 $room_names = array();
76 foreach (VikBooking::loadOrdersRoomsData($next['id']) as $rr) {
77 $room_names[] = $rr['room_name'];
78 }
79 if ($next['roomsnum'] == 1) {
80 $roomstr = '<span class="vbo-smalltext">' . ($room_names ? $room_names[0] : '') . '</span>';
81 } else {
82 $roomstr = '<span class="vbo-tooltip vbo-tooltip-top" data-tooltiptext="' . JHtml::fetch('esc_attr', implode(', ', $room_names)) . '">'.$next['roomsnum'].'</span>';
83 }
84 if ($next['status'] == 'confirmed') {
85 $ord_status = '<span class="label label-success vbo-status-label">'.JText::translate('VBCONFIRMED').'</span>';
86 } elseif ($next['status'] == 'standby') {
87 $ord_status = '<span class="label label-warning vbo-status-label">'.JText::translate('VBSTANDBY').'</span>';
88 } else {
89 $ord_status = '<span class="label label-error vbo-status-label">'.JText::translate('VBCANCELLED').'</span>';
90 }
91 if (!empty($next['type']) && !strcasecmp($next['type'], 'overbooking')) {
92 $ord_status .= '<div class="vbo-orders-substatus"><span class="label label-error">' . JText::translate('VBO_BTYPE_OVERBOOKING') . '</span></div>';
93 }
94 $nominative = strlen((string) $next['nominative']) > 1 ? $next['nominative'] : VikBooking::getFirstCustDataField($next['custdata']);
95 $country_flag = '';
96 if (is_file(VBO_ADMIN_PATH . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'countries' . DIRECTORY_SEPARATOR . $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 class="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 class="left"><?php echo $country_flag.$nominative; ?></td>
103 <td class="left"><?php echo $roomstr; ?></td>
104 <td class="left"><?php echo date(str_replace("/", $this->datesep, $this->df), $next['checkin']) . ' - &times;' . $next['days']; ?></td>
105 <td class="center"><?php echo $ord_status; ?></td>
106 </tr>
107 <?php
108 }
109 ?>
110 </tbody>
111 </table>
112 </div>
113 </div>
114 <?php
115 }
116 }
117