File: /var/www/html/wp-content/themes/frameMyrskyNew/led_details.php
<?php
/**
* @package WordPress
* @subpackage frameLED_Theme
*/
/*
Template Name: Led Details
*/
?>
<?php
include_once("stock_manage.php");
get_header();
?>
<?php /* if (have_posts()) : while (have_posts()) : the_post();
$erp_page_path = get_the_content();
wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number'));
endwhile; endif;
echo "http://".$_SERVER['SERVER_NAME'].'/'.$erp_page_path;
*/
?>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/<?php echo $servers['Lang']; ?>.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.cookie.js"></script>
<?php
//include_once("config.php");
$part_id = $_GET["part_id"];
$SaleManage = new SaleManage();
$ProductList = $SaleManage->getProductList();
$ProListName = $SaleManage->getProListName();
$left_menu = '';
foreach($ProductList as $listKey=>$listInfo){
//$kindName = $ProListName[$listKey];
//$kindName =ucfirst(str_replace("_"," ",$listKey));
$left_menu .= "<h2><a href='product-list/?kind=$listKey'>".$SaleManage->getCategoryChinaName($listKey,"zh")."</a><span class='arrow'></span></h2><ul style='display:none;'>";
foreach($listInfo as $proKey=>$proInfo){
$tmp = iconv("utf-8","GB2312",$proInfo); //防止UTF-8中文被截取成两半
$proInfo = strlen($tmp)>20 ? substr ($tmp,0,20)."..." : $tmp;//处理长度
$left_menu .="<li><a href='product-detail/?part_id=$proKey'>".iconv("GB2312","utf-8",$proInfo)."</a></li>";
}
$left_menu .='</ul>';
}
//echo bloginfo('stylesheet_directory');
//var_dump($servers);
$part_info = $SaleManage->getProductByPartID($part_id);
//var_dump($part_info);
//取价格显示
$proPriceArray=$part_info["price"];
$price_detail_html = "";
$jsArr ="";
$aNum = count($proPriceArray);
$last_quantity =0;
if($aNum<2){
$quantity = $proPriceArray[0]['quantity'];
$unit_price = round($proPriceArray[0]['unit_price'], 2);
$jsArr .='{quantityMin:'.$last_quantity.',quantityMax:'.$quantity.','.'unit_price:'.$unit_price.'},';
$price_detail_html .= "<tr><td>-</td><td>$unit_price</td></tr>";
}else{
$last_quantity = 0;
$fistQuantity = $proPriceArray[0]['quantity'];
$lastQuantity = $proPriceArray[($aNum-1)]['quantity'];
$i = 0 ;
foreach($proPriceArray as $proPrice){
$quantity = $proPrice['quantity'];
if($quantity>$fistQuantity){
$ii= $i-1;
$unit_price = round($proPriceArray[$ii]['unit_price'], 2);
$jsArr .='{quantityMin:'.$last_quantity.',quantityMax:'.$quantity.','.'unit_price:'.$unit_price.'},';
$price_detail_html .= "<tr><td>$last_quantity-$quantity</td><td>$unit_price</td></tr>";
$last_quantity = $quantity;
}
$i++;
}
$unit_price = round($proPriceArray[($aNum-1)]['unit_price'],2);
$quantity = $proPriceArray[($aNum-1)]['quantity'];
$jsArr .='{quantityMin:'.$last_quantity.',quantityMax:'.$quantity.','.'unit_price:'.$unit_price.'},';
$price_detail_html .= "<tr><td>>$last_quantity</td><td>$unit_price</td></tr>";
}
if(!empty($price_detail_html)){
$price_detail_html ='<table><tr><td>购买数量</td><td>价格</td></tr>'.$price_detail_html.'</table>';
}
//Color
$part_color = $part_info["parameters"]["color"];
//产品参数
unset($prarameters_html);
foreach($part_info as $pKey=>$pValue){
//if($pKey == "ours_amount_in_stock"||$pKey == "real_amount_in_stock"||$pKey == "price"||$pKey == "category"||$pKey == "price_unit"||$pKey == "part_id"||$pKey == "description") continue;
if(in_array($pKey ,array("ours_amount_in_stock","real_amount_in_stock","price","category","price_unit","part_id","description","currency_id","category_symbol","lead_time","p_no"))) continue;
//if(count($pValue)>1){
if(is_array($pValue)){
foreach($pValue as $pKey=>$pdValue){
$prarameters_html .= "<li>$pKey: $pdValue</li>";
}
}else{
if($pKey!='img_url'){
if($pKey=="name") $pKey = "产品名称";
$prarameters_html .= "<li>$pKey: $pValue</li>";
}
}
}
$jsArr = trim($jsArr,',');
?>
<script type="text/javascript" >
var priceArr ='[<?php echo $jsArr;?>]';
var obj = eval(priceArr);
function changePrice(quantity){
for(i in obj){
if(quantity>=obj[i].quantityMin){
var price = obj[i].unit_price;
}
}
$('#showPrice').html(price);
}
</script>
<div class="leftMenu led-box">
<h2 class="led-box-head"><span class="ledBackground left-circle"></span><a href="product-list/?">产品列表</a><span class="ledBackground right-circle"></span> </h2>
<div class="led-box-body">
<div class="listMenu">
<?php echo $left_menu; //左边产品导航?>
</div>
</div>
<span class="led-box-bottom"><span class="left-circle-bottom ledBackground"></span><span class="right-circle-bottom ledBackground"></span></span>
</div>
<div class="rightConeten">
<div class="proDetailLeft">
<div class="proImg">
<img src="<?php echo "http://".$_SERVER['SERVER_NAME'].'/code/'.$part_info["img_url"]; ?>" alt="<?php echo $part_info["name"]; ?>" id="openImg" />
</div>
</div>
<div class="proDeatilRight">
<h1 class="proName"><?php echo $part_info["name"]; ?></h1>
<div class="proBase">
<ul>
<li>产品名称:<?php echo $part_info["name"]; ?></li>
<li>产品编号:<?php echo $part_info["p_no"]; ?></li>
<?php echo $part_color ? "<li>颜色:$part_color</li>" :""; ?>
<li>价格: <?php echo $part_info["category_symbol"]; ?> <span id="showPrice"><?php echo round($part_info["price"][0]["unit_price"],2); ?></span><?php echo $price_detail_html; ?></li>
<li>库存:<span id="qty_<?php echo $part_id; ?>"><?php echo $part_info["ours_amount_in_stock"]; ?></span></li>
</ul>
<div class="shopCar">
<dl>
<dt> 数量:</dt>
<dd>
<a href="javascript:void(0)" class="reduce" id="reduce">-</a>
<input type="text" id="pamount" value="1" pid="<?php echo $part_id; ?>"/>
<a href="javascript:void(0)" class="add" id="add">+</a>
</dd>
</dl>
<div class="shopBtn">
<a href="<?php echo "http://".$_SERVER['SERVER_NAME'];?>/code/led/shop_car.php?user_email={user_email}&pid=<?php echo $part_id; ?>" class="addToCar" pid="<?php echo $part_id; ?>" lead_time="<?php echo empty($part_info["lead_time"])?$servers['led_ledtime']:$part_info["lead_time"] ;?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/css/images/btn_car.jpg"/></a>
</div>
</div>
</div>
</div>
<div class="clear myh1"></div>
<div class="proInfo">
<h2><a href="#" class="choose" id="choose1">产品特点</a><a href="#" id="choose2">产品参数</a></h2>
</div>
<div class="proDetail">
<ul id="show2">
<?php echo $prarameters_html; ?>
</ul>
<pre id="show1">
<?php echo $part_info["description"]; ?>
</pre>
</div>
<div id="light" class="white_content">
<img src="<?php echo "http://".$_SERVER['SERVER_NAME'].'/code/'.$part_info["img_url"];?>" alt="<?php echo $part_info["name"]; ?>" id="closeImg" />
</div>
<div id="fade" class="black_overlay"></div>
</div>
<?php
//include_once("stock_manage.php");
//$stock = new StockManage();
//var_dump($_GET);
?>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/led.js"></script>
<?php get_footer() ?>