<?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>January</th>
            <th>February</th>
            <th>March</th>
            <th>April</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>
          <tr>
              <td style="background-color:#ffe6e6" class="cola1">School Fees</td>
              <td class="cola2"><?php echo number_format($Januaryfee); ?></td>
              <td class="cola3"><?php echo number_format($junfee); ?></td>
              <td class="cola4"><?php echo number_format($Marchfee); ?></td>
              <td class="cola5"><?php echo number_format($augfee); ?></td>
              <td class="bg-primary cola6"><strong style="padding:5px"><?php echo number_format($totJanuaryfee); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($sfee); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totJanuaryfee !='0'  && $sfee !='0' && $sfee !='')
                 {
                    $badbal=$sfee-$totJanuaryfee;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuaryfee !='0'  && $sfee !='0' && $sfee !='')
                 {
                    $badbal=$sfee-$totJanuaryfee;
                    $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>
          
           <tr>
              <td style="background-color:#ffe6e6" class="cola1">Uniform Fee</td>
              <td><?php echo number_format($Januaryuni); ?></td>
              <td><?php echo number_format($jununi); ?></td>
              <td><?php echo number_format($Marchuni); ?></td>
              <td><?php echo number_format($auguni); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totJanuaryuni); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($unifee); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totJanuaryuni !='0'  && $unifee !='0' && $unifee !='')
                 {
                    $badbal=$unifee-$totJanuaryuni;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuaryuni !='0'  && $unifee !='0' && $unifee !='')
                 {
                    $badbal=$unifee-$totJanuaryuni;
                    $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($Januaryadfe); ?></td>
              <td><?php echo number_format($junadfe); ?></td>
              <td><?php echo number_format($Marchadfe); ?></td>
              <td><?php echo number_format($augadfe); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totJanuaryadfee); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($adfee); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totJanuaryadfee !='0'  && $adfee !='0' && $adfee !='')
                 {
                    $badbal=$adfee-$totJanuaryadfee;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuaryadfee !='0'  && $adfee !='0' && $adfee !='')
                 {
                    $badbal=$adfee-$totJanuaryadfee;
                    $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($Januarytra); ?></td>
              <td><?php echo number_format($juntra); ?></td>
              <td><?php echo number_format($Marchtra); ?></td>
              <td><?php echo number_format($augtra); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totJanuarytra); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($trafee); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totJanuarytra !='0'  && $trafee !='0' && $trafee !='')
                 {
                    $badbal=$trafee-$totJanuarytra;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuarytra !='0'  && $trafee !='0' && $trafee !='')
                 {
                    $badbal=$trafee-$totJanuarytra;
                    $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 $Januarymoti; ?></td>
              <td><?php echo $junmoti; ?></td>
              <td><?php echo $Marchmoti; ?></td>
              <td><?php echo $augmoti; ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totJanuarymoti); ?></strong> </td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($moti); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totJanuarymoti !='0'  && $moti !='0' && $moti !='')
                 {
                    $badbal=$moti-$totJanuarymoti;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuarymoti !='0'  && $moti !='0' && $moti !='')
                 {
                    $badbal=$moti-$totJanuarymoti;
                    $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($Januarydia); ?></td>
              <td><?php echo number_format($jundia); ?></td>
              <td><?php echo number_format($Marchdia); ?></td>
              <td><?php echo number_format($augdia); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totJanuarydia); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($diafee); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totJanuarydia !='0'  && $diafee !='0' && $diafee !='')
                 {
                    $badbal=$diafee-$totJanuarydia;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuarydia !='0'  && $diafee !='0' && $diafee !='')
                 {
                    $badbal=$diafee-$totJanuarydia;
                    $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($Januarybkf); ?></td>
              <td><?php echo number_format($junbkf); ?></td>
              <td><?php echo number_format($Marchbkf); ?></td>
              <td><?php echo number_format($augbkf); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totJanuarybkf); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($bks); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totJanuarybkf !='0'  && $bks !='0' && $bks !='')
                 {
                    $badbal=$bks-$totJanuarybkf;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuarybkf !='0'  && $bks !='0' && $bks !='')
                 {
                    $badbal=$bks-$totJanuarybkf;
                    $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($Januarydev); ?></td>
              <td><?php echo number_format($jundev); ?></td>
              <td><?php echo number_format($Marchdev); ?></td>
              <td><?php echo number_format($augdev); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totJanuarydev); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($devfee); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totJanuarydev !='0'  && $devfee !='0' && $devfee !='')
                 {
                    $badbal=$devfee-$totJanuarydev;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuarydev !='0'  && $devfee !='0' && $devfee !='')
                 {
                    $badbal=$devfee-$totJanuarydev;
                    $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($Januaryfeen); ?></td>
              <td><?php echo number_format($junfeen); ?></td>
              <td><?php echo number_format($Marchfeen); ?></td>
              <td><?php echo number_format($augfeen); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totJanuaryfeen); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($tufeen); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totJanuaryfeen !='0'  && $tufeen !='0' && $tufeen !='')
                 {
                    $badbal=$tufeen-$totJanuaryfeen;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuaryfeen !='0'  && $tufeen !='0' && $tufeen !='')
                 {
                    $badbal=$tufeen-$totJanuaryfeen;
                    $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($Januarytran); ?></td>
              <td><?php echo number_format($juntran); ?></td>
              <td><?php echo number_format($Marchtran); ?></td>
              <td><?php echo number_format($augtran); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totJanuarytran); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($trafeen); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totJanuarytran !='0'  && $trafeen !='0' && $trafeen !='')
                 {
                    $badbal=$trafeen-$totJanuarytran;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuarytran !='0'  && $trafeen !='0' && $trafeen !='')
                 {
                    $badbal=$trafeen-$totJanuarytran;
                    $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($Januaryunin); ?></td>
              <td><?php echo number_format($jununin); ?></td>
              <td><?php echo number_format($Marchunin); ?></td>
              <td><?php echo number_format($augunin); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totJanuaryunin); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($unifeen); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totJanuaryunin !='0'  && $unifeen !='0' && $unifeen !='')
                 {
                    $badbal=$unifeen-$totJanuaryunin;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuaryunin !='0'  && $unifeen !='0' && $unifeen !='')
                 {
                    $badbal=$unifeen-$totJanuaryunin;
                    $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($Januaryadfel); ?></td>
              <td><?php echo number_format($junadfel); ?></td>
              <td><?php echo number_format($Marchadfel); ?></td>
              <td><?php echo number_format($augadfel); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totJanuaryadfeel); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($adfee2); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totJanuaryadfeel !='0'  && $adfee2 !='0' && $adfee2 !='')
                 {
                    $badbal=$adfee2-$totJanuaryadfeel;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuaryadfeel !='0'  && $adfee2 !='0' && $adfee2 !='')
                 {
                    $badbal=$adfee2-$totJanuaryadfeel;
                    $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($Januarybkfn); ?></td>
              <td><?php echo number_format($junbkfn); ?></td>
              <td><?php echo number_format($Marchbkfn); ?></td>
              <td><?php echo number_format($augbkfn); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totJanuarybkfn); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($boon); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totJanuarybkfn !='0'  && $boon !='0' && $boon !='')
                 {
                    $badbal=$boon-$totJanuarybkfn;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuarybkfn !='0'  && $boon !='0' && $boon !='')
                 {
                    $badbal=$boon-$totJanuarybkfn;
                    $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($Januarydian); ?></td>
              <td><?php echo number_format($jundian); ?></td>
              <td><?php echo number_format($Marchdian); ?></td>
              <td><?php echo number_format($augdian); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totJanuarydian); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($diafeen); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totJanuarydian !='0'  && $diafeen !='0' && $diafeen !='')
                 {
                    $badbal=$diafeen-$totJanuarydian;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuarydian !='0'  && $diafeen !='0' && $diafeen !='')
                 {
                    $badbal=$diafeen-$totJanuarydian;
                    $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">Developmentt</td>
              <td><?php echo number_format($Januarydevn); ?></td>
              <td><?php echo number_format($jundevn); ?></td>
              <td><?php echo number_format($Marchdevn); ?></td>
              <td><?php echo number_format($augdevn); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totJanuarydevn); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($devn); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totJanuarydevn !='0'  && $devn !='0' && $devn !='')
                 {
                    $badbal=$devn-$totJanuarydevn;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuarydevn !='0'  && $devn !='0' && $devn !='')
                 {
                    $badbal=$devn-$totJanuarydevn;
                    $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 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>
          
            <tr>
              <td style="background-color:#ffe6e6" class="cola1">School Bus Hire</td>
              <td><?php echo $Januarybh; ?></td>
              <td><?php echo $junbh; ?></td>
              <td><?php echo $Marchbh; ?></td>
              <td><?php echo $augbh; ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo $totJanuarybh; ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($bus); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totJanuarybh !='0'  && $bus !='0' && $bus !='')
                 {
                    $badbal=$bus-$totJanuarybh;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuarybh !='0'  && $bus !='0' && $bus !='')
                 {
                    $badbal=$bus-$totJanuarybh;
                    $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>
          
           <tr>
              <td style="background-color:#ffe6e6" class="cola1">Tour Payment</td>
              <td><?php echo number_format($Januarytour); ?></td>
              <td><?php echo number_format($juntour); ?></td>
              <td><?php echo number_format($Marchtour); ?></td>
              <td><?php echo number_format($augtour); ?></td>
              <td class="bg-primary"><strong style="padding:5px"><?php echo number_format($totJanuarytour); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($tuwa); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totJanuarytour !='0'  && $tuwa !='0' && $tuwa !='')
                 {
                    $badbal=$tuwa-$totJanuarytour;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuarytour !='0'  && $tuwa !='0' && $tuwa !='')
                 {
                    $badbal=$tuwa-$totJanuarytour;
                    $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>
       
          <tr>
              <td style="background-color:#ffe6e6" class="cola1">Farm Income</td>
              <td><?php echo number_format($Januaryfam); ?></td>
              <td><?php echo number_format($junfam); ?></td>
              <td><?php echo number_format($Marchfam); ?></td>
              <td><?php echo number_format($augfam); ?></td>
              <td class="bg-primary"><strong  style="padding:5px"><?php echo number_format($totJanuaryfam); ?></strong> </td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($farm1); ?></strong></td>
              <td>
                 <strong>
                 <?php
                 if($totJanuaryfam !='0'  && $farm1 !='0' && $farm1 !='')
                 {
                    $badbal=$farm1-$totJanuaryfam;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuaryfam !='0'  && $farm1 !='0' && $farm1 !='')
                 {
                    $badbal=$farm1-$totJanuaryfam;
                    $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='January-April-'.$yr;
            $in='in';
            $query=mysqli_query($con,"select IncomeCat.*,(SELECT SUM(Amount) FROM Otherincome where Month='January' AND Year='$yr' AND Cat=IncomeCat.count) as Januaryinco,
            (SELECT SUM(Amount) FROM Otherincome where Month='February' AND Year='$yr' AND Cat=IncomeCat.count) as juninco,
            (SELECT SUM(Amount) FROM Otherincome where Month='March' AND Year='$yr' AND Cat=IncomeCat.count) as julinco,
            (SELECT SUM(Amount) FROM Otherincome where Month='April' 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))
            {
            $Januaryinco=$row['Januaryinco'];
            $juninco=$row['juninco'];
            $julinco=$row['julinco'];
            $auginco=$row['auginco'];
            $bud=$row['badget'];
            
            $toto=$juninco+$Januaryinco+$julinco+$auginco;
            if($toto<1)
            { }else
            {
           ?>
           <tr>
             <td style="background-color:#ffe6e6" class="cola1"><?php echo $row['Item']; ?></td> 
             <td><?php echo number_format($Januaryinco); ?></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($totincomeJanuaryaug); ?></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($totJanuaryproject); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($proje); ?></strong></td>
               <td>
                 <strong>
                 <?php
                 if($totJanuaryproject !='0'  && $proje !='0' && $proje !='')
                 {
                    $badbal=$proje-$totJanuaryproject;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuaryproject !='0'  && $proje !='0' && $proje !='')
                 {
                    $badbal=$proje-$totJanuaryproject;
                    $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($totJanuarysala==0  || $totJanuarysala=='0')
          { }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($totJanuarysala); ?></strong></td>
              <td style="background-color:#e6ccff"><strong><?php echo number_format($sala); ?></strong></td>
               <td>
                 <strong>
                 <?php
                 if($totJanuarysala !='0'  && $sala !='0' && $sala !='')
                 {
                    $badbal=$sala-$totJanuarysala;
                    echo number_format($badbal);
                 }
                 ?>
                 </strong>
             </td>
             
             <td>
                 <strong class="text-success">
                 <?php
                 if($totJanuarysala !='0'  && $sala !='0' && $sala !='')
                 {
                    $badbal=$sala-$totJanuarysala;
                    $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='January-April-'.$yr;
            $query=mysqli_query($con,"select expenses.*,(SELECT SUM(Amount) FROM Expenses where Month='January' AND Year='$yr' AND Cat=expenses.Count) as Januaryyexpe,
            (SELECT SUM(Amount) FROM Imprest2 where Month='January' AND Year='$yr' AND Cate=expenses.Count) as Januaryyexpe2,
            (SELECT SUM(Amount) FROM Expenses where Month='February' AND Year='$yr' AND Cat=expenses.Count) as Februaryexpe,
            (SELECT SUM(Amount) FROM Imprest2 where Month='February' AND Year='$yr' AND Cate=expenses.Count) as Februaryexpe2,
            
            (SELECT SUM(Amount) FROM Expenses where Month='March' AND Year='$yr' AND Cat=expenses.Count) as Marchexpe,
            (SELECT SUM(Amount) FROM Imprest2 where Month='March' AND Year='$yr' AND Cate=expenses.Count) as Marchexpe2,
            
            (SELECT SUM(Amount) FROM Expenses where Month='April' AND Year='$yr' AND Cat=expenses.Count) as augaexpe,
            (SELECT SUM(Amount) FROM Imprest2 where Month='April' 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))
            {
            $totJanuarye=$row['Januaryyexpe']+$row['Januaryyexpe2'];
            $totFebruarye=$row['Februaryexpe']+$row['Februaryexpe2'];
            $totMarche=$row['Marchexpe']+$row['Marchexpe2'];
            $totaugae=$row['augaexpe']+$row['augaexpe2'];
            $badget=$row['badget'];
            
            $tot=$totJanuarye+$totFebruarye+$totMarche+$totaugae;
            
            if($tot=='0' || $tot==0)
            { }else {
           ?>
           
          <tr>
             <td style="background-color:#ffe6e6" class="cola1"><?php echo $row['Item']; ?></td> 
             <td><?php echo number_format($totJanuarye); ?></td>
             <td><?php echo number_format($totFebruarye); ?></td>
             <td><?php echo number_format($totMarche); ?></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=$totincomeJanuaryaug-$totalexpens;
              if($bala>0)
              {
              ?>
              <td class="alert-success"><STRONG class=""><?php echo number_format($totincomeJanuaryaug-$totalexpens); ?></STRONG> <small>SURPLUS</small></td>
              <?php
              }else{
              ?>
              <td class="alert-warning"><STRONG class=""><?php echo number_format($totincomeJanuaryaug-$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>