<?php include "header_with_out_nav.php"; ?>

<?php 
$tocken=$_POST['tocken'];
$id=$_POST['id'];
$en=$_POST['en'];
$day=$_POST['day'];
$month=$_POST['month'];
$year=$_POST['year'];
$payment_option=$_POST['payment_option'];
$dd_cc_no=$_POST['dd_cc_no'];
$bank_name=$_POST['bank_name'];
$branch=$_POST['branch'];
$mode_of_pay=$_POST['mode_of_pay'];
$psa=$_POST['psa'];
$Deduction=$_POST['Deduction'];
$bonus=$_POST['bonus'];
$notes=$_POST['notes'];
$tempo_fee=$_POST['tempo_fee'];
$JANUARY=$_POST['JANUARY'];
$FEBRUARY=$_POST['FEBRUARY'];
$MARCH=$_POST['MARCH'];
$APRIL=$_POST['APRIL'];
$MAY=$_POST['MAY'];
$JUNE=$_POST['JUNE'];
$JULY=$_POST['JULY'];
$AUGUST=$_POST['AUGUST'];
$SEPTEMBER=$_POST['SEPTEMBER'];
$OCTOBER=$_POST['OCTOBER'];
$NOVEMBER=$_POST['NOVEMBER'];
$DECEMBER=$_POST['DECEMBER'];
$year_fee=$_POST['year_fee'];
$section=$_POST['section'];
$post=$_POST['post'];
$monthx=$_POST['monthx'];



$tcounter=0;
if($APRIL=='Paid'){$tcounter+=1;}
if($MAY=='Paid'){$tcounter+=1;}
if($JUNE=='Paid'){$tcounter+=1;}
if($JULY=='Paid'){$tcounter+=1;}
if($AUGUST=='Paid'){$tcounter+=1;}
if($SEPTEMBER=='Paid'){$tcounter+=1;}
if($OCTOBER=='Paid'){$tcounter+=1;}
if($NOVEMBER=='Paid'){$tcounter+=1;}
if($DECEMBER=='Paid'){$tcounter+=1;}
if($JANUARY=='Paid'){$tcounter+=1;}
if($FEBRUARY=='Paid'){$tcounter+=1;}
if($MARCH=='Paid'){$tcounter+=1;}
if($mode_of_pay==$tcounter){						
							 		 		   ?>
 <style>
h1{
font-size:14px;
color:#FF0000;
text-align:center;}
 </style>

	<?php 
	$psa_pe=$psa;
	$psa_p=$psa_pe;?>
	<?php $total=$psa_p+$bonus-$Deduction;?>
	<?php $paid=$psa_p+$bonus-$Deduction;?>
	
	<?php //echo $SEPTEMBER;?>
 <?php
 $balance=$total-$paid;
$query = "INSERT INTO `salary` (`id`, `sr_no`, `day`, `month`, `year`, `psa`, `Deduction`, `bonus`, `Note`, `payment_option`, `dd_cc_no`, `bank_name`, `Branch`, `mode_of_pay`, `JANUARY`, `FEBRUARY`, `MARCH`, `APRIL`, `MAY`, `JUNE`, `JULY`, `AUGUST`, `SEPTEMBER`, `OCTOBER`, `NOVEMBER`, `DECEMBER`, `total`, `tocken`, `account`,`code`,`session`) VALUES ('$id', '$en', '$day', '$month', '$year', '$psa', '$Deduction', '$bonus', '$notes', '$payment_option', '$dd_cc_no', '$bank_name', '$Branch', '$mode_of_pay', '$JANUARY', '$FEBRUARY', '$MARCH', '$APRIL', '$MAY', '$JUNE', '$JULY', '$AUGUST', '$SEPTEMBER', '$OCTOBER', '$NOVEMBER', '$DECEMBER', '$total', '$tocken', '$post','$code','$session');";
  mysql_query( $query )
 
 ?>

	<?php

$result = mysql_query("SELECT * FROM salary where tocken=$tocken and session='$session' and code='$code'");
$id=mysql_result($result,$i,"id");
$sr_no=mysql_result($result,$i,"sr_no");
$day=mysql_result($result,$i,"day");
$month=mysql_result($result,$i,"month");
$year=mysql_result($result,$i,"year");
$psa=mysql_result($result,$i,"psa");
$Deduction=mysql_result($result,$i,"Deduction");
$bonus=mysql_result($result,$i,"bonus");
$Note=mysql_result($result,$i,"Note");
$bonus=mysql_result($result,$i,"bonus");
$payment_option=mysql_result($result,$i,"payment_option");
$dd_cc_no=mysql_result($result,$i,"dd_cc_no");
$bank_name=mysql_result($result,$i,"bank_name");
$Branch=mysql_result($result,$i,"Branch");
$mode_of_pay=mysql_result($result,$i,"mode_of_pay");
$JANUARY=mysql_result($result,$i,"JANUARY");
$FEBRUARY=mysql_result($result,$i,"FEBRUARY");
$MARCH=mysql_result($result,$i,"MARCH");
$APRIL=mysql_result($result,$i,"APRIL");
$MAY=mysql_result($result,$i,"MAY");
$JUNE=mysql_result($result,$i,"JUNE");
$JULY=mysql_result($result,$i,"JULY");
$AUGUST=mysql_result($result,$i,"AUGUST");
$SEPTEMBER=mysql_result($result,$i,"SEPTEMBER");
$OCTOBER=mysql_result($result,$i,"OCTOBER");
$NOVEMBER=mysql_result($result,$i,"NOVEMBER");
$DECEMBER=mysql_result($result,$i,"DECEMBER");
$total=mysql_result($result,$i,"total");

?>
		 
		  <table cellpadding="2" cellspacing="0" border="0" width="680" align="center">
  <tr>
    <td><div>
      <div align="center"><span class="style1" style="color:#000000; font-size:18px"><?php echo $cname; ?></span><?php echo $cadd; ?></div>
    </div>
	<div>
	  
	</div>
	</td>
  <tr>
    <td></td>
 
    <td></td>
  <tr>
    <td><table width="100%" border="0" cellspacing="" align="center" cellpadding="2">
 <input type="hidden" name="id" value="<?php echo $id;?>" />
 
  
  <tr>
    <td colspan="4" align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      
	  
      <tr>
        <td ><table width="100%" border="0" cellspacing="2" cellpadding="2">
          <tr>
            <td colspan="6"><div align="center"><span class="style3"><span class="style4">Date<strong>:</strong></span><span class="style44"><?php echo $day;?>-<?php echo $month;?>-<?php echo $year;?> </span></span></div></td>
            </tr>
          <tr>
            <td width="20%"><div align="right"><strong><span class="style46">No</span></strong></div></td>
            <td width="3%"><div align="center"><strong>-</strong></div></td>
            <td width="27%"><div align="left"><span class="style46"><?php echo $id;?></span></div></td>
            <td width="21%"><div align="right"><strong><span class="style46"><span class="style47">Enro. No</span></span></strong></div></td>
            <td width="3%"><div align="center"><strong>-</strong></div></td>
            <td width="26%"><div align="left"><span class="style46"><span class="style48">
              <input name="en"   style="width:30px;" value="<?php echo $en;?>" type="hidden" />
              <?php echo $en;?></span></span></div></td>
          </tr>
          <tr>
            <td><div align="right"><strong><span class="style46"><span class="style47">
              <?php
$resultt = mysql_query("SELECT * FROM add_teachers where sr_no='$en' and session='$session' and code='$code'");
 
 $name=mysql_result($resultt,$i,"name");
 $f_h_name=mysql_result($resultt,$i,"f_h_name");
  
?>
              Staff Name</span></span></strong></div></td>
            <td><div align="center"><strong>-</strong></div></td>
            <td><div align="left"><span class="style46"><span class="style48"><?php echo $name;?>
               
            </span></span></div></td>
            <td><div align="right"><strong>Father Name</strong></div></td>
            <td><div align="center"><strong>-</strong></div></td>
            <td><div align="left"><span class="style48"><?php echo $f_h_name;?></span></div></td>
          </tr>
       
        </table></td>
      </tr>
          
      <?php if($dd_cc_no!=0){?>
      <tr>
        <td  >      <div align="center"><span class="style15 style5">Cheque/D.D. Number&nbsp;:&nbsp;</span><span class="style44"><?php echo $dd_cc_no;?><input name="dd_cc_no" value="<?php echo $dd_cc_no;?>"    style="width:60px;"type="hidden" /></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            
                  <span class="style15 style5">Bank Name</span>&nbsp;:&nbsp;<span class="style44"><?php echo $bank_name;?><input name="bank_name"   style="width:70px;" value="<?php echo $bank_name;?>" type="hidden" /></span>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <span class="style15 style5">Branch&nbsp;:&nbsp;</span><span class="style44"><input name="branch"    style="width:80px;"value="<?php echo $branch;?>" type="hidden" /><?php echo $branch;?>
            
          </span></div></td>
        </tr>
      <?php }?>
      
    </table></td>
    </tr>
  <tr>
    <td width="50%" style="border-bottom:1px #000000 solid;border-top:1px #000000 solid" ><div align="center" class="style45">Detail </div></td>
    <td width="2%" style="border-bottom:1px #000000 solid;border-top:1px #000000 solid" ><div align="center"></div></td>
    <td colspan="2" style="border-bottom:1px #000000 solid;border-top:1px #000000 solid" ><div align="center" class="style45">Amount ( Rs/-) </div></td>
    </tr>
	
	<?php if($add_fee!="0"){?>
	<?php }?>
	<?php if($annual_cha_n_vii!="0"){?>
  <?php }?>
	<?php if($facility_develop!="0"){?>
   <?php }?>
	<?php if($caution_mony!="0"){?>
   <?php }?><tr>
      <td colspan="4"><div align="center">---------------------------------------------History--------------------------------------------------</div></td>
      </tr>
	<?php 
$resultbb = mysql_query("SELECT * FROM salary where sr_no=$en and $monthx='Paid' and session='$session' and code='$code' ORDER BY id ");
?>
 <?php
while ( $a_rowbb = mysql_fetch_array( $resultbb ) )
 {
  $advan+=$a_rowbb['total'];
 ?> 
    
    <tr>
      <td><div align="right">Payment Details - <?php echo $a_rowbb['day']; ?>-<?php echo $a_rowbb['month']; ?>-<?php echo $a_rowbb['year']; ?></div></td>
      <td valign="bottom">:</td>
      <td width="29%" align="left" valign="bottom"><div align="right"><?php echo $a_rowbb['total']; ?></div></td>
      <td width="19%" align="left" valign="bottom">&nbsp;</td>
    </tr>
   
	<?php } echo $advan;?> <tr>
      <td colspan="4"><div align="center">---------------------------------------------History--------------------------------------------------</div></td>
    </tr>
  
    <tr>
      <td colspan="4">&nbsp;</td>
      </tr>
    <tr>
      <td><div align="right">Payment</div></td>
      <td>:</td>
      <td align="left" valign="bottom"><div align="right"><?php echo $advan;?> /-</div></td>
      <td align="left" valign="bottom">&nbsp;</td>
    </tr> <?php if($Deduction!="0"){?>
    <tr>
    <td><div align="right" class="style4">Deduction</div></td>
    <td><div align="center"><strong>:</strong></div></td>
    <td align="left" valign="bottom"><div align="left" class="style72"> 
      <div align="right"><strong>-</strong> <?php echo $Deduction;?>
        /-</div>
    </div></td>
    <td align="left" valign="bottom">&nbsp;</td>
  </tr>
  <?php }?>
	<?php if($bonus!="0"){?>
  <tr>
    <td><div align="right" class="style4">Bonus</div></td>
    <td><div align="center"><strong>:</strong></div></td>
    <td align="left" valign="bottom"><div align="left" class="style72">
      <div align="right"><?php echo $bonus;?>
        /-</div>
    </div></td>
    <td align="left" valign="bottom">&nbsp;</td>
  </tr>

  <?php }?>
		<?php if($notes!=""){?> 
    <tr>
      <td colspan="4" bgcolor="#FFFFFF" ><div align="right" class="style53"><span class="style44"><u>Notes</u></span>&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="hidden" name="notes"  style="width:60px;" value="<?php echo $notes;?>"  /><?php echo $notes;?></div></td>
      </tr><?php }?>
    <tr >
      <td colspan="4" style="border-bottom:1px #000000 solid;border-top:1px #000000 solid" > <table width="100%" border="0" align="right" cellpadding="2" cellspacing="2">
        <tr>
          <td width="50%"><div align="right"><span class="style71"><strong>Total:-</strong></span></div></td>
          <td width="3%"><div align="center">:</div></td>
          <td width="29%">
	        <div align="right"><?php print $total;?>
	          /-</div></td>
          <td width="18%">&nbsp;</td>
        </tr>
		
      </table>	</td>
      </tr>
	
</table>
    <table width="100%" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td width="17%"><strong>Pay Months</strong></td>
    <td width="3%"><div align="center"><strong>-</strong></div></td>
    <td width="80%"><div style=" font-variant:small-caps;"><?php 
if($JANUARY=='Paid'){
echo 'jan-paid&nbsp;&nbsp;';
}
if($FEBRUARY=='Paid'){
echo 'feb-paid&nbsp;';
}
if($MARCH=='Paid'){
echo 'Mar-paid&nbsp;&nbsp;';
}
if($APRIL=='Paid'){
echo 'APR-paid&nbsp;&nbsp;';
}
if($MAY=='Paid'){
echo 'MAY-paid&nbsp;&nbsp;';
}
if($JUNE=='Paid'){
echo 'JUNE-paid&nbsp;&nbsp;';
}
if($JULY=='Paid'){
echo 'JULY-paid&nbsp;&nbsp;';
}
if($AUGUST=='Paid'){
echo 'AUG-paid&nbsp;&nbsp;';
}
if($SEPTEMBER=='Paid'){
echo 'SEP-paid&nbsp;&nbsp;';
}
if($OCTOBER=='Paid'){
echo 'OCTO-paid&nbsp;&nbsp;';
}
if($NOVEMBER=='Paid'){
echo 'NOVE-paid&nbsp;&nbsp;';
}
if($DECEMBER=='Paid'){
echo 'DEC-paid&nbsp;&nbsp;';
}
?></div></td>
  </tr>
  <tr>
    <td><strong>
      <?php if($vname=='Tempo'){?>
      Tempo Fees 
      <?php } ?>
      <?php if($vname=='Bus'){?>
      Bus Fees 
      <?php } ?>
    </strong></td>
    <td style=" font-variant:small-caps;"><div align="center"></div></td>
    <td style=" font-variant:small-caps;"><?php 
if($JANUARYv=='Paid'){
echo 'jan-paid&nbsp;&nbsp;';
}
if($FEBRUARYv=='Paid'){
echo 'feb-paid&nbsp;';
}
if($MARCHv=='Paid'){
echo 'Mar-paid&nbsp;&nbsp;';
}
if($APRILv=='Paid'){
echo 'APR-paid&nbsp;&nbsp;';
}
if($MAYv=='Paid'){
echo 'MAY-paid&nbsp;&nbsp;';
}
if($JUNEv=='Paid'){
echo 'JUNE-paid&nbsp;&nbsp;';
}
if($JULYv=='Paid'){
echo 'JULY-paid&nbsp;&nbsp;';
}
if($AUGUSTv=='Paid'){
echo 'AUG-paid&nbsp;&nbsp;';
}
if($SEPTEMBERv=='Paid'){
echo 'SEP-paid&nbsp;&nbsp;';
}
if($OCTOBERv=='Paid'){
echo 'OCTO-paid&nbsp;&nbsp;';
}
if($NOVEMBERv=='Paid'){
echo 'NOVE-paid&nbsp;&nbsp;';
}
if($DECEMBERv=='Paid'){
echo 'DEC-paid&nbsp;&nbsp;';
}
?></td>
  </tr>
</table>
</tr></table>


</td>
  </table>     
	      
<?php } else {?>
<a href="salary_payment_en.php?en=<?php echo $en;?>"><h2 align="center" style="color:#F00">Please Select Correct Month</h2></a>

<?php }


?> 
<?php 
//include "footer.php"; ?>