 <?php
 if(isset($_REQUEST['submit']))
 {
    $emp_name               = ucwords(strtolower(mysql_real_escape_string($_POST['emp_name'])));
    $emp_name_alias         = mysql_real_escape_string($_POST['emp_name_alias']);
    $desiganation           = strtoupper(mysql_real_escape_string($_POST['desiganation']));
    $gender		            = mysql_real_escape_string($_POST['gender']);
    $head_qtrer	            = mysql_real_escape_string($_POST['head_qtrer']);
    $state		            = mysql_real_escape_string($_POST['state']);
    $state_qry				= mysql_query(" SELECT `state_code` FROM `state` WHERE `state_name`='$state' ");
    $state_data				= mysql_fetch_array($state_qry);

    $sql_code				= mysql_query(" SELECT `emp_code` FROM `tbl_emp_rsp` WHERE `emp_code`!='' and `state`='$state' order by `id` DESC ");
 	if(mysql_num_rows($sql_code)>0)
    {
        $data_code			= mysql_fetch_array($sql_code);
        $emp_code_arr		= explode("-",$data_code['emp_code']);

        $emp_code			= "RSP-".($emp_code_arr[1]+1);
    }
    else
    {
        $emp_code			= "RSP-"."1";
    }

    $tsi	            	= mysql_real_escape_string($_POST['tsi']);
    $tso		            = mysql_real_escape_string($_POST['tso']);
    $asm		            = mysql_real_escape_string($_POST['asm']);
    $st_head	            = mysql_real_escape_string($_POST['st_head']);
    $fnct_head	            = mysql_real_escape_string($_POST['fnct_head']);
    $dob		            = date("Y-m-d",strtotime($_POST['dob']));
    $mobil_no	            = mysql_real_escape_string($_POST['mobil_no']);
    $marital_st	            = mysql_real_escape_string($_POST['marital_st']);
    $fname		            = mysql_real_escape_string($_POST['fname']);
    $aadhar_no	            = mysql_real_escape_string($_POST['aadhar_no']);
    $uan_no					= mysql_real_escape_string($_POST['uan_no']);
    $bank_name	            = mysql_real_escape_string($_POST['bank_name']);
    $bank_name_alias        = mysql_real_escape_string($_POST['bank_name_alias']);
    $branch_name            = mysql_real_escape_string($_POST['branch_name']);
    $branch_city	        = mysql_real_escape_string($_POST['branch_city']);
    $branch_ifsc            = strtoupper(mysql_real_escape_string($_POST['branch_ifsc']));
    $account_no	            = mysql_real_escape_string($_POST['account_no']);
    $salary_rate            = mysql_real_escape_string($_POST['salary_rate']);
    $da_rate	            = mysql_real_escape_string($_POST['da_rate']);
    $oda_rate               = mysql_real_escape_string($_POST['oda_rate']);
    $phone_rate	            = mysql_real_escape_string($_POST['phone_rate']);
    $ta_rate				= mysql_real_escape_string($_POST['ta_rate']);
    $travel_exp				= mysql_real_escape_string($_POST['travel_exp']);
    $payment_status         = mysql_real_escape_string($_POST['payment_status']);
    $uan_status             = mysql_real_escape_string($_POST['uan_status']);
    $payment_status_2       = mysql_real_escape_string($_POST['payment_status_2']);
    $uan_status_2           = mysql_real_escape_string($_POST['uan_status_2']);

    $jul_sal            	= mysql_real_escape_string($_POST['jul_sal']);
    $jul_paid       	    = mysql_real_escape_string($_POST['jul_paid']);
    $jul_code    	        = mysql_real_escape_string($_POST['jul_code']);
    $jul_dis_name           = mysql_real_escape_string($_POST['jul_dis_name']);
    $jul_status	            = "Pendding";
    if(isset($_POST['jul_status']))
    {
     $jul_status	        = mysql_real_escape_string($_POST['jul_status']);
    }

    $aug_sal	            = mysql_real_escape_string($_POST['aug_sal']);
    $aug_paid	            = mysql_real_escape_string($_POST['aug_paid']);
    $aug_code	            = mysql_real_escape_string($_POST['aug_code']);
    $aug_dis_name           = mysql_real_escape_string($_POST['aug_dis_name']);
    $aug_status	            = "Pendding";
    if(isset($_POST['aug_status']))
    {
     $aug_status	        = mysql_real_escape_string($_POST['aug_status']);
    }

    $sept_sal	            = mysql_real_escape_string($_POST['sept_sal']);
    $sept_paid              = mysql_real_escape_string($_POST['sept_paid']);
    $sept_code              = mysql_real_escape_string($_POST['sept_code']);
    $sept_dis_name          = mysql_real_escape_string($_POST['sept_dis_name']);
    $sep_status	            = "Pendding";
    if(isset($_POST['sep_status']))
    {
     $sep_status	        = mysql_real_escape_string($_POST['sep_status']);
    }

    $oct_sal	            = mysql_real_escape_string($_POST['oct_sal']);
    $oct_paid               = mysql_real_escape_string($_POST['oct_paid']);
    $oct_code               = mysql_real_escape_string($_POST['oct_code']);
    $oct_dis_name           = mysql_real_escape_string($_POST['oct_dis_name']);
    $oct_status	            = "Pendding";
    if(isset($_POST['oct_status']))
    {
     $oct_status	        = mysql_real_escape_string($_POST['oct_status']);
    }
    $remark					= mysql_real_escape_string($_POST['remark']);
    $front_photo			= '';
    $back_photo				= '';
    $sql_img				= '';
    if(!empty($_FILES['front_photo']['name']))
    {
        $front_photo        = rand().$_FILES['front_photo']['name'];
        $sql_img			.= " , `front_photo`='$front_photo' ";
        move_uploaded_file($_FILES['front_photo']['tmp_name'],"page_image/".$front_photo);
    }
    if(!empty($_FILES['back_photo']['name']))
    {
        $back_photo         = rand().$_FILES['back_photo']['name'];
        if(!empty($sql_img))
        {
            $sql_img		.= " , ";
        }
        $sql_img			.= " `back_photo`='$back_photo' ";
        move_uploaded_file($_FILES['back_photo']['tmp_name'],"page_image/".$back_photo);
    }
    if($_SESSION['userid']==4)
    {
        $sql_img		 .= ", `jul_status`='$jul_status', `aug_status`='$aug_status', `sep_status`='$sep_status' ";
    }
    mysql_query("insert into `tbl_emp_records` set `emp_code`='$emp_code', `emp_name`='$emp_name', `emp_name_alias`='$emp_name_alias', `desiganation`='$desiganation', `gender`='$gender', `head_qtrer`='$head_qtrer', `state`='$state', `tsi`='$tsi', `tso`='$tso', `asm`='$asm', `st_head`='$st_head', `fnct_head`='$fnct_head', `dob`='$dob', `mobil_no`='$mobil_no', `marital_st`='$marital_st', `fname`='$fname', `aadhar_no`='$aadhar_no', `uan_no`='$uan_no' ,`bank_name`='$bank_name', `bank_name_alias`='$bank_name_alias', `branch_name`='$branch_name', `branch_city`='$branch_city', `branch_ifsc`='$branch_ifsc', `account_no`='$account_no', `salary_rate`='$salary_rate', `da_rate`='$da_rate', `oda_rate`='".$oda_rate."', `phone_rate`='$phone_rate',`ta_rate`='$ta_rate',`travel_exp`='$travel_exp',`jul_sal`='$jul_sal', `jul_paid`='$jul_paid', `jul_code`='$jul_code', `jul_dis_name`='$jul_dis_name', `aug_sal`='$aug_sal', `aug_paid`='$aug_paid', `aug_code`='$aug_code', `aug_dis_name`='$aug_dis_name', `sept_sal`='$sept_sal', `sept_paid`='$sept_paid', `sept_code`='$sept_code', `sept_dis_name`='$sept_dis_name',`oct_sal`='$oct_sal',`oct_paid`='$oct_paid',`oct_code`='$oct_code',`oct_dis_name`='$oct_dis_name',`oct_status`='$oct_status',`remark`='$remark',`payment_status`='$payment_status', `uan_status`='$uan_status',`payment_status_2`='$payment_status_2', `uan_status_2`='$uan_status_2' $sql_img  ")or die(mysql_error());
     $_SESSION['msg'] = 'Employee Added Sucessfully!!';
     header("location:home.php?page=page");
 }
 if(isset($_REQUEST['update']))
 {
    $id                     = $_POST['id'];
    $emp_name               = ucwords(strtolower(mysql_real_escape_string($_POST['emp_name'])));
    $emp_name_alias         = mysql_real_escape_string($_POST['emp_name_alias']);
    $desiganation           = strtoupper(mysql_real_escape_string($_POST['desiganation']));
    $gender		            = mysql_real_escape_string($_POST['gender']);
    $head_qtrer	            = mysql_real_escape_string($_POST['head_qtrer']);
    $state		            = mysql_real_escape_string($_POST['state']);
    $tsi	            	= mysql_real_escape_string($_POST['tsi']);
    $tso		            = mysql_real_escape_string($_POST['tso']);
    $asm		            = mysql_real_escape_string($_POST['asm']);
    $st_head	            = mysql_real_escape_string($_POST['st_head']);
    $fnct_head	            = mysql_real_escape_string($_POST['fnct_head']);
    $dob		            = date("Y-m-d",strtotime($_POST['dob']));
    $mobil_no	            = mysql_real_escape_string($_POST['mobil_no']);
    $marital_st	            = mysql_real_escape_string($_POST['marital_st']);
    $fname		            = mysql_real_escape_string($_POST['fname']);
    $aadhar_no	            = mysql_real_escape_string($_POST['aadhar_no']);
    $uan_no					= mysql_real_escape_string($_POST['uan_no']);
    $bank_name	            = mysql_real_escape_string($_POST['bank_name']);
    $bank_name_alias        = mysql_real_escape_string($_POST['bank_name_alias']);
    $branch_name            = mysql_real_escape_string($_POST['branch_name']);
    $branch_city	        = mysql_real_escape_string($_POST['branch_city']);
    $branch_ifsc            = strtoupper(mysql_real_escape_string($_POST['branch_ifsc']));
    $account_no	            = mysql_real_escape_string($_POST['account_no']);
    $salary_rate            = mysql_real_escape_string($_POST['salary_rate']);
    $da_rate	            = mysql_real_escape_string($_POST['da_rate']);
    $oda_rate               = mysql_real_escape_string($_POST['oda_rate']);
    $phone_rate	            = mysql_real_escape_string($_POST['phone_rate']);
    $ta_rate				= mysql_real_escape_string($_POST['ta_rate']);
    $travel_exp				= mysql_real_escape_string($_POST['travel_exp']);
    $payment_status         = mysql_real_escape_string($_POST['payment_status']);
    $old_payment_status     = mysql_real_escape_string($_POST['old_payment_status']);
    $uan_status             = mysql_real_escape_string($_POST['uan_status']);
    $payment_status_2       = mysql_real_escape_string($_POST['payment_status_2']);
    $uan_status_2           = mysql_real_escape_string($_POST['uan_status_2']);
    $old_uan_status         = mysql_real_escape_string($_POST['old_uan_status']);

    $jul_sal            	= mysql_real_escape_string($_POST['jul_sal']);
    $jul_paid       	    = mysql_real_escape_string($_POST['old_jul_paid']);
    if(isset($_POST['jul_paid']))
    {
        $jul_paid    	    = mysql_real_escape_string($_POST['jul_paid']);
    }
    $jul_code    	        = mysql_real_escape_string($_POST['jul_code']);
    $jul_dis_name           = mysql_real_escape_string($_POST['jul_dis_name']);
    $jul_status	            = mysql_real_escape_string($_POST['old_jul_status']);
    if(isset($_POST['jul_status']))
    {
     $jul_status	        = mysql_real_escape_string($_POST['jul_status']);
    }
    $aug_sal	            = mysql_real_escape_string($_POST['aug_sal']);
    $aug_paid	            = mysql_real_escape_string($_POST['old_aug_paid']);
    if(isset($_POST['aug_paid']))
    {
        $aug_paid    	    = mysql_real_escape_string($_POST['aug_paid']);
    }
    $aug_code	            = mysql_real_escape_string($_POST['aug_code']);
    $aug_dis_name           = mysql_real_escape_string($_POST['aug_dis_name']);
    $aug_status	            = mysql_real_escape_string($_POST['old_aug_status']);
    if(isset($_POST['aug_status']))
    {
     $aug_status	        = mysql_real_escape_string($_POST['aug_status']);
    }

    $sept_sal	            = mysql_real_escape_string($_POST['sept_sal']);
    $sept_paid              = mysql_real_escape_string($_POST['old_sept_paid']);
    if(isset($_POST['sept_paid']))
    {
        $sept_paid    	    = mysql_real_escape_string($_POST['sept_paid']);
    }
    $sept_code              = mysql_real_escape_string($_POST['sept_code']);
    $sept_dis_name          = mysql_real_escape_string($_POST['sept_dis_name']);
    $sep_status	            = mysql_real_escape_string($_POST['old_sep_status']);
    if(isset($_POST['sep_status']))
    {
     $sep_status	        = mysql_real_escape_string($_POST['sep_status']);
    }

    $oct_sal	            = mysql_real_escape_string($_POST['oct_sal']);
    $oct_paid               = mysql_real_escape_string($_POST['oct_paid']);
    $oct_code               = mysql_real_escape_string($_POST['oct_code']);
    $oct_dis_name           = mysql_real_escape_string($_POST['oct_dis_name']);
    $oct_status	            = "Pendding";
    if(isset($_POST['oct_status']))
    {
     $oct_status	        = mysql_real_escape_string($_POST['oct_status']);
    }
    $remark					= mysql_real_escape_string($_POST['remark']);
    if($uan_status !=$old_uan_status)
    {
        $sql_uan			= mysql_query(" insert into `tbl_check_status` set `login_id`='".$_SESSION['userid']."', `emp_id`='$id', `type`='UAN', `old`='$old_uan_status', `new`='$uan_status', `datetime`=NOW() ")or die(mysql_error());
    }
    if($payment_status !=$old_payment_status)
    {
        $sql_uan			= mysql_query(" insert into `tbl_check_status` set `login_id`='".$_SESSION['userid']."', `emp_id`='$id', `type`='PAYMENT', `old`='$old_payment_status', `new`='$payment_status', `datetime`=NOW() ")or die(mysql_error());
    }

    $front_photo			= '';
    $back_photo				= '';
    $sql_img				= '';
    if(!empty($_FILES['front_photo']['name']))
    {
        $front_photo        = rand().$_FILES['front_photo']['name'];
        $sql_img			.= " ,`front_photo`='$front_photo' ";
        move_uploaded_file($_FILES['front_photo']['tmp_name'],"page_image/".$front_photo);
    }

    if(!empty($_FILES['back_photo']['name']))
    {
        $back_photo         = rand().$_FILES['back_photo']['name'];
        $sql_img			.= ", `back_photo`='$back_photo' ";
        move_uploaded_file($_FILES['back_photo']['tmp_name'],"page_image/".$back_photo);
    }
    if($_SESSION['userid']==4)
    {
        $sql_img		 .= ", `jul_status`='$jul_status', `aug_status`='$aug_status', `sep_status`='$sep_status' ";
    }
    mysql_query("update `tbl_emp_records` set `emp_name`='$emp_name', `emp_name_alias`='$emp_name_alias', `desiganation`='$desiganation', `gender`='$gender', `head_qtrer`='$head_qtrer', `state`='$state', `tsi`='$tsi', `tso`='$tso', `asm`='$asm', `st_head`='$st_head', `fnct_head`='$fnct_head', `dob`='$dob', `mobil_no`='$mobil_no', `marital_st`='$marital_st', `fname`='$fname', `aadhar_no`='$aadhar_no', `uan_no`='$uan_no', `bank_name`='$bank_name', `bank_name_alias`='$bank_name_alias', `branch_name`='$branch_name', `branch_city`='$branch_city', `branch_ifsc`='$branch_ifsc', `account_no`='$account_no', `salary_rate`='$salary_rate', `da_rate`='$da_rate', `oda_rate`='".$oda_rate."', `phone_rate`='$phone_rate',`ta_rate`='$ta_rate',`travel_exp`='$travel_exp',`jul_sal`='$jul_sal', `jul_paid`='$jul_paid', `jul_code`='$jul_code', `jul_dis_name`='$jul_dis_name', `aug_sal`='$aug_sal', `aug_paid`='$aug_paid', `aug_code`='$aug_code', `aug_dis_name`='$aug_dis_name', `sept_sal`='$sept_sal', `sept_paid`='$sept_paid', `sept_code`='$sept_code', `sept_dis_name`='$sept_dis_name',`oct_sal`='$oct_sal',`oct_paid`='$oct_paid',`oct_code`='$oct_code',`oct_dis_name`='$oct_dis_name',`oct_status`='$oct_status',`remark`='$remark',`payment_status`='$payment_status', `uan_status`='$uan_status',`payment_status_2`='$payment_status_2', `uan_status_2`='$uan_status_2' $sql_img where `id`='$id'") or die(mysql_error());
    $_SESSION['msg'] = 'Employee Details Updated Sucessfully!!';
     header("location:home.php?page=page");
 }

if(isset($_GET['rspId']))
{
   $id            =       $_REQUEST['rspId'];
   $modify_menu   =       mysql_query("SELECT * FROM `tbl_emp_rsp` WHERE `id` = '$id'");
   $show_modify   =       mysql_fetch_array($modify_menu);
}
?>
<div class="row-fluid" >
    <div class="span12">
        <div class="head clearfix">
            <div class="isw-ok"></div>
            <h1><?php if(isset($_REQUEST['rspId'])) { echo "Edit";}else {echo "Add";}?> RSP</h1>
            <h1 style="float: right; margin-right: 10px;"><a href="home.php?page=rspList" style="color:#FFF;">RSP LIST</a></h1>
        </div>
        
        <div class="block-fluid">
            <form id="employee_frm" class="form-horizontal" action="" method="post" enctype="multipart/form-data">
				<fieldset>              	
                    <input type="hidden" name="id" id="id" placeholder="Page Name" <?php if(isset($_REQUEST['rspId'])){?> required value="<?php echo $show_modify['id'];  ?>"<?php } else  {?>value="0"<?php } ?> autocomplete="off" />
                    <input type="hidden" name="emp_code" id="emp_code" <?php if(isset($_REQUEST['rspId'])){?> required value="<?php echo $show_modify['emp_code'];  ?>"<?php } else  {?>value="0"<?php } ?> autocomplete="off" />
                     <div class="row-form clearfix">
                        <div class="span12">
                        	<p>
                        	    <span style="color:red;text-align:center;">* Please Fill All Mandatory Fields</span><br>
                                <span style="color:red;font-size:16px;" id="id_error"></span>
                            </p>
                        </div>
                     </div>
                     
					<div class="row-form clearfix">
                        <div class="span3">
                            <label>Employee Name <span style="color:red;text-align:center">*</span></label>
                            <input type="text" name="emp_name" placeholder="Employee Name" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['emp_name'];  ?>"<?php } ?> <?php if( isset($show_modify['uan_status'])&&($show_modify['uan_status']=='Done')){echo "readonly='readonly'"; }?> autocomplete="off" id="emp_name" onkeyup="capital_letter('emp_name');" required/>
                        </div>
                        
                        <div class="span3">
                            <label>Employee Name Alias</label>
                            <input type="text" name="emp_name_alias" placeholder="Employee Name Alias" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['emp_name_alias'];  ?>"<?php } ?> id="emp_name_alias" onkeyup="capital_letter('emp_name_alias');" required/>
                        </div>
                        
                        <div class="span3">
                            <label>Designation</label>
                            <input type="text" name="desiganation" autocomplete="off" required placeholder="Designation" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['desiganation'];?>"<?php } ?> id="desiganation" onkeyup="capital_letter('desiganation');"/>
                        </div>                                                
					</div>
                    
					<div class="row-form clearfix">
                        <div class="span3">
                            <label>Headquarter District</label>
                            <input type="text" name="head_qtrer" autocomplete="off" required placeholder="Headquarter District" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['head_qtrer'];?>"<?php } ?> id="head_qtrer"  onkeyup="capital_letter('head_qtrer');"/>
                        </div>
                        
                        <div class="span3">
                        	<label>State <span style="color:red;text-align:center;">*</span></label>
                            <select name="state" id="state" required>
                            <option value="">Select State</option>
                            <?php 
							$sql_st	= mysql_query("SELECT distinct `state` FROM `tbl_emp_rsp` ORDER BY `state` ASC ")or die(mysql_error());
							while($row_st= mysql_fetch_array($sql_st))
							{?>
								<option value="<?php echo $row_st['state'];?>" <?php if(isset($_GET['rspId'])&&($show_modify['state']==$row_st['state'])){ echo "selected";}?>><?php echo $row_st['state'];?></option>
							<?php }?>                                                        
                            </select>
                        </div>
                        
                        <div class="span3">
                        	<label>TSI</label>
                        	<input type="text" name="tsi" autocomplete="off" placeholder="TSI" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['tsi'];  ?>"<?php } ?> id="tsi" onkeyup="capital_letter('tsi');" required/>
                        </div>
                        
                        <div class="span3">
                        	<label>TSO</label>
                        	<input type="text" name="tso" autocomplete="off" required placeholder="TSO" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['tso'];?>"<?php } ?> id="tso" onkeyup="capital_letter('tso');"/>
                        </div>
                     </div>
                     
                     <div class="row-form clearfix">
                     	<div class="span3">
                        	<label>ASM</label>
                        	<input type="text" name="asm" autocomplete="off" required placeholder="ASM" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['asm'];?>"<?php } ?> id="asm" onkeyup="capital_letter('tso');"/>
                        </div>
                        
                        <div class="span3">
                        	<label>State Head</label>
                        	<input type="text" name="st_head" autocomplete="off" placeholder="State Head" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['st_head'];  ?>"<?php } ?> id="st_head" onkeyup="capital_letter('st_head');" required/>
                        </div>
                        
                        <div class="span3">
                        	<label>Functional Head</label>
                        	<input type="text" required autocomplete="off" name="fnct_head" placeholder="Functional Head" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['fnct_head'];  ?>"<?php } ?> id="fnct_head" onkeyup="capital_letter('fnct_head');"/>
                        </div>
                        
                        <div class="span3">
                        	<label>Date of Birth</label>
                        	<!--<input type="text" <?php if(isset($show_modify['uan_status'])&&($show_modify['uan_status']=='Done')){echo "readonly='readonly'"; }else {echo 'class="datetimepicker2"';}?> required autocomplete="off" name="dob" placeholder="Date of Birth" <?php if(isset($_REQUEST['rspId'])){?> value="<?php if( ($show_modify['dob']!='0000-00-00') &&($show_modify['dob']!='1970-01-01')&&($show_modify['dob']!='1969-12-31') ) {echo date("d-m-Y",strtotime($show_modify['dob']));}?>"<?php } ?> id="dob"/>-->
                            <input type="text" class="datetimepicker2" required autocomplete="off" name="dob" placeholder="Date of Birth" <?php if(isset($_REQUEST['rspId'])){?> value="<?php if( ($show_modify['dob']!='0000-00-00') &&($show_modify['dob']!='1970-01-01')&&($show_modify['dob']!='1969-12-31') ) {echo date("d-m-Y",strtotime($show_modify['dob']));}?>"<?php } ?> id="dob"/>
                        </div>
                     </div>
                     
                     <div class="row-form clearfix">
                     	<div class="span3">
                        	<label>Mobile No. <span style="color:red" style="text-align:center">*</span></label>
                        	<input type="text" required autocomplete="off" name="mobil_no" placeholder="Mobile" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['mobil_no'];?>"<?php } ?> onkeypress='return isNumberKey(event)' id="mobil_no" maxlength="10" onkeyup="capital_letter('mobil_no');"/>
                        </div>
                        
                        <div class="span3">
                        	<label>Gender</label>
                        	<input type="radio" <?php if(isset($show_modify['gender'])&&($show_modify['gender']=='Male')){echo "checked"; }?> class="gender" onclick="get_hus_fat();" name="gender" value="Male" />Male
                            <input type="radio" <?php if(isset($show_modify['gender'])&&($show_modify['gender']=='Female')){echo "checked"; }?> class="gender" name="gender" onclick="get_hus_fat();" value="Female" />Female
                            <br /><span style="color:red;" id="gender_err"></span>
                        </div>
                        
                        <div class="span3">
                        	<label>Marital Status</label>
                        	<select name="marital_st" onchange="get_hus_fat();" id="marital_st" required>
                            	<option value="">Select One</option>
                                <option value="MARRIED" <?php if(isset($show_modify['marital_st'])&&($show_modify['marital_st']=='MARRIED')){echo "selected"; }?>>MARRIED</option>
                                <option value="UN MARRIED" <?php if(isset($show_modify['marital_st'])&&($show_modify['marital_st']=='UN MARRIED')){echo "selected"; }?>>UN MARRIED</option>
                            </select>
                        </div>
                        
                        <div class="span3">
                        	<label id="fname_label">Father's<?php if(isset($show_modify['marital_st'])&&($show_modify['marital_st']=='UN MARRIED')&&($show_modify['gender']=='Female')){echo " /Husband's";}?> Name</label>
                        	<input type="text" <?php if( isset($show_modify['uan_status'])&&($show_modify['uan_status']=='Done')){echo "readonly='readonly'"; }?> autocomplete="off" required name="fname" placeholder="Father's/Huband Name" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['fname'];  ?>"<?php } ?> id="fname" onkeyup="capital_letter('fname');"/>
                        </div>
                     </div>
                     
                     <div class="row-form clearfix">                     	                        
                        <div class="span3">
                        	<label>Bank Name <span style="color:red;text-align:center">*</span></label>
                        	<input type="text" name="bank_name" autocomplete="off" placeholder="Bank Name" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['bank_name'];  ?>"<?php } ?> id="bank_name" required onkeyup="capital_letter('bank_name');"/>
                        </div> 
                        
                        <div class="span3">
                        	<label>Branch Name <span style="color:red;text-align:center">*</span></label>
                        	<input type="text" name="branch_name" autocomplete="off" placeholder="Branch Name" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['branch_name'];?>"<?php } ?> required id="branch_name" onkeyup="capital_letter('branch_name');"/>
                        </div>
                                                
                        <div class="span3">
                        	<label>Branch IFSC Code <span style="color:red;text-align:center">*</span></label>
                        	<input type="text" <?php if( isset($show_modify['payment_status'])&&($show_modify['payment_status']=='Complete')){echo "readonly='readonly'"; }?> name="branch_ifsc" autocomplete="off" placeholder="Branch IFSC Code" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['branch_ifsc'];  ?>"<?php } ?> required id="branch_ifsc" style="text-transform:uppercase;" maxlength="11"/>
                        </div>                                               
                     </div>
                                          
                     <div class="row-form clearfix">
                     	<div class="span3">
                        	<label>Account Nnumber <span style="color:red;text-align:center">*</span></label>
                        	<input type="text" name="account_no" autocomplete="off" placeholder="Account Nnumber" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['account_no'];  ?>"<?php } ?> <?php if( isset($show_modify['payment_status'])&&($show_modify['payment_status']=='Complete')){echo "readonly='readonly'"; }?> required id="account_no" onkeypress="return isNumberKey(event)"/>
                        </div>
                        
                        <div class="span3">
                        	<label>Confirm Account Nnumber <span style="color:red;text-align:center">*</span></label>
                        	<input type="text" name="re_account_no" autocomplete="off" placeholder="Re-Enter Account Nnumber" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['account_no'];  ?>"<?php } ?> required id="re_account_no" onkeypress="return isNumberKey(event)" <?php if( isset($show_modify['payment_status'])&&($show_modify['payment_status']=='Complete')){echo "readonly='readonly'"; }?>/>
                        </div>
                        
                        <div class="span3">
                        	<label>Aadhaar No. <span style="color:red;text-align:center;">*</span></label>
                        	<input type="text" name="aadhar_no" autocomplete="off" placeholder="Aadhaar No."onkeypress='return isNumberKey(event)' <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo str_replace('-','',$show_modify['aadhar_no']);  ?>"<?php } ?> id="aadhar_no" maxlength="12" <?php if( isset($show_modify['uan_status'])&&($show_modify['uan_status']=='Done')){echo "readonly='readonly'"; }?> required/>
                        </div>
                        
                        <div class="span3">
                        	<label>UAN NO.</label>
                        	<input type="text" name="uan_no" autocomplete="off" placeholder="UAN NO."onkeypress='return isNumberKey(event)' <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['uan_no'];  ?>"<?php } ?> id="uan_no" <?php if( isset($show_modify['uan_status'])&&($show_modify['uan_status']=='Done')){echo "readonly='readonly'"; }?> />
                        </div>                        
                     </div>
                     
                     <div class="row-form clearfix">
                        <div class="span3">
                        	<label>Monthly Payout <span style="color:red;text-align:center">*</span></label>
                        	<input type="text" name="salary_rate" autocomplete="off" placeholder="Monthly Payout" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['salary_rate'];  ?>"<?php } ?> required id="salary_rate" onkeypress="return isNumberKey(event)"/>
                        </div>
                        
                        <div class="span3">
                        	<label>Lodging Allowance(Per Working Day) <span style="color:red;text-align:center">*</span></label>
                        	<input type="text" name="da_rate" autocomplete="off" placeholder="Lodging Allowance(Per Working Day)" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['da_rate'];  ?>"<?php } ?> id="da_rate" required onkeypress="return isNumberKey(event)"/>
                        </div>
                        
                        <div class="span2">
                        	<label>ODA<span style="color:red;text-align:center">*</span></label>
                        	<input type="text" name="oda_rate" autocomplete="off" placeholder="ODA" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['oda_rate'];  ?>"<?php } ?> id="oda_rate" onkeypress="return isNumberKey(event)" required/>                           
                        </div>
                        
                        <div class="span2">
                        	<label>Monthly Wages<span style="color:red;text-align:center">*</span></label>
                        	<input type="text" name="phone_rate" autocomplete="off" placeholder="Monthly Wages" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['phone_rate'];  ?>"<?php } ?> id="phone_rate" onkeypress="return isNumberKey(event)" required/>                           
                        </div>
                        
                        <div class="span2">
                        	<label>HRA Rate <span style="color:red;text-align:center">*</span></label>
                        	<input type="text" name="ta_rate" autocomplete="off" placeholder="HRA Rate" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['ta_rate'];  ?>"<?php } ?> id="ta_rate" onkeypress="return isNumberKey(event)" required/>                            
                        </div>                        
					</div>
                    
					<div class="row-form clearfix">
                        <div class="span3">
                        	<label>Travelling Exp.( Per Month) <span style="color:red;text-align:center">*</span></label>
                        	<input type="text" name="travel_exp" autocomplete="off" placeholder="Travelling Exp.(Per Month)" <?php if(isset($_REQUEST['rspId'])){?>value="<?php echo $show_modify['travel_exp'];  ?>"<?php } ?> id="travel_exp" onkeypress="return isNumberKey(event)" required/>
                        </div>
                        
                        <div class="span3" <?php if($_SESSION['userid']!=4){?>style="display:none"<?php } ?>>
                        	<label>Payment Status</label>
                            <input type="hidden" name="old_payment_status" value="<?php if( isset($show_modify['payment_status'])){ echo $show_modify['payment_status']; }?>" />
                        	<select name="payment_status" id="payment_status" <?php if($_SESSION['userid']==4){?>required<?php } ?>>
                            	<option value="">Select One</option>
                                <option value="Pendding" <?php if( isset($show_modify['payment_status'])&&(($show_modify['payment_status']=='') ||($show_modify['payment_status']=='Pendding'))){echo "selected"; }?>>Pendding</option>
                                <option value="Complete" <?php if( isset($show_modify['payment_status'])&&($show_modify['payment_status']=='Complete')){echo "selected"; }?>>Complete</option>
                            </select>
                        </div>
                        
                        <div class="span3" <?php if($_SESSION['userid']!=4){?>style="display:none"<?php } ?>>
                        	<label>UAN Status</label>
                            <input type="hidden" name="old_uan_status" value="<?php if( isset($show_modify['uan_status'])){ echo $show_modify['uan_status']; }?>" />
                        	<select name="uan_status" id="uan_status" <?php if($_SESSION['userid']==4){?>required<?php } ?>>
                            	<option value="">Select One</option>
                                <option value="Not Done" <?php if( isset($show_modify['uan_status'])&&(($show_modify['uan_status']=='') ||($show_modify['uan_status']=='Not Done'))){echo "selected"; }?>>Not Done</option>
                                <option value="Done" <?php if(isset($show_modify['uan_status'])&&($show_modify['uan_status']=='Done')){echo "selected"; }?>>Done</option>
                            </select>
                        </div>
                     </div>
                     <div class="row-form clearfix">                        
                        <?php
                        if( (isset($show_modify['uan_status'])&&(($show_modify['uan_status']=='')||($show_modify['uan_status']=='Not Done')))||(!isset($_REQUEST['rspId'])) )
                        {?>
                        <div class="span3">
                        	<label>Adhar Card Front Photo</label>
                        	<input type="file" name="front_photo"/>
                             <?php if(!empty($show_modify['front_photo'])){?>
                            <span>
                           		 <img src="page_image/<?php echo $show_modify['front_photo'];?>" style="width: 54%; margin-top:5px;padding: 2px 17px 3px 0px;"/>

                            </span>
                            <?php } ?>
                        </div>
                        <div class="span3">
                        	<label>Adhar Card Back Photo</label>
                        	<input type="file" name="back_photo"/>
                             <?php if(!empty($show_modify['back_photo'])){?>
                            <span >
                           		 <img src="page_image/<?php echo $show_modify['back_photo'];?>" style="width: 54%; margin-top:5px;padding: 2px 17px 3px 0px;"/>

                            </span>
                            <?php } ?>
                        </div>
                        <?php } ?>
                     </div>
                     
                     <div class="row-form clearfix">
                    <div class="span12">
                    	<label>Remark</label>
                        <textarea name="remark" id="remark" onkeyup="capital_letter('remark');" ><?php if(isset($_REQUEST['rspId'])){echo $show_modify['remark'];}?></textarea>
                    </div>
                </div>
                <div class="row-form clearfix">
                    <div class="span3">&nbsp;</div>
                    <div class="span2"><input type="submit" name="<?php if(isset($_REQUEST['rspId'])){echo "update"; }else{ echo "submit";}?>" class="panel_setting btn btn-block" value="<?php if(isset($_REQUEST['rspId'])){ echo "Update"; }else{ echo "Save";}?>"/></div>
                </div>
              </fieldset>
            </form>
        </div>
    </div>
</div>
<script>
///Change Panel Setting
$(".panel_setting").click(function(event) {
    var id       	  = $("#id").val();
    var emp_name      = $("#emp_name").val();
    var state         = $("#state").val();
    var mobil_no      = $("#mobil_no").val();
    var bank_name     = $("#bank_name").val();
    var branch_ifsc   = $("#branch_ifsc").val();
    var cs 			  = branch_ifsc.length;
    var no_5		  = branch_ifsc.substring(4,5);
    var account_no 	  = $("#account_no").val();
    var re_account_no = $("#re_account_no").val();

    var salary_rate   = $("#salary_rate").val();
    var da_rate       = $("#da_rate").val();
    var phone_rate    = $("#phone_rate").val();
    var ta_rate       = $("#ta_rate").val();
    var travel_exp    = $("#travel_exp").val();

    $("#id_error").html("");

    if(emp_name =='')
    {
     	$("#id_error").html("Please enter employee name.");
    }
    else if(state =='')
    {
     	$("#id_error").html("Please select state name.");
    }
    else if(mobil_no =='')
    {
     	$("#id_error").html("Please mobile number.");
    }
    else if($('input[name=gender]:checked').length<=0)
    {
     	$("#id_error").html("Please select gender.");
    }
    else if(bank_name =='')
    {
     	$("#id_error").html("Please enter bank name.");
    }
    else if(cs<11)
    {
        $("#id_error").html("Please enter branch IFSC code minimum 11 ");
    }
    else if(no_5!=0)
    {
        $("#id_error").html("Please Enter Right Ifsc Code ");
    }
    else if(account_no =='')
    {
     	$("#id_error").html("Please enter account number");
    }
    else if(re_account_no =='')
    {
     	$("#id_error").html("Please enter Confirm account number");
    }
    else if(re_account_no !=account_no)
    {
     	$("#id_error").html("Account not matched ");
    }
    else if( (salary_rate =='') || (da_rate =='') || (phone_rate =='') || (ta_rate =='') || (travel_exp =='') )
    {
        $("#id_error").html("Please enter Monthly Payout, DA Rate (per Working Day), Phone Rate (per Working Day), TA Rate (per Working Day), Travelling Exp.(per month) ");
    }
    else
    {
    	var data = $("#employee_frm").serialize();
        $.ajax({
            url: "ajax/get_check_account_no2.php?id="+id,
            type: "get", //send it through get method
            data: data,
            success: function(res){
               if(res ==0)
               {
                   $("#id_error").html(" Your details successfully updated !!!");
                   $("#id_error").css("color","green");
                   setTimeout(function() { location.href = "home.php?page=rspList";  }, 3000);
               }
               else if(res ==1)
               {
                   $("#id_error").html("Successfully saved ");
                   $("#id_error").css("color","green");
                   $("#employee_frm").trigger("reset");
               }
               else if(res ==2)
               {
                   $("#id_error").html("Aadhar number already exists !! ");
               }
               else if(res ==3)
               {
                  $("#id_error").html("Account number already exists !! ");
               }
            }

        });
    }
    $("html, body").animate({ scrollTop: 0 }, "slow");
    event.preventDefault();
});
function isNumberKey(evt){
    var charCode = (evt.which) ? evt.which : evt.keyCode;
    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;
    return true;
}
function capital_letter(id)
{
    var arr 		  = $('#'+id).val().split(' ');
    var result 		  = "";
    for (var x=0; x<arr.length; x++)
        result+=arr[x].substring(0,1).toUpperCase()+arr[x].substring(1)+' ';
    $('#'+id).val(result.substring(0, result.length-1));
}
function get_hus_fat()
{
    var marital_st = $('#marital_st').val();
    var radioValue = $("input[name='gender']:checked").val();
    if(marital_st=='')
    {
       alert("Please Select Marital Status !!!!");
    }
    if(radioValue=='')
    {
       alert("Please Select Gender !!!!");
    }
    if( (marital_st=='MARRIED') && (radioValue=='Female'))
    {
     	document.getElementById("fname_label").innerHTML="Husband's Name";
    }
    else if( (marital_st=='UN MARRIED') && (radioValue=='Female'))
    {
        document.getElementById("fname_label").innerHTML="Father's Name";
    }
    else if( radioValue=='Male')
    {
        document.getElementById("fname_label").innerHTML="Father's Name";
    }
}
function get_month_test(val_val,month_name)
{
    if(val_val=='Distributer')
    {
        $("."+month_name+"_id").css("display","block");
    }
    else
    {
        $("."+month_name+"_id").css("display","none");
    }
}
function get_emp_code()
{
    var emp_code   = $("#emp_code").val();
    if (emp_code == '') {
        alert("Please Enter Employee Code !!!");
        return;
    } else {
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                alert(xmlhttp.responseText)
                if(xmlhttp.responseText==0)
                {
                    return true;
                }
                else
                {
                    alert("Employee Code Already Exists !!!!!!");
                    $("#emp_code").focus();
                    return false;
                }
            }
        }
        xmlhttp.open("GET","ajax/gte_chk_emp_code.php?emp_code="+emp_code,true);
        xmlhttp.send();
    ///	return false;
    }
}
</script>