<?php
include("Views/HRM/createEmpTransferDay.php");
?>
<style>
    .table thead tr >th{
        background-color:#4c0870;
        color:#fff;
        text-align: center;
    }

    #error_list_row thead tr>th{
        background-color:#ba1d1d;
        text-align: center !important;
    }
    .table tbody tr >td,.table tbody tr >td input{

        text-align: center;
    }
    .table thead tr th[class*='sorting_'] {
        color: #fff;
    }
    #InputFile{
        width:227px;
        color:#fff;
    }
    #InputFile > input{
        position:absolute;
        cursor:pointer;
        left:0px;
        top:0px;
        width:100%;
        height:100%;
        opacity:0.01;
    }
</style>
<div class="container-fluid container-fixed-lg bg-white">
    <div class="panel panel-transparent">
        <div class="panel-heading">
            <div class="panel-title"><?php print CommonLanguage::getMessage('viewEmpTransferDay'); ?></div>
            <div class="clearfix"></div>

            <?php
            if ($permissions->hasPermission('addEmpTransferDay')) {
                echo Forms::FloatingAddButton('4c0870', '#CreateEmpTransferDay', CommonLanguage::getMessage('add'));
            }
            ?>
        </div>
        <div class="panel-body">





            <table class="table table-bordered table-hover demo-table-search" id="tableWithSearch">
                <thead>
                    <tr>
                        <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('employee_name'); ?></th>
                        <th class="text-center" style="width:5%"><?php print CommonLanguage::getMessage('Date'); ?></th>
                        <th class="text-center" style="width:5%"><?php print CommonLanguage::getMessage('days_nb'); ?></th>
                        <th class="text-center" style="width:5%"><?php print CommonLanguage::getMessage('note'); ?></th>
                        <th class="text-center" style="width:5%"><?php print CommonLanguage::getMessage('Action'); ?></th>

                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>



        </div>
    </div>
</div>
<div class="modal fade bs-example-modal-md" id="DeleteFromList" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width:50%">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                <h4 class="modal-title"><?php print CommonLanguage::getMessage('Confirm_Delete'); ?></h4>
                <div id="DeleteEmployee_modalAlert"></div>
            </div>
            <div class="modal-body">
                <form>
                    <div class="row">
                        <div class="col-md-12 ">
                            <div class="col-md-12" style="margin-top: 20px;">
                                <p><?php print CommonLanguage::getMessage('delete'); ?> <strong class="Name"></strong></p>
                                <p><?php print CommonLanguage::getMessage('Proceed_Delete'); ?></p>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><?php print CommonLanguage::getMessage('Close'); ?></button>
                <button type="button" class="btn btn-danger" id="Employee_Delete" style="width:auto"><?php print CommonLanguage::getMessage('delete'); ?></button>
            </div>
        </div>
    </div>
</div>

<script>
    var title = <?php echo json_encode(CommonLanguage::getMessage('viewEmployeeAlert')); ?>;
    var delete_trs = <?php echo json_encode(CommonLanguage::getMessage('delete_trs_dys')); ?>,
            is_actual = <?php echo json_encode($is_actual);?>;
    var id;
    $(function () {
        RebuildDataTable(title, [0, 1, 2, 3], 'HRMAjax/viewEmpTransferDay',{is_actual : is_actual});
        $("#tableWithSearch").on("click", ".Action .Delete", function () {
            var EmployeeName = $(this).parents("tr").find("td:eq(0)").text()
            var days = $(this).parents("tr").find("td:eq(2)").text()
            $("#DeleteFromList").find(".Name").text(days + ' ' + delete_trs + ' ' + EmployeeName).end().modal("show"); // to set the name of employee in modal to delete 
            id = $(this).parents("tr").find('.Action').attr('data-id'); // current id to delete
        });
        $("#Employee_Delete").on("click", function () {
         
            $.ajax({
                url: "HRMAjax/viewEmpTransferDay",
                method: "POST",
                dataType: 'JSON',
                data: {Getid: id},
                complete: function (v1, v2) {
                    if (v2 == "success") {
                        if (v1.responseJSON[0] == "OK") {
                            $("#DeleteEmployee_modalAlert").attr("class", "alert alert-success").html(Submitted_Successfully);
                            RebuildDataTable(title, [0, 1, 2, 3], 'HRMAjax/viewEmpTransferDay',{is_actual : is_actual});
                            setTimeout(function () {
                                $("#DeleteFromList").modal("hide")
                                
                            }, 1000)
                        } else {
                            $("#DeleteEmployee_modalAlert").attr("class", "alert alert-danger").html(v1.responseJSON[1]);
                        }
                    } else {
                        $("#DeleteEmployee_modalAlert").attr("class", "alert alert-danger").html(Failed_Submit);
                    }
              
                }
            });
        });
    });
    

</script>