/** * * this function deletes 1 attendee from a raid * dkp account is then updated * * @param int $raid_id * @param int $attendee_id * @return boolean */ private function deleteraider($raid_id, $attendee_id) { global $user, $config, $template, $phpbb_admin_path, $phpEx; $link = '<br /><a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_raid&mode=editraid&" . URI_RAID . "=" . $raid_id) . '"><h3>' . $user->lang['RETURN_RAID'] . '</h3></a>'; if (confirm_box(true)) { //recall vars $raid_id = request_var('raid_idx', 0); $member_id = request_var('attendee', 0); $this->PointsController->removeraid_delete_dkprecord($raid_id, $member_id); //carry on with fact tables $this->RaidController->deleteraider($raid_id, $member_id); trigger_error(sprintf($user->lang['ADMIN_RAID_ATTENDEE_DELETED_SUCCESS'], utf8_normalize_nfc(request_var('attendeename', '', true)), $raid_id) . $link, E_USER_WARNING); //update fact tables // do accounting } else { if ($this->LootController->Countloot($raid_id, $attendee_id) > 0) { trigger_error(sprintf($user->lang['ADMIN_RAID_ATTENDEE_DELETED_FAILED'], utf8_normalize_nfc(request_var('attendeename', '', true)), $raid_id) . $link, E_USER_WARNING); } $attendee = new \bbdkp\controller\members\Members($attendee_id); $s_hidden_fields = build_hidden_fields(array('deleteraider' => true, 'raid_idx' => $raid_id, 'attendee' => $attendee_id, 'attendeename' => $attendee->member_name)); $template->assign_vars(array('S_HIDDEN_FIELDS' => $s_hidden_fields)); confirm_box(false, sprintf($user->lang['CONFIRM_DELETE_ATTENDEE'], $attendee->member_name, $raid_id), $s_hidden_fields); } return true; }
/** * list items for a pool. master-detail form * */ private function listitems() { global $db, $user, $config, $template, $phpEx, $phpbb_admin_path, $phpbb_root_path; if (count((array) $this->LootController->dkpsys) == 0) { trigger_error('ERROR_NOPOOLS', E_USER_WARNING); } // guild dropdown $submit = isset($_POST['member_guild_id']) ? true : false; $Guild = new \bbdkp\controller\guilds\Guilds(); $guildlist = $Guild->guildlist(1); if ($submit) { $Guild->guildid = request_var('member_guild_id', 0); } else { foreach ($guildlist as $g) { $Guild->guildid = $g['id']; $Guild->name = $g['name']; if ($Guild->guildid == 0 && $Guild->name == 'Guildless') { trigger_error('ERROR_NOGUILD', E_USER_WARNING); } break; } } foreach ($guildlist as $g) { $template->assign_block_vars('guild_row', array('VALUE' => $g['id'], 'SELECTED' => $g['id'] == $Guild->guildid ? ' selected="selected"' : '', 'OPTION' => !empty($g['name']) ? $g['name'] : '(None)')); } /*** DKPSYS drop-down query ***/ $dkpsys_id = 0; // select all dkp pools that have raids $sql_array = array('SELECT' => 'd.dkpsys_id, d.dkpsys_name, d.dkpsys_default', 'FROM' => array(DKPSYS_TABLE => 'd', EVENTS_TABLE => 'e', RAIDS_TABLE => 'r'), 'WHERE' => 'd.dkpsys_id = e.event_dkpid and e.event_id = r.event_id ', 'GROUP_BY' => 'd.dkpsys_id, d.dkpsys_name, d.dkpsys_default'); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $submit = isset($_POST['dkpsys_id']) ? true : false; if ($submit) { $dkpsys_id = request_var('dkpsys_id', 0); } else { while ($row = $db->sql_fetchrow($result)) { if ($row['dkpsys_default'] == "Y") { $dkpsys_id = $row['dkpsys_id']; } } if ($dkpsys_id == 0) { $result = $db->sql_query_limit($sql, 1); while ($row = $db->sql_fetchrow($result)) { $dkpsys_id = $row['dkpsys_id']; } } } $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('dkpsys_row', array('VALUE' => $row['dkpsys_id'], 'SELECTED' => $row['dkpsys_id'] == $dkpsys_id ? ' selected="selected"' : '', 'OPTION' => !empty($row['dkpsys_name']) ? $row['dkpsys_name'] : '(None)')); $poolhasitems = true; } $db->sql_freeresult($result); /*** end drop-down query ***/ // user clicks on master raid list $raid_id = request_var('raid_id', 0); $lootcount = $this->LootController->Countloot(0, 0, $Guild->guildid); if ($lootcount > 0) { $total_raids = (int) $this->RaidController->guildraidcount($dkpsys_id, $Guild->guildid); $start = request_var('start', 0, false); $sort_order = array(0 => array('raid_id desc', 'raid_id'), 1 => array('event_name desc', 'event_name')); $current_order = $this->switch_order($sort_order); // populate raid master grid $this->RaidController->listraids($dkpsys_id, $start, 0, $Guild->guildid); foreach ($this->RaidController->raidlist as $id => $raid) { $template->assign_block_vars('raids_row', array('EVENTCOLOR' => !empty($raid['event_color']) ? $raid['event_color'] : '', 'U_VIEW_RAID' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_raid&mode=editraid&" . URI_RAID . "={$id}"), 'ID' => $id, 'DATE' => $user->format_date($raid['raid_start']), 'RAIDNAME' => $raid['event_name'], 'RAIDNOTE' => $raid['raid_note'], 'ONCLICK' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_item&mode=listitems&" . URI_DKPSYS . "={$dkpsys_id}&" . URI_RAID . "={$id}&start=" . $start))); if ($raid_id == $id) { $raid_name = $raid['event_name']; $raid_date = $user->format_date($raid['raid_start']); } } $raidpgination = generate_pagination(append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_item&mode=listitems&" . URI_DKPSYS . "=" . $dkpsys_id . "&o=" . $current_order['uri']['current']), $total_raids, $config['bbdkp_user_rlimit'], $start, true); // detail grid for items $sql1 = 'SELECT count(*) as countitems FROM ' . RAID_ITEMS_TABLE . ' where raid_id = ' . $raid_id; $result1 = $db->sql_query($sql1); $total_items = (int) $db->sql_fetchfield('countitems', false, $result1); $db->sql_freeresult($result1); $start = request_var('start', 0); $sort_order = array(0 => array('i.item_date desc', 'item_date'), 1 => array('l.member_name', 'member_name desc'), 2 => array('i.item_name', 'item_name desc'), 3 => array('e.event_name', 'event_name desc'), 4 => array('i.item_value desc', 'item_value'), 5 => array('d.dkpsys_name desc', 'dkpsys_name')); $current_order = $this->switch_order($sort_order); $items_result = $this->LootController->listRaidLoot($dkpsys_id, $raid_id, $current_order['sql']); $listitems_footcount = sprintf($user->lang['LISTPURCHASED_FOOTCOUNT_SHORT'], $total_items); $this->bbtips = false; while ($item = $db->sql_fetchrow($items_result)) { if ($this->bbtips == true && $item['item_gameid'] == 'wow') { if (is_numeric($item['item_gameid'])) { $item_name = '<strong>' . $this->bbtips->parse('[itemdkp]' . $item['item_gameid'] . '[/itemdkp]') . '</strong>'; } else { $item_name = '<strong>' . $this->bbtips->parse('[itemdkp]' . $item['item_name'] . '[/itemdkp]') . '</strong>'; } } else { $item_name = $item['item_name']; } $template->assign_block_vars('items_row', array('COLORCODE' => $item['colorcode'] == '' ? '#254689' : $item['colorcode'], 'CLASS_IMAGE' => strlen($item['imagename']) > 1 ? $phpbb_root_path . "images/bbdkp/class_images/" . $item['imagename'] . ".png" : '', 'S_CLASS_IMAGE_EXISTS' => strlen($item['imagename']) > 1 ? true : false, 'DATE' => !empty($item['item_date']) ? $user->format_date($item['item_date'], $config['bbdkp_date_format']) : ' ', 'BUYER' => !empty($item['member_name']) ? $item['member_name'] : '<<i>Not Found</i>>', 'ITEMNAME' => $item_name, 'RAID' => !empty($item['event_name']) ? $item['event_name'] : '<<i>Not Found</i>>', 'U_VIEW_BUYER' => !empty($item['member_name']) ? append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_mdkp&mode=mm_editmemberdkp&member_id={$item['member_id']}&" . URI_DKPSYS . "={$item['event_dkpid']}") : '', 'U_VIEW_ITEM' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_item&mode=additem&" . URI_ITEM . "={$item['item_id']}&" . URI_RAID . "={$raid_id}"), 'VALUE' => $item['item_value'])); } $db->sql_freeresult($items_result); $template->assign_vars(array('ICON_VIEWLOOT' => '<img src="' . $phpbb_admin_path . 'images/glyphs/view.gif" alt="' . $user->lang['ITEMS'] . '" title="' . $user->lang['ITEMS'] . '" />', 'S_SHOW' => true, 'F_LIST_ITEM' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_item&mode=listitems"), 'L_TITLE' => $user->lang['ACP_LISTITEMS'], 'L_EXPLAIN' => $user->lang['ACP_LISTITEMS_EXPLAIN'], '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' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_item&mode=listitems&start={$start}&" . URI_RAID . '=' . $raid_id), 'S_BBTIPS' => $this->bbtips, 'START' => $start, 'LISTITEMS_FOOTCOUNT' => $listitems_footcount, 'RAID_PAGINATION' => $raidpgination)); } else { $template->assign_vars(array('F_LIST_ITEM' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_item&mode=listitems"), 'L_TITLE' => $user->lang['ACP_LISTITEMS'], 'L_EXPLAIN' => $user->lang['ACP_LISTITEMS_EXPLAIN'], 'S_SHOW' => false, 'S_BBTIPS' => $this->bbtips)); } }