<?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.php"); ?>
<?php

$session1;
      if($_REQUEST['session']!=NULL){

       $session1=$_REQUEST['session'];
     }else {
       $session1=$_SESSION['current_session'];
     }


       $m->where("student_id", $_REQUEST['std']);
       $m->where("branch_id", $_SESSION['branch']);
       $students = $m->get("edu_student_details");

       $m->where("class_id", $students[0]['class_id']);
       $class=$m->get("edu_class_config");

       $m->where("section_id", $students[0]['section_id']);
       $section=$m->get("edu_adm_section_detail");

       $m->where("session_id", $students[0]['session_id']);
       $session=$m->get("edu_session_config");
 
     ?>


<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <script src="https://cdn.zingchart.com/zingchart.min.js"></script>
<script src="https://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Monthly Result Graph | EduPortal</title>
    <!-- Bootstrap -->
    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- bootstrap-daterangepicker -->
    <link href="../vendors/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">

    <!-- Custom Theme Style -->
    <link href="../build/css/custom.min.css" rel="stylesheet">
    <link href="<?php echo DOMAIN;?>Production/css/style1.css" rel="stylesheet">
   
  </head>
    
<style>

#myChart {
  height:100%;
  width:100%;
  min-height:400px;
}

.zc-ref {
  display: none;
}
zing-grid[loading]{height:450px;}
</style>

<style>

#myChart1 {
  height:100%;
  width:100%;
  min-height:400px;
}

.zc-ref {
  display: none;
}
zing-grid[loading]{height:450px;}
</style>

<?php
$branch=$_SESSION['branch'];


//print_r($dateArray);
 $dateArray=array();
 $terms_ids=array();
$sql = "select * from  eduportal_exam_terms where branch_id=".$_SESSION['branch']." and session_id='$session1' order by term_title asc";

     $terms = $m->query($sql);
     $count=1;
      foreach($terms as $term)
      { 
      $dateArray[]=$term['term_title'];
      $terms_ids[]=$term['term_id'];
      }

$result = array();

for($i=0; $i < count($terms_ids); $i++){
  
// this code is used to fetch all Term Test result

$trm=$terms_ids[$i];
 $query="SELECT SUM(obtained_marks)as obt,SUM(total_marks) as tm,sms_status from eduportal_exam_marksheet where branch_id='$branch' and session_id='$session1' AND term_id='$trm' AND student_id=".$_GET['std'];

 $marks = $m->query($query);

  $student_result=($marks[0]['obt'])/($marks[0]['tm'])*100;

 //echo "$annual_amount2";
   $result[] = $student_result;

}


array_push($dateArray);
array_push($result);

/*-------------------------------------------------------------------------------------------*/

$branch=$_SESSION['branch'];
$stdid=$_GET['std'];

$months = array();

$months_names = array();
$max_value;


for ($i = 1; $i <= 12; $i++) {



    $months[] = str_pad($i, 2, '0', STR_PAD_LEFT);

    $months_names[] = date("F", mktime(0, 0, 0, $i, 15));

}

$attendance = array();

for ($i = 0; $i < count($months); $i++) {

    $mon = $months[$i] . "-" . date("Y");
//echo $i;
  
// this code is used to fetch all the other fee paraments of current month
$new_month=date("Y") . "-" . $months[$i];

 $att_qr= "SELECT count(att.attendance) as total FROM `eduportal_attendance_detail` as att, edu_student_details as st where att.branch_Id='$branch' and att.attendance='P' and st.status='0' and att.student_id=st.student_id and att.student_id='$stdid' and att.date like '$new_month%'";
//echo $att_qr;

 $P=$m->query($att_qr);

 //echo $P;
  $weekly_attendance= $P[0]['total'];

 //echo "$annual_amount2";
   $attendance[] = $weekly_attendance;

}




$absents = array();

for ($i = 0; $i < count($months); $i++) {

    $mon = $months[$i] . "-" . date("Y");

    // getting bookings amount
    $new_month=date("Y") . "-" . $months[$i];

    $qr = "SELECT count(att.attendance) as total FROM `eduportal_attendance_detail` as att, edu_student_details as st where att.branch_Id='$branch' and att.attendance='A' and st.status='0' and att.student_id=st.student_id and att.student_id='$stdid' and att.date like '$new_month%'";
   
    $A=$m->query($qr);
    $weekly_absents = $A[0]['total'];





    $absents[] = $weekly_absents;

}

$leave = array();

for ($i = 0; $i < count($months); $i++) {

    $mon = $months[$i] . "-" . date("Y");

    // getting bookings amount
    $new_month=date("Y") . "-" . $months[$i];
    $qr = "SELECT count(att.attendance) as total FROM `eduportal_attendance_detail` as att, edu_student_details as st where att.branch_Id='$branch' and att.attendance='L' and st.status='0' and att.student_id=st.student_id and att.student_id='$stdid' and att.date like '$new_month%'";
 
    $total_stds2=totalStudents($m);
    $L=$m->query($qr);
    $weekly_leaves = $L[0]['total'];





    $leave[] = $weekly_leaves;

}



array_push($months_names);
array_push($attendance);
array_push($absents);
array_push($leave);


?>

  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
     
            <?php include('RootMe/sidebar.php');?>

              <?php include('RootMe/header.php');?>
     
        <!-- page content -->
          <div class="right_col" role="main">
          <div class="">
     
 

<div class="col-lg-12 col-lg-offset-0 text-center page-title">
<table width="100%"  style="font-size:16px;"  >  
   
   
      <tr>  
         <td width="">Name: <?php echo $students[0]['first_name']." ".$students[0]['last_name'];?>   </td>
         
         <td width=""> Class: <?php echo $class[0]['Class_Name']." ".$section[0]['section_name'];?>   </td>
        
         <td width=""> Roll No: <?php echo $students[0]['candidate_roll_no'];?></td>
         <td width=""> Session: <?php echo $session[0]['session_year'];?>   </td>
       
      </tr>

  
   </table>
   </div>

<?php // restricting user from this page || $_SESSION['user_id']!=213 

if($_SESSION['user_id']!=213 && $_SESSION['user_id']!=212 && $_SESSION['user_id']!=227){

?>
  
<div id='myChart' style="margin-top:5%;"></div>


<?php } ?>

 <script type="text/javascript">
 $(function () {

        var dateArray =<?php echo json_encode($dateArray) ?>;
        var result =<?php echo json_encode($result) ?>;
      
       //alert(dateArray);

    ZC.LICENSE=["569d52cefae586f634c54f86dc99e6a9", "b55b025e438fa8a98e32482b5f768ff5"];var myConfig = {
    "graphset": [
        {
            "type": "bar",
            "background-color": "white",
            "title": {
                "text": " Result Graph",
                "font-color": "#7E7E7E",
                "backgroundColor": "none",
                "font-size": "22px",
                "alpha": 1,
                "adjust-layout":true,
            },
            "plotarea": {
                "margin": "dynamic"
            },
            "legend": {
                "layout": "x3",
                "overflow": "page",
                "alpha": 0.05,
                "shadow": false,
                "align":"center",
                "adjust-layout":true,
                "marker": {
                    "type": "circle",
                    "border-color": "none",
                    "size": "10px"
                },
                "border-width": 0,
                "maxItems": 3,
                "toggle-action": "hide",
                "pageOn": {
                    "backgroundColor": "#000",
                    "size": "10px",
                    "alpha": 0.65
                },
                "pageOff": {
                    "backgroundColor": "#7E7E7E",
                    "size": "10px",
                    "alpha": 0.65
                },
                "pageStatus": {
                    "color": "black"
                }
            },
            "plot": {   
                "bars-space-left":0.15,
                "bars-space-right":0.15,
                "animation": {
                    "effect": "ANIMATION_SLIDE_BOTTOM",
                    "sequence": 0, 
                    "speed": 800,
                    "delay": 800
                }
            },
            "scale-y": {
                "line-color": "#7E7E7E",
                "item": {
                    "font-color": "#7e7e7e"
                },
                "values":'100',
                "guide": {
                    "visible": true
                },
                "label": {
                  "text": "Result (Percentage)",
                  "font-family": "arial",
                  "bold": true,
                  "font-size": "14px",
                  "font-color": "#7E7E7E",
                },
            },
           
            "scaleX":{
                "values":dateArray,
                "placement":"default",
                "tick":{
                    "size":58,
                    "placement":"cross"
                },
                "itemsOverlap":true,
                "item":{
                    "offsetY":-55
                }
            },
          
            "tooltip": {
              "visible": false
            },
            "crosshair-x":{
                "line-width":"100%",
                "alpha":0.18,
                "plot-label":{
                  "header-text":"%kv Result"
                }
            },
            "series": [
         
                {
                    "values":result,
                    "alpha": 0.95,
                    "borderRadiusTopLeft": 7,
                    "background-color": "#8dd3c7",
                    "text": "Results"
                },
                
              
            ]
        }
    ]
};

zingchart.render({ 
  id : 'myChart', 
  data : myConfig, 
  height: '100%', 
  width: '100%' 
 });
});
</script>

<!------------------------------------------------------------------------------------------->

<div id='myChart1' style="margin-top:5%;"></div>



  <script type="text/javascript">
 $(function () {

        var months =<?php echo json_encode($months_names) ?>;
        var attendance =<?php echo json_encode($attendance) ?>;
        var absents =<?php echo json_encode($absents) ?>;
         var leave =<?php echo json_encode($leave) ?>;
       //alert(dateArray);

    ZC.LICENSE=["569d52cefae586f634c54f86dc99e6a9", "b55b025e438fa8a98e32482b5f768ff5"];var myConfig = {
    "graphset": [
        {
            "type": "bar",
            "background-color": "white",
            "title": {
                "text": "Monthly Attendance Graph",
                "font-color": "#7E7E7E",
                "backgroundColor": "none",
                "font-size": "22px",
                "alpha": 1,
                "adjust-layout":true,
            },
            "plotarea": {
                "margin": "dynamic"
            },
            "legend": {
                "layout": "x3",
                "overflow": "page",
                "alpha": 0.05,
                "shadow": false,
                "align":"center",
                "adjust-layout":true,
                "marker": {
                    "type": "circle",
                    "border-color": "none",
                    "size": "10px"
                },
                "border-width": 0,
                "maxItems": 3,
                "toggle-action": "hide",
                "pageOn": {
                    "backgroundColor": "#000",
                    "size": "10px",
                    "alpha": 0.65
                },
                "pageOff": {
                    "backgroundColor": "#7E7E7E",
                    "size": "10px",
                    "alpha": 0.65
                },
                "pageStatus": {
                    "color": "black"
                }
            },
            "plot": {   
                "bars-space-left":0.15,
                "bars-space-right":0.15,
                "animation": {
                    "effect": "ANIMATION_SLIDE_BOTTOM",
                    "sequence": 0, 
                    "speed": 800,
                    "delay": 800
                }
            },
            "scale-y": {
                "line-color": "#7E7E7E",
                "item": {
                    "font-color": "#7e7e7e"
                },
                "values":'30',
                "guide": {
                    "visible": true
                },
                "label": {
                  "text": "Attendance",
                  "font-family": "arial",
                  "bold": true,
                  "font-size": "14px",
                  "font-color": "#7E7E7E",
                },
            },
           
            "scaleX":{
                "values":months,
                "placement":"default",
                "tick":{
                    "size":58,
                    "placement":"cross"
                },
                "itemsOverlap":true,
                "item":{
                    "offsetY":-55
                }
            },
          
            "tooltip": {
              "visible": false
            },
            "crosshair-x":{
                "line-width":"100%",
                "alpha":0.18,
                "plot-label":{
                  "header-text":"%kv Attendance"
                }
            },
            "series": [
         
                {
                    "values":attendance,
                    "alpha": 0.95,
                    "borderRadiusTopLeft": 7,
                    "background-color": "#8dd3c7",
                    "text": "Presents"
                },
                {
                    "values":absents,
                    "borderRadiusTopLeft": 7,
                    "alpha": 0.95,
                    "background-color": "#fdb462",
                    "text": "Absents "
                },
                {
                    "values":leave,
                    "borderRadiusTopLeft": 7,
                    "alpha": 0.95,
                    "background-color": "#8993c7",
                    "text": "Leaves "
                },
              
            ]
        }
    ]
};

zingchart.render({ 
  id : 'myChart1', 
  data : myConfig, 
  height: '100%', 
  width: '100%' 
 });
});
</script>

          </div>
        </div>

            </div>
          </div>
        </div>
        <!-- /page content -->
  

    <!-- jQuery -->
    <script src="../vendors/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap -->
    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>    
    <!-- Custom Theme Scripts -->
    <script src="../build/js/custom.min.js"></script>

    <!-- morris.js -->
    <script src="../vendors/raphael/raphael.min.js"></script>
    <script src="../vendors/morris.js/morris.min.js"></script>
  
  </body>
</html>
