<?php
$peri=$pe.'-'.$yr;
include('FetchingBudgeted.php');
?>
<div class="divscroll">
    <input type="hidden" value="<?php echo $peri; ?>" id="periodic" />
    <input type="hidden" value="<?php echo $yr; ?>" id="themwaka" />
  <h6> <u class="text-info"> Cash Equivalent report for: <strong class='text-danger'> <?php echo $pe.' '.$yr;  ?> </strong></u></h6>
  
  <table class="table tablesummary table-sm" id="tsummary">
      <thead>
          <tr>
            <th>Particular</th>
            <th>September</th>
            <th>October</th>
            <th>November</th>
            <th>December</th>
            <th>Total</th>
            <th>Budgeted</th>
            <th>Variance</th>
            <th>%</th>
            <th class="leavethis">Action</th>
          </tr>
      </thead>
      <tbody>
           <tr class="alert-success">
              <td colspan="10"><strong>Income</strong></td>
          </tr>
          
         <?php
         if($totSeptemberfee=='0')
         { }else{ ?>
          <tr>
              <td style="background-color:#ffe6e6" class="cola1">School Fees</td>
              <td class="cola2"><?php echo number_format($Septemberfee); ?></td>
              <td class="cola3"><?php echo number_format($junfee); ?></td>
              <td class="cola4"><?php echo number_format($Novemberfee); ?></td>
              <td class="cola5"><?php echo number_format($augfee); ?></td>
              <td class="bg-primary cola6"><strong style="padding:5px"><?php echo number_format($totSeptemberfee); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($sfee); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totSeptemberfee !='0'  && $sfee !='0' && $sfee !='')
                 {
                    $badbal=$sfee-$totSeptemberfee;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptemberfee !='0'  && $sfee !='0' && $sfee !='')
                 {
                    $badbal=$sfee-$totSeptemberfee;
                    $para=($badbal/$sfee)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                  <input type="hidden" value="sfee" class="textwithid" />
                  <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
              </td>
          </tr>
          <?php
         }
         ?>
           <tr>
              <td style="background-color:#ffe6e6" class="cola1">Uniform Fee</td>
              <td><?php echo number_format($Septemberuni); ?></td>
              <td><?php echo number_format($jununi); ?></td>
              <td><?php echo number_format($Novemberuni); ?></td>
              <td><?php echo number_format($auguni); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totSeptemberuni); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($unifee); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totSeptemberuni !='0'  && $unifee !='0' && $unifee !='')
                 {
                    $badbal=$unifee-$totSeptemberuni;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptemberuni !='0'  && $unifee !='0' && $unifee !='')
                 {
                    $badbal=$unifee-$totSeptemberuni;
                    $para=($badbal/$unifee)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                   <input type="hidden" value="unifee" class="textwithid" />
                   <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
              </td>
          </tr>
          
          <tr>
              <td style="background-color:#ffe6e6" class="cola1">Admission Fee</td>
              <td><?php echo number_format($Septemberadfe); ?></td>
              <td><?php echo number_format($junadfe); ?></td>
              <td><?php echo number_format($Novemberadfe); ?></td>
              <td><?php echo number_format($augadfe); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totSeptemberadfee); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($adfee); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totSeptemberadfee !='0'  && $adfee !='0' && $adfee !='')
                 {
                    $badbal=$adfee-$totSeptemberadfee;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptemberadfee !='0'  && $adfee !='0' && $adfee !='')
                 {
                    $badbal=$adfee-$totSeptemberadfee;
                    $para=($badbal/$adfee)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                   <input type="hidden" value="adfee" class="textwithid" />
                   <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
              </td>
          </tr>
          
           <tr>
              <td style="background-color:#ffe6e6" class="cola1">Transport Fee</td>
              <td><?php echo number_format($Septembertra); ?></td>
              <td><?php echo number_format($juntra); ?></td>
              <td><?php echo number_format($Novembertra); ?></td>
              <td><?php echo number_format($augtra); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totSeptembertra); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($trafee); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totSeptembertra !='0'  && $trafee !='0' && $trafee !='')
                 {
                    $badbal=$trafee-$totSeptembertra;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptembertra !='0'  && $trafee !='0' && $trafee !='')
                 {
                    $badbal=$trafee-$totSeptembertra;
                    $para=($badbal/$trafee)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                   <input type="hidden" value="trafee" class="textwithid" />
                   <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
              </td>
          </tr>
          
           <tr>
              <td style="background-color:#ffe6e6" class="cola1">Motivation</td>
              <td><?php echo $Septembermoti; ?></td>
              <td><?php echo $junmoti; ?></td>
              <td><?php echo $Novembermoti; ?></td>
              <td><?php echo $augmoti; ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totSeptembermoti); ?></strong> </td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($moti); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totSeptembermoti !='0'  && $moti !='0' && $moti !='')
                 {
                    $badbal=$moti-$totSeptembermoti;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptembermoti !='0'  && $moti !='0' && $moti !='')
                 {
                    $badbal=$moti-$totSeptembermoti;
                    $para=($badbal/$moti)*100;
                    
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                  <input type="hidden" value="moti" class="textwithid" />
                  <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
             </td>
          </tr>
        
          <tr>
              <td style="background-color:#ffe6e6" class="cola1">Diaries</td>
              <td><?php echo number_format($Septemberdia); ?></td>
              <td><?php echo number_format($jundia); ?></td>
              <td><?php echo number_format($Novemberdia); ?></td>
              <td><?php echo number_format($augdia); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totSeptemberdia); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($diafee); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totSeptemberdia !='0'  && $diafee !='0' && $diafee !='')
                 {
                    $badbal=$diafee-$totSeptemberdia;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptemberdia !='0'  && $diafee !='0' && $diafee !='')
                 {
                    $badbal=$diafee-$totSeptemberdia;
                    $para=($badbal/$diafee)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                   <input type="hidden" value="diafee" class="textwithid" />
                   <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
              </td>
            </tr>
      
         
             <tr>
              <td style="background-color:#ffe6e6" class="cola1">Assessment Books</td>
              <td><?php echo number_format($Septemberbkf); ?></td>
              <td><?php echo number_format($junbkf); ?></td>
              <td><?php echo number_format($Novemberbkf); ?></td>
              <td><?php echo number_format($augbkf); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totSeptemberbkf); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($bks); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totSeptemberbkf !='0'  && $bks !='0' && $bks !='')
                 {
                    $badbal=$bks-$totSeptemberbkf;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptemberbkf !='0'  && $bks !='0' && $bks !='')
                 {
                    $badbal=$bks-$totSeptemberbkf;
                    $para=($badbal/$bks)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                   <input type="hidden" value="bks" class="textwithid" />
                   <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
              </td>
            </tr>
    
         <tr>
              <td style="background-color:#ffe6e6" class="cola1">Development</td>
              <td><?php echo number_format($Septemberdev); ?></td>
              <td><?php echo number_format($jundev); ?></td>
              <td><?php echo number_format($Novemberdev); ?></td>
              <td><?php echo number_format($augdev); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totSeptemberdev); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($devfee); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totSeptemberdev !='0'  && $devfee !='0' && $devfee !='')
                 {
                    $badbal=$devfee-$totSeptemberdev;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptemberdev !='0'  && $devfee !='0' && $devfee !='')
                 {
                    $badbal=$devfee-$totSeptemberdev;
                    $para=($badbal/$devfee)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                   <input type="hidden" value="dev" class="textwithid" />
                   <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
              </td>
            </tr>
             
           <tr class="bg-secondary">
              <td><strong class="alert-success">Sub Total (CBC)</strong></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td><STRONG style="color:orange"><?php echo number_format($subtncbc); ?></STRONG></td>
              <td></td>
              <td></td>
              <td></td>
              <td class="leavethis"></td>
          </tr>
          
           <tr class="">
              <td colspan="9"></td>
              <td class="leavethis"></td>
          </tr>
          
          <tr class="">
              <td colspan="7"><strong class="text-primary">Nursery School</strong></td> <td class="leavethis"></td>
          </tr>
          
          <tr>
              <td style="background-color:#ffe6e6" class="cola1">School Fees</td>
              <td><?php echo number_format($Septemberfeen); ?></td>
              <td><?php echo number_format($junfeen); ?></td>
              <td><?php echo number_format($Novemberfeen); ?></td>
              <td><?php echo number_format($augfeen); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totSeptemberfeen); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($tufeen); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totSeptemberfeen !='0'  && $tufeen !='0' && $tufeen !='')
                 {
                    $badbal=$tufeen-$totSeptemberfeen;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptemberfeen !='0'  && $tufeen !='0' && $tufeen !='')
                 {
                    $badbal=$tufeen-$totSeptemberfeen;
                    $para=($badbal/$tufeen)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                  <input type="hidden" value="tufeen" class="textwithid" />
                  <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
              </td>
          </tr>
          
            <tr>
              <td style="background-color:#ffe6e6" class="cola1">Transport Fee</td>
              <td><?php echo number_format($Septembertran); ?></td>
              <td><?php echo number_format($juntran); ?></td>
              <td><?php echo number_format($Novembertran); ?></td>
              <td><?php echo number_format($augtran); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totSeptembertran); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($trafeen); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totSeptembertran !='0'  && $trafeen !='0' && $trafeen !='')
                 {
                    $badbal=$trafeen-$totSeptembertran;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptembertran !='0'  && $trafeen !='0' && $trafeen !='')
                 {
                    $badbal=$trafeen-$totSeptembertran;
                    $para=($badbal/$trafeen)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                   <input type="hidden" value="trafeen" class="textwithid" />
                   <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
              </td>
          </tr>
          
           <tr>
              <td style="background-color:#ffe6e6" class="cola1">Uniform Fee</td>
              <td><?php echo number_format($Septemberunin); ?></td>
              <td><?php echo number_format($jununin); ?></td>
              <td><?php echo number_format($Novemberunin); ?></td>
              <td><?php echo number_format($augunin); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totSeptemberunin); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($unifeen); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totSeptemberunin !='0'  && $unifeen !='0' && $unifeen !='')
                 {
                    $badbal=$unifeen-$totSeptemberunin;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptemberunin !='0'  && $unifeen !='0' && $unifeen !='')
                 {
                    $badbal=$unifeen-$totSeptemberunin;
                    $para=($badbal/$unifeen)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                   <input type="hidden" value="unifeen" class="textwithid" />
                   <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
              </td>
          </tr>
          
          <tr>
              <td style="background-color:#ffe6e6" class="cola1">Admission Fee</td>
              <td><?php echo number_format($Septemberadfel); ?></td>
              <td><?php echo number_format($junadfel); ?></td>
              <td><?php echo number_format($Novemberadfel); ?></td>
              <td><?php echo number_format($augadfel); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totSeptemberadfeel); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($adfee2); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totSeptemberadfeel !='0'  && $adfee2 !='0' && $adfee2 !='')
                 {
                    $badbal=$adfee2-$totSeptemberadfeel;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptemberadfeel !='0'  && $adfee2 !='0' && $adfee2 !='')
                 {
                    $badbal=$adfee2-$totSeptemberadfeel;
                    $para=($badbal/$adfee2)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                   <input type="hidden" value="adfee2" class="textwithid" />
                   <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
              </td>
          </tr>
          <tr>
              <td style="background-color:#ffe6e6" class="cola1">Assessment Books</td>
              <td><?php echo number_format($Septemberbkfn); ?></td>
              <td><?php echo number_format($junbkfn); ?></td>
              <td><?php echo number_format($Novemberbkfn); ?></td>
              <td><?php echo number_format($augbkfn); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totSeptemberbkfn); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($boon); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totSeptemberbkfn !='0'  && $boon !='0' && $boon !='')
                 {
                    $badbal=$boon-$totSeptemberbkfn;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptemberbkfn !='0'  && $boon !='0' && $boon !='')
                 {
                    $badbal=$boon-$totSeptemberbkfn;
                    $para=($badbal/$boon)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                   <input type="hidden" value="boon" class="textwithid" />
                   <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
              </td>
            </tr>
     
            <tr>
              <td style="background-color:#ffe6e6" class="cola1">Diaries</td>
              <td><?php echo number_format($Septemberdian); ?></td>
              <td><?php echo number_format($jundian); ?></td>
              <td><?php echo number_format($Novemberdian); ?></td>
              <td><?php echo number_format($augdian); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totSeptemberdian); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($diafeen); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totSeptemberdian !='0'  && $diafeen !='0' && $diafeen !='')
                 {
                    $badbal=$diafeen-$totSeptemberdian;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptemberdian !='0'  && $diafeen !='0' && $diafeen !='')
                 {
                    $badbal=$diafeen-$totSeptemberdian;
                    $para=($badbal/$diafeen)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                   <input type="hidden" value="diafeen" class="textwithid" />
                   <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
              </td>
            </tr>
        
            <tr>
              <td style="background-color:#ffe6e6" class="cola1">Development</td>
              <td><?php echo number_format($Septemberdevn); ?></td>
              <td><?php echo number_format($jundevn); ?></td>
              <td><?php echo number_format($Novemberdevn); ?></td>
              <td><?php echo number_format($augdevn); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totSeptemberdevn); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($devn); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totSeptemberdevn !='0'  && $devn !='0' && $devn !='')
                 {
                    $badbal=$devn-$totSeptemberdevn;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptemberdevn !='0'  && $devn !='0' && $devn !='')
                 {
                    $badbal=$devn-$totSeptemberdevn;
                    $para=($badbal/$devn)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                   <input type="hidden" value="devn" class="textwithid" />
                   <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
              </td>
            </tr>
        
            <tr>
              <td style="background-color:#ffe6e6" class="cola1">Graduation</td>
              <td><?php echo number_format($gSeptember); ?></td>
              <td><?php echo number_format($gjun); ?></td>
              <td><?php echo number_format($gjul); ?></td>
              <td><?php echo number_format($gaug); ?></td>
              <td class="bg-primary"><strong  style="padding:5px"><?php echo number_format($totgradSeptember); ?></strong> </td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($gradd); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totgradSeptember !='0'  && $gradd !='0' && $gradd !='')
                 {
                    $badbal=$gradd-$totgradSeptember;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totgradSeptember !='0'  && $gradd !='0' && $gradd !='')
                 {
                    $badbal=$gradd-$totgradSeptember;
                    $para=($badbal/$gradd)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                  <input type="hidden" value="grad" class="textwithid" />
                  <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i>
                  </button>
             </td>
          </tr>
      
          
           <tr class="bg-secondary">
              <td><strong class="alert-success">Sub Total (Nursery)</strong></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td><STRONG style="color:orange"><?php echo number_format($subtn); ?></STRONG></td>
              <td></td>
              <td></td>
              <td></td>
              <td class="leavethis"></td>
          </tr>
          
           <tr class="">
              <td colspan="9"><strong>OTHER INCOME</strong></td>
              <td class="leavethis"></td>
          </tr>
          
          <?php
          if($totSeptemberbh=='' || $totSeptemberbh==0 || $totSeptemberbh==null)
          {
              
          }else{ ?>
          
            <tr>
              <td style="background-color:#ffe6e6" class="cola1">School Bus Hire</td>
              <td><?php echo $Septemberbh; ?></td>
              <td><?php echo $junbh; ?></td>
              <td><?php echo $Novemberbh; ?></td>
              <td><?php echo $augbh; ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo $totSeptemberbh; ?></strong>
              </td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($bus); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totSeptemberbh !='0'  && $bus !='0' && $bus !='')
                 {
                    $badbal=$bus-$totSeptemberbh;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptemberbh !='0'  && $bus !='0' && $bus !='')
                 {
                    $badbal=$bus-$totSeptemberbh;
                    $para=($badbal/$bus)*100;
                    
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                  <input type="hidden" value="bus" class="textwithid" />
                  <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
             </td>
          </tr>
          
           <?php
          }
         if($totSeptembertour=='0')
         { }else{ ?>
           <tr>
              <td style="background-color:#ffe6e6" class="cola1">Tour Payment</td>
              <td><?php echo number_format($Septembertour); ?></td>
              <td><?php echo number_format($juntour); ?></td>
              <td><?php echo number_format($Novembertour); ?></td>
              <td><?php echo number_format($augtour); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totSeptembertour); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($tuwa); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totSeptembertour !='0'  && $tuwa !='0' && $tuwa !='')
                 {
                    $badbal=$tuwa-$totSeptembertour;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptembertour !='0'  && $tuwa !='0' && $tuwa !='')
                 {
                    $badbal=$tuwa-$totSeptembertour;
                    $para=($badbal/$tuwa)*100;
                    
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                  <input type="hidden" value="tuwa" class="textwithid" />
                  <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
             </td>
          </tr>
          <?php
         }
         ?>
       
          <tr>
              <td style="background-color:#ffe6e6" class="cola1">Farm Income</td>
              <td><?php echo number_format($Septemberfam); ?></td>
              <td><?php echo number_format($junfam); ?></td>
              <td><?php echo number_format($Novemberfam); ?></td>
              <td><?php echo number_format($augfam); ?></td>
              <td class="bg-primary"><strong  style="padding:5px"><?php echo number_format($totSeptemberfam); ?></strong> </td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($farm1); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totSeptemberfam !='0'  && $farm1 !='0' && $farm1 !='')
                 {
                    $badbal=$farm1-$totSeptemberfam;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptemberfam !='0'  && $farm1 !='0' && $farm1 !='')
                 {
                    $badbal=$farm1-$totSeptemberfam;
                    $para=($badbal/$farm1)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                  <input type="hidden" value="farm1" class="textwithid" />
                  <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i>
                  </button>
             </td>
          </tr>
          
          <?php
            $peri='September-December-'.$yr;
            $in='in';
            $query=mysqli_query($con,"select IncomeCat.*,(SELECT SUM(Amount) FROM Otherincome where Month='September' AND Year='$yr' AND Cat=IncomeCat.count) as Septemberinco,
            (SELECT SUM(Amount) FROM Otherincome where Month='October' AND Year='$yr' AND Cat=IncomeCat.count) as juninco,
            (SELECT SUM(Amount) FROM Otherincome where Month='November' AND Year='$yr' AND Cat=IncomeCat.count) as julinco,
            (SELECT SUM(Amount) FROM Otherincome where Month='December' AND Year='$yr' AND Cat=IncomeCat.count) as auginco,
            (SELECT SUM(Amount) FROM Incomebudget where Period='$peri' AND ID=IncomeCat.count) as badget from IncomeCat ORDER BY Item ASC");
            while($row=mysqli_fetch_array($query))
            {
            $Septemberinco=$row['Septemberinco'];
            $juninco=$row['juninco'];
            $julinco=$row['julinco'];
            $auginco=$row['auginco'];
            $bud=$row['badget'];
            
            $toto=$juninco+$Septemberinco+$julinco+$auginco;
           ?>
           <?php
         if($toto=='0')
         { }else{ ?>
           <tr>
             <td style="background-color:#ffe6e6" class="cola1"><?php echo $row['Item']; ?></td> 
             <td><?php echo number_format($Septemberinco); ?></td>
             <td><?php echo number_format($juninco); ?></td>
             <td><?php echo number_format($julinco); ?></td>
             <td><?php echo number_format($auginco); ?></td>
             <td class="bg-primary"><strong><?php echo number_format($toto); ?></strong></td>
             <td style="background-color:#e6ccff"><strong><?php echo number_format($bud); ?></strong></td>
             
             <td>
                 <strong>
                 <?php
                 if($toto !='0'  && $bud !='0' && $bud !='')
                 {
                    $badbal=$bud-$toto;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($toto !='0'  && $bud !='0' && $bud !='')
                 {
                    $badbal=$bud-$toto;
                    $para=($badbal/$bud)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
             <td class="leavethis">
                  <input type="hidden" value="<?php echo $row['count']; ?>" class="itemidd" />
                  <button class="btn btn-default budgettincome btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
             </td>
          </tr>
          <?php
         }
            }
            ?>

           <tr class="bg-success">
              <td><strong>TOTAL GROSS INCOME</strong></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td><strong style="font-size:22px"><?php echo number_format($totincomeSeptemberaug); ?></strong></td>
              <td></td>
              <td></td>
              <td></td>
              <td class="leavethis"></td>
          </tr>
          
          
          <tr>
               <td colspan="9"></td>
          </tr>
          
           <tr class="alert-warning">
              <td colspan="10"><strong>Expenses</strong></td>
          </tr>
           <tr>
              <td style="background-color:#ffe6e6" class="cola1">Projects</td>
              <td><?php echo number_format($mpro); ?></td>
              <td><?php echo number_format($jupro); ?></td>
              <td><?php echo number_format($julpro); ?></td>
              <td><?php echo number_format($aupro); ?></td>
              <td style="background-color:#fff2cc"><strong><?php echo number_format($totSeptemberproject); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($proje); ?></strong></td>
               <td>
                 <strong>
                 <?php
                 if($totSeptemberproject !='0'  && $proje !='0' && $proje !='')
                 {
                    $badbal=$proje-$totSeptemberproject;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptemberproject !='0'  && $proje !='0' && $proje !='')
                 {
                    $badbal=$proje-$totSeptemberproject;
                    $para=($badbal/$proje)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              <td class="leavethis">
                  <input type="hidden" value="proje" class="textwithid" />
                  <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
              </td>
          </tr>
          <?php
          if($totSeptembersala<1) { }else
          { ?>
           <tr>
              <td style="background-color:#ffe6e6" class="cola1">Salaries</td>
              <td><?php echo $msala; ?></td>
              <td><?php echo $jusala; ?></td>
              <td><?php echo $julsala; ?></td>
              <td><?php echo $ausala; ?></td>
              <td style="background-color:#fff2cc"><strong><?php echo number_format($totSeptembersala); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($sala); ?></strong></td>
               <td>
                 <strong>
                 <?php
                 if($totSeptembersala !='0'  && $sala !='0' && $sala !='')
                 {
                    $badbal=$sala-$totSeptembersala;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totSeptembersala !='0'  && $sala !='0' && $sala !='')
                 {
                    $badbal=$sala-$totSeptembersala;
                    $para=($badbal/$sala)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
              
              <td class="leavethis">
                  <input type="hidden" value="sala" class="textwithid" />
                  <button class="btn btn-default budget btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
                  </td>
          </tr>
            <?php
          }
            $peri='September-December-'.$yr;
            $query=mysqli_query($con,"select expenses.*,(SELECT SUM(Amount) FROM Expenses where Month='September' AND Year='$yr' AND Cat=expenses.Count) as Septemberyexpe,
            (SELECT SUM(Amount) FROM Imprest2 where Month='September' AND Year='$yr' AND Cate=expenses.Count) as Septemberyexpe2,
            (SELECT SUM(Amount) FROM Expenses where Month='October' AND Year='$yr' AND Cat=expenses.Count) as Octoberexpe,
            (SELECT SUM(Amount) FROM Imprest2 where Month='October' AND Year='$yr' AND Cate=expenses.Count) as Octoberexpe2,
            
            (SELECT SUM(Amount) FROM Expenses where Month='November' AND Year='$yr' AND Cat=expenses.Count) as Novemberexpe,
            (SELECT SUM(Amount) FROM Imprest2 where Month='November' AND Year='$yr' AND Cate=expenses.Count) as Novemberexpe2,
            
            (SELECT SUM(Amount) FROM Expenses where Month='December' AND Year='$yr' AND Cat=expenses.Count) as augaexpe,
            (SELECT SUM(Amount) FROM Imprest2 where Month='December' AND Year='$yr' AND Cate=expenses.Count) as augaexpe2,
            (SELECT SUM(Amount) FROM BudgetAmount where Period='$peri' AND ID=expenses.Count) as badget from expenses ORDER BY Item ASC");
            while($row=mysqli_fetch_array($query))
            {
            $totSeptembere=$row['Septemberyexpe']+$row['Septemberyexpe2'];
            $totOctobere=$row['Octoberexpe']+$row['Octoberexpe2'];
            $totNovembere=$row['Novemberexpe']+$row['Novemberexpe2'];
            $totaugae=$row['augaexpe']+$row['augaexpe2'];
            $badget=$row['badget'];
            
            $tot=$totSeptembere+$totOctobere+$totNovembere+$totaugae;
            if($tot<1)
            { 
                
            }else
            {
           ?>
          <tr>
             <td style="background-color:#ffe6e6" class="cola1"><?php echo $row['Item']; ?></td> 
             <td><?php echo number_format($totSeptembere); ?></td>
             <td><?php echo number_format($totOctobere); ?></td>
             <td><?php echo number_format($totNovembere); ?></td>
             <td><?php echo number_format($totaugae); ?></td>
             <td style="background-color:#fff2cc"><strong><?php echo number_format($tot); ?></strong></td>
             <td style="background-color:#e6ccff"><strong><?php echo number_format($badget); ?></strong></td>
             
             <td>
                 <strong>
                 <?php
                 if($tot !='0'  && $badget !='0' && $badget !='')
                 {
                    $badbal=$badget-$tot;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($tot !='0'  && $badget !='0' && $badget !='')
                 {
                    $badbal=$badget-$tot;
                    $para=($badbal/$badget)*100;
                    echo number_format((float)$para, 2, '.', '').'%';
                 }
                 ?>
                 </strong>
             </td>
             <td class="leavethis">
                  <input type="hidden" value="<?php echo $row['Count']; ?>" class="itemid" />
                  <button class="btn btn-default budgett btn-sm">Budgeted Amount <i class="fa fa-refresh"></i></button>
             </td>
          </tr>
          <?php
            }
            }
            ?>
          
           <tr class="alert-danger">
              <td><STRONG>TOTAL EXPENSES</STRONG></td>
              <td><?php  ?></td>
              <td><?php ?></td>
              <td><?php  ?></td>
              <td><?php  ?></td>
              <td><STRONG class=""><?php echo number_format($totalexpens); ?></STRONG></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
          </tr>
          
          <tr class="alert-warning">
              <td><STRONG>BALANCE (KES)</STRONG></td>
              <td><?php  ?></td>
              <td><?php ?></td>
              <td><?php  ?></td>
              <td><?php  ?></td>
              <?php
              $bala=$totincomeSeptemberaug-$totalexpens;
              if($bala>0)
              {
              ?>
              <td class="alert-success"><STRONG class=""><?php echo number_format($totincomeSeptemberaug-$totalexpens); ?></STRONG> <small>SURPLUS</small></td>
              <?php
              }else{
              ?>
              <td class="alert-warning"><STRONG class=""><?php echo number_format($totincomeSeptemberaug-$totalexpens); ?></STRONG> <small>DEFICIT</small></td>
              <?php
              } 
              ?>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
          </tr>
      </tbody>
      <tfooter class="leavethis">
          <tr class="leavethis">
              <td colspan="10"><button class="btn btn-default btn-sm pull-right" id="down"> Download Excel File <i class="fa fa-cloud-download"></i></button>
              </td>
          </tr>
      </tfooter>
  </table>
  <input type="hidden" value="<?php echo $peri; ?>" id="periodicc" />
</div>