<?php

include "header_with_out_nav.php";

$btnSave=$_GET['btnSave'];

$college_id=$_GET['college_id'];

$course_name=$_GET['course_name'];

$subject=$_GET['subject'];

$college_type=$_GET['college_type'];

$Course_Details=$_GET['Course_Details'];

$month=$_GET['month'];

$year=$_GET['year'];

if($btnSave==""){

?>

<form name="form1" action="att_view.php" method="get"  class="form-horizontal" role="form">

	  <table cellpadding=2 cellspacing=0 border=1 bordercolor=#FFFFCC bgcolor="" align=center class="table table-bordered table-striped">

				

		

		<tr>

          <td class=color3>Select College</td>

		  <td class=color2><?php

							

$queryy = "SELECT * FROM college_name where code='$code'";

$numresultsy=mysql_query($queryy);

$resulty= mysql_query($queryy) or die("Couldn't execute query");

?>

              <select name="college_id" class="chosen-select form-control" id="college_id" required onchange='this.form.submit()'>

                <option value="">Select</option>

                <?php

while ( $a_roww = mysql_fetch_row( $resulty ) )

 {?>

                <option

                 <?php 

				 $cn_id=$a_roww[2];

				 if($cn_id==$college_id){

				  ?>selected<?php } ?>

                  

                   value="<?php echo $a_roww[2];?>" >( <?php echo $a_roww[2];?> ) <?php echo $a_roww[1];?></option>

                <?php } ?>

            </select></td>

	    </tr>

		<tr>

          <td width="116" class=color3>College Type</td>

		  <td width="190" class=color2><select name="college_type" class="chosen-select form-control" required="required" onchange='this.form.submit()'>
<?php
$query = "SELECT * FROM ctype where session='$session' and code='$code' ORDER BY id";
$numresults=mysql_query($query);
 $numrows=mysql_num_rows($numresults);
$result = mysql_query($query) or die("Couldn't execute query");
while ( $a_row = mysql_fetch_row( $result ) )

 {?>
          <option value="<?php echo $rty=$a_row[1]; ?>" <?php 
				 if($college_type==$rty){
				  ?>selected<?php } ?>><?php echo $a_row[2]; ?></option>
<?php } ?>

            </select>          </td>

	    </tr>

		

		<tr>

          <td class=color3> Course Name</td>

		  <td class=color2>

          <select name="course_name"  required onchange='this.form.submit()' class="chosen-select form-control">

                                            

                                            <?php $queryy = "SELECT * FROM course_name where college_id='$college_id' && ctype='$college_type' && session=$session && code='$code' Order by id";

$numresultsy=mysql_query($queryy);

$resulty= mysql_query($queryy) or die("Couldn't execute query");

 ?>

	<option value="">Select</option>

	 <?php

while ( $a_roww = mysql_fetch_row( $resulty ) )

 {?>

                  <option 

                 <?php 

				 $Course_id=$a_roww[0];

				 if($Course_id==$course_name){

				  ?>selected<?php } ?> 

                  value="<?php echo $a_roww[0];?>" ><?php echo $a_roww[1];?></option>

                  <?php } ?>

</select>         </td>

	    </tr>

          <tr>

		  <td class=color3>Select Year</td>

		  <td class=color2><select name="Course_Details" title="Select  Year/Semester" class="chosen-select form-control" required>

	

     <?php $queryy = "SELECT * FROM seme_year where course_name='$course_name' and session='$session' and code='$code' Order by id";

$numresultsy=mysql_query($queryy);

$resulty= mysql_query($queryy) or die("Couldn't execute query");

 ?>

	<option value="">Select</option>

	 <?php

while ( $a_roww = mysql_fetch_row( $resulty ) )

 {?>

                  <option

                 <?php 

				 $Course_Detailss=$a_roww[1];

				 if($Course_Detailss==$Course_Details){

				  ?>selected<?php } ?>

                  

                   value="<?php echo $a_roww[1];?>" ><?php echo $a_roww[1];?></option>

                  <?php } ?>

    

    

</select></td>

	    </tr>

		<tr>

		  <td class=color3>Subject Name</td>

		  <td class=color2>

           <select name="subject"  onchange='this.form.submit()' class="chosen-select form-control">

                                            

                                            <?php $queryy = "SELECT * FROM subject where session=$session && code='$code' && college_code='$college_id' && college_type='$college_type' && course_name='$course_name' Order by id";

$numresultsy=mysql_query($queryy);

$resulty= mysql_query($queryy) or die("Couldn't execute query");

 ?>

	

    <option <?php 

				 

				 if($subject==''){

				  ?>selected<?php } ?> value="">All</option>

	 <?php

while ( $a_roww = mysql_fetch_row( $resulty ) )

 {?>

                  <option 

                 <?php 

				 $Course_id=$a_roww[1];

				 if($Course_id==$subject){

				  ?>selected<?php } ?> 

                  value="<?php echo $a_roww[1];?>" ><?php echo $a_roww[1];?></option>

                  <?php } ?>

</select>        </td>

		</tr>

         <tr>

    <td><div align="right">Date</div></td>

    <td>

        <select name="month"  required="required" class="chosen-select form-control">

          <option value="<?php echo $date_array[mon];?>"><?php echo $date_array[mon];?></option>

          <option <?php if($month=='1'){ ?>selected<?php } ?> value="1">1</option>

          <option <?php if($month=='2'){ ?>selected<?php } ?> value="2">2</option>

          <option <?php if($month=='3'){ ?>selected<?php } ?> value="3">3</option>

          <option <?php if($month=='4'){ ?>selected<?php } ?> value="4">4</option>

          <option <?php if($month=='5'){ ?>selected<?php } ?> value="5">5</option>

          <option <?php if($month=='6'){ ?>selected<?php } ?> value="6">6</option>

          <option <?php if($month=='7'){ ?>selected<?php } ?> value="7">7</option>

          <option <?php if($month=='8'){ ?>selected<?php } ?> value="8">8</option>

          <option <?php if($month=='9'){ ?>selected<?php } ?> value="9">9</option>

          <option <?php if($month=='10'){ ?>selected<?php } ?> value="10">10</option>

          <option <?php if($month=='11'){ ?>selected<?php } ?> value="11">11</option>

          <option <?php if($month=='12'){ ?>selected<?php } ?> value="12">12</option>

        </select>

          <select name="year"  required="required" class="chosen-select form-control">

          <option value="<?php echo $date_array[year]; ?>"><?php echo $date_array[year]; ?></option>

            <option <?php if($year=='2017'){ ?>selected<?php } ?>value="2017">2017</option>

            <option <?php if($year=='2018'){ ?>selected<?php } ?>value="2018">2018</option>

            <option <?php if($year=='2019'){ ?>selected<?php } ?>value="2019">2019</option>

            <option <?php if($year=='2020'){ ?>selected<?php } ?>value="2020">2020</option>

          </select> </td>

  </tr> 

        <tr> 

			<td class=color3></td>

			<td class=color2><input type="submit" name="btnSave" value="Get  List"  class="btn btn-info" ></td>

		</tr>

	</table>

</form>

<?php } ?>

<center><a href="att_view.php"><h3>Back</h3></a></center>

<?php 

$monthNames = Array("January", "February", "March", "April", "May", "June", "July","August", "September", "October", "November", "December");

?>

<?php

if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");

if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y");

?><?php

$cMonth = $_REQUEST["month"];

$cYear = $_REQUEST["year"];

 

$prev_year = $cYear;

$next_year = $cYear;

$prev_month = $cMonth-1;

$next_month = $cMonth+1;

 

if ($prev_month == 0 ) {

    $prev_month = 12;

    $prev_year = $cYear - 1;

}

if ($next_month == 13 ) {

    $next_month = 1;

    $next_year = $cYear + 1;

}

?><table width="100%">

<tr>

<td align="center"><table width="100%" border="0" cellpadding="2" cellspacing="2">

<tr align="center">

<td colspan="7" bgcolor="#999999" style="color:#FFFFFF"><strong><?php echo $monthNames[$cMonth-1].' '.$cYear; ?></strong></td>

</tr>

</table>

<style>.CSSTableGenerator {

	margin:0px;padding:0px;

	width:100%;

	box-shadow: 10px 10px 5px #888888;

	border:1px solid #000000;

	

	-moz-border-radius-bottomleft:0px;

	-webkit-border-bottom-left-radius:0px;

	border-bottom-left-radius:0px;

	

	-moz-border-radius-bottomright:0px;

	-webkit-border-bottom-right-radius:0px;

	border-bottom-right-radius:0px;

	

	-moz-border-radius-topright:0px;

	-webkit-border-top-right-radius:0px;

	border-top-right-radius:0px;

	

	-moz-border-radius-topleft:0px;

	-webkit-border-top-left-radius:0px;

	border-top-left-radius:0px;

}.CSSTableGenerator table{

    border-collapse: collapse;

        border-spacing: 0;

	width:100%;

	height:100%;

	margin:0px;padding:0px;

}.CSSTableGenerator tr:last-child td:last-child {

	-moz-border-radius-bottomright:0px;

	-webkit-border-bottom-right-radius:0px;

	border-bottom-right-radius:0px;

}

.CSSTableGenerator table tr:first-child td:first-child {

	-moz-border-radius-topleft:0px;

	-webkit-border-top-left-radius:0px;

	border-top-left-radius:0px;

}

.CSSTableGenerator table tr:first-child td:last-child {

	-moz-border-radius-topright:0px;

	-webkit-border-top-right-radius:0px;

	border-top-right-radius:0px;

}.CSSTableGenerator tr:last-child td:first-child{

	-moz-border-radius-bottomleft:0px;

	-webkit-border-bottom-left-radius:0px;

	border-bottom-left-radius:0px;

}.CSSTableGenerator tr:hover td{

	

}

.CSSTableGenerator tr:nth-child(odd){ background-color:#aad4ff; }

.CSSTableGenerator tr:nth-child(even)    { background-color:#ffffff; }.CSSTableGenerator td{

	vertical-align:middle;

	

	

	border:1px solid #000000;

	border-width:0px 1px 1px 0px;

	text-align:left;

	padding:7px;

	font-size:13px;

	font-family:Arial;

	font-weight:normal;

	color:#000000;

}.CSSTableGenerator tr:last-child td{

	border-width:0px 1px 0px 0px;

}.CSSTableGenerator tr td:last-child{

	border-width:0px 0px 1px 0px;

}.CSSTableGenerator tr:last-child td:last-child{

	border-width:0px 0px 0px 0px;

}

.CSSTableGenerator tr:first-child td{

		background:-o-linear-gradient(bottom, #005fbf 5%, #003f7f 100%);	background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #005fbf), color-stop(1, #003f7f) );

	background:-moz-linear-gradient( center top, #005fbf 5%, #003f7f 100% );

	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#005fbf", endColorstr="#003f7f");	background: -o-linear-gradient(top,#005fbf,003f7f);



	background-color:#005fbf;

	border:0px solid #000000;

	text-align:center;

	border-width:0px 0px 1px 1px;

	font-size:14px;

	font-family:Arial;

	font-weight:bold;

	color:#ffffff;

}

.CSSTableGenerator tr:first-child:hover td{

	background:-o-linear-gradient(bottom, #005fbf 5%, #003f7f 100%);	background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #005fbf), color-stop(1, #003f7f) );

	background:-moz-linear-gradient( center top, #005fbf 5%, #003f7f 100% );

	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#005fbf", endColorstr="#003f7f");	background: -o-linear-gradient(top,#005fbf,003f7f);



	background-color:#005fbf;

}

.CSSTableGenerator tr:first-child td:first-child{

	border-width:0px 0px 1px 0px;

}

.CSSTableGenerator tr:first-child td:last-child{

	border-width:0px 0px 1px 1px;

}</style>

<div class="CSSTableGenerator">

<table width="100%" border="1" cellspacing="0" cellpadding="4">

<tr>

<td width="240" style="width:200px;">Roll No</td>

    <td width="240" style="width:200px;">Name</td>

   <?php 

$timestamp = mktime(0,0,0,$cMonth,1,$cYear);

$maxday = date("t",$timestamp);

$thismonth = getdate ($timestamp);

$startday = $thismonth['wday'];

for ($i=0; $i<($maxday+$startday); $i++) {



$timestamp = mktime(0,0,0,$cMonth,($i - $startday + 1),$cYear);

$maxweek = date("D",$timestamp);

if($maxweek=='Sun'){

$sunr='#CCCCCC';

}

elseif($maxweek=='Mon'){

$sunr='#FFFFFF';

}

elseif($maxweek=='Tue'){

$sunr='#FFFFFF';

}

elseif($maxweek=='Wed'){

$sunr='#FFFFFF';

}

elseif($maxweek=='Thu'){

$sunr='#FFFFFF';

}

elseif($maxweek=='Fri'){

$sunr='#FFFFFF';

}

elseif($maxweek=='Sat'){

$sunr='#FFFFFF';

}

 

  

    if($i < $startday) echo "";

	else 

	{



// echo $maxweek;



	//

//	echo "<td align='center' valign='middle' height='20px;' >"."<div style='width:150px;color:#FFFFFF'><a href='".($i - $startday + 1)."-".$cMonth."-".$cYear."' title='".($i - $startday + 1)."-".$cMonth."-".$cYear."'>". ($i - $startday + 1)."-".$cMonth."-".$cYear."(".$maxweek.")"."</div></a></td>";

	

	echo "<td align='center' valign='middle' height='80px;' >"."<div style='width:20px;color:#FFFFFF;font-size:11px'>". ($i - $startday + 1)."<br/>(".$maxweek.")"."</div></td>";

	$dt=($i - $startday + 1)."-".$cMonth."-".$cYear;

}}?>

    

     <td width="765">P</td>

    <td width="62"  >A</td>

    <td width="62"  >H</td>

    <td width="62"  >L</td>

    </tr>

<?php $query = "SELECT * FROM class2 WHERE session=$session && code='$code' && college='$college_id' and `CourseType`='$college_type' and `Course`='$course_name' and `Course_Details`='$Course_Details' and class_app LIKE '%$subject%' and college_roll!='' order by id";

$numresults=mysql_query($query);

$numrows=mysql_num_rows($numresults);

$result = mysql_query($query) or die("Couldn't execute query");



?>

    <?php while ( $a_row = mysql_fetch_array( $result ) )

 { 

 ?><tr>

<td style="width:200px;"><?php echo $a_row['college_roll'];?></td>

    <td style="width:200px;"><?php echo $a_row['StudentName'];?></td>

   <?php 

$timestamp = mktime(0,0,0,$cMonth,1,$cYear);

$maxday = date("t",$timestamp);

$thismonth = getdate ($timestamp);

$startday = $thismonth['wday'];



for ($i=0; $i<($maxday+$startday); $i++) {

$counter1=1;

$counter2=1;

$counter3=1;

$counter4=1;

$timestamp = mktime(0,0,0,$cMonth,($i - $startday + 1),$cYear);

$maxweek = date("D",$timestamp);

if($maxweek=='Sun'){

$sunr='#CCCCCC';

}

elseif($maxweek=='Mon'){

$sunr='#FFFFFF';

}

elseif($maxweek=='Tue'){

$sunr='#FFFFFF';

}

elseif($maxweek=='Wed'){

$sunr='#FFFFFF';

}

elseif($maxweek=='Thu'){

$sunr='#FFFFFF';

}

elseif($maxweek=='Fri'){

$sunr='#FFFFFF';

}

elseif($maxweek=='Sat'){

$sunr='#FFFFFF';

}

 

  

    if($i < $startday) echo "";

	else 

	{

	$pid=$a_row['college_roll'];

	$dt=($i - $startday + 1)."-".$cMonth."-".$cYear;

?> <td <?php if($maxweek=='Sun'){ ?> style="background-color:#FF0000; color:#FFFFFF"><?php } ?><?php 

 $queryy = "SELECT * FROM att where sid='$pid' and date='$dt'";

$resulty = mysql_query($queryy) or die("Couldn't execute query");

$a_rowy = mysql_fetch_row( $resulty );

$satt=$a_rowy[2];

?>

<?php if($satt=='P'){

$c1+=$counter1;

$counter1++;

?>

<font color="#006600" size="+0" ><i><b>

<?php echo $satt; ?></b></i></font>

    <?php }elseif($satt=='A'){

	$c2+=$counter2;

$counter2++;?>

<font color="#FF0000" size="+0"><b>

<?php echo $satt; ?>   </b></font>

    <?php }elseif($satt=='H'){

	$c3+=$counter3;

$counter3++;?>

<font color="#0000FF" size="+0"><b>

<?php echo $satt; ?>   </b></font>

    <?php }elseif($satt=='L'){

	$c4+=$counter4;

$counter4++;?>

<font color="#000000" size="+0"><b>

<?php echo $satt; ?>   </b></font>

    <?php } ?>



    </td>

<?php 

}





}?>

    

     <td  ><?php if($c1!=''){echo $c1;}else{echo '0';} ?></td>

    <td  ><?php if($c2!=''){echo $c2;}else{echo '0';} ?></td>

    <td  ><?php if($c3!=''){echo $c3;}else{echo '0';} ?></td>

    <td width="56"  ><?php if($c4!=''){echo $c4;}else{echo '0';} ?></td>

    </tr><?php

	$c1=0;$c2=0;$c3=0;$c4=0;

	$counter1=0;

$counter2=0;

$counter3=0;

$counter4=0;

	 }?> <?php /*?><tr  bgcolor='$sunr'>

<?php 

$timestamp = mktime(0,0,0,$cMonth,1,$cYear);

$maxday = date("t",$timestamp);

$thismonth = getdate ($timestamp);

$startday = $thismonth['wday'];

for ($i=0; $i<($maxday+$startday); $i++) {



$timestamp = mktime(0,0,0,$cMonth,($i - $startday + 1),$cYear);

$maxweek = date("D",$timestamp);

if($maxweek=='Sun'){

$sunr='#CCCCCC';

}

elseif($maxweek=='Mon'){

$sunr='#FFFFFF';

}

elseif($maxweek=='Tue'){

$sunr='#FFFFFF';

}

elseif($maxweek=='Wed'){

$sunr='#FFFFFF';

}

elseif($maxweek=='Thu'){

$sunr='#FFFFFF';

}

elseif($maxweek=='Fri'){

$sunr='#FFFFFF';

}

elseif($maxweek=='Sat'){

$sunr='#FFFFFF';

}

 

  

    if($i < $startday) echo "";

	else 

	{



// echo $maxweek;



	

	echo "<td align='center' valign='middle' height='20px' >"."<div style='width:150px;'><a href='".($i - $startday + 1)."-".$cMonth."-".$cYear."' title='".($i - $startday + 1)."-".$cMonth."-".$cYear."'>". ($i - $startday + 1)."-".$cMonth."-".$cYear."(".$maxweek.")"."</div></a></td>";

	$dt=($i - $startday + 1)."-".$cMonth."-".$cYear;

	//echo $dt."<br>";

	

	$query = "SELECT * FROM add_new_admision where class_t_ad='$class_t_ad'  and section='$section' order by en";

$numresults=mysql_query($query);

$result = mysql_query($query) or die("Couldn't execute query");



?>

    <?php while ( $a_row = mysql_fetch_row( $result ) )

 { 

 $pid=$a_row[2];



 ?>

  <td><?php 

 $queryy = "SELECT * FROM att where sid='$pid' and date='$dt'";

$resulty = mysql_query($queryy) or die("Couldn't execute query");

$a_rowy = mysql_fetch_row( $resulty );

$satt=$a_rowy[2];

?>

<?php if($satt=='P'){?>

<font color="#006600" size="+0" ><i><b>

<?php echo $satt; ?></b></i></font>

    <?php }elseif($satt=='A'){?>

<font color="#FF0000" size="+0"><b>

<?php echo $satt; ?>   </b></font>

    <?php }elseif($satt=='H'){?>

<font color="#0000FF" size="+0"><b>

<?php echo $satt; ?>   </b></font>

    <?php }elseif($satt=='L'){?>

<font color="#000000" size="+0"><b>

<?php echo $satt; ?>   </b></font>

    <?php } ?>



    </td>

   

    <?php }?>

    <td  ></td>

    <td  ></td>

    <td  ></td> <td  ></td>

<?php }?> <?php }

?></tr><tr>

<td  ></td>



 </tr>

  <tr>    

</table></div>







</td>

</tr>

</table>