-
Notifications
You must be signed in to change notification settings - Fork 1
/
helper.php
127 lines (105 loc) · 2.76 KB
/
helper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/**
* @author Henrik Nielsen
* @copyright (C) 2018 Flexsus.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
/**
* Helper for mod_hikamarket_stats
*/
class ModHikamarketStatsHelper
{
/**
* Method to get total count of published vendors.
*
*/
public static function getTotalVendors() {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('count(*)')
->from('#__hikamarket_vendor')
->where('vendor_published = 1');
$db->setQuery($query);
$vendor_count = $db->loadResult();
return $vendor_count;
}
/**
* Method to get total count of published products.
*
*/
public static function getTotalProducts() {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('count(*)')
->from('#__hikashop_product')
->where(array(
'product_published = 1',
'product_type = '.$db->Quote('main')
));
$db->setQuery($query);
$product_count = $db->loadResult();
return $product_count;
}
/**
* Method to get total count of shipped orders.
*
*/
public static function getTotalShippedOrders() {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('count(*)')
->from('#__hikashop_order')
->where(array(
'order_status = "shipped"'
));
$db->setQuery($query);
$shipped_order_count = $db->loadResult();
return $shipped_order_count;
}
/**
* Method to get frontend online users.
*
*/
public static function getOnlineCount() {
$config = JFactory::getConfig();
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Get the number of frontend logged in users if shared sessions is not enabled.
$online_num = 0;
if (!$config->get('shared_session', '0'))
{
$query->select('COUNT(session_id)')
->from('#__session')
->where(array(
'guest = 1',
'client_id = 0'
));
$db->setQuery($query);
$online_num = (int) $db->loadResult();
return $online_num;
}
// Get the number of logged in users if shared sessions is enabled.
$total_users = 0;
if ($config->get('shared_session', '0'))
{
$query->clear()
->select('COUNT(session_id)')
->from('#__session')
->where('guest = 0');
$db->setQuery($query);
$total_users = (int) $db->loadResult();
return $total_users;
}
}
/**
* @return mod_hikamarket_stats params
*/
public static function getData(&$params) {
$ShowHideParams = array();
$ShowHideParams['show_total_vendors'] = $params->get('show_total_vendors');
$ShowHideParams['show_total_products'] = $params->get('show_total_products');
$ShowHideParams['show_total_shipped_orders'] = $params->get('show_total_shipped_orders');
$ShowHideParams['show_total_online'] = $params->get('show_total_online');
return $ShowHideParams;
}
}