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


// code to update the credit limit at every new month
$branch_details=getBranch($m);
if(date("d")==01 || date("d")==1 || date("d")=="01" || date("d")=="1" && $branch_details[0]['payment_type']=="Monthly" ){    

//    echo "==".date("d")."==";
    $data = array('sms_limit' => $branch_details[0]['monthly_credit']);
    $m->where("branch_id", $_SESSION['branch']);
    $result =  $m->update ('edu_branch_config', $data);

}  // ending if    
        
    $m->where("session_id", $_SESSION['current_session']);
    $sessionname = $m->get("edu_session_config");
    $years=explode("-",$sessionname[0]['session_year']);

    $date=date('m-d');

    $sql1="SELECT * FROM edu_student_details WHERE branch_id='$b' and status='0' and dob like '%-$date'";
    $StudentDOB=$m->query($sql1);

    $sql="SELECT * FROM edu_user_config WHERE branch_id='$b' and status='0' and DOB like '%-$date' order by user_id desc";

    $TeacherDOB=$m->query($sql);

    
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <title> Dashboard | EduPortal </title>
    <!-- bootstrap-progressbar -->
    <link href="../vendors/bootstrap-progressbar/css/bootstrap-progressbar-3.3.4.min.css" rel="stylesheet">
    <?php include('RootMe/css_links.php');?>
    <script src="https://cdn.zingchart.com/zingchart.min.js"></script>
    <script src="https://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
     <!-- Flaticon CSS -->
    <link rel="stylesheet" href="fonts/flaticon.css">
       
    <link rel="stylesheet" href="stylebox.css">

<style>

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

.zc-ref {
  display: none;
}
zing-grid[loading]{height:450px;}</style>
  </head>
  <style type="text/css">
      .tile-stats .icon i{
        font-size: 35px; 
      }
    </style>
  <style>
.vl {
  border-left: 1px solid lightgray;
  height: 40px;
  position: absolute;
  left: 50%;
  margin-left: -3px;
  margin-top: 24px;
}
</style>
<?php

//getting branch details

  $m->where("branch_id", $_SESSION['branch']);
  $branch_record=$m->get("edu_branch_config");

  $m->where("Month_Id", date('m'));
  $month=$m->get("eduportal_month_config");
  $current_month= date('M');
  $branch=$_SESSION['branch'];

$months = array();

$months_names = array();
$max_value;

$cout=0;
for ($i = date('m'); $i >= 1; $i--) {
  $count++;
    $months[] = str_pad($i, 2, '0', STR_PAD_LEFT);

    $months_names[] = date("F", mktime(0, 0, 0, $i, 15));
    if ($count==6) {
      break;
    }

}


$revenue = array();



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

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

    // getting  fee collections against particular months
  
     $qr="SELECT SUM(fee.collected_amount) AS total  FROM eduportal_monthly_challan as fee, edu_student_details as std WHERE fee.student_id=std.student_id and std.status='0' and fee.branch_id='$branch' and fee.paid_status='1' and fee.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];

    $revenue[] = $revenue_amount[0]['total'];

}


$salary = array();



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

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

    // getting bookings amount

    $qr = "SELECT SUM(paid_amount) AS Total FROM employee_payroll WHERE branch_id ='$branch' and paid_status = '1' and paid_date LIKE '$mon%'";

    $salary_amount = $m->query($qr);
    $salary[] = $salary_amount[0]['Total'];

}

$expense = array();

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

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

    $qr = "SELECT SUM(expense_amount) AS Total FROM eduportal_expense_detail WHERE branch_id ='$branch' and status = '0' and expense_date LIKE '$mon%'";

    $expense_amount = $m->query($qr);





    $expense[] = $expense_amount[0]['Total'];

}

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

?>
  
  <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/header1.php');?>
     
        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
            <div class="row top_tiles">


             <div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                <a href="manage_students.php">
                        <div class="dashboard-summery-one">
                            <div class="row">
                                <div class="col-md-4">
                                    <div class="item-icon bg-light-yellow">
                                        <i class="flaticon-multiple-users-silhouette text-orange"></i>
                                    </div>
                                </div>
                                <div class="col-md-8">
                                    <div class="item-content">
                                        <div class="item-title">Total Students</div>
                                        <div class="item-number"><span></span><span class="counter" data-num=""></span><?php echo totalStudents($m);?></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </a> 
                    
            </div>

               <div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                        <div class="dashboard-summery-one">
                            <div class="row">
                                <div class="col-md-4">
                                    <div class="item-icon bg-light-magenta">
                                        <i class="flaticon-checklist text-magenta"></i>
                                    </div>
                                </div>
                                <div class="col-md-8">
                                    <div class="item-content">
                                        <div class="item-title">Students Present</div>
                                        <div class="item-number"><span></span><span class="counter" data-num=""></span>
                                        <?php echo number_format(getTodayPresentStudentPercentage($m));?>%</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    
            </div>

               <div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                 <a href="print_fee_reports.php?session=gv7dus9tmrqlsae170i962isu1gv7dus9tmrqlsae170i962isu1gv7dus9tmrqlsae170i962isu1gv7dus9tmrqlsae170i962isu1gv7dus9tmrqlsae170i962isu1&class_id=All&session=<?php echo $_SESSION['current_session']; ?>&month=<?php echo date('m'); ?>&fee=1&from=<?php echo date('Y-m-d'); ?>&to=<?php echo date('Y-m-d'); ?>">
                        <div class="dashboard-summery-one">
                            <div class="row">
                                <div class="col-md-4">
                                    <div class="item-icon bg-light-blue">
                                        <i class="flaticon-money text-blue"></i>
                                    </div>
                                </div>
                                <div class="col-md-8">
                                    <div class="item-content">
                                        <div class="item-title">Today Collection</div>
                                        <div class="item-number"><span></span><span class="counter" data-num=""></span>
                                        <?php echo number_format(today_Fee($m));?></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                      </a>
                    
            </div>

               <div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                <a href="view_emp.php">
                        <div class="dashboard-summery-one">
                            <div class="row">
                                <div class="col-md-4">
                                    <div class="item-icon bg-light-red">
                                        <i class="flaticon-user text-red"></i>
                                    </div>
                                </div>
                                <div class="col-md-8">
                                    <div class="item-content">
                                        <div class="item-title">Total Staff</div>
                                        <div class="item-number"><span></span><span class="counter" data-num=""></span>
                                        <?php echo totalStaff($m);?></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                     
                    </a>
            </div>

            <div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                 <a href="student_birthday.php">
                        <div class="dashboard-summery-one">
                            <div class="row">
                                <div class="col-md-4">
                                    <div class="item-icon bg-light-blue">
                                        <i class="fa fa-birthday-cake text-blue"></i>
                                    </div>
                                </div>
                                <div class="col-md-8">
                                    <div class="item-content">
                                        <div class="item-title">Student Birthday</div>
                                        <div class="item-number"><span></span><span class="counter" data-num=""></span>
                                        <?php echo count($StudentDOB);?></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                     
                 </a>  
            </div>

            <div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                 <a href="teacher_birthday.php">
                        <div class="dashboard-summery-one">
                            <div class="row">
                                <div class="col-md-4">
                                    <div class="item-icon bg-light-green">
                                        <i class="fa fa-birthday-cake text-green"></i>
                                    </div>
                                </div>
                                <div class="col-md-8">
                                    <div class="item-content">
                                        <div class="item-title">Teacher Birthday</div>
                                        <div class="item-number"><span></span><span class="counter" data-num=""></span>
                                        <?php echo count($TeacherDOB);?></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                     
                 </a>  
            </div>

             <div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                 <a href="#">
                        <div class="dashboard-summery-one">
                            <div class="row">
                                <div class="col-md-4">
                                    <div class="item-icon bg-light-green">
                                        <i class="flaticon-user text-green"></i>
                                    </div>
                                </div>
                                <div class="col-md-8">
                                    <div class="item-content">
                                        <div class="item-title">Today Present Students</div>
                                        <div class="item-number"><span></span><span class="counter" data-num=""></span>
                                        <?php echo todayPresentStudentsCount($m);?></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                     
                 </a>  
            </div>

           <div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                 <a href="#">
                        <div class="dashboard-summery-one">
                            <div class="row">
                                <div class="col-md-4">
                                    <div class="item-icon bg-light-red">
                                        <i class="flaticon-user text-red"></i>
                                    </div>
                                </div>
                                <div class="col-md-8">
                                    <div class="item-content">
                                        <div class="item-title">Today Absent Students</div>
                                        <div class="item-number"><span></span><span class="counter" data-num=""></span>
                                        <?php echo todayAbsentStudentsCount($m); ?></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                     
                 </a>  
            </div>

             <div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                 <a href="#">
                        <div class="dashboard-summery-one">
                            <div class="row">
                                <div class="col-md-4">
                                    <div class="item-icon bg-light-yellow">
                                        <i class="flaticon-user text-orange"></i>
                                    </div>
                                </div>
                                <div class="col-md-8">
                                    <div class="item-content">
                                        <div class="item-title">Today Leave</div>
                                        <div class="item-number"><span></span><span class="counter" data-num=""></span>
                                        <?php echo todayLeaveStudentsCount($m); ?></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                     
                 </a>  
            </div>

   

                            <div style="text-align: center;">
                              <ul class="verticle_bars list-inline">
                                <li>
                                  <div class="progress vertical progress_wide bottom">
                                    <div class="progress-bar progress-bar-dark" role="progressbar" data-transitiongoal="<?php //echo getTodayPresentStudentPercentage($m); ?>"></div>
                                  </div>
                                </li>
                               
                               
                                
                              </ul>
                            </div>
                            

                            


     

               


              </div>

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

    <?php include('RootMe/js_linksscript.php');?>
    <!-- Chart.js -->
    <script src="../vendors/Chart.js/dist/Chart.min.js"></script>
     <!-- ECharts -->
    <script src="../vendors/echarts/dist/echarts.min.js"></script>
    <script src="../vendors/echarts/map/js/world.js"></script>
    <!-- bootstrap-progressbar -->
    <script src="../vendors/bootstrap-progressbar/bootstrap-progressbar.min.js"></script>
     <script src="../vendors/morris.js/morris.min.js"></script>
    <!-- Custom Theme Scripts -->
    <script src="../build/js/custom.min.js"></script>
     <!-- easy-pie-chart -->
    <script src="../vendors/jquery.easy-pie-chart/dist/jquery.easypiechart.min.js"></script>
      <!-- morris.js -->
    <script src="../vendors/raphael/raphael.min.js"></script>
    <script src="../vendors/morris.js/morris.min.js"></script>

  </body>
</html>
