#################################################################
## PHP Pro Bid v6.07 ##
##-------------------------------------------------------------##
## Copyright ©2007 PHP Pro Software LTD. All rights reserved. ##
##-------------------------------------------------------------##
#################################################################
session_start();
define ('IN_SITE', 1);
include_once ('includes/global.php');
include_once ('includes/class_formchecker.php');
include_once ('includes/class_custom_field.php');
include_once ('includes/class_user.php');
include_once ('includes/class_fees.php');
include_once ('includes/class_shop.php');
include_once ('includes/class_item.php');
include_once ('includes/functions_item.php');
include_once ('includes/functions_login.php');
include_once ('includes/class_messaging.php');
include_once ('includes/class_reputation.php');
if (!$session->value('user_id'))
{
header_redirect('login.php');
}
else
{
$template->set('session', $session);
(array) $summary_page_content = null;
$default_landing_page = 'summary';
$default_landing_section = 'summary_main';
$page = (!empty($_REQUEST['page'])) ? $_REQUEST['page'] : $default_landing_page;
$section = (!empty($_REQUEST['section'])) ? $_REQUEST['section'] : $default_landing_section;
$section = ($page == 'wanted_ads' && !$setts['enable_wanted_ads']) ? $default_landing_section : $section;
$page = ($page == 'wanted_ads' && !$setts['enable_wanted_ads']) ? $default_landing_page : $page;
$section = ($page == 'store' && !$setts['enable_stores']) ? $default_landing_section : $section;
$page = ($page == 'store' && !$setts['enable_stores']) ? $default_landing_page : $page;
$section = ($page == 'bulk' && !$setts['enable_bulk_lister']) ? $default_landing_section : $section;
$page = ($page == 'bulk' && !$setts['enable_bulk_lister']) ? $default_landing_page : $page;
$section = ($page == 'reverse' && !$setts['enable_reverse_auctions']) ? $default_landing_section : $section;
$page = ($page == 'reverse' && !$setts['enable_reverse_auctions']) ? $default_landing_page : $page;
/* if account is suspended, only account related pages are active */
if ($session->value('membersarea') == 'Active')
{
if (!$session->value('is_seller') && in_array($page, array('selling', 'bulk', 'store')))
{
$page = 'bidding';
$section = 'current_bids';
$template->set('msg_seller_error', '
' . MSG_NO_SELLING_CAPABILITIES . '
');
}
}
else
{
$page = 'account';
$section = (in_array($section, array('editinfo', 'management', 'invoices', 'mailprefs'))) ? $section : 'management';
}
require ('global_header.php');
$msg_changes_saved = '' . MSG_CHANGES_SAVED . '
';
$limit = 20;
if ($page == 'messaging' || $page == 'summary')
{
$order_field = ($_REQUEST['order_field']) ? $_REQUEST['order_field'] : 'm.reg_date';
}
else if ($page == 'reputation')
{
$order_field = ($_REQUEST['order_field']) ? $_REQUEST['order_field'] : 'r.reg_date';
}
else if ($section == 'current_bids')
{
$order_field = ($_REQUEST['order_field']) ? $_REQUEST['order_field'] : 'b.auction_id';
}
else if ($section == 'item_watch')
{
$order_field = ($_REQUEST['order_field']) ? $_REQUEST['order_field'] : 'aw.id';
}
else if ($section == 'favorite_stores')
{
$order_field = ($_REQUEST['order_field']) ? $_REQUEST['order_field'] : 's.id';
}
else if ($section == 'keywords_watch')
{
$order_field = ($_REQUEST['order_field']) ? $_REQUEST['order_field'] : 'keyword_id';
}
else if ($section == 'block_users')
{
$order_field = ($_REQUEST['order_field']) ? $_REQUEST['order_field'] : 'b.reg_date';
}
else if ($page == 'wanted_ads')
{
$order_field = ($_REQUEST['order_field']) ? $_REQUEST['order_field'] : 'w.wanted_ad_id';
}
else if ($section == 'won_items' || $section == 'sold')
{
$order_field = ($_REQUEST['order_field']) ? $_REQUEST['order_field'] : 'w.auction_id';
}
else if ($page == 'reverse')
{
$order_field = ($_REQUEST['order_field']) ? $_REQUEST['order_field'] : 'r.reverse_id';
}
else
{
$order_field = ($_REQUEST['order_field']) ? $_REQUEST['order_field'] : 'a.auction_id';
}
$order_type = ($_REQUEST['order_type']) ? $_REQUEST['order_type'] : 'DESC';
$additional_vars = '&page=' . $page . '§ion=' . $section;
$order_link = '&order_field=' . $order_field . '&order_type=' . $order_type;
$limit_link = '&start=' . $start . '&limit=' . $limit;
$template->set('page', $page);
$template->set('section', $section);
$item = new item();
$item->setts = &$setts;
$item->layout = &$layout;
/**
* pending Google Checkout fees
*/
$is_pending_gc = $db->count_rows('gc_transactions', "WHERE buyer_id='" . $session->value('user_id') . "'");
$template->set('is_pending_gc', $is_pending_gc);
if ($is_pending_gc)
{
if ($section == 'management')
{
$sql_pending_gc_transactions = $db->query("SELECT gc.*, u.username FROM " . DB_PREFIX . "gc_transactions gc
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=gc.seller_id
WHERE gc.buyer_id='" . $session->value('user_id') . "' ORDER BY gc.reg_date ASC");
while ($payment_details = $db->fetch_array($sql_pending_gc_transactions))
{
$pending_gc_transactions_content .= '' . MSG_MEMBER_TIPS_A . ' ' . MSG_MEMBER_TIPS_B . '
';
$db->query("UPDATE " . DB_PREFIX . "users SET notif_a=1 WHERE user_id='" . $session->value('user_id') . "'");
}
$template->set('msg_member_tips', $msg_member_tips);
}
if (isset($_REQUEST['form_download_proceed']))
{
$download_result = download_redirect($_REQUEST['winner_id'], $session->value('user_id'));
if ($download_result['redirect'])
{
header('Location: ' . $download_result['url']);
}
$template->set('msg_changes_saved', '' . $download_result['display'] . '
');
$page = 'bidding';
$section = 'won_items';
}
if ($_REQUEST['do'] == 'delete_invoice')
{
$item->delete_invoice($_REQUEST['invoice_id'], $_REQUEST['option'], $session->value('user_id'));
}
if ($_REQUEST['do'] == 'delete_winner')
{
$item->delete_winner($_REQUEST['winner_id'], $_REQUEST['option'], $session->value('user_id'));
}
if ($_REQUEST['do'] == 'request_refund')
{
$winner_details = $db->get_sql_row("SELECT w.*, i.user_id AS payer_id, i.refund_request FROM " . DB_PREFIX . "winners w
LEFT JOIN " . DB_PREFIX . "invoices i ON i.invoice_id=w.refund_invoice_id
WHERE w.refund_invoice_id='" . intval($_REQUEST['refund_invoice_id']) . "'");
if ($winner_details['payer_id'] == $session->value('user_id') && $item->request_refund($winner_details['refund_invoice_id'], $winner_details['purchase_date'], $winner_details['flag_paid'], $winner_details['refund_request']))
{
$output = $item->process_refund_request($winner_details['refund_invoice_id']);
$template->set('msg_changes_saved', '' . $output['display'] . '
');
}
}
$src_transactions_query = null;
$src_auctions_query = null;
if ($page != 'reverse' && ($section == 'sold' || $section == 'won_items' || ($page == 'selling' && $section == 'open')))
{
$src_box_type = ($page == 'selling' && $section == 'open') ? 1 : 0;
$template->set('src_box_type', $src_box_type);
$src_auction_id = intval($_REQUEST['src_auction_id']);
$template->set('src_auction_id', $_REQUEST['src_auction_id']);
if ($src_box_type == 1)
{
$keywords_search = $db->rem_special_chars($_REQUEST['src_item_title']);
$keywords_search = optimize_search_string($keywords_search);
}
else
{
$src_username = $db->rem_special_chars($_REQUEST['src_username']);
$template->set('src_username', $src_username);
$src_start_time = (isset($_REQUEST['form_search_transactions'])) ? get_box_timestamp($_REQUEST, 1) : intval($_REQUEST['src_start_time']);
$src_start_time = ($src_start_time > 0) ? $src_start_time : 0;
$src_end_time = (isset($_REQUEST['form_search_transactions'])) ? get_box_timestamp($_REQUEST, 2) : intval($_REQUEST['src_end_time']);
$src_end_time = ($src_end_time > 0 && $src_end_time <= CURRENT_TIME) ? $src_end_time + (24 * 60 * 60 - 1) : CURRENT_TIME;
$start_date_box = date_form_field($src_start_time, 1, 'search_transactions_form', false);
$template->set('start_date_box', $start_date_box);
$end_date_box = date_form_field($src_end_time, 2, 'search_transactions_form', false);
$template->set('end_date_box', $end_date_box);
}
$show = $_REQUEST['show'];
$template->set('show', $show);
$search_transactions_box = $template->process('search_transactions_box.tpl.php');
$template->set('search_transactions_box', $search_transactions_box);
// build search query
if ($src_box_type == 1)
{
if ($src_auction_id)
{
$src_auctions_query .= " AND a.auction_id='" . $src_auction_id . "'";
}
if (!empty($_REQUEST['src_item_title']))
{
$src_auctions_query .= " AND MATCH (a.name) AGAINST ('+" . $keywords_search . "' IN BOOLEAN MODE)";
}
}
else
{
if ($src_auction_id)
{
$src_transactions_query .= " AND w.auction_id='" . $src_auction_id . "'";
}
if ($src_username)
{
$src_user_id = $db->get_sql_field("SELECT user_id FROM " . DB_PREFIX . "users WHERE username='" . $src_username . "'", 'user_id');
$src_transactions_query .= " AND " . (($section == 'sold') ? 'w.buyer_id' : 'w.seller_id') . "='" . $src_user_id . "'";
}
if ($src_start_time)
{
$src_transactions_query .= " AND w.purchase_date>='" . $src_start_time . "'";
}
if ($src_end_time)
{
$src_transactions_query .= " AND w.purchase_date<='" . $src_end_time . "'";
}
}
$additional_vars .= '&src_auction_id=' . $_REQUEST['src_auction_id'] . '&src_username=' . $src_username .
'&src_start_time=' . $src_start_time . '&src_end_time=' . $src_end_time . '&src_item_title=' . $_REQUEST['src_item_title'];
}
if ($page == 'bidding' || $page == 'selling') /* allow bidders to create product invoices as well */
{
if (isset($_REQUEST['form_send_invoice']) || $_REQUEST['send_invoice'] == 1)
{
$item->send_invoice($_POST, intval($_REQUEST['seller_id']), doubleval($_REQUEST['total_postage']), $session->value('user_id'));
$template->set('msg_changes_saved', '' . MSG_INVOICE_SENT_SUCCESSFULLY_B . '
');
$section = ($page == 'bidding') ? 'invoices_received' : 'invoices_sent';
$additional_vars = '&page=' . $page . '§ion=' . $section;
}
if ($section == 'product_invoice')
{
if ($setts['enable_buyer_create_invoice'])
{
$seller_id = ($_REQUEST['buyer_id'] && $page == 'selling') ? $session->value('user_id') : intval($_REQUEST['seller_id']);
$buyer_id = ($_REQUEST['seller_id'] && $page == 'bidding') ? $session->value('user_id') : intval($_REQUEST['buyer_id']);
}
else
{
$seller_id = $session->value('user_id');
$buyer_id = intval($_REQUEST['buyer_id']);
}
$edit_invoice = false;
if ($_REQUEST['option'] == 'edit_invoice') // only the seller can edit the invoice
{
$edit_invoice = true;
$sql_select_products = $db->query("SELECT w.*, a.name, a.apply_tax, a.currency FROM " . DB_PREFIX . "winners w
LEFT JOIN " . DB_PREFIX . "auctions a ON a.auction_id=w.auction_id WHERE w.invoice_id='" . intval($_REQUEST['invoice_id']) . "' AND
w.seller_id='" . $session->value('user_id') . "'");
$buyer_id = $db->get_sql_field("SELECT buyer_id FROM " . DB_PREFIX . "winners WHERE
invoice_id='" . intval($_REQUEST['invoice_id']) . "' AND seller_id='" . $session->value('user_id') . "'", 'buyer_id');
$seller_id = $session->value('user_id');
}
else
{
/**
* only items which have the same currency as the auction selected to be invoiced can be added in the
* same invoice
*/
$accepted_currency = $db->get_sql_field("SELECT currency FROM " . DB_PREFIX . "auctions WHERE auction_id='" . intval($_REQUEST['auction_id']) . "'", 'currency');
$sql_select_products = $db->query("SELECT a.*, w.winner_id, w.bid_amount, w.quantity_offered FROM
" . DB_PREFIX . "auctions a, " . DB_PREFIX . "winners w WHERE
a.currency='" . $accepted_currency . "' AND a.auction_id=w.auction_id AND w.seller_id='" . $seller_id . "' AND
w.buyer_id='" . $buyer_id . "' AND w.invoice_id=0");
}
$template->set('edit_invoice', $edit_invoice);
$seller_details = $db->get_sql_row("SELECT * FROM " . DB_PREFIX . "users WHERE
user_id='" . $seller_id . "'");
$template->set('seller_details', $seller_details);
$user_details = $db->get_sql_row("SELECT user_id, username FROM " . DB_PREFIX . "users WHERE
user_id='" . $buyer_id . "'");
$template->set('user_details', $user_details);
$template->set('auction_id', intval($_REQUEST['auction_id']));
$single_settings = false;
$calculate_postage = true;
$winner_ids = null;
$disabled_button = 'disabled';
$can_edit = ($seller_id == $session->value('user_id') || $edit_invoice) ? true : false;
while ($item_details = $db->fetch_array($sql_select_products))
{
if (!$single_settings)
{
$currency = $item_details['currency'];
if ($_REQUEST['option'] == 'edit_invoice')
{
$total_postage['postage'] = $item_details['postage_amount'];
$calculate_postage = false;
$disabled_button = '';
}
$template->set('invoice_comments', $item_details['invoice_comments']);
}
$background = ($counter++%2) ? 'c1' : 'c2';
$winner_array = (!empty($_REQUEST['winner_id'])) ? $_REQUEST['winner_id'] : array();
if (in_array($item_details['winner_id'], $winner_array))
{
$disabled_button = '';
$checked = 'checked';
$winner_ids[] = $item_details['winner_id'];
}
else
{
$checked = '';
}
$field = null;
if ($can_edit)
{
$field['winning_bid'] = $item_details['currency'] . ' ' . MSG_ABUSE_REPORT_ADDED . '
');
}
else
{
$display_formcheck_errors = '' . MSG_MSG_DELETED_SUCCESS . '
');
}
}
if ($section == 'received' || $page == 'summary')
{
$nb_messages = $db->count_rows('messaging', "WHERE receiver_id='" . $session->value('user_id') . "' AND
receiver_deleted=0" . (($page == 'summary') ? " AND is_read=0" : ''));
$template->set('nb_messages', $nb_messages);
$template->set('page_order_reg_date', page_order('members_area.php', 'm.reg_date', $start, $limit, $additional_vars, MSG_MESSAGE_DATE));
$template->set('page_order_sender_username', page_order('members_area.php', 'u.username', $start, $limit, $additional_vars, MSG_SENDER_USERNAME));
if ($nb_messages)
{
$nb_unread_messages = $db->count_rows('messaging', "WHERE receiver_id='" . $session->value('user_id') . "' AND
receiver_deleted=0 AND is_read=0");
$template->set('nb_unread_messages', $nb_unread_messages);
$sql_select_messages = $db->query("SELECT m.admin_message, a.name, u.username AS sender_username,
w.name AS wanted_name, r.name AS reverse_name,
m.* FROM " . DB_PREFIX . "messaging m
LEFT JOIN " . DB_PREFIX . "auctions a ON a.auction_id=m.auction_id
LEFT JOIN " . DB_PREFIX . "wanted_ads w ON w.wanted_ad_id=m.wanted_ad_id
LEFT JOIN " . DB_PREFIX . "reverse_auctions r ON r.reverse_id=m.reverse_id
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=m.sender_id
WHERE m.receiver_id='" . $session->value('user_id') . "' AND m.receiver_deleted=0
" . (($page == 'summary') ? " AND m.is_read=0" : '') . "
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
while ($msg_details = $db->fetch_array($sql_select_messages))
{
//if (!$msg_details['is_read']) exit("message not read: ".$msg_details['sender_username']);
$background = ($counter++%2) ? 'c1' : 'c2';
$ico_read = (!$msg_details['is_read']) ? 'unread' : 'read';
$content_options = '
$summary_page_content['messaging_received'] = $members_area_page_content;
}
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'sent')
{
$nb_messages = $db->count_rows('messaging', "WHERE sender_id='" . $session->value('user_id') . "' AND
sender_deleted=0");
$template->set('nb_messages', $nb_messages);
$template->set('page_order_reg_date', page_order('members_area.php', 'm.reg_date', $start, $limit, $additional_vars, MSG_MESSAGE_DATE));
$template->set('page_order_receiver_username', page_order('members_area.php', 'u.username', $start, $limit, $additional_vars, MSG_SENDER_USERNAME));
if ($nb_messages)
{
$sql_select_messages = $db->query("SELECT a.name, u.username AS receiver_username,
w.name AS wanted_name, r.name AS reverse_name,
m.* FROM " . DB_PREFIX . "messaging m
LEFT JOIN " . DB_PREFIX . "auctions a ON a.auction_id=m.auction_id
LEFT JOIN " . DB_PREFIX . "wanted_ads w ON w.wanted_ad_id=m.wanted_ad_id
LEFT JOIN " . DB_PREFIX . "reverse_auctions r ON r.reverse_id=m.reverse_id
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=m.receiver_id
WHERE m.sender_id='" . $session->value('user_id') . "' AND m.sender_deleted=0
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
while ($msg_details = $db->fetch_array($sql_select_messages))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$content_options = '
' . MSG_DELETE . ' ';
/*
$sent_messages_content .= '
'.
' ' . $msg_details['receiver_username'] . ' '.
' ' . $msg->message_subject($msg_details) . ' '.
' ' . show_date($msg_details['reg_date']) . ' '.
' '.
' ';
*/
$sent_messages_content .= '
' . (($msg_details['admin_message']) ? GMSG_SITE_ADMIN : $msg_details['sender_username']) . '
'.$msg->message_subject($msg_details).'
' . show_date($msg_details['reg_date']) . '
';
}
}
else
{
$sent_messages_content = '
' . GMSG_NO_MESSAGES_MSG . ' ';
}
$template->set('sent_messages_content', $sent_messages_content);
$pagination = paginate($start, $limit, $nb_messages, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_messaging_sent.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
} /* END -> MESSAGING PAGES */
if ($page == 'bidding' || $page == 'summary') /* BEGIN -> BIDDING PAGES */
{
if ($_REQUEST['do'] == 'retract_bid')
{
$item_details_tmp = $db->get_sql_row("SELECT * FROM " . DB_PREFIX . "auctions WHERE auction_id='" . $_REQUEST['auction_id'] . "'");
if (!$item->under_time($item_details_tmp))
{
$retract_output = $item->retract_bid($session->value('user_id'), $_REQUEST['auction_id']);
$template->set('msg_changes_saved', '
' . $retract_output['display'] . '
');
}
}
if ($_REQUEST['do'] == 'hide_bid')
{
$hide_output = $item->hide_bid($_REQUEST['bid_id'], $session->value('user_id'));
$template->set('msg_changes_saved', '
' . $hide_output . '
');
}
/*
if ($_REQUEST['do'] == 'delete_item_watch')
{
$delete_output = $item->item_watch_delete($_REQUEST['auction_id'], $session->value('user_id'));
$template->set('msg_changes_saved', '
' . $delete_output . '
');
}
*/
if (isset($_POST['form_watched_proceed']))
{
$nb_deletions = $item->count_contents($_REQUEST['delete']);
if ($nb_deletions > 0)
{
$delete_output = $item->item_watch_delete($db->implode_array($_REQUEST['delete']), $session->value('user_id'));
}
$template->set('msg_changes_saved', '
' . $delete_output . '
');
}
if (isset($_POST['form_keywords_watch_proceed']))
{
$nb_deletions = $item->count_contents($_REQUEST['delete']);
if ($nb_deletions > 0)
{
$delete_output = $item->keywords_watch_delete($db->implode_array($_REQUEST['delete']), $session->value('user_id'));
}
$template->set('msg_changes_saved', '
' . $delete_output . '
');
}
if (isset($_POST['form_keywords_watch_add_keyword']))
{
$keyword = $db->rem_special_chars($_REQUEST['keyword']);
if (!empty($keyword))
{
$db->query("INSERT INTO " . DB_PREFIX . "keywords_watch
(keyword, user_id) VALUES ('" . $keyword . "', '" . $session->value('user_id') . "')");
$template->set('msg_changes_saved', '
' . MSG_KEYWORD_ADD_SUCCESS . '
');
}
}
if ($_REQUEST['do'] == 'delete_fav_store')
{
$db->query("DELETE FROM " . DB_PREFIX . "favourite_stores WHERE id='" . intval($_REQUEST['id']) . "' AND
user_id='" . $session->value('user_id') . "'");
$template->set('msg_changes_saved', '
' . MSG_FAV_STORE_REMOVED . '
');
}
/* begin -> stats box */
$nb_current_bids = $db->get_sql_field("SELECT count(*) AS nb_bids FROM " . DB_PREFIX . "bids b, " . DB_PREFIX . "auctions a WHERE
b.bidder_id=" . $session->value('user_id') . " AND a.auction_id=b.auction_id AND a.active=1 AND a.closed=0 AND
a.deleted=0 AND b.deleted=0 AND b.bid_invalid=0", 'nb_bids');
$nb_winning = $db->get_sql_field("SELECT count(*) AS nb_bids FROM " . DB_PREFIX . "bids b, " . DB_PREFIX . "auctions a WHERE
b.bidder_id=" . $session->value('user_id') . " AND b.bid_out=0 AND b.bid_invalid=0 AND
a.auction_id=b.auction_id AND a.active=1 AND a.closed=0 AND a.deleted=0 AND b.deleted=0", 'nb_bids');
$nb_won_items = $db->count_rows('winners w', "WHERE w.buyer_id='" . $session->value('user_id') . "' AND
w.b_deleted=0" . $src_transactions_query);
$template->set('nb_current_bids', $nb_current_bids);
$template->set('nb_winning', $nb_winning);
$template->set('nb_won_items', $nb_won_items);
$members_area_stats = $template->process('members_area_stats_bidding.tpl.php');
if ($page == 'summary')
{
$summary_page_content['stats_bidding'] = $members_area_stats;
}
else
{
$template->set('members_area_stats', $members_area_stats);
}
/* end -> stats box */
if ($section == 'current_bids' || $page == 'summary')
{
$header_bidding_page = headercat('
' . MSG_MM_BIDDING . ' - ' . MSG_MM_CURRENT_BIDS . ' ');
$nb_bids = $nb_current_bids;
$template->set('header_bidding_page', $header_bidding_page);
$template->set('nb_bids', $nb_bids);
if ($page == 'summary')
{
$order_field = 'b.bid_id';
$order_type = 'DESC';
$start = 0;
$limit = 5;
}
else
{
$template->set('page_order_auction_id', page_order('members_area.php', 'a.auction_id', $start, $limit, $additional_vars, MSG_AUCTION_ID));
$template->set('page_order_itemname', page_order('members_area.php', 'a.name', $start, $limit, $additional_vars, MSG_ITEM_TITLE));
$template->set('page_order_bid_amount', page_order('members_area.php', 'b.bid_amount', $start, $limit, $additional_vars, MSG_BID_AMOUNT));
$template->set('page_order_bid_proxy', page_order('members_area.php', 'b.bid_proxy', $start, $limit, $additional_vars, MSG_PROXY_BID));
$template->set('page_order_bid_date', page_order('members_area.php', 'b.bid_date', $start, $limit, $additional_vars, GMSG_DATE));
}
if ($nb_bids)
{
$sql_select_bids = $db->query("SELECT b.*, a.* FROM " . DB_PREFIX . "bids b, " . DB_PREFIX . "auctions a
WHERE b.bidder_id=" . $session->value('user_id') . " AND a.auction_id=b.auction_id AND a.active=1 AND
a.closed=0 AND a.deleted=0 AND b.deleted=0 AND b.bid_invalid=0
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
while ($bid_details = $db->fetch_array($sql_select_bids))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$content_options = array();
if ($setts['enable_bid_retraction'])
{
if (!$item->under_time($bid_details))
{
$content_options[] = '
' . MSG_RETRACT_BID . ' ';
}
if ($bid_details['bid_out'])
{
$content_options[] = '
' . MSG_DELETE . ' ';
}
}
$options_output = $db->implode_array($content_options, '
');
$media_url = $db->get_sql_field("SELECT media_url FROM " . DB_PREFIX . "auction_media WHERE auction_id=" . $bid_details['auction_id'] . " AND
media_type=1 AND upload_in_progress=0 ORDER BY media_id ASC", 'media_url');
$auction_image = (!empty($media_url)) ? $media_url : 'themes/' . $setts['default_theme'] . '/img/system/noimg.gif';
$auction_link = process_link('auction_details', array('auction_id' => $bid_details['auction_id']));
$current_bids_content .= '
'.
' '.
' # ' . $bid_details['auction_id'] . ' '.
' ' . $bid_details['name'] . ' '.
' ' . $fees->display_amount($bid_details['bid_amount'], $bid_details['currency']) . ' '.
' ' . $fees->display_amount($bid_details['bid_proxy'], $bid_details['currency']) . ' '.
' ' . show_date($bid_details['bid_date']) . ' '.
' ' . field_display($bid_details['bid_out'], GMSG_ACTIVE, GMSG_INACTIVE) . ' '.
' ' . $options_output . ' '.
' ';
}
}
else
{
$current_bids_content = '
' . GMSG_NO_BIDS_MSG . ' ';
}
$template->set('current_bids_content', $current_bids_content);
if ($page != 'summary')
{
$pagination = paginate($start, $limit, $nb_bids, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
}
// current bids
$members_area_page_content = $template->process('members_area_bidding_current_bids.tpl.php');
if ($page == 'summary')
{
$summary_page_content['bidding_current_bids'] = $members_area_page_content;
}
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'won_items')
{
$show_link = '&show=' . $_REQUEST['show'];
(string) $search_filter = null;
if ($_REQUEST['show'] == 'dd')
{
$search_filter .= " AND w.is_dd=1";
$nb_won_items = $db->count_rows('winners w', "WHERE w.buyer_id='" . $session->value('user_id') . "' AND
w.b_deleted=0" . $search_filter . $src_transactions_query);
}
else if ($_REQUEST['show'] == 'no_dd')
{
$search_filter .= " AND w.is_dd=0";
$nb_won_items = $db->count_rows('winners w', "WHERE w.buyer_id='" . $session->value('user_id') . "' AND
w.b_deleted=0" . $search_filter . $src_transactions_query);
}
(string) $filter_items_content = null;
$filter_items_content .= display_link('members_area.php?page=bidding§ion=won_items', GMSG_ALL, ((!$_REQUEST['show']) ? false : true)) . ' | ';
$filter_items_content .= display_link('members_area.php?page=bidding§ion=won_items&show=dd', MSG_DIGITAL_MEDIA_ATTACHED, (($_REQUEST['show'] == 'dd') ? false : true)) . ' | ';
$filter_items_content .= display_link('members_area.php?page=bidding§ion=won_items&show=no_dd', MSG_NO_DIGITAL_MEDIA, (($_REQUEST['show'] == 'no_dd') ? false : true));
$template->set('filter_items_content', $filter_items_content);
$nb_items = $nb_won_items;
$template->set('nb_items', $nb_items);
$template->set('page_order_auction_id', page_order('members_area.php', 'w.auction_id', $start, $limit, $additional_vars . $show_link, MSG_AUCTION_ID));
$template->set('page_order_itemname', page_order('members_area.php', 'a.name', $start, $limit, $additional_vars . $show_link, MSG_ITEM_TITLE));
$template->set('page_order_bid_amount', page_order('members_area.php', 'w.bid_amount', $start, $limit, $additional_vars . $show_link, MSG_WINNING_BID));
$template->set('page_order_quantity', page_order('members_area.php', 'w.quantity_offered', $start, $limit, $additional_vars . $show_link, MSG_QUANTITY_OFFERED));
$template->set('page_order_purchase_date', page_order('members_area.php', 'w.purchase_date', $start, $limit, $additional_vars . $show_link, MSG_PURCHASE_DATE));
if ($nb_items)
{
$sql_select_won = $db->query("SELECT w.*, a.name AS auction_name, a.currency, a.category_id,
a.bank_details, a.direct_payment, u.username, u.name, r.submitted, r.reputation_id,
i.refund_request, i.user_id AS payer_id
FROM " . DB_PREFIX . "winners w
LEFT JOIN " . DB_PREFIX . "auctions a ON a.auction_id=w.auction_id
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=w.seller_id
LEFT JOIN " . DB_PREFIX . "reputation r ON r.from_id=w.buyer_id AND r.winner_id=w.winner_id
LEFT JOIN " . DB_PREFIX . "invoices i ON i.invoice_id=w.refund_invoice_id
WHERE w.buyer_id='" . $session->value('user_id') . "' AND w.b_deleted=0
" . $search_filter . $src_transactions_query . "
GROUP BY w.winner_id
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
$sale_fee = new fees();
$sale_fee->setts = &$setts;
while ($item_details = $db->fetch_array($sql_select_won))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$sale_fee->set_fees($item_details['buyer_id'], $item_details['category_id']);## PHP Pro Bid v6.00 by default the seller will pay
$item_paid = ($item_details['active'] == 1 && $item_details['payment_status'] == 'confirmed') ? 1 : 0;
if ($item_paid)
{
$content_options = '•
' . MSG_MESSAGE_BOARD . ' ';
if (!$item_details['submitted'])
{
//$content_options .= '•
' . MSG_LEAVE_COMMENTS . ' ';
}
$content_options .= (!empty($item_details['bank_details'])) ? '•
' . MSG_VIEW_BANK_DETAILS . ' ' : '';
if (!$item_details['invoice_sent'])
{
$content_options .= '•
' . MSG_DELETE . ' ';
}
}
else
{
if (eregi('b', $sale_fee->fee['endauction_fee_applies']))
{
$content_options = '•
' . MSG_PAY_ENDAUCTION_FEE . ' ';
}
else
{
$content_options = '• ' . MSG_ENDAUCTION_FEE_NOT_PAID;
}
}
if ($item_details['invoice_id'])
{
$direct_payment_link = '[
' . MSG_PAY_WITH_DIRECT_PAYMENT . ' ]';
}
else
{
$direct_payment_link = '[
' . field_display(MSG_PAY_WITH_DIRECT_PAYMENT, '') . ' ]';
}
$won_auctions_content .= '
'.
' # ' . $item_details['auction_id'] . ' - '.
' ' . field_display($item_details['auction_name'], MSG_AUCTION_DELETED) . ' '.
(($item_paid && !empty($item_details['direct_payment']) && !$item_details['direct_payment_paid'] && !$item_details['flag_paid'] && $item_details['bid_amount'] > 0) ? ' ' . $direct_payment_link : '').
' '.
' ' . $fees->display_amount($item_details['bid_amount'], $item_details['currency']) . ' '.
' ' . MSG_REQUESTED . ': ' . $item_details['quantity_requested'] . ' '.
' ' . MSG_OFFERED . ': ' . $item_details['quantity_offered'] . ' '.
' ';
if ($item_paid)
{
$won_auctions_content .= ' '.
' '.
' ' . MSG_USERNAME . ' '.
' ' . field_display($item_details['username'], GMSG_NA) . ' '.
' '.
' '.
' ' . MSG_FULL_NAME . ' '.
' ' . field_display($item_details['name'], GMSG_NA) . ' '.
' '.
'
';
}
$won_auctions_content .= ' '.
' ';
if ($item_paid)
{
$won_auctions_content .= ' '.
' '.
' ' . show_date($item_details['purchase_date']) . ' '.
' '.
' '.
' ' . $item->flag_paid($item_details['flag_paid'], $item_details['direct_payment_paid']) . ' '.
' '.
' '.
' ' . $item->flag_status($item_details['flag_status']) . ' '.
' '.
'
';
}
$won_auctions_content .= ' '.
' ' . $content_options . ' '.
' ';
if ($item_paid)
{
if ($item_details['invoice_sent'])
{
$won_auctions_content .= '
'.
' '.
' • ' . MSG_INVOICE_RECEIVED . ' [ ' . MSG_ID . ': ' . $item_details['invoice_id'] . ' ] ' . MSG_VIEW_PRODUCT_INVOICE . ' '.
' '.
' ';
}
else if ($setts['enable_buyer_create_invoice'])
{
$won_auctions_content .= '
'.
' '.
' • ' . MSG_COMBINE_PURCHASES . ' '.
' '.
' ';
}
if ($item_details['payer_id'] == $session->value('user_id') && $item->request_refund($item_details['refund_invoice_id'], $item_details['purchase_date'], $item_details['flag_paid'], $item_details['refund_request']))
{
$won_auctions_content .= '
'.
' '.
' • ' . MSG_REQUEST_EOA_REFUND . ' ';
' '.
' ';
}
if ($item_details['is_dd'])
{
$dd_expires = dd_expires($item_details['dd_active_date']);
$won_auctions_content .= '
'.
' ' . MSG_DIGITAL_MEDIA_ATTACHED . ' '.
' ' . MSG_DOWNLOADED . ' ' . $item_details['dd_nb_downloads'] . ' ' . MSG_TIMES . ' '.
(($item_details['dd_active']) ? '' : '') .
' ' . MSG_LINK_EXPIRES . ': ' . (($item_details['dd_active']) ? $dd_expires['display'] : GMSG_NA) . ' '.
' ';
}
}
if ($item_details['temp_purchase'])
{
$won_auctions_content .= '
'.
' ' . MSG_BUYOUT_FORCE_PAYMENT_ALERT . ' '.
' ';
}
$won_auctions_content .= '
'.
' '.
' ';
}
}
else
{
$won_auctions_content = '
' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('won_auctions_content', $won_auctions_content);
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link . $show_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_bidding_won_items.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'invoices_received')
{
$nb_items = $db->get_sql_number("SELECT winner_id FROM " . DB_PREFIX . "winners WHERE
invoice_sent=1 AND buyer_id='" . $session->value('user_id') . "' GROUP BY invoice_id");
$template->set('nb_items', $nb_items);
(string) $invoices_received_content = null;
if ($nb_items)
{
$sql_select_invoices = $db->query("SELECT w.*, u.username FROM " . DB_PREFIX . "winners w
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=w.seller_id
WHERE w.buyer_id='" . $session->value('user_id') . "' AND w.b_deleted=0 AND w.invoice_sent=1
GROUP BY w.invoice_id
ORDER BY w.invoice_id DESC LIMIT " . $start . ", 5");
while ($invoice_details = $db->fetch_array($sql_select_invoices))
{
$invoices_received_content .= '
'.
' [ ' . MSG_INVOICE_ID . ': ' . $invoice_details['invoice_id'] . ' ] [ ' . MSG_SELLER_USERNAME . ': ' . $invoice_details['username'] . ' ]'.
' [ ' . MSG_DELETE . ' ]'.
' ';
$sql_select_products = $db->query("SELECT w.*, a.name,
a.direct_payment, a.currency FROM " . DB_PREFIX . "winners w
LEFT JOIN " . DB_PREFIX . "auctions a ON a.auction_id=w.auction_id WHERE
w.invoice_id='" . $invoice_details['invoice_id'] . "'");
$invoices_received_content .= ' '.
'
'.
' '.
' '.
' '.
' ';
(array) $dp_array = null;
(array) $items_array = null;
$product_postage = null;
$product_insurance = null;
while ($item_details = $db->fetch_array($sql_select_products))
{
$background = 'c1';
$currency = $item_details['currency'];
$product_postage = ($item_details['postage_included']) ? (($item_details['pc_postage_type'] == 'item') ? ($item_details['postage_amount'] + $product_postage) : $item_details['postage_amount']) : 0;
$product_insurance += ($item_details['insurance_included']) ? $item_details['insurance_amount'] : 0;
$auction_link = process_link('auction_details', array('name' => $item_details['name'], 'auction_id' => $item_details['auction_id']));
$invoices_received_content .= '
'.
' [ ' . MSG_ID . ': ' . $item_details['auction_id'] . ' ] ' . $item_details['name'] . ' '.
' ' . $item_details['quantity_offered'] . ' '.
' ' . $fees->display_amount($item_details['bid_amount'], $item_details['currency']) . ' '.
' ';
$items_array[] = $item_details;
$dp_array[] = ($item_details['direct_payment']) ? @explode(',', $item_details['direct_payment']) : null;
}
// new postage and insurance tab
$invoices_received_content .= '
'.
' '.
' '.
'
'.
' '.
' ' . MSG_POSTAGE . ': '.
' ' . $fees->display_amount($product_postage, $currency) . ' '.
' '.
'
'.
' '.
' ' . MSG_INSURANCE . ': '.
' ' . $fees->display_amount($product_insurance, $currency) . ' '.
' '.
'
'.
' '.
' ';
(string) $direct_payment_link = null;
$is_direct_payment = $item->direct_payment_multiple($invoice_details['invoice_id'], $items_array, $dp_array, $session->value('user_id'));
if ($is_direct_payment)
{
$direct_payment_link = '[
' . MSG_PAY_WITH_DIRECT_PAYMENT . ' ]';
}
$invoices_received_content .= '
'.
' [ ' . MSG_VIEW_PRODUCT_INVOICE . ' ] ' . $direct_payment_link . ' '.
' '.
'
'.
' '.
' ';
}
}
else
{
$invoices_received_content = '
' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('invoices_received_content', $invoices_received_content);
$pagination = paginate($start, 5, $nb_items, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_bidding_invoices_received.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'item_watch')
{
$nb_items = $db->count_rows('auction_watch', "WHERE user_id='" . $session->value('user_id') . "'");
$template->set('nb_items', $nb_items);
$template->set('page_order_auction_id', page_order('members_area.php', 'a.auction_id', $start, $limit, $additional_vars, MSG_AUCTION_ID));
$template->set('page_order_end_time', page_order('members_area.php', 'a.end_time', $start, $limit, $additional_vars, GMSG_END_TIME));
$template->set('page_order_itemname', page_order('members_area.php', 'a.name', $start, $limit, $additional_vars, MSG_ITEM_TITLE));
if ($nb_items)
{
$sql_select_items = $db->query("SELECT aw.*, a.name, a.end_time FROM " . DB_PREFIX . "auction_watch aw
LEFT JOIN " . DB_PREFIX . "auctions a ON a.auction_id=aw.auction_id
WHERE aw.user_id='" . $session->value('user_id') . "'
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
while ($item_details = $db->fetch_array($sql_select_items))
{
$background = ($counter++%2) ? 'c1' : 'c2';
//$content_options = '
' . MSG_DELETE . ' ';
$content_options = '
';
$watched_items_content .= '
'.
' # ' . $item_details['auction_id'] . ' '.
' ' . $item_details['name'] . ' '.
' ' . time_left($item_details['end_time']) . ' '.
' ' . $content_options . ' '.
' ';
}
}
else
{
$watched_items_content = '
' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('watched_items_content', $watched_items_content);
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_bidding_item_watch.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'favorite_stores')
{
$nb_items = $db->count_rows('favourite_stores', "WHERE user_id='" . $session->value('user_id') . "'");
$template->set('nb_items', $nb_items);
if ($nb_items)
{
$sql_select_items = $db->query("SELECT s.*, u.shop_name, u.username, u.shop_nb_items FROM " . DB_PREFIX . "favourite_stores s
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=s.store_id
WHERE s.user_id='" . $session->value('user_id') . "'
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
while ($item_details = $db->fetch_array($sql_select_items))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$content_options = '
' . MSG_DELETE . ' ';
$fav_stores_content .= '
'.
' # ' . $item_details['store_id'] . ' '.
' ' . $item_details['shop_name'] . ' '.
' ' . $item_details['username'] . ' '.
' ' . $item_details['shop_nb_items'] . ' '.
' ' . $content_options . ' '.
' ';
}
}
else
{
$fav_stores_content = '
' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('fav_stores_content', $fav_stores_content);
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_bidding_favorite_stores.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'keywords_watch')
{
$nb_items = $db->count_rows('keywords_watch', "WHERE user_id='" . $session->value('user_id') . "'");
$template->set('nb_items', $nb_items);
$template->set('option', $_REQUEST['option']);
$template->set('page_order_keyword', page_order('members_area.php', 'keyword', $start, $limit, $additional_vars, MSG_KEYWORD));
if ($nb_items)
{
$sql_select_items = $db->query("SELECT * FROM " . DB_PREFIX . "keywords_watch
WHERE user_id='" . $session->value('user_id') . "'
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
while ($item_details = $db->fetch_array($sql_select_items))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$content_options = '
';
$keywords_watch_content .= '
'.
' ' . $item_details['keyword'] . ' '.
' ' . $content_options . ' '.
' ';
}
}
else
{
$keywords_watch_content = '
' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('keywords_watch_content', $keywords_watch_content);
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_bidding_keywords_watch.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
} /* END -> BIDDING PAGES */
if ($page == 'selling' || ($page == 'summary' && $session->value('is_seller'))) /* BEGIN -> SELLING PAGES */
{
if ($page == 'selling' && $session->value('is_seller') && $setts['enable_seller_verification'])
{
## seller verification status box
$seller_details = $db->get_sql_row("SELECT seller_verified FROM
" . DB_PREFIX . "users WHERE user_id=" . $session->value('user_id'));
$template->set('seller_details', $seller_details);
$seller_verified_status_box = $template->process('members_area_stats_verif_status_box.tpl.php');
$template->set('seller_verified_status_box', $seller_verified_status_box);
}
if ($_REQUEST['do'] == 'delete_auction')
{
$item->delete($_REQUEST['auction_id'], $session->value('user_id'));
}
if ($_REQUEST['do'] == 'close_auction')
{
$auction_id = intval($_REQUEST['auction_id']);
$close_item_details = $db->get_sql_row("SELECT * FROM " . DB_PREFIX . "auctions WHERE auction_id='" . $auction_id . "'");
if ($item->can_close_manually($close_item_details, $session->value('user_id')))
{
$db->query("UPDATE " . DB_PREFIX . "auctions SET close_in_progress=1 WHERE
auction_id='" . $auction_id . "'");
$item->close($close_item_details, false, false);
$db->query("UPDATE " . DB_PREFIX . "auctions SET close_in_progress=0 WHERE
auction_id='" . $auction_id . "'");
}
}
if ($_REQUEST['do'] == 'closed_proceed')
{
$nb_relists = $item->count_contents($_REQUEST['relist']);
$nb_deletions = $item->count_contents($_REQUEST['delete']);
if ($nb_relists > 0)
{
for ($i=0; $i<$nb_relists; $i++)
{
$relist_id = $_REQUEST['relist'][$i];
$relist_result = $item->relist($relist_id, $session->value('user_id'), $_REQUEST['duration'][$relist_id]);
$relist_output[] = $relist_result['display'];
}
$template->set('msg_auction_relist', '
' . $db->implode_array($relist_output, ' ') . '
');
}
if ($nb_deletions > 0)
{
$item->delete($db->implode_array($_REQUEST['delete']), $session->value('user_id'));
}
}
if ($_REQUEST['do'] == 'delete_offer')
{
$msg_changes_saved = '
' . MSG_OFFER_DELETED_SUCCESS . '
';
$template->set('msg_changes_saved', $msg_changes_saved);
if (in_array($_REQUEST['offer_type'], array('auction_offers', 'swaps')))
{
$item->delete_offer($_REQUEST['offer_type'], $_REQUEST['offer_id'], $session->value('user_id'));
}
}
if ($_REQUEST['do'] == 'accept_offer')
{
$msg_changes_saved = '
' . MSG_OFFER_ACCEPTED_SUCCESS . '
';
$template->set('msg_changes_saved', $msg_changes_saved);
if (in_array($_REQUEST['offer_type'], array('auction_offers', 'swaps', 'bids')))
{
$item->accept_offer($_REQUEST['offer_type'], $_REQUEST['offer_id'], $session->value('user_id'));
}
}
if ($_REQUEST['do'] == 'resend_invoice')
{
$invoice_id = intval($_REQUEST['invoice_id']);
$is_invoice = $db->count_rows('winners', "WHERE invoice_id='" . $invoice_id . "' AND
seller_id='" . $session->value('user_id') . "'");
if ($is_invoice && $invoice_id > 0)
{
$item->resend_invoice($invoice_id);
$template->set('msg_changes_saved', '
' . MSG_INVOICE_SENT_SUCCESSFULLY . '
');
}
}
if ($_REQUEST['do'] == 'dd_active')
{
activate_dd($_REQUEST['winner_id'], $session->value('user_id'), $_REQUEST['value']);
$template->set('msg_changes_saved', '
' . MSG_CHANGES_SAVED . '
');
}
if ($_REQUEST['do'] == 'add_suggested_category')
{
$category_desc = $db->rem_special_chars($_REQUEST['category_desc']);
$db->query("INSERT INTO " . DB_PREFIX . "suggested_categories
(userid, content, regdate) VALUES
('" . $session->value('user_id') . "', '" . $category_desc . "', '" . CURRENT_TIME . "')");
$template->set('msg_changes_saved', '
' . MSG_CATEGORY_SUGGESTION_SUCCESS . '
');
}
if ($section == 'suggest_category')
{
$members_area_page_content = $template->process('members_area_selling_suggest_category.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'view_offers')
{
$item_details = $db->get_sql_row("SELECT a.*, w.seller_id, w.purchase_date, w.flag_paid, w.buyer_id FROM " . DB_PREFIX . "auctions a
LEFT JOIN " . DB_PREFIX . "winners w ON w.auction_id=a.auction_id WHERE
a.owner_id='" . $session->value('user_id') . "' AND a.auction_id='" . intval($_REQUEST['auction_id']) . "'
GROUP BY a.auction_id");
## add a can_make_offer function which checks if offers are available.
$can_make_offer = $item->can_make_offer($item_details);
if ($item->count_contents($item_details))
{
$template->set('item_details', $item_details);
if (!empty($item_details['direct_payment']))
{
$dp_methods = $item->select_direct_payment($item_details['direct_payment'], 0, true, true);
$template->set('direct_payment_methods_display', $db->implode_array($dp_methods, ', '));
}
if (!empty($item_details['payment_methods']))
{
$offline_payments = $item->select_offline_payment($item_details['payment_methods'], true, true);
$template->set('offline_payment_methods_display', $db->implode_array($offline_payments, ', '));
}
(string) $winning_bids_content = null;
(string) $make_offer_content = null;
(string) $reserve_offer_content = null;
(string) $second_chance_content = null;
(string) $swap_offer_content = null;
/**
* first we will show on this page if there are any winners on this auction with the possibility to
* delete the winning bid rows
*/
if ($item_details['closed'] == 1)
{
$sql_select_winning_bids = $db->query("SELECT w.*, u.username, a.currency FROM " . DB_PREFIX . "winners w
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=w.buyer_id
LEFT JOIN " . DB_PREFIX . "auctions a ON a.auction_id=w.auction_id
WHERE w.auction_id='" . $item_details['auction_id'] . "' AND w.seller_id='" . $session->value('user_id') . "'
ORDER BY w.winner_id DESC");
while ($winning_bid_details = $db->fetch_array($sql_select_winning_bids))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$winning_bids_content .= '
'.
' ' . $winning_bid_details['username'] . user_pics($winning_bid_details['buyer_id']) . ' '.
' ' . $winning_bid_details['quantity_offered'] . ' '.
' ' . $fees->display_amount($winning_bid_details['bid_amount'], $winning_bid_details['currency']) . ' '.
' ' . show_date($winning_bid_details['purchase_date']) . ' '.
' ' . $item->flag_paid($winning_bid_details['flag_paid'], $winning_bid_details['direct_payment_paid']) . ' '.
' ';
}
$template->set('winning_bids_content', $winning_bids_content);
}
if ($layout['enable_buyout'] && $setts['makeoffer_process'] == 1 && ($item_details['auction_type'] == 'standard' || empty($winning_bids_content)))## make offer is enabled (for dutch only if no winners)
{
$sql_select_make_offer = $db->query("SELECT ao.*, u.username FROM " . DB_PREFIX . "auction_offers ao,
" . DB_PREFIX . "users u WHERE ao.auction_id='" . $item_details['auction_id'] . "' AND
ao.seller_id='" . $session->value('user_id') . "' AND ao.buyer_id=u.user_id");
while ($offer_details = $db->fetch_array($sql_select_make_offer))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$make_offer_content .= '
'.
' ' . $offer_details['username'] . ' '.
' ' . $offer_details['quantity'] . ' '.
' ' . $offer_details['amount'] . ' '.
' ' . $item->offer_status($offer_details['accepted']) . ' '.
' ' . $item->offer_options($item_details['auction_id'], $offer_details['offer_id'], $offer_details['accepted'], $can_make_offer, 'auction_offers') . ' '.
' ';
}
$template->set('make_offer_content', $make_offer_content);
}
if ($item_details['enable_swap'] && ($item_details['auction_type'] == 'standard' || empty($winning_bids_content))) ## swaps are enabled (for dutch only if no winners)
{
$sql_select_swaps = $db->query("SELECT s.*, u.username FROM " . DB_PREFIX . "swaps s,
" . DB_PREFIX . "users u WHERE s.auction_id='" . $item_details['auction_id'] . "' AND
s.seller_id='" . $session->value('user_id') . "' AND s.buyer_id=u.user_id");
while ($offer_details = $db->fetch_array($sql_select_swaps))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$swap_offer_content .= '
'.
' ' . $offer_details['username'] . ' '.
' ' . $offer_details['quantity'] . ' '.
' ' . $offer_details['description'] . ' '.
' ' . $item->offer_status($offer_details['accepted']) . ' '.
' ' . $item->offer_options($item_details['auction_id'], $offer_details['swap_id'], $offer_details['accepted'], $can_make_offer, 'swaps') . ' '.
' ';
}
$template->set('swap_offer_content', $swap_offer_content);
}
if ($item_details['closed'] == 1 && $item_details['nb_bids'] > 0 && $item_details['max_bid'] < $item_details['reserve_price'])## PHP Pro Bid v6.00 we have bids on the auction
{
$sql_select_bids = $db->query("SELECT b.*, u.username FROM " . DB_PREFIX . "bids b,
" . DB_PREFIX . "users u WHERE b.auction_id='" . $item_details['auction_id'] . "' AND b.bidder_id=u.user_id");
while ($offer_details = $db->fetch_array($sql_select_bids))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$reserve_offer_content .= '
'.
' ' . $offer_details['username'] . user_pics($offer_details['bidder_id']) . ' '.
' ' . $offer_details['quantity'] . ' '.
' ' . $offer_details['bid_amount'] . ' '.
' ' . $item->offer_status($offer_details['accepted']) . ' '.
' ' . $item->offer_options($item_details['auction_id'], $offer_details['bid_id'], 0, $can_make_offer, 'bids') . ' '.
' ';
}
$template->set('reserve_offer_content', $reserve_offer_content);
}
else if ($setts['enable_second_chance'] && $item_details['nb_bids'] > 0 && $item_details['closed'] == 1)
{
if ($item_details['closed'] == 1 && $item_details['nb_bids'] > 0 && $item->apply_second_chance($item_details, $session->value('user_id')))
{
$sql_select_bids = $db->query("SELECT b.*, u.username FROM " . DB_PREFIX . "bids b,
" . DB_PREFIX . "users u WHERE b.auction_id='" . $item_details['auction_id'] . "' AND
b.bidder_id=u.user_id AND b.bid_invalid=0 AND b.bidder_id!='" . $item_details['buyer_id'] . "' ORDER BY b.bid_out ASC, b.bid_id DESC");
while ($bid_details = $db->fetch_array($sql_select_bids))
{
$select_winner_link = '[
' . MSG_SELECT_WINNER . ' ] ';
$background = ($counter++%2) ? 'c1' : 'c2';
$second_chance_content .= '
'.
' ' . $bid_details['username'] . user_pics($bid_details['bidder_id']) . ' '.
' ' . $bid_details['quantity'] . ' '.
' ' . $bid_details['bid_amount'] . ' '.
' ' . $select_winner_link . ' '.
' ';
}
$template->set('second_chance_content', $second_chance_content);
}
}
$members_area_page_content = $template->process('members_area_selling_view_offers.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
else
{
$section = 'selling';## PHP Pro Bid v6.00 we redirect
}
}
if ($section == 'rollback')
{
$auction_id = intval($_REQUEST['auction_id']);
$reverse_id = intval($_REQUEST['reverse_id']);
$message_header = headercat('
' . (($reverse_id) ? MSG_MM_REVERSE_AUCTIONS : MSG_MM_SELLING) . ' - ' . MSG_ROLLBACK_TRANSACTION . ' ');
$template->set('message_header', $message_header);
$template->set('message_content', '
' . MSG_ROLLBACK_SUCCESS . '
');
$item->rollback_transaction($auction_id, $session->value('user_id'), $reverse_id);
$template_output .= $template->process('single_message.tpl.php');
}
/* begin -> stats box */
$nb_open_items = $db->count_rows('auctions a', "WHERE a.owner_id='" . $session->value('user_id') . "' AND
a.closed=0 AND a.deleted=0 AND a.creation_in_progress=0 AND a.is_draft=0" . $src_auctions_query);
$nb_items_bids = $db->count_rows('auctions', "WHERE owner_id='" . $session->value('user_id') . "' AND
closed=0 AND deleted=0 AND creation_in_progress=0 AND is_draft=0 AND (nb_bids>0 OR nb_offers>0)");
$nb_scheduled_items = $db->count_rows('auctions', "WHERE closed=1 AND owner_id='" . $session->value('user_id') . "' AND
deleted=0 AND creation_in_progress=0 AND is_draft=0 AND end_time>='" . CURRENT_TIME . "'");
$nb_closed_items = $db->count_rows('auctions', "WHERE closed=1 AND owner_id='" . $session->value('user_id') . "' AND
deleted=0 AND end_time<='" . CURRENT_TIME . "' AND creation_in_progress=0 AND is_draft=0");
$nb_sold_items = $db->count_rows('winners w', "WHERE w.seller_id='" . $session->value('user_id') . "' AND
w.s_deleted=0" . $src_transactions_query);
$nb_drafts = $db->count_rows('auctions', "WHERE owner_id='" . $session->value('user_id') . "' AND
is_draft=1");
$template->set('nb_open_items', $nb_open_items);
$template->set('nb_items_bids', $nb_items_bids);
$template->set('nb_scheduled_items', $nb_scheduled_items);
$template->set('nb_closed_items', $nb_closed_items);
$template->set('nb_sold_items', $nb_sold_items);
$template->set('nb_drafts', $nb_drafts);
$members_area_stats = $template->process('members_area_stats_selling.tpl.php');
if ($page == 'summary')
{
$summary_page_content['stats_selling'] = $members_area_stats;
}
else
{
$template->set('members_area_stats', $members_area_stats);
}
/* end -> stats box */
if ($section == 'open' || $page == 'summary')
{
$header_selling_page = headercat('
' . MSG_MM_SELLING . ' - ' . MSG_MM_OPEN_AUCTIONS . ' ');
$nb_items = $nb_open_items;
$template->set('header_selling_page', $header_selling_page);
$template->set('nb_items', $nb_items);
if ($page == 'summary')
{
$order_field = 'a.auction_id';
$order_type = 'DESC';
$start = 0;
$limit = 5;
}
else
{
$template->set('page_order_auction_id', page_order('members_area.php', 'a.auction_id', $start, $limit, $additional_vars, MSG_AUCTION_ID));
$template->set('page_order_itemname', page_order('members_area.php', 'a.name', $start, $limit, $additional_vars, MSG_ITEM_TITLE));
$template->set('page_order_start_time', page_order('members_area.php', 'a.start_time', $start, $limit, $additional_vars, GMSG_START_TIME));
$template->set('page_order_end_time', page_order('members_area.php', 'a.end_time', $start, $limit, $additional_vars, GMSG_END_TIME));
$template->set('page_order_nb_bids', page_order('members_area.php', 'a.nb_bids', $start, $limit, $additional_vars, MSG_NR_BIDS));
$template->set('page_order_start_bid', page_order('members_area.php', 'a.start_price', $start, $limit, $additional_vars, MSG_START_BID));
$template->set('page_order_max_bid', page_order('members_area.php', 'a.max_bid', $start, $limit, $additional_vars, MSG_MAX_BID));
}
if ($nb_items)
{
$force_index = $item->force_index($order_field, true);
$sql_select_items = $db->query("SELECT a.*, ao.offer_id, s.swap_id, u.username,
u.shop_account_id, u.shop_active, m.message_id FROM " . DB_PREFIX . "auctions a
" . $force_index . "
LEFT JOIN " . DB_PREFIX . "auction_offers ao ON ao.auction_id=a.auction_id
LEFT JOIN " . DB_PREFIX . "swaps s ON s.auction_id=a.auction_id
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=a.owner_id
LEFT JOIN " . DB_PREFIX . "messaging m ON m.auction_id=a.auction_id AND m.is_read=0 AND m.sender_id!=a.owner_id
WHERE a.owner_id='" . $session->value('user_id') . "' AND a.closed=0 AND
a.deleted=0 AND a.creation_in_progress=0 AND a.is_draft=0
" . $src_auctions_query . "
GROUP BY a.auction_id
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
while ($item_details = $db->fetch_array($sql_select_items))
{
$media_url = $db->get_sql_field("SELECT media_url FROM " . DB_PREFIX . "auction_media WHERE auction_id=" . $item_details['auction_id'] . " AND
media_type=1 AND upload_in_progress=0 ORDER BY media_id ASC", 'media_url');
$auction_image = (!empty($media_url)) ? $media_url : 'themes/' . $setts['default_theme'] . '/img/system/noimg.gif';
$background = ($counter++%2) ? 'c1' : 'c2';
$content_options = '
' . MSG_SELL_SIMILAR . ' ';
if ($item_details['payment_status']!='confirmed' && $item_details['active']==0)
{
$content_options .= '
' . MSG_PAY_SETUP_FEE . ' ';
}
else if ($item_details['nb_bids']==0 && $item_details['active']==1 && !$item_details['offer_id'] && !$item_details['swap_id'])
{
$content_options .= '
' . MSG_EDIT_AUCTION . ' ';
//if (!$item->under_time($item_details))
//{
$content_options .= '
' . MSG_DELETE . ' ';
//}
}
else if (($item_details['nb_bids']>0 || $item_details['offer_id'] || $item_details['swap_id']) && $item_details['active']==1)
{
$content_options .= '
' . MSG_EDIT_AUCTION . ' ';
$content_options .= '
' . MSG_DELETE . ' ';
//$content_options .= '
' . MSG_EDIT_DESCRIPTION . ' ';
}
//if ($item->can_close_manually($item_details, $session->value('user_id')))
//{
$content_options .= '
' . MSG_CLOSE_AUCTION . ' ';
//}
if ($item_details['approved']==0 && $item_details['payment_status'] == 'confirmed')
{
$content_options .= '
' . MSG_AUCTION_AWAITING_APPROVAL;
}
$auction_link = process_link('auction_details', array('auction_id' => $item_details['auction_id']));
$open_auctions_content .= '
'.
' '.
' # ' . $item_details['auction_id'] . ' '.
' ' . $item_details['name'] . ' ' .
$item->relisted_tick($item_details['is_relisted_item']) .
$item->new_message_tick($item_details['message_id']) . $item->listed_in($item_details) .
(($item_details['offer_id'] || $item_details['swap_id']) ? ' [ ' . MSG_VIEW_AUCTION_OFFERS . ' ]' : '') .
' '.
' ' . show_date($item_details['start_time'], false) . ' '.
' ' . show_date($item_details['end_time'], false) . ' '.
' ' . field_display($item_details['nb_bids'], '-', $item_details['nb_bids']) . ' '.
' ' . field_display($item_details['auto_relist_nb'], GMSG_NO, GMSG_YES . ' (' . $item_details['auto_relist_nb'] . ')'). ' '.
' ' . $fees->display_amount($item_details['start_price'], $item_details['currency']) . ' '.
' ' . $fees->display_amount($item_details['max_bid'], $item_details['currency']) . ' '.
' ' . $content_options . ' '.
' ';
}
}
else
{
$open_auctions_content = '
' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('open_auctions_content', $open_auctions_content);
if ($page != 'summary')
{
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
}
$members_area_page_content = $template->process('members_area_selling_open.tpl.php');
if ($page == 'summary')
{
$summary_page_content['selling_open'] = $members_area_page_content;
}
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'bids_offers')
{
$header_selling_page = headercat('
' . MSG_MM_SELLING . ' - ' . MSG_MM_OPEN_AUCTIONS . ' ');
$nb_items = $nb_items_bids;
$template->set('header_selling_page', $header_selling_page);
$template->set('nb_items', $nb_items);
$template->set('page_order_auction_id', page_order('members_area.php', 'a.auction_id', $start, $limit, $additional_vars, MSG_AUCTION_ID));
$template->set('page_order_itemname', page_order('members_area.php', 'a.name', $start, $limit, $additional_vars, MSG_ITEM_TITLE));
$template->set('page_order_start_time', page_order('members_area.php', 'a.start_time', $start, $limit, $additional_vars, GMSG_START_TIME));
$template->set('page_order_end_time', page_order('members_area.php', 'a.end_time', $start, $limit, $additional_vars, GMSG_END_TIME));
$template->set('page_order_nb_bids', page_order('members_area.php', 'a.nb_bids', $start, $limit, $additional_vars, MSG_NR_BIDS));
$template->set('page_order_max_bid', page_order('members_area.php', 'a.max_bid', $start, $limit, $additional_vars, MSG_MAX_BID));
if ($nb_items)
{
$force_index = $item->force_index($order_field, true);
$sql_select_items = $db->query("SELECT a.*, ao.offer_id, s.swap_id, u.username,
u.shop_account_id, u.shop_active FROM " . DB_PREFIX . "auctions a
" . $force_index . "
LEFT JOIN " . DB_PREFIX . "auction_offers ao ON ao.auction_id=a.auction_id
LEFT JOIN " . DB_PREFIX . "swaps s ON s.auction_id=a.auction_id
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=a.owner_id
WHERE a.owner_id='" . $session->value('user_id') . "' AND a.closed=0 AND
a.deleted=0 AND a.creation_in_progress=0 AND a.is_draft=0 AND end_time>0 AND
(nb_bids>0 OR nb_offers>0)
GROUP BY a.auction_id
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
while ($item_details = $db->fetch_array($sql_select_items))
{
$media_url = $db->get_sql_field("SELECT media_url FROM " . DB_PREFIX . "auction_media WHERE auction_id=" . $item_details['auction_id'] . " AND
media_type=1 AND upload_in_progress=0 ORDER BY media_id ASC", 'media_url');
$auction_image = (!empty($media_url)) ? $media_url : 'themes/' . $setts['default_theme'] . '/img/system/noimg.gif';
$background = ($counter++%2) ? 'c1' : 'c2';
$content_options = '
' . MSG_SELL_SIMILAR . ' ';
if ($item_details['payment_status']!='confirmed' && $item_details['active']==0)
{
$content_options .= '
' . MSG_PAY_SETUP_FEE . ' ';
}
else if ($item_details['nb_bids']==0 && $item_details['active']==1)
{
$content_options .= '
' . MSG_EDIT_AUCTION . ' ';
if (!$item->under_time($item_details))
{
$content_options .= '
' . MSG_DELETE . ' ';
}
}
else if ($item_details['nb_bids']>0 && $item_details['active']==1)
{
$content_options .= '
' . MSG_EDIT_DESCRIPTION . ' ';
}
if ($item_details['approved']==0 && $item_details['payment_status'] == 'confirmed')
{
$content_options .= '
' . MSG_AUCTION_AWAITING_APPROVAL;
}
$auction_link = process_link('auction_details', array('auction_id' => $item_details['auction_id']));
$open_auctions_content .= '
'.
' '.
' # ' . $item_details['auction_id'] . ' '.
' ' . $item_details['name'] . ' ' . $item->relisted_tick($item_details['is_relisted_item']) . $item->listed_in($item_details) .
(($item_details['offer_id'] || $item_details['swap_id']) ? ' [ ' . MSG_VIEW_AUCTION_OFFERS . ' ]' : '') .
' '.
' ' . show_date($item_details['start_time'], false) . ' '.
' ' . show_date($item_details['end_time'], false) . ' '.
' ' . field_display($item_details['nb_bids'], '-', $item_details['nb_bids']) . ' '.
' ' . field_display($item_details['auto_relist_nb'], GMSG_NO, GMSG_YES . ' (' . $item_details['auto_relist_nb'] . ')'). ' '.
' ' . $fees->display_amount($item_details['start_price'], $item_details['currency']) . ' '.
' ' . $fees->display_amount($item_details['max_bid'], $item_details['currency']) . ' '.
' ' . $content_options . ' '.
' ';
}
}
else
{
$open_auctions_content = '
' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('open_auctions_content', $open_auctions_content);
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_selling_open.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'scheduled')
{
$header_selling_page = headercat('
' . MSG_MM_SELLING . ' - ' . MSG_MM_SCHEDULED_AUCTIONS . ' ');
$nb_items = $nb_scheduled_items;
$template->set('header_selling_page', $header_selling_page);
$template->set('nb_items', $nb_items);
$template->set('page_order_auction_id', page_order('members_area.php', 'a.auction_id', $start, $limit, $additional_vars, MSG_AUCTION_ID));
$template->set('page_order_itemname', page_order('members_area.php', 'a.name', $start, $limit, $additional_vars, MSG_ITEM_TITLE));
$template->set('page_order_start_time', page_order('members_area.php', 'a.start_time', $start, $limit, $additional_vars, GMSG_START_TIME));
$template->set('page_order_end_time', page_order('members_area.php', 'a.end_time', $start, $limit, $additional_vars, GMSG_END_TIME));
$template->set('page_order_nb_bids', page_order('members_area.php', 'a.nb_bids', $start, $limit, $additional_vars, MSG_NR_BIDS));
$template->set('page_order_max_bid', page_order('members_area.php', 'a.max_bid', $start, $limit, $additional_vars, MSG_MAX_BID));
if ($nb_items)
{
$force_index = $item->force_index($order_field, true);
$sql_select_items = $db->query("SELECT a.*, u.username,
u.shop_account_id, u.shop_active FROM " . DB_PREFIX . "auctions a
" . $force_index . "
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=a.owner_id
WHERE a.owner_id='" . $session->value('user_id') . "' AND a.closed=1 AND a.deleted=0 AND
a.end_time>'" . CURRENT_TIME . "' AND a.creation_in_progress=0 AND a.is_draft=0
GROUP BY a.auction_id
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
while ($item_details = $db->fetch_array($sql_select_items))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$content_options = '
' . MSG_SELL_SIMILAR . ' ';
if ($item_details['payment_status']!='confirmed' && $item_details['active']==0)
{
$content_options .= '
' . MSG_PAY_SETUP_FEE . ' ';
}
else if ($item_details['nb_bids']==0 && $item_details['active']==1)
{
$content_options .= '
' . MSG_EDIT_AUCTION . ' ';
if (!$item->under_time($item_details))
{
$content_options .= '
' . MSG_DELETE . ' ';
}
}
else if ($item_details['nb_bids']>0 && $item_details['active']==1)
{
$content_options .= '
' . MSG_EDIT_DESCRIPTION . ' ';
}
if ($item_details['approved']==0 && $item_details['payment_status'] == 'confirmed')
{
$content_options .= '
' . MSG_AUCTION_AWAITING_APPROVAL;
}
$scheduled_auctions_content .= '
'.
' # ' . $item_details['auction_id'] . ' '.
' ' . $item_details['name'] . ' ' . $item->listed_in($item_details) . ' '.
' ' . show_date($item_details['start_time']) . ' '.
' ' . show_date($item_details['end_time']) . ' '.
' ' . field_display($item_details['auto_relist_nb'], GMSG_NO, GMSG_YES . ' (' . $item_details['auto_relist_nb'] . ')'). ' '.
' ' . $content_options . ' '.
' ';
}
}
else
{
$scheduled_auctions_content = '
' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('scheduled_auctions_content', $scheduled_auctions_content);
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_selling_scheduled.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'closed')
{
$header_selling_page = headercat('
' . MSG_MM_SELLING . ' - ' . MSG_MM_CLOSED_AUCTIONS . ' ');
$nb_items = $nb_closed_items;
$template->set('header_selling_page', $header_selling_page);
$template->set('nb_items', $nb_items);
$template->set('page_order_auction_id', page_order('members_area.php', 'a.auction_id', $start, $limit, $additional_vars, MSG_AUCTION_ID));
$template->set('page_order_itemname', page_order('members_area.php', 'a.name', $start, $limit, $additional_vars, MSG_ITEM_TITLE));
$template->set('page_order_start_time', page_order('members_area.php', 'a.start_time', $start, $limit, $additional_vars, GMSG_START_TIME));
$template->set('page_order_end_time', page_order('members_area.php', 'a.end_time', $start, $limit, $additional_vars, GMSG_END_TIME));
$template->set('page_order_nb_bids', page_order('members_area.php', 'a.nb_bids', $start, $limit, $additional_vars, MSG_NR_BIDS));
$template->set('page_order_max_bid', page_order('members_area.php', 'a.max_bid', $start, $limit, $additional_vars, MSG_MAX_BID));
if ($nb_items)
{
$force_index = $item->force_index($order_field, true);
$sql_select_items = $db->query("SELECT a.*, ao.offer_id, s.swap_id, w.winner_id, b.bid_id, u.shop_active FROM " . DB_PREFIX . "auctions a
" . $force_index . "
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=a.owner_id
LEFT JOIN " . DB_PREFIX . "auction_offers ao ON ao.auction_id=a.auction_id
LEFT JOIN " . DB_PREFIX . "swaps s ON s.auction_id=a.auction_id
LEFT JOIN " . DB_PREFIX . "winners w ON w.auction_id=a.auction_id
LEFT JOIN " . DB_PREFIX . "bids b ON b.auction_id=a.auction_id
WHERE a.owner_id='" . $session->value('user_id') . "' AND a.closed=1 AND a.deleted=0
AND a.end_time<='" . CURRENT_TIME . "'AND a.creation_in_progress=0 AND a.is_draft=0
GROUP BY a.auction_id
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
while ($item_details = $db->fetch_array($sql_select_items))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$closed_auctions_content .= '
'.
' # ' . $item_details['auction_id'] . ' '.
' ' . $item_details['name'] . ' ' .
(($item_details['winner_id']) ? ' ' : '') . ' ' . $item->listed_in($item_details) .
((!$item_details['winner_id'] && (($item_details['bid_id'] && $item_details['max_bid'] < $item_details['reserve_price']) || $item_details['offer_id'] || $item_details['swap_id'])) ? ' [ ' . MSG_SELECT_WINNER_MANUALLY . ' ]' : '') .
' '.
' ' . show_date($item_details['start_time'], false) . ' '.
' ' . show_date($item_details['end_time'], false) . ' '.
' ' . field_display($item_details['nb_bids'], '-', $item_details['nb_bids']) . ' '.
' ' . $fees->display_amount($item_details['max_bid'], $item_details['currency']) . ' '.
' '.
' ' . $item->durations_drop_down('duration[' . $item_details['auction_id'] . ']', $item_details['duration']) . ' '.
' '.
' ';
}
}
else
{
$closed_auctions_content = '
' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('closed_auctions_content', $closed_auctions_content);
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_selling_closed.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'drafts')
{
$header_selling_page = headercat('
' . MSG_MM_SELLING . ' - ' . MSG_MM_DRAFTS . ' ');
$nb_items = $nb_drafts;
$template->set('header_selling_page', $header_selling_page);
$template->set('nb_items', $nb_items);
$template->set('page_order_auction_id', page_order('members_area.php', 'a.auction_id', $start, $limit, $additional_vars, MSG_AUCTION_ID));
$template->set('page_order_itemname', page_order('members_area.php', 'a.name', $start, $limit, $additional_vars, MSG_ITEM_TITLE));
$template->set('page_order_start_bid', page_order('members_area.php', 'a.start_price', $start, $limit, $additional_vars, MSG_START_BID));
if ($nb_items)
{
$sql_select_items = $db->query("SELECT a.*, u.username,
u.shop_account_id, u.shop_active FROM " . DB_PREFIX . "auctions a
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=a.owner_id
WHERE a.owner_id='" . $session->value('user_id') . "' AND a.is_draft=1 AND a.deleted=0
GROUP BY a.auction_id
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);## PHP Pro Bid v6.00 uses temporary/filesort
while ($item_details = $db->fetch_array($sql_select_items))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$content_options = '
' . GMSG_LIST_NOW . ' ';
$content_options .= '
' . MSG_EDIT_DRAFT . ' ';
$content_options .= '
' . MSG_DELETE . ' ';
$drafts_content .= '
'.
' # ' . $item_details['auction_id'] . ' '.
' ' . $item_details['name'] . ' '.
' ' . $fees->display_amount($item_details['start_price'], $item_details['currency']) . ' '.
' ' . $content_options . ' '.
' ';
}
}
else
{
$drafts_content = '
' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('drafts_content', $drafts_content);
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_selling_drafts.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'sold')
{
$show_link = '&show=' . $_REQUEST['show'];
(string) $search_filter = null;
if ($_REQUEST['show'] == 'dd')
{
$search_filter .= " AND w.is_dd=1";
$nb_sold_items = $db->count_rows('winners w', "WHERE w.seller_id='" . $session->value('user_id') . "' AND
w.s_deleted=0" . $search_filter . $src_transactions_query);
}
else if ($_REQUEST['show'] == 'no_dd')
{
$search_filter .= " AND w.is_dd=0";
$nb_sold_items = $db->count_rows('winners w', "WHERE w.seller_id='" . $session->value('user_id') . "' AND
w.s_deleted=0" . $search_filter . $src_transactions_query);
}
(string) $filter_items_content = null;
$filter_items_content .= display_link('members_area.php?page=selling§ion=sold', GMSG_ALL, ((!$_REQUEST['show']) ? false : true)) . ' | ';
$filter_items_content .= display_link('members_area.php?page=selling§ion=sold&show=dd', MSG_DIGITAL_MEDIA_ATTACHED, (($_REQUEST['show'] == 'dd') ? false : true)) . ' | ';
$filter_items_content .= display_link('members_area.php?page=selling§ion=sold&show=no_dd', MSG_NO_DIGITAL_MEDIA, (($_REQUEST['show'] == 'no_dd') ? false : true));
$template->set('filter_items_content', $filter_items_content);
if (isset($_REQUEST['form_update_winner_status']))
{
$dd_active = (intval($_REQUEST['flag_paid']) == 1) ? 1 : 0;
$current_time = ($dd_active) ? CURRENT_TIME : 0;
$update_force_payment = (intval($_REQUEST['flag_paid']) == 1) ? ", temp_purchase=0" : '';
$db->query("UPDATE " . DB_PREFIX . "winners SET flag_paid='" . $_REQUEST['flag_paid'] . "',
flag_status='" . $_REQUEST['flag_status'] . "',dd_active=IF(is_dd=1, " . $dd_active . ", 0),
dd_active_date=IF(is_dd=1, " . $current_time . ", 0)
" . $update_force_payment . " WHERE winner_id='" . intval($_REQUEST['winner_id']) . "' AND
seller_id='" . $session->value('user_id') . "'");
}
$header_selling_page = headercat('
' . MSG_MM_SELLING . ' - ' . MSG_MM_SOLD_ITEMS . ' ');
$nb_items = $nb_sold_items;
$template->set('header_selling_page', $header_selling_page);
$template->set('nb_items', $nb_items);
$template->set('page_order_auction_id', page_order('members_area.php', 'w.auction_id', $start, $limit, $additional_vars . $show_link, MSG_AUCTION_ID));
$template->set('page_order_itemname', page_order('members_area.php', 'a.name', $start, $limit, $additional_vars . $show_link, MSG_ITEM_TITLE));
$template->set('page_order_bid_amount', page_order('members_area.php', 'w.bid_amount', $start, $limit, $additional_vars . $show_link, MSG_WINNING_BID));
$template->set('page_order_quantity', page_order('members_area.php', 'w.quantity_offered', $start, $limit, $additional_vars . $show_link, MSG_QUANTITY_OFFERED));
$template->set('page_order_purchase_date', page_order('members_area.php', 'w.purchase_date', $start, $limit, $additional_vars . $show_link, MSG_PURCHASE_DATE));
if ($nb_items)
{
$sql_select_sold = $db->query("SELECT w.*, a.name AS auction_name, a.currency, a.category_id, a.auction_type,
a.bank_details, u.username, u.name, r.submitted, r.reputation_id, m.message_id,
i.refund_request, i.user_id AS payer_id
FROM " . DB_PREFIX . "winners w
LEFT JOIN " . DB_PREFIX . "auctions a ON a.auction_id=w.auction_id
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=w.buyer_id
LEFT JOIN " . DB_PREFIX . "reputation r ON r.from_id=w.seller_id AND r.winner_id=w.winner_id
LEFT JOIN " . DB_PREFIX . "messaging m ON m.auction_id=w.auction_id AND m.is_read=0 AND m.sender_id!=w.seller_id
LEFT JOIN " . DB_PREFIX . "invoices i ON i.invoice_id=w.refund_invoice_id
WHERE w.seller_id='" . $session->value('user_id') . "' AND w.s_deleted=0
" . $search_filter . $src_transactions_query . "
GROUP BY w.winner_id
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
$sale_fee = new fees();
$sale_fee->setts = &$setts;
while ($item_details = $db->fetch_array($sql_select_sold))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$sale_fee->set_fees($item_details['seller_id'], $item_details['category_id']);
$item_paid = ($item_details['active'] == 1 && $item_details['payment_status'] == 'confirmed') ? 1 : 0;
if ($item_paid)
{
$content_options = '•
' . MSG_MESSAGE_BOARD . ' ';
if (!$item_details['submitted'])
{
//$content_options .= '•
' . MSG_LEAVE_COMMENTS . ' ';
}
$content_options .= '•
' . ((empty($item_details['bank_details'])) ? MSG_SEND_BANK_DETAILS : MSG_VIEW_BANK_DETAILS) . ' ';
if (!$item_details['invoice_sent'])
{
$content_options .= '•
' . MSG_DELETE . ' ';
}
}
else
{
if (eregi('s', $sale_fee->fee['endauction_fee_applies']))
{
$content_options = '•
' . MSG_PAY_ENDAUCTION_FEE . ' ';
}
else
{
$content_options = '• ' . MSG_ENDAUCTION_FEE_NOT_PAID;
}
}
$sold_auctions_content .= '
'.
' # ' . $item_details['auction_id'] . ' - '.
' ' . field_display($item_details['auction_name'], MSG_AUCTION_DELETED) . ' '.
$item->new_message_tick($item_details['message_id']) . ' '.
' ' . $fees->display_amount($item_details['bid_amount'], $item_details['currency']) . ' '.
' ' . MSG_REQUESTED . ': ' . $item_details['quantity_requested'] . ' '.
' ' . MSG_OFFERED . ': ' . $item_details['quantity_offered'] . ' '.
' ';
if ($item_paid)
{
$sold_auctions_content .= ' '.
' '.
' ' . MSG_USERNAME . ' '.
' ' . field_display($item_details['username'], GMSG_NA) . ' '.
' '.
' '.
' ' . MSG_FULL_NAME . ' '.
' ' . field_display($item_details['name'], GMSG_NA) . ' '.
' '.
'
';
}
$sold_auctions_content .= ' '.
' ';
if ($item_paid)
{
$sold_auctions_content .= show_date($item_details['purchase_date']) . ' '.
'';
}
$sold_auctions_content .= ' '.
' ' . $content_options . ' '.
' ';
if ($item_paid && !empty($item_details['auction_name']))
{
if ($item_details['is_dd'])
{
$link_active = MSG_LINK_ACTIVE . ' · [
' . MSG_INACTIVATE . ' ]';
$link_inactive = MSG_LINK_INACTIVE . ' · [
' . MSG_ACTIVATE . ' ]';
$dd_expires = dd_expires($item_details['dd_active_date']);
$sold_auctions_content .= '
'.
' ' . MSG_DIGITAL_MEDIA_ATTACHED . ' '.
' ' . MSG_DOWNLOADED . ' ' . $item_details['dd_nb_downloads'] . ' ' . MSG_TIMES . ' '.
' ' . (($item_details['dd_active'] && $dd_expires['result']>0) ? $link_active : $link_inactive) . ' '.
' ' . MSG_LINK_EXPIRES . ': ' . (($item_details['dd_active']) ? $dd_expires['display'] : GMSG_NA) . ' '.
' ';
}
$sold_auctions_content .= '
';
if ($item_details['invoice_sent'])
{
$sold_auctions_content .= '• ' . MSG_INVOICE_SENT . ' [ ' . MSG_ID . ': ' . $item_details['invoice_id'] . ' ] ' . MSG_VIEW_PRODUCT_INVOICE . ' · '.
' ' . MSG_EDIT_PRODUCT_INVOICE . ' · ' .
'' . MSG_RESEND_PRODUCT_INVOICE . ' ';
}
else
{
$sold_auctions_content .= '• ' . MSG_SEND_PRODUCT_INVOICE . ' ';
}
if ($item->apply_second_chance($item_details, $session->value('user_id')))
{
$sold_auctions_content .= ' · ' . MSG_SECOND_CHANCE_PURCHASING . ' ';
}
if ($item_details['payer_id'] == $session->value('user_id') && $item->request_refund($item_details['refund_invoice_id'], $item_details['purchase_date'], $item_details['flag_paid'], $item_details['refund_request']))
{
$sold_auctions_content .= ' · ' . MSG_REQUEST_EOA_REFUND . ' ';
}
$sold_auctions_content .= ' ';
}
if ($item_details['temp_purchase'])
{
$sold_auctions_content .= '
'.
' ' . MSG_BUYOUT_FORCE_PAYMENT_ALERT . ' '.
' ';
}
//$sold_auctions_content .= '
';
}
}
else
{
$sold_auctions_content = '
' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('sold_auctions_content', $sold_auctions_content);
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link . $show_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_selling_sold.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'invoices_sent')
{
$nb_items = $db->get_sql_number("SELECT winner_id FROM " . DB_PREFIX . "winners WHERE
invoice_sent=1 AND seller_id='" . $session->value('user_id') . "' GROUP BY invoice_id");
$template->set('nb_items', $nb_items);
(string) $invoices_sent_content = null;
if ($nb_items)
{
$sql_select_invoices = $db->query("SELECT w.*, u.username FROM " . DB_PREFIX . "winners w
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=w.buyer_id
WHERE w.seller_id='" . $session->value('user_id') . "' AND w.s_deleted=0 AND w.invoice_sent=1
GROUP BY w.invoice_id
ORDER BY w.invoice_id DESC LIMIT " . $start . ", 5");
while ($invoice_details = $db->fetch_array($sql_select_invoices))
{
$invoices_sent_content .= '
'.
' [ ' . MSG_INVOICE_ID . ': ' . $invoice_details['invoice_id'] . ' ] [ ' . MSG_BUYER_USERNAME . ': ' . $invoice_details['username'] . ' ]'.
' [ ' . MSG_DELETE . ' ]'.
' ';
$sql_select_products = $db->query("SELECT w.*, a.name,
a.direct_payment, a.currency FROM " . DB_PREFIX . "winners w
LEFT JOIN " . DB_PREFIX . "auctions a ON a.auction_id=w.auction_id WHERE
w.invoice_id='" . $invoice_details['invoice_id'] . "'");
$invoices_sent_content .= ' '.
'
'.
' '.
' '.
' '.
' ';
$product_postage = null;
$product_insurance = null;
while ($item_details = $db->fetch_array($sql_select_products))
{
$background = 'c1';
$currency = $item_details['currency'];
$product_postage = ($item_details['postage_included']) ? (($item_details['pc_postage_type'] == 'item') ? ($item_details['postage_amount'] + $product_postage) : $item_details['postage_amount']) : 0;
$product_insurance += ($item_details['insurance_included']) ? $item_details['insurance_amount'] : 0;
$auction_link = process_link('auction_details', array('name' => $item_details['name'], 'auction_id' => $item_details['auction_id']));
$invoices_sent_content .= '
'.
' [ ' . MSG_ID . ': ' . $item_details['auction_id'] . ' ] ' . $item_details['name'] . ' '.
' ' . $item_details['quantity_offered'] . ' '.
' ' . $fees->display_amount($item_details['bid_amount'], $item_details['currency']) . ' '.
' ';
}
// new postage and insurance tab
$invoices_sent_content .= '
'.
' '.
' '.
'
'.
' '.
' ' . MSG_POSTAGE . ': '.
' ' . $fees->display_amount($product_postage, $currency) . ' '.
' '.
'
'.
' '.
' ' . MSG_INSURANCE . ': '.
' ' . $fees->display_amount($product_insurance, $currency) . ' '.
' '.
'
'.
' '.
' ';
(string) $direct_payment_link = null;
$invoices_sent_content .= '
'.
' [ ' . MSG_VIEW_PRODUCT_INVOICE . ' ] · ' .
' [ ' . MSG_EDIT_PRODUCT_INVOICE . ' ] · ' .
' [ ' . MSG_RESEND_PRODUCT_INVOICE . ' ] ' . $direct_payment_link . ' '.
' '.
'
'.
' '.
' ';
}
}
else
{
$invoices_sent_content = '
' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('invoices_sent_content', $invoices_sent_content);
$pagination = paginate($start, 5, $nb_items, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_selling_invoices_sent.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'fees_calculator')
{
$item_details = $_POST;
$item_details['currency'] = ($item_details['currency']) ? $item_details['currency'] : $setts['currency'];
$item_details['ad_image'] = array();
$item_details['ad_image'][0] = ($item_details['is_image']) ? 'image_placeholder' : '';
$item_details['ad_video'] = array();
$item_details['ad_video'][0] = ($item_details['is_video']) ? 'video_placeholder' : '';
if (isset($_POST['form_save_settings']))
{
$setup_fee = new fees();
$setup_fee->setts = &$setts;
if ($item_details['start_price'] > 0)
{
$user_details = $db->get_sql_row("SELECT user_id, username, shop_account_id, shop_categories,
shop_active, preferred_seller, reg_date, country, state, zip_code, balance,
default_name, default_description, default_duration, default_hidden_bidding,
default_enable_swap, default_shipping_method, default_shipping_int, default_postage_amount,
default_insurance_amount, default_type_service, default_shipping_details, default_payment_methods FROM
" . DB_PREFIX . "users WHERE user_id=" . $session->value('user_id'));
$auction_fees = $setup_fee->auction_setup_fees($item_details, $user_details);
$fees_calculator_result = $auction_fees['display'];
}
else
{
$fees_calculator_result = '
' . MSG_START_PRICE_ERROR . ' ';
}
$template->set('fees_calculator_result', $fees_calculator_result);
}
$currency_drop_down = $item->currency_drop_down('currency', $item_details['currency'], 'fees_calculator_form');
$template->set('currency_drop_down', $currency_drop_down);
$categories_list_menu = categories_list ($item_details['category_id']);
$template->set('categories_list_menu', $categories_list_menu);
$template->set('item_details', $item_details);
$members_area_page_content = $template->process('members_area_selling_fees_calculator.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'prefilled_fields')
{
if (isset($_POST['form_save_settings']))
{
$template->set('msg_changes_saved', $msg_changes_saved);
$item->update_prefilled($_POST, $session->value('user_id'));
}
$header_selling_page = headercat('
' . MSG_MM_SELLING . ' - ' . MSG_MM_PREFILLED_FIELDS . ' ');
$template->set('header_selling_page', $header_selling_page);
$prefilled_fields = $db->get_sql_row("SELECT * FROM " . DB_PREFIX . "users WHERE
user_id='" . $session->value('user_id') . "'");
$template->set('prefilled_fields', $prefilled_fields);
$item_description_editor = "";
$template->set('item_description_editor', $item_description_editor);
$default_currency = (!empty($prefilled_fields['default_currency'])) ? $prefilled_fields['default_currency'] : $setts['currency'];
$template->set('currency_drop_down', $item->currency_drop_down('currency', $default_currency));
$template->set('duration_drop_down', $item->durations_drop_down('duration', $prefilled_fields['default_duration']));
$template->set('shipping_methods_drop_down', $item->shipping_methods_drop_down('default_type_service', $prefilled_fields['default_type_service']));
$direct_payments = $item->select_direct_payment($prefilled_fields['default_direct_payment'], $session->value('user_id'));
$direct_payment_table = $template->generate_table($direct_payments, 4, 1, 1, '75%');
$template->set('direct_payment_table', $direct_payment_table);
$offline_payments = $item->select_offline_payment($prefilled_fields['default_payment_methods']);
$offline_payment_table = $template->generate_table($offline_payments, 4, 1, 1, '75%');
$template->set('offline_payment_table', $offline_payment_table);
$members_area_page_content = $template->process('members_area_selling_prefilled.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'block_users')
{
$template->set('do', $_REQUEST['do']);
if ($_REQUEST['do'] == 'add_user')
{
$form_submitted = false;
if (isset($_POST['form_add_blocked_user']))
{
$post_details = $db->rem_special_chars_array($_POST);
$is_user = $db->count_rows('users', "WHERE username='" . $post_details['username'] . "'");
if ($is_user)
{
$form_submitted = true;
$blocked_user_id = $db->get_sql_field("SELECT user_id FROM " . DB_PREFIX . "users WHERE
username='" . $post_details['username'] . "'", 'user_id');
$db->query("INSERT INTO " . DB_PREFIX . "blocked_users
(user_id, owner_id, reg_date, block_reason, show_reason, block_bid, block_message, block_reputation) VALUES
('" . $blocked_user_id . "', '" . $session->value('user_id') . "', '" . CURRENT_TIME . "',
'" . $post_details['block_reason'] . "', '" . $post_details['show_reason'] . "',
'" . intval($post_details['block_bid']) . "', '" . intval($post_details['block_message']) . "',
'" . intval($post_details['block_reputation']) . "')");
$template->set('msg_changes_saved', '
' . MSG_BLOCKED_USER_ADD_SUCCESS . '
');
}
else
{
$display_formcheck_errors = '
'.
' ' . MSG_ERROR_USER_DOESNT_EXIST . ' '.
' ';
$template->set('display_formcheck_errors', $display_formcheck_errors);
}
}
if (!$form_submitted)
{
$template->set('post_details', $post_details);
$template->set('block_users_header_message', MSG_ADD_BLOCKED_USER);
$block_add_user_content = $template->process('members_area_selling_block_users_add_user.tpl.php');
$template->set('block_add_user_content', $block_add_user_content);
}
}
else if ($_REQUEST['do'] == 'edit_user')
{
$form_submitted = false;
if (isset($_POST['form_add_blocked_user']))
{
$post_details = $db->rem_special_chars_array($_POST);
$form_submitted = true;
$db->query("UPDATE " . DB_PREFIX . "blocked_users SET
block_reason='" . $post_details['block_reason'] . "', show_reason='" . $post_details['show_reason'] . "',
block_bid='" . intval($post_details['block_bid']) . "', block_message='" . intval($post_details['block_message']) . "',
block_reputation='" . intval($post_details['block_reputation']) . "' WHERE
block_id='" . intval($_REQUEST['block_id']) . "' AND owner_id='" . $session->value('user_id') . "'");
$template->set('msg_changes_saved', '
' . MSG_BLOCKED_USER_EDIT_SUCCESS . '
');
}
else
{
$post_details = $db->get_sql_row("SELECT b.*, u.username FROM " . DB_PREFIX . "blocked_users b
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=b.user_id WHERE
b.block_id='" . intval($_REQUEST['block_id']) . "' AND b.owner_id='" . $session->value('user_id') . "'");
}
if (!$form_submitted)
{
$template->set('post_details', $post_details);
$template->set('block_users_header_message', MSG_EDIT_BLOCKED_USER);
$block_add_user_content = $template->process('members_area_selling_block_users_add_user.tpl.php');
$template->set('block_add_user_content', $block_add_user_content);
}
}
else if ($_REQUEST['do'] == 'delete_user')
{
$db->query("DELETE FROM " . DB_PREFIX . "blocked_users WHERE block_id='" . intval($_REQUEST['block_id']) . "' AND
owner_id='" . $session->value('user_id') . "'");
$template->set('msg_changes_saved', '
' . MSG_BLOCKED_USER_DELETE_SUCCESS . '
');
}
$nb_items = $db->count_rows('blocked_users', "WHERE owner_id='" . $session->value('user_id') . "'");
$template->set('nb_items', $nb_items);
if ($nb_items)
{
$sql_select_blocked = $db->query("SELECT b.*, u.username FROM " . DB_PREFIX . "blocked_users b
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=b.user_id
WHERE b.owner_id='" . $session->value('user_id') . "'
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
while ($block_details = $db->fetch_array($sql_select_blocked))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$content_options = '[
' . GMSG_EDIT . ' ] ';
$content_options .= '[
' . MSG_DELETE . ' ]';
$blocked_users_content .= '
'.
' ' . $block_details['username'] . ' '.
' ' . $block_details['block_reason'] . ' '.
' ' . field_display($block_details['show_reason'], '' . GMSG_NO . ' ', '' . GMSG_YES . ' ') . ' '.
' ' . $db->implode_array(block_type($block_details), '; ', true, GMSG_NA) . ' '.
' ' . $content_options . ' '.
' ';
}
}
else
{
$blocked_users_content = '
' . MSG_NO_BLOCKED_USERS . ' ';
}
$template->set('blocked_users_content', $blocked_users_content);
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_selling_block_users.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'postage_setup')
{
if ($_REQUEST['option'] == 'delete_location')
{
$db->query("DELETE FROM " . DB_PREFIX . "shipping_locations WHERE
id='" . intval($_REQUEST['id']) . "' AND user_id='" . $session->value('user_id') . "'");
$template->set('msg_changes_saved', $msg_changes_saved);
}
if (isset($_POST['form_postage_save']))
{
$user = new user();
$user->setts = &$setts;
$template->set('msg_changes_saved', $msg_changes_saved);
$user->postage_calc_save($_POST, $session->value('user_id'));
}
else
{
$postage_details = $db->get_sql_row("SELECT * FROM
" . DB_PREFIX . "users WHERE user_id=" . $session->value('user_id'));
}
if ($_POST['box_submit'] == 1)
{
$postage_details = $_POST;
}
$postage_details['pc_postage_type'] = (in_array($postage_details['pc_postage_type'], array('item', 'weight', 'amount', 'flat'))) ? $postage_details['pc_postage_type'] : 'item';
$template->set('postage_details', $db->rem_special_chars_array($postage_details));
(string) $postage_tiers_table = null;
$postage_tiers_table = '
';
$template->set('postage_tiers_table', $postage_tiers_table);
if ($postage_details['pc_shipping_locations'] == 'local')
{
$sql_select_shipping_locations = $db->query("SELECT * FROM " . DB_PREFIX . "shipping_locations WHERE
user_id='" . $session->value('user_id') . "' ORDER BY amount ASC");
$shipping_locations_table = null;
$tax = new tax();
while ($location_details = $db->fetch_array($sql_select_shipping_locations))
{
$shipping_locations_table .= '
'.
' ' . title_resize($tax->display_countries($location_details['locations_id']), 200, true) . ' '.
' ' . (($location_details['amount_type'] == 'flat') ? $fees->display_amount($location_details['amount']) : $location_details['amount'] . '%') . ' '.
//' '.
' [ ' . GMSG_EDIT . ' ] '.
' [ ' . GMSG_DELETE . ' ] '.
' ';
}
if (empty($shipping_locations_table))
{
$shipping_locations_table = '
' . MSG_NO_SHIPPING_LOCATIONS_SET . ' ';
}
$template->set('shipping_locations_table', $shipping_locations_table);
}
$members_area_page_content = $template->process('members_area_selling_postage_setup.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
} /* END -> SELLING PAGES */
if ($page == 'reputation') /* BEGIN -> REPUTATION PAGES */
{
$reputation = new reputation();
$reputation->setts = &$setts;
if ($section == 'post' || isset($_POST['form_reputation_post']))
{
$custom_fld = new custom_field();
$reputation_ids = format_response_integer($_POST['reputation_id'], $_REQUEST['reputation_ids']);
$template->set('reputation_ids', $reputation_ids);
$sql_select_reputation = $db->query("SELECT r.*, u.username, IF(a.auction_id,a.name,rp.name) AS auction_name FROM " . DB_PREFIX . "reputation r
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=r.user_id
LEFT JOIN " . DB_PREFIX . "auctions a ON a.auction_id=r.auction_id
LEFT JOIN " . DB_PREFIX . "reverse_auctions rp ON rp.reverse_id=r.reverse_id
WHERE r.from_id='" . $session->value('user_id') . "' AND r.submitted=0 AND r.reputation_id IN (" . $reputation_ids . ")");
$nb_reputation_rows = $db->num_rows($sql_select_reputation);
if ($nb_reputation_rows > 0)
{
if ($nb_reputation_rows == 1)
{
$reputation_details = $db->fetch_array($sql_select_reputation);
}
else
{
$reputation_details['username'] = MSG_MULTIPLE_USERS;
$reputation_details['auction_name'] = MSG_MULTIPLE_AUCTIONS;
}
$template->set('reputation_details', $reputation_details);
$form_submitted = false;
$post_details = $_POST;
$custom_fld->save_vars($_POST);
$template->set('post_details', $post_details);
if (isset($_POST['form_leave_comments'])) /* formchecker code snippet */
{
define ('FRMCHK_ITEM', 1);
(int) $item_post = 1;
$frmchk_details = $post_details;
include('includes/procedure_frmchk_reputation.php');
if ($fv->is_error())
{
$template->set('display_formcheck_errors', '
' . $fv->display_errors() . '');
}
else
{
$form_submitted = true;
$reputation->save($post_details, $session->value('user_id'));
$template->set('message_content', '
' . MSG_REPUTATION_SAVED . '
');
$members_area_page_content = $template->process('single_message.tpl.php');
}
}
if (!$form_submitted)
{
$custom_fld->new_table = false;
$custom_fld->field_colspan = 1;
$page_handle = $reputation->cf_page_handle($reputation_details);
$custom_sections_table = $custom_fld->display_sections($post_details, $page_handle, false, $reputation_details['reputation_id']);
$template->set('custom_sections_table', $custom_sections_table);
$members_area_page_content = $template->process('members_area_reputation_post.tpl.php');
}
}
else
{
$template->set('message_content', '
' . MSG_POST_REP_FAILURE . '
');
$members_area_page_content = $template->process('single_message.tpl.php');
}
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'received')
{
$nb_items = $db->count_rows('reputation', "WHERE user_id='" . $session->value('user_id') . "' AND
submitted=1");
$template->set('nb_items', $nb_items);
if ($nb_items)
{
$sql_select_reputation = $db->query("SELECT r.*, u.username FROM " . DB_PREFIX . "reputation r
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=r.from_id
WHERE r.user_id='" . $session->value('user_id') . "' AND r.submitted=1
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
while ($reputation_details = $db->fetch_array($sql_select_reputation))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$reputation_received_content .= '
'.
' ' . $reputation_details['username'] . ' '.
' ' . $reputation->rep_rate($reputation_details['reputation_rate']) . ' '.
' ' . show_date($reputation_details['reg_date'], false) . ' '.
' ' . $reputation_details['reputation_content'] . ' '.
' [ ' . GMSG_VIEW . ' ] '.
' ' . $reputation->reputation_type($reputation_details) . ' '.
' ';
}
}
else
{
$reputation_received_content = '
' . GMSG_NO_COMMENTS_MSG . ' ';
}
$template->set('reputation_received_content', $reputation_received_content);
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_reputation_received.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'sent')
{
$sql_nb_items = $db->query("SELECT r.reputation_id FROM " . DB_PREFIX . "reputation r
LEFT JOIN " . DB_PREFIX . "auctions a ON a.auction_id=r.auction_id
LEFT JOIN " . DB_PREFIX . "reverse_auctions rp ON rp.reverse_id=r.reverse_id
WHERE r.from_id='" . $session->value('user_id') . "' AND r.submitted=0 AND (a.auction_id!=0 OR rp.reverse_id!=0)");
$nb_items = $db->num_rows($sql_nb_items);
$template->set('nb_items', intval($nb_items));
$nb_auction_items = 0;
if ($nb_items)
{
$sql_select_reputation = $db->query("SELECT r.*, u.username, IF(a.auction_id, a.name, rp.name) AS auction_name FROM " . DB_PREFIX . "reputation r
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=r.user_id
LEFT JOIN " . DB_PREFIX . "auctions a ON a.auction_id=r.auction_id
LEFT JOIN " . DB_PREFIX . "reverse_auctions rp ON rp.reverse_id=r.reverse_id
WHERE r.from_id='" . $session->value('user_id') . "' AND r.submitted=0 AND (a.auction_id!=0 OR rp.reverse_id!=0)
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
while ($reputation_details = $db->fetch_array($sql_select_reputation))
{
if ($reputation_details['auction_id'])
{
$nb_auction_items++;
}
$background = ($counter++%2) ? 'c1' : 'c2';
if ($reputation_details['reverse_id'])
{
$auction_link = process_link('reverse_details', array('reverse_id' => $reputation_details['reverse_id']));
$auction_id = $reputation_details['reverse_id'];
//$rep_link = '[
' . MSG_LEAVE_COMMENTS . ' ]';
}
else
{
$auction_link = process_link('auction_details', array('auction_id' => $reputation_details['auction_id']));
$auction_id = $reputation_details['auction_id'];
$rep_link = '
';
}
$reputation_sent_content .= '
'.
' ' . $reputation_details['username'] . ' '.
' ' . $auction_id . ' '.
' ' . $reputation_details['auction_name'] . ' '.
' ' . $reputation->reputation_type($reputation_details) . ' '.
' ' . $rep_link . ' '.
' ';
}
}
else
{
$reputation_sent_content = '
' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('nb_auction_items', $nb_auction_items);
$template->set('reputation_sent_content', $reputation_sent_content);
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_reputation_sent.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
} /* END -> REPUTATION PAGES */
if ($page == 'bulk') /* BEGIN -> BULK PAGE(S) */
{
if ($section == 'details')
{
$members_area_page_content = $template->process('members_area_bulk_details.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
} /* END -> BULK PAGE(S) */
if ($page == 'about_me') /* BEGIN -> ABOUT ME PAGE(S) */
{
if ($section == 'view')
{
$shop = new shop();
if (isset($_POST['form_aboutme_save']))
{
$shop->save_aboutme($_POST, $session->value('user_id'));
$template->set('msg_changes_saved', $msg_changes_saved);
}
$user_details = $db->get_sql_row("SELECT user_id, username, email,
enable_aboutme_page, aboutme_page_content, shop_account_id, shop_active FROM
" . DB_PREFIX . "users WHERE user_id=" . $session->value('user_id'));
$template->set('user_details', $user_details);
$shop_status = $shop->shop_status($user_details);
$template->set('shop_status', $shop_status);
$members_area_page_content = $template->process('members_area_aboutme_view.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'profile' && $setts['enable_profile_page'])
{
if (isset($_POST['form_profile_save']))
{
$post_details = $db->rem_special_chars_array($_POST);
$db->query("UPDATE " . DB_PREFIX . "users SET
enable_profile_page='" . $post_details['enable_profile_page'] . "',
profile_www='" . $post_details['profile_www'] . "', profile_msn='" . $post_details['profile_msn'] . "',
profile_icq='" . $post_details['profile_icq'] . "', profile_aim='" . $post_details['profile_aim'] . "',
profile_yim='" . $post_details['profile_yim'] . "', profile_skype='" . $post_details['profile_skype'] . "',
profile_show_birthdate='" . $post_details['profile_show_birthdate'] . "' WHERE
user_id='" . $session->value('user_id') . "'");
$template->set('msg_changes_saved', $msg_changes_saved);
}
$user_details = $db->get_sql_row("SELECT * FROM
" . DB_PREFIX . "users WHERE user_id=" . $session->value('user_id'));
$template->set('user_details', $user_details);
$members_area_page_content = $template->process('members_area_aboutme_profile.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
} /* END -> ABOUT ME PAGE(S) */
if ($page == 'store') /* BEGIN -> STORE SETUP PAGES */
{
$shop = new shop();
$shop->setts = &$setts;
$shop->user_id = $session->value('user_id');
if ($section == 'subscription')
{
$show_page = true;
if (isset($_POST['form_shop_save']))
{
define ('FRMCHK_STORE_SETUP', 1);
$frmchk_details = $db->get_sql_row("SELECT * FROM
" . DB_PREFIX . "users WHERE user_id=" . $session->value('user_id'));
$frmchk_store_settings = true;
include ('includes/procedure_frmchk_store_setup.php'); /* Formchecker for store setup pages */
if ($fv->is_error())
{
$template->set('display_formcheck_errors', $fv->display_errors());
}
else
{
$subscription_output = $shop->shop_save_subscription($_POST, $session->value('user_id'));
$template->set('msg_changes_saved', $subscription_output['display']);
$show_page = $subscription_output['show_page'];
}
}
if ($show_page)
{
$user_details = $db->get_sql_row("SELECT * FROM
" . DB_PREFIX . "users WHERE user_id=" . $session->value('user_id'));
$template->set('user_details', $user_details);
$shop_status = $shop->shop_status($user_details, true);
$template->set('shop_status', $shop_status);
$template->set('list_store_subscriptions', $shop->store_subscriptions_drop_down('shop_account_id', $user_details['shop_account_id']));
$members_area_page_content = $template->process('members_area_store_subscription.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
}
if ($section == 'setup')
{
if (isset($_POST['form_shop_save']))
{
define ('FRMCHK_STORE_SETUP', 1);
$frmchk_details = $_POST;
$frmchk_store_settings = true;
include ('includes/procedure_frmchk_store_setup.php'); /* Formchecker for store setup pages */
if ($fv->is_error())
{
$template->set('display_formcheck_errors', $fv->display_errors());
}
else
{
$template->set('msg_changes_saved', $msg_changes_saved);
$shop->shop_save_settings($_POST, $session->value('user_id'));
}
$user_details = $_POST;
}
else
{
$user_details = $db->get_sql_row("SELECT * FROM
" . DB_PREFIX . "users WHERE user_id=" . $session->value('user_id'));
}
$item->setts['max_images'] = 1;
$post_details = $_POST;
if ($_POST['box_submit'] == 1)
{
$user_details = $post_details;
}
$post_details['auction_id'] = 'store_logo_' . $session->value('user_id');
$post_details['ad_image'][0] = (!empty($_POST['ad_image'][0])) ? $_POST['ad_image'][0] : $user_details['shop_logo_path'];
if (empty($_POST['file_upload_type']))
{
$template->set('media_upload_fields', $item->upload_manager($post_details));
}
else if (is_numeric($_POST['file_upload_id'])) /* means we remove a file / media url */
{
$media_upload = $item->media_removal($post_details, $post_details['file_upload_type'], $post_details['file_upload_id'], false);
$media_upload_fields = $media_upload['display_output'];
$post_details['ad_image'] = $media_upload['post_details']['ad_image'];
$db->query("UPDATE " . DB_PREFIX . "users SET shop_logo_path='' WHERE user_id='" . $session->value('user_id') . "'");
$template->set('media_upload_fields', $media_upload_fields);
}
else /* means we have a file upload */
{
$media_upload = $item->media_upload($post_details, $post_details['file_upload_type'], $_FILES, false);
$media_upload_fields = $media_upload['display_output'];
$post_details['ad_image'] = $media_upload['post_details']['ad_image'];
$db->query("UPDATE " . DB_PREFIX . "users SET shop_logo_path='" . $post_details['ad_image'][0] . "' WHERE user_id='" . $session->value('user_id') . "'");
$template->set('media_upload_fields', $media_upload_fields);
}
$template->set('user_details', $db->rem_special_chars_array($user_details));
$image_upload_manager = $item->upload_manager($post_details, 1, 'form_store_setup', true, true, false);
$template->set('image_upload_manager', $image_upload_manager);
$template->set('store_templates_drop_down', $shop->store_templates_drop_down('shop_template_id', $user_details['shop_template_id']));
$members_area_page_content = $template->process('members_area_store_setup.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'store_pages')
{
if (isset($_POST['form_shop_save']))
{
define ('FRMCHK_STORE_SETUP', 1);
$frmchk_details = $_POST;
$frmchk_store_pages = true;
include ('includes/procedure_frmchk_store_setup.php'); /* Formchecker for store setup pages */
if ($fv->is_error())
{
$template->set('display_formcheck_errors', $fv->display_errors());
}
else
{
$template->set('msg_changes_saved', $msg_changes_saved);
$shop->shop_save_pages($_POST, $session->value('user_id'));
}
$user_details = $db->rem_special_chars_array($_POST);
}
else
{
$user_details = $db->get_sql_row("SELECT * FROM
" . DB_PREFIX . "users WHERE user_id=" . $session->value('user_id'));
}
$template->set('user_details', $user_details);
$members_area_page_content = $template->process('members_area_store_pages.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'categories')
{
$parent_id = intval($_REQUEST['parent_id']);
if (isset($_POST['form_save_settings']))
{
$session->set('category_language', 1);
$template->set('msg_changes_saved', $msg_changes_saved);
if (count($_POST['category_id']) > 0)
{
foreach ($_POST['category_id'] as $key => $value)
{
$order_id = intval($_POST['order_id'][$key]);
$order_id = ($order_id>=0 && $order_id<10000) ? $order_id : 10000;
$sql_update_categories = $db->query("UPDATE " . DB_PREFIX . "categories SET
name='" . $db->rem_special_chars($_POST['name'][$key]) . "', order_id=" . $order_id . " WHERE
category_id=" . $value . " AND user_id='" . $session->value('user_id') . "'");
}
}
if (count($_POST['delete'])>0)
{
$delete_array = $db->implode_array($_POST['delete']);
$sql_delete_categories = $db->query("DELETE FROM " . DB_PREFIX . "categories WHERE category_id IN (" . $delete_array . ")");## PHP Pro Bid v6.00 all the subcategories need to be deleted as well.
}
foreach ($_POST['add_name'] as $value)
{
if (!empty($value))
{
$sql_insert_category = $db->query("INSERT INTO " . DB_PREFIX . "categories
(name, parent_id, user_id) VALUES ('" . $db->rem_special_chars($value) . "', " . $parent_id . ", '" . $session->value('user_id') . "')");
}
}
}
if (isset($_POST['form_generate_subcategories']) || $_REQUEST['generate_subcategories'] == 1)
{
(array) $subcat_ids_array = NULL;
$template->set('msg_changes_saved', '
' . MSG_CATEGORIES_GENERATED . '
');
$sql_reset_subcategories = $db->query("UPDATE " . DB_PREFIX . "categories SET is_subcat=''");
$sql_select_subcategories = $db->query("SELECT parent_id FROM " . DB_PREFIX . "categories WHERE
parent_id>0");
while ($subcat_details = $db->fetch_array($sql_select_subcategories))
{
$subcat_ids_array[] = $subcat_details['parent_id'];
}
if (count($subcat_ids_array) > 0)
{
$subcat_ids = $db->implode_array($subcat_ids_array);
$sql_update_subcategories = $db->query("UPDATE " . DB_PREFIX . "categories SET
is_subcat='>' WHERE category_id IN (" . $subcat_ids . ")");
}## PHP Pro Bid v6.00 here we delete all subcategories that have no parent anymore
$delete_subcats = 1;
while ($delete_subcats)
{
(array) $subcategory = null;
$sql_select_obsolete_cats = $db->query_silent("SELECT c.category_id FROM " . DB_PREFIX . "categories c WHERE
(SELECT count(*) FROM " . DB_PREFIX . "categories cc WHERE cc.category_id=c.parent_id)=0 AND c.parent_id!=0");
$delete_subcats = 0;
if ($sql_select_obsolete_cats)
{
while ($subcat_details = $db->fetch_array($sql_select_obsolete_cats))
{
$delete_subcats = 1;
$subcategory[] = $subcat_details['category_id'];
}
if ($delete_subcats)
{
$delete_array = $db->implode_array($subcategory);
$db->query("DELETE FROM " . DB_PREFIX . "categories WHERE category_id IN (" . $delete_array . ")");
}
}
else
{
## delete obsolete cats using the old slower version
$sql_select_subcats = $db->query("SELECT * FROM " . DB_PREFIX . "categories WHERE parent_id!=0");
while ($subcat_details = $db->fetch_array($sql_select_subcats))
{
$is_maincat = $db->count_rows('categories', "WHERE category_id='" . $subcat_details['parent_id'] . "'");
if ($is_maincat == 0)
{
$db->query("DELETE FROM " . DB_PREFIX . "categories WHERE parent_id='" . $subcat_details['parent_id'] . "'");
}
}
}
}
}
if (isset($_POST['form_shop_save']))
{
$template->set('msg_changes_saved', $msg_changes_saved);
$db->query("UPDATE " . DB_PREFIX . "users SET shop_categories = '" . $db->implode_array($_POST['categories_id']) . "' WHERE
user_id='" . $session->value('user_id') . "'");
$user_details = $_POST;
}
else
{
$user_details = $db->get_sql_row("SELECT * FROM
" . DB_PREFIX . "users WHERE user_id=" . $session->value('user_id'));
}
$template->set('parent_id', $parent_id);
$template->set('category_navigator', category_navigator($parent_id, true, true, 'members_area.php', 'page=store§ion=categories'));
(string) $categories_page_content = NULL;
(string) $add_category_content = NULL;
$sql_select_categories = $db->query("SELECT category_id, name, parent_id, order_id, hidden, custom_fees, user_id, is_subcat FROM
" . DB_PREFIX . "categories WHERE parent_id=" . $parent_id . " AND user_id=" . $session->value('user_id') . " ORDER BY order_id ASC, name ASC");
while ($category_details = $db->fetch_array($sql_select_categories))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$background_border = (!empty($category_details['is_subcat'])) ? 'grey' : $background;
$order_value = ($category_details['order_id']>0 && $category_details['order_id']<1000) ? $category_details['order_id'] : '';
$categories_page_content .= '
'.
' '.
' '.
' ' ;
$categories_page_content .= ' ';
$categories_page_content .= ' '.
' '.
' ';
$categories_page_content .= ' '.
' ';
}
(int) $add_cats_counter = 1;
$add_category_content = '
'.
' '.
' ';
for ($i=0; $i<$add_cats_counter; $i++)
{
$add_category_content .= ' ';
}
$add_category_content .=' ' .
' ';
$add_category_content .= ' '.
' ';
$template->set('categories_page_content', $categories_page_content);
$template->set('add_category_content', $add_category_content);
(string) $all_categories_table = null;
(string) $selected_categories_table = null;
$selected_categories = (!empty($user_details['shop_categories'])) ? $user_details['shop_categories'] : 0;
$selected_categories = (is_array($_POST['categories_id'])) ? $db->implode_array($_POST['categories_id']) : $selected_categories;
$selected_categories = last_char($selected_categories);
$sql_select_all_categories = $db->query("SELECT category_id, name FROM " . DB_PREFIX . "categories WHERE
parent_id=0 AND user_id IN (0, " . $session->value('user_id') . ") AND category_id NOT IN (" . $selected_categories . ") ORDER BY order_id ASC, name ASC");
$all_categories_table = '
';
while ($all_categories_details = $db->fetch_array($sql_select_all_categories))
{
$all_categories_table .= '' . $all_categories_details['name'] . ' ';
}
$all_categories_table .= ' ';
$sql_select_selected_categories = $db->query("SELECT category_id, name FROM " . DB_PREFIX . "categories WHERE
parent_id=0 AND user_id IN (0, " . $session->value('user_id') . ") AND category_id IN (" . $selected_categories . ") ORDER BY order_id ASC, name ASC");
$selected_categories_table ='
';
while ($selected_categories_details = $db->fetch_array($sql_select_selected_categories))
{
$selected_categories_table .= '' . $selected_categories_details['name'] . ' ';
}
$selected_categories_table .= ' ';
$template->set('all_categories_table', $all_categories_table);
$template->set('selected_categories_table', $selected_categories_table);
$template->set('user_details', $user_details);
$members_area_page_content = $template->process('members_area_store_categories.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
} /* END -> STORE SETUP PAGES */
if ($page == 'wanted_ads') /* BEGIN -> WANTED ADS PAGE(S) */
{
if ($_REQUEST['do'] == 'closed_wa_proceed')
{
$nb_relists = $item->count_contents($_REQUEST['relist']);
$nb_deletions = $item->count_contents($_REQUEST['delete']);
if ($nb_relists > 0)
{
for ($i=0; $i<$nb_relists; $i++)
{
$relist_id = $_REQUEST['relist'][$i];
$relist_result = $item->relist_wanted_ad($relist_id, $session->value('user_id'), $_REQUEST['duration'][$relist_id]);
$relist_output[] = $relist_result['display'];
}
$template->set('msg_auction_relist', '
' . $db->implode_array($relist_output, ' ') . '
');
}
if ($nb_deletions > 0)
{
$item->delete_wanted_ad($db->implode_array($_REQUEST['delete']), $session->value('user_id'));
}
}
if ($section == 'new')
{
header_redirect(SITE_PATH . 'wanted_manage.php');
}
if ($_REQUEST['do'] == 'delete_wanted_ad')
{
$item->delete_wanted_ad($_REQUEST['wanted_ad_id'], $session->value('user_id'));
}
if ($section == 'open')
{
$nb_items = $db->count_rows('wanted_ads', "WHERE owner_id='" . $session->value('user_id') . "' AND
closed=0 AND deleted=0 AND creation_in_progress=0");
$template->set('nb_items', $nb_items);
$template->set('page_order_wanted_ad_id', page_order('members_area.php', 'w.wanted_ad_id', $start, $limit, $additional_vars, MSG_WANTED_AD_ID));
$template->set('page_order_itemname', page_order('members_area.php', 'w.name', $start, $limit, $additional_vars, MSG_ITEM_TITLE));
$template->set('page_order_start_time', page_order('members_area.php', 'w.start_time', $start, $limit, $additional_vars, GMSG_START_TIME));
$template->set('page_order_end_time', page_order('members_area.php', 'w.end_time', $start, $limit, $additional_vars, GMSG_END_TIME));
if ($nb_items)
{
$sql_select_items = $db->query("SELECT w.* FROM " . DB_PREFIX . "wanted_ads w
WHERE w.owner_id='" . $session->value('user_id') . "' AND w.closed=0 AND w.deleted=0 AND w.creation_in_progress=0
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
while ($item_details = $db->fetch_array($sql_select_items))
{
$background = ($counter++%2) ? 'c1' : 'c2';
(string) $content_options = null;
if ($item_details['payment_status']!='confirmed' && $item_details['active']==0)
{
$content_options .= '
' . MSG_PAY_WA_SETUP_FEE . ' ';
}
else
{
$content_options .= '
' . MSG_EDIT_WANTED_AD . ' ';
$content_options .= '
' . MSG_DELETE . ' ';
}
$open_wanted_ads_content .= '
'.
' # ' . $item_details['wanted_ad_id'] . ' '.
' ' . $item_details['name'] . ' '.
' ' . show_date($item_details['start_time'], false) . ' '.
' ' . show_date($item_details['end_time'], false) . ' '.
' ' . $content_options . ' '.
' ';
}
}
else
{
$open_wanted_ads_content = '
' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('open_wanted_ads_content', $open_wanted_ads_content);
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_wanted_ads_open.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'closed')
{
$nb_items = $db->count_rows('wanted_ads', "WHERE owner_id='" . $session->value('user_id') . "' AND
closed=1 AND deleted=0 AND end_time<='" . CURRENT_TIME . "' AND creation_in_progress=0");
$template->set('nb_items', $nb_items);
$template->set('page_order_wanted_ad_id', page_order('members_area.php', 'w.wanted_ad_id', $start, $limit, $additional_vars, MSG_WANTED_AD_ID));
$template->set('page_order_itemname', page_order('members_area.php', 'w.name', $start, $limit, $additional_vars, MSG_ITEM_TITLE));
$template->set('page_order_start_time', page_order('members_area.php', 'w.start_time', $start, $limit, $additional_vars, GMSG_START_TIME));
$template->set('page_order_end_time', page_order('members_area.php', 'w.end_time', $start, $limit, $additional_vars, GMSG_END_TIME));
$template->set('page_order_nb_bids', page_order('members_area.php', 'w.nb_bids', $start, $limit, $additional_vars, GMSG_OFFERS));
if ($nb_items)
{
$sql_select_items = $db->query("SELECT w.* FROM " . DB_PREFIX . "wanted_ads w
WHERE w.owner_id='" . $session->value('user_id') . "' AND w.closed=1 AND w.deleted=0
AND w.end_time<='" . CURRENT_TIME . "'AND w.creation_in_progress=0
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
while ($item_details = $db->fetch_array($sql_select_items))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$closed_wanted_ads_content .= '
'.
' # ' . $item_details['wanted_ad_id'] . ' '.
' ' . $item_details['name'] . ' '.
' ' . show_date($item_details['start_time'], false) . ' '.
' ' . show_date($item_details['end_time'], false) . ' '.
' ' . field_display($item_details['nb_bids'], '-', $item_details['nb_bids']) . ' '.
' '.
' ' . $item->durations_drop_down('duration[' . $item_details['wanted_ad_id'] . ']', $item_details['duration']) . ' '.
' '.
' ';
}
}
else
{
$closed_wanted_ads_content = '
' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('closed_wanted_ads_content', $closed_wanted_ads_content);
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_wanted_ads_closed.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
} /* END -> WANTED ADS PAGE(S) */
if ($page == 'reverse') /* BEGIN -> REVERSE AUCTIONS PAGE(S) */
{
if ($_REQUEST['do'] == 'closed_reverse_proceed')
{
$nb_relists = $item->count_contents($_REQUEST['relist']);
$nb_deletions = $item->count_contents($_REQUEST['delete']);
if ($nb_relists > 0)
{
for ($i=0; $i<$nb_relists; $i++)
{
$relist_id = intval($_REQUEST['relist'][$i]);
$relist_result = $item->relist_reverse($relist_id, $session->value('user_id'), intval($_REQUEST['duration'][$relist_id]));
$relist_output[] = $relist_result['display'];
}
$template->set('msg_auction_relist', '
' . $db->implode_array($relist_output, ' ') . '
');
}
if ($nb_deletions > 0)
{
$item->delete_reverse($db->implode_array($_REQUEST['delete']), $session->value('user_id'));
}
}
if ($section == 'new_auction')
{
header_redirect(SITE_PATH . 'reverse_manage.php');
}
if ($_REQUEST['do'] == 'delete_reverse')
{
$item->delete_reverse(intval($_REQUEST['reverse_id']), $session->value('user_id'));
}
if ($section == 'open')
{
$nb_items = $db->count_rows('reverse_auctions', "WHERE owner_id='" . $session->value('user_id') . "' AND
closed=0 AND deleted=0 AND creation_in_progress=0");
$template->set('nb_items', $nb_items);
$template->set('page_order_reverse_id', page_order('members_area.php', 'r.reverse_id', $start, $limit, $additional_vars, MSG_AUCTION_ID));
$template->set('page_order_itemname', page_order('members_area.php', 'r.name', $start, $limit, $additional_vars, MSG_ITEM_TITLE));
$template->set('page_order_start_time', page_order('members_area.php', 'r.start_time', $start, $limit, $additional_vars, GMSG_START_TIME));
$template->set('page_order_end_time', page_order('members_area.php', 'r.end_time', $start, $limit, $additional_vars, GMSG_END_TIME));
if ($nb_items)
{
$sql_select_items = $db->query("SELECT r.* FROM " . DB_PREFIX . "reverse_auctions r
WHERE r.owner_id='" . $session->value('user_id') . "' AND r.closed=0 AND r.deleted=0 AND r.creation_in_progress=0
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
while ($item_details = $db->fetch_array($sql_select_items))
{
$background = ($counter++%2) ? 'c1' : 'c2';
(string) $content_options = null;
if ($item_details['payment_status']!='confirmed' && $item_details['active']==0)
{
$content_options .= '
' . MSG_PAY_REVERSE_SETUP_FEE . ' ';
}
else
{
$content_options .= '
' . MSG_EDIT_AUCTION . ' ';
$content_options .= '
' . MSG_DELETE . ' ';
}
$open_reverse_content .= '
'.
' # ' . $item_details['reverse_id'] . ' '.
' ' . $item_details['name'] . ' '.
' ' . field_display($item_details['nb_bids'], '-', $item_details['nb_bids']) . ' '.
' ' . show_date($item_details['start_time'], false) . ' '.
' ' . show_date($item_details['end_time'], false) . ' '.
' ' . $content_options . ' '.
' ';
}
}
else
{
$open_reverse_content = '
' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('open_reverse_content', $open_reverse_content);
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_reverse_open.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'closed')
{
$nb_items = $db->count_rows('reverse_auctions', "WHERE owner_id='" . $session->value('user_id') . "' AND
closed=1 AND deleted=0 AND end_time<='" . CURRENT_TIME . "' AND creation_in_progress=0");
$template->set('nb_items', $nb_items);
$template->set('page_order_reverse_id', page_order('members_area.php', 'r.reverse_id', $start, $limit, $additional_vars, MSG_AUCTION_ID));
$template->set('page_order_itemname', page_order('members_area.php', 'r.name', $start, $limit, $additional_vars, MSG_ITEM_TITLE));
$template->set('page_order_start_time', page_order('members_area.php', 'r.start_time', $start, $limit, $additional_vars, GMSG_START_TIME));
$template->set('page_order_end_time', page_order('members_area.php', 'r.end_time', $start, $limit, $additional_vars, GMSG_END_TIME));
$template->set('page_order_nb_bids', page_order('members_area.php', 'r.nb_bids', $start, $limit, $additional_vars, GMSG_OFFERS));
if ($nb_items)
{
$sql_select_items = $db->query("SELECT r.* FROM " . DB_PREFIX . "reverse_auctions r
WHERE r.owner_id='" . $session->value('user_id') . "' AND r.closed=1 AND r.deleted=0
AND r.end_time<='" . CURRENT_TIME . "'AND r.creation_in_progress=0
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
while ($item_details = $db->fetch_array($sql_select_items))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$closed_reverse_content .= '
'.
' # ' . $item_details['reverse_id'] . ' '.
' ' . $item_details['name'] . ' '.
' ' . show_date($item_details['start_time'], false) . ' '.
' ' . show_date($item_details['end_time'], false) . ' '.
' ' . field_display($item_details['nb_bids'], '-', $item_details['nb_bids']) . ' '.
' '.
' ' . $item->durations_drop_down('duration[' . $item_details['reverse_id'] . ']', $item_details['duration']) . ' '.
' '.
' ';
}
}
else
{
$closed_reverse_content = '
' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('closed_reverse_content', $closed_reverse_content);
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_reverse_closed.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'scheduled')
{
$nb_items = $db->count_rows('reverse_auctions', "WHERE closed=1 AND owner_id='" . $session->value('user_id') . "' AND
deleted=0 AND creation_in_progress=0 AND end_time>='" . CURRENT_TIME . "'");
$template->set('nb_items', $nb_items);
$template->set('page_order_auction_id', page_order('members_area.php', 'r.reverse_id', $start, $limit, $additional_vars, MSG_AUCTION_ID));
$template->set('page_order_itemname', page_order('members_area.php', 'r.name', $start, $limit, $additional_vars, MSG_ITEM_TITLE));
$template->set('page_order_start_time', page_order('members_area.php', 'r.start_time', $start, $limit, $additional_vars, GMSG_START_TIME));
$template->set('page_order_end_time', page_order('members_area.php', 'r.end_time', $start, $limit, $additional_vars, GMSG_END_TIME));
if ($nb_items)
{
$force_index = $item->force_index($order_field, true);
$sql_select_items = $db->query("SELECT r.*, u.username FROM " . DB_PREFIX . "reverse_auctions r
" . $force_index . "
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=r.owner_id
WHERE r.owner_id='" . $session->value('user_id') . "' AND r.closed=1 AND r.deleted=0 AND
r.end_time>'" . CURRENT_TIME . "' AND r.creation_in_progress=0
GROUP BY r.reverse_id
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
while ($item_details = $db->fetch_array($sql_select_items))
{
$background = ($counter++%2) ? 'c1' : 'c2';
(string) $content_options = null;
if ($item_details['payment_status']!='confirmed' && $item_details['active']==0)
{
$content_options .= '
' . MSG_PAY_REVERSE_SETUP_FEE . ' ';
}
else
{
$content_options .= '
' . MSG_EDIT_AUCTION . ' ';
$content_options .= '
' . MSG_DELETE . ' ';
}
$scheduled_reverse_content .= '
'.
' # ' . $item_details['reverse_id'] . ' '.
' ' . $item_details['name'] . ' '.
' ' . show_date($item_details['start_time']) . ' '.
' ' . show_date($item_details['end_time']) . ' '.
' ' . $content_options . ' '.
' ';
}
}
else
{
$scheduled_reverse_content = '
' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('scheduled_reverse_content', $scheduled_reverse_content);
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_reverse_scheduled.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'awarded')
{
$nb_items = $db->count_rows('reverse_winners w', "WHERE w.poster_id='" . $session->value('user_id') . "' AND
w.b_deleted=0");
$template->set('nb_items', $nb_items);
$template->set('page_order_auction_id', page_order('members_area.php', 'r.reverse_id', $start, $limit, $additional_vars . $show_link, MSG_AUCTION_ID));
$template->set('page_order_itemname', page_order('members_area.php', 'r.name', $start, $limit, $additional_vars . $show_link, MSG_ITEM_TITLE));
$template->set('page_order_bid_amount', page_order('members_area.php', 'w.bid_amount', $start, $limit, $additional_vars . $show_link, MSG_WINNING_BID));
$template->set('page_order_purchase_date', page_order('members_area.php', 'w.purchase_date', $start, $limit, $additional_vars . $show_link, MSG_PURCHASE_DATE));
if ($nb_items)
{
$sql_select_awarded = $db->query("SELECT w.*, b.bid_id, r.name AS auction_name, r.currency, r.category_id,
u.username, u.name, rp.submitted, rp.reputation_id
FROM " . DB_PREFIX . "reverse_winners w
LEFT JOIN " . DB_PREFIX . "reverse_auctions r ON r.reverse_id=w.reverse_id
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=w.provider_id
LEFT JOIN " . DB_PREFIX . "reverse_bids b ON b.winner_id=w.winner_id
LEFT JOIN " . DB_PREFIX . "reputation rp ON rp.from_id=w.poster_id AND rp.reverse_winner_id=w.winner_id
WHERE w.poster_id='" . $session->value('user_id') . "' AND w.b_deleted=0
" . $search_filter . "
GROUP BY w.winner_id
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
$reverse_fee = new fees(true);
$reverse_fee->setts = &$setts;
while ($item_details = $db->fetch_array($sql_select_awarded))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$reverse_fee->set_fees($item_details['poster_id'], $item_details['category_id']);## PHP Pro Bid v6.00 by default the seller will pay
$item_paid = ($item_details['active'] == 1 && $item_details['payment_status'] == 'confirmed') ? 1 : 0;
if ($item_paid)
{
$content_options = '•
' . MSG_PMB . ' ';
if (!$item_details['submitted'])
{
//$content_options .= '•
' . MSG_LEAVE_COMMENTS . ' ';
}
}
else
{
if (eregi('b', $sale_fee->fee['endauction_fee_applies']))
{
$content_options = '•
' . MSG_PAY_ENDAUCTION_FEE . ' ';
}
else
{
$content_options = '• ' . MSG_ENDAUCTION_FEE_NOT_PAID;
}
}
$reverse_awarded_content .= '
'.
' # ' . $item_details['reverse_id'] . ' - '.
' ' . field_display($item_details['auction_name'], MSG_AUCTION_DELETED) . ' '.
' '.
' ' . $fees->display_amount($item_details['bid_amount'], $item_details['currency']) . ' '.
' ';
if ($item_paid)
{
$reverse_awarded_content .= ' '.
' '.
' ' . MSG_USERNAME . ' '.
' ' . field_display($item_details['username'], GMSG_NA) . ' '.
' '.
' '.
' ' . MSG_FULL_NAME . ' '.
' ' . field_display($item_details['name'], GMSG_NA) . ' '.
' '.
'
';
}
$reverse_awarded_content .= ' '.
' ';
if ($item_paid)
{
$reverse_awarded_content .= ' '.
' '.
' ' . show_date($item_details['purchase_date']) . ' '.
' '.
' '.
' ' . $item->flag_paid($item_details['flag_paid'], $item_details['direct_payment_paid']) . ' '.
' '.
'
';
}
$reverse_awarded_content .= ' '.
' ' . $content_options . ' '.
' ';
$reverse_awarded_content .= '
'.
' '.
' ';
}
}
else
{
$reverse_awarded_content = '
' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('reverse_awarded_content', $reverse_awarded_content);
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link . $show_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_reverse_awarded.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'my_bids')
{
$header_bidding_page = headercat('
' . MSG_MM_REVERSE_AUCTIONS . ' - ' . MSG_MM_MY_BIDS . ' ');
$nb_bids = $db->get_sql_field("SELECT count(*) AS nb_bids FROM " . DB_PREFIX . "reverse_bids b, " . DB_PREFIX . "reverse_auctions r WHERE
b.bidder_id=" . $session->value('user_id') . " AND r.reverse_id=b.reverse_id AND r.active=1 AND r.closed=0 AND
r.deleted=0", 'nb_bids');
$template->set('nb_bids', $nb_bids);
$template->set('page_order_auction_id', page_order('members_area.php', 'r.reverse_id', $start, $limit, $additional_vars, MSG_AUCTION_ID));
$template->set('page_order_itemname', page_order('members_area.php', 'r.name', $start, $limit, $additional_vars, MSG_ITEM_TITLE));
$template->set('page_order_bid_amount', page_order('members_area.php', 'b.bid_amount', $start, $limit, $additional_vars, MSG_BID_AMOUNT));
$template->set('page_order_bid_date', page_order('members_area.php', 'b.bid_date', $start, $limit, $additional_vars, GMSG_DATE));
if ($nb_bids)
{
$sql_select_bids = $db->query("SELECT b.*, b.active AS bid_active, b.payment_status AS bid_payment_status, r.*
FROM " . DB_PREFIX . "reverse_bids b, " . DB_PREFIX . "reverse_auctions r
WHERE b.bidder_id=" . $session->value('user_id') . " AND r.reverse_id=b.reverse_id AND r.active=1 AND
r.closed=0 AND r.deleted=0
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
while ($bid_details = $db->fetch_array($sql_select_bids))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$auction_link = process_link('reverse_details', array('reverse_id' => $bid_details['reverse_id']));
$item_paid = ($bid_details['bid_active'] == 1 && $bid_details['bid_payment_status'] == 'confirmed') ? 1 : 0;
$content_options = ($item_paid) ? $item->reverse_bid_status($bid_details['bid_status']) : '
' . MSG_PAY_ENDAUCTION_FEE . ' ';
/*$current_bids_content .= '
'.
' # ' . $bid_details['reverse_id'] . ' '.
' ' . $bid_details['name'] . ' '.
' ' . $fees->display_amount($bid_details['bid_amount'], $bid_details['currency']) . ' '.
' ' . show_date($bid_details['bid_date']) . ' '.
' ' . $content_options . ' '.
' ';
*/
$current_bids_content .= '';
}
}
else
{
$current_bids_content = '
' . GMSG_NO_BIDS_MSG . ' ';
}
$template->set('current_bids_content', $current_bids_content);
$pagination = paginate($start, $limit, $nb_bids, 'members_area.php', $additional_vars . $order_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_reverse_my_bids.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'my_profile')
{
$custom_fld = new custom_field();
$page_handle = 'provider_profile';
$frmchk_error = false;
$custom_fld->save_edit_vars($session->value('user_id'), 'provider_profile');
$item->setts['max_images'] = $setts['max_portfolio_files'];
if (isset($_POST['form_profile_save']) || $_POST['box_submit'] == 1)
{
$user_details = $_POST;
}
else
{
$user_details = $db->get_sql_row("SELECT user_id, provider_profile FROM
" . DB_PREFIX . "users WHERE user_id=" . $session->value('user_id'));
$user_details['profile_id'] = $user_details['user_id'];
## retrieve profile images
$media_details = $item->get_media_values($user_details['user_id'], false, false, true);
$user_details['ad_image'] = $media_details['ad_image'];
$user_details['ad_video'] = $media_details['ad_video'];
$user_details['ad_dd'] = $media_details['ad_dd'];
}
if (isset($_POST['form_profile_save']))
{
$custom_fld->save_vars($_POST);
define ('FRMCHK_ITEM', 1);
$frmchk_details = $_POST;
include ('includes/procedure_frmchk_provider_profile.php'); /* Formchecker for reverse auction creation/edit */
if ($fv->is_error())
{
$template->set('display_formcheck_errors', $fv->display_errors());
$frmchk_error = true;
}
else
{
$form_submitted = true;
$db->query("UPDATE " . DB_PREFIX . "users SET
provider_profile='" . $db->rem_special_chars($_POST['provider_profile']) . "' WHERE
user_id='" . $session->value('user_id') . "'");
$custom_fld->update_page_data($session->value('user_id'), $page_handle, $_POST);
$template->set('msg_changes_saved', $msg_changes_saved);
}
}
$custom_fld->new_table = false;
$custom_fld->field_colspan = 2;
$custom_sections_table = $custom_fld->display_sections($user_details, $page_handle);
$template->set('custom_sections_table', $custom_sections_table);
if (empty($_POST['file_upload_type']))
{
$template->set('media_upload_fields', $item->upload_manager($user_details));
}
else if (is_numeric($_POST['file_upload_id'])) /* means we remove a file / media url */
{
$media_upload = $item->media_removal($user_details, $user_details['file_upload_type'], $user_details['file_upload_id']);
$media_upload_fields = $media_upload['display_output'];
$user_details['ad_image'] = $media_upload['post_details']['ad_image'];
$user_details['ad_video'] = $media_upload['post_details']['ad_video'];
$user_details['ad_dd'] = $media_upload['post_details']['ad_dd'];
$template->set('media_upload_fields', $media_upload_fields);
}
else /* means we have a file upload */
{
$media_upload = $item->media_upload($user_details, $user_details['file_upload_type'], $_FILES);
$media_upload_fields = $media_upload['display_output'];
$user_details['ad_image'] = $media_upload['post_details']['ad_image'];
$user_details['ad_video'] = $media_upload['post_details']['ad_video'];
$user_details['ad_dd'] = $media_upload['post_details']['ad_dd'];
$template->set('media_upload_fields', $media_upload_fields);
}## <
> media upload sequence
$image_upload_manager = $item->upload_manager($user_details, 1, 'form_provider_profile', true, false, false);
$template->set('image_upload_manager', $image_upload_manager);
$template->set('user_details', $user_details);
$members_area_page_content = $template->process('members_area_reverse_profile.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
if ($section == 'won')
{
if (isset($_REQUEST['form_update_winner_status']))
{
$dd_active = (intval($_REQUEST['flag_paid']) == 1) ? 1 : 0;
$current_time = ($dd_active) ? CURRENT_TIME : 0;
$update_force_payment = (intval($_REQUEST['flag_paid']) == 1) ? ", temp_purchase=0" : '';
$db->query("UPDATE " . DB_PREFIX . "reverse_winners SET flag_paid='" . intval($_REQUEST['flag_paid']) . "'
WHERE winner_id='" . intval($_REQUEST['winner_id']) . "' AND
provider_id='" . $session->value('user_id') . "'");
}
$nb_items = $db->count_rows('reverse_winners w', "WHERE w.provider_id='" . $session->value('user_id') . "' AND
w.b_deleted=0");
$template->set('nb_items', $nb_items);
$template->set('page_order_auction_id', page_order('members_area.php', 'w.reverse_id', $start, $limit, $additional_vars . $show_link, MSG_AUCTION_ID));
$template->set('page_order_itemname', page_order('members_area.php', 'a.name', $start, $limit, $additional_vars . $show_link, MSG_ITEM_TITLE));
$template->set('page_order_bid_amount', page_order('members_area.php', 'w.bid_amount', $start, $limit, $additional_vars . $show_link, MSG_WINNING_BID));
$template->set('page_order_purchase_date', page_order('members_area.php', 'w.purchase_date', $start, $limit, $additional_vars . $show_link, MSG_PURCHASE_DATE));
if ($nb_items)
{
$sql_select_won = $db->query("SELECT w.*, b.bid_id, r.name AS auction_name, r.currency, r.category_id,
u.username, u.name, rp.submitted, rp.reputation_id, m.message_id
FROM " . DB_PREFIX . "reverse_winners w
LEFT JOIN " . DB_PREFIX . "reverse_auctions r ON r.reverse_id=w.reverse_id
LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=w.poster_id
LEFT JOIN " . DB_PREFIX . "reverse_bids b ON b.winner_id=w.winner_id
LEFT JOIN " . DB_PREFIX . "reputation rp ON rp.from_id=w.provider_id AND rp.reverse_winner_id=w.winner_id
LEFT JOIN " . DB_PREFIX . "messaging m ON m.reverse_id=w.reverse_id AND m.is_read=0 AND m.sender_id!=w.provider_id
WHERE w.provider_id='" . $session->value('user_id') . "' AND w.b_deleted=0
GROUP BY w.winner_id
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
$reverse_fee = new fees(true);
$reverse_fee->setts = &$setts;
while ($item_details = $db->fetch_array($sql_select_won))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$reverse_fee->set_fees($item_details['provider_id'], $item_details['category_id']);
$item_paid = ($item_details['active'] == 1 && $item_details['payment_status'] == 'confirmed') ? 1 : 0;
if ($item_paid)
{
$content_options = '• ' . MSG_PMB . ' ';
if (!$item_details['submitted'])
{
//$content_options .= '• ' . MSG_LEAVE_COMMENTS . ' ';
}
}
else
{
if (eregi('b', $reverse_fee->fee['endauction_fee_applies']))
{
$content_options = '• ' . MSG_PAY_ENDAUCTION_FEE . ' ';
}
else
{
$content_options = '• ' . MSG_ENDAUCTION_FEE_NOT_PAID;
}
}
$reverse_won_content .= ' '.
' # ' . $item_details['reverse_id'] . ' - '.
' ' . field_display($item_details['auction_name'], MSG_AUCTION_DELETED) . ' '.
$item->new_message_tick($item_details['message_id']) . ' '.
' ' . $fees->display_amount($item_details['bid_amount'], $item_details['currency']) . ' '.
' ';
if ($item_paid)
{
$reverse_won_content .= ' '.
' '.
' ' . MSG_USERNAME . ' '.
' ' . field_display($item_details['username'], GMSG_NA) . ' '.
' '.
' '.
' ' . MSG_FULL_NAME . ' '.
' ' . field_display($item_details['name'], GMSG_NA) . ' '.
' '.
'
';
}
$reverse_won_content .= ' '.
' ';
if ($item_paid)
{
$reverse_won_content .= show_date($item_details['purchase_date']) . ' '.
'';
}
$reverse_won_content .= ' '.
' ' . $content_options . ' '.
' ';
$reverse_won_content .= ' ';
}
}
else
{
$reverse_won_content = '' . GMSG_NO_ITEMS_MSG . ' ';
}
$template->set('reverse_won_content', $reverse_won_content);
$pagination = paginate($start, $limit, $nb_items, 'members_area.php', $additional_vars . $order_link . $show_link);
$template->set('pagination', $pagination);
$members_area_page_content = $template->process('members_area_reverse_my_projects.tpl.php');
$template->set('members_area_page_content', $members_area_page_content);
}
} /* END -> WANTED ADS PAGE(S) */
if ($page == 'summary') /* BEGIN -> SUMMARY PAGE */
{
if ($section == 'summary_main')
{
$summary_page_content['content'] = header6(MSG_MM_SUMMARY) .
$summary_page_content['manage_account'] .
$summary_page_content['messaging_received'] . ' ' .
$summary_page_content['stats_bidding'] . ''.
$summary_page_content['stats_selling'] . ''.
$summary_page_content['bidding_current_bids'] .
$summary_page_content['selling_open'];
$template->set('members_area_page_content', $summary_page_content['content']);
}
} /* END -> SUMMARY PAGE */
//$template->set('members_area_header', header7(MSG_MEMBERS_AREA_TITLE));
if ($page == 'summary') $template->set('members_area_header', "Área de membros > Sumário");
elseif ($page == 'messaging') $template->set('members_area_header', "Área de membros > Mensagens");
elseif ($page == 'bidding') $template->set('members_area_header', "Área de membros > Licitação");
elseif ($page == 'selling') $template->set('members_area_header', "Área de membros > Vender");
elseif ($page == 'about_me') $template->set('members_area_header', "Área de membros > Sobre mim");
elseif ($page == 'account') $template->set('members_area_header', "Área de membros > A minha conta");
elseif ($page == 'messages') $template->set('members_area_header', "Área de membros > Mensagens");
else $template->set('members_area_header', header7(MSG_MEMBERS_AREA_TITLE));
if ($session->value('category_language') == 1)
{
$msg_store_cats_modified = '' . MSG_STORE_CATS_MODIFIED . '
';
$template->set('msg_store_cats_modified', $msg_store_cats_modified);
}
## begin - header members area
## preferred seller and check for credit limit
$user_details = $db->get_sql_row("SELECT preferred_seller, balance, max_credit FROM " . DB_PREFIX . "users WHERE user_id='" . $session->value('user_id') . "'");
$user_payment_mode = $fees->user_payment_mode($session->value('user_id'));
$template->set('pref_seller_reduction', ($user_details['preferred_seller'] && $setts['enable_pref_sellers']) ? 1 : 0);
$credit_limit_warning = ($user_payment_mode == 2 && ($user_details['max_credit'] <= ($user_details['balance']+2))) ? 1 : 0;
$template->set('credit_limit_warning', $credit_limit_warning);
$nb_cells = 1;
if ($session->value('membersarea') == 'Active')
{
$nb_cells+=4;
}
if ($session->value('is_seller'))
{
$nb_cells++;
if ($setts['enable_bulk_lister'])
{
$nb_cells++;
}
if ($setts['enable_stores'])
{
$nb_cells++;
}
}
if ($setts['enable_wanted_ads'])
{
$nb_cells++;
}
if ($setts['enable_reverse_auctions'])
{
$nb_cells++;
}
$cell_width = round(100/$nb_cells) . '%';
$template->set('cell_width', $cell_width);
if ($page != 'summary')
{
$template->change_path('themes/' . $setts['default_theme'] . '/templates/');
$members_area_header_menu = $template->process('members_area_header_menu.tpl.php');
$template->change_path('templates/');
$template->set('members_area_header_menu', $members_area_header_menu);## PHP Pro Bid v6.00 end - header members area
}
$template->change_path('themes/' . $setts['default_theme'] . '/templates/');
$my_sidebar = $template->process('sidebar.tpl.php');
$template->change_path('templates/');
$template->set('my_sidebar', $my_sidebar);
$template_output .= $template->process('members_area.tpl.php');
include_once ('global_footer.php');
echo $template_output;
}
?>