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


 
     ?>


<!DOCTYPE html>
<html lang="en">
  <head>
    <script src="https://cdn.zingchart.com/zingchart.min.js"></script>
    <title>Monthly Usage SMS | EduPortal</title>
    <?php include('RootMe/css_links.php');?>
  
<script src="https://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
 
  </head>
  
<style>

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

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







<script type="text/javascript">




function delete_student(id,b){

    

    if (window.XMLHttpRequest) {

      // code for IE7+, Firefox, Chrome, Opera, Safari

      xmlhttp=new XMLHttpRequest();

    } else { // code for IE6, IE5

      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

    }

    xmlhttp.onreadystatechange=function() {

      if (xmlhttp.readyState==4 && xmlhttp.status==200) {

        document.getElementById("listofstudents").innerHTML=xmlhttp.responseText;
         //alert(xmlhttp.responseText);

      }

    }

    xmlhttp.open("GET","parent/delete_student.php?id="+id+"&b="+b,true);

    xmlhttp.send();




  }



</script>
<?php


$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));

}


$revenue = array();



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

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





    // getting bookingsWorldWide amount
    
    $qr = "SELECT SUM(collected_amount) AS Total FROM eduportal_monthly_challan WHERE branch_id ='$branch' and paid_status = '1' and paying_date LIKE '%$mon'";
//echo "$qr";
    $revenue_amount = $m->query($qr);



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

$branch=$_SESSION['branch'];

 $qr2= "SELECT sum(`attendance_msg`) as att,sum(`result_msg`) as rslt, sum(`fee_msg`) as fe, sum(`salary_msg`) as sal, sum(`other_msg`) as oth  FROM `edu_messages_details` where branch_id='$branch' and msg_date like '$new_month%'";
 //echo $qr2;

  $annual = $m->query($qr2);
  $annual_amount2=$annual[0]['att']+$annual[0]['rslt']+$annual[0]['fe']+$annual[0]['sal']+$annual[0]['oth'];

    $revenue[] = $annual_amount2;

}




$max_value=max($revenue);
array_push($max_value);
array_push($months_names);
array_push($revenue);

?>



  <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="">
           
<?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 months =<?php echo json_encode($months_names) ?>;
        var revenue =<?php echo json_encode($revenue) ?>;
        var max_value=<?php echo json_encode($max_value) ?>;
        max_value=100+"";
      //alert(max_value);

    ZC.LICENSE=["569d52cefae586f634c54f86dc99e6a9", "b55b025e438fa8a98e32482b5f768ff5"];var myConfig = {
    "graphset": [
        {
            "type": "bar",
            "background-color": "white",
            "title": {
                "text": " SMS Usage Statistics",
                "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": max_value,
                "guide": {
                    "visible": true
                },
                "label": {
                  "text": "Total (SMS)",
                  "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 SMS"
                }
            },
            "series": [
         
                {
                    "values":revenue,
                    "alpha": 0.95,
                    "borderRadiusTopLeft": 7,
                    "background-color": "#8dd3c7",
                    "text": "Usage SMS"
                },
              
            ]
        }
    ]
};

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

           
          </div>
        </div>

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

    
  <?php include('RootMe/js_linksscript.php');?>
  </body>
</html>
