<?php 
if(isset($_SESSION['msg'])){?>
	<div class="alert alert-info">                
	<h4>Info!</h4>
	<?php echo $_SESSION['msg']; unset($_SESSION['msg']); ?>
</div> 
<?php }?> 
<style>
.table thead th {
    vertical-align: bottom;
    white-space: nowrap;
}
.table tbody td {
    vertical-align: bottom;
    white-space: nowrap;
}
.uneditable-input, input, textarea {
    width: 100px !important;
}
</style>    
<div class="row-fluid" >
    <div class="span12">    
    	<div class="head clearfix"><h1>UPDATE RSP TRAVELLING EXP.</h1></div>
        
        <div class="block-fluid">
            <div style="overflow-x:auto;">
                <form method="post" enctype="multipart/form-data">
                    <table cellpadding="0" cellspacing="0" width="100%" class="table" id="example">
                    <thead>
                        <tr>
                            <th>S.No.</th>
                            <th>Emp Code</th>
                            <th>Emp Name</th>
                            <th>Fat. Name</th>
                            <th>Designation</th>
                            <th>State</th>                        
                            <th>Aadhar No.</th>                        
                            <th>Travelling Exp.</th>
                        </tr>
                    </thead>                 
                    <tbody>
                        <?php
                        $i=1;
                        $menu		= mysql_query("SELECT * FROM `tbl_emp_rsp` where `status`='0' order by `emp_name` asc ")or die(mysql_error());
                        while($show_menu = mysql_fetch_array($menu)) 
                        {
                            $a			 = "<img height='20' width='20' src='images/right.png'/>";
                            $b			 = "<img height='20' width='20' src='images/wrong.png'/>";
                            $payment_status	 = $b;
                            if($show_menu['payment_status']=='complete')
                            {
                                $payment_status	= $a;
                            }
                            $uan_status	 = $b;
                            if($show_menu['uan_status']=='Done')
                            {
                                $uan_status	= $a;
                            }
                            
                        ?>	
                            <tr>
                            <td><?php echo $i++; ?></td>
                            <td><?php echo ucwords($show_menu['emp_code']);?></td>
                            <td><?php echo ucwords($show_menu['emp_name']); ?></td>
                            <td><?php echo ucwords($show_menu['fname']); ?></td>
                            <td><?php echo ucwords($show_menu['desiganation']); ?></td>
                            <td><?php echo ucwords($show_menu['state']); ?></td>
                            <td><?php echo ucwords($show_menu['aadhar_no']); ?></td>                           
                            <td class="center" style="text-align:center"><input name="empId[]" type="hidden" value="<?php echo $show_menu['id'];?>"><input name="expAmount[]" type="text" value="<?php echo $show_menu['travel_exp'];?>" placeholder="Travelling Exp." required/></td>
                        </tr>
                        <?php }?>               	                
                    </tbody>            
                </table>
                <hr>
                <p style="margin:0 15px 10px;">Press <b>Submit</b> to see form data that would be submitted to the server.</p>            
                <p style="margin:0 15px 10px;"><button type="submit" name="save">Submit</button></p>                        
                </form>
            </div> 
        </div>    
   </div>
</div> 

<?php
if(isset($_POST['save']))
{
	$index = 0;
	$arrayEmpId     = $_POST['empId'];
	$arrayExpAmount = $_POST['expAmount'];
	foreach($arrayEmpId as $aEId)
	{
		mysql_query("update `tbl_emp_rsp` SET `travel_exp`='".$arrayExpAmount[$index]."' where `id`='".$aEId."'");
		$index++;
	}
	$_SESSION['msg'] ="Travelling Expenses Updated Successfully.";
	header("location:home.php?page=updateTravellingExp"); 
}
?>
<script>
function confirm_delete(row_num,delete_id)
{
	if (confirm("Delete Account?"))
	{		
	  return true;
	}
	else
	{
		return false;
	}
}  
$(document).ready(function() {
    var table = $('#example').DataTable( {
		"order": [[ 2, "asc" ]],
		"pageLength": 100,stateSave: true,
        fixedHeader: {
            header: true,
            footer: true
        }
    } );
	 table.on( 'order.dt search.dt', function () {
        table.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
            cell.innerHTML = i+1;
        } );
    }).draw(); 
});
</script>


   
