Hacked By AnonymousFox

Current Path : C:/AppServ/www/mfu/webengine/mod_cms_group1/
Upload File :
Current File : C:/AppServ/www/mfu/webengine/mod_cms_group1/index-t.php

<? 
include("../lib/session.php"); 
include("../lib/config.php");
include("../lib/connect.php");
include("../lib/function.php");
?>
<html>
<head>
 
<title>Web Engine : <?=$System_Variable_Title?>
</title>
 
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
 
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
<link href="../css/mystyle.css" rel="stylesheet" type="text/css">  
</head> 
<body bgcolor="#E9E6DF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('../../images/thai.gif','../../images/eng.gif','../../images/chaina.gif','../../images/object/topbar-thai-over.gif','../../images/object/topbar-english-over.gif','../images/bullet/lang_over_02_1.gif','../images/bullet/lang_over_01_1.gif')">
<script src="ckeditor.js"></script>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="49%" height="100" align="center" bgcolor="#0866C6" ><img src="../../../timetable_teacher/home/logo.png" width="567" height="102" /></td>
    <td width="51%" align="center" bgcolor="#0866C6" ><table width="60%" border="0" align="right" cellpadding="5" cellspacing="5">
      <tr>
        <td width="31%" rowspan="2"><div align="center">
		<?php
		$sqlpic="select picture from mfu_mod_teacher where Id='$System_Session_User_ID'";
		$querypic=mysql_query($sqlpic);
		$rowpic=mysql_fetch_array($querypic);
if( file_exists("../../upload/member/$rowpic[0]") )
{ ?>
		<img src="../../upload/member/<?=$rowpic[0]?>" alt="Photo" width="87" height="109" border="3" style="border-color:#3984D0" />
		<? }
else
{  ?>
<img src="pic/nopic.jpg" alt="Photo" height="130" border="3" style="border-color:#3984D0" />
<? } ?>
		
		</div></td>
        <td width="69%" class="login"><div align="left">
			<strong><font color="#FFFFFF"> <? if($System_Session_Sex==1){echo"นพ.";}if($System_Session_Sex==2){echo"พญ.";} if($System_Session_Sex==""&&$System_Session_Prefix=="นาย"){echo"นพ.";}if($System_Session_Sex==""&&$System_Session_Prefix=="นาง"){echo"พญ.";}if($System_Session_Sex==""&&$System_Session_Prefix=="นางสาว"){echo"พญ.";}?><?=$System_Session_FullName?></font></strong>
         
        </div></td>
      </tr>
      <tr>
        <td bgcolor="2074CA">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
	</table>
<table width="100%" height="26" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td background="../../images/main/main-t-bg.gif" bgcolor="#162C41" align="center"><p><strong><br>
      <font color="#FFFFFF">ระบบจัดการสื่อการเรียนการสอน</font></strong><br>
    </p>
    <p>&nbsp; </p></td>
  </tr>
</table>
<table width="100%" height="6" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td width="1" bgcolor="#10202F">&nbsp;</td>
  </tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr> 
    <td width="1" bgcolor="#10202F"><img src="../../images/blank.gif" width="1" height="1"></td>
    <td align="center" valign="top"><table width="100%" height="480" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td align="center" valign="top" bgcolor="#E9E6DF"> 
            <table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="16" valign="top" bgcolor="#C4BDB1">&nbsp;</td>
        <td align="center" valign="top" bgcolor="#C4BDB1">&nbsp;</td>
        <td valign="top" bgcolor="#C4BDB1">&nbsp;</td>
      </tr>
      <tr>
        <td width="20" valign="top" background="../images/object/border_03.gif"><img src="../images/object/border_16.gif" width="20" height="83"></td>
        <td align="center" valign="top" bgcolor="#FFFFFF">
		   <? if(strlen($System_Session_User_ID)>0) { ?>
                    <br>
                    <br>
                    <? 
## Load Module Configuration Variable ############################################
include("config.php");

## Default Value ############################################
$SystemModule_defaultPageSize = 10;
$SystemModule_defaultPageShow = 1;
$SystemModule_MaxPage = 20;
$SystemModule_ReduceRange = 10; 		// +,- from current page show
$SystemModule_ASCDESC = "DESC";
$SystemModule_OrderBy = $myModule_Table."_Order";

#########################################################
?>
                    <!-- import the calendar script -->
                    <link rel="stylesheet" type="text/css" href="../css/myCalendarStyle.css">
                    <script type="text/javascript" src="lib/calendar.js"></script>
                    <script type="text/javascript" src="lib/lang/calendar-th.js"></script>
                    <script type="text/javascript" src="lib/loadcalendar.js"></script>
                    <!-- end the calendar script -->
                  <? 
#########################################################
if ($action=="addnew") { 
//$ASCDESC="DESC";
if(strlen($inputYear)>0 && $inputGroupID==4){
	$inputStrFilter=$inputYear."-01-01";
}

if(strlen($inputMonth)>0 && $inputGroupID==2){
	$inputStrFilter=date('Y')."-".$inputMonth."-01";
}

		if( strlen($inputStartDate)>0 && strlen($inputExpireDate)>0 ) {
			if(strcmp($inputStartDate,$inputExpireDate)<1) { 
				// Do nothing.
			} else { 
				// Switch Date
				$myTmp = $inputStartDate;
				$inputStartDate = $inputExpireDate;
				$inputExpireDate = $myTmp;
			}
		}

		if(strlen($inputStartDate)!=10) { $inputStartDate="0000-00-00 00:00:00"; } else { $inputStartDate = $inputStartDate." 00:00:00"; }
		if(strlen($inputExpireDate)!=10) { $inputExpireDate="0000-00-00 00:00:00"; } else { $inputExpireDate= $inputExpireDate." 00:00:00"; }

		$sql = "SELECT COUNT(*) FROM ".$myModule_Table." WHERE ".$myModule_Table."_ModuleKey='$SystemModuleKey' AND ".$myModule_Table."_Language='$System_Session_Language'  ";
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
		$Row=MYSQL_FETCH_ARRAY($Query);
		$MaxOrder = $Row[0]+1;
		if($inputGroupID=="") $inputGroupID=0;	
		
		$sql = "INSERT INTO ".$myModule_Table."(".$myModule_Table."_Subject,".
		$myModule_Table."_By,".
		$myModule_Table."_From,".
		$myModule_Table."_For,".
		$myModule_Table."_GID,".
		$myModule_Table."_Title,".
		$myModule_Table."_PictureFile,".
		//$myModule_Table."_FilterDate,".
		$myModule_Table."_CreateByID,".
		$myModule_Table."_CreateBy,".
		$myModule_Table."_CreateDate,".
		$myModule_Table."_LastUpdate ,".
		$myModule_Table."_StartDate,".
		$myModule_Table."_ExpireDate,".
		$myModule_Table."_Relate,".
		$myModule_Table."_Status,".
		$myModule_Table."_ModuleKey,".
		$myModule_Table."_HTMLFileName,".
		
		$myModule_Table."_Language,".
		$myModule_Table."_Order) VALUES('".changeQuot($inputSubject)."','".changeQuot($inputBy)."','$inputFrom','".changeQuot($inputFor)."','$inputGroupID','".changeQuot($inputTitle)."','',$System_Session_User_ID,'$System_Session_UserName',NOW(),NOW(),'$inputStartDate','$inputExpireDate','".changeQuot($inputRelate)."','".$System_Approve_DefaultStatus."','$SystemModuleKey','$editor1','$System_Session_Language',$MaxOrder)";
	
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");

		$sql="select MAX(moe_mod_wnw_ID) from moe_mod_wnw";
	$query=mysql_query($sql);
	$row=mysql_fetch_array($query);
	$MAXID=$row[0];
	$myrand = rand(1111,9999);
	$exts = explode(".", $_FILES['inputMap']['name']);
	$ext = strtolower(($exts[count($exts) - 1]));	
	$ImageType = $ext;

	if(copy($_FILES["inputMap"]["tmp_name"],"../../upload/download/$MAXID-$myrand.$ImageType")) 
	{ 
	$inputmap=$_FILES["inputMap"]["name"];
	$picmap = "$MAXID-$myrand.$ImageType";
	
    	  $sql="update moe_mod_wnw set moe_mod_wnw_FileDownload='$picmap' where moe_mod_wnw_ID='$MAXID'";
		 
		$query=mysql_query($sql);
	}  
		?>
                    <form action="?" method="post" name="myForm" id="myForm">
                      <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
                      <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
                      <input name="action" type="hidden" id="action">
					  <input type="hidden" id="GroupID" name="GroupID" value="<?=$inputGroupID?>">
                      <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
                      <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
                      <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
                      <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
                      <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
                    </form>
                    <script language="JavaScript" type="text/JavaScript"> document.myForm.submit(); </script>
                    <? 
} 
?>
                    <? 
####################################################################
if($action=="add") { 
	$HTMLToolContentBG = "#FFFFFF";
?>
                    <? include("htmltool/header.php"); ?>
                    <table width="98%" border="0" cellpadding="0" cellspacing="1" class="table_header">
                      <form action="?" method="post" name="myReturnForm" id="myReturnForm">
                        <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
                        <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
                        <input name="action" type="hidden" id="action" value="">
						 <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
                        <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
                        <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
                        <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
                        <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
                        <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
                      </form>
                      <form action="?" method="post" enctype="multipart/form-data" name="myForm" id="myForm">
                        <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
                        <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
                        <input name="action" type="hidden" id="action" value="addnew">
						 <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
                        <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
                        <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
                        <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
                        <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
                        <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
                        <tr> 
                          <td bgcolor="#FFFFFF"> <table width="100%" border="0" cellpadding="2" cellspacing="1">
                              <tr> 
                                <td height="24" colspan="2" align="center" class="menu_table_header">Add New</td>
                              </tr>
                              <tr> 
                                <td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Header Information </td>
                              </tr>
                            

                              <tr> 
                                <td height="22" width="140" align="right" class="table_col1">สำหรับชั้นปี&nbsp;</td>
                                <td height="22" class="table_col2"><select name="inputFor">-<option value="4">--ชั้นปี 4--</option>
								<option value="5">--ชั้นปี 5--</option>
									<option value="6">--ชั้นปี 6--</option>
									</select> </td>
                              </tr>
                              <tr>
                                <td height="22" align="right" class="table_col1">ข้อมูลสื่อการสอนภาควิชา</td>
                                <td height="22" class="table_col2"><select name="inputFrom" id="inputFrom">
				<option value="" selected="selected">---เลือกภาควิชา---</option>
                <option value="ภาควิชาอายุรศาสตร์">ภาควิชาอายุรศาสตร์</option>
                <option value="ภาควิชากุมารเวชศาสตร์">ภาควิชากุมารเวชศาสตร์</option>
                <option value="ภาควิชาศัลยศาสตร์">ภาควิชาศัลยศาสตร์</option>
                 <option value="ภาควิชาสูตินรีเวชศาสตร์">ภาควิชาสูติศาสตร์และนรีเวชวิทยา</option>
                  <option value="ภาควิชาจิตเวชศาสตร์">ภาควิชาจิตเวชศาสตร์</option>
                   <option value="ภาควิชาจักษุวิทยา">ภาควิชาจักษุวิทยา</option>
                    <option value="ภาควิชาศัลยกรรมกระดูก">ภาควิชาออร์โธปิดิกส์</option>
                     <option value="ภาควิชาเวชศาสตร์ฉุกเฉินและนิติเวชศาสตร์">ภาควิชาเวชศาสตร์ฉุกเฉินและนิติเวชวิทยา</option>
                     <option value="ภาควิชาโสตศอนาสิก">ภาควิชาโสต ศอ นาสิก</option>
                     
                      <option value="ภาควิชาวิสัญญี">ภาควิชาวิสัญญีวิทยา</option>
                       <option value="ภาควิชาเวชศาสตร์ฟื้นฟู">ภาควิชาเวชศาสตร์ฟื้นฟู</option>
              </select></td>
                              </tr>

                              <tr> 
                                <td width="140" height="22" align="right" class="table_col1">เรื่อง&nbsp;</td>
                                <td height="22" class="table_col2"> <input name="inputSubject" type="text" class="input_left" id="inputSubject" size="50" maxlength="255"></td>
                              </tr>
                              
                              <tr>
                                <td width="140" height="22" align="right" class="table_col1">คำอธิบาย&nbsp; </td>
                                <td height="22" class="table_col2"><textarea name="inputTitle" cols="50" rows="6" class="input_textarea" id="inputTitle"></textarea></td>
                              </tr>
                              <tr> 
                                <td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;File แนบดาวน์โหลด</td>
                              </tr>
                              <tr> 
                                <td width="140" height="22" align="right" class="table_col1">&nbsp; </td>
                                <td height="22" class="table_col2"><input type="file" name="inputMap" id="inputMap" /></td>
                              </tr>
                              <tr> 
                                <td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;เนื้อหา VDO และบรรยายอื่น ๆ</td>
                              </tr>
                              <tr align="center" valign="top"> 
                                <td height="350" colspan="2" class="table_col2"><textarea cols="80" id="editor1" name="editor1" rows="10">
		</textarea>
        <script>

			CKEDITOR.replace( 'editor1');

		</script>    
                                </td>
                              </tr>
                              <tr align="left" valign="top"> 
                                <td colspan="2" align="right" class="table_col2">Use <span class="text_hilight">Shift+Enter</span>  to make a new row.</td>
                              </tr>
                              <tr style="display:none"> 
                                <td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Expiration</td>
                              </tr>
                              <tr style="display:none"> 
                                <td height="22" align="right" class="table_col1">วันที่เริ่มต้น&nbsp; </td>
                                <td height="22" class="table_col2"><input name="inputStartDate" type="text" class="input_center" id="inputStartDate" size="10" maxlength="10"> <input type="reset" class="button_normal" onClick="return showCalendar('inputStartDate', 'y-mm-dd');" value=" ... "></td>
                              </tr>
                              <tr style="display:none"> 
                                <td height="22" align="right" class="table_col1">วันที่สิ้นสุด&nbsp; </td>
                                <td height="22" class="table_col2"><input name="inputExpireDate" type="text" class="input_center" id="inputExpireDate" size="10" maxlength="10"> <input type="reset" class="button_normal" onClick="return showCalendar('inputExpireDate', 'y-mm-dd');" value=" ... "></td>
                              </tr>
                              <tr style="display:none"> 
                                <td height="22" align="right" class="table_col1">&nbsp;</td>
                                <td height="22" class="table_col2">Keep blank to alway on.</td>
                              </tr>
                            </table>
                            <table width="100%" height="24" border="0" cellpadding="3" cellspacing="0">
                              <tr align="right"> 
                                <td height="30" colspan="4" align="center" class="table_footer"> 
                                  <table width="300" border="0" cellspacing="0" cellpadding="2">
                                    <tr align="center"> 
                                      <td> <script language="JavaScript" type="text/JavaScript">
function isBlank(myObj) { if(myObj.value=='') { return true; } return false; }
function verifySubmit() {
	with(document.myForm) {
		if(isBlank(inputSubject)) {	inputSubject.focus(); return false; }
		if(isBlank(inputTitle)) {	inputTitle.focus(); return false; }
		//if(isBlank(inputThumbnailPicture)) {	inputThumbnailPicture.focus(); return false; }
		
		

	}
	//fnSave();
	document.myForm.submit();
}
						</script> <input name="btAdd" type="button" class="button_80" id="btAdd" value="Add" onClick="verifySubmit();">                                      </td>
                                      <td> <input name="btCalcel" type="button" class="button_80" id="btCalcel" onClick="
if(confirm('Are you sure to return to list?')) {
	document.myReturnForm.submit();
}
						" value="Cancel"> </td>
                                    </tr>
                                  </table></td>
                              </tr>
                            </table></td>
                        </tr>
                      </form>
                    </table>
                    <br>
                    <br>
                    <br>
                    <? 
#########################################################
} else if ($action=="edit") { 
	$myCheckBoxID=0;
	for($i=1;$i<=$TotalCheckBoxID;$i++) {
		$myVar="CheckBoxID".$i;
		if(strlen($$myVar)>0) {
			$myCheckBoxID=$$myVar;
		}
	}
	$sql="SELECT * FROM ".$myModule_Table." WHERE ".$myModule_Table."_ID=".$myCheckBoxID;
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
	$Row=MYSQL_FETCH_ARRAY($Query);
	$HTMLsrcSTR=$Row[$myModule_Table."_HTMLFileName"];
	$HTMLsrc = $myModule_Path_HTMLFiles."/".$Row[$myModule_Table."_HTMLFileName"];
	$HTMLToolContentBG = $Row[$myModule_Table."_BackgroudColor"];

	$sql="SELECT * FROM ".$myModule_Table_File." WHERE ".$myModule_Table_File."_WNWID=".$Row[$myModule_Table."_ID"];
	$QueryOther=mysql_query($sql);
	if(mysql_num_rows($QueryOther)>0){
		$index=0;
		while($RowOther=mysql_fetch_array($QueryOther)){
			$FileStr[$index]=$RowOther[$myModule_Table_File."_FileName"];
			$index++;
		}
	}
$strFilterDateArr=explode("-",$Row[$myModule_Table."_FilterDate"]);
?>
                    <? include("htmltool/header.php"); ?>
                    <table width="98%" border="0" cellpadding="0" cellspacing="1" class="table_header">
                      <form action="?" method="post" name="myReturnForm" id="myReturnForm">
                        <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
                        <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
                        <input name="action" type="hidden" id="action">
						 <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
                        <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
                        <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
                        <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
                        <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
                        <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
                      </form>
                      <form action="?" method="post" enctype="multipart/form-data" name="myForm" id="myForm">
                        <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
                        <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
                        <input name="action" type="hidden" id="action" value="update">
						 <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
                        <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
                        <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
                        <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
                        <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
                        <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
                        <input name="CheckBoxID1" type="hidden" id="CheckBoxID1" value="<?=$myCheckBoxID?>">
                        <tr> 
                          <td bgcolor="#FFFFFF"> <table width="100%" border="0" cellpadding="2" cellspacing="1">
                              <tr> 
                                <td height="24" colspan="2" align="center" class="menu_table_header">Edit </td>
                              </tr>
                              <tr> 
                                <td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Header Information </td>
                              </tr>
						    <?
if($Row[$myModule_Table."_GID"]>0){
?>
<script language="javascript" type="text/javascript">
if(<?=$Row[$myModule_Table."_GID"]?>==2){
	document.getElementById('RowhideMonth').style.display=''; 
	document.getElementById('RowhideYear').style.display='none'; 
	document.myForm.inputMonth.value='<?=$strFilterDateArr[1]?>';
}else if(<?=$Row[$myModule_Table."_GID"]?>==4){
	document.getElementById('RowhideMonth').style.display='none'; 
	document.getElementById('RowhideYear').style.display=''; 
	document.myForm.inputYear.value='<?=$strFilterDateArr[0]?>';
}else{
	document.getElementById('RowhideMonth').style.display='none'; 
	document.getElementById('RowhideYear').style.display='none'; 
}
</script>
<?
}
?>
                              <tr>
                                <td height="22" align="right" class="table_col1">สำหรับชั้นปี&nbsp;</td>
                                <td height="22" class="table_col2"><select name="inputFor2">
                                  -
                                  <option value="4" <? if($Row[moe_mod_wnw_For]=="4"){?> selected="selected"<? } ?>>--ชั้นปี 4--</option>
                                  <option value="5" <? if($Row[moe_mod_wnw_For]=="5"){?> selected="selected"<? } ?>>--ชั้นปี 5--</option>
                                  <option value="6"<? if($Row[moe_mod_wnw_For]=="6"){?> selected="selected"<? } ?>>--ชั้นปี 6--</option>
                                </select></td>
                              </tr>
                              <tr>
                                <td height="22" align="right" class="table_col1">ข้อมูลสื่อการสอนภาควิชา</td>
                                <td height="22" class="table_col2"><select name="inputFrom" id="inputFrom">
                                  <option value="" selected="selected">---เลือกภาควิชา---</option>
                                  <option value="ภาควิชาอายุรศาสตร์" <? if($Row[moe_mod_wnw_From]=="ภาควิชาอายุรศาสตร์"){?> selected="selected"<? } ?>>ภาควิชาอายุรศาสตร์</option>
                                  <option value="ภาควิชากุมารเวชศาสตร์" <? if($Row[moe_mod_wnw_From]=="ภาควิชากุมารเวชศาสตร์"){?> selected="selected"<? } ?>>ภาควิชากุมารเวชศาสตร์</option>
                                  <option value="ภาควิชาศัลยศาสตร์" <? if($Row[moe_mod_wnw_From]=="ภาควิชาศัลยศาสตร์"){?> selected="selected"<? } ?>>ภาควิชาศัลยศาสตร์</option>
                                  <option value="ภาควิชาสูตินรีเวชศาสตร์" <? if($Row[moe_mod_wnw_From]=="ภาควิชาสูตินรีเวชศาสตร์"){?> selected="selected"<? } ?>>ภาควิชาสูติศาสตร์และนรีเวชวิทยา</option>
                                  <option value="ภาควิชาจิตเวชศาสตร์" <? if($Row[moe_mod_wnw_From]=="ภาควิชาจิตเวชศาสตร์"){?> selected="selected"<? } ?>>ภาควิชาจิตเวชศาสตร์</option>
                                  <option value="ภาควิชาจักษุวิทยา" <? if($Row[moe_mod_wnw_From]=="ภาควิชาจักษุวิทยา"){?> selected="selected"<? } ?>>ภาควิชาจักษุวิทยา</option>
                                  <option value="ภาควิชาศัลยกรรมกระดูก" <? if($Row[moe_mod_wnw_From]=="ภาควิชาศัลยกรรมกระดูก"){?> selected="selected"<? } ?>>ภาควิชาออร์โธปิดิกส์</option>
                                  <option value="ภาควิชาเวชศาสตร์ฉุกเฉินและนิติเวชศาสตร์" <? if($Row[moe_mod_wnw_From]=="ภาควิชาเวชศาสตร์ฉุกเฉินและนิติเวชศาสตร์"){?>> selected="selected"<? } ?>>ภาควิชาเวชศาสตร์ฉุกเฉินและนิติเวชวิทยา</option>
                                  <option value="ภาควิชาโสตศอนาสิก" <? if($Row[moe_mod_wnw_From]=="ภาควิชาโสตศอนาสิก"){?> selected="selected"<? } ?>>ภาควิชาโสต ศอ นาสิก</option>
                                  <option value="ภาควิชาวิสัญญี" <? if($Row[moe_mod_wnw_From]=="ภาควิชาวิสัญญี"){?> selected="selected"<? } ?>>ภาควิชาวิสัญญีวิทยา</option>
                                  <option value="ภาควิชาเวชศาสตร์ฟื้นฟู" <? if($Row[moe_mod_wnw_From]=="ภาควิชาเวชศาสตร์ฟื้นฟู"){?> selected="selected"<? } ?>>ภาควิชาเวชศาสตร์ฟื้นฟู</option>
                                </select></td>
                              </tr>
                              <tr> 
                                <td width="140" height="22" align="right" class="table_col1">เรื่อง&nbsp;</td>
                                <td height="22" class="table_col2"> <input name="inputSubject" type="text" class="input_left" id="inputSubject" value="<?=$Row[$myModule_Table."_Subject"]?>" size="50" maxlength="255"></td>
                              </tr>
<?
if($SystemModuleKey=="Food"){
?>
                              <tr> 
                                <td height="22" width="140" align="right" class="table_col1">สำหรับ&nbsp;</td>
                                <td height="22" class="table_col2"> <input name="inputFor" type="text" class="input_left" id="inputFor" size="5" maxlength="10" value="<?=$Row[$myModule_Table."_For"]?>" onKeyPress="if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;"> ที่</td>
                              </tr>
<?
}
?>
                             
                              <tr> 
                                <td width="140" height="22" align="right" class="table_col1">คำอธิบาย&nbsp; </td>
                                <td height="22" class="table_col2"><textarea name="inputTitle" cols="50" rows="6" class="input_textarea" id="inputTitle"><?=$Row[$myModule_Table."_Title"]?></textarea></td>
                              </tr>
                              <tr> 
                                <td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;เนื้อหา VDO และบรรยายอื่น ๆ</td>
                              </tr>
                              <tr align="center" valign="top"> 
                                <td height="350" colspan="2" class="table_col2">
              <?                   if($Row[$myModule_Table."_ID"]<15){ ?>

                                <? include("htmltool/textarea.php"); ?>
                                <? } else { ?>
                                <textarea cols="80" id="editor1" name="editor1" rows="10">
				<?=$Row[$myModule_Table."_HTMLFileName"]?>
		</textarea>
        <script>

			CKEDITOR.replace( 'editor1');

		</script>
        <? } ?>                                  </td>
                              </tr>
                              <tr align="right" valign="top"> 
                                <td colspan="2" class="table_col2">Use <span class="text_hilight">Shift+Enter</span> to make a new row.</td>
                              </tr>
                            </table>
                            <table width="100%" height="24" border="0" cellpadding="3" cellspacing="0">
                              <tr align="right"> 
                                <td height="30" colspan="4" align="center" class="table_footer"> 
                                  <table width="300" border="0" cellspacing="0" cellpadding="2">
                                    <tr align="center"> 
                                      <td> <script language="JavaScript" type="text/JavaScript">
function isBlank(myObj) { if(myObj.value=='') { return true; } return false; }
function verifySubmit() {
	with(document.myForm) {
		if(isBlank(inputSubject)) {	inputSubject.focus(); return false; }
		if(isBlank(inputTitle)) {	inputTitle.focus(); return false; }
	}
	//fnSave();
	document.myForm.submit();
}
						</script> <input name="btSave" type="button" class="button_80" id="btSave" value="Save" onClick="verifySubmit();">                                      </td>
                                      <td> <input name="btCalcel" type="button" class="button_80" id="btCalcel" onClick="
if(confirm('Are you sure to return to list?')) {
	document.myReturnForm.submit();
}
						" value="Cancel"> </td>
                                    </tr>
                                  </table></td>
                              </tr>
                            </table></td>
                        </tr>
                      </form>
                    </table>
                    <br>
                    <br>
                    <br>
                    <? 
#########################################################
} else if ($action=="update") { 

if(strlen($inputYear)>0 && $inputGroupID==4){
	$inputStrFilter=$inputYear."-01-01";
}

if(strlen($inputMonth)>0 && $inputGroupID==2){
	$inputStrFilter=date('Y')."-".$inputMonth."-01";
}

		if( strlen($inputStartDate)>0 && strlen($inputExpireDate)>0 ) {
			if(strcmp($inputStartDate,$inputExpireDate)<1) { 
				// Do nothing.
			} else { 
				// Switch Date
				$myTmp = $inputStartDate;
				$inputStartDate = $inputExpireDate;
				$inputExpireDate = $myTmp;
			}
		}

		if(strlen($inputStartDate)!=10) { $inputStartDate="0000-00-00 00:00:00"; } else { $inputStartDate = $inputStartDate." 00:00:00"; }
		if(strlen($inputExpireDate)!=10) { $inputExpireDate="0000-00-00 00:00:00"; } else { $inputExpireDate= $inputExpireDate." 00:00:00"; }

		$MaxID = $CheckBoxID1;

		srand(make_seed());
		$myrand = rand(1111,9999);

		// Check to create module data directory. ---------
		if(!is_dir($System_RelativePath_Upload."/".$SystemModuleKey)) { mkdir($System_RelativePath_Upload."/".$SystemModuleKey,0777); }
		if(!is_dir($myModule_Path_ThumbnailPicture)) { mkdir($myModule_Path_ThumbnailPicture,0777); }
		if(!is_dir($myModule_Path_HTMLFiles)) { mkdir($myModule_Path_HTMLFiles,0777); }
		if(!is_dir($myModule_Path_ImageLibrary)) { mkdir($myModule_Path_ImageLibrary,0777); }
		if(!is_dir($myModule_Path_Download)) { mkdir($myModule_Path_Download,0777); }

		// ------------------------------------------------

		$sql="SELECT * FROM ".$myModule_Table." WHERE ".$myModule_Table."_ID=".$MaxID;
		$query=mysql_query($sql);
		$row=mysql_fetch_array($query);
		
		/*
		if(is_file($inputThumbnailPicture)) {
			$ThumbnailPictureName=$row[$myModule_Table."_PictureFile"];
			if(file_exists($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName)) {
					unlink($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName);
			}
			$ImageData = getimagesize($inputThumbnailPicture);
			if($ImageData!=NULL) {
				if($ImageData[2]==1) { 
					$ImageType="gif";
				} elseif($ImageData[2]==2) {
					$ImageType="jpg";
				}
				$ThumbnailPictureName = "$MaxID-$myrand.$ImageType";
				if(file_exists($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName)) {
					unlink($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName);
				}
				if(copy($inputThumbnailPicture,$myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName)) {
					chmod($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName,0777);
				}
				$sql = "UPDATE ".$myModule_Table." SET ".$myModule_Table."_PictureFile='$ThumbnailPictureName' WHERE ".$myModule_Table."_ID=".$MaxID;
				$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
			}			
		}
		*/
		if(isset($_FILES['inputThumbnailPicture'])) {
				if($_FILES['inputThumbnailPicture']['error']==0){				
					$exts = explode(".", $_FILES['inputThumbnailPicture']['name']);
					$ext = strtolower(($exts[count($exts) - 1]));	
					$ImageType = $ext;
				$ThumbnailPictureName = "$MaxID-$myrand.$ImageType";
				if(file_exists($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName)) {
					unlink($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName);
				}
				if(move_uploaded_file($_FILES['inputThumbnailPicture']['tmp_name'],$myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName)) {
					chmod($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName,0777);
				}
				$sql = "UPDATE ".$myModule_Table." SET ".$myModule_Table."_PictureFile='$ThumbnailPictureName' WHERE ".$myModule_Table."_ID=".$MaxID;
				$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
			}
		}

for($i=0;$i<=count($inputRealFileID);$i++){
	echo "ID : ".$inputRealFileID[$i]."<br>";
	if($inputRealFileID[$i]<>""){
		$IDStr .=",".$inputRealFileID[$i];
	}
}
//echo $IDStr;
//echo "<br>";
$sql="SELECT * FROM ".$myModule_Table_File." WHERE ".$myModule_Table_File."_ID NOT IN (aa".$IDStr.") AND ".$myModule_Table_File."_WNWID=".$MaxID;
$QueryChkFile=mysql_query($sql);
while($RowChkFile=mysql_fetch_array($QueryChkFile)){
	//echo $myModule_Path_Download."/".$RowChkFile[$myModule_Table_File."_FileName"];
	if(file_exists($myModule_Path_Download."/".$RowChkFile[$myModule_Table_File."_FileName"])) {
		unlink($myModule_Path_Download."/".$RowChkFile[$myModule_Table_File."_FileName"]);
	}
	$sql="DELETE FROM ".$myModule_Table_File." WHERE ".$myModule_Table_File."_ID=".$RowChkFile[$myModule_Table_File."_ID"];
	$QueryDel=mysql_query($sql);
}

/*
		for($i=0;$i<=count($inputFile);$i++){
			if(is_file($inputFile[$i])){
				$FileDownloadNameArr=explode(".",$inputFile_name[$i]);
				$FileDownloadName = "$MaxID-$myrand-$i.$FileDownloadNameArr[1]";
				if(file_exists($myModule_Path_Download."/".$FileDownloadName)) {
					unlink($myModule_Path_Download."/".$FileDownloadName);
				}
				if(copy($inputFile[$i],$myModule_Path_Download."/".$FileDownloadName)) {
					chmod($myModule_Path_Download."/".$FileDownloadName,0777);
				}
	
				$sql="INSERT INTO ".$myModule_Table_File." (".$myModule_Table_File."_WNWID,".$myModule_Table_File."_FileName,".$myModule_Table_File."_Name) VALUES ('".$MaxID."','".$FileDownloadName."','".$inputFileName[$i]."')";
				$Query=mysql_query($sql);
			}
		}
		*/
		
		include"function_mod.php";
		///////--  Attach Files  ------------//
	 if( isset( $_FILES[inputFile][tmp_name] ) ){
				for($i=0; $i < count( $_FILES[inputFile][tmp_name] );  $i++){
					$exts = explode(".", $_FILES[inputFile][name][$i]);
					$ext = strtolower(($exts[count($exts) - 1]));	
					$tmpName = $_FILES[inputFile][tmp_name][$i];
					$fileName = $_FILES[inputFile][name][$i];     				
					$fileSize = imgGetFileSize($_FILES[inputFile][size][$i]);
					$myrand = rand(1111,9999);
					$path =  $MaxID."-".$myrand."." . $ext;										
					$paths= $myModule_Path_Download ."/". $path;				
				if ($_FILES[InputFile][error][$i]==0) {
					 if ($_FILES[inputFile][type][$i])	$mimeType = $_FILES[inputFile][type][$i];												
					 else  $mimeType = "application/unknown";					
						if( move_uploaded_file($_FILES[inputFile][tmp_name][$i], $paths) ){							
						//sql
							$insert[$myModule_Table_File."_WNWID"] = "$MaxID";
							$insert[$myModule_Table_File."_FileName"] = "'$fileName'";
							$insert[$myModule_Table_File."_Name"] = "'$inputFileName[$i]'";		
							$sql="INSERT INTO ".$myModule_Table_File." (".implode(",",array_keys($insert)).") VALUES (".implode(",",array_values($insert)).")";
							mysql_query($sql) or die("Error: เกิดความผิดพลาด <br>$sql<br>\n");
						}
				}											
			}
			unset($insert);
		 }//end check file.
		 //------- end add file ---------
		
		$sql = "SELECT * FROM ".$myModule_Table." WHERE ".$myModule_Table."_ID=".$MaxID;
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
		$Row=MYSQL_FETCH_ARRAY($Query);

		$HTMLFileName = $Row[$myModule_Table."_HTMLFileName"];		
		if(file_exists($myModule_Path_HTMLFiles."/".$HTMLFileName)) {
			unlink($myModule_Path_HTMLFiles."/".$HTMLFileName);
		}
		$HTMLFileName = "$MaxID-$myrand.html";

		$HTMLToolContent=stripslashes($HTMLToolContent);
		$fp = fopen ($myModule_Path_HTMLFiles."/".$HTMLFileName, "w+");
		fwrite($fp,$HTMLToolContent);
		fclose($fp);

		$sql = "UPDATE ".$myModule_Table." SET ".
		$myModule_Table."_GID='$inputGroupID', ".
		$myModule_Table."_HTMLFileName='$HTMLFileName', ".
		$myModule_Table."_Subject='".changeQuot($inputSubject)."', ".
		$myModule_Table."_For='".changeQuot($inputFor)."', ".
		$myModule_Table."_By='".changeQuot($inputBy)."', ".
		$myModule_Table."_From='".changeQuot($inputFrom)."', ".
		$myModule_Table."_Title='".changeQuot($inputTitle)."' ,".
		$myModule_Table."_Relate='".changeQuot($inputRelate)."' ,".
		$myModule_Table."_HTMLFileName='$editor1', ".
		//$myModule_Table."_FilterDate='$inputStrFilter', ".
		$myModule_Table."_CreateByID=$System_Session_User_ID,".
		$myModule_Table."_CreateBy='$System_Session_UserName' ,".
		$myModule_Table."_StartDate='$inputStartDate', ".
		$myModule_Table."_ExpireDate='$inputExpireDate' ,".
		$myModule_Table."_LastUpdate=NOW(),".
		$myModule_Table."_Status='".$System_Approve_DefaultStatus."'".
		" WHERE ".$myModule_Table."_ID=".$MaxID;
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");

?>
                    <form action="?" method="post" name="myForm" id="myForm">
                      <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
                      <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
                      <input name="action" type="hidden" id="action">
					   <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
                      <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
                      <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
                      <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
                      <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
                      <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
                    </form>
                    <script language="JavaScript" type="text/JavaScript"> document.myForm.submit(); </script>
                    <? 
#########################################################
} else if ($action=="view") { 
	for($i=1;$i<=$TotalCheckBoxID;$i++) {
		$myVar="CheckBoxID".$i;
		if(strlen($$myVar)>0) {
			$myCheckBoxID=$$myVar;
		}
	}
	$sql="SELECT * FROM ".$myModule_Table." WHERE ".$myModule_Table."_ID=".$myCheckBoxID;
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
	$Row=MYSQL_FETCH_ARRAY($Query);
?>
                    <table width="98%" border="0" cellpadding="0" cellspacing="1" class="table_border">
                      <form action="?" method="post" name="myForm" id="myForm">
                        <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
                        <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
                        <input name="action" type="hidden" id="action">
						 <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
                        <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
                        <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
                        <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
                        <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
                        <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
                        <input name="CheckBoxID1" type="hidden" id="CheckBoxID1" value="<?=$myCheckBoxID?>">
                        <input name="TotalCheckBoxID" type="hidden" id="TotalCheckBoxID" value="1">
                        <tr> 
                          <td bgcolor="#FFFFFF"> <table width="100%" border="0" cellpadding="2" cellspacing="1" >
                              <tr align="center"> 
                                <td height="24" colspan="2" align="center" class="table_header">  Information</td>
                              </tr>
                              <tr> 
                                <td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Header Information </td>
                              </tr>
						    <?
if($Row[$myModule_Table."_GID"]==2){
?>
                              
<?
}else if($Row[$myModule_Table."_GID"]==4){
?>
                            <?
}
?>
                              <tr>
                                <td height="22" align="right" class="table_col1">ข้อมูลสื่อการสอนภาควิชา</td>
                                <td class="table_col2"><?=$Row[$myModule_Table."_From"]?></td>
                              </tr>
                              <tr> 
                                <td height="22" align="right" class="table_col1">เรื่อง&nbsp;</td>
                                <td width="1097" class="table_col2"><?=$Row[$myModule_Table."_Subject"]?> </td>
                              </tr>
<?
if($SystemModuleKey=="Food"){
?>
                              <tr> 
                                <td height="22" width="90" align="right" class="table_col1">สำหรับ&nbsp;</td>
                                <td height="22" class="table_col2"><?=$Row[$myModule_Table."_For"]?> ที่</td>
                              </tr>
<?
}
?>
                              <tr style="display:none"> 
                                <td width="90" height="22" align="right" class="table_col1">จาก&nbsp;</td>
                                <td height="22" class="table_col2"><?=$Row[$myModule_Table."_From"]?></td>
                              </tr>
                              <tr>
                                <td height="22" align="right" class="table_col1">คำอธิบาย&nbsp;</td>
                                <td class="table_col2"><?=nl2br($Row[$myModule_Table."_Title"])?></td>
                              </tr>
							  <tr style="display:none"> 
                                <td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Thumbnail</td>
                              </tr>
                              <tr style="display:none"> 
                                <td height="22" align="right" class="table_col1">รูปภาพ&nbsp;</td>
                                <td height="26" class="table_col2">
								<? if($Row[$myModule_Table."_PictureFile"]==""){?>
									<img src="../images/blank.gif">
								<? }else{?>
									<img src="<?=$myModule_Path_ThumbnailPicture?>/<?=$Row[$myModule_Table."_PictureFile"]?>" name="PreviewImage" border="0" id="PreviewImage">
								<? }?>								</td>
                              </tr>
                              <tr> 
                                <td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;เนื้อหา VDO และบรรยายอื่น ๆ</td>
                              </tr>
                            </table>
                            <table width="100%" height="100" border="0" cellpadding="2" cellspacing="0"  bgcolor="#FFFFFF">
                              <tr> 
                                <td align="left" valign="top"> 
<?
if($Row[$myModule_Table."_ID"]<15){
$filename = $myModule_Path_HTMLFiles."/".$Row[$myModule_Table."_HTMLFileName"];
$fd = fopen ($filename, "r");
$contents = fread ($fd, filesize ($filename));
fclose ($fd);
echo $contents;
}else{
echo $Row[$myModule_Table."_HTMLFileName"];
 } ?>
</td>
                              </tr>
                            </table>
                            <table width="100%" border="0" cellpadding="2" cellspacing="1"   style="display:none">
                              <tr> 
                                <td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;File Download</td>
                              </tr>
                              <tr> 
                                <td height="22" align="right" class="table_col1">ไฟล์&nbsp; </td>
                                <td height="22" class="table_col2">
									<table width="100%"  border="0" cellspacing="1" cellpadding="2">
									<?
									$sql="SELECT * FROM ".$myModule_Table_File." WHERE ".$myModule_Table_File."_WNWID=".$Row[$myModule_Table."_ID"];
									$QueryFile=mysql_query($sql);
									$index=1;
									if(mysql_num_rows($QueryFile)>0){
										while($RowFile=mysql_fetch_array($QueryFile)){
									?>
									  <tr>
										<td><img src="../images/icon/ico418.gif"> <a href="<?=$myModule_Path_Download."/".$RowFile[$myModule_Table_File."_FileName"]?>" target="_blank"><?=$RowFile[$myModule_Table_File."_Name"]?></a></td>
									  </tr>
									<?
											$index++;
										}
									}else{
									?>
										<tr>
											<td>No File Download</td>
										</tr>
									<?
									}
									?>
									</table>								</td>
                              </tr>
                              <tr> 
                                <td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Expiration</td>
                              </tr>
                              <tr> 
                                <td height="22" align="right" class="table_col1" width="140">วันที่เริ่มต้น&nbsp;</td>
                                <td height="22" class="table_col2"> 
<?
$myTmpDate = substr($Row[$myModule_Table."_StartDate"],0,10);
if($myTmpDate=="0000-00-00") { echo "No start date limit."; } else { echo $myTmpDate; }
?>                                </td>
                              </tr>
                              <tr> 
                                <td height="22" align="right" class="table_col1">วันที่สิ้นสุด&nbsp;</td>
                                <td height="22" class="table_col2"> 
<?
$myTmpDate = substr($Row[$myModule_Table."_ExpireDate"],0,10);
if($myTmpDate=="0000-00-00") { echo "No expire date limit."; } else { echo $myTmpDate; }
?>                                </td>
                              </tr>
                              <tr> 
                                <td height="27" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;More Information</td>
                              </tr>
                              <tr> 
                                <td height="22" align="right" class="table_col1">สร้างเมื่อ&nbsp;</td>
                                <td height="22" class="table_col2"><?=$Row[$myModule_Table."_CreateDate"]?></td>
                              </tr>
                              <tr> 
                                <td height="22" align="right" class="table_col1">แก้ไขล่าสุด&nbsp;</td>
                                <td height="22" class="table_col2"><?=$Row[$myModule_Table."_LastUpdate"]?></td>
                              </tr>
                              <tr> 
                                <td height="22" align="right" class="table_col1">แก้ไขโดย&nbsp;</td>
                                <td height="22" class="table_col2"><?=$Row[$myModule_Table."_CreateBy"]?></td>
                              </tr>
                              <tr> 
                                <td height="22" align="right" class="table_col1">สถานะ&nbsp;</td>
                                <td height="22" class="table_col2"><?=$Row[$myModule_Table."_Status"]?></td>
                              </tr>
                            </table>
                            <table width="100%" height="24" border="0" cellpadding="3" cellspacing="0">
                              <tr align="right"> 
                                <td height="30" colspan="4" align="center" class="table_footer"> 
                                  <table width="300" border="0" cellspacing="0" cellpadding="2">
                                    <tr align="center"> 
<? if($System_Session_Permission[$SystemMenuID]=="RW" ){ ?>
                                      <td> <input name="btEdit" type="submit" class="button_80" id="btEdit" value="Edit" onClick="
document.myForm.action.value='edit';
document.myForm.submit();
						"> </td>
<? }?>
                                      <td> <input name="btCalcel" type="button" class="button_80" id="btCalcel" onClick="
document.myForm.submit();
						" value="Cancel"> </td>
                                    </tr>
                                  </table></td>
                              </tr>
                          </table></td>
                        </tr>
                      </form>
                    </table>
                    <? 
#########################################################
} else if ($action=="delete") { 
	for($i=1;$i<=$TotalCheckBoxID;$i++) {
		$myVar="CheckBoxID".$i;
		if(strlen($$myVar)>0) {
			$sql = "SELECT * FROM ".$myModule_Table." WHERE ".$myModule_Table."_ID=".$$myVar;
			$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
			$Row=MYSQL_FETCH_ARRAY($Query);
			if(strlen($Row[$myModule_Table."_PictureFile"])>0) {
				if(file_exists($myModule_Path_ThumbnailPicture."/".$Row[$myModule_Table."_PictureFile"])) {
					unlink($myModule_Path_ThumbnailPicture."/".$Row[$myModule_Table."_PictureFile"]);
				}
			}			
			if(strlen($Row[$myModule_Table."_HTMLFileName"])>0) {
				if(file_exists($myModule_Path_HTMLFiles."/".$Row[$myModule_Table."_HTMLFileName"])) {
					unlink($myModule_Path_HTMLFiles."/".$Row[$myModule_Table."_HTMLFileName"]);
				}
			}			
			if(strlen($Row[$myModule_Table."_FileDownload"])>0){
				if(file_exists($myModule_Path_Download."/".$Row[$myModule_Table."_FileDownload"])) {
						unlink($myModule_Path_Download."/".$Row[$myModule_Table."_FileDownload"]);
				}
			}

			$sql = "DELETE FROM ".$myModule_Table." WHERE ".$myModule_Table."_ID=".$$myVar;
			$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");

		}
	}
?>
                    <form action="?" method="post" name="myForm" id="myForm">
                      <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
                      <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
                      <input name="action" type="hidden" id="action">
					   <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
                      <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
                      <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
                      <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
                      <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
                      <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
                    </form>
                    <script language="JavaScript" type="text/JavaScript"> document.myForm.submit(); </script>
                    <? 
#########################################################
} else if ($action=="setstatus") { 
	$myCheckBoxID=0;
	for($i=1;$i<=$TotalCheckBoxID;$i++) {
		$myVar="CheckBoxID".$i;
		if(strlen($$myVar)>0) {
			$myCheckBoxID=$$myVar;
		}
	}
	$sql="UPDATE ".$myModule_Table." SET ".$myModule_Table."_Status='$SelectStatus' WHERE ".$myModule_Table."_ID=".$myCheckBoxID;
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");

	// Update Content Approve Status
	UpdateApproveStatus($SystemModuleKey,$myCheckBoxID,$SelectStatus);
	
?>
                    <form action="?" method="post" name="myForm" id="myForm">
                      <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
                      <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
                      <input name="action" type="hidden" id="action">
					   <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
                      <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
                      <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
                      <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
                      <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
                      <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
                    </form>
                    <script language="JavaScript" type="text/JavaScript"> document.myForm.submit(); </script>
                    <? 
//########################################################
} else if ($action=="makeordering") { 
	$sql = "SELECT * FROM ".$myModule_Table." WHERE ".$myModule_Table."_ModuleKey='$SystemModuleKey'  AND " .$myModule_Table."_Language='$System_Session_Language'";
	if($GroupID!=""){
	$sql=$sql." AND ".$myModule_Table."_GID=".$GroupID;
	}
	
	$sql=$sql." Order by ".$myModule_Table."_Order ASC ";
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
	$RecordCount=MYSQL_NUMROWS($Query);
?>
                    <table width="500" border="0" cellpadding="0" cellspacing="1" class="table_border">
                      <form action="?" method="post" name="myRedirectForm" id="myRedirectForm">
                      <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
                      <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
                      <input name="action" type="hidden" id="action">
					   <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
                      <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
                      <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
                      <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
                      <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
                      <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
                      </form>
                      <form action="?" method="post" name="myForm" id="myForm">
                      <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
                      <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
                      <input name="action" type="hidden" id="action">
					   <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
                      <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
                      <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
                      <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
                      <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
                      <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
                        <tr> 
                          <td bgcolor="#FFFFFF"> <table width="100%" border="0" cellpadding="2" cellspacing="1" class="mytable_inner">
                              <tr align="center"> 
                                <td height="24" colspan="2" align="center" class="table_header">Make 
                                  Ordering 
                                  <?=getMenuName($SystemMenuID)?>                                </td>
                              </tr>
                              <tr> 
                                <td width="100" align="right" valign="top" class="table_col1"><br>
                                  <?=getMenuName($SystemMenuID)?>
                                  List&nbsp;</td>
                                <td height="40" align="left" class="table_col2"> 
                                  <table height="60" border="0" cellpadding="2" cellspacing="0">
                                    <tr> 
                                      <td align="center"> <select name="listUser[]" size="15" multiple class="input_textarea" id="listUser" style="width:200">
                                          <?
if($RecordCount>0) {
	$index=1;
	while($index<$RecordCount+1) {
		$Row=MYSQL_FETCH_ARRAY($Query);
		echo "<option value=\"".$Row[$myModule_Table."_ID"]."\">";
			echo $Row[$myModule_Table."_Subject"];
		echo "</option>\n";
		$index++;
	}
}
?>
                                        </select> </td>
                                      <td valign="top"><table height="100%" border="0" cellpadding="1" cellspacing="0">
                                          <tr> 
                                            <td height="10"><input type="button"  class="button_100" id="RemoveUp" name="RemoveUp"  value="Move Up" onClick="funcMultipleMoveUp(document.myForm.elements['listUser[]'])"></td>
                                          </tr>
                                          <tr> 
                                            <td><script language="JavaScript" type="text/JavaScript">
function funcMultipleSelectAll(myListObj) {
	var Len = myListObj.options.length;
	if(Len>0) 
		for(var i=0;i<Len;i++)
		   myListObj.options[i].selected=true;
}
function funcMultipleMoveUp(myListObj) {
	var Len = myListObj.options.length;
	var tmpID,tmpValue;
	if(Len>0) 
		for(var i=1;i<Len;i++)
	    	if (myListObj.options[i]!=null && myListObj.options[i].selected==true) {
					if(!myListObj.options[i-1].selected) {
					   myListObj.options[i].selected=false;
					   tmpID = myListObj.options[i].value;
					   tmpValue = myListObj.options[i].text;
					   myListObj.options[i].value = myListObj.options[i-1].value;
					   myListObj.options[i].text = myListObj.options[i-1].text;
					   myListObj.options[i-1].value = tmpID;
					   myListObj.options[i-1].text = tmpValue;
					   myListObj.options[i-1].selected=true;
				}
			}
}
function funcMultipleMoveDown(myListObj) {
	var Len = myListObj.options.length;
	var tmpID,tmpValue;
	if(Len>0) 
		for(var i=Len-2;i>=0;i--)
	    	if (myListObj.options[i]!=null && myListObj.options[i].selected==true) {
					if(!myListObj.options[i+1].selected) {
					   myListObj.options[i].selected=false;
					   tmpID = myListObj.options[i].value;
					   tmpValue = myListObj.options[i].text;
					   myListObj.options[i].value = myListObj.options[i+1].value;
					   myListObj.options[i].text = myListObj.options[i+1].text;
					   myListObj.options[i+1].value = tmpID;
					   myListObj.options[i+1].text = tmpValue;
					   myListObj.options[i+1].selected=true;
				}
			}
}
								  </script> </td>
                                          </tr>
                                          <tr> 
                                            <td height="10"><input type="button"  class="button_100" id="MoveDown" name="MoveDown"  value="Move Down" onClick="funcMultipleMoveDown(document.myForm.elements['listUser[]'])"></td>
                                          </tr>
                                        </table></td>
                                    </tr>
                                  </table></td>
                              </tr>
                            </table>
                            <table width="100%" height="24" border="0" cellpadding="3" cellspacing="0">
                              <tr align="right"> 
                                <td height="30" colspan="4" align="center" class="table_footer"> 
                                  <table width="300" border="0" cellspacing="0" cellpadding="2">
                                    <tr align="center"> 
                                      <td> <input name="btSave" type="button" class="button_80" id="btSave" value="Save"  onClick="
if(confirm('Are you sure to save a change?')) {
	document.myForm.action.value='updateordering';
	funcMultipleSelectAll(document.myForm.elements['listUser[]']);
	document.myForm.submit();
}
						"> </td>
                                      <td> <input name="btCalcel" type="button" class="button_80" id="btCalcel" onClick="
if(confirm('Are you sure to return to list?')) {
	document.myRedirectForm.submit();
}
						" value="Cancel"> </td>
                                    </tr>
                                  </table></td>
                              </tr>
                            </table></td>
                        </tr>
                      </form>
                    </table>
                    <br>
                    <? 
//########################################################
} else if ($action=="updateordering") { 
$index=1;
if($listUser!="") {
	while (list ($key, $val) = each ($listUser)) {
		$sql="UPDATE ".$myModule_Table." SET ".$myModule_Table."_Order='$index' WHERE ".$myModule_Table."_ID=".$val;
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
		$index++;
	}
}
?>
                    <form action="?" method="post" name="myForm" id="myForm">
                      <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
                      <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
                      <input name="action" type="hidden" id="action">
					   <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
                      <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
                      <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
                      <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
                      <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
                      <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
                    </form>
                    <script language="JavaScript" type="text/JavaScript"> document.myForm.submit(); </script>
                    <?	
#########################################################
} else { ?>

                  <?
# Check to set default value #########################
if($PageSize=="") { $PageSize = $SystemModule_defaultPageSize; }
if($PageShow=="") { $PageShow = $SystemModule_defaultPageShow; }
if($ASCDESC=="") { $ASCDESC = $SystemModule_ASCDESC; } 
if($OrderBy=="") { $OrderBy = $SystemModule_OrderBy; } 
if($action=="switchorder") { 
	if($ASCDESC=="ASC") { $ASCDESC = "DESC"; }  else { $ASCDESC="ASC"; } 
} 
if($PageSearch!="") { $PageSearch=trim($PageSearch); }

# Count total record size #########################
$sql = "SELECT * FROM ".$myModule_Table." WHERE ".$myModule_Table."_Language='$System_Session_Language' and ".$myModule_Table."_CreateByID='$System_Session_User_ID'  ";
$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("<br><br><b><font color=#FF0000>ไม่สามารถใช้งานระบบได้<br>หากคุณเข้าใช้งานเป็นครั้งแรก<br><a href=\"#\" onClick=\"Popup('popupCreateDatabaseWindow','createdatabase.php',220,180,1);\">กรุณาคลิ๊กที่นี่</a><br>เพื่อทำการสร้างฐานข้อมูลใหม่</font></b>\n");

if($PageSearch=="") {
	$sql = "SELECT * FROM ".$myModule_Table." WHERE ".$myModule_Table."_ModuleKey='$SystemModuleKey'  AND ".$myModule_Table."_Language='$System_Session_Language' and ".$myModule_Table."_CreateByID='$System_Session_User_ID'  ";
} else {
	$sql = "SELECT * FROM ".$myModule_Table." WHERE ".$myModule_Table."_ModuleKey='$SystemModuleKey' AND ".$myModule_Table."_Language='$System_Session_Language'   AND ( ".
	$myModule_Table."_Subject LIKE '%$PageSearch%' OR ".
	$myModule_Table."_Title LIKE '%$PageSearch%' OR ".
	$myModule_Table."_Status LIKE '%$PageSearch%'  ) ";
}

if($GroupID>0){
$sql = $sql." AND ".$myModule_Table."_GID = ".$GroupID; 
}



$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
$TotalRecordCount=MYSQL_NUMROWS($Query);

# Find max page size #########################
if($TotalRecordCount>$PageSize) {
	$NoOfPage= ceil($TotalRecordCount/$PageSize);
} else {
	$NoOfPage=1;
}
# Recover page show into range #########################
if($PageShow>$NoOfPage) { $PageShow=$NoOfPage; }

# Select only paging range #########################
$RecordStart = ($PageShow-1)*$PageSize;
$sql.=" ORDER BY $OrderBy $ASCDESC LIMIT $RecordStart , $PageSize";

$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
$RecordCount=MYSQL_NUMROWS($Query);
?>
                    <script language="JavaScript" type="text/JavaScript">
function Paging_CheckAll(objCheckHeader,txtCheckBoxFirstName,intTotalItems) {
	if(intTotalItems>0)
		for(i=1;i<=intTotalItems;i++)
			document.getElementById(txtCheckBoxFirstName+i).checked = objCheckHeader.checked;			
	return true;
}
function Paging_CheckAllHandle(objCheckHeader,txtCheckBoxFirstName,intTotalItems) {
	var isCheckedAll = true;
	if(intTotalItems>0)
		for(i=1;i<=intTotalItems;i++)
			if(!document.getElementById(txtCheckBoxFirstName+i).checked) 
				isCheckedAll = false;
	objCheckHeader.checked = isCheckedAll;
	return true;
}
function Paging_CountChecked(txtCheckBoxFirstName,intTotalItems) {
	var intChecked = 0;
	if(intTotalItems>0)
		for(i=1;i<=intTotalItems;i++)
			if(document.getElementById(txtCheckBoxFirstName+i).checked) 
				intChecked ++;
	return intChecked ;
}
function Paging_CheckedThisItem(objCheckHeader,indexing,txtCheckBoxFirstName,intTotalItems) {
	if(intTotalItems>0)
		for(i=1;i<=intTotalItems;i++)
			if(i==indexing) {
				document.getElementById(txtCheckBoxFirstName+i).checked = true;
			} else {
				document.getElementById(txtCheckBoxFirstName+i).checked = false;
			}
	objCheckHeader.checked = false;
	return true;
}
                    </script>
                    <div id="divDataPicker" style="display:none; position:absolute; top:-115px; left:180px; width: 200px; z-index: 1;Filter:Alpha(opacity=95)"> 
                      <table width="100%" border="0" cellpadding="0" cellspacing="1" class="table_border">
                        <form action="?" method="post" name="myStatusForm" id="myStatusForm">
                          <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
                          <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
                          <tr> 
                            <td height="22"><table width="100%" height="22" border="0" cellpadding="0" cellspacing="0" class="table_header">
                                <tr> 
                                  <td width="28" align="center"><img src="../images/icon/ico439.gif" width="19" height="15"></td>
                                  <td align="center">Select Status</td>
                                  <td width="22" align="center"><img src="../images/icon/ico215.gif" width="16" height="16" onMouseOver="this.style.cursor='hand'" onClick="document.getElementById('divDataPicker').style.display='none'; "></td>
                                </tr>
                              </table></td>
                          </tr>
                          <tr> 
                            <td height="120" align="center" class="table_row1"><br> 
                              <table width="120" border="0" cellpadding="2" cellspacing="0">
                                <? for ($i=1;$i<=$System_Approve_ContentStatus_Count;$i++) { ?>
								<? if (strstr($System_StaffLevel_StatusManage[$System_Session_Level],$System_Approve_ContentStatus_Value[$i])) { ?>
								<tr> 
                                  <td width="26" height="22" align="center"><input name="toolbarStatus" type="radio" class="form_checkbox" value="<?=$System_Approve_ContentStatus_Value[$i]?>"></td>
                                  <td height="22" class="text_bold"><font color="#<?=$System_Approve_ContentStatus_Color[$System_Approve_ContentStatus_Value[$i]]?>"><?=$System_Approve_ContentStatus_Name[$System_Approve_ContentStatus_Value[$i]]?></font></td>
                                </tr>
								<? } ?>
								<? } ?>
                              </table>
                              <br> <table border="0" cellspacing="0" cellpadding="6">
                                <tr> 
                                  <td><input name="btSave" type="button" class="button_th_60" id="btSave" value="Save" onClick="
if (document.myStatusForm.toolbarStatus.length>1) {
	for (var i=0;i<document.myStatusForm.toolbarStatus.length;i++) {
		if (document.myStatusForm.toolbarStatus[i].checked) {
			document.myForm.SelectStatus.value = document.myStatusForm.toolbarStatus[i].value;
		}
	}
} else {
	if (document.myStatusForm.toolbarStatus.checked) {
		document.myForm.SelectStatus.value = document.myStatusForm.toolbarStatus.value;
	}
}
document.myForm.action.value='setstatus';
Paging_CheckedThisItem(document.myForm.CheckBoxAll, StatusIndex ,'CheckBoxID', document.myForm.TotalCheckBoxID.value );
document.myForm.submit();
"></td>
                                  <td><input name="btClose" type="button" class="button_th_60" id="btClose" value="Close" onClick="document.getElementById('divDataPicker').style.display='none';"></td>
                                </tr>
                              </table></td>
                          </tr>
                          <tr> 
                            <td height="6" class="table_footer"><img src="../images/blank.gif" width="1" height="1"></td>
                          </tr>
                        </form>
                      </table>
                    </div>
                    <script language="JavaScript" type="text/JavaScript">
var StatusIndex=0;
function ShowDataPicker(myDivName,RefX,RefY) {
	document.getElementById(myDivName).style.display=''; 
	document.getElementById(myDivName).style.left = document.body.scrollLeft + window.event.clientX + RefX;
	document.getElementById(myDivName).style.top= document.body.scrollTop+ window.event.clientY + RefY;
}
	                </script>
                    <table width="95%" height="22" border="0" cellpadding="2" cellspacing="0">
                      <form action="?" method="post" name="myHeaderButton" id="myHeaderButton" onSubmit="return false;">
                        <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
                        <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
						 <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
                        <tr valign="bottom"> 
                          <td width="75%"> <table border="0" cellspacing="0" cellpadding="2">
                              <tr> 
<?
					$sql_permission="SELECT * FROM ".$System_TableName_Menu.
			" LEFT JOIN ".$System_TableName_StaffOnPermission." ON ".$System_TableName_Menu."_ID=".$System_TableName_StaffOnPermission."_MenuID".
			" WHERE ".$System_TableName_StaffOnPermission."_StaffID=".$System_Session_User_ID;
			$Query_permission = mysql_query($sql_permission);
			while ($Row_Permission = mysql_fetch_array($Query_permission)) {
					if ($Row_Permission[$System_TableName_StaffOnPermission."_Permission"]<>"") {
						$System_Session_Permission[$Row_Permission[$System_TableName_StaffOnPermission."_MenuID"]] = $Row_Permission[$System_TableName_StaffOnPermission."_Permission"];
					} else {
						$System_Session_Permission[$Row_Permission[$System_TableName_StaffOnPermission."_MenuID"]] = "NA";
					}
			}
		?>
					  
							   <td><input name="btAdd" type="button" class="button_80" id="btAdd" value="Add New" onClick="
document.myForm.action.value='add';
document.myForm.submit();
				"></td>

                                <td><input name="btView" type="button" class="button_60" id="btView" onClick="
if(Paging_CountChecked('CheckBoxID',document.myForm.TotalCheckBoxID.value)==1) {
	document.myForm.action.value='view';
	document.myForm.submit();
} else {
	alert('Please checked 1 item to view this record.');
}
				  " value="View"></td>
			  				  
                                <td><input name="btEdit" type="button" class="button_60" id="btEdit" onClick="
if(Paging_CountChecked('CheckBoxID',document.myForm.TotalCheckBoxID.value)==1) {
	document.myForm.action.value='edit';
	document.myForm.submit();
} else {
	alert('Please checked 1 item to edit this record.');
}
				  " value="Edit"></td>
                                <td><input name="btDelete" type="button" class="button_60" id="btDelete" onClick="
if(Paging_CountChecked('CheckBoxID',document.myForm.TotalCheckBoxID.value)>0) {
	if(confirm('Are you sure to delete selected record?')) {
		document.myForm.action.value='delete';
		document.myForm.submit();
	}
} else {
	alert('Please checked 1 or more item to delete record.');
}
				  " value="Delete"></td>
				  
                            </tr>
                            </table></td>
                        </tr>
                      </form>
                    </table>
                    <table width="98%" height="26" border="0" cellpadding="0" cellspacing="0" class="table_toolbar">
                      <form action="?" method="post" name="myToolbarForm" id="myToolbarForm" onSubmit="return false;">
                        <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
						 <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
                        <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
                        <tr> 
                          <td width="5" align="left" valign="top"> <img src="../images/bgborder1w.gif" width="5" height="5"></td>
                          <td valign="bottom"> <table border="0" cellpadding="2" cellspacing="0" class="toolbar">
                              <tr> 
                                <td width="10">&nbsp;</td>
                                <td>Page</td>
                                <td> 
                                  <? 
				  if($NoOfPage>1) { 
				  ?>
                                  <select name="toolbarPageShow" class="select" onChange="document.myForm.PageShow.value=this.value; document.myForm.submit(); ">
                                    <? 
if($NoOfPage<$SystemModule_MaxPage) {
	// Show page list #########################
	for($i=1;$i<=$NoOfPage;$i++) { 
		echo "<option value=\"$i\"";
		if($i==$PageShow) { echo " selected"; }
		echo ">$i</option>";
	} 
}  else {
	// # If total page count greater than default max page  value then reduce page select size #########################
	$starti = $PageShow-$SystemModule_ReduceRange;
	if($starti<1) { $starti=1; }
	$endi = $PageShow+$SystemModule_ReduceRange;
	if($endi>$NoOfPage) { $endi=$NoOfPage; }
	//#####################
	for($i=$starti ;$i<=$endi;$i++) { 
		echo "<option value=\"$i\"";
		if($i==$PageShow) { echo " selected"; }
		echo ">$i</option>";
	} 
}
?>
                                  </select> 
                                  <? 
 } else { 
	echo "1";
 }
 ?>                                </td>
                                <td>of 
                                  <?=$NoOfPage?>                                </td>
                                <td width="10">&nbsp;</td>
                                <td>Page size</td>
                                <td> <input name="toolbarPageSize" type="text" class="input_center" id="toolbarPageSize" value="<?=$PageSize?>" size="3" maxlength="3"></td>
                                <td> <input name="btChangePageSize" type="button" class="button_normal" id="btChangePageSize" value=" Go " onClick="
if(isNaN(document.myToolbarForm.toolbarPageSize.value*1)) {
	document.myToolbarForm.toolbarPageSize.value='<?=$PageSize?>';
	document.myToolbarForm.toolbarPageSize.focus();
	return false;
}
if(document.myToolbarForm.toolbarPageSize.value<=0) {
	document.myToolbarForm.toolbarPageSize.value='<?=$PageSize?>';
	document.myToolbarForm.toolbarPageSize.focus();
	return false;
}
document.myForm.PageSize.value=document.myToolbarForm.toolbarPageSize.value; 
document.myForm.submit(); 
				  "> </td>
                              </tr>
                            </table></td>
                          <td align="right" valign="bottom"> <table border="0" cellpadding="0" cellspacing="0">
                              <tr> 
                                <td>Found 
                                  <?=$TotalRecordCount?>
                                  record</td>
                                <td width="10">&nbsp;</td>
                                <? if($PageShow>1) { ?>
                                <td width="21" align="center"> <img src="../images/controlpage/playset_start.gif" width="21" height="21" 
				  onMouseOver="this.src='../images/controlpage/playset_start_active.gif'; this.style.cursor='hand';" 
				  onMouseOut="this.src='../images/controlpage/playset_start.gif';" 
				  onClick="document.myForm.PageShow.value=1; document.myForm.submit();"></td>
                                <? } else { ?>
                                <td width="21" align="center"><img src="../images/controlpage/playset_start_disable.gif" width="21" height="21"></td>
                                <? } ?>
                                <? if($PageShow>1) { ?>
                                <td width="21" align="center"> <img src="../images/controlpage/playset_backward.gif" width="21" height="21" 
				  onMouseOver="this.src='../images/controlpage/playset_backward_active.gif'; this.style.cursor='hand';" 
				  onMouseOut="this.src='../images/controlpage/playset_backward.gif';" 
				  onClick="document.myForm.PageShow.value--; document.myForm.submit();"></td>
                                <? } else { ?>
                                <td width="21" align="center"><img src="../images/controlpage/playset_backward_disable.gif" width="21" height="21"></td>
                                <? } ?>
                                <td width="21" align="center"> <img src="../images/controlpage/playset_stop.gif" width="21" height="21" 
				  onMouseOver="this.src='../images/controlpage/playset_stop_active.gif'; this.style.cursor='hand';" 
				  onMouseOut="this.src='../images/controlpage/playset_stop.gif';" 
				  onClick="
					with(document.myForm) {
					GroupID.value='';
						PageShow.value='';
						PageSize.value='';
						ASCDESC.value='';
						OrderBy.value='';
						PageSearch.value='';
						submit();
					}
					"></td>
                                <? if($PageShow<$NoOfPage) { ?>
                                <td width="21" align="center"> <img src="../images/controlpage/playset_forward.gif" width="21" height="21" 
				  onMouseOver="this.src='../images/controlpage/playset_forward_active.gif'; this.style.cursor='hand';" 
				  onMouseOut="this.src='../images/controlpage/playset_forward.gif';" 
				  onClick="document.myForm.PageShow.value++; document.myForm.submit();"></td>
                                <? } else { ?>
                                <td width="10" align="center"><img src="../images/controlpage/playset_forward_disable.gif" width="21" height="21"></td>
                                <? } ?>
                                <? if($PageShow<$NoOfPage) { ?>
                                <td width="10" align="center"><img src="../images/controlpage/playset_end.gif" width="21" height="21" 
				  onMouseOver="this.src='../images/controlpage/playset_end_active.gif'; this.style.cursor='hand';" 
				  onMouseOut="this.src='../images/controlpage/playset_end.gif';" 
				  onClick="document.myForm.PageShow.value='<?=$NoOfPage?>'; document.myForm.submit();"></td>
                                <? } else { ?>
                                <td width="10" align="center"><img src="../images/controlpage/playset_end_disable.gif" width="21" height="21"></td>
                                <? } ?>
                              </tr>
                            </table></td>
                          <td width="5" align="right" valign="top"><img src="../images/bgborder2w.gif" width="5" height="5"></td>
                        </tr>
                      </form>
                    </table>
                    <table width="98%" border="0" cellpadding="0" cellspacing="1" class="table_border">
                      <tr> 
                        <td bgcolor="#FFFFFF"> <table width="100%" border="0" cellpadding="1" cellspacing="1">
                            <form action="?" method="post" name="myForm" id="myForm">
                              <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
                              <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
                              <input name="action" type="hidden" id="action">
							   <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
                              <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
                              <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
                              <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
                              <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
                              <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
                              <input name="SelectStatus" type="hidden" id="SelectStatus">
                              <tr align="center" class="menu_table_header"> 
                                <td width="58" height="30"><input name="CheckBoxAll" type="checkbox" class="form_checkbox" id="CheckBoxAll" value="Yes" onClick="Paging_CheckAll(this,'CheckBoxID',document.myForm.TotalCheckBoxID.value)"></td>
                                <td width="58" height="30" align="center"> 
                                  <? 
$myOrderBy = $myModule_Table."_ID";
if($OrderBy==$myOrderBy) { 
	if($ASCDESC=="DESC") { ?>
                                  <img src="../images/controlpage/desc_order.gif" width="7" height="7"> 
                                  <? }
	if($ASCDESC=="ASC") { ?>
                                  <img src="../images/controlpage/asc_order.gif" width="7" height="7"> 
                                  <? }
} 
?>
                                  <a href="#" class="link_headbar" onClick="
with(document.myForm) { 
	<? if($OrderBy==$myOrderBy) { echo "action.value='switchorder';\n"; } ?>
	OrderBy.value='<?=$myOrderBy?>';
	submit(); 
}
					">No.</a></td>
                                <td width="491" height="30">ข้อมูลเนื้อหาการเรียนการสอน</td>
                                <td width="172">จำนวน นศ.<br>
                                  ดาวน์โหลดเอกสาร</td>
                                <td width="153">จำนวน นศ.<br>
                                เข้าไปดูเนื้อหา</td>
                                <td width="247" height="30" valign="top"> 
                                  การจัดการ<br>
                                  ข้อมูลการสอน</td>
                              </tr>
                              <?
$index=1;
if($RecordCount>0) {
	while($index<$RecordCount+1) {
		if($myClassRow=="table_row1") { $myClassRow="table_row2"; } else { $myClassRow="table_row1";  }
		$Row=MYSQL_FETCH_ARRAY($Query);
	?>
                              <tr class="<?=$myClassRow?>" onMouseOver="this.className='table_rowover'" onMouseOut="this.className='<?=$myClassRow?>'"> 
                                <td width="58" height="65" align="center"> <input name="CheckBoxID<?=$index?>" type="checkbox" class="form_checkbox" id="CheckBoxID<?=$index?>" onClick="Paging_CheckAllHandle(document.myForm.CheckBoxAll,'CheckBoxID',document.myForm.TotalCheckBoxID.value)" value="<?=$Row[$myModule_Table."_ID"]?>"></td>
                                <td width="58" height="65" align="center"> 
                                  <? if($ASCDESC=="ASC"){echo $RecordStart+$index;}else{echo ($TotalRecordCount-($RecordStart+$index)+1);} ?>
                                  <!--?=$Row[$myModule_Table."_ID"]?-->                                </td>
                                <td height="65" valign="top"> 
									<?=$Row[$myModule_Table."_From"]?><br>
<span class="text_bold">
                                  <a href="#" onClick="
Paging_CheckedThisItem( document.myForm.CheckBoxAll, <?=$index?>, 'CheckBoxID', document.myForm.TotalCheckBoxID.value );
document.myForm.action.value='view';
document.myForm.submit();
						  "> 
                                  <?=$Row[$myModule_Table."_Subject"]?>
                                  </a> </span><br> 
                                  <?
						  if(strlen($Row[$myModule_Table."_Title"])>100) {
						  	echo substr($Row[$myModule_Table."_Title"],0,100)."...";
						  }  else {
						  	echo $Row[$myModule_Table."_Title"];
						  }
						  ?>                                </td>
                                <td height="65" align="center"><?
		$sqlcv1="select * from countdownload_el where Idel='$Row[moe_mod_wnw_ID]'";
		$querycv1=mysql_query($sqlcv1);
		$numcv1=mysql_num_rows($querycv1);
		?><?=$numcv1?>
                                  <br>
                                <a href="cd_el.php?Idel=<?=$Row[moe_mod_wnw_ID]?>" target="_blank">ดูข้อมูล</a><br></td>
                                <td height="65" align="center">
		<?
		$sqlcv2="select * from countview_el where Idel='$Row[moe_mod_wnw_ID]'";
		$querycv2=mysql_query($sqlcv2);
		$numcv2=mysql_num_rows($querycv2);
		?><?=$numcv2?>
								  <br>
								  <a href="cv_el.php?Idel=<?=$Row[moe_mod_wnw_ID]?>" target="_blank">ดูข้อมูล</a></td>
                                <td width="247" height="65" align="center" valign="middle"><br> <table border="0" cellspacing="0" cellpadding="1">
                                    <tr align="center" valign="bottom">

                                      <td><img src="../images/icon/ico416.gif" alt="View" width="16" height="21" border="0" onMouseOver="this.style.cursor='hand'" onClick="
Paging_CheckedThisItem( document.myForm.CheckBoxAll, <?=$index?>, 'CheckBoxID', document.myForm.TotalCheckBoxID.value );
document.myForm.action.value='view';
document.myForm.submit();
						"></td>
 						
                                      <td><img src="../images/icon/ico425.gif" alt="Edit" width="16" height="16" border="0" onMouseOver="this.style.cursor='hand'" onClick="
if(confirm('Are you sure to edit this record?')) {
	Paging_CheckedThisItem( document.myForm.CheckBoxAll, <?=$index?>, 'CheckBoxID', document.myForm.TotalCheckBoxID.value );
	document.myForm.action.value='edit';
	document.myForm.submit();
}
						"></td>
                                      <td><img src="../images/icon/ico417.gif" alt="Delete" width="16" height="16" border="0" onMouseOver="this.style.cursor='hand'" onClick="
if(confirm('Are you sure to delete this record?')) {
	Paging_CheckedThisItem( document.myForm.CheckBoxAll, <?=$index?>, 'CheckBoxID', document.myForm.TotalCheckBoxID.value );
	document.myForm.action.value='delete';
	document.myForm.submit();
}
						"></td>
						
                                    </tr>
                                  </table></td>
                              </tr>
                              <?
		$index++;
	}
} else {  ?>
                              <tr class="table_row1"> 
                                <td height="80" colspan="6" align="center"> Data 
                                  not found!</td>
                              </tr>
                              <? } ?>
                              <input name="TotalCheckBoxID" type="hidden" id="TotalCheckBoxID" value="<?=$index-1?>">
                            </form>
                          </table>
                          <table width="100%" height="24" border="0" cellpadding="3" cellspacing="0">
                            <form action="?" method="post" name="mySearchForm" id="mySearchForm" onSubmit="return false;">
                              <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
                              <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
							   <input name="GroupID" type="hidden" id="GroupID" >
                              <tr align="right"> 
                                <td colspan="4" align="right" class="table_footer">&nbsp;</td>
                              </tr>
                            </form>
							 <script language="javascipt" type="text/javascript">
										if('<?=$GroupID?>'!=""){
										
										document.mySearchForm.GroupID.value='<?=$GroupID?>';
										
	                                    }
										</script>
                          </table></td>
                      </tr>
                    </table>
                    <br>
                    <? 
}
#########################################################
?>
                    <br>
            <? }  else { echo "&nbsp;&nbsp;&nbsp;"; } ?>		</td>
        <td width="17" valign="top" background="../images/object/border_07.gif"><img src="../images/object/border_17.gif" width="17" height="119"></td>
      </tr>
      <tr>
        <td height="16"><img src="../images/object/border_09.gif" width="20" height="16"></td>
        <td height="16" background="../images/object/border_11.gif"><img src="../images/object/border_11.gif" width="1" height="16"></td>
        <td><img src="../images/object/border_13.gif" width="17" height="16"></td>
      </tr>
    </table></td>
        </tr>
      </table></td>
    <td width="1" bgcolor="#10202F"><img src="../../images/blank.gif" width="1" height="1"></td> 
  </tr>
</table>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="4" height="30" align="left" valign="bottom" background="../../images/main/main-t-bg.gif">&nbsp;</td>
    <td height="30" align="center" background="../../images/main/main-t-bg.gif">&nbsp;</td>
    <td width="4" height="30" align="right" valign="bottom" background="../../images/main/main-t-bg.gif">&nbsp;</td>
  </tr>
</table>
</body>
</html>
<? 
include("../lib/disconnect.php");
?>

Hacked By AnonymousFox1.0, Coded By AnonymousFox