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

<?php   

  

$month;

if($_GET["month"]!=NULL ){
  $month= $_GET["month"];
}
else{
  $month= date("m");
}

$sessionid;

if($_GET["session"]!=NULL ){
  $sessionid= $_GET["session"];
}
else{
  $sessionid= $_SESSION['current_session'];
}

$m->where("Month_Id", $month);
$month_name=$m->get("eduportal_month_config");

$m->where("session_id", $sessionid);
$session_name=$m->get("edu_session_config");




$sql = "SELECT * FROM eduportal_expense_detail as b  ";
$from;
$to;

$branch=$_SESSION['branch'];


 
      if($_REQUEST['from']!=" " && $_REQUEST['from']!=NULL ) {
        $from=date("Y-m-d",strtotime($_REQUEST['from']));  

      }else {
        $from=date("Y-m-01");  
      }
     
      if($_REQUEST['to']!=" " && $_REQUEST['to']!=NULL   ) {
        $to=date("Y-m-d",strtotime($_REQUEST['to']));
      }else {
        $to=date("Y-m-t");  
      } 
      
     
    $sql .= "where b.branch_id='$branch' and b.expense_date BETWEEN '" .$from. "' AND '" .$to. "' order by expense_id desc";


// echo $sql;

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

?>


<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>Two Month Income & Exp Report | EduPortal</title>
    <?php include('RootMe/css_links.php');?>
  

  </head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

  <style>
#snackbar {
  visibility: hidden;
  min-width: 250px;
  margin-left: -125px;
  background-color: #1E90FF;
  color: #fff;
  text-align: right;
  border-radius: 2px;
  padding: 16px;
  position: fixed;
  z-index: 1;
  left: 80%;
  bottom: 30px;
  font-size: 17px;
}

#snackbar.show {
  visibility: visible;
  -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
  animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

@-webkit-keyframes fadein {
  from {bottom: 0; opacity: 0;} 
  to {bottom: 30px; opacity: 1;}
}

@keyframes fadein {
  from {bottom: 0; opacity: 0;}
  to {bottom: 30px; opacity: 1;}
}

@-webkit-keyframes fadeout {
  from {bottom: 30px; opacity: 1;} 
  to {bottom: 0; opacity: 0;}
}

@keyframes fadeout {
  from {bottom: 30px; opacity: 1;}
  to {bottom: 0; opacity: 0;}
}
</style>
  <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">

            <a href="<?php echo $_SESSION['dashboard'];?>">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
                Two Months Income and Expense Report
            <br><br>

          <div class="row" style="background-color: white;">
           
  <section class="add_sub_agent" id="table_sub_agent">
  <div class="container">

 <div class="" style="margin-top:10px;">
   

   <form class="form-style-7">

    
  <div style="overflow-x:auto;">
                      
           


              <div class="col-md-3 col-sm-12 col-xs-12" style="padding:8px; float:left;"  id="col1">
                 <div class="form-group ">

                 <label class="required"> From Date</label>
                 <input name="from"  id="from" value="<?php echo $from;?>" type="date" class="form-control"  >
                       
                  </div>
                  </div>                      
             

                  <div class="col-md-3 col-sm-12 col-xs-12" style="padding:8px; float:left;"  id="col2">

                       <div class="form-group ">

                          <label class="required"> To Date</label>
                              <input name="to" id="to" value="<?php echo $to;?>" type="date" class="form-control"  >
                       
                          </div>
                  </div>


              

              <div class="col-md-4 " style="padding:2px;">
    
          

                <div class="form-group ">
                   
                <button id="send" type="submit" class="btn btn-primary" style="margin-top: 34px;"> 
                Search</button>
                <a href="print_months_incexp_report.php?from=<?php echo $from; ?>&to=<?php echo $to;?>" id="subuser" class="btn btn-primary" style="margin-top: 34px;">Print Report </a>

                <a data-toggle="modal" data-target="#ClosingReportDateWise" class="btn btn-primary" style="margin-top: 34px;"> DateWise Income & Expense</a>


               
                </div>

        

              </div>
</form>


 <!-- start popup code -->

<div id="ClosingReportDateWise" class="modal fade" role="dialog">
<div class="modal-dialog">

<!-- Modal content-->
<div class="modal-content">
<div class="modal-header" style="border-bottom:none;">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title" style="text-align:center;">   </h4>
</div>

<div class="modal-body">

<form  action="datewise_income_expense_report.php">
<input type="hidden" name="session" value="kjdahsfkjhasdjkfhkjasdfkjdshfkjadshfdsncnkdjashfsdafkjbdnasjkckasjdfjdsfkjdsbfkjbdsfjkbdskjfkjdshfkjdhskjcnjdas">
<div class="col-md-12" style="padding: 8px;">


<div class="form-group ">

<label class="required">From Date</label>

<input type="date" name="from_date" class="form-control"
value="<?php echo date("Y-m-d");?>"  />

</div>


<div class="form-group ">

<label class="required">To Date</label>

<input type="date" name="to_date" class="form-control"
value="<?php echo date("Y-m-d");?>"  />

</div>


</div> 



<div class="modal-footer">

<button type="submit" class="btn btn-primary" name="submit" >Submit </button>



</div>



</form>

</div>

</div>

</div>
</div>

<!-- popup ending -->
      

       <!-- page content -->
        
          
      <br><br><br><br><br>

<div style="text-align:center;font-size:20px;font-weight:bold;">Monthly Income & Expense Report </div>
<div style="text-align:center;font-size:18px;font-weight:bold;">Session: (<?php echo $session_name[0]['session_year'] ?>) </div>


<?php 
$expense_amount=$expense[0]['total'] + $salary[0]['total'];
?>
<br><br>
<div>

<div style="width: 48%; float: left;">

<!--   <h3 style="text-align: left;margin-left: 10px;">Month Name: <?php echo date("F");?></h3> -->
    <table style="width:100%;float: left;" cellspacing="0">
          
          <thead>
            <tr>
                <th width="3%" class="center padng"style="font-size:17px;">S.No</th>
                <th colspan="2" width="10%" class="center padng"style="font-size:17px;">Expenses</th>            
               
                 
            </tr>

            <tr>
                <th width="3%" class="center padng"style="font-size:14px;"></th>
                <th width="10%" class="center padng"style="font-size:14px;">Particular</th>
                <th width="10%" class="center padng"style="font-size:14px;">Amount</th>
                
                 
            </tr>
<?php    

$count=1;

foreach($expenses as $category){

   $m->where("category_id", $category['category_id']);
  $ctgry=$m->get("eduportal_expanse_category");

  $m->where("subcategory_id", $category['subcategory_id']);
  $sbctgry=$m->get("eduportal_expanse_subcategory");

  
$total_amount+=$category['expense_amount'];

?>

            <tr>
                <td width="3%" class="center padng"style="font-size:17px;"><?php echo $count++;?></td>
                <td width="10%" class=" padng"style="font-size:17px;"><?php echo $sbctgry[0]['subcategory_name'];?></td>
                <td width="10%" class="center padng"style="font-size:17px;"> <?php echo $category['expense_amount'];?> </td>
                 
            </tr>

<? } ?>



            <tr>
                
                <th width="10%" class="center padng"style="font-size:17px;border-top: none;background-color: lightgray;"colspan="2">Total Amount</th>
                <th width="10%" class="center padng"style="font-size:17px;border-top: none;background-color: lightgray;"> <?php echo number_format($total_amount)?> </th>
                 
            </tr>





             
        </thead>
        <tbody>
   
                       
              
             
        </tbody>
        
    </table>
  
</div>
<div style="width: 48%; float: right;">


    <table style="width:100%;float: left;" cellspacing="0">
          
          <thead>
            <tr>
                <th width="3%" class="center padng"style="font-size:17px;">S.No</th>
                <th colspan="2" width="10%" class="center padng"style="font-size:17px;">Income</th>
             
               
                 
            </tr>

            <tr>
                <th width="3%" class="center padng"style="font-size:14px;"></th>
                <th width="10%" class="center padng"style="font-size:14px;">Particular</th>
                <th width="10%" class="center padng"style="font-size:14px;">Amount</th>
                
                 
            </tr>
<?php        
foreach($expenses as $category){

   $m->where("category_id", $category['category_id']);
  $ctgry=$m->get("eduportal_expanse_category");

  $m->where("subcategory_id", $category['subcategory_id']);
  $sbctgry=$m->get("eduportal_expanse_subcategory");

  
$total_amount+=$category['expense_amount'];

?>

            

<? } ?>

            <tr>
            <td width="1%" class="center padng">0</td>
            <td width="10%" class="padng">Previous Balance</td>
            <td width="10%" class="center padng"><?php $pre_bal=getMoreMonthsRegularFee($sessionid,$from,$to,'balance',$m);  echo number_format($pre_bal); ?></td>
                                   
            </tr>

            <tr>
              <td width="1%" class="center padng">1</td>
              <td width="10%" class="padng">Tuition Fee</td>
              <td width="10%" class="center padng"><?php $tution_fee=getMoreMonthsRegularFee($sessionid,$from,$to,'tutionfee',$m);  echo number_format($tution_fee); ?></td>
                                      
            </tr>

            <tr>
              <td width="1%" class="center padng">2</td>
              <td width="10%" class="padng"><?php if ($brid[0]['misc_title']!=NULL){echo $brid[0]['misc_title'];}else {echo 'Miscellaneous';} ?></td>
              <td width="10%" class="center padng"><?php $misc_fee=getMoreMonthsRegularFee($sessionid,$from,$to,'misc_fee',$m);  echo number_format($misc_fee); ?></td>
                                      
            </tr>

             <tr>
              <td width="1%" class="center padng">3</td>
              <td width="10%" class="padng"> Transport Fee</td>
              <td width="10%" class="center padng"><?php $trans_fee=getMoreMonthsRegularFee($sessionid,$from,$to,'transportfee',$m);  echo number_format($trans_fee); ?></td>                                    
            </tr>

            <tr>
              <td width="1%" class="center padng">4</td>
              <td width="10%"class="padng">Admission Fee</td>
              <td width="10%" class="center padng">
                <?php $adm_fee=getMoreAllotherFeeWithType_Summary($from,$to,1,0,$m);  echo number_format($adm_fee); ?></td>                                      
            </tr>

             <tr>
              <td width="1%" class="center padng">5</td>
              <td width="10%" class="padng">Paper Fund</td>
              <td width="10%" class="center padng">
                <?php $pap_fund=getMoreAllotherFeeWithType_Summary($from,$to,2,0,$m);  echo number_format($pap_fund); ?></td>                                      
            </tr>

             <tr>
              <td width="1%" class="center padng">6</td>
              <td width="10%" class="padng">Library Fee</td>
              <td width="10%" class="center padng">
                <?php $lib_fee=getMoreAllotherFeeWithType_Summary($from,$to,3,0,$m);  echo number_format($lib_fee); ?></td>
                             
             </tr>

             <tr>
              <td width="1%" class="center padng">7</td>
              <td width="10%"class="padng">Lab Fee</td>
              <td width="10%" class="center padng">
                <?php $lab_fee=getMoreAllotherFeeWithType_Summary($from,$to,4,0,$m);  echo number_format($lab_fee); ?></td>
                                      
            </tr>

             <tr>
              <td width="1%" class="center padng">8</td>
              <td width="10%"class="padng">Other Fee</td>
              <td width="10%" class="center padng">
                <?php $othr_fee=getMoreAllotherFeeWithType_Summary($from,$to,5,0,$m);  echo number_format($othr_fee); ?></td>
                                      
            </tr>

            <tr>
              <td width="1%" class="center padng">9</td>
              <td width="10%"class="padng">Registration Fee</td>
              <td width="10%" class="center padng">
                <?php $Reg_fee=getMoreAllotherFeeWithType_Summary($from,$to,6,0,$m);  echo number_format($Reg_fee); ?></td>
                                      
            </tr>

            <tr>
              <td width="1%" class="center padng">10</td>
              <td width="10%"class="padng">Security Fee</td>
              <td width="10%" class="center padng">
                <?php $secu_fee=getMoreAllotherFeeWithType_Summary($from,$to,7,0,$m);  echo number_format($secu_fee); ?></td>
                                      
            </tr>

            <tr>
              <td width="1%" class="center padng">11</td>
              <td width="10%"class="padng">Annual Fund</td>
              <td width="10%" class="center padng">
                <?php $annual_fee=getMoreAllotherFeeWithType_Summary($from,$to,8,0,$m);  echo number_format($annual_fee); ?></td>
                                      
            </tr>

            <tr>
              <td width="1%" class="center padng">12</td>
              <td width="10%"class="padng">Books Pack</td>
              <td width="10%" class="center padng">
                <?php $bookpack_fee=getMoreAllotherFeeWithType_Summary($from,$to,9,0,$m);  echo number_format($bookpack_fee); ?></td>
                                      
            </tr>


            <tr style="background-color:lightgray;color:black;">
              
              <td width="10%" colspan="2" class="center padng">Total Discount         </td>
            <td width="10%" class="center padng">

                <?php $disc=getCurrentMonthFeeDiscount($sessionid,$month,$m); echo number_format($disc); ?></td>
                                 

            </tr>
<?php 
$total_amount=$pre_bal+$tution_fee+$misc_fee+$trans_fee+$adm_fee+$pap_fund+$lib_fee+$lab_fee+$othr_fee+$Reg_fee+$secu_fee+$annual_fee+$bookpack_fee-$disc;
?>
            <tr>
                
                <th width="10%" class="center padng"style="font-size:17px;border-top: none;background-color: lightgray;"colspan="2">Total Amount</th>
                <th width="10%" class="center padng"style="font-size:17px;border-top: none;background-color: lightgray;"> <?php echo number_format($total_amount)?> </th>
                 
            </tr>
             
        </thead>
        <tbody>                      
              
             
        </tbody>
        
    </table>
  
  
</div>

</div>
   
<br><br>


        <!-- /page content -->



  </div>
  <div class="clearfix"></div>
</section>           

  


      

  

    
  <?php include('RootMe/js_linksscript.php');?>
  </body>
</html>
<script>
function toastFunction() {
  var x = document.getElementById("snackbar");
  x.className = "show";
  setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
}
</script>