-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlistitems.php
143 lines (116 loc) · 5.45 KB
/
listitems.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
/******************************
* EQdkp
* Copyright 2002-2005
* Licensed under the GNU GPL. See COPYING for full terms.
* ------------------
* listitems.php
* Began: Sat December 21 2002
*
* $Id: listitems.php 46 2007-06-19 07:29:11Z tsigo $
*
******************************/
define('EQDKP_INC', true);
$eqdkp_root_path = './';
include_once($eqdkp_root_path . 'common.php');
$user->check_auth('u_item_list');
//
// Item Values (unique items)
//
if ( (!isset($_GET[URI_PAGE])) || ($_GET[URI_PAGE] == 'values') )
{
$sort_order = array(
0 => array('item_date desc', 'item_date'),
1 => array('item_buyer', 'item_buyer desc'),
2 => array('item_name', 'item_name desc'),
3 => array('raid_name', 'raid_name desc'),
4 => array('item_value desc', 'item_value')
);
$current_order = switch_order($sort_order);
$u_list_items = 'listitems.php'.$SID.'&';
$page_title = sprintf($user->lang['title_prefix'], $eqdkp->config['guildtag'], $eqdkp->config['dkp_name']).': '.$user->lang['listitems_title'];
$total_items = $db->num_rows($db->query('SELECT item_id FROM ' . ITEMS_TABLE . ' GROUP BY item_name'));
$start = ( isset($_GET['start']) ) ? $_GET['start'] : 0;
// We don't care about history; ignore making the items unique
$s_history = false;
$sql = 'SELECT i.item_id, i.item_name, i.item_buyer, i.item_date, i.raid_id, min(i.item_value) AS item_value, r.raid_name
FROM ' . ITEMS_TABLE . ' i, ' . RAIDS_TABLE . ' r
WHERE i.raid_id = r.raid_id
GROUP BY item_name
ORDER BY '.$current_order['sql']. '
LIMIT '.$start.','.$user->data['user_ilimit'];
$listitems_footcount = sprintf($user->lang['listitems_footcount'], $total_items, $user->data['user_ilimit']);
$pagination = generate_pagination('listitems.php'.$SID.'&o='.$current_order['uri']['current'],
$total_items, $user->data['user_ilimit'], $start);
}
//
// Item Purchase History (all items)
//
elseif ( $_GET[URI_PAGE] == 'history' )
{
$sort_order = array(
0 => array('item_date desc', 'item_date'),
1 => array('item_buyer', 'item_buyer desc'),
2 => array('item_name', 'item_name desc'),
3 => array('raid_name', 'raid_name desc'),
4 => array('item_value desc', 'item_value')
);
$current_order = switch_order($sort_order);
$u_list_items = 'listitems.php'.$SID.'&' . URI_PAGE . '=history&';
$page_title = sprintf($user->lang['title_prefix'], $eqdkp->config['guildtag'], $eqdkp->config['dkp_name']).': '.$user->lang['listpurchased_title'];
$total_items = $db->query_first('SELECT count(*) FROM ' . ITEMS_TABLE);
$start = ( isset($_GET['start']) ) ? $_GET['start'] : 0;
$s_history = true;
$sql = 'SELECT i.item_id, i.item_name, i.item_buyer, i.item_date, i.raid_id, i.item_value, r.raid_name
FROM ' . ITEMS_TABLE . ' i, ' . RAIDS_TABLE . ' r
WHERE r.raid_id=i.raid_id
ORDER BY '.$current_order['sql']. '
LIMIT '.$start.','.$user->data['user_ilimit'];
$listitems_footcount = sprintf($user->lang['listpurchased_footcount'], $total_items, $user->data['user_ilimit']);
$pagination = generate_pagination('listitems.php'.$SID.'&' . URI_PAGE . '=history&o='.$current_order['uri']['current'],
$total_items, $user->data['user_ilimit'], $start);
}
// Regardless of which listitem page they're on, we're essentially
// outputting the same stuff. Purchase History just has a buyer column.
if ( !($items_result = $db->query($sql)) )
{
message_die('Could not obtain item information', '', __FILE__, __LINE__, $sql);
}
while ( $item = $db->fetch_record($items_result) )
{
$tpl->assign_block_vars('items_row', array(
'ROW_CLASS' => $eqdkp->switch_row_class(),
'DATE' => ( !empty($item['item_date']) ) ? date($user->style['date_notime_short'], $item['item_date']) : ' ',
'BUYER' => ( !empty($item['item_buyer']) ) ? $item['item_buyer'] : '<<i>Not Found</i>>',
'U_VIEW_BUYER' => 'viewmember.php'.$SID.'&' . URI_NAME . '='.$item['item_buyer'],
'NAME' => stripslashes($item['item_name']),
'U_VIEW_ITEM' => 'viewitem.php'.$SID.'&' . URI_ITEM . '='.$item['item_id'],
'RAID' => ( !empty($item['raid_name']) ) ? stripslashes($item['raid_name']) : '<<i>Not Found</i>>',
'U_VIEW_RAID' => 'viewraid.php'.$SID.'&' . URI_RAID . '='.$item['raid_id'],
'VALUE' => $item['item_value'])
);
}
$db->free_result($items_result);
$tpl->assign_vars(array(
'L_DATE' => $user->lang['date'],
'L_BUYER' => $user->lang['buyer'],
'L_ITEM' => $user->lang['item'],
'L_RAID' => $user->lang['raid'],
'L_VALUE' => $user->lang['value'],
'O_DATE' => $current_order['uri'][0],
'O_BUYER' => $current_order['uri'][1],
'O_NAME' => $current_order['uri'][2],
'O_RAID' => $current_order['uri'][3],
'O_VALUE' => $current_order['uri'][4],
'U_LIST_ITEMS' => $u_list_items,
'START' => $start,
'S_HISTORY' => $s_history,
'LISTITEMS_FOOTCOUNT' => $listitems_footcount,
'ITEM_PAGINATION' => $pagination)
);
$eqdkp->set_vars(array(
'page_title' => $page_title,
'template_file' => 'listitems.html',
'display' => true)
);
?>