<?php
 $pe=$_SESSION['PE'];
 $yr=$_SESSION['Yeear'];
 $year=$_SESSION['Yeear'];
 $expenov='';
  $ctoincome='';
if($yr != '')
{
?>
<div class="table-responsive">
                  <h6> <u class="text-info"> Bank reports for year: <strong class='text-danger'> <?php echo $yr;  ?></strong></u>
                  </h6>
                  
                 <table class="table table-bordered" id="tablebankdata">
                     <thead>
                         <tr class="text-success">
                             <th>#</th>
                             <th class="text-danger">Accounts</th>
                             <th colspan="2" >January</th>
                             <th colspan="2">February</th>
                             <th colspan="2">March</th>
                             <th colspan="2">April</th>
                             <th colspan="2">May</th>
                             <th colspan="2">June</th>
                             <th colspan="2">July</th>
                             <th colspan="2">August</th>
                             <th colspan="2">September</th>
                             <th colspan="2">October</th>
                             <th colspan="2">November</th>
                             <th colspan="2">December</th>
                         </tr>
                         <tr class="bg-gray">
                             <th colspan="2">Bank Name</th>
                             
                             <th>Cash In</th>
                             <th>Cash Out</th>
                             
                             <th>Cash In</th>
                             <th>Cash Out</th>
                             
                             <th>Cash In</th>
                             <th>Cash Out</th>
                             
                             <th>Cash In</th>
                             <th>Cash Out</th>
                             
                             <th>Cash In</th>
                             <th>Cash Out</th>
                             
                             <th>Cash In</th>
                             <th>Cash Out</th>
                             
                             <th>Cash In</th>
                             <th>Cash Out</th>
                             
                             <th>Cash In</th>
                             <th>Cash Out</th>
                             
                             <th>Cash In</th>
                             <th>Cash Out</th>
                             
                             <th>Cash In</th>
                             <th>Cash Out</th>
                             
                             <th>Cash In</th>
                             <th>Cash Out</th>
                             
                             <th>Cash In</th>
                             <th>Cash Out</th>
                         </tr>
                     </thead>
                     <tbody style="font-weight:bold">
                        <?php
                         $sqlquery=mysqli_query($con,"DELETE FROM bankanalysis WHERE Year='$year'");
                         
                        $sql = "select bankdata.id as bid,bankdata.Bname as bnm, bankdata.Account as act,
                        
                        (SELECT SUM(PaidAmount) from feestatement where Month='January' AND Bank=bid AND Year='$year') as Januaryfe,(SELECT SUM(Amount) from farminput where Month='January' AND Bank=bid AND Year='$year') as Januaryfarminp,(SELECT SUM(cost) from busincome where Month='January' AND Bank=bid AND Year='$year') as Januarybus,(SELECT SUM(Amount) from Otherincome where Month='January' AND Bank=bid AND Year='$year') as Januaryother, (SELECT SUM(Amount) from TourPayment where Month='January' AND Bank=bid AND Year='$year') as Januarytour,(SELECT SUM(Amount) from Gradpayment where Month='January' AND Bank=bid AND Year='$year') as Januarygrad, (SELECT SUM(Amount) from prodata where Month='January' AND Bank=bid AND Year='$year') as Januaryproj, (SELECT SUM(Amount) from Imprest where Month='January' AND Bank=bid AND Year='$year') as Januaryimpre,(SELECT SUM(Amount) from Expenses where Month='January' AND Account=bid AND Year='$year') as Januaryxpen,
                        
                        (SELECT SUM(PaidAmount) from feestatement where Month='February' AND Bank=bid AND Year='$year') as Februaryfe,(SELECT SUM(Amount) from farminput where Month='February' AND Bank=bid AND Year='$year') as Februaryfarminp,(SELECT SUM(cost) from busincome where Month='February' AND Bank=bid AND Year='$year') as Februarybus,(SELECT SUM(Amount) from Otherincome where Month='February' AND Bank=bid AND Year='$year') as Februaryother, (SELECT SUM(Amount) from TourPayment where Month='February' AND Bank=bid AND Year='$year') as Februarytour,(SELECT SUM(Amount) from Gradpayment where Month='February' AND Bank=bid AND Year='$year') as Februarygrad, (SELECT SUM(Amount) from prodata where Month='February' AND Bank=bid AND Year='$year') as Februaryproj, (SELECT SUM(Amount) from Imprest where Month='February' AND Bank=bid AND Year='$year') as Februaryimpre,(SELECT SUM(Amount) from Expenses where Month='February' AND Account=bid AND Year='$year') as Februaryxpen,  (SELECT SUM(PaidAmount) from feestatement where Month='March' AND Bank=bid AND Year='$year') as Marchfe,(SELECT SUM(Amount) from farminput where Month='March' AND Bank=bid AND Year='$year') as Marchfarminp,(SELECT SUM(cost) from busincome where Month='March' AND Bank=bid AND Year='$year') as Marchbus,(SELECT SUM(Amount) from Otherincome where Month='March' AND Bank=bid AND Year='$year') as Marchother, (SELECT SUM(Amount) from TourPayment where Month='March' AND Bank=bid AND Year='$year') as Marchtour,(SELECT SUM(Amount) from Gradpayment where Month='March' AND Bank=bid AND Year='$year') as Marchgrad, (SELECT SUM(Amount) from prodata where Month='March' AND Bank=bid AND Year='$year') as Marchproj, (SELECT SUM(Amount) from Imprest where Month='March' AND Bank=bid AND Year='$year') as Marchimpre,(SELECT SUM(Amount) from Expenses where Month='March' AND Account=bid AND Year='$year') as Marchxpen,(SELECT SUM(PaidAmount) from feestatement where Month='April' AND Bank=bid AND Year='$year') as Aprilfe,(SELECT SUM(Amount) from farminput where Month='April' AND Bank=bid AND Year='$year') as Aprilfarminp,(SELECT SUM(cost) from busincome where Month='April' AND Bank=bid AND Year='$year') as Aprilbus,(SELECT SUM(Amount) from Otherincome where Month='April' AND Bank=bid AND Year='$year') as Aprilother, (SELECT SUM(Amount) from TourPayment where Month='April' AND Bank=bid AND Year='$year') as Apriltour,(SELECT SUM(Amount) from Gradpayment where Month='April' AND Bank=bid AND Year='$year') as Aprilgrad, (SELECT SUM(Amount) from prodata where Month='April' AND Bank=bid AND Year='$year') as Aprilproj, (SELECT SUM(Amount) from Imprest where Month='April' AND Bank=bid AND Year='$year') as Aprilimpre,(SELECT SUM(Amount) from Expenses where Month='April' AND Account=bid AND Year='$year') as Aprilxpen,(SELECT SUM(PaidAmount) from feestatement where Month='May' AND Bank=bid AND Year='$year') as mayfe,(SELECT SUM(Amount) from farminput where Month='May' AND Bank=bid AND Year='$year') as mayfarminp,(SELECT SUM(cost) from busincome where Month='May' AND Bank=bid AND Year='$year') as maybus,(SELECT SUM(Amount) from Otherincome where Month='May' AND Bank=bid AND Year='$year') as mayother, (SELECT SUM(Amount) from TourPayment where Month='May' AND Bank=bid AND Year='$year') as maytour,(SELECT SUM(Amount) from Gradpayment where Month='May' AND Bank=bid AND Year='$year') as maygrad, (SELECT SUM(Amount) from prodata where Month='May' AND Bank=bid AND Year='$year') as mayproj, (SELECT SUM(Amount) from Imprest where Month='May' AND Bank=bid AND Year='$year') as mayimpre,(SELECT SUM(Amount) from Expenses where Month='May' AND Account=bid AND Year='$year') as Mayxpen,(SELECT SUM(PaidAmount) from feestatement where Month='June' AND Bank=bid AND Year='$year') as junfe,(SELECT SUM(Amount) from farminput where Month='June' AND Bank=bid AND Year='$year') as junfarminp,(SELECT SUM(cost) from busincome where Month='June' AND Bank=bid AND Year='$year') as junbus,(SELECT SUM(Amount) from Otherincome where Month='June' AND Bank=bid AND Year='$year') as junother, (SELECT SUM(Amount) from TourPayment where Month='June' AND Bank=bid AND Year='$year') as juntour,(SELECT SUM(Amount) from Gradpayment where Month='June' AND Bank=bid AND Year='$year') as jungrad, (SELECT SUM(Amount) from prodata where Month='June' AND Bank=bid AND Year='$year') as junproj, (SELECT SUM(Amount) from Imprest where Month='June' AND Bank=bid AND Year='$year') as junimpre,(SELECT SUM(Amount) from Expenses where Month='June' AND Account=bid AND Year='$year') as junexpen,(SELECT SUM(PaidAmount) from feestatement where Month='July' AND Bank=bid AND Year='$year') as julfe,(SELECT SUM(Amount) from farminput where Month='July' AND Bank=bid AND Year='$year') as julfarminp,(SELECT SUM(cost) from busincome where Month='July' AND Bank=bid AND Year='$year') as julbus,(SELECT SUM(Amount) from Otherincome where Month='July' AND Bank=bid AND Year='$year') as julother, (SELECT SUM(Amount) from TourPayment where Month='July' AND Bank=bid AND Year='$year') as jultour,(SELECT SUM(Amount) from Gradpayment where Month='July' AND Bank=bid AND Year='$year') as julgrad, (SELECT SUM(Amount) from prodata where Month='July' AND Bank=bid AND Year='$year') as julproj, (SELECT SUM(Amount) from Imprest where Month='July' AND Bank=bid AND Year='$year') as julimpre,(SELECT SUM(Amount) from Expenses where Month='July' AND Account=bid AND Year='$year') as julexpen,(SELECT SUM(PaidAmount) from feestatement where Month='August' AND Bank=bid AND Year='$year') as augfe,(SELECT SUM(Amount) from farminput where Month='August' AND Bank=bid AND Year='$year') as augfarminp,(SELECT SUM(cost) from busincome where Month='August' AND Bank=bid AND Year='$year') as augbus,(SELECT SUM(Amount) from Otherincome where Month='August' AND Bank=bid AND Year='$year') as augother, (SELECT SUM(Amount) from TourPayment where Month='August' AND Bank=bid AND Year='$year') as augtour,(SELECT SUM(Amount) from Gradpayment where Month='August' AND Bank=bid AND Year='$year') as auggrad, (SELECT SUM(Amount) from prodata where Month='August' AND Bank=bid AND Year='$year') as augproj, (SELECT SUM(Amount) from Imprest where Month='August' AND Bank=bid AND Year='$year') as augimpre,(SELECT SUM(Amount) from Expenses where Month='August' AND Account=bid AND Year='$year') as augexpen,(SELECT SUM(PaidAmount) from feestatement where Month='September' AND Bank=bid AND Year='$year') as sepfe,(SELECT SUM(Amount) from farminput where Month='September' AND Bank=bid AND Year='$year') as sepfarminp,(SELECT SUM(cost) from busincome where Month='September' AND Bank=bid AND Year='$year') as sepbus,(SELECT SUM(Amount) from Otherincome where Month='September' AND Bank=bid AND Year='$year') as sepother, (SELECT SUM(Amount) from TourPayment where Month='September' AND Bank=bid AND Year='$year') as septour,(SELECT SUM(Amount) from Gradpayment where Month='September' AND Bank=bid AND Year='$year') as sepgrad, (SELECT SUM(Amount) from prodata where Month='September' AND Bank=bid AND Year='$year') as sepproj, (SELECT SUM(Amount) from Imprest where Month='September' AND Bank=bid AND Year='$year') as sepimpre,(SELECT SUM(Amount) from Expenses where Month='September' AND Account=bid AND Year='$year') as sepexpen, (SELECT SUM(PaidAmount) from feestatement where Month='October' AND Bank=bid AND Year='$year') as octfe,(SELECT SUM(Amount) from farminput where Month='October' AND Bank=bid AND Year='$year') as octfarminp,(SELECT SUM(cost) from busincome where Month='October' AND Bank=bid AND Year='$year') as octbus,(SELECT SUM(Amount) from Otherincome where Month='October' AND Bank=bid AND Year='$year') as octother, (SELECT SUM(Amount) from TourPayment where Month='October' AND Bank=bid AND Year='$year') as octtour,(SELECT SUM(Amount) from Gradpayment where Month='October' AND Bank=bid AND Year='$year') as octgrad, (SELECT SUM(Amount) from prodata where Month='October' AND Bank=bid AND Year='$year') as octproj, (SELECT SUM(Amount) from Imprest where Month='October' AND Bank=bid AND Year='$year') as octimpre,(SELECT SUM(Amount) from Expenses where Month='October' AND Account=bid AND Year='$year') as octexpen,(SELECT SUM(PaidAmount) from feestatement where Month='November' AND Bank=bid AND Year='$year') as novfe,(SELECT SUM(Amount) from farminput where Month='November' AND Bank=bid AND Year='$year') as novfarminp,(SELECT SUM(cost) from busincome where Month='November' AND Bank=bid AND Year='$year') as novbus,(SELECT SUM(Amount) from Otherincome where Month='November' AND Bank=bid AND Year='$year') as novother, (SELECT SUM(Amount) from TourPayment where Month='November' AND Bank=bid AND Year='$year') as novtour,(SELECT SUM(Amount) from Gradpayment where Month='November' AND Bank=bid AND Year='$year') as novgrad, (SELECT SUM(Amount) from prodata where Month='November' AND Bank=bid AND Year='$year') as novproj, (SELECT SUM(Amount) from Imprest where Month='November' AND Bank=bid AND Year='$year') as novimpre,(SELECT SUM(Amount) from Expenses where Month='November' AND Account=bid AND Year='$year') as novexpen,(SELECT SUM(PaidAmount) from feestatement where Month='December' AND Bank=bid AND Year='$year') as decfe,(SELECT SUM(Amount) from farminput where Month='December' AND Bank=bid AND Year='$year') as decfarminp,(SELECT SUM(cost) from busincome where Month='December' AND Bank=bid AND Year='$year') as decbus,(SELECT SUM(Amount) from Otherincome where Month='December' AND Bank=bid AND Year='$year') as decother, (SELECT SUM(Amount) from TourPayment where Month='December' AND Bank=bid AND Year='$year') as dectour,(SELECT SUM(Amount) from Gradpayment where Month='December' AND Bank=bid AND Year='$year') as decgrad, (SELECT SUM(Amount) from prodata where Month='December' AND Bank=bid AND Year='$year') as decproj, (SELECT SUM(Amount) from Imprest where Month='December' AND Bank=bid AND Year='$year') as decimpre,(SELECT SUM(Amount) from Expenses where Month='December' AND Account=bid AND Year='$year') as decexpen

                        from bankdata order by bnm DESC";
                        $result = $con->query($sql);
                        if ($result->num_rows > 0) 
                        {
                            $cnt='1';
                            while($row = $result->fetch_assoc()) 
                            {
                              $baid=$row["bid"];   
                                
                            $ctoincomee= $row["augfe"]+$row["augfarminp"]+$row["augbus"]+$row["augother"]+$row["augtour"]+$row["auggrad"];
                            
                           //January 
                         $jani=$row["Januaryfe"]+$row["Januaryfarminp"]+$row["Januarybus"]+$row["Januaryother"]+$row["Januarytour"]+$row["Januarygrad"];  
                         $jane=$row["Januaryproj"]+$row["Januaryimpre"]+$row["Januaryxpen"];  
                        
                           //February 
                         $febi=$row["Februaryfe"]+$row["Februaryfarminp"]+$row["Februarybus"]+$row["Februaryother"]+$row["Februarytour"]+$row["Februarygrad"];  
                         $febe=$row["Februaryproj"]+$row["Februaryimpre"]+$row["Februaryxpen"]; 
                            
                          //March  
                         $mari=$row["Marchfe"]+$row["Marchfarminp"]+$row["Marchbus"]+$row["Marchother"]+$row["Marchtour"]+$row["Marchgrad"];  
                         $mare=$row["Marchproj"]+$row["Marchimpre"]+$row["Marchxpen"];
                          
                           //April  
                         $apri=$row["Aprilfe"]+$row["Aprilfarminp"]+$row["Aprilbus"]+$row["Aprilother"]+$row["Apriltour"]+$row["Aprilgrad"];  
                         $apre=$row["Aprilproj"]+$row["Aprilimpre"]+$row["Aprilxpen"];
                          
                          
                           //May  
                         $mayi=$row["mayfe"]+$row["mayfarminp"]+$row["maybus"]+$row["mayother"]+$row["maytour"]+$row["maygrad"];  
                         $maye=$row["mayproj"]+$row["mayimpre"]+$row["mayxpen"];
                          
                           //June  
                         $juni=$row["junfe"]+$row["junfarminp"]+$row["junbus"]+$row["junother"]+$row["juntour"]+$row["jungrad"];  
                         $june=$row["junproj"]+$row["junimpre"]+$row["junexpen"]; 
                            
                           //July  
                         $juli=$row["julfe"]+$row["julfarminp"]+$row["julbus"]+$row["julother"]+$row["jultour"]+$row["julgrad"];  
                         $jule=$row["julproj"]+$row["julimpre"]+$row["julexpen"];   
                            
                          //August  
                         $augi=$row["augfe"]+$row["augfarminp"]+$row["augbus"]+$row["augother"]+$row["augtour"]+$row["auggrad"];  
                         $auge=$row["augproj"]+$row["augimpre"]+$row["augexpen"];    
                            
                         //September   
                              $sepi=$row["sepfe"]+$row["sepfarminp"]+$row["sepbus"]+$row["sepother"]+$row["septour"]+$row["sepgrad"];;  
                              $sepe=$row["sepproj"]+$row["sepimpre"]+$row["sepexpen"];  
                
                         //October   
                         $octi=$row["octfe"]+$row["octfarminp"]+$row["octbus"]+$row["octother"]+$row["octtour"]+$row["octgrad"];  
                          $octe=$row["octproj"]+$row["octimpre"]+$row["octexpen"]; 
                          
                        //November  
                          $novi=$row["novfe"]+$row["novfarminp"]+$row["novbus"]+$row["novother"]+$row["novtour"]+$row["novgrad"];  
                          $nove=$row["novproj"]+$row["novimpre"]+$row["novexpen"];
                        
                        //December  
                          $deci=$row["decfe"]+$row["decfarminp"]+$row["decbus"]+$row["decother"]+$row["dectour"]+$row["decgrad"];  
                          $dece=$row["decproj"]+$row["decimpre"]+$row["decexpen"];
                        
                        
                         //Insert Data
                         $sql=mysqli_query($con,"INSERT INTO bankanalysis(Income,Month,bid,Year,Expe) values('$jani','January','$baid','$year','$jane')");
                         
                         $sql=mysqli_query($con,"INSERT INTO bankanalysis(Income,Month,bid,Year,Expe) values('$febi','February','$baid','$year','$febe')");
                         
                         $sql=mysqli_query($con,"INSERT INTO bankanalysis(Income,Month,bid,Year,Expe) values('$mari','March','$baid','$year','$mare')");
                         
                         $sql=mysqli_query($con,"INSERT INTO bankanalysis(Income,Month,bid,Year,Expe) values('$apri','April','$baid','$year','$apre')");
                         
                         $sql=mysqli_query($con,"INSERT INTO bankanalysis(Income,Month,bid,Year,Expe) values('$mayi','May','$baid','$year','$maye')");
                         
                         $sql=mysqli_query($con,"INSERT INTO bankanalysis(Income,Month,bid,Year,Expe) values('$juni','June','$baid','$year','$june')");
                         
                         $sql=mysqli_query($con,"INSERT INTO bankanalysis(Income,Month,bid,Year,Expe) values('$juli','July','$baid','$year','$jule')");
                         
                         $sql=mysqli_query($con,"INSERT INTO bankanalysis(Income,Month,bid,Year,Expe) values('$augi','August','$baid','$year','$auge')");
                         
                         $sql=mysqli_query($con,"INSERT INTO bankanalysis(Income,Month,bid,Year,Expe) values('$sepi','September','$baid','$year','$sepe')"); 
                         
                          $sql=mysqli_query($con,"INSERT INTO bankanalysis(Income,Month,bid,Year,Expe) values('$octi','October','$baid','$year','$octe')"); 
                          
                           $sql=mysqli_query($con,"INSERT INTO bankanalysis(Income,Month,bid,Year,Expe) values('$novi','November','$baid','$year','$nove')"); 
                           
                           $sql=mysqli_query($con,"INSERT INTO bankanalysis(Income,Month,bid,Year,Expe) values('$deci','December','$baid','$year','$dece')");
                     
                            ?>	
                            <tr>
                        <td><?php echo $cnt; ?></td>
                        <td class="text-success"><?php echo $row["bnm"].' '; ?>
                        <small>(<?php echo $row["act"]; ?>)</small></td>
                        
                <td class="Januaryo"><?php echo $row["Januaryfe"]+$row["Januaryfarminp"]+$row["Januarybus"]+$row["Januaryother"]+$row["Januarytour"]+$row["Januarygrad"]; ?>
               </td>  
               <td class="text-danger"><?php echo $row["Januaryproj"]+$row["Januaryimpre"]+$row["Januaryxpen"]; ?>
               </td>  
                
               <td class="Februaryo"><?php echo $row["Februaryfe"]+$row["Februaryfarminp"]+$row["Februarybus"]+$row["Februaryother"]+$row["Februarytour"]+$row["Februarygrad"]; ?>
               </td>  
               <td class="text-danger"><?php echo $row["Februaryproj"]+$row["Februaryimpre"]+$row["Februaryxpen"]; ?>
               </td> 
               
                
                <td class="marcho"><?php echo $row["Marchfe"]+$row["Marchfarminp"]+$row["Marchbus"]+$row["Marchother"]+$row["Marchtour"]+$row["Marchgrad"]; ?>
               </td>  
               <td class="text-danger"><?php echo $row["Marchproj"]+$row["Marchimpre"]+$row["Marchxpen"]; ?>
               </td> 
                
                
                <td class="aprilo"><?php echo $row["Aprilfe"]+$row["Aprilfarminp"]+$row["Aprilbus"]+$row["Aprilother"]+$row["Apriltour"]+$row["Aprilgrad"]; ?>
               </td>  
               <td class="text-danger"><?php echo $row["Aprilproj"]+$row["Aprilimpre"]+$row["Aprilxpen"]; ?>
               </td> 
                
                
                <td class="mayo"><?php echo $row["mayfe"]+$row["mayfarminp"]+$row["maybus"]+$row["mayother"]+$row["maytour"]+$row["maygrad"]; ?>
               </td>  
               <td class="text-danger"><?php echo $row["mayproj"]+$row["mayimpre"]+$row["mayxpen"]; ?>
               </td> 
                
                
                <td class="juno"><?php echo $row["junfe"]+$row["junfarminp"]+$row["junbus"]+$row["junother"]+$row["juntour"]+$row["jungrad"]; ?>
               </td>  
               <td class="text-danger"><?php echo $row["junproj"]+$row["junimpre"]+$row["junexpen"]; ?>
               </td> 
               
                        
               <td class="julo"><?php echo $row["julfe"]+$row["julfarminp"]+$row["julbus"]+$row["julother"]+$row["jultour"]+$row["julgrad"]; ?>
               </td>  
               <td class="text-danger"><?php echo $row["julproj"]+$row["julimpre"]+$row["julexpen"]; ?>
               </td>
               
               <td class="augo"><?php echo $row["augfe"]+$row["augfarminp"]+$row["augbus"]+$row["augother"]+$row["augtour"]+$row["auggrad"]; ?>
               </td>  
               <td class="text-danger"><?php echo $row["augproj"]+$row["augimpre"]+$row["augexpen"]; ?>
               </td>
                
                
               <td class="sepo"><?php echo $row["sepfe"]+$row["sepfarminp"]+$row["sepbus"]+$row["sepother"]+$row["septour"]+$row["sepgrad"]; ?>
               </td>  
               <td class="text-danger"><?php echo $row["sepproj"]+$row["sepimpre"]+$row["sepexpen"]; ?>
               </td>
             
               <td class="octo"><?php echo $row["octfe"]+$row["octfarminp"]+$row["octbus"]+$row["octother"]+$row["octtour"]+$row["octgrad"]; ?>
               </td>  
               <td class="text-danger"><?php echo $row["octproj"]+$row["octimpre"]+$row["octexpen"]; ?>
               </td>
    
              <td class="novo"><?php echo $row["novfe"]+$row["novfarminp"]+$row["novbus"]+$row["novother"]+$row["novtour"]+$row["novgrad"]; ?>
               </td>  
               <td class="text-danger"><?php echo $row["novproj"]+$row["novimpre"]+$row["novexpen"]; 
               ?>
               </td>
        
                <td class="deco"><?php echo $row["decfe"]+$row["decfarminp"]+$row["decbus"]+$row["decother"]+$row["dectour"]+$row["decgrad"]; ?>
               </td>  
               <td class="text-danger"><?php echo $row["decproj"]+$row["decimpre"]+$row["decexpen"]; ?>
               </td> 
                </tr>
                            <?php
                            $cnt=$cnt+1;
                            
                            }
                        }
                            ?>
                     </tbody>
                     <tfooter>
                         
                       <?php
                       $sql = "select bankdata.id as bid,bankdata.Bname as bnm, bankdata.Account as act,
                        
                        (SELECT SUM(Income) from bankanalysis where Month='January' AND Year='$year') as janincome,
                        (SELECT SUM(Expe) from bankanalysis where Month='January' AND Year='$year') as janexpe,
                        
                        (SELECT SUM(Income) from bankanalysis where Month='February' AND Year='$year') as febincome,
                        (SELECT SUM(Expe) from bankanalysis where Month='February' AND Year='$year') as febexpe,
                        
                        (SELECT SUM(Income) from bankanalysis where Month='March' AND Year='$year') as marincome,
                        (SELECT SUM(Expe) from bankanalysis where Month='March' AND Year='$year') as marexpe,
                        
                        (SELECT SUM(Income) from bankanalysis where Month='April' AND Year='$year') as aprincome,
                        (SELECT SUM(Expe) from bankanalysis where Month='April' AND Year='$year') as aprexpe,
                        
                        (SELECT SUM(Income) from bankanalysis where Month='May' AND Year='$year') as mayincome,
                        (SELECT SUM(Expe) from bankanalysis where Month='May' AND Year='$year') as mayexpe,
                        
                        (SELECT SUM(Income) from bankanalysis where Month='June' AND Year='$year') as junincome,
                        (SELECT SUM(Expe) from bankanalysis where Month='June' AND Year='$year') as junexpe,
                        
                        (SELECT SUM(Income) from bankanalysis where Month='July' AND Year='$year') as julincome,
                        (SELECT SUM(Expe) from bankanalysis where Month='July' AND Year='$year') as julexpe,
                        
                        
                        (SELECT SUM(Expe) from bankanalysis where Month='August' AND Year='$year') as augexpe,(SELECT SUM(Income) from bankanalysis where Month='September' AND Year='$year') as sepincome,(SELECT SUM(Expe) from bankanalysis where Month='September' AND Year='$year') as sepexpe,(SELECT SUM(Income) from bankanalysis where Month='October' AND Year='$year') as octincome,(SELECT SUM(Expe) from bankanalysis where Month='October' AND Year='$year') as octexpe,(SELECT SUM(Income) from bankanalysis where Month='November' AND Year='$year') as novincome,(SELECT SUM(Expe) from bankanalysis where Month='November' AND Year='$year') as novexpe,(SELECT SUM(Income) from bankanalysis where Month='December' AND Year='$year') as decincome,(SELECT SUM(Expe) from bankanalysis where Month='December' AND Year='$year') as decexpe from bankdata";
                        $result = $con->query($sql);
                        if ($result->num_rows > 0) 
                        {
                            while($row = $result->fetch_assoc()) 
                            {
                                
                              $jin=$row["janincome"]; 
                              $jex=$row["janexpe"];   
                              
                              $fin=$row["febincome"]; 
                              $fex=$row["febexpe"]; 
                              
                              $min=$row["marincome"]; 
                              $mex=$row["marexpe"];
                              
                              $apin=$row["aprincome"]; 
                              $apex=$row["aprexpe"];
                              
                              $main=$row["mayincome"]; 
                              $maex=$row["mayexpe"];
                              
                              $jin=$row["junincome"]; 
                              $jex=$row["junexpe"];
                              
                              $juin=$row["julincome"]; 
                              $juex=$row["julexpe"];
     
                              $ain=$row["augincome"]; 
                              $aex=$row["augexpe"]; 
                              
                              $sin=$row["sepincome"]; 
                              $sex=$row["sepexpe"];
                             
                              $oin=$row["octincome"]; 
                              $oex=$row["octexpe"];
                              
                              $nin=$row["novincome"]; 
                              $nex=$row["novexpe"];
                              
                              $din=$row["decincome"]; 
                              $dex=$row["decexpe"];
                              
                            }
                        }
                       ?>
                         
                         <tr class="alert-warning">
                             <td colspan="2">TOTAL (KES) </td>
                             <td class="alert-success"><strong><?php echo $jin; ?></strong>
                             </td>
                             <td class="alert-danger"><strong ><?php echo $jex; ?></strong>
                             </td>
                             
                             <td class="alert-success"><strong><?php echo $fin; ?></strong></td>
                             <td class="alert-danger"><strong ><?php echo $fex; ?></strong>
                             </td>
                             
                             <td class="alert-success"><strong><?php echo $min; ?></strong></td>
                             <td class="alert-danger"><strong ><?php echo $mex; ?></strong>
                             </td>
                             
                             <td class="alert-success"><strong><?php echo $apin; ?></strong></td>
                             <td class="alert-danger"><strong ><?php echo $apex; ?></strong>
                             </td>
                             
                             <td class="alert-success"><strong><?php echo $main; ?></strong></td>
                             <td class="alert-danger"><strong ><?php echo $maex; ?></strong>
                             </td>
                             
                             <td class="alert-success"><strong><?php echo $jin; ?></strong></td>
                             <td class="alert-danger"><strong ><?php echo $jex; ?></strong>
                             </td>
                             
                             <td class="alert-success"><strong><?php echo $juin; ?></strong></td>
                             <td class="alert-danger"><strong ><?php echo $juex; ?></strong>
                             </td>
                             
                             <td class="alert-success"><strong><?php echo $ain; ?></strong></td>
                             <td class="alert-danger"><strong ><?php echo $aex; ?></strong></td>
                             
                             <td class="alert-success"><strong><?php echo $sin; ?></strong></td>
                             <td class="alert-danger"><strong ><?php echo $sex; ?></strong></td>
                              
                             <td class="alert-success"><strong><?php echo $oin; ?></strong></td>
                             <td class="alert-danger"><strong ><?php echo $oex; ?></strong>
                             </td>
                             
                              <td class="alert-success"><strong><?php echo $nin; ?></strong></td>
                             <td class="alert-danger"><strong ><?php echo $nex; ?></strong></td>
                             
                             <td class="alert-success"><strong><?php echo $din; ?></strong></td>
                             <td class="alert-danger"><strong ><?php echo $dex; ?></strong></td>
                         </tr>
                     </tfooter>
                 </table> 
                 
                 
              </div>
              <button class="btn btn-primary btn-xs pull-right" id="btn-down-data"> <i class="fa fa-cloud-download"></i> Download Data</button>
              <?php
}else if($pe=='October-December')
{
    echo 'This is October-December';
}else
{
  echo 'SORRY. No details found for this period';
}
?>