<%@ Page ValidateRequest="false" Language="C#" MasterPageFile="~/Views/Shared/ExhibitorMaster.Master"
    Inherits="System.Web.Mvc.ViewPage<FamousFurnitureExpo.Models.Actor>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script language="javascript" type="text/javascript">
        $(function () {
            $("#CurrentPosition").html("定制邀请函");
            $("#mainmenu5").css("visibility", "visible");
        });
        function GoTo(str) {
            document.location = "<%=FamousFurnitureExpo.Models.Helper.VRoot %>/Exhibitor/" + str;
        }
        
        function jscheckEmail(email) {
            var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
            return reg.test(email);
        }
        function jscheckMobile(mobile) {
            var reg = /^[0-9]{7,20}$/;
            return reg.test(mobile);
        }
        //邮件发送
        function sendemail() {
            var email = $("#ImeEmail").val();
            if (email == "") {
                alert("请至少输入一个邀请邮箱！");
                $("#ImeEmail").focus();
                return;
            }
            var regReplace = new RegExp("，", "g");
            email = email.replace(regReplace, ",");
            $("#ImeEmail").val(email);
            var ArrMail = email.split(',');
            for (var i = 0; i < ArrMail.length; i++) {
                if (!jscheckEmail(ArrMail[i])) {
                    alert("邀请邮箱格式不正确！");
                    $("#ImeEmail").focus();
                    return;
                }
            }
            //            document.getElementById("ImeEmailInfo").value = editor.html();
            document.getElementById("sendtype").value = "1";
            document.getElementById("ImeEmailInfo").value = $("#contentEmail").html();
            document.getElementById("f2").submit();
        }
        //短信发送
        function sendMsg() {
            var mobile = $("#ImeMobile").val();
            if (mobile == "") {
                alert("请至少输入一个手机号码！");
                $("#ImeMobile").focus();
                return;
            }
            var regReplace = new RegExp("，", "g");
            mobile = mobile.replace(regReplace, ",");
            $("#ImeMobile").val(mobile);
            var ArrMobile = mobile.split(',');
            for (var i = 0; i < ArrMobile.length; i++) {
                if (!jscheckMobile(ArrMobile[i])) {
                    alert("手机号码格式不正确！");
                    $("#ImeMobile").focus();
                    return;
                }
            }
            document.getElementById("sendtype").value = "2";
            document.getElementById("ImeMobileInfo").value = $("#contentMobile").html();
            document.getElementById("f2").submit();
        }
        function changersendtype(id) {
            if (id == 1) {
                document.getElementById("tableMobileinfo").style.display = "none";
                document.getElementById("tableEmailInfo").style.display = "";
            }

            if (id == 2) {
                document.getElementById("tableMobileinfo").style.display = "";
                document.getElementById("tableEmailInfo").style.display = "none";
            }
        }

        function ShowInfo(id) {
            var ifCheck = $("#selProduct" + id).find("input[type=checkbox]").attr("checked");
            if (ifCheck) {
                var src = $("#selProduct" + id).find("img").attr("src");
                var name = $("#selProduct" + id).attr("pname");
                var intro = $("#selProduct" + id).attr("pintro");
                //alert(src + ":" + name + ":" + intro);
                var addhtml = "";
                addhtml += "<div id='showProduct" + id + "'>";
                addhtml += "<table width='100%' border='0' cellpadding='3' cellspacing='0'  style='border:1px solid #bfefff;'>";
                addhtml += "<tr>";
                addhtml += "<td rowspan='2' width='180'><img alt='' width='180' height='120' src='" + src + "' /></td>";
                addhtml += "<td valign='top' width='100'>产品名称：</td>";
                addhtml += "<td valign='top' align='left'>" + name + "</td>";
                addhtml += "</tr><tr>";
                addhtml += "<td valign='top'>产品介绍：</td>";
                addhtml += "<td valign='top' align='left'>" + intro.replace(new RegExp("\n", "gm"), "<br />") + "</td>";
                addhtml += "</tr>";
                addhtml += "</table>";
                addhtml += "</div>";

                var intro = $("#ProductInfo").append(addhtml);
            } else {
                $("#ProductInfo").find("div[id='showProduct" + id + "']").remove();
            }
        }

        function SaveInviteCard() {
            var num = $("#CardNum").val();
            var reg = /^[0-9]{1,}$/g;
            if (reg.test(num)) {
                $.ajax({
                    type: "POST",
                    data: "num=" + num,
                    async: false,
                    url: "<%=FamousFurnitureExpo.Models.Helper.VRoot %>/Exhibitor/SaveInviteCardNum",
                    success: function (data) {
                        if (data != "") {
                            alert("保存成功！");
                        }
                    }
                });
            } else {
                alert("请输入数量！");
            }
        }
    </script>
    <%=ViewData["Msg"]%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <center>
            <form id="f2" name="f2" method="post" action="">
            <table width="100%" border="0" style="text-align: left" cellpadding="0" cellspacing="0"
                id="main">
                <tr style="display:none">
                    <td align="left">
                        <table border='0' cellpadding="0" cellspacing="0" width="100%" align="left">
                            <tr>
                                <td class="tdMenuSelect" onclick="GoTo('VisitorInvite')">
                                    邀请注册
                                </td>
                                <td class="tdMenuWidth">&nbsp;</td>
                                <td class="tdMenu" onclick="GoTo('VisitorInviteCount')">
                                    邀请统计
                                </td>
                                <td>&nbsp;</td>
                            </tr>
                            <tr>
                                <td class="tdMenuLine" colspan="4"></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr style="display:none">
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;
                        <%
                            string exhName = Session["ExhName"].ToString();
                            DateTime exhBTime = Convert.ToDateTime(Session["ExhBTime"]);
                            DateTime exhETime = Convert.ToDateTime(Session["ExhETime"]);
                            string showDate = "";
                            if (exhBTime.Year == exhETime.Year && exhBTime.Month == exhETime.Month)
                            {
                                showDate = exhBTime.Year + "." + exhBTime.Month + "." + exhBTime.Day + "-" + exhETime.Day;
                            }
                            else if (exhBTime.Year == exhETime.Year)
                            {
                                showDate = exhBTime.Year + "." + exhBTime.Month + "." + exhBTime.Day + "-" + exhETime.Month + "." + exhETime.Day;
                            }
                            else
                            {
                                showDate = exhBTime.Year + "." + exhBTime.Month + "." + exhBTime.Day + "-" + exhETime.Year + "." + exhETime.Month + "." + exhETime.Day;
                            }

                            string mobileMessage = "您好，" + Server.HtmlEncode(Model.AtrName) + "邀请您一同参观" + showDate + "的" + exhName + "。";
                        %>
                    </td>
                </tr>
                <tr>
                    <td valign="top" align="left" bgcolor="#ffffff">
                        <table border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td></td>
                                <td>
                                    <div style="padding: 15px;display:none">
                                        <input name="email1" id="email1" value="邮件邀请" type="radio" checked="checked" onclick="changersendtype(1)" /><label
                                            for="email1">邮件邀请</label>
                                        <%--<input name="email1" id="mobile1" value="短信邀请" type="radio" onclick="changersendtype(2)" /><label
                                            for="mobile1">短信邀请</label>--%>
                                        
                                    </div>
                                    <input name="sendtype" id="sendtype" value="1" type="hidden" />
                                    <table width="100%" border="0" cellspacing="0" cellpadding="3" id="tableEmailInfo">
                                        <tr>
                                            <td class="tdright" width="100px">
                                                发件人：
                                            </td>
                                            <td class="tdleft">
                                                <input type="text" class="text" name="SenderName" id="SenderName" value="<%=Server.HtmlEncode(Model.AtrName) %>" readonly="readonly"
                                                    style="color: #000;" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="tdright">
                                                E-mail：
                                            </td>
                                            <td class="tdleft">
                                                <input type="text" class="text" name="ImeEmail" id="ImeEmail" value="" />
                                                <span>发给多个收件人，请将邮箱用英文逗号隔开</span>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="tdright">
                                                邮件标题：
                                            </td>
                                            <td class="tdleft">
                                                <input type="text" class="text" name="SendEmailTitle" id="SendEmailTitle" value="<%=Server.HtmlEncode(Model.AtrName) %>邀请您参观<%=Session["ExhName"] %>"
                                                    style="width: 400px; color: #000;" /><div style="float:right" class="button" onclick="javascript:sendemail();">发送</div>
                                                <input id="ImeEmailInfo" name="ImeEmailInfo" value="" type="hidden" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="tdright">
                                                
                                            </td>
                                            <td class="tdleft">
                                                <font color="red">请先在会刊页面上传LOGO</font>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="tdright">
                                                发送内容：
                                            </td>
                                            <td class="tdleft">
                                                <div style="width: 609px; border: solid 1px #cccccc;font-family: Arial, Helvetica, sans-serif;line-height: 25px;font-size: 12px;color: #333;" id="contentEmail" name="contentEmail" >
                                                    <table width="600px"  align="center" style="background-image:url(http://servicecenter.petfairasia.com/APFA/DataFile/ExhSettingFiles/1/pfa-yaoqinghan.jpg);height:900px" border="0">
                                                        <tr>
                                                        <td width="600px" valign="bottom" style="height:290px">
                                                            <div style="text-align:center;vertical-align:top;"><img src="<%=ViewData["LogoUrl"] %>" border="0"></div>
                                                        </td>
                                                        </tr>
                                                        <tr>
                                                        <td width="600px" valign="bottom" style="height:140px">
                                                            <div style="text-align:center;vertical-align:top;font-size:14px;font-weight:bold;color:White;font-family: 微软雅黑"><%=Server.HtmlEncode(Model.AtrName) %></div>
                                                        </td>
                                                        </tr>
                                                        <tr>
                                                        <td width="600px" valign="bottom" style="top:20px;height:220px">
                                                            <div style="text-align:center;vertical-align:top;font-size:14px;font-weight:bold;color:White;font-family: 微软雅黑"><%=ViewData["BthCodeNum"]%></div>
                                                        </td>
                                                        </tr>
                                                        <tr>
                                                        <td width="600px"  valign="bottom"  align="center"  style="height:70px">
                                                            <a href="<%=ViewData["LinkUrl"] %>"  target="_blank"  style="cursor:pointer"><div style="border:0 solid;height:46px;width:187px"></div></a>
                                                        </td>
                                                        </tr>
                                                        <tr>
                                                        <td width="600px" valign="bottom" style="text-align:center;height:170px">
        
                                                        </td>
                                                        </tr>
                                                    </table>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr style="display:none">
                                            <td align="right">产品信息：</td>
                                            <td align="left">
                                                <div style="width: 450px; height:200px; padding:10px; overflow:auto;" class="text" id="selectProduct">
                                                    <table border='0' cellpadding='0' cellspacing='0' width='100%'>
                                                        <tr>
                                                            <td colspan="5" align="center">
                                                                <font color="red">您可以选择您上传的产品信息和图片一起发送给您邀请的观众</font>&nbsp;&nbsp;
                                                                <a href="<%=FamousFurnitureExpo.Models.Helper.VRoot %>/Exhibitor/ProductList">点击添加产品信息</a>
                                                            </td>
                                                        </tr>
                                        <%
                                            System.Data.DataTable dtProduct = ViewData["Product"] as System.Data.DataTable;
                                            if (dtProduct.Rows.Count > 0)
                                            {
                                                int colNum = 4;
                                                int num = 1;
                                                Response.Write("<tr>");
                                                foreach (System.Data.DataRow drProduct in dtProduct.Rows)
                                                {
                                                    if (num != 1 && num % colNum == 1)
                                                    {
                                                        Response.Write("</tr><tr>");
                                                    }
                                        %>   
                                            <td align='center' valign="top" width='<%=100/colNum %>%'>
                                                <div id="selProduct<%=drProduct["ID"]%>" pname="<%=Server.HtmlEncode(drProduct["PdtName"].ToString())%>" pintro="<%=Server.HtmlEncode(drProduct["PdtIntro"].ToString()) %>">
                                                    <img alt="" width="90" height="60" src="http://<%=FamousFurnitureExpo.Models.Helper.HostName + FamousFurnitureExpo.Models.Helper.VRoot + drProduct["FilSPath"]%>" /><br />
                                                    <input type="checkbox" value="<%=drProduct["ID"]%>" onclick="ShowInfo(<%=drProduct["ID"]%>)" />
                                                    <%=Server.HtmlEncode(drProduct["PdtName"].ToString()) %>
                                                </div>
                                            </td>
                                        <%
                                                    num++;
                                                }
                                                for (int i = 0; i < colNum - num % colNum; i++)
                                                {
                                                    Response.Write("<td></td>");
                                                }
                                                Response.Write("</tr>");
                                            }
                                            else
                                            { 
                                        %>
                                                        <tr>
                                                            <td valign="middle" align="center" height="30px">
                                                                您还没有添加产品信息
                                                            </td>
                                                        </tr>
                                        <%        
                                            }
                                        %>          
                                                    </table>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr style="display:none">
                                            <td class="tdright">
                                                留言：
                                            </td>
                                            <td class="tdleft">
                                                <textarea id="AddMessage" name="AddMessage" style="width: 470px; height: 50px;" class="text"></textarea>
                                            </td>
                                        </tr>

                                        <tr>
                                            <td> &nbsp;</td>
                                        </tr>
                                        <tr>
                                            <td colspan="2" style="text-align: center;">
                                                
                                            </td>
                                        </tr>
                                    </table>
                                    <table width="100%" border="0" cellspacing="0" cellpadding="3" id="tableMobileinfo" style="display: none;">
                                        <tr>
                                            <td class="tdright">
                                                发件人：
                                            </td>
                                            <td class="tdleft">
                                                <input type="text" class="text" name="SenderNameMsg" id="SenderNameMsg" value="<%=Server.HtmlEncode(Model.AtrName) %>" readonly="readonly"
                                                    style="border: 1px solid #CCC; font-size: 12px; color: #000;" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="tdright">
                                                手机号码：
                                            </td>
                                            <td class="tdleft">
                                                <input type="text" name="ImeMobile" id="ImeMobile" value="" class="text" style="font-size: 12px;
                                                    color: #000;" />发给多个收件人，请将手机用英文分号隔开
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="tdright">
                                                发送内容：
                                            </td>
                                            <td class="tdleft">
                                                <div style="width: 450px; height: 300px; padding:10px;" class="text" id="contentMobile" name="contentMobile"><%=mobileMessage %></div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td> &nbsp;</td>
                                        </tr>
                                        <tr>
                                            <td colspan="2" style="text-align: center;">
                                                <div class="button" onclick="javascript:sendMsg();">发送</div>
                                                <input type="hidden" id="ImeMobileInfo" name="ImeMobileInfo" />
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                       
                    </td>
                </tr>
            </table>
            </form>
        </center>
    </div>
</asp:Content>
