<script src="../js/jquery-1.11.1.min.js"></script>
<script>
/////////////HOD Department Find Name Related of Department//////////////

    function check_name(name)
    {

        $.ajax({
            type: 'post',
            url: 'ajax/my_ajax.php',
            data: {name: name, funtion: 'empl_name'},
            success: function (data)

            {
                $("#student_record").html(data);

            }
        });
    }

    function assign(emp_id)
    {

        window.location.href = 'emp_leave.php?empl_id=' + emp_id;
        $("#goto_closed1").click();
    }


/////////////reset and id assign//////////////

    function resetfield(id)
    {


        $("#reserts").click();
        check_name();

        if (id !== '')
        {
            document.getElementById("dep_id").value = id;
        }

    }

</script>

<script>
    function total_collect_admission()
    {
        //alert("hello");
        var total = 0;
        $("input[name='b[]']").each(function () {
            total = parseInt(total) + parseInt($(this).val());
        });
        //alert(total);
        var val1 = parseInt(document.getElementById("value1").value);
        var val2 = parseInt(document.getElementById("value2").value);
        //alert(val1);
        document.getElementById("demo").innerHTML = total + val1 + val2;


    }
</script>


<script>
    $(function () {
        $("#datepicker").datepicker();
        $("#anim").change(function () {
            $("#datepicker").datepicker("option", "showAnim", $(this).val());
        });
    });
    $(function () {
        $("#datepicker1").datepicker();
        $("#anim").change(function () {
            $("#datepicker1").datepicker("option", "showAnim", $(this).val());
        });

    });
</script>

<script>

    function select_batch123(id)
    {
//alert("Hello");
//alert(course_id);
//alert(id);
        var xmlhttp;
        if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        }
        else
        {// code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function ()
        {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
            {
                document.getElementById("find_batch_miss").innerHTML = xmlhttp.responseText;
                alert(responseText);
            }
        }
        xmlhttp.open("GET", "find-batch-miss.php?course_id123=" + id, true);
        xmlhttp.send();
    }
</script>

<script>
    var prefix = "selectBox_";
    $(function () {
        $('.selectpicker').selectpicker({
            'selectedText': 'cat'
        });
    });

    jQuery(document).ready(function () {
        // for remove bootstrap-select validation

        $(".datepicker").datepicker({
            dateFormat: 'yy-mm-dd',
            changeMonth: true,
            changeYear: true,
            yearRange: '-90:+0'
        });


        $('select').each(function () {
            $(this).next('div.bootstrap-select').attr("id", prefix + this.id).removeClass("validate[required]");
        });


        jQuery("#registration").validationEngine('attach', {
            promptPosition: "bottomLeft",
            autoHidePrompt: true,
            prettySelect: true,
            usePrefix: prefix
        });


        $(".datepicker1").datepicker({
            dateFormat: 'yy-mm-dd',
            minDate: dateToday + "-10Y",
            changeMonth: true,
            changeYear: true,
            maxDate: selectedDate + "+3Y"
        });
    });


</script>


<script>
    function nodecut(id)
    {
        var total = 0;
        $("input[name='notdeduction[]']").each(function () {
            total = parseInt(total) + parseInt($(this).val());
        });
        document.getElementById("sum_income").value = total;
        document.getElementById("nettol").value = parseInt(document.getElementById("sum_income").value) - parseInt(document.getElementById("summ").value);
    }


    function nodecut3(id)
    {

        var total1 = 0;
        $("input[name='deduction12[]']").each(function () {
            total1 = parseInt(total1) + parseInt($(this).val());
        });
        document.getElementById("summ").value = total1;
        document.getElementById("nettol").value = parseInt(document.getElementById("sum_income").value) - parseInt(document.getElementById("summ").value);
    }

    function nodecut1(id, value, pa, val)
    {

        if (pa == "P")
        {
            document.getElementById(id).value = (document.getElementById(value).value * val) / 100;

            nodecut3(id);
        }
        if (pa == "A")
        {
            document.getElementById(id).value = val;

            document.getElementById("nettol").value = parseInt(document.getElementById("sum_income").value) - parseInt(document.getElementById("summ").value);
        }
    }


    function check_end()
    {
        alert('Please Add End Date For Add Salary');
    }
</script>

<style>
    .searchres{width:100%;border: #f0f0f0 1px solid;border-radius:5px;}
    .img{float:left;}
    .search_box{width:100%;height:50px;border: 1px solid;border-radius: 5px;font-family: verdana;color:#3C8DBC; font-size: 15px;}
    .user_div{clear:both;font-family: verdana;border-top: #f0f0f0 1px solid;color:black; font-size: 15px;height:40px;width:98%;border-radius:4px;vertical-align: top;  }
    .user_div:hover{background:#4c66a4;color:#fff;cursor:pointer}
    .no_data{height: 40px;background-color: #F0F0F0;width: 99%;border-radius: 5px;font-family: verdana;color:black; font-size: 15px;}
    .name{float:left;}.cntry{ font-size:13px}
    a:link {text-decoration:none;}a:visited {text-decoration:none;}a:hover {text-decoration:none;}a:active {text-decoration:none;}
</style>
<!-- Right side column. Contains the navbar and content of the page -->
<aside class="right-side">
    <!-- Content Header (Page header) -->
    <section class="content-header">
<h1>Master » Employee Exit Policy </h1>

        <ol class="breadcrumb">
            <li><a href="account_management.php"><i class="fa fa-dashboard"></i> Help</a></li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">

                <?php if (isset($success)) { ?>
                    <div class="alert alert-success"><?php echo $success; ?></div>
                <?php } ?>
                <?php if (isset($error)) { ?>
                    <div class="alert alert-danger"> <?php echo $error; ?></div>
                <?php } ?>
                <div class="box-body table-responsive">
                    <div class="header">
                        <input type="text" id="emp_name" placeholder="Search By Name or Emp No.." style="width:100%; padding-left:8px;" class="validate[required] form-control search_box" onKeyUp="return check_name(this.value);" autocomplete="off">
                    </div>
                    <div id="searchres" class="searchres"></div>
                    <div id="table"> <span id="course_name"></span> </div>
                    <table id="student_record" class="table table-bordered table-striped table-hover" border="1" align="center">
                        <tbody>
                        </tbody>
                    </table>
                </div>



                <?php if (isset($_GET['empl_id'])  && !empty($_GET['empl_id'])) { ?>
                    <div class="box box-primary">
                        <form action="" method="post"  id="registration1">

                            <div class="box-body table-responsive">
                                <table id="example2" class="table">
                                    <tr>
                                        <th>Employee No :</th>
                                        <td><?php
                                            if (isset($_GET['empl_id']) && !empty($_GET['empl_id'])) {
                                                echo $fetch_emp['employee_number'];
                                            }
                                            ?>
                                        </td>
                                        <th>Employee Name :</th>
                                        <td><?php
                                            if (isset($_GET['empl_id']) && !empty($_GET['empl_id'])) {
                                                echo $fetch_emp['first_name'] . " " . $fetch_emp['middle_name'] . " " . $fetch_emp['last_name'];
                                            }
                                            ?></td>
                                    </tr>
                                    <tr>
                                        <th>Joining Date :</th>
                                        <td><?php echo $joiningss_date; ?></td>
                                        <th>Pan Card No.  :</th>

                                        <td><?php
                                        if ($fetch_emp['pan_card_no'] != '') {
                                            echo $fetch_emp['pan_card_no'];
                                        } else {
                                            echo "N/A";
                                        }
                                            ?></td>
                                    </tr>
                                    <tr>
                                        <th>Department :</th>
                                        <td><?php
                                            $dept = mysql_fetch_array(mysql_query("select * from employee_departments where id='" . $fetch_emp['employee_department_id'] . "'"));
                                            echo $dept['name'
                                            ];
                                            ?></td>

                                        <th>Designation :</th>
                                        <td><?php
                                            $desig = mysql_fetch_array(mysql_query("select * from employee_positions where id='" . $fetch_emp['employee_position_id'] . "'"));
                                            echo $desig['name'
                                            ];
                                            ?></td>


                                    </tr>
                                    <tr>
                                        <th>Gender :</th>
                                        <td><?php
                                        if ($fetch_emp['gender'] == 'm') {
                                            echo "Male";
                                        } else if ($fetch_emp['gender'] == 'f') {
                                            echo "Female";
                                        }
                                        ?></td>

                                        <th>Account Number :</th>
                                        <td><?php echo $fetch_account['account_no']; ?></td>

                                    </tr>
                                </table>
                            </div>
                    </div>
                    <!-- /.box-header -->

                    <div class="box box-primary">
                        <div class="box-body">
                            <form  name="myForm" action="" class="form-horizontal" method="post" id="registration">
                                <div class="row">
                                    <div class="col-sm-6 col-lg-6">
                                        <div class="form-group">
                                            <label for="inputEmail" class="col-md-4 control-label">Employee Leave Reason:</label>
    <?php ?>
                                            <div class="col-md-6">
                                                <select name="leav_statuss" class="validate[required] form-control" style="width:100%;">
                                                    <option value="">--select--</option>    
    <?php $sql_qu = mysql_query("select * from employee_status");
    while ($fetch_emp_stutus = mysql_fetch_array($sql_qu)) {
        ?>
                    <option value="<?php echo $fetch_emp_stutus['id']; ?>" <?php if($sql_edit['leave_status']==$fetch_emp_stutus['id']){ echo "selected"; } else if($fetch_emp['status']==$fetch_emp_stutus['id']){ echo "selected"; } ?>><?php echo $fetch_emp_stutus['name']; ?></option>
    <?php } ?>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-6 col-lg-6">
                                        <div class="form-group">
                                            <label for="inputEmail" class="col-md-4 control-label">Leaving Date :</label>
                                            <div class="col-md-6">
                                                <input class="validate[required] form-control date_of_bith" name="leav_date" readonly="" type="text" placeholder="Enter leaving date"  value="<?php if(isset($_GET['empl_id']) && !empty($_GET['empl_id'])){ echo $get_date; } ?>" style="width:100%; padding-left:8px;"/>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!--/.row-->
                                <div class="row"><div class="col-lg-12">&nbsp;</div></div>
                                <div class="row">
                                    <div class="col-sm-6 col-lg-6">
                                        <div class="form-group">
                                            <label for="inputEmail" class="col-md-4 control-label">Remarks :</label>
                                            <div class="col-md-6">
                                                <textarea class="validate[required] form-control" name="remarkss" placeholder="Enter Remarks" style="width:100%; padding-left:8px;"><?php if(isset($_GET['empl_id']) && !empty($_GET['empl_id'])){ echo $sql_edit['remark']; } ?></textarea>
                                            </div>
                                        </div>
                                    </div>

                                </div>
                                <center>
                                    <input type="submit" name="submit" value="<?php if ($_GET[edit_id] == '') { ?>Submit<?php } else { ?>Update<? } ?>" class="btn btn-primary" />
                                    <input type="reset"   id="reset" name="reset"  value="Reset" class="btn btn-primary submit-green"     />
                                </center>
                            </form>
                        </div>
                        <!--/.box body--->
                    </div>
                </div>
<?php } ?>
            <div class="col-xs-12">
                <?php if (isset($_GET['empl_id']) && !empty($_GET['empl_id'])) { ?>

                    <div id="no-more-tables">
                        <table class="col-md-12 table-bordered table-striped table-condensed cf">
                            <thead class="cf">
                                <tr>
                                    <th>Emp No.</th>
                                    <th>Employee Name </th>
                                    <th>Joining Date</th>
                                    <th>Employee Exit Date</th>
                                    <th>Remarks</th>
                                    <th>Leave Reason</th>
                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                        <?php
                                        $num_rw = mysql_num_rows($leav_emp);
                                        if ($num_rw > 0) {
                                            //$sql_sal = mysql_query("select  distinct  net_salary, employee_id , end_date, start_date from  employee_salary_structures where employee_id='" . $_GET['empl_id'] . "' order by id desc");
                                            while ($fetch_sql = mysql_fetch_array($leav_emp)) {
                                                ?>
                                        <tr>
                                            <td data-title="Emp No."> <?php echo $fetch_sql['employee_number']; ?></td>
                                            <td data-title="Employee Name"><?php echo $fetch_sql['first_name'] . " " . $fetch_sql['middle_name'] . " " . $fetch_sql['last_name']; ?></td>
                                            <td data-title="Joining Date"><?php echo $fetch_sql['joining_date']; ?></td>
                                            <td data-title="Leave Reason"><?php echo $fetch_sql['leave_date']; ?></td>
                                             <td data-title="Remarks"><?php echo $fetch_sql['remark']; ?></td>
                                             <th data-title="Leave Reason"><?php $query=mysql_fetch_array(mysql_query("select * from employee_status where id='".$fetch_sql['leave_status']."'")); echo $query['name']; ?></th>
                                            <td data-title="Action"><a href="emp_leave.php?edit_id=<?php echo $fetch_sql['id']; ?>&&empl_id=<?php echo $fetch_sql['id']; ?>" class="label label-info">Update</a></td>
                                        </tr>
                    <?php }
                } else {
                    ?>
                                    <tr>
                                        <td colspan="7" align="center">No Record</td>




                                    </tr>  
    <?php } ?>

                            </tbody>
                        </table>
                    </div>
                

<?php } ?>

        </div>
        <!-- /.col-->

        </div>
        <!-- /.rows-->
    </section>
    <!-- /.content -->
</aside>
<!-- /.right-side -->
