<?php

session_start();



// require("checklogin.php");

    $kieu=@$_GET["kieu"];

    $madxgt=@$_GET["madx"];

    $makl=@$_POST["khoilop"];



 require("Connection.php");





if($kieu=="D" and $madxgt<>"")

{

	$sql="delete from dexuatgiaotrinh where madx=".$madxgt;

	$result=mysql_query($sql,$link);

	}



 ?>





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<HTML>

<HEAD><Title>De xuat giao trinh</Title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<link href="css/default.css" rel="stylesheet" type="text/css" />

<style type="text/css">

<!--

body {

	margin-left: 00px;

	margin-top: 0px;

	margin-right: 0px;

	margin-bottom: 0px;

}

.style7 {

	font-size: 16pt;

	color:  #CC0000;

	font-weight: bold;

	font-family: Arial, Helvetica, sans-serif;

}

-->

</style>

</HEAD>

<center>

	</head>

	<body>

	

	<form name=f1  method=POST >

<div align="center"><span class="style7">ĐỀ XUẤT GI&Aacute;O TR&Igrave;NH<br />


<?php 

$hotengv="";

$sql1="select tentruongmn from truongmn where matruongmn='".$_SESSION["matruongmn"]."'";



	$result1=mysql_query($sql1,$link);

	if (!$result1) {

		die('Invalid query: ' . mysql_error());

	}

	$tongrec1= mysql_num_rows($result1);

	if ($tongrec1>0)

	{

	while ($row1=mysql_fetch_array($result1))

			{		$hotengv=$row1["tentruongmn"];

			}

	}

			echo "<font face='Arial'>$hotengv</font>";

?>





</span>

    </div>



	

	<br />

	<div align="center">Ch&#7885;n kh&#7889;i l&#7899;p :
	
	<?php


	?>

      <select name="khoilop" class="box1" onchange="chuyenlop()">

        <option value="" >Tất cả</option>

		<?php

			$sql1="select  distinct(khoilop) from lopmn where matruongmn='".$_SESSION["matruongmn"]."'";


	$result1=mysql_query($sql1,$link);

	$tongrec1= mysql_num_rows($result1);

	if ($tongrec1>0)

	{

	while ($row1=mysql_fetch_array($result1))

			{		$makhoi=$row1["khoilop"];

?>			

			<option value="<?php echo $makhoi;?>" <?php if($makhoi==$makl)echo " selected" ?>>    <?php echo $makhoi;?>        </option>

		<?php

			}

	}

	?>

		

      </select>

	  <br /><br />

	  <?php 

	 $chuoitim="";

     if($makl<>"")

		$chuoitim=$chuoitim . " khoilop like N'%".$makl."%' and " ;

	 if($chuoitim<> "")

		 $sql3 ="SELECT * FROM lopmn where matruongmn='".$_SESSION["matruongmn"]."' and " . $chuoitim . " 1=1 order by tenlopmn ";

	else

         $sql3 ="SELECT * FROM lopmn where matruongmn='".$_SESSION["matruongmn"]."'  order by tenlopmn";



	$result3=mysql_query($sql3,$link);

	$tongrec3= mysql_num_rows($result3);

	  

	  ?>

	  

    </div>

	

<table width="100%" align="center" cellspacing="0" class="khungbao1">

          <tr>

            <td width="9%" align = "center" class="dkta1"><p align="center"><font color="#800000" face="Arial" size="2">L&#7899;p</font></p></td>

  		    <td width="10%" align = "center" class="dkta1"><p align="center"><font color="#800000" face="Arial" size="2">S&#7889; lư&#7907;ng b&eacute;</font></p></td>

            <td width="16%" align = "center" class="dkta1"><p align="center"><font color="#800000" face="Arial" size="2">Ng&agrave;y &#273;&#7873; xu&#7845;t</font></p></td>

            <td width="26%" align = "center" class="dkta1"><p align="center"><font color="#800000" size="2" face="Arial">Ngư&#7901;i &#273;&#7873; xu&#7845;t</font></p></td>

            <td width="39%" align = "center" class="dkta1"><p align="center"><font color="#800000" size="2" face="Arial">Gi&aacute;o tr&igrave;nh &#273;&#7873; xu&#7845;t</font></p></td>

          </tr>

<?php

$i=0;

	if ($tongrec3>0)

	{

	while ($row3=mysql_fetch_array($result3))

			{	$i++;



    $now = getdate();

    $currentDate = $now["year"] . "-" . $now["mon"] . "-" . $now["mday"];







?>

      

          <tr>

            <td align = "center" class="dkta1"><div align="center"><font  face="arial" color="#0000CC" size="3"><?php echo $row3["tenlopmn"];?></font>&nbsp;</div></td>

		   <td align = "center" class="dkta1"><div align="center">&nbsp;

		     <input name="soluongbe<?php echo $row3["malopmn"]; ?>" type="text" class="box1" size="7" maxlength="10"  onkeypress="checknum()" />

		   </div></td>

            <td align = "center" class="dkta1"><div align="center">

              <input name="ngaydx<?php echo $row3["malopmn"]?>" type="text" class="box1"  onfocus="javascript:document.f1.ngaydx<?php echo $row3["malopmn"]?>.value='<?php echo  $currentDate;?>';" size="15" maxlength="10" />

              &nbsp;</div></td>

            <td align = "left" class="dkta1"><div align="center">&nbsp;

                <input name="nguoidx<?php echo $row3["malopmn"];?>" type="text" class="box1"  size="33" />

            </div></td>

            <td align = "center" class="dkta1" ><div align="center">

			  <input name="<?php echo $row3["malopmn"];?>" type="hidden" />

              <textarea name="giaotrinhdx<?php echo $row3["malopmn"];?>" cols="50" rows="3" class="box2" ></textarea>

</div></td>

          </tr>

        <?php

}}



?>

  </table>

	    <p align="center">

	      <br />

	      <input type="button" value="Cập nhật" name="cmd1" onclick="kt()"/>

	      &nbsp;&nbsp;

	      <input name="cmd12" type="button" value="Thoát" onclick="javascript:window.location.href='logout.php';" />

		  <input type="hidden" value="<?php echo $malh;?>" name="malh" />

</p>

	    <p align="center">&nbsp;</p>

	    <p align="center" class="style7"><a name="xemgt" id="xemgt"></a>DANH S&Aacute;CH GIÁO TR&Igrave;NH &#272;&Atilde; &#272;&#7872; XU&#7844;T</p>



	    <table width="100%" cellspacing="0" class="khungbao1">

          <tr>

            <td width="5%" align = "center" class="dkta1"><p align="center"><font color="#800000" size="2" face="Arial">X&Oacute;A</font></p></td>

            <td width="5%" align = "center" class="dkta1"><p align="center"><font color="#800000" face="Arial" size="2">M&atilde;QL</font></p></td>

            <td width="14%" align = "center" class="dkta1"><p align="center"><font color="#800000" face="Arial" size="2">Ng&agrave;y &#273;&#7873; xu&#7845;t</font></p></td>

            <td width="7%" align = "center" class="dkta1"><p align="center"><font color="#800000" face="Arial" size="2">L&#7899;p</font></p></td>

            <td width="10%" align = "center" class="dkta1"><p align="center"><font color="#800000" face="Arial" size="2">S&#7889; lư&#7907;ng b&eacute;</font></p></td>

            <td width="41%" align = "center" class="dkta1"><p align="center"><font color="#800000" face="Arial" size="2">Gi&aacute;o tr&igrave;nh &#273;&atilde; &#273;&#7873; xu&#7845;t</font></p></td>

            <td width="10%" align = "center" class="dkta1"><p align="center"><font color="#800000" size="2" face="Arial">Ngư&#7901;i &#273;&#7873; xu&#7845;t</font></p></td>

            <td width="6%" align = "center" class="dkta1"><p align="center"><font color="#800000" face="Arial" size="2">Tr&#7841;ng thái</font></p></td>

            <td width="7%" align = "center" class="dkta1"><p align="center"><font color="#800000" face="Arial" size="2">Trư&#7901;ng</font></p></td>

          </tr>

		  <?php 

    		  $chuoitim="";

			  if($makl<>"")

				 $chuoitim=$chuoitim . " b.khoilop like N'%".$makl."%' and " ;

			  if($chuoitim<> "")

                 $sql4 ="SELECT a.*,b.khoilop, b.tenlopmn FROM dexuatgiaotrinh a , lopmn b where " . $chuoitim . " a.malopmn=b.malopmn and a.matruongmn='".$_SESSION["matruongmn"]."' order by a.ngaydexuat desc limit 0,200";

			  else

                 $sql4 ="SELECT  a.*,b.khoilop, b.tenlopmn FROM dexuatgiaotrinh a , lopmn b where a.malopmn=b.malopmn and a.matruongmn='".$_SESSION["matruongmn"]."' order by a.ngaydexuat desc limit 0,200";



	$result4=mysql_query($sql4,$link);

	$tongrec4= mysql_num_rows($result4);

		  

	 $chuoitim="";

	$i=0;

	if ($tongrec4>0)

	{

	while ($row4=mysql_fetch_array($result4))

			{	$i++; 

?>

		  

          <tr>

            <td align = "center" class="dkta1"><div align="center"><font  face="arial"  size="2"><a href="#xemgt" onclick="xoadl(<?php echo $row4["madx"];?>,'<?php echo $row4["trangthai"];?>')">Delete</a></font>&nbsp;</div></td>

            <td align = "center" class="dkta1"><div align="center"><font  face="arial"  size="2"><?php echo $row4["madx"];?></font>&nbsp;</div></td>

            <td align = "center" class="dkta1"><div align="center"><font  face="arial"  size="2"><?php echo $row4["ngaydexuat"];?></font>&nbsp;</div></td>

            <td align = "center" class="dkta1"><div align="center"><font  face="arial"  size="2"><?php  echo $row4["tenlopmn"];?></font>&nbsp;</div></td>

            <td align = "center" class="dkta1"><div align="center"><font  face="arial"  size="2"><?php echo $row4["soluongbe"];?></font>&nbsp;</div></td>

            <td align = "center" class="dkta1"><div align="center"><font  face="arial"  size="2"><?php echo $row4["noidungdx"];?></font>&nbsp;</div></td>

            <td align = "center" class="dkta1"><div align="center"><font  face="arial"  size="2"><?php echo $row4["nguoidx"];?></font>&nbsp;</div></td>

            <td align = "center" class="dkta1" ><div align="center"><strong><font  face="arial"  color="#990000" size="2"><?php echo $row4["trangthai"];?></font>&nbsp;</strong></div></td>

            <td align = "center" class="dkta1" ><div align="center"><font  face="arial"  size="2"><?php echo $row4["matruongmn"];?></font>

            </div></td>

          </tr>

          <?php

}}

?>

        </table>

	    <p align="center">&nbsp;</p>

</form>

    </body>

</html>

		<script language="javascript">



	function checknum()

	{

		var a=window.event.keyCode;

		if(a<48 || a>57)

			window.event.keyCode=0;

		

	}



		function kt()

		{

		if(confirm("Ban co dong y de xuat cac giao trinh nay khong?"))

	 {document.f1.action="capnhatgiaotrinhdx.php";

			 document.f1.submit();}

		}

		 function chuyenlop()

		 {



			 document.f1.action="dexuatgiaotrinh.php";

			 document.f1.submit();

			 }

			 

			 	 function xoadl(a,b)

		 {

				if(b!="DX")

				{alert("Giao trinh nay da phat ban khong duoc xoa!");

				return false;}

				if(confirm("Ban co dong y xoa khong?"))

				   {window.location.href="dexuatgiaotrinh.php?kieu=D&madx="+a;}

			 }

		</script>

