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

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

if(!isset($_SESSION['jay_proj_mngmnt']) && empty($_SESSION['jay_proj_mngmnt']))
{
    echo '<script type="text/javascript">alert("You Want To Login Now.."); window.location.href="../Login";</script>';
}

include "../ses_write.php";
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Marketing</title>

    <!-- Bootstrap core CSS -->

    <link href="../components/css/bootstrap.min.css" rel="stylesheet">

    <link href="../components/fonts/css/font-awesome.min.css" rel="stylesheet">
    <link href="../components/css/animate.min.css" rel="stylesheet">

    <!-- Custom styling plus plugins -->
    <link href="../components/css/custom.css" rel="stylesheet">
    <link href="../components/css/icheck/flat/green.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="../components/css/maps/jquery-jvectormap-2.0.1.css" />
    <link href="../components/css/floatexamples.css" rel="stylesheet" type="text/css" />


    <script src="../components/js/jquery.min.js"></script>
    <script src="../components/js/nprogress.js"></script>
    <script>
        NProgress.start();
    </script>

    <style>
        input[type=number] {
            -moz-appearance:textfield;
        }

        input[type=number]::-webkit-inner-spin-button,
        input[type=number]::-webkit-outer-spin-button {
            -webkit-appearance: none;
            margin: 0;
        }
    </style>

    <script src="../components/js/jquery.min.js"></script>

    <!--[if lt IE 9]>
    <script src="../assets/js/ie8-responsive-file-warning.js"></script>
    <![endif]-->

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <!-- DataTables CSS -->
    <link href="../components/data_table/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.css" rel="stylesheet">

    <!-- DataTables Responsive CSS -->
    <link href="../components/data_table/datatables-responsive/css/dataTables.responsive.css" rel="stylesheet">

    <!-- select2 -->
    <link href="../components/css/select/select2.min.css" rel="stylesheet">

</head>




<body class="nav-md">

<div class="container body">


<div class="main_container">

<?php include("left_menu.php"); ?>

<!-- top navigation -->
<?php include("../marketing/top_nav.php"); ?>
<!-- /top navigation -->

<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>
<script>
    window.onload = function () { $("#alert").removeClass(); }
</script>
<script>
    function reg_employee()
    {
        var ck_name = /^[A-Za-z .,0-9 ]{3,30}$/;
        var ck_disc = /^[A-Za-z .,0-9 ]/;
        var ck_num = /^[ 0-9 ]/;
        var ck_email = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
        var ck_date  = /^\d{4}-\d{2}-\d{2}$/;

        $("#alert").removeClass();

        //PERSON
        if(document.getElementById('emp_name').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Employee Name.!');
            $('#emp_name').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('emp_name').value.match(ck_name))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Employee Name..!');
            $('#emp_name').focus();
            return false;
        }
        $('#alert').html('');

        //Phone 1
        if(document.getElementById('phone').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Please Enter Phone Number.!');
            $('#phone').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('phone').value.match(ck_num))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Phone Number..!');
            $('#phone').focus();
            return false;
        }
        $('#alert').html('');

        //ADDRESS LINE1
        if(document.getElementById('add1').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Address Line 1.!');
            $('#add1').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('add1').value.match(ck_name))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Address Line 1..!');
            $('#add1').focus();
            return false;
        }
        $('#alert').html('');

        //POST
        if(document.getElementById('post').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Postal Name.!');
            $('#post').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('post').value.match(ck_name))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Postal Name..!');
            $('#post').focus();
            return false;
        }
        $('#alert').html('');

        //PIN
        if(document.getElementById('pin').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Pin/Zip Code.!');
            $('#pin').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('pin').value.match(ck_num))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Pin/Zip Code..!');
            $('#pin').focus();
            return false;
        }
        $('#alert').html('');

        //Location
        if(document.getElementById('loc').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Location.!');
            $('#loc').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('loc').value.match(ck_disc))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Location..!');
            $('#loc').focus();
            return false;
        }
        $('#alert').html('');

        //UserName
        if(document.getElementById('username').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter User Name.!');
            $('#username').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('username').value.match(ck_name))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error User Name..!');
            $('#username').focus();
            return false;
        }
        $('#alert').html('');

        //Password
        if(document.getElementById('password').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Password.!');
            $('#password').focus();
            return false;
        }
        $('#alert').html('');


        //Join Date
        if(document.getElementById('join_date').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Join Date.!');
            $('#join_date').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('join_date').value.match(ck_date))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Join Date..!');
            $('#join_date').focus();
            return false;
        }
        $('#alert').html('');

        //Salary
        if(document.getElementById('salary').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Salary.!');
            $('#salary').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('salary').value.match(ck_num))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Salary..!');
            $('#salary').focus();
            return false;
        }
        $('#alert').html('');

        //Department
        if(document.getElementById('department').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Department.!');
            $('#department').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('department').value.match(ck_num))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Department..!');
            $('#department').focus();
            return false;
        }
        $('#alert').html('')

        //Designation
        if(document.getElementById('designation').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Designation.!');
            $('#designation').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('department').value.match(ck_num))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Designation..!');
            $('#designation').focus();
            return false;
        }
        $('#alert').html('');

        //Status
        if(document.getElementById('status').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Status.!');
            $('#status').focus();
            return false;
        }
        $('#alert').html('');


        if(document.getElementById('email').value != "")
        {
            //email
            if(document.getElementById('email').value.match(ck_email))
            {

            }
            else
            {
                $('#alert').addClass('alert alert-danger fade in');
                $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Email..!');
                $('#email').focus();
                return false;
            }
            $('#alert').html('');
        }

        if(document.getElementById('phone2').value != "")
        {
            //phone2
            if(document.getElementById('phone2').value.match(ck_num))
            {

            }
            else
            {
                $('#alert').addClass('alert alert-danger fade in');
                $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Second Phone Number..!');
                $('#phone2').focus();
                return false;
            }
            $('#alert').html('');
        }

        if(document.getElementById('add2').value != "")
        {
            //Address line 2
            if(document.getElementById('add2').value.match(ck_disc))
            {

            }
            else
            {
                $('#alert').addClass('alert alert-danger fade in');
                $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Address Line2..!');
                $('#add2').focus();
                return false;
            }
            $('#alert').html('');
        }

        if(document.getElementById('country').value != "")
        {
            //country
            if(document.getElementById('country').value.match(ck_disc))
            {

            }
            else
            {
                $('#alert').addClass('alert alert-danger fade in');
                $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Country..!');
                $('#country').focus();
                return false;
            }
            $('#alert').html('');
        }

        if(document.getElementById('state').value != "")
        {
            //state
            if(document.getElementById('state').value.match(ck_disc))
            {

            }
            else
            {
                $('#alert').addClass('alert alert-danger fade in');
                $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error State..!');
                $('#state').focus();
                return false;
            }
            $('#alert').html('');
        }

        if(document.getElementById('district').value != "")
        {
            //district
            if(document.getElementById('district').value.match(ck_disc))
            {

            }
            else
            {
                $('#alert').addClass('alert alert-danger fade in');
                $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error District..!');
                $('#district').focus();
                return false;
            }
            $('#alert').html('');
        }

        if(document.getElementById('qualification').value != "")
        {
            //qualification
            if(document.getElementById('qualification').value.match(ck_disc))
            {

            }
            else
            {
                $('#alert').addClass('alert alert-danger fade in');
                $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Qualification..!');
                $('#qualification').focus();
                return false;
            }
            $('#alert').html('');
        }

         var emp_name = $('#emp_name').val();
         var email = $('#email').val();
         var phone = $('#phone').val();
         var phone2 = $('#phone2').val();
         var add1 = $('#add1').val();
         var add2 = $('#add2').val();
         var post = $('#post').val();
         var pin = $('#pin').val();
         var country = $('#country').val();
         var state = $('#state').val();
         var district = $('#district').val();
         var loc = $('#loc').val();
         var username = $('#username').val();
         var password = $('#password').val();
         var qualification = $('#qualification').val();
         var join_date = $('#join_date').val();
         var salary = $('#salary').val();
         var department = $('#department').val();
         var designation = $('#designation').val();
         var status = $('#status').val();


        $.ajax({
            url   :"ajax_employee.php" ,
            type  : "POST",
            data  :
            {
                btn_add_emp_data : 1,
                emp_name         : emp_name,
                email            : email,
                phone            : phone,
                phone2           : phone2,
                add1             : add1,
                add2             : add2,
                post             : post,
                pin              : pin,
                country          : country,
                state            : state,
                district         : district,
                loc              : loc,
                username         : username,
                password         : password,
                qualification    : qualification,
                join_date        : join_date,
                salary           : salary,
                department       : department,
                designation      : designation,
                status           : status
            },
            success:function(res11)
            {
                $('#alert').html(res11);
            }
        });


    }
</script>
<script>
    function show_emp_data()
    {
        $.ajax({
            url   :"ajax_employee.php" ,
            type  : "POST",
            data  :
            {
                btn_show_emp_data : 1
            },
            success:function(res777)
            {
                $('#show_data').html(res777);
            }
        });
    }
</script>
<script>
    function edt_mem_data(id)
    {
        $.ajax({
            url   :"ajax_employee.php" ,
            type  : "POST",
            data  :
            {
                btn_edt_mem_det : 1,
                id              : id
            },
            success:function(res171)
            {
                $('#edt_data').html(res171);
            }
        });
    }
</script>
<script>
    function upd_employee()
    {
        var ck_name = /^[A-Za-z .,0-9 ]{3,30}$/;
        var ck_disc = /^[A-Za-z .,0-9 ]/;
        var ck_num = /^[ 0-9 ]/;
        var ck_email = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
        var ck_date  = /^\d{4}-\d{2}-\d{2}$/;

        $("#alert").removeClass();

        //PERSON
        if(document.getElementById('emp_name').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Employee Name.!');
            $('#emp_name').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('emp_name').value.match(ck_name))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Employee Name..!');
            $('#emp_name').focus();
            return false;
        }
        $('#alert').html('');

        //Phone 1
        if(document.getElementById('phone').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Please Enter Phone Number.!');
            $('#phone').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('phone').value.match(ck_num))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Phone Number..!');
            $('#phone').focus();
            return false;
        }
        $('#alert').html('');

        //ADDRESS LINE1
        if(document.getElementById('add1').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Address Line 1.!');
            $('#add1').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('add1').value.match(ck_name))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Address Line 1..!');
            $('#add1').focus();
            return false;
        }
        $('#alert').html('');

        //POST
        if(document.getElementById('post').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Postal Name.!');
            $('#post').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('post').value.match(ck_name))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Postal Name..!');
            $('#post').focus();
            return false;
        }
        $('#alert').html('');

        //PIN
        if(document.getElementById('pin').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Pin/Zip Code.!');
            $('#pin').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('pin').value.match(ck_num))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Pin/Zip Code..!');
            $('#pin').focus();
            return false;
        }
        $('#alert').html('');

        //Location
        if(document.getElementById('loc').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Location.!');
            $('#loc').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('loc').value.match(ck_disc))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Location..!');
            $('#loc').focus();
            return false;
        }
        $('#alert').html('');

        //UserName
        if(document.getElementById('username').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter User Name.!');
            $('#username').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('username').value.match(ck_name))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error User Name..!');
            $('#username').focus();
            return false;
        }
        $('#alert').html('');


        //Join Date
        if(document.getElementById('join_date').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Join Date.!');
            $('#join_date').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('join_date').value.match(ck_date))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Join Date..!');
            $('#join_date').focus();
            return false;
        }
        $('#alert').html('');

        //Salary
        if(document.getElementById('salary').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Salary.!');
            $('#salary').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('salary').value.match(ck_num))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Salary..!');
            $('#salary').focus();
            return false;
        }
        $('#alert').html('');

        //Department
        if(document.getElementById('department').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Department.!');
            $('#department').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('department').value.match(ck_num))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Department..!');
            $('#department').focus();
            return false;
        }
        $('#alert').html('')

        //Designation
        if(document.getElementById('designation').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Designation.!');
            $('#designation').focus();
            return false;
        }
        $('#alert').html('');
        if(document.getElementById('department').value.match(ck_num))
        {

        }
        else
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Designation..!');
            $('#designation').focus();
            return false;
        }
        $('#alert').html('');

        //Status
        if(document.getElementById('status').value == "")
        {
            $('#alert').addClass('alert alert-danger fade in');
            $('#alert').html('<strong> Error! </strong> Please Enter Status.!');
            $('#status').focus();
            return false;
        }
        $('#alert').html('');


        if(document.getElementById('email').value != "")
        {
            //email
            if(document.getElementById('email').value.match(ck_email))
            {

            }
            else
            {
                $('#alert').addClass('alert alert-danger fade in');
                $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Email..!');
                $('#email').focus();
                return false;
            }
            $('#alert').html('');
        }

        if(document.getElementById('phone2').value != "")
        {
            //phone2
            if(document.getElementById('phone2').value.match(ck_num))
            {

            }
            else
            {
                $('#alert').addClass('alert alert-danger fade in');
                $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Second Phone Number..!');
                $('#phone2').focus();
                return false;
            }
            $('#alert').html('');
        }

        if(document.getElementById('add2').value != "")
        {
            //Address line 2
            if(document.getElementById('add2').value.match(ck_disc))
            {

            }
            else
            {
                $('#alert').addClass('alert alert-danger fade in');
                $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Address Line2..!');
                $('#add2').focus();
                return false;
            }
            $('#alert').html('');
        }

        if(document.getElementById('country').value != "")
        {
            //country
            if(document.getElementById('country').value.match(ck_disc))
            {

            }
            else
            {
                $('#alert').addClass('alert alert-danger fade in');
                $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Country..!');
                $('#country').focus();
                return false;
            }
            $('#alert').html('');
        }

        if(document.getElementById('state').value != "")
        {
            //state
            if(document.getElementById('state').value.match(ck_disc))
            {

            }
            else
            {
                $('#alert').addClass('alert alert-danger fade in');
                $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error State..!');
                $('#state').focus();
                return false;
            }
            $('#alert').html('');
        }

        if(document.getElementById('district').value != "")
        {
            //district
            if(document.getElementById('district').value.match(ck_disc))
            {

            }
            else
            {
                $('#alert').addClass('alert alert-danger fade in');
                $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error District..!');
                $('#district').focus();
                return false;
            }
            $('#alert').html('');
        }

        if(document.getElementById('qualification').value != "")
        {
            //qualification
            if(document.getElementById('qualification').value.match(ck_disc))
            {

            }
            else
            {
                $('#alert').addClass('alert alert-danger fade in');
                $('#alert').html('<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong> Error! </strong> Miss Match Error Qualification..!');
                $('#qualification').focus();
                return false;
            }
            $('#alert').html('');
        }
        if(document.getElementById('ide').value == "")
        {
            alert("Error..!");
            return false;
        }

        var emp_name = $('#emp_name').val();
        var email = $('#email').val();
        var phone = $('#phone').val();
        var phone2 = $('#phone2').val();
        var add1 = $('#add1').val();
        var add2 = $('#add2').val();
        var post = $('#post').val();
        var pin = $('#pin').val();
        var country = $('#country').val();
        var state = $('#state').val();
        var district = $('#district').val();
        var loc = $('#loc').val();
        var username = $('#username').val();
        var password = $('#password').val();
        var qualification = $('#qualification').val();
        var join_date = $('#join_date').val();
        var salary = $('#salary').val();
        var department = $('#department').val();
        var designation = $('#designation').val();
        var status = $('#status').val();
        var ide = $('#ide').val();
      


        $.ajax({
            url   :"ajax_employee.php" ,
            type  : "POST",
            data  :
            {
                btn_upd_mem_det : 1,
                emp_name        : emp_name,
                email           : email,
                phone           : phone,
                phone2          : phone2,
                add1            : add1,
                add2            : add2,
                post            : post,
                pin             : pin,
                country         : country,
                state           : state,
                district        : district,
                loc             : loc,
                username        : username,
                password        : password,
                qualification   : qualification,
                join_date       : join_date,
                salary          : salary,
                department      : department,
                designation     : designation,
                status          : status,
                ide             : ide
            },
            success:function(res185)
            {
              
                $('#alert').html(res185);
            }
        });



    }
</script>
<script>
    $(function()
    {

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

    });
</script>
<script>
    function del_emp_data()
    {
        if (confirm("Are you sure you want to delete?"))
        {
            var notChecked = [], checked = [];

            $(":checkbox").each(function()
            {
                if(this.checked)
                {
                    checked.push(this.id);
                }
                else
                {
                    notChecked.push(this.id);
                }
            });

            $.ajax({
                url   :"ajax_employee.php" ,
                type  : "POST",
                data  :
                {
                    btn_delete_employe_data : 1,
                    checked                 : checked
                },
                success:function(res216)
                {
                    $('#alert').html(res216);
                }
            });
        }
    }
</script>
<!-- page content -->
<div class="right_col" role="main">
    <div class="row">
        <div class="col-md-12 col-sm-12 col-xs-12">
            <div class="" id="alert">

            </div>
            <div class="x_panel">
                <div class="x_title">
                    <h2>Employee<small>registration</small></h2>
                    <ul class="nav navbar-right panel_toolbox">
                        <li>
                            <a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                        </li>
                        <li>
                            <a class="close-link"><i class="fa fa-close"></i></a>
                        </li>
                    </ul>
                    <div class="clearfix"></div>
                </div>
                <div class="x_content" id="edt_data">


                    <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" placeholder="Employee Name*" required="required"  type="text" name="emp_name" >
                            </div>
                            <div class="col-md-3 col-sm-3 col-xs-12">
                                <input type="email" id="email" name="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" 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" 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" 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" 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" 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" 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">
                                <!--<input id="country" class="form-control col-md-7 col-xs-12" placeholder="Enter Country"  type="text" name="country" >-->
                                <select class="country form-control " id="country" tabindex="-1">
                                    <option value=""></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">
                                <!--<input id="state" class="form-control col-md-7 col-xs-12" placeholder="Enter State"  type="text" name="state">-->
                                <select class="state form-control" id="state" tabindex="-1">
                                    <option value=""></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">
                                <!-- <input id="dist" class="form-control col-md-7 col-xs-12" placeholder="Enter District"  type="text" name="dist">-->
                                <select class="district form-control" id="district" tabindex="-1">
                                    <option value=""></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 echo $_SESSION['city']; ?>" 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" 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="Enter Password"  type="password" name="password" >
                            </div>

                            <div class="col-md-3 col-sm-3 col-xs-12">
                                <input id="qualification" name="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" 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" class="date-picker 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="">Department*</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="">Designation*</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">
                                    <option value="">Status*</option>
                                    <option value="1">Active</option>
                                    <option value="0">In-Active</option>
                                </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="save" onclick="reg_employee();" class="btn btn-primary btn-sm">Save</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12 col-sm-12 col-xs-12">
            <div class="x_panel">
                <div class="x_title">
                    <h2>Employee<small>View</small></h2>
                    <ul class="nav navbar-right panel_toolbox">
                        <li class="col-md-pull-6">
                            <button class="btn btn-default btn-sm" onclick="del_emp_data();"  disabled="disabled" id="delete" name="delete"><span class="glyphicon glyphicon-trash"  ></span></button>
                        </li>
                        <li>
                            <a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                        </li>
                        <li>
                            <a class="close-link"><i class="fa fa-close"></i></a>
                        </li>
                    </ul>
                    <div class="clearfix"></div>
                </div>
                <div class="x_content" id="show_data">
                    <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>
                    <!-- /.table-responsive -->
                </div>
            </div>
        </div>
    </div>

</div>
<!-- /page content -->

</div>

</div>

<div id="custom_notifications" class="custom-notifications dsp_none">
    <ul class="list-unstyled notifications clearfix" data-tabbed_notifications="notif-group">
    </ul>
    <div class="clearfix"></div>
    <div id="notif-group" class="tabbed_notifications"></div>
</div>

<script src="../components/js/bootstrap.min.js"></script>


<!-- chart js -->
<script src="../components/js/chartjs/chart.min.js"></script>
<!-- bootstrap progress js -->
<script src="../components/js/progressbar/bootstrap-progressbar.min.js"></script>
<script src="../components/js/nicescroll/jquery.nicescroll.min.js"></script>
<!-- icheck -->
<script src="../components/js/icheck/icheck.min.js"></script>
<!-- tags -->
<script src="../components/js/tags/jquery.tagsinput.min.js"></script>
<!-- switchery -->
<script src="../components/js/switchery/switchery.min.js"></script>
<!-- daterangepicker -->
<script type="text/javascript" src="../components/js/moment.min2.js"></script>
<script type="text/javascript" src="../components/js/datepicker/daterangepicker.js"></script>

<!-- form validation -->
<!--<script type="text/javascript" src="js/parsley/parsley.min.js"></script>-->

<!-- textarea resize -->
<script src="../components/js/textarea/autosize.min.js"></script>
<script>
    autosize($('.resizable_textarea'));
</script>
<script src="../components/js/custom.js"></script>

<!-- DataTables JavaScript -->
<script src="../components/data_table/datatables/media/js/jquery.dataTables.min.js"></script>
<script src="../components/data_table/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>
<!-- Page-Level Demo Scripts - Tables - Use for reference -->
<script>
    $(document).ready(function() {
        $('#dataTables-example').DataTable({
            responsive: true
        });
    });
</script>

<!-- 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 -->
</body>

</html>
