<%@ Control Language="C#" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.HtmlTags" %>
<%@ Import Namespace="Kesion.APPCode" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Kesion.Course" %>
<script runat="server" type="text/C#">
    dynamic __user = HttpContext.Current.Items["user"];                //初始化用户信息，
    private static dynamic __info = new System.Dynamic.ExpandoObject();   //初始化当前页信息
    bool isLoadPage = true;  //定义页面是否加载

    public static int CourseId = 0;
    public static int ZLID;
    public static string name;
    public static int type;
    public static string DefaultFile = string.Empty;
    public static string photourl = string.Empty;
    public static string CourseName = string.Empty;
    public static float price_meber = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        CourseId = Utils.StrToInt(KSCMS.S("CourseId"));
        string sql1 = "";
        if (CourseId != 0)
        {
            if (type == 0)
            {
                sql1 = "select top 1 Name,Price_Member,isfree from KS_Course where CourseId = " + CourseId;
            }
            using (DataTable dt = DataFactory.GetDataTable(sql1))
            {
                if (dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];
                    CourseName = dr["name"].ToString();

                }
            }
        }
        if (KSCMS.S("do").Equals("del"))
        {
            if (KSCMS.S("zlid") != "" || KSCMS.S("zlid") != null)
            {
                deleteSj(KSCMS.S("zlid"));
                CourseId = Utils.StrToInt(KSCMS.S("courseId"));
            }
            else
            {
                deleteSj(KSCMS.S("ids"));
            }
        }
        if (KSCMS.S("do").Equals("IsPublic"))  //状态
        {
            CommonData.UpdateFieldStatus("KS_CosZL", "verify", "Zlid", Utils.StrToInt(KSCMS.S("Zlid")));
            KSCMS.Redirect(KSCMS.GetComeUrl());
            isLoadPage = false;
            return;
        }
    }

    private void deleteSj(string pjid)
    {
        if (pjid == null || pjid == "0") return;
        DataTable dt = DataFactory.GetDataTable("select userId,username from KS_User where userid in (" + pjid + ")");
        if (dt.Rows.Count > 0)
        {
            foreach (DataRow dr in dt.Rows)
            {
                Kesion.Course.CourseLearnRecordCache.CleanUserLearnRecordFromDB(Utils.StrToInt(dr["UserID"].ToString()), CourseId);
            }
        }
        Msg.Alert("恭喜,清空成功!", BasicField.GetUserUrl("teacher/TcSchedule"));
        isLoadPage = false;
        return;
    }

	  </script>
<%
    if (!isLoadPage) return;
%>
     <div class="t_tybox">
	 	  <form name="myform" action="<%=BasicField.GetUserUrl("course/TcSchedule") %>" method="post" id="myform" >
		<div class="tytitle"><h4>学员进度</h4>
			<a onclick="window.history.go(-1);" class="addbtn">返回</a>
		</div>
		<div class="clear blank10"></div>
     	<div class="top_c_sc">
    	</div>
		<div class="part_now">当前课程：<%=CourseName %></div>
        <div class="clear blank10"></div>
  
            <table id="tablist" width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
            <tr align="center" class="title">
                 <td width="8%" align="center">选择</td>
				 <td width="8%" align="center">序号</td>
                 <td width="20%" align="center">学员名称</td>
                 <td width="39%">学习进度</td>              
                 <td width="15%">最后标记日期</td>
                 <td align="center" nowrap width="10%">操作</td>
              </tr>
  <%
	  	 int recordcount, pagecount;
					 int CurrPage = new BasicField().GetCurrPage;
					 int PageSize = 10;
					 string sqlParam = " KS_CosOrderItem where courseid=" + CourseId + " ";

					 using (DataTable dt = DataFactory.GetPage("*", sqlParam, "ID", " order by  ID DESC", CurrPage, PageSize, out recordcount, out pagecount))
					 {
						 if (dt.Rows.Count > 0)
						 {
							 int i = (CurrPage - 1) * PageSize + 1;
							 foreach (DataRow dr in dt.Rows)
							 {
								 KSCMS.W("<TR class=\"tdbg sort bar\"><td height=\"38\" align=\"center\" nowrap><input type=\"checkbox\"  name=\"ids\" id=\"ids\" value=\"" + dr["userid"].ToString() + "\" class=\"checkbtn\" /></td><td align=\"center\">" + i + "</td> <td class=\"Ctd\" align=\"center\">" + dr["username"].ToString() + "</td>");
								 KSCMS.W("	<td class=\"tag_left lefticon\">" + Kesion.Course.CourseLearnRecordCache.GetLearnProcess(Utils.StrToInt(dr["UserID"].ToString()),CourseId) + " </td> <td align=\"center\">" + Kesion.Course.CourseLearnRecordCache.GetUserLearnJsonNodeValue(Utils.StrToInt(dr["userid"].ToString()),"lastdate",CourseId) + " </td>");
								 KSCMS.W(" <td style=\"text-align:center\" nowrap><div class=\"gl_btn\"> <span class=\"span5\" style=\"width:100%\"><a href=\"" + BasicField.GetUserUrl("teacher/TcSchedule", "do-del,zlid-" + dr["userid"].ToString() + ",courseid-" + dr["courseid"].ToString() + "") + " \" onclick=\"return confirm('确认清空吗?\n如果要清空,请点确认,否则请取消.')\"><i class=\"iconfont\">&#xe637;</i>清空</a> </span></div></td></TR>");
							 }
						 }
						 else
						 {
							 KSCMS.W("<tr class=\"tdbg\"><td class=\"Ctd\" style=\"text-align:center\" colspan=\"15\"><div class=\"empty\">暂未无学员进度</div></td></tr> ");
						 }
					 }
	   %>

           </table>

		   
			<div class="cz_btn">        
         	<span><input type="checkbox" class="checkbtn" name="chkall" id="chkall" onclick="CheckAll(this.form);" /><label for="chkall">全部选中</label></span>		   
           <span>
		   <input type="submit" class="button" value="批量清空" onclick="return (GetIDS());">
            </span>
        </div> 
			<div class="clear"></div>
            
		    <div class="fy_box" style="margin-top:0px;border-top:0px;"> <%
            #region 分页
            string PageStr = "[KS:PageStr2]";
            BasicField.ReplaceFilterPage(ref PageStr, CurrPage, PageSize, pagecount, recordcount);
            KSCMS.W(PageStr);
            #endregion
         %></div>
		 	  </form>
		<script>
			$(function () {
				//获取进度百分比
				$(".schedule").each(function () {
					var a = $(this).find(".nowid").text() / $(this).find(".total").text() * 100;
					$(this).find(".lineBg").animate({ width: "" + a + "%" }, 300);
				});
			});
        </script>
		</div>
