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

<?php  include("sessioncheck.php"); ?>

<?php

$branch=getBranch($m);

$month;

    

    if($_GET["month"]!=NULL ){

      $month= $_GET["month"];

    }

    else{

      $month= date("m");

    }

$year;

    

    if($_GET["year"]!=NULL ){

      $year= $_GET["year"];

    }

    else{

      $year= date("Y");

    }

  

// $sessionIDs;

    

//     if($_GET["session"]!=NULL ){

//       $sessionIDs= $_GET["session"];

//     }

//     else{

//       $sessionIDs= $_SESSION['current_session'];

//     }



    

    $month_name=getMonthName($m,$month);









    function getAllotherFeeWithType_Summary_new($month,$feetype,$status,$m)

{

    $branchID=$_SESSION['branch'];

    //$curr_session23=$_SESSION['current_session'];



    $qr="SELECT SUM(fee.fee_amount) as total FROM eduportal_monthly_challan_details as fee, eduportal_monthly_challan as cha, edu_student_details as std WHERE std.student_id=cha.student_id and std.status='0' and cha.year='$year' and cha.month_id='$month' and cha.challan_id=fee.challan_id and cha.branch_id='$branchID' and fee.feetype_id='$feetype' ";



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

    return $amount[0]['total'];

}



function getCurrentMonthFeeReceivedWithStruckOff_new($session,$month,$m)

{



 $branch=$_SESSION['branch']; 

  $qr="SELECT SUM(fee.collected_amount) as received, SUM(fee.paid_again_amount) as againPay, SUM(fee.collected_fine) as total_fine FROM eduportal_monthly_challan as fee,edu_student_details as std WHERE std.student_id=fee.student_id  and fee.branch_id='$branch' AND fee.year='$year' AND fee.month_id='$month' ";

//print_r($qr);

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

  $received_amount=$amount[0]['received']+$amount[0]['total_fine']+$amount[0]['againPay'];



   return $received_amount;



}



$branchID=$_SESSION['branch'];

$query="SELECT SUM(collected_fine) as fine FROM eduportal_monthly_challan WHERE  branch_id='$branchID' and paid_status='1' and month_id='$month' and year='$year'";



    //print_r($query);

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



$currentDaete=date("Y-m-d");

$query1="SELECT * FROM eduportal_monthly_challan WHERE  branch_id='$branchID' and paid_status='0' and year='$year' and month_id='$month' and challan_duedate < '$currentDaete'";



    //print_r($query1);

    $sumunpaidchallan = $m->query($query1);



$upaidChallanFine=count($sumunpaidchallan)*$brid[0]['late_fee_fine'];

//echo count($sumunpaidchallan)."==".$brid[0]['late_fee_fine'];



$query11="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchID' and fee_head_id='1'";

//print_r($query1);

$AdmfeeHead = $m->query($query11);



$query12="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchID' and fee_head_id='2'";

//print_r($query1);

$paperFund = $m->query($query12);



$query13="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchID' and fee_head_id='3'";

//print_r($query1);

$uniform = $m->query($query13);



$query14="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchID' and fee_head_id='4'";

//print_r($query1);

$Stationary = $m->query($query14);



$query15="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchID' and fee_head_id='5'";

//print_r($query1);

$OtherFee = $m->query($query15);



$query16="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchID' and fee_head_id='6'";

//print_r($query1);

$RegFee = $m->query($query16);



$query17="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchID' and fee_head_id='7'";

//print_r($query1);

$SecurityFee = $m->query($query17);



$query18="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchID' and fee_head_id='8'";

//print_r($query1);

$ExamFee = $m->query($query18);



$query19="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchID' and fee_head_id='9'";

//print_r($query1);

$BooksPack = $m->query($query19);



$query20="SELECT * FROM eduportal_manage_fee_heads_details WHERE  branch_id='$branchID' and fee_head_id='10'";

//print_r($query1);

$ProcFee = $m->query($query20);

 ?>





<!DOCTYPE html>

<html lang="en">

  <head>

    

    <title>Monthly Fee Summary | EduPortal</title>

   <?php include('RootMe/css_links.php');?>

   

  </head>



  <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="" style="background-color: white;padding:2%;margin-top:5%;">

   

  <section class="">

  <div class="container">

  <div class="inner_banner_bg">





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



  <a href="<?php echo $_SESSION['dashboard'];?>" style="margin-left: 0px;">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp;



          <a href="multi_fee_reports.php">Fee Reports </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp;  



          Monthly Fee Summary



  <h4> Monthly Fee Summary Report (<?php echo $month_name; ?>) </h4>





<form class="" action="monthly_fee_summary.php" enctype="multipart/form-data" method="get">

 

    



  <input type="hidden" value="<?php echo session_id().session_id().session_id().session_id().session_id(); ?>" name="session" />
  
  <!-- <input type="hidden" value="</?php echo session_id().session_id().session_id().session_id().session_id(); ?>" name="year" /> -->





<div class="pull-right">   



  <a target="_blank" class="btn btn-success"style="float: right;" title="Print Students List" href="print_monthly_fee_summary.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&year=<?php echo $year;?>&month=<?php echo $month;?>">

   <i class="fa fa-print m-right-xs" target="_blank"></i> &nbsp; Print Report

  </a>

 

  <a onClick="$('#advanceSearch').toggle('blind')" class="btn btn-primary">Advance Search</a>





</div>







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

          <div class="panel-body" style="padding: 0px;">

          

            <div class="col-md-12" id="advanceSearch" style="display:none;">



              <div class="col-md-3" style="padding: 8px;">

                <div class="form-group ">

                  <label class="required">Year</label>

                  <select style="height:40px;" name="year" class="form-control">

                    <option value="All">All</option>

                    <?php

                    $match;

                    if(!isset($_REQUEST['year'])){

                      $match=date("Y");

                    }else { $match=$_REQUEST['year']; }

                    for($i=2018;$i<2031;$i++){ ?> 

                      <option <?php if($match==$i){echo 'selected';}?> value="<?php echo $i; ?>"><?php echo $i; ?></option>

                    <?php } ?>  

                  </select>
                </div>

              </div>







       <div class="col-md-3" style="padding: 8px;">

          <div class="form-group ">

         

            <label>Month</label>

                <select style="height:40px;" name="month" id="month" class="form-control"  required>



                              <option value="">Select Month</option>

                        

                        <?php

                        $WorkAssignList = $m->get("eduportal_month_config");

                        foreach($WorkAssignList as $WorkAssignListVal)

                        { ?>



                           <option <?php if($month==$WorkAssignListVal['Month_Id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['Month_Id']; ?>"><?php echo $WorkAssignListVal['Month_Name']; ?></option>





                                <?php

                        } ?>



                 </select>

              </div>

            </div>







              <div class="col-md-3 pull-left" style="padding:2px;margin-top:8px;">

                <div class="form-group ">

                   <input type="hidden" name="addaccountAdmin" value="1">

                <button type="submit" class="btn btn-primary" style="margin-top: 24px;float: right;">Search Record</button>

                </div>

              </div>



             

            </div>

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

          </div>

        </div>

      </form>

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

    </div>

    <br>



        







   <div class="table-responsive" style="min-height:320px;">









<table id="datatable" class="table table-striped table-bordered">

         



          <thead>

            <tr style="background-color: lightgray;color: black;">

              <th width="1%" class="text-center">S.No</th>

              <th width="10%">Particularly</th>

              <th width="10%" class="text-center">Amount</th>

              

            

            </tr>







            <tr>

            <td width="1%" class="text-center">1</td>

            <td width="10%">Previous Balance</td>

            <td width="10%" class="text-center"><?php $pre_bal=getMonthlyRegularFee($year,$month,'balance',$m);  echo number_format($pre_bal); ?></td>

                                    

            </tr>

            <tr>

              <td width="1%" class="text-center">2</td>

              <td width="10%">Monthly Fee</td>

              <td width="10%" class="text-center"><?php $tution_fee=getMonthlyRegularFee($year,$month,'tutionfee',$m);  echo number_format($tution_fee); ?></td>

                                      

            </tr>



           <?php if ($brid[0]['misc_status']=='0' || $brid[0]['misc_status']==0 ) { ?>



             <tr>

              <td width="1%" class="text-center">3</td>

              <td width="10%"><?php if ($brid[0]['misc_title']!=NULL){echo $brid[0]['misc_title'];}else {echo 'Miscellaneous';} ?></td>

              <td width="10%" class="text-center"><?php $misc_fee=getMonthlyRegularFee($year,$month,'misc_fee',$m);  echo number_format($misc_fee); ?></td>

                                      

            </tr>



            <?php } ?>



            <?php if ($brid[0]['transport_status']=='0' || $brid[0]['transport_status']==0 ) { ?>



             <tr>

              <td width="1%" class="text-center">4</td>

              <td width="10%"> <?php if ($brid[0]['transport_title']!=NULL){echo $brid[0]['transport_title'];}else {echo 'Transport';} ?></td>

              <td width="10%" class="text-center"><?php $trans_fee=getMonthlyRegularFee($year,$month,'transportfee',$m);  echo number_format($trans_fee); ?></td>

                                      

            </tr>



            <?php } ?>



            <?php if ($AdmfeeHead[0]['status']=='0' || $AdmfeeHead[0]['status']==0) { ?>



             <tr>

              <td width="1%" class="text-center">5</td>

              <td width="10%"><?php if ($AdmfeeHead[0]['fee_head_title']!=NULL){echo $AdmfeeHead[0]['fee_head_title'];}else {echo 'Admission Fee';} ?></td>

              <td width="10%" class="text-center">

                <?php $adm_fee=getAllotherFeeWithType_Summary_new($month,1,0,$m);  echo number_format($adm_fee); ?></td>

             </tr>



             <?php } ?>





             <?php if ($paperFund[0]['status']=='0' || $paperFund[0]['status']==0) { ?>



             <tr>

              <td width="1%" class="text-center">6</td>

              <td width="10%"><?php if ($paperFund[0]['fee_head_title']!=NULL){echo $paperFund[0]['fee_head_title'];}else {echo 'Paper Fund';} ?></td>

              <td width="10%" class="text-center">

                <?php $pap_fund=getAllotherFeeWithType_Summary_new($month,2,0,$m);  echo number_format($pap_fund); ?></td>

            </tr>



            <?php } ?>





            <?php if ($uniform[0]['status']=='0' || $uniform[0]['status']==0) { ?>

             <tr>

              <td width="1%" class="text-center">7</td>

              <td width="10%"><?php if ($uniform[0]['fee_head_title']!=NULL){echo $uniform[0]['fee_head_title'];}else {echo 'Uniform/Card Fee';} ?></td>

              <td width="10%" class="text-center">

                <?php $lib_fee=getAllotherFeeWithType_Summary_new($month,3,0,$m);  echo number_format($lib_fee); ?></td>                            

             </tr>



             <?php } ?>



             <?php if ($Stationary[0]['status']=='0' || $Stationary[0]['status']==0) { ?>



             <tr>

              <td width="1%" class="text-center">8</td>

              <td width="10%"><?php if ($Stationary[0]['fee_head_title']!=NULL){echo $Stationary[0]['fee_head_title'];}else {echo 'Stationery';} ?></td>

              <td width="10%" class="text-center">

                <?php $lab_fee=getAllotherFeeWithType_Summary_new($month,4,0,$m);  echo number_format($lab_fee); ?></td>

             </tr>

            <?php } ?>



            <?php if ($OtherFee[0]['status']=='0' || $OtherFee[0]['status']==0) { ?>



             <tr>

              <td width="1%" class="text-center">9</td>

              <td width="10%"><?php if ($OtherFee[0]['fee_head_title']!=NULL){echo $OtherFee[0]['fee_head_title'];}else {echo 'Other Fee';} ?></td>

              <td width="10%" class="text-center">

                <?php $othr_fee=getAllotherFeeWithType_Summary_new($month,5,0,$m);  echo number_format($othr_fee); ?></td>                                      

            </tr>



            <?php } ?>



            <?php if ($RegFee[0]['status']=='0' || $RegFee[0]['status']==0) { ?>



             <tr>

              <td width="1%" class="text-center">10</td>

              <td width="10%"> <?php if ($RegFee[0]['fee_head_title']!=NULL){echo $RegFee[0]['fee_head_title'];}else {echo 'Annual Fund';} ?></td>

              <td width="10%" class="text-center">

                <?php $anual_fnd=getAllotherFeeWithType_Summary_new($month,8,0,$m);  echo number_format($anual_fnd); ?></td>

                                      

            </tr>



            <?php } ?>



            <?php if ($SecurityFee[0]['status']=='0' || $SecurityFee[0]['status']==0) { ?>



            <tr>

              <td width="1%" class="text-center">11</td>

              <td width="10%"><?php if ($SecurityFee[0]['fee_head_title']!=NULL){echo $SecurityFee[0]['fee_head_title'];}else {echo 'Registration Fee';} ?></td>

              <td width="10%" class="text-center">

                <?php $Reg_fee=getAllotherFeeWithType_Summary_new($month,6,0,$m);  echo number_format($Reg_fee); ?></td>

                                      

            </tr>



            <?php } ?>





            <?php if ($ExamFee[0]['status']=='0' || $ExamFee[0]['status']==0) { ?>



            <tr>

              <td width="1%" class="text-center">12</td>

              <td width="10%"><?php if ($ExamFee[0]['fee_head_title']!=NULL){echo $ExamFee[0]['fee_head_title'];}else {echo 'Security Fee';} ?></td>

              <td width="10%" class="text-center">

                <?php $security_fee=getAllotherFeeWithType_Summary_new($month,7,0,$m);  echo number_format($security_fee); ?></td>

                                      

            </tr>



            <?php } ?>



            <?php if ($BooksPack[0]['status']=='0' || $BooksPack[0]['status']==0) { ?>



            <tr>

              <td width="1%" class="text-center">13</td>

              <td width="10%"class="padng"><?php if ($BooksPack[0]['fee_head_title']!=NULL){echo $BooksPack[0]['fee_head_title'];}else {echo 'Books Pack';} ?></td>

              <td width="10%" class="text-center">

                <?php $bookPack_fee=getAllotherFeeWithType_Summary_new($month,9,0,$m);  echo number_format($bookPack_fee); ?></td>                                      

            </tr>



             <?php } ?>



               <?php if ($ProcFee[0]['status']=='0' || $ProcFee[0]['status']==0) { ?>

             <tr>

              <td width="1%" class="text-center">14</td>

              <td width="10%"class="padng"><?php if ($ProcFee[0]['fee_head_title']!=NULL){echo $ProcFee[0]['fee_head_title'];}else {echo 'Proc. Fee';} ?></td>

              <td width="10%" class="text-center">

                <?php $proc_fee=getAllotherFeeWithType_Summary_new($month,10,0,$m);  echo number_format($proc_fee); ?></td>                                      

            </tr>

            <?php } ?>



     

             <tr>

              <td width="1%" class="text-center">15</td>

              <td width="10%"class="padng">Fine Report</td>

              <td width="10%" class="text-center">

                <?php $totalFine=$fineCollected[0]['fine']+$upaidChallanFine; echo number_format($totalFine); ?></td>                                      

            </tr>

          





            <tr style="background-color:lightgray;color:black;">

              

              <td width="10%" colspan="2" class="text-center">Total Discount         </td>

            <td width="10%" class="text-center">



                <?php $disc=getCurrentMonthFeeDiscount($year,$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+$anual_fnd+$Reg_fee+$security_fee+$bookPack_fee+$proc_fee+$totalFine-$disc;

?>





            <tr style="background-color:lightgray;color:black;">

              

              <td width="10%" colspan="2" class="text-center">Total Amount</td>

              <td width="10%" class="text-center"><?php echo number_format($total_amount)?></td>

                                      

            </tr>



          

            <tr>

              

              <td width="10%" colspan="2" class="text-center">Total Received</td>

              <td width="10%" class="text-center">



                <?php $recieved=getCurrentMonthFeeReceivedWithStruckOff_new($year,$month,$m); echo number_format($recieved); ?></td>

                                      

            </tr>

            

            <tr class="bg-primary">

              

              <td width="10%" colspan="2" class="text-center">Total Recveiable</td>

              <td width="10%" class="text-center"><?php echo number_format($total_amount - $recieved );?></td>

              

            </tr>



          </thead>

          <tbody>



                        



          



          </tbody>

        </table>





          </tr>

            





    </div>









    </div>

  </div>

</section>



















           

          </div>

        </div>



            </div>

          </div>

        </div>

        <!-- /page content -->

  



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

  



<script type="text/javascript" src="<?php echo DOMAIN;?>AgentPanel/js/select2.full.min.js"></script> 

<script>

  $(function () {

    //Initialize Select2 Elements

    $(".select2").select2();



  });

</script>

  </body>

</html>

