<link rel="stylesheet" type="text/css" href="css/table_frize_1.css">
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
 
<h1><?php echo $s->GetFieldValue('modules_form','id="'.$_REQUEST['frmid'].'"','description');?></h1>
<?php
	if(isset($_POST['Save']))
{ 
	for($i=0;$i<count($_REQUEST['amount']);$i++)
		   {
		   	if($_REQUEST['hid_id'][$i]!=''){
	        $dataArr['amount']=$_REQUEST['amount'][$i];
	        $condd="id='".$_REQUEST['hid_id'][$i]."'";
	        $s->RecordEdit('monthly_other_deducation_details',$dataArr,$condd);	
	       }else{
	       	if($_REQUEST['amount'][$i]!=''){
	       	$data['parentid']=$_REQUEST['id'];
			$data['other_ded']=$_REQUEST['hid_other_ded'][$i];
			$data['other_ded_type']=$_REQUEST['hid_other_ded_type'][$i];						
			$data['amount']=$_REQUEST['amount'][$i];
			$s->RecordInsert('monthly_other_deducation_details',$data);
		    }
	       }
	       }
	    $s->pageLocation("index.php?route=HRModule/view_monthely_other_ded_index".$rurl);
}
  $sql=DB_query("select empid,site,month,year from monthly_other_deducation where id='".$_REQUEST['id']."'",$db);
  $row=DB_fetch_array($sql);
?>
<form action="" method="post">
	<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr class="row1">
    <td width="13%" align="right"><strong>Site :</strong></td>
    <td width="28%"><?php echo $s->getField('locations','loccode',$row['site'],'locationname');?></td>
    <td width="13%" align="right"><strong>Month :</strong></td>
    <td width="28%"><?php $arr=array(1=>"Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec"); echo $arr[$row['month']]; ?></td>
    <td width="13%" align="right"><strong>Year :</strong></td>
    <td><?php echo $row['year'];?></td>
  </tr>
</table>
</form>	
<br>
<form action="" method="post" name="myform">
<input type="hidden" name="sitedata" value="<?php echo $_REQUEST['site'];?>" />
<input type="hidden" name="month_other" value="<?php echo $_REQUEST['paymonth']; ?>" />
	<input  type="hidden" name="year_other" value="<?php echo $_REQUEST['payyear']; ?>" />
<table width="100%" border="0" cellpadding="3" cellspacing="0" class="thborder">
  <tr>
    <th width="10%" rowspan="2">Emp Code</th>
    <th rowspan="2">Emp Name</th>
	<?php $sql_otherd=DB_query("select * from other_deduction_master where type='D'",$db);
    $dcol=DB_num_rows($sql_otherd);
    if($dcol>0){
    ?>
    <th colspan="<?php echo $dcol;?>" style="text-align:center">Deduction</th>
    <?php 
	}
    $sql_othera=DB_query("select * from other_deduction_master where type='A'",$db);
    $acol=DB_num_rows($sql_othera);
    if($acol>0){
    ?>
    <th colspan="<?php echo $dcol;?>" style="text-align:center">Addition</th>
    <?php } ?>   
  </tr>
  <tr>
	<?php 	
	$sql_other=DB_query("select * from other_deduction_master where type='D'",$db);
	while($row_other=DB_fetch_array($sql_other))
	{	
   ?>
<th width="10%"><?php echo $row_other['name']; ?></th>
<?php } ?>
   <?php 	
	$sql_other=DB_query("select * from other_deduction_master where type='A'",$db);
	while($row_other=DB_fetch_array($sql_other))
	{	
   ?>
<th width="10%"><?php echo $row_other['name']; ?></th>
<?php } ?>   
  </tr>
    <?php 
    $emp_sql=DB_query("select id,emp_name,emp_code from empmaster where id='".$row['empid']."'",$db);
    $RowData=DB_fetch_array($emp_sql);
   ?>
<tr>
    <td><?php echo $RowData['emp_code'];?><input type="hidden" name="empid[]" value="<?php echo $RowData['id']; ?>" /></td>
	<!-- <td><?php //echo $RowData['AccountsType']; ?>	  </td>-->
	 <td><?php echo $RowData['emp_name'];?></td>
 	<?php  $sql_other=DB_query("select * from other_deduction_master where type='D'",$db);
	while($row_other=DB_fetch_array($sql_other))
	{
    $ded_sql=DB_fetch_array(DB_query("select B.id,B.amount from monthly_other_deducation AS A INNER JOIN monthly_other_deducation_details AS B ON A.id=B.parentid WHERE A.id='".$_REQUEST['id']."' AND B.other_ded='".$row_other['id']."'",$db));
	?>
	<td>
	<input type="hidden" name="hid_other_ded[]" value="<?php echo $row_other['id'];?>"/>
	<input type="hidden" name="hid_other_ded_type[]" value="<?php echo $row_other['type'];?>"/>
	<input type="hidden" name="hid_id[]" value="<?php echo $ded_sql['id']; ?>"/>
	<input type="text" name="amount[]" value="<?php echo $ded_sql['amount'];?>" style="width:98%;" />
	</td>
	<?php }?>
	<?php  $sql_other=DB_query("select * from other_deduction_master where type='A'",$db);
	while($row_other=DB_fetch_array($sql_other))
	{
    $ded_sql=DB_fetch_array(DB_query("select B.id,B.amount from monthly_other_deducation AS A INNER JOIN monthly_other_deducation_details AS B ON A.id=B.parentid WHERE A.id='".$_REQUEST['id']."' AND B.other_ded='".$row_other['id']."'",$db));
	?>
	<td><input type="hidden" name="hid_other_ded[]" value="<?php echo $row_other['id'];?>"/>
		<input type="hidden" name="hid_other_ded_type[]" value="<?php echo $row_other['type'];?>"/>
	<input type="hidden" name="hid_id[]" value="<?php echo $ded_sql['id']; ?>"/>
	<input type="text" name="amount[]" value="<?php echo $ded_sql['amount'];?>" style="width:98%;" />
	</td>
	<?php }?>
   
  </tr>
 </table>
<p align="center" style="text-align:center"><input type="submit" name="Save" value="Save" class="search" /></p>
</form>

</div>
</div>