<?php
include "../../pidbco/pidbjoin.php";

if(!isset($_SESSION))
{
    session_start();
}

//fetching Client IP address
function get_client_ip()
{
    $ipaddress = '';
    if (getenv('HTTP_CLIENT_IP'))
        $ipaddress = getenv('HTTP_CLIENT_IP');
    else if(getenv('HTTP_X_FORWARDED_FOR'))
        $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
    else if(getenv('HTTP_X_FORWARDED'))
        $ipaddress = getenv('HTTP_X_FORWARDED');
    else if(getenv('HTTP_FORWARDED_FOR'))
        $ipaddress = getenv('HTTP_FORWARDED_FOR');
    else if(getenv('HTTP_FORWARDED'))
        $ipaddress = getenv('HTTP_FORWARDED');
    else if(getenv('REMOTE_ADDR'))
        $ipaddress = getenv('REMOTE_ADDR');
    else
        $ipaddress = 'UNKNOWN';
    return $ipaddress;
}
$ip=get_client_ip();

?>
<!-- select2 -->
<script src="../components/js/select/select2.full.js"></script>
<script>
    $(document).ready(function () {
        $(".country").select2({
            placeholder: "Select a Country",
            allowClear: true
        });
        $(".state").select2({
            placeholder: "Select a State",
            allowClear: true
        });
        $(".district").select2({
            placeholder: "Select a District",
            allowClear: true
        });
        $(".department").select2({
            placeholder: "Select a Department",
            allowClear: true
        });
        $(".designation").select2({
            placeholder: "Select a Designation",
            allowClear: true
        });
    });
</script>
<!-- /select2 -->


    <script type="text/javascript">
        $(document).ready(function () {
            $('#join_date').daterangepicker({
                singleDatePicker: true,
                calender_style: "picker_4"
            }, function (start, end, label) {
                console.log(start.toISOString(), end.toISOString(), label);
            });
        });
    </script>
<?php

if(isset($_POST['btn_add_emp_data']))
{
    $emp_name = strip_tags(trim($_POST['emp_name']));
    $email = strip_tags(trim($_POST['email']));
    if($_POST['phone'] != "")
    {
        $phone = strip_tags(trim($_POST['phone']));
    }
    else
    {
        $phone = '';
    }
    if($_POST['phone2'] != "")
    {
        $phone2 = strip_tags(trim($_POST['phone2']));
    }
    else
    {
        $phone2 = '';
    }

    $add1 = strip_tags(trim($_POST['add1']));
    $add2 = strip_tags(trim($_POST['add2']));
    $post = strip_tags(trim($_POST['post']));
    $pin = strip_tags(trim($_POST['pin']));
    $country = strip_tags(trim($_POST['country']));
    $state = strip_tags(trim($_POST['state']));
    $district = strip_tags(trim($_POST['district']));
    $loc = strip_tags(trim($_POST['loc']));
    $username = strip_tags(trim($_POST['username']));
    $password = strip_tags(trim($_POST['password']));
    $qualification = strip_tags(trim($_POST['qualification']));
    $join_date = strip_tags(trim($_POST['join_date']));
    $salary = strip_tags(trim($_POST['salary']));
    $department = strip_tags(trim($_POST['department']));
    $designation = strip_tags(trim($_POST['designation']));
    $status = strip_tags(trim($_POST['status']));

    $today = date('Y-m-d');
    $tme = date('H:m:s');

    if(!empty($_SESSION['city']))
    {
        $loc2 = $_SESSION['city'];
    }
    else
    {
        $loc2 = "";
    }
    $photo="";

    $stmt3 = $con->prepare("SELECT emp_name,username FROM employee_registration WHERE emp_name=? OR username=?");
    $stmt3 -> bind_param("ss",$emp_name,$username);
    $stmt3 -> execute();
    $stmt3 -> store_result();
    $num = $stmt3 -> num_rows;

    $stmt4 = $con->prepare("Select mob1 FROM employee_registration WHERE mob1 = ? OR mob2 = ? ");
    $stmt4 -> bind_param("ss",$phone,$phone);
    $stmt4 -> execute();
    $stmt4 -> store_result();
    $num1 = $stmt4 -> num_rows;

    if($phone2 != "")
    {
        $stmt5 = $con->prepare("Select mob2 FROM employee_registration WHERE mob1 = ? OR mob2 = ? ");
        $stmt5 -> bind_param("ss",$phone2,$phone2);
        $stmt5 -> execute();
        $stmt5 -> store_result();
        $num2 = $stmt5 -> num_rows;
    }

    if($num > 0 || $num1 >0 || $num2 >0)
    {
        if($num > 0)
        {
            ?><script>alert("Error! Name Or Username Exist");</script><?php
        }
        if($num1 > 0)
        {
            ?><script>alert("Error! Phone number One Exist");</script><?php
        }
        if($num2 > 0)
        {
            ?><script>alert("Error! Phone number Two Exist");</script><?php
        }

    }
    else
    {

        if(!empty($emp_name) && !empty($phone) && !empty($add1) && !empty($post) && !empty($pin) && !empty($loc) && !empty($username) && !empty($password) && !empty($join_date) && !empty($salary) && !empty($department) && !empty($designation))
        {

            $stmt = $con->prepare("INSERT INTO employee_registration(reg_date, entered_ip, emp_name, email, mob1, mob2, address_line1, address_line2, post, pin, country, state, district, location, photo, username, qualification, joined_date, salary, department, designation, status) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
            $stmt->bind_param("ssssssssssssssssssissi",$today,$ip,$emp_name,$email,$phone,$phone2,$add1,$add2,$post,$pin,$country,$state,$district,$loc,$photo,$username,$qualification,$join_date,$salary,$department,$designation,$status);
            $stmt->execute();
            $stmt->store_result();
            $last_id = $stmt->insert_id;
            $ok = $stmt->affected_rows;
            if($ok > 0)
            {
                $st=1;$per="";$pass=sha1($password);
                $stmt2 = $con->prepare("INSERT INTO pi_log_data(staff_id, user_name, pass, permission, status) VALUES (?,?,?,?,?)");
                $stmt2 -> bind_param("ssssi",$last_id,$username,$pass,$per,$st);
                $stmt2->execute();

                /*?><script>alert("Added.");</script><?php*/

                ?>
                <script>
                    $('#emp_name').val('');
                    $('#phone').val('');
                    $('#add1').val('');
                    $('#post').val('');
                    $('#pin').val('');
                    $('#loc').val('');
                    $('#username').val('');
                    $('#password').val('');
                    $('#join_date').val('');
                    $('#salary').val('');
                    $('#department').val('');
                    $('#designation').val('');
                    $('#status').val('');
                    $('#email').val('');
                    $('#phone2').val('');
                    $('#add2').val('');
                    $('#country').val('');
                    $('#state').val('');
                    $('#district').val('');
                    $('#qualification').val('');
                    show_emp_data();
                </script>
            <?php
            }
            $stmt->close();
            $stmt2->close();
        }
        else
        {
            ?>
            <script>
                alert('Error..!');
            </script>
        <?php
        }

    }

    $stmt3->close();
    $stmt4->close();
exit();

}
if(isset($_POST['btn_show_emp_data']))
{
?>
    <script>
        $(function()
        {

            $(".checkbox").click(function(){
                $('#delete').prop('disabled',$('input.checkbox:checked').length == 0);
            });

        });
    </script>

    <div class="dataTables_wrapper">
        <table class="table table-striped table-bordered table-hover table-responsive" id="dataTables-example">
            <thead>
            <tr>
                <th width="5%">#</th>
                <th>Name</th>
                <th>Mobile</th>
                <th>Department</th>
                <th>Designation</th>
                <th>Status</th>
            </tr>
            </thead>
            <tbody>
            <?php
            $stmt = mysqli_query($con,"SELECT * FROM employee_registration WHERE id != '1' ORDER BY id DESC ");
            $i=1;
            while($res = mysqli_fetch_object($stmt))
            {
                $st1 = mysqli_query($con,"SELECT * FROM `department_det` WHERE id='{$res->department}'");
                $result = mysqli_fetch_object($st1);

                $st2 = mysqli_query($con,"SELECT * FROM `designation_det` WHERE id='{$res->designation}'");
                $result2 = mysqli_fetch_object($st2);
                ?>
                <tr class="odd gradeX" data-toggle="modal"  style="cursor: pointer;">
                    <td width="5%"><input type="checkbox" class="checkbox"  id="<?php echo $res->id; ?>" style="cursor: pointer;" /></td>
                    <td onclick="edt_mem_data(<?php echo $res->id; ?>);" ><?php echo $res->emp_name; ?></td>
                    <td onclick="edt_mem_data(<?php echo $res->id; ?>);" ><?php echo $res->mob1; ?></td>
                    <td onclick="edt_mem_data(<?php echo $res->id; ?>);" ><?php echo $result->dep_name; ?></td>
                    <td onclick="edt_mem_data(<?php echo $res->id; ?>);" ><?php echo $result2->des_name; ?></td>
                    <td onclick="edt_mem_data(<?php echo $res->id; ?>);" class="center"><?php if($res->status == 1){ echo 'Active'; }else{ echo 'In-Active'; } ?></td>
                </tr>
                <?php
                $i++;
            }
            ?>
            </tbody>
        </table>
    </div>
<?php
    exit();
}
if(isset($_POST['btn_edt_mem_det']))
{

    $id = strip_tags(trim($_POST['id']));
    $stmt = $con->prepare("SELECT id, reg_date, emp_name, email, mob1, mob2, address_line1, address_line2, post, pin, country, state, district, location, photo, username, qualification, joined_date, salary, department, designation, status FROM employee_registration WHERE id = ?");
    $stmt -> bind_param("i",$id);
    $stmt -> execute();
    $stmt -> store_result();
    $stmt -> bind_result($id,$reg_date,$emp_name,$email,$mob1,$mob2,$address_line1,$address_line2,$post,$pin,$country,$state,$district,$location,$photo,$username,$qualification,$joined_date,$salary,$department,$designation,$status);
    $all_posts = Array();
    while($stmt->fetch())
    {
        $individual_post = Array(
            'id' => $id,
            'reg_date'      => $reg_date,
            'emp_name'      => $emp_name,
            'email'         => $email,
            'mob1'          => $mob1,
            'mob2'          => $mob2,
            'address_line1' => $address_line1,
            'address_line2' => $address_line2,
            'post'          => $post,
            'pin'           => $pin,
            'country'       => $country,
            'state'         => $state,
            'district'      => $district,
            'location'      => $location,
            'photo'         => $photo,
            'username'      => $username,
            'qualification' => $qualification,
            'joined_date'   => $joined_date,
            'salary'        => $salary,
            'department'    => $department,
            'designation'   => $designation,
            'status'        => $status
        );
        array_push($all_posts, $individual_post);
    }
    $stmt->close();

    $dep = $individual_post['department'];
    $dep_q = mysqli_query($con,"SELECT id,dep_name FROM department_det WHERE id='$dep'");
    $dep_q_fet = mysqli_fetch_object($dep_q);

    $des = $individual_post['designation'];
    $des_q = mysqli_query($con,"SELECT id,des_name FROM designation_det WHERE id='$des'");
    $des_q_fet = mysqli_fetch_object($des_q);
?>
    <form id="frm_1" name="frm_1" data-parsley-validate class="form-horizontal form-label-left">

        <div class="form-group">
            <div class="col-md-3 col-sm-3 col-xs-12">
                <input id="emp_name" class="form-control col-md-7 col-xs-12" value="<?php echo $individual_post['emp_name']; ?>" placeholder="Employee Name*" required="required"  type="text" name="emp_name" >
                <input type="hidden" name="ide" id="ide" value="<?php echo base64_encode($individual_post['id']);?>">
            </div>
            <div class="col-md-3 col-sm-3 col-xs-12">
                <input type="email" id="email" name="email" value="<?php echo $individual_post['email']; ?>" placeholder="Enter Email" class="form-control col-md-7 col-xs-12">
            </div>
            <div class="col-md-3 col-sm-3 col-xs-12">
                <input type="number" id="phone" name="phone" required="required" value="<?php echo $individual_post['mob1']; ?>" placeholder="Enter Mobile Number*"  min="0" class="form-control col-md-7 col-xs-12">
            </div>
            <div class="col-md-3 col-sm-3 col-xs-12">
                <input id="phone2" class="form-control col-md-7 col-xs-12" value="<?php if(!empty($individual_post['mob2'])){ echo $individual_post['mob2']; } ?>" placeholder="Enter Second Mobile Number"  type="number" min="0" name="phone2" >
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-3 col-sm-3 col-xs-12">
                <input id="add1" class="form-control col-md-7 col-xs-12" value="<?php if(!empty($individual_post['address_line1'])){ echo $individual_post['address_line1']; } ?>" placeholder="Address Line1*" required="required"  type="text" name="add1" >
            </div>
            <div class="col-md-3 col-sm-3 col-xs-12">
                <input id="add2" class="form-control col-md-7 col-xs-12" value="<?php if(!empty($individual_post['address_line2'])){ echo $individual_post['address_line2']; } ?>" placeholder="Address Line2*"   type="text" name="add2" >
            </div>
            <div class="col-md-3 col-sm-3 col-xs-12">
                <input type="text" id="post" name="post" required="required" value="<?php if(!empty($individual_post['post'])){ echo $individual_post['post']; } ?>" placeholder="Post*"   class="form-control col-md-7 col-xs-12">
            </div>
            <div class="col-md-3 col-sm-3 col-xs-12">
                <input id="pin" class="form-control col-md-7 col-xs-12" value="<?php if(!empty($individual_post['pin'])){ echo $individual_post['pin']; } ?>" placeholder="Enter Pin/Zip"  type="text"  name="pin" >
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-3 col-sm-3 col-xs-12">
                <select class="country form-control " id="country" tabindex="-1">
                    <option value="<?php if(!empty($individual_post['country'])){ echo $individual_post['country']; } ?>"><?php if(!empty($individual_post['country'])){ echo $individual_post['country']; } ?></option>
                    <?php
                    $stmt01 = mysqli_query($con,"SELECT * FROM `countries`  ORDER BY id ASC");
                    while($res01 = mysqli_fetch_object($stmt01))
                    {
                        ?>
                        <option value="<?php echo $res01->country_name; ?>"><?php echo $res01->country_name; ?></option>
                    <?php
                    }
                    ?>
                </select>
            </div>
            <div class="col-md-3 col-sm-3 col-xs-12">
                <select class="state form-control" id="state" tabindex="-1">
                    <option value="<?php if(!empty($individual_post['state'])){ echo $individual_post['state']; } ?>"><?php if(!empty($individual_post['state'])){ echo $individual_post['state']; } ?></option>
                    <?php
                    $stmt01 = mysqli_query($con,"SELECT * FROM `states` ");
                    while($res01 = mysqli_fetch_object($stmt01))
                    {
                        ?>
                        <option value="<?php echo $res01->state_name; ?>"><?php echo $res01->state_name; ?></option>
                    <?php
                    }
                    ?>
                </select>
            </div>
            <div class="col-md-3 col-sm-3 col-xs-12">
                <select class="district form-control" id="district" tabindex="-1">
                    <option value="<?php if(!empty($individual_post['district'])){ echo $individual_post['district']; } ?>"><?php if(!empty($individual_post['district'])){ echo $individual_post['district']; } ?></option>
                    <?php
                    $stmt01 = mysqli_query($con,"SELECT * FROM `cities` ");
                    while($res01 = mysqli_fetch_object($stmt01))
                    {
                        ?>
                        <option value="<?php echo $res01->cities_name; ?>"><?php echo $res01->cities_name; ?></option>
                    <?php
                    }
                    ?>
                </select>
            </div>
            <div class="col-md-3 col-sm-3 col-xs-12">
                <input id="loc" class="form-control col-md-7 col-xs-12" value="<?php if(!empty($individual_post['location'])){ echo $individual_post['location']; } ?>" placeholder="Enter Location*" required="required" type="text" name="loc" >
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-3 col-sm-3 col-xs-12">
                <input id="username" class="form-control col-md-7 col-xs-12" value="<?php if(!empty($individual_post['username'])){ echo $individual_post['username']; } ?>" placeholder="Enter User Name*" required="required" type="text" name="username" >
            </div>

            <div class="col-md-3 col-sm-3 col-xs-12">
                <input id="password" class="form-control col-md-7 col-xs-12"  placeholder="Change Password"  type="password" name="password" >
            </div>

            <div class="col-md-3 col-sm-3 col-xs-12">
                <input id="qualification" name="qualification" value="<?php if(!empty($individual_post['qualification'])){ echo $individual_post['qualification']; } ?>" class="date-picker form-control col-md-7 col-xs-12" placeholder="Enter Qualification"  type="text">
            </div>

            <div class="col-md-3 col-sm-3 col-xs-12">
                <input id="join_date" name="join_date" value="<?php if(!empty($individual_post['joined_date'])){ echo $individual_post['joined_date']; } ?>" class="date-picker form-control col-md-7 col-xs-12" placeholder="Enter joining date"  type="date">
            </div>

        </div>
        <div class="form-group">
            <div class="col-md-3 col-sm-3 col-xs-12">
                <input id="salary" name="salary" value="<?php if(!empty($individual_post['salary'])){ echo $individual_post['salary']; } ?>" class="form-control col-md-7 col-xs-12" placeholder="Enter Salary"  type="number">
            </div>
            <div class="col-md-3 col-sm-3 col-xs-12">
                <select class="department form-control" id="department" tabindex="-1" required="required">
                    <option value="<?php if(!empty($dep_q_fet->dep_name)){ echo $dep_q_fet->id; } ?>"><?php if(!empty($dep_q_fet->dep_name)){ echo $dep_q_fet->dep_name; } ?></option>
                    <?php
                    $stmt03 = mysqli_query($con,"SELECT * FROM `department_det` WHERE status='1'");
                    while($res03 = mysqli_fetch_object($stmt03))
                    {
                        ?>
                        <option value="<?php echo $res03->id; ?>"><?php echo $res03->dep_name; ?></option>
                    <?php
                    }
                    ?>
                </select>
            </div>
            <div class="col-md-3 col-sm-3 col-xs-12">
                <select class="designation form-control" id="designation" tabindex="-1" required="required">
                    <option value="<?php if(!empty($des_q_fet->des_name)){ echo $des_q_fet->id; } ?>"><?php if(!empty($des_q_fet->des_name)){ echo $des_q_fet->des_name; } ?></option>
                    <?php
                    $stmt04 = mysqli_query($con,"SELECT * FROM `designation_det` WHERE status='1'");
                    while($res04 = mysqli_fetch_object($stmt04))
                    {
                        ?>
                        <option value="<?php echo $res04->id; ?>"><?php echo $res04->des_name; ?></option>
                    <?php
                    }
                    ?>
                </select>
            </div>
            <div class="col-md-3 col-sm-3 col-xs-12">
                <select id="status" class="form-control col-md-7 col-xs-12" name="status"  required="required">
                    <?php
                    if($individual_post['status'] == 1)
                    {
                    ?>
                        <option value="1">Active</option>
                        <option value="0">In-Active</option>
                    <?php
                    }
                    else
                    {
                    ?>
                        <option value="0">In-Active</option>
                        <option value="1">Active</option>
                    <?php
                    }
                    ?>
                </select>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-4 col-sm-4 col-xs-4">
                <!--<input type="file"  >-->
            </div>
            <div class="col-md-8 col-sm-8 col-xs-8 text-right" id="btn_data">
                <button type="button" name="update" onclick="upd_employee();" class="btn btn-primary btn-sm">Update</button>
            </div>
        </div>
    </form>
<?php
    exit();
}
if(isset($_POST['btn_upd_mem_det']))
{
    $ide = strip_tags(trim(base64_decode($_POST['ide'])));
    $emp_name = strip_tags(trim($_POST['emp_name']));
    $email = strip_tags(trim($_POST['email']));
    if($_POST['phone'] != "")
    {
        $phone = strip_tags(trim($_POST['phone']));
    }
    else
    {
        $phone = '';
    }
    if($_POST['phone2'] != "")
    {
        $phone2 = strip_tags(trim($_POST['phone2']));
    }
    else
    {
        $phone2 = '';
    }

    $add1 = strip_tags(trim($_POST['add1']));
    $add2 = strip_tags(trim($_POST['add2']));
    $post = strip_tags(trim($_POST['post']));
    $pin = strip_tags(trim($_POST['pin']));
    $country = strip_tags(trim($_POST['country']));
    $state = strip_tags(trim($_POST['state']));
    $district = strip_tags(trim($_POST['district']));
    $loc = strip_tags(trim($_POST['loc']));
    $username = strip_tags(trim($_POST['username']));
    $password = strip_tags(trim($_POST['password']));
    $qualification = strip_tags(trim($_POST['qualification']));
    $join_date = strip_tags(trim($_POST['join_date']));
    $salary = strip_tags(trim($_POST['salary']));
    $department = strip_tags(trim($_POST['department']));
    $designation = strip_tags(trim($_POST['designation']));
    $status = strip_tags(trim($_POST['status']));

    $today = date('Y-m-d');
    $tme = date('H:m:s');

    if(!empty($_SESSION['city']))
    {
        $loc2 = $_SESSION['city'];
    }
    else
    {
        $loc2 = "";
    }
    $photo="avatar5.png";

    $stmt3 = $con->prepare("SELECT id,emp_name,username FROM employee_registration WHERE emp_name=? AND username=? AND id != ?");
    $stmt3 -> bind_param("ssi",$emp_name,$username,$ide);
    $stmt3 -> execute();
    $stmt3 -> store_result();
    $num = $stmt3 -> num_rows;


    $stmt4 = $con->prepare("Select id,mob1 FROM employee_registration WHERE mob1 = ? AND mob2 = ? AND id != ?");
    $stmt4 -> bind_param("ssi",$phone,$phone,$ide);
    $stmt4 -> execute();
    $stmt4 -> store_result();
    $num1 = $stmt4 -> num_rows;

    if($phone2 != "")
    {
        $stmt5 = $con->prepare("Select id,mob2 FROM employee_registration WHERE mob1 = ? AND mob2 = ? AND id != ?");
        $stmt5 -> bind_param("ssi",$phone2,$phone2,$ide);
        $stmt5 -> execute();
        $stmt5 -> store_result();
        $num2 = $stmt5 -> num_rows;
    }

    if($num > 0 || $num1 >0 || $num2 >0)
    {
        if($num > 0)
        {
            ?><script>alert("Error! Name Or Username Exist");</script><?php
        }
        if($num1 > 0)
        {
            ?><script>alert("Error! Phone number One Exist");</script><?php
        }
        if($num2 > 0)
        {
            ?><script>alert("Error! Phone number Two Exist");</script><?php
        }

    }
    else
    {
        if(!empty($emp_name) && !empty($phone) && !empty($add1) && !empty($post) && !empty($pin) && !empty($username) && !empty($salary) && !empty($department) && !empty($designation))
        {
         

            $stmt = $con->prepare("UPDATE employee_registration SET emp_name=?,email=?,mob1=?,mob2=?,address_line1=?,address_line2=?,post=?,pin=?,country=?,state=?,district=?,location=?,photo=?,username=?,qualification=?,joined_date=?,salary=?,department=?,designation=?,status=? WHERE id=?");
            $stmt->bind_param("ssssssssssssssssissii",$emp_name,$email,$phone,$phone2,$add1,$add2,$post,$pin,$country,$state,$district,$loc,$photo,$username,$qualification,$join_date,$salary,$department,$designation,$status,$ide);
            $stmt->execute();
            $stmt->store_result();
            $ok = $stmt->affected_rows;

          
                if(!empty($password))
                {
                    $pass=sha1($password);
                    $stmt2 = $con->prepare("UPDATE pi_log_data SET user_name=?,pass=? WHERE staff_id=?");
                    $stmt2 -> bind_param("ssi",$username,$pass,$ide);
                    $stmt2->execute();
                    $stmt2->close();
                }
                else
                {
                    $stmt12 = $con->prepare("UPDATE pi_log_data SET user_name=? WHERE staff_id=?");
                    $stmt12 -> bind_param("si",$username,$ide);
                    $stmt12->execute();
                    $stmt12->close();
                }


                /*?><script>alert("Added.");</script><?php*/

           
            ?>
            <script>

                $('#emp_name').val('');
                $('#phone').val('');
                $('#add1').val('');
                $('#post').val('');
                $('#pin').val('');
                $('#loc').val('');
                $('#username').val('');
                $('#password').val('');
                $('#join_date').val('');
                $('#salary').val('');
                $('#department').val('');
                $('#designation').val('');
                $('#status').val('');
                $('#email').val('');
                $('#phone2').val('');
                $('#add2').val('');
                $('#country').val('');
                $('#state').val('');
                $('#district').val('');
                $('#qualification').val('');
            </script>
            <?php
            $stmt->close();

        }
        else
        {
            ?>
            <script>
                alert('Error..!');
            </script>
        <?php
        }
    }
    ?><script>window.location.href="Employee-Registration";</script><?php
    $stmt3->close();
    $stmt4->close();

 exit();
}
if(isset($_POST['btn_delete_employe_data']))
{

    $count = "";$i=0;
    $checked = $_POST['checked'];
    $count = count($checked);
    if($count > 0)
    {
        while($i<$count)
        {
            $del_id = $checked[$i];
            echo $del_id;
            mysqli_query($con,"DELETE FROM employee_registration WHERE id = '$del_id'");
            $i++;
        }
        ?>
        <script>
            show_emp_data();
        </script>
    <?php
    }
    else
    {
        ?>
        <script>alert("Errorr..!");</script>
    <?php
    }

    exit();
}

?>

