<?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: 2048 $ */ if (!defined('IN_PHPB2B')) { exit('Not A Valid Entry Point'); } uses("trade", "tradefield"); $trade = new Trades(); $trade_controller = new Trade(); $conditions = array(); $conditions[] = "Trade.status=1"; if (!empty($member->info['id'])) { $conditions[] = "Trade.member_id='" . $member->info['id'] . "'"; } if (!empty($company->info['id'])) { $conditions[] = "Trade.company_id='" . $company->info['id'] . "'"; } $amount = $trade->findCount(null, $conditions, "Trade.id"); setvar("TradeTypes", $tradetypes = $trade_controller->getTradeTypes()); setvar("TradeNames", $tradenames = $trade_controller->getTradeTypeNames()); setvar("paging", array('total' => $amount)); $space->render("offer");
/** * [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: 2116 $ */ function smarty_block_offer($params, $content, &$smarty, &$repeat) { global $_PB_CACHE; $conditions[] = "t.status='1'"; $param_count = count($smarty->_tag_stack); if (empty($params['name'])) { $params['name'] = "offer"; } if (!class_exists("Trades")) { uses("trade"); $trade = new Trades(); $trade_controller = new Trade(); } else { $trade = new Trades(); $trade_controller = new Trade(); } if ($_PB_CACHE['setting']['offer_expire_method']) { switch ($_PB_CACHE['setting']['offer_expire_method']) { case "2": $conditions[] = "t.expire_time>" . $trade->timestamp; break; case "3": $conditions[] = "t.expire_time>" . $trade->timestamp; break; default: break; } } if (isset($params['type'])) { $type = explode(",", $params['type']); $type = array_unique($type); foreach ($type as $val) { switch ($val) { case 'image': $conditions[] = "t.picture!=''"; break; case 'urgent': $conditions[] = "t.if_urgent='1'"; break; case 'company': $conditions[] = "t.company_id>0"; break; case 'commend': $conditions[] = "t.if_commend>0"; break; default: break; } } } if (isset($params['industryid'])) { if (isset($params['depth'])) { $depth = intval($params['depth']); if ($depth) { if (class_exists("Industries")) { $industry = new Industries(); $industry_controller = new Industry(); } else { uses("industry"); $industry = new Industries(); $industry_controller = new Industry(); } $ids_s = $industry->getConditionIds($params['industryid']); if (is_array($ids_s)) { $ids_s = array_filter($ids_s); $conditions['industry'] = "t.industry_id IN (" . implode(",", $ids_s) . ")"; } else { $conditions['industry'] = "t.industry_id='" . $ids_s . "'"; } } } else { $conditions[] = "t.industry_id = '" . $params['industryid'] . "'"; } } if (isset($params['areaid'])) { if (isset($params['depth'])) { $depth = intval($params['depth']); if ($depth) { global $industry; $ids_s = $industry->getConditionIds($params['areaid']); if (is_array($ids_s)) { $ids_s = array_filter($ids_s); $conditions['area'] = "t.area_id IN (" . implode(",", $ids_s) . ")"; } else { $conditions['area'] = "t.area_id='" . $ids_s . "'"; } } } else { $conditions['area'] = "t.area_id = '" . $params['areaid'] . "'"; } } if (!empty($_GET['industryid'])) { $conditions['industry'] = "t.industry_id=" . intval($_GET['industryid']); } if (!empty($_GET['areaid'])) { $conditions['area'] = "t.area_id=" . intval($_GET['areaid']); } if (isset($params['exclude'])) { $conditions[] = $trade->getExcludeIds($params['exclude']); } if (isset($params['include'])) { $conditions[] = $trade->getIncludeIds($params['include']); } if (isset($params['country_id'])) { $conditions[] = "t.country_id='" . $params['country_id'] . "'"; } if (isset($params['expday'])) { $conditions[] = "t.expire_time<'" . ($params['expday'] * 86400 + $trade->timestamp) . "'"; } if (isset($params['subday'])) { $conditions[] = "t.submit_time>'" . ($trade->timestamp - $params['expireday'] * 86400) . "'"; } if (isset($params['typeid'])) { if (!empty($params['typeid'])) { if (strpos($params['typeid'], ",") > 0) { $tmp_ids = explode(",", $params['typeid']); $conditions[] = "t.type_id in ('" . implode("','", $tmp_ids) . "')"; } else { $conditions[] = "t.type_id='" . $params['typeid'] . "'"; } } } if (isset($params['urgent'])) { $conditions[] = "t.if_urgent='1'"; } if (!empty($params['memberid'])) { $conditions[] = "t.member_id='" . $params['memberid'] . "'"; } if (!empty($params['companyid'])) { $conditions[] = "t.company_id='" . $params['companyid'] . "'"; } if (isset($params['cash'])) { $conditions[] = "t.require_point>0"; } $trade->setCondition($conditions); $orderby = null; $orderby = isset($params['orderby']) ? " ORDER BY " . trim($params['orderby']) . " " : " ORDER BY modified DESC"; $limit = $offset = 0; if (isset($params['row'])) { $limit = $params['row']; } if (isset($params['start'])) { $offset = $params['start']; } if (isset($_GET['pos'])) { $offset = intval($_GET['pos']); } $trade->setLimitOffset($offset, $limit); $mysql_limit = $trade->getLimitOffset(); if (isset($params['limit'])) { $mysql_limit = " " . trim($params['limit']); } if (!$params['recursive']) { $sql = "SELECT *,title as name,title as fulltitle,content as fullcontent FROM {$trade->table_prefix}trades t " . $trade->getCondition() . "{$orderby}" . $mysql_limit; } else { $sql = "SELECT *,content as fullcontent FROM {$trade->table_prefix}trades t " . $trade->getCondition() . " ORDER BY t.display_order ASC,t.id DESC" . $mysql_limit; } $offer_typenames = $trade_controller->getTradeTypes(); if (empty($smarty->blockvars[$param_count])) { $smarty->blockvars[$param_count] = $trade->GetArray($sql); if (!$smarty->blockvars[$param_count]) { return $repeat = false; } } if (!function_exists("smarty_function_the_url")) { require "function.the_url.php"; } if (list($key, $item) = each($smarty->blockvars[$param_count])) { $repeat = true; $item['rownum'] = $key; $item['iteration'] = ++$key; $url = smarty_function_the_url(array("id" => $item['id'], "typeid" => $item['type_id'], "module" => "offer")); $item['url'] = $url; $item['title'] = strip_tags($item['title']); $item['content'] = strip_tags($item['content']); if (isset($params['titlelen'])) { $item['title'] = mb_substr($item['title'], 0, $params['titlelen']); } if (isset($params['infolen'])) { $item['content'] = mb_substr($item['content'], 0, $params['infolen']); } if (isset($params['titlestart'])) { $item['title'] = $params['titlestart'] . $item['title']; } $item['pubdate'] = df($item['submit_time']); $item['typeid'] = $item['type_id']; $item['typename'] = $offer_typenames[$item['type_id']]; $item['src'] = $item['thumb'] = URL . "attachment/" . $item['picture'] . ".small.jpg"; $item['link'] = '<a title="' . $item['fulltitle'] . '" href="' . $url . '">' . $item['title'] . '</a>'; $item['style'] = parse_highlight($item['highlight']); $smarty->assign($params['name'], $item); } else { $repeat = false; reset($smarty->blockvars[$param_count]); } if (!is_null($content)) { print $content; } if (!$repeat) { $smarty->blockvars[$param_count] = array(); } }
setvar("service_days", $service_interation > 100 ? 100 : $service_interation); $service_info = true; } if (isset($service_interation)) { if ($service_interation >= 100) { $group_info = $pdb->GetRow("SELECT default_live_time,after_live_time FROM {$tb_prefix}membergroups WHERE id=" . $membergroup_id); $membergroup_id = $group_info['after_live_time']; $time_add = $membergroup->getServiceEndtime($group_info['default_live_time']); // $pdb->Execute("UPDATE {$tb_prefix}members SET membergroup_id='".$group_info['after_live_time']."',service_start_date='".$time_stamp."',service_end_date='".$time_add."' WHERE id=".$the_memberid); $pdb->Execute("UPDATE {$tb_prefix}members SET membergroup_id='" . $group_info['after_live_time'] . "' WHERE id=" . $the_memberid); } } uaAssign(array("LastLogin" => date("Y-m-d H:i", $memberinfo['last_login']))); $offer_count = $pdb->GetArray("SELECT count(id) AS amount,type_id AS typeid FROM {$tb_prefix}trades WHERE member_id=" . $the_memberid . " GROUP BY type_id"); $offer_stat = array(); $types = $trade->getTradeTypes(); if (!empty($offer_count)) { foreach ($offer_count as $offer_key => $offer_val) { $offer_stat[$types[$offer_val['typeid']]] = $offer_val['amount']; } setvar("items_offer", $offer_stat); } $pm_count = $pdb->GetArray("SELECT count(id) AS amount,type AS typename FROM {$tb_prefix}messages WHERE to_member_id=" . $the_memberid . " GROUP BY type"); if (!empty($pm_count)) { $pm_result = array(); foreach ($pm_count as $pm_val) { $pm_result[$pm_val['typename']] = intval($pm_val['amount']); } setvar("pm", $pm_result); } setvar("ServiceInfo", $service_info);
$ids = implode(",", $_POST['id']); $ids = "(" . $ids . ")"; $sql = "DELETE FROM {$tb_prefix}favorites WHERE id IN " . $ids . " AND member_id=" . $_SESSION['MemberID']; $res = $pdb->Execute($sql); if (!$res) { flash("action_failed"); } } if (isset($_POST['do']) && isset($_POST['id'])) { if ($trade_model->checkExist($_POST['id'])) { $sql = "INSERT INTO {$tb_prefix}favorites (target_id,member_id,type_id,created,modified) VALUE (" . $_POST['id'] . "," . $_SESSION['MemberID'] . ",1," . $time_stamp . "," . $time_stamp . ")"; $result = $pdb->Execute($sql); } if ($result) { echo "<script language='javascript'>window.close();</script>"; exit; } else { flash("been_favorited", '', 0); } } $tpl_file = "favor"; $sql = "select f.id,t.id as offerid,t.title,t.type_id,f.created from {$tb_prefix}trades as t,{$tb_prefix}favorites as f where f.member_id=" . $pb_userinfo['pb_userid'] . " and f.target_id=t.id"; $result = $pdb->GetArray($sql); if (!empty($result)) { for ($i = 0; $i < count($result); $i++) { $result[$i]['pubdate'] = date("Y-m-d", $result[$i]['created']); } setvar("Items", $result); } setvar("TradeTypes", $trade->getTradeTypes()); template($tpl_file);
function detail() { global $viewhelper, $G, $pb_user; $positions = $titles = array(); uses("trade", "member", "company", "tradefield", "form", "industry", "area", "meta"); $offer = new Tradefields(); $area = new Areas(); $meta = new Metas(); $industry = new Industries(); $company = new Companies(); $trade = new Trade(); $trade_model = new Trades(); $member = new Members(); //$typeoption = new Typeoption(); $form = new Forms(); setvar("Genders", cache_read("typeoption", 'gender')); setvar("PhoneTypes", cache_read("typeoption", 'phone_type')); $viewhelper->setTitle(L("offer", "tpl")); $viewhelper->setPosition(L("offer", "tpl"), "index.php?do=offer"); if (isset($_GET['title'])) { $title = trim($_GET['title']); $res = $trade_model->findByTitle($title); $id = $res['id']; } if (isset($_GET['id'])) { $id = intval($_GET['id']); } if (!empty($id)) { $trade->setInfoById($id); $info = $trade->info; if (empty($info['id'])) { flash("data_not_exists", '', 0); } $info['title_clear'] = $info['title']; $info['title'] .= ($G['setting']['offer_expire_method'] == 1 || $G['setting']['offer_expire_method'] == 3) && $info['expdate'] < $offer->timestamp ? "[" . L("has_expired", "tpl") . "]" : ''; $info['title'] .= !empty($info['if_urgent']) ? "[" . L("urgent_buy", "tpl") . "]" : ''; if ($info['expdate'] < $offer->timestamp && $G['setting']['offer_expire_method'] == 2) { flash("has_been_expired", URL, 0, $info['title_clear'] . " "); } } else { flash("data_not_exists", '', 0); } if ($info['status'] != 1) { flash("under_checking", null, 0, $info['title_clear'] . " "); } $trade_types = $trade->getTradeTypes(); $viewhelper->setTitle($trade_types[$info['type_id']]); $viewhelper->setPosition($trade_types[$info['type_id']], "index.php?do=offer&action=lists&typeid=" . $info['type_id']); $trade_model->clicked($id); if ($info['require_point'] > 0) { //check member points if (empty($pb_user)) { flash("please_login_first", URL . "logging.php"); } $point = $member->field("points", "id='" . $pb_user['pb_userid'] . "'"); if ($point < $info['require_point']) { flash("not_enough_points", URL, 0, $info['require_point']); } } $form_vars = array(); if (isset($info['formattribute_ids'])) { $form_vars = $form->getAttributes(explode(",", $info['formattribute_ids'])); } setvar("ObjectParams", $form_vars); $info['pubdate'] = df($info['pubdate']); $info['expdate'] = df($info['expdate']); $info['image'] = pb_get_attachmenturl($info['picture']); $login_check = 1; if ($info['type_id'] == 1) { $login_check = $G['setting']['buy_logincheck']; } elseif ($info['type_id'] == 2) { $login_check = $G['setting']['sell_logincheck']; } if (!empty($info['member_id'])) { $member_info = $member->getInfoById($info['member_id']); $info['link_people'] = $member_info['last_name']; $info['space_name'] = $member_info['space_name']; $info['tel'] = $member_info['tel']; $info['address'] = $member_info['address']; $info['zipcode'] = $member_info['zipcode']; $info['fax'] = $member_info['fax']; $info['site_url'] = $member_info['site_url']; setvar("MEMBER", $member_info); } if (!empty($info['company_id'])) { $company_info = $company->getInfoById($info['company_id']); if (!empty($company_info)) { $info['companyname'] = $company_info['name']; $info['link_people'] = $company_info['link_man']; $info['address'] = $company_info['address']; $info['zipcode'] = $company_info['zipcode']; $info['site_url'] = pb_hidestr($company_info['site_url']); $info['tel'] = pb_hidestr($company_info['tel']); $info['fax'] = pb_hidestr($company_info['fax']); } setvar("COMPANY", $company_info); } setvar("LoginCheck", $login_check); $info['title'] = strip_tags($info['title']); $info['industry_names'] = $industry->disSubNames($info['industry_id'], null, true, "offer"); $info['area_names'] = $area->disSubNames($info['area_id'], null, true, "offer"); //delete the pre num.2011.9.1 // $info['tel'] = preg_replace('/\((.+?)\)/i', '', pb_hidestr($info['tel'])); // $info['fax'] = preg_replace('/\((.+?)\)/i', '', pb_hidestr($info['fax'])); $info = pb_lang_split_recursive($info); setvar("item", $info); $meta_info = $meta->getSEOById($id, 'trade', false); empty($meta_info['title']) ? $viewhelper->setTitle($info['title'], $info['picture']) : $viewhelper->setTitle($meta_info['title']); empty($meta_info['description']) ? $viewhelper->setMetaDescription($info['content']) : $viewhelper->setMetaDescription($meta_info['description']); $viewhelper->setPosition($info['title_clear']); if (isset($meta_info['keyword'])) { $viewhelper->setMetaKeyword($meta_info['keyword']); } setvar("forward", $this->url(array("module" => "offer", "id" => $id))); render("offer/detail"); }
<?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");