  <div class="card">
    <div class="card-body">
<h2>ภาคเรียนที่ <?=$semester?> ปีการศึกษา <?=$academicYear?> </h2>
<!-- <div align="right"><a href="?op=summarize&module=groups-list&show=all" class="btn btn-secondary" role="button"> <i class="fa fa-share" aria-hidden="true"></i> แสดงกลุ่มเรียนทั้งหมด</a> </div> -->
		<p>ข้อมูลจำนวนกลุ่มเรียน และจำนวนนักเรียน นักศึกษาที่ร่วมกิจกรรมหน้าเสาธง ภาคเรียนที่ <?=$semester?> ปีการศึกษา <?=$academicYear?> </p>




 <?php
global $connect;	
$sql="Select * From regis_level order by level_id  ASC";
$db_query=mysqli_query($connect,$sql);
$num_rows=mysqli_num_rows($db_query); /* นับ Reccord ที่พบ */
//echo "มีจำนวน <b>$num_rows</b> รายการ <font color=\"#9E0002\">คลิก ปุ่มรายละเอียด เพื่อแสดงกลุ่มเรียน </font>";

?>
  <table class="table table-hover table-striped table-condensed table-sm table-bordered ">
    <thead>
      <tr>
        <th width="10%"><center>#</center></th>
        <th>ระดับ</th>
		  <th style="text-align: right" width="25%">จำนวนกลุ่มเรียน</th>
  		 <th style="text-align: right" width="25%">จำนวนนักศึกษา</th> 
      </tr>
    </thead>
    <tbody>
	<?php
$a=0;
$no=1;
$sum_group=0;				
$sum_student=0;		
while($a < $num_rows)
{
	$result = mysqli_fetch_array($db_query);
	$level_id=$result['level_id'];
	$level_name=$result['level_name'];

	$num_regis_group=num_record("regis_group","where level_no='$level_id' AND academicYear='$academicYear' AND semester='$semester' AND status='1' ");
	
	//echo num_regis_group;
	if($num_regis_group!=0){
		$sum_group=$sum_group+$num_regis_group;
	?>	
    	
		
      <tr>
        <td align="center"><?php echo $no;?>.<a name="<?=$level_id?>" id="<?=$level_id?>"></a></td>
        <td> <?php if($_GET['id']==$level_id){ echo"<i class=\"fa fa-check fa-2x\" aria-hidden=\"true\" style=\"color:green\"></i> ";}
		echo "$level_name"; ?></td>
		 <td style="text-align: right"><?=$num_regis_group?> กลุ่มเรียน</td> 	   

		<td style="text-align: right"><?php //ตรวจสอบว่ามีรายการนี้หรือยัง
		$result_regis_summarize_student=select("regis_summarize_student","where academicYear='$academicYear' AND semester='$semester' AND summarize_name='$level_name' ");  
		$totalStudent=$result_regis_summarize_student["totalStudent"]; 
		$sum_student=$sum_student+$totalStudent;
		echo "<b>"; 
		echo number_format($totalStudent); 
		echo"</b> คน"; 
		?> 
	</td>  
      </tr>



   <?php
				$no++;
			}
		$a++;
}
	
	?>
<tr>
	<td colspan="2"><center><b>รวม</b></center></td>
	 <td align="center" style="text-align: right"><b><?php echo number_format($sum_group); ?></b> กลุ่มเรียน</td> 	
	<td style="text-align: right"><b><?php echo number_format($sum_student); ?></b> คน</td>
</tr>

    </tbody>
  </table>
<!--- รูป pie ---->
<script src="Highcharts-6.0.3/highcharts.js"></script>
<script src="Highcharts-6.0.3/modules/exporting.js"></script>
<?php


//echo" ยังไม่เข้าระบบ $num_nologin <br>";
//echo" รอการชำระเงิน $num_login <br>";
//echo" ชำระเงินเรียบร้อย $num_ok <br>";
?>
  <p>ข้อมูลการร่วมกิจกรรมฯ ของนักเรียน นักศึกษา ภาคเรียนที่ <?=$semester?> ปีการศึกษา <?=$academicYear?> </p>              
<div class="row">
<div class="container">   
<h3><i class="fa fa-calendar fa-1x" aria-hidden="true"></i> วันในสัปดาห์ ภาคเรียนที่ <u><?=$semester?></u>  ปีการศึกษา  &nbsp;<u><?=$academicYear?></u> </h3>    
<?php
global $connect;	
$sql="Select * From week_day where status='1'  order by day_id  ASC";
$db_query=mysqli_query($connect,$sql);
$num_rows=mysqli_num_rows($db_query); /* นับ Reccord ที่พบ */
echo "วันที่ร่วมกิจกรรมฯ   จำนวน &nbsp;  <u>$num_rows</u>&nbsp;  วัน ";

?>

  <table class="table table-hover table-striped table-condensed table-sm table-bordered ">
    <thead>
      <tr>
        <th><center>#</center></th>
        <th><center>ชื่อวัน</center></th>
		  <th><center>ตัวย่อ</center></th>
		  <th><center>(w)</center></th>
		  <th><center>จำนวนกลุ่มเรียน/ห้องเรียน</center></th>
		  <th><center>จำนวนนักเรียน นักศึกษา</center></th>	 
		  <th><center>จัดการ</center></th>
      </tr>
    </thead>
    <tbody>
	<?php
$a=0;
$no=1;	
$num_group_all=0;        
$num_student_all=0;	
while($a < $num_rows)
{
	$result = mysqli_fetch_array($db_query);
	$day_id=$result['day_id'];
	$day_name=$result['day_name'];
	$day_name_eng=$result['day_name_eng'];
	$day_name_short=$result['day_name_short'];
	$w=$result['w'];
    //นับจำนวนกลุ่มเรียน
    $num_week_group=num_record("week_group","where academicYear='$academicYear' AND semester='$semester' AND  day_id='$day_id' ");
    $num_group_all=$num_group_all+$num_week_group;
    //นับจำนวนผู้นักเรียน นักศึกษา
    $sql_week_group="Select * From week_group where academicYear='$academicYear' AND semester='$semester' AND  day_id='$day_id' ";
    $db_query_week_group=mysqli_query($connect,$sql_week_group);
    $num_rows_week_group=mysqli_num_rows($db_query_week_group); 
    //echo "num_rows_week_group=$num_rows_week_group";
    $a_week_group=0;
    $num_student=0;
    while($a_week_group < $num_rows_week_group){
        $result_week_group = mysqli_fetch_array($db_query_week_group);
	    $groupCode=$result_week_group['groupCode'];
        $num_student2=num_record("std2018_student","where groupCode='$groupCode' AND studentStatusCode='03'");
        $num_student=$num_student+$num_student2;
        $num_student_all=$num_student_all+$num_student2;
        //echo "groupCode=$groupCode<br>";
    
        $a_week_group++;
    }
	?>	
    	
		
      <tr>
        <td align="center"><?php echo $no;?>.<a name="<?=$day_id?>" id="<?=$day_id?>"></a></td>
        <td><center><?=$day_name?></center></td>
		 <td><center><?=$day_name_short?></center></td>
		 <td><center><?=$w?></center></td>
		 <td><center><?php if($num_week_group==0){ echo "-"; }else{ echo $num_week_group; } ?></center></td>  
		 <td><center><?php if($num_student==0){ echo "-"; }else{ echo $num_student; } ?></center></td>  
		 <td><center>
         
             <a href="?op=calendar&module=group-day&p=&day=<?=$day_id?>&w=<?=$w?>&sday_name=<?=$day_name?>#data" class="btn btn-sm btn-outline-info" ><i class="fa fa-cube" aria-hidden="true"></i> รายละเอียด</a>
             </center>
    
             </td> 	   
      </tr>
   <?php
        $no++;
		$a++;
}
	
	?>
    <tr>
          <td colspan="4"><center><b>รวม</b></center></td>  
          <td><center><?=$num_group_all?></center></td>  
         <td><center><?=number_format($num_student_all)?></center></td>  

    </tr>    


    </tbody>
  </table>
    <hr>

  
    </div>
    </div>

<!-- <div id="containerpie" style="min-width: 900px; height: 500px; max-width: 600px; margin: 0 auto"></div> -->
<div id="containerpie" style="min-width: 600px;  max-width: 900px; margin: 0 auto"></div>


		<script type="text/javascript">


// Radialize the colors
Highcharts.setOptions({
    colors: Highcharts.map(Highcharts.getOptions().colors, function (color) {
        return {
            radialGradient: {
                cx: 0.5,
                cy: 0.3,
                r: 0.7
            },
            stops: [
                [0, color],
                [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
            ]
        };
    })
});

// Build the chart	
Highcharts.chart('containerpie', {
    chart: {
        plotBackgroundColor: null,
        plotBorderWidth: null,
        plotShadow: false,
        type: 'pie'
    },
    title: {
        text: 'สถิติการลงทะเบียน ภาคเรียนที่ <?=$semester?> ปีการศึกษา <?=$academicYear?> '
    },
    tooltip: {
        pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
    },
    plotOptions: {
        pie: {
            allowPointSelect: true,
            cursor: 'pointer',
            dataLabels: {
                enabled: true,
                format: '<b>{point.name}</b>: {point.percentage:.1f} %',
                style: {
                    color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                },
                connectorColor: 'silver'
            }
        }
    },

    series: [{
        name: 'นักศึกษา',
        data: [
    
            {
                name: 'เข้าระบบลงทะเบียน(รอการชำระเงิน)',
                y: <?=$num_login?>,
                sliced: true,
				color: '#A3A8FE',
                selected: true
            },
            { name: 'ยังไม่เข้าระบบลงทะเบียน', 
			 	y: <?=$num_nologin?> ,
			 	color: '#FF9693',
			},
            { name: 'ลงทะเบียนเสร็จสมบูรณ์(ชำระเงินเรียบร้อยแล้ว)', 
			 	y: <?=$num_ok?> ,
			 	color: '#04860C',
			}

        ]
    }]
});
		</script>
<!-----สิ้นสุด รุูป pic ----->

<!--- สถิติการจ่ายเงินของนักศึกษา ผ่่านอินเทอร์เน็ตแบ็งกิ้ง กับ จ่ายที่ธนาคาร -->
  <p>ข้อมูลวิธีการชำระค่าลงทะเบียนของนักศึกษา ภาคเรียนที่ <?=$semester?> ปีการศึกษา <?=$academicYear?> </p>            
  <table class="table table-hover table-striped table-condensed table-sm table-bordered ">
<?php
$result_TATAL=num_record("regis_payment_log","where academicYear='$academicYear' AND semester='$semester' ");
$result_NET2=num_record("regis_payment_log","where academicYear='$academicYear' AND 	semester='$semester' AND TransactionCode='NET' ");
$result_NET3=num_record("regis_payment_log","where academicYear='$academicYear' AND 	semester='$semester' AND TransactionCode='CNET' ");	$result_NET=$result_NET2+$result_NET3;	
$result_CSH2=num_record("regis_payment_log","where academicYear='$academicYear' AND 	semester='$semester' AND TransactionCode='CSH' ");
$result_CCSH=num_record("regis_payment_log","where academicYear='$academicYear' AND 	semester='$semester' AND TransactionCode='CCSH' ");	
$result_OTH=num_record("regis_payment_log","where academicYear='$academicYear' AND 	semester='$semester' AND TransactionCode='OTH' ");	
$result_CSH=$result_CSH2+$result_CCSH+$result_OTH;		

$percent_NET=$result_NET/$result_TATAL*100;	
		$percent_NET=number_format($percent_NET,2);		
		
$percent_CSH=$result_CSH/$result_TATAL*100;	
		$percent_CSH=number_format($percent_CSH,2);	
?>	
    <thead>
      <tr>
        <th width="10%"><center>#</center></th>
        <th>รายการ</th>
        <th width="25%" style="text-align: right">จำนวน&nbsp;&nbsp;</th>
		 <th width="25%" style="text-align: right">ร้อยละ&nbsp;&nbsp;</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><center>1.</center></td>
        <td>Mobile Banking</td>
        <td style="text-align: right"><?php echo number_format($result_NET);?>&nbsp;&nbsp;</td>
		 <td style="text-align: right"><?=$percent_NET?>&nbsp;&nbsp;</td>
      </tr>
	      <tr>
        <td><center>2.</center></td>
        <td>เคาน์เตอร์ธนาคาร</td>
        <td style="text-align: right"><?php echo number_format($result_CSH);?>&nbsp;&nbsp;</td>
		 <td style="text-align: right"><?=$percent_CSH?>&nbsp;&nbsp;</td>
      </tr>	
    </tbody>
  </table>
<div id="containerpieType" style="min-width:600px;  max-width: 900px; margin: 0 auto"></div>
<script type="text/javascript">

Highcharts.chart('containerpieType', {
    chart: {
        plotBackgroundColor: null,
        plotBorderWidth: 0,
        plotShadow: false
    },
    title: {
        text: 'วิธีการชำระเงิน',
        align: 'center',
        verticalAlign: 'middle',
        y: 40
    },
    tooltip: {
        pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
    },
    plotOptions: {
        pie: {
            dataLabels: {
                enabled: true,
                distance: -50,
                style: {
                    fontWeight: 'bold',
                    color: 'white'
                }
            },
            startAngle: -90,
            endAngle: 90,
            center: ['50%', '75%']
        }
    },
    series: [{
        type: 'pie',
        name: 'วิธีชำระเงินค่าลงทะเบียน',
        innerSize: '50%',
        data: [
            ['เคาน์เตอร์ธนาคาร',   <?=$percent_CSH?>] ,
            ['Mobile Banking',       <?=$percent_NET?>],

            {
                name: 'Proprietary or Undetectable',
                y: 0.2,
                dataLabels: {
                    enabled: false
                }
            }
        ]
    }]
});


		</script>		
		
<!-- 		
		<script type="text/javascript">

// Radialize the colors
Highcharts.setOptions({
    colors: Highcharts.map(Highcharts.getOptions().colors, function (color) {
        return {
            radialGradient: {
                cx: 0.5,
                cy: 0.3,
                r: 0.7
            },
            stops: [
                [0, color],
                [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
            ]
        };
    })
});

// Build the chart	
Highcharts.chart('containerpieType', {
    chart: {
        plotBackgroundColor: null,
        plotBorderWidth: null,
        plotShadow: false,
        type: 'pie'
    },
    title: {
        text: 'วิธีการชำระเงินของนักศึกษา ภาคเรียนที่ <?=$semester?> ปีการศึกษา <?=$academicYear?> '
    },
    tooltip: {
        pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
    },
    plotOptions: {
        pie: {
            allowPointSelect: true,
            cursor: 'pointer',
            dataLabels: {
                enabled: true,
                format: '<b>{point.name}</b>: {point.percentage:.1f} %',
                style: {
                    color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                },
                connectorColor: 'silver'
            }
        }
    },

    series: [{
        name: 'รูปแบบการชำระเงิน',
        data: [
    
            {
                name: 'ชำระเงินทางเคาน์เตอร์ธนาคาร',
                y: <?=$percent_CSH?>,
                sliced: true,
				color: '#FFBF00',
                selected: true
            },
            { name: 'ชำระเงินทาง Mobile Banking', 
			 	y: <?=$percent_NET?> ,
			 	color: '#9CC6CE',
			}

        ]
    }]
});
		</script> -->
<!--- สิ้นสดุด  สถิติการจ่ายเงินของนักศึกษา ผ่่านอินเทอร์เน็ตแบ็งกิ้ง กับ จ่ายที่ธนาคาร -->

  <p>ส่งออกข้อมูลสรุปผลการลงทะเบียนของนักเรียน นักศึกษา ภาคเรียนที่ <?=$semester?> ปีการศึกษา <?=$academicYear?> เป็นไฟล์ Excel(xls) </p>            
  <table class="table table-hover table-striped table-condensed table-sm table-bordered ">
    <thead>
      <tr>
        <th width="10%"><center>#</center></th>
        <th>รายการ</th>
        <th width="20%" style="text-align: right">จำนวน&nbsp;&nbsp;</th>
		 <th width="20%" style="text-align: right">ร้อยละ&nbsp;&nbsp;</th>
		 <th width="10%"><center>ส่งออก</center></th>    
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><center>1.</center></td>
        <td>นักศึกษายังไม่ได้ชำระเงินค่าลงทะเบียน</td>
        <td style="text-align: right"><?php echo number_format($num_total_not_regis);?>&nbsp;&nbsp;</td>
		 <td style="text-align: right"><?=$num_total_not_regis_percen?>&nbsp;&nbsp;</td>
		 <td align="center">	<a href="pages/export-studentRegisAll.php?ex=xls&key=0" class="btn btn-primary btn-sm " role="button"><i class="fa fa-file-excel-o" aria-hidden="true"></i> </a> </td> 
      </tr>
      <tr>
        <td><center>2.</center></td>
        <td>นักศึกษาลงทะเบียนเสร็จสมบูรณ์ (ชำระเงินเรียบร้อยแล้ว)</td>
        <td style="text-align: right"><?php echo number_format($num1_payment);?>&nbsp;&nbsp;</td>
		 <td style="text-align: right"><?=$num_ok?>&nbsp;&nbsp;</td> 
		 <td align="center"> <a href="pages/export-studentRegisAll.php?ex=xls&key=1" class="btn btn-primary btn-sm " role="button"><i class="fa fa-file-excel-o" aria-hidden="true"></i> </a></td>  
      </tr>
		
		   <tr>
        <td colspan="2"><center><b>รวม</b></center></td>

        <td style="text-align: right"><b><?php $total=$num_total_not_regis+$num1_payment; echo number_format($total);?>&nbsp;&nbsp;</b></td>
		 <td style="text-align: right"><b>100.00</b>&nbsp;&nbsp; </td> 
		 <td align="center"><a href="pages/export-studentRegisAll.php?ex=xls&key=2" class="btn btn-primary btn-sm " role="button"><i class="fa fa-file-excel-o" aria-hidden="true"></i></a></td>  
      </tr>
	
    </tbody>
  </table>
<a name="data" id="data"></a>
		
<?php include("pages/statistics-pament-date.php"); ?>		
<?php
		
/*
if($_GET['detail']=="list"){
	$id=$_GET['id'];
	include("admin-summarize-groups-list.php");
}
*/	

?>
</div>
</div></div>