<?php /** * [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved. * The contents of this file are subject to the License; you may not use this file except in compliance with the License. * * @version $Revision: 2075 $ */ require "../libraries/common.inc.php"; require "room.share.php"; uses("trade", "product"); check_permission("offer"); $product = new Products(); $trade = new Trades(); $trade_controller = new Trade(); $trade_type_names = $trade_controller->getTradeTypes(); $conditions = "member_id = " . $the_memberid; $amount = $pdb->GetArray("select Trade.type_id as TradeTypeId,count(Trade.id) as CountTrade from " . $trade->getTable(true) . " where " . $conditions . " group by Trade.type_id"); if (is_array($amount)) { $stats = array(); foreach ($amount as $val) { $stats[$val['TradeTypeId']] = array("Amount" => $val['CountTrade'], "name" => $trade_type_names[$val['TradeTypeId']]); } } setvar("UserTradeStat", $stats); setvar("ProductAmount", $product->findCount(null, $conditions, "Product.id")); template("stat");
} if (isset($_POST['refresh'])) { if (!empty($_POST['refresh']) && !empty($_POST['tradeid'])) { $vals = array(); $pre_submittime = $pdb->GetOne("select max(submit_time) from {$tb_prefix}trades where member_id=" . $the_memberid); if ($pre_submittime > $time_stamp - $tMaxDay * 86400) { flash("allow_refresh_day"); } $vals['submit_time'] = $time_stamp; $vals['expire_days'] = 10; $vals['expire_time'] = $time_stamp + 24 * 3600 * $vals['expire_days']; $conditions[] = "status='1'"; $ids = implode(",", $_POST['tradeid']); $conditions[] = "id in (" . $ids . ")"; $condition = implode(" AND ", $conditions); $sql = "update " . $trade->getTable() . " set submit_time=" . $time_stamp . ",expire_days=10,expire_time=" . $vals['expire_time'] . " where " . $condition; $result = $pdb->Execute($sql); if ($result) { flash("success"); } else { flash("action_failed"); } } } $amount = 0; $amount = $trade->findCount(null, $conditions); $page->setPagenav($amount); $result = $trade->findAll("*", null, $conditions, "Trade.submit_time DESC,Trade.id DESC", $page->firstcount, $page->displaypg); if (!empty($result)) { for ($i = 0; $i < count($result); $i++) { $result[$i]['expire_date'] = df($result[$i]['expire_time']);
if ($_GET['ExpFromDate'] != "None" && $_GET['ExpToDate'] != "None") { $condition = "Trade.expire_time BETWEEN "; $condition .= Times::dateConvert($_GET['ExpFromDate']); $condition .= " AND "; $condition .= Times::dateConvert($_GET['ExpToDate']); $conditions = $condition; } } if (!empty($_GET['ip'])) { $conditions[] = "Trade.ip_addr='" . $_GET['ip'] . "'"; } } } if (isset($_POST['urgent_batch'])) { $ids = implode(",", $_POST['id']); $result = $pdb->Execute("update " . $trade->getTable() . " set if_urgent='1' where if_urgent='0' AND id in (" . $ids . ")"); if (!$result) { flash(); } } if (isset($_POST['cancel_urgent_batch'])) { $ids = implode(",", $_POST['id']); $result = $pdb->Execute("update " . $trade->getTable() . " set if_urgent='0' where if_urgent='1' AND id in (" . $ids . ")"); if (!$result) { flash(); } } if (isset($_POST['del']) && !empty($_POST['id'])) { foreach ($_POST['id'] as $val) { $picture = $trade->field("picture", "id=" . $val); $attachment->deleteBySource($picture);