<%@ Page language="c#" Codebehind="OrderDetailView.aspx.cs" AutoEventWireup="true" Inherits="XpShop.Supplier.OrderDetailView" %>
<%@ Register TagPrefix="uc1" TagName="Header" Src="Modules/Header.ascx" %>
<%@ Register TagPrefix="uc1" TagName="SupplierMenu" Src="Modules/SupplierMenu.ascx" %>
<%@	Register TagPrefix="ftb" Namespace="FreeTextBoxControls" Assembly="FreeTextBox"	%>
<%@ Register TagPrefix="uc1" TagName="Helper" Src="Modules/Helper.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Footer" Src="Modules/Footer.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<!--#include file="inc/head.inc"-->
		<title>商家中心 <%=config.SiteTitle%></title>
        <script type="text/javascript" src="inc/OrderPayList.js"></script>
        <script type="text/javascript" src="inc/commond.js"></script>
		<script src="inc/ui.datepicker.cn.js" type="text/javascript"></script>
		<link type="text/css" rel="stylesheet" href="<%=webSite %>Template/<%=config.TemplateFolder%>/style/ui.datepicker.css" />
		<script type="text/javascript" src="<%=webSite %>Template/<%=config.TemplateFolder%>/inc/jquery.easydrag.handler.beta2.js"></script>
		<script type="text/javascript" src="<%=webSite %>Template/<%=config.TemplateFolder%>/inc/multi_popup.js"></script>
		<link type="text/css" rel="stylesheet" href="style/multi_popup.css" />
		<style type="text/css">
            /*弹出窗口*/
            .popupWindow{position: absolute; z-index: 100;display: none;background-color:#FFFFFF;border:solid 1px #ccc;width: 550px; }
            .popupHead{}
            .popupTitle{}
            .popupClose{}
            .popupContent{padding:0px;width:100%;max-height:350px;height:expression( this.scrollHeight > 350 ? "350px" : "auto" );overflow-y:auto;}
            .tips{font-size:14px;height:30px;padding-left:15px;padding-top:10px}
            .item{font-size:12px;padding-left:15px}
            .popupFooter{width:100%;text-align:center;margin:10px 0 10px 0}
            .btn{height:20px;}
             #maskLayer{background-color:#e3e3e3; position:absolute; z-index:99; left:0; top:0; display:none; width:100%; height:1000px;opacity:0.5;filter: alpha(opacity=50);-moz-opacity: 0.5;}
 	    </style>		
		<script type="text/javascript">
		    $(document).ready(function(){
                var pageH = $(document.body).height();
                var pageW = $(document.body).width();
                var winH = $(window).height();
                var maxH = Math.max(winH, pageH);
                                		        
		        $(window).resize(function() {
		            $('#SendGoodsDiv').css("left",($(window).width()-$('#SendGoodsDiv').width())/2);
		            $('#SendGoodsDiv').css("top",$(window).scrollTop()+($(window).height()-$('#SendGoodsDiv').height())/2);
                });

                $(window).scroll(function() {
		            $('#SendGoodsDiv').css("top",$(window).scrollTop()+($(window).height()-$('#SendGoodsDiv').height())/2);
		            $('#CancelDiv').css("top",$(window).scrollTop()+($(window).height()-$('#CancelDiv').height())/2);
                });

                //发货单
		        $('#doSend').click(function(){
		            $('#SendGoodsDiv').css("left",($(window).width()-$('#SendGoodsDiv').width())/2);
                    $('#SendGoodsDiv').css("top",$(window).scrollTop()+($(window).height()-$('#SendGoodsDiv').height())/2);
                    $('#SendGoodsDiv').show();
                    $('#maskLayer').show().width(pageW).height(maxH);
     	        });
                $('#closeSend').click(function(){
		            $('#SendGoodsDiv').hide();
		            $('#maskLayer').hide();
		        });
                $('#btnSend').click(function(){
		            if(!CheckSend())
		            return false;
		            if(confirm("这个操作将会改变订单的状态，确定发货吗?"))
		            return true;
		            else
		            return false;
		        });
		        
		        //取消订单
		        $('#doCancel').click(function(){
		            $('#CancelDiv').css("left",($(window).width()-$('#CancelDiv').width())/2);
                    $('#CancelDiv').css("top",$(window).scrollTop()+($(window).height()-$('#CancelDiv').height())/2);
		            $('#CancelDiv').show();
                    $('#maskLayer').show().width(pageW).height(maxH);              
		        })
                $('#closeCancel').click(function(){
		            $('#CancelDiv').hide();
		            $('#maskLayer').hide();
                });
                $('#btnCancel').click(function(){
		            if(confirm("这个操作将会改变订单的状态，取消这个订单吗?"))
		            return true;
		            else
		            return false;
		        });
		        
                //货到付款，确认订单
                $('#doConfirm').click(function(){
		            $('#ConfirmDiv').css("left",($(window).width()-$('#ConfirmDiv').width())/2);
		            $('#ConfirmDiv').css("top",$(window).scrollTop()+($(window).height()-$('#ConfirmDiv').height())/2);
		            $('#ConfirmDiv').show();
                    $('#maskLayer').show().width(pageW).height(maxH);         
		        })
                $('#closeConfirm').click(function(){
		            $('#ConfirmDiv').hide();
		            $('#maskLayer').hide();
		        });		        
                $('#btnConfirm').click(function(){
		            if(confirm("这个操作将会改变订单的状态，确定这个订单吗?"))
		            return true;
		            else
		            return false;
		        });	
		        
	            //发货表中的物流公司	            
                 $('#ddlExpress').change(function(){
                    if($('#ddlExpress :selected').val()=="0"){
		                $('input[name=txtExpress]').val("");
		            }
                    else if($('#ddlExpress :selected').val()=="门店自提"){
		                $('input[name=txtExpress]').val($('#ddlExpress :selected').text());
		                $('input[name=txtTransNum]').val('门店自提,无需物流单号');
		            }
		            else{
		                $('input[name=txtExpress]').val($('#ddlExpress :selected').text());
		            }
		        });		        
		        
		        //检查发货表单中的数据
                function CheckSend(){
                    if($('input[name=txtExpress]').val()==''){
                        alert("物流公司不能为空");
                        $('input[name=txtExpress]').focus();
                        return false 
                    }
                    if($('#txtTransNum').val()==''){
                        alert("物流单号不能为空");
                        $('#txtTransNum').focus();
                        return false 
                    }
                    if(!CheckLength('#txtTransNum',50)){
                        alert("物流单号长度不能超过50个字符");
                        $('#txtTransNum').focus();
                        return false;
                    }
                    return true;                     
                }  	
                //检测长度是否符合要求
                function CheckLength(element,maxLen){
                    if($(element).val().length>maxLen)
                    return false;
                    return true;
                }                	        
		    });
		</script>
		</head>
				
	<body>
	    <!-- 遮罩层 -->
	    <div id=maskLayer></div>

			<uc1:Header id="Header1" runat="server"></uc1:Header>
			 <!--位置导航开始-->
			 <div class="path"><a href="<%=webSite%>supplier/default.<%=config.html%>">商家桌面</a> >  订单管理 >订单处理 >
                 <asp:Label ID="lblTitleInfo" runat="server" Text="订单详情"></asp:Label></div>
			<!--位置导航结束-->
			<div class="xp-w clear">
				<div class="content-left">
					<!--会员中心导航开始-->
					<uc1:SupplierMenu id="SupplierMenu1" runat="server"></uc1:SupplierMenu>
					<!--会员中心导航结束-->
				</div>
				<div class="content-middle">	

                    <%--<h3>欢迎您,<%=CurrentSupplier.RealName%></h3>
                    <hr class="itemhr" />--%>
                    <div class="rframe">
                        <div class="tm">订单详情</div>
                        <div class="mm clear">
                            <div style="height: 35px;">
                                <span  style="font-size: 14px;font-weight: bold;line-height:35px;padding-left:10px">
                                 <asp:Label ID="lblProcedure" runat="server" Text="订单处理流程"></asp:Label>
                                </span>
                            </div>					 
                            <div class="detail_title">>订单操作:</div>
                            <div class="detail_top"></div>
                            <div class="detail_frame">
                                <table width="100%" cellspacing="0" cellpadding="0">
                                    <tbody>
                                        <tr>
                                            <th width="20%">操作角色</th>
                                            <th width="30%">操作时间</th>
                                            <th width="50%">操作</th>
                                        </tr>
                                        <asp:repeater id="rptOrderOpt" Runat="server">
                                            <ItemTemplate>
                                                <tr>
                                                    <td><%# DataBinder.Eval(Container.DataItem, "OpRule")%></td>
                                                    <td><%# DataBinder.Eval(Container.DataItem, "OPTime")%></td>
                                                    <td><%# DataBinder.Eval(Container.DataItem, "OPDesc")%></td>
                                                </tr>
                                            </ItemTemplate>
                                        </asp:repeater>
                                       <%
                                            if (order.Status <=2 && order.PayType >=5 )
                                            {%>
                                            <tr>
                                                <td>商家</td>
                                                <td>------</td>
                                                <td>
                                                <a id="doConfirm" style="cursor:pointer;color:blue">确认订单</a>(货到付款的订单要商家先确认订单)<br />
                                                </td>
                                            </tr>
                                        <%
                                            }%>
                                            
                                        <%if (((order.Status >= 2 && order.Status <= 5) && order.PayType <= 4) || (order.Status == 3 && order.PayType >= 5 ))
                                          { %>
                                            <tr>
                                                <td>商家</td>
                                                <td></td>
                                                <td>
                                                <a id="doSend" style="cursor:pointer;color:blue">发货</a>(可进行全部或部分发货)<br />
                                                <a id="doCancel" style="cursor:pointer;color:blue">取消订单</a>(全部缺货、无法配送等时可取消订单,进行退款) 
                                                </td>
                                            </tr>
                                        <%} %>

                                    </tbody>
                                </table>
                            </div>

    				        <div class="detail_title">>订单详情:</div>
    				        <span>&nbsp&nbsp订单号:<%=order.OrderNo%></span>
            				
					        <div class="detail_top"></div>
					        <div class="detail_frame">
					            <h2>商品清单</h2>
                                <table class="product" cellspacing="0" cellpadding="0">
                                <asp:Repeater ID="rptProduct" runat="server" >
                                    <HeaderTemplate>
                                        <thead>
                                            <tr class="datagrid-header">
                                                <th width="15%" align="center">商品编号</th>
                                                <th width="48%" align="center">商品名称</th>
                                                <th width="10%" align="center">购买价格</th>
                                                <th width="10%" align="center">已优惠</th>
                                                <th width="10%" align="center">赠送积分</th>
                                                <th width="10%" align="center">购买数量</th>
	                                        </tr>
                                        </thead>
                                    </HeaderTemplate>
                                        <ItemTemplate>
                                            <tr class="datagrid-item">
                                            <td align="center"><%# DataBinder.Eval(Container.DataItem, "ProductNo")%></td>
                                            <td align="center">
                                            <a href='<%=webSite %>products/product-<%# DataBinder.Eval(Container.DataItem, "ProductID") %>.<%=config.html %>' target="_blank" style="color:#3665cd;">
                                            <%# DataBinder.Eval(Container.DataItem, "ProductName") %></a>
                                            </td>
                                            <td align="center"><%# DataBinder.Eval(Container.DataItem, "UnitPrice")%></td>
                                            <td align="center"><%# DataBinder.Eval(Container.DataItem, "LessMoney")%></td>
                                            <td align="center"><%# DataBinder.Eval(Container.DataItem, "Score")%></td>
                                            <td align="center"><%# DataBinder.Eval(Container.DataItem, "Quantity")%></td>
                                            </tr>
	                                     </ItemTemplate>
                                </asp:Repeater>
                                </table>

					            <table class="price" cellspacing="0" cellpadding="0">
					                <colgroup> 
                                    <col class="col1" /> 
                                    <col class="col2" />
                                    </colgroup>
					                <tbody>
					                <tr>
					                <td align="right"><%=GetResourceString("ProductPrice")%>:</td>
					                <td><%=string.Format("{0:f}", order.ProductPrice)%></td>
					                </tr>
					                <tr>
					                <td>发票税金:</td>
					                <td ><%=string.Format("{0:f}", order.TaxPrice)%></td>
					                </tr>
					                <tr>
					                <td><%=GetResourceString("OrderEmail_ShipPrice")%>:</td>
					                <td><%=string.Format("{0:f}", order.ShipPrice)%><%
                                    if (order.IsShippingFree == 1)
                                    {%>(<%=
                                            GetResourceString("ShippingFree")%>)<%
                                    }%></td>
					                </tr>
					                <tr>
					                <td><%=GetResourceString("OrderEmail_AdvancePayment")%>:</td>
					                <td><%=string.Format("{0:f}", order.AdvancePayment)%></td>
					                </tr>
					                <tr>
					                <td>积分抵消金额:</td>
					                <td><%=string.Format("{0:f}", order.ScoreAmount)%></td>
					                </tr>
					                <tr>
					                <td>订单总金额:</td>
					                <td><%=string.Format("{0:f}", order.TotalPrice)%></td>
					                </tr>
					                </tbody>
					            </table>
					            <div class="price_total">顾客需为订单支付现金:<%=GetPay()%></div>
					        </div>
					        <div class="detail_frame">
					            <h2>收货人信息</h2>
					            <ul>
					                <li>收 货 人：<%=order.ReceiverName%></li>	
					                <li>收货地址：<%=order.ReceiverAddress%></li>
					                <li>联系电话：<%=order.ReceiverPhone%></li>	
					            </ul>
					        </div>
					        <div class="detail_frame">
					            <h2>送货方式</h2>
					            <ul>
                                    <li><%=GetResourceString("ShippingWay")%>：<%=GetShippingName(order.ShippingType)%></li>
      				            </ul>
					        </div>
					        <div class="detail_frame">
					            <h2>支付方式</h2>
					            <ul>
                                    <li><%=GetResourceString("PaymentInfo")%>：<%=GetPayType(order.PayType)%></li>
      				            </ul>
					        </div>
					        <%if(order.NeedInvoice){%>
                            <div class="detail_frame">
					            <h2>发票信息</h2>
					            <ul>
                                    <li>发票类型：<%=orderInvoice.InvoiceType == 0 ? "普通发票" : "增值税发票"%> </li>
                                    <li>发票抬头：<%=orderInvoice.InvoiceHead%></li>
                                    <li>发票内容：<%=orderInvoice.IsDetails ? orderInvoice.InvoiceContent : "商品明细"%></li>
                                </ul>                  
					        </div>
					        <%}%>
                        </div>
                    </div>
		        </div>
			</div>	
		<uc1:Helper id="Helper" runat="server"></uc1:Helper>
		<uc1:Footer id="Footer" runat="server"></uc1:Footer>		

          <form runat=server>
          
            <div id="ConfirmDiv" class="popupWindow" style="width:350px;" >
                <div class="popupHead">
                <div class="popupTitle">确认订单</div>
                <div class="popupClose" id="closeConfirm"><span id="Span5">×</span></div>
                <div class="clear" ></div>
                </div>
                <div class="popupContent">
                <div class="tips">请选择确认方式</div>
                <div>
                    <div class="item"><input type="radio" value="已通过电话确认订单" name="confirmRemark" checked=checked >已跟顾客通过电话确认订单</div>
                    <div class="item"><input type="radio" value="已通过其它方式确认订单" name="confirmRemark">已跟顾客通过其它方式确认订单</div>
                </div>
                </div>
                <div class="popupFooter" >
                        <asp:button text="确认订单" class="btn" id="btnConfirm" runat=server onclick="btnConfirm_Click" />
                </div>
            </div>
                           
		    <div id="SendGoodsDiv" class="popupWindow" >
	                <div class="popupHead">
                        <div class="popupTitle">发货</div>
                        <div class="popupClose" id="closesend"><span id="closeSend">×</span></div>
                        <div class="clear" ></div>
                    </div>
                    <div class="popupContent">
                        <table style="width:100%;" class="thinBorder">
                            <tr>
                                <td style="width:15%;">订单号：</td>
                                <td style="width:35%;"><%=order.OrderNo%><input type="hidden" id="orderid" name="orderid" value="<%=order.OrderID%>" /></td>
                                <td style="width:15%">下订日期：</td>
                                <td style="width:35%;"><%=order.OrderTime%></td>
                            </tr>
                            <tr>
                                <td>配送方式：</td>
                                <td>
                                    <div>
                                      <asp:DropDownList ID=ddlShippingName runat=server>
                                      </asp:DropDownList>
                                    </div>
                                </td>
                                <td>物流公司：</td>
                                <td>
                                    <div>
                                        <input type="text" id="txtExpress" name="txtExpress"/><em>*</em>
                                        <asp:DropDownList ID=ddlExpress runat=server>
                                        </asp:DropDownList>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td>物流单号：</td>
                                <td>
                                    <span><asp:TextBox ID=txtTransNum runat=server></asp:TextBox><em>*</em><br />(最多输入50个字符)</span>
                                </td>
                                <td>配送费用：</td>
                                <td><input type="text" name="txtSendShippingPrice" value="<%=order.ShipPrice%>" /></td>
                            </tr>
                            <tr>
                                <td><span id="span1">收货人</span>：</td>
                                <td><input type="text" name="txtSendReceiverName" value="<%=order.ReceiverName%>" /></td>
                                <td>E-mail：</td>
                                <td><input type="text" name="txtSendReceiverEmail" value="<%=order.ReceiverEmail%>" /></td>
                            </tr>
                            <tr>
                                <td>联系电话：</td>
                                <td><input type="text" name="txtSendReceiverPhone" value="<%=order.ReceiverPhone%>"/></td>
                                <td>邮政编码：</td>
                                <td><input type="text" name="txtSendReceiverPostalCode" value="<%=order.ReceiverPostalcode%>" /></td>
                            </tr>
                            <tr>
                                <td>地址：</td>
                                <td colspan="3"><input type="text" name="txtSendReceiverAdress" size="50" value="<%=order.ReceiverAddress%>" /></td>
                            </tr>
                            <tr>
                                <td><span id="span2">发货备注</span>：</td>
                                <td colspan="3"><textarea id="areaShippingRemark" name="tarSendShippingRemark" cols="50" rows="5" ></textarea><br />(最多255个字符)</td>
                            </tr>
                        </table>
                        <div class="tips">请确认发货的商品及数量：(货到付款的订单只支持全部发货)</div>
                        <div class="item">
                            <div style="padding-left: 10px;">
                            <span style="width: 400px; float: left;"><b>商品名称</b></span>
                            <span style="text-align: center; width: 60px; float: left;"><b>发货数量</b></span></div>
                                <asp:Repeater ID="rptSendProduct" runat="server" >
                                      <ItemTemplate>
                                            <div style="padding-left: 10px ;">
                                                <span style="width: 400px; float: left;margin:5px 0px;"><%# DataBinder.Eval(Container.DataItem, "ProductName") %></span>
                                                <input type=hidden name="pdtID" value="<%# DataBinder.Eval(Container.DataItem, "ProductID") %>">
                                                <input type=hidden name="goodsID" value="<%# DataBinder.Eval(Container.DataItem, "GoodsID") %>">
                                                <input type=hidden name="pdtName" value="<%# DataBinder.Eval(Container.DataItem, "ProductName") %>">
                                                <span style="width: 60px; text-align: center; float: left;margin:5px 0px">
                                                   <%# CreateSelect(Convert.ToInt32(DataBinder.Eval(Container.DataItem, "PayType")),Convert.ToInt32(DataBinder.Eval(Container.DataItem, "Stockout")))%>
                                                </span>
                                            </div>
		                               </ItemTemplate> 
                                </asp:Repeater> 
                            <input type=hidden name="orderQuantity" value=<%=order.Quantity%>>
                            <div style="clear:both"></div>
                        </div>
                    </div>
                    <div class="popupFooter">
                        <asp:button text="确认发货" class="btn" id="btnSend" runat=server onclick="btnSend_Click" />
                    </div>
            </div>
            
            <div id="CancelDiv" class="popupWindow" style="width:350px;" >
                <div class="popupHead">
                    <div class="popupTitle">取消订单</div>
                    <div class="popupClose" id="closeCancel"><span id="Span3">×</span></div>
                    <div class="clear" ></div>
                </div>
                <div class="popupContent">
                    <div class="tips">  请选择取消订单的理由</div>
                    <div>
                        <div class="item"><input type="radio" value="缺货,取消订单" name="cancelRemark" checked=checked >全部缺货</div>
                        <div class="item"><input type="radio" value="无法送达,取消订单" name="cancelRemark">无法送达</div>
                        <div class="item"><input type="radio" value="顾客要求退款,取消订单" name="cancelRemark">顾客要求退款</div>
                        <div class="item"><input type="radio" value="其它原因,取消订单" name="cancelRemark">其它原因</div>
                    </div>
                </div>
                <div class="popupFooter">
                        <asp:button text="确认取消" class="btn" id="btnCancel" runat=server onclick="btnCancel_Click" />
                </div>
            </div>
        </form>

    </body>
</html>