<!DOCTYPE html>
<html lang="en">


<!-- Mirrored from edumin.dexignlab.com/xhtml/add-departments.html by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 17 Nov 2020 13:56:15 GMT -->

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Rizwan </title>
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" sizes="16x16" href="<?php echo base_url(); ?>assets/images/favicon.png">
    <link rel="stylesheet"
        href="<?php echo base_url(); ?>assets/vendor/bootstrap-select/dist/css/bootstrap-select.min.css">
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/style.css">
    <!-- Pick date -->
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets/vendor/pickadate/themes/default.css">
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets/vendor/pickadate/themes/default.date.css">
    <link href="<?php echo base_url(); ?>assets/vendor/datatables/css/jquery.dataTables.min.css" rel="stylesheet">
    <!-- Custom Stylesheet -->


</head>

<body>

    <!--*******************
        Preloader start
    ********************-->
    <div id="preloader">
        <div class="sk-three-bounce">
            <div class="sk-child sk-bounce1"></div>
            <div class="sk-child sk-bounce2"></div>
            <div class="sk-child sk-bounce3"></div>
        </div>
    </div>
    <!--*******************
        Preloader end
    ********************-->

    <!--**********************************
        Main wrapper start
    ***********************************-->
    <div id="main-wrapper">

        <?php $this->load->view('header'); ?>

        <!--**********************************
            Content body start
        ***********************************-->
        <div class="content-body">
            <!-- row -->
            <div class="container-fluid">

                <div class="row page-titles mx-0">
                    <div class="col-sm-6 p-md-0">
                        <div class="welcome-text">
                            <h4>Edit Employee</h4>
                        </div>
                    </div>
                    <div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="index.html">Home</a></li>
                            <li class="breadcrumb-item active"><a href="javascript:void(0);">Employees</a></li>
                            <li class="breadcrumb-item active"><a href="javascript:void(0);">Edit Employees</a></li>
                        </ol>
                    </div>
                </div>

                <div class="row">


                    <div class="col-12">
                        <div class="card">
                            <div class="card-header">

                                <div class="col-xl-12">
                                    <div class="card">
                                    <div id='empolyee_success' class='alert alert-success solid'
                                    style='display:none;'></div>
                                    <div id='empolyee_issue' class='alert alert-danger solid'
                                    style='display:none;'></div>
                                    
                                        <div class="card-header">
                                            <h5 class="card-title">Edit Employee</h5>
                                        </div>
                                        <div class="card-body">
                                            <?php echo form_open(base_url('employee/update'), [
                                                'class' => "form-horizontal edit_empolyee",
                                                'id' => "edit_empolyee",
                                                'enctype' => 'multipart/form-data'
                                            ]); ?>

                                            <!-- Hidden Inputs -->
                                            <input type="hidden" name="user_id"
                                                value="<?php echo $this->session->userdata('id'); ?>">
                                            <input type="hidden" name="created"
                                                value="<?php echo date('Y-m-d H:i:s'); ?>">
                                            <input type="hidden" name="modified"
                                                value="<?php echo date('Y-m-d H:i:s'); ?>">
                                                <input type="hidden" name="id" id="id" value="<?php echo $this->uri->segment(3); ?>">


                                            <div class="row">
                                                <!-- Full Name -->
                                                <div class="col-md-6 mb-3">
                                                    <label>Name</label>
                                                    <input type="text" name="fullname"
                                                        value="<?php echo $get_emp[0]['fullname']; ?>"
                                                        class="form-control" required>
                                                </div>

                                                <!-- Phone -->
                                                <div class="col-md-6 mb-3">
                                                    <label>Phone</label>
                                                    <input type="number" name="phone"
                                                        value="<?php echo $get_emp[0]['phone']; ?>" class="form-control"
                                                        required>
                                                </div>

                                                <!-- NIC -->
                                                <div class="col-md-6 mb-3">
                                                    <label>NIC</label>
                                                    <input type="number" name="nic"
                                                        value="<?php echo $get_emp[0]['nic']; ?>" class="form-control">
                                                </div>

                                                <!-- Email -->
                                                <div class="col-md-6 mb-3">
                                                    <label>Email</label>
                                                    <input type="email" name="email"
                                                        value="<?php echo $get_emp[0]['email']; ?>"
                                                        class="form-control">
                                                </div>

                                                <!-- Department -->
                                                <div class="col-md-6 mb-3">
                                                    <label>Department</label>
                                                    <select name="depart" class="form-control" required>
                                                        <option value="">Select Department</option>
                                                        <option selected value="<?php echo $get_emp[0]['depart']; ?>">
                                                            <?php echo depart($get_emp[0]['depart']); ?></option>
                                                        <?php foreach ($get_depart as $value): ?>
                                                            <option value="<?php echo $value['id']; ?>">
                                                                <?php echo $value['depart']; ?></option>
                                                        <?php endforeach; ?>
                                                    </select>
                                                </div>

                                                <!-- Designation -->
                                                <div class="col-md-6 mb-3">
                                                    <label>Designation</label>
                                                    <input type="text" name="designation"
                                                        value="<?php echo $get_emp[0]['designation']; ?>"
                                                        class="form-control" required>
                                                </div>

                                                <!-- Salary -->
                                                <div class="col-md-6 mb-3">
                                                    <label>Salary</label>
                                                    <input type="number" name="salary"
                                                        value="<?php echo $get_emp[0]['salary']; ?>"
                                                        class="form-control" required>
                                                </div>

                                                <!-- Overtime -->
                                                <div class="col-md-6 mb-3">
                                                    <label>Over Time</label>
                                                    <input type="text" name="over_time"
                                                        value="<?php echo $get_emp[0]['over_time']; ?>"
                                                        class="form-control">
                                                </div>

                                                <!-- Allowance -->
                                                <div class="col-md-6 mb-3">
                                                    <label>Tea / Petrol</label>
                                                    <input type="text" name="tea_petrol"
                                                        value="<?php echo $get_emp[0]['tea_petrol']; ?>"
                                                        class="form-control">
                                                </div>
                                                
                                                 <div class="col-md-6 mb-3">
                                                    <label>Allowance</label>
                                                    <input type="text" name="allowance"
                                                        value="<?php echo $get_emp[0]['allowance']; ?>"
                                                        class="form-control">
                                                </div>

                                                <?php
                                                    $tap_in_24  = date("H:i", strtotime($get_emp[0]['tap_in']));
                                                    $tap_out_24 = date("H:i", strtotime($get_emp[0]['tap_out']));
                                                    ?>

                                                <!-- Tap In -->
                                                    <div class="col-md-6 mb-3">
                                                        <label>Tap In</label>
                                                        <input type="time" name="tap_in"
                                                            value="<?php echo $tap_in_24; ?>"
                                                            class="form-control" required>
                                                    </div>

                                                    <!-- Tap Out -->
                                                    <div class="col-md-6 mb-3">
                                                        <label>Tap Out</label>
                                                        <input type="time" name="tap_out"
                                                            value="<?php echo $tap_out_24; ?>"
                                                            class="form-control" required>
                                                    </div>


                                                <!-- RFID -->
                                                <div class="col-md-6 mb-3">
                                                    <label>RF ID</label>
                                                    <input type="number" name="rf_id"
                                                        value="<?php echo $get_emp[0]['rf_id']; ?>" class="form-control"
                                                        required>
                                                </div>

                                                <!-- Bank Account -->
                                                <div class="col-md-6 mb-3">
                                                    <label>Bank Account</label>
                                                    <input type="number" name="bank_account"
                                                        value="<?php echo $get_emp[0]['bank_account']; ?>"
                                                        class="form-control" required>
                                                </div>

                                                <!-- Address -->
                                                <div class="col-md-6 mb-3">
                                                    <label>Address</label>
                                                    <textarea name="address" class="form-control" rows="3"
                                                        required><?php echo $get_emp[0]['address']; ?></textarea>
                                                </div>

                                                <!-- Comments -->
                                                <div class="col-md-6 mb-3">
                                                    <label>Comments</label>
                                                    <textarea name="comments" class="form-control"
                                                        rows="3"><?php echo $get_emp[0]['comments']; ?></textarea>
                                                </div>

                                                <!-- Image Upload -->

                                                <!-- Status -->
                                                <div class="col-md-6 mb-3">
                                                    <label>Status</label>
                                                    <select name="status" class="form-control">
                                                        <option value="1" <?= $get_emp[0]['status'] == 1 ? 'selected' : ''; ?>>Active</option>
                                                        <option value="0" <?= $get_emp[0]['status'] == 0 ? 'selected' : ''; ?>>De-Active</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="col-md-6 mb-3">
                                                    <label>Image</label>
                                                    <input type="file" name="file" id="file" class="form-control">
                                                    <?php if (!empty($get_emp[0]['image'])): ?>
                                                        <div class="mt-2">
                                                            <img src="<?php echo base_url('assets/images/profile/' . $get_emp[0]['image']); ?>"
                                                                height="10" alt="Employee Image" class="img-thumbnail">
                                                        </div>
                                                    <?php endif; ?>
                                                </div>

                                            <!-- Submit -->
                                            <div class="text-right mt-4">
                                                <button type="submit" class="btn btn-primary px-5">Update
                                                    Employee</button>
                                            </div>

                                            <?php echo form_close(); ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>


                </div>
            </div>
        </div>
        <!--**********************************
            Content body end
        ***********************************-->


        <!--**********************************
            Footer start
        ***********************************-->
        <div class="footer">
            <div class="copyright">
                <p>Copyright © Designed &amp; Developed by > 2020</p>
            </div>
        </div>
        <!--**********************************
            Footer end
        ***********************************-->

        <!--**********************************
           Support ticket button start
        ***********************************-->

        <!--**********************************
           Support ticket button end
        ***********************************-->


    </div>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

    <script type="text/javascript">

        function isNumberKey(evt) {
            var charCode = (evt.which) ? evt.which : evt.keyCode;
            if (charCode != 46 && charCode > 31
                && (charCode < 48 || charCode > 57))
                return false;

            return true;
        }


        var empolyee = $('#edit_empolyee');

        empolyee.on('submit', function (e) {

            e.preventDefault();
            var id = $('#id').val(); // 👈 Get it early!
            var empolyeedata = empolyee.serialize();
            var fullname = $("input#fullname").val();
            var phone = $("input#phone").val();
            var nic = $("#nic").val();
            var depart = $("input#depart").val();
            var designation = $("input#designation").val();
            var salary = $("input#salary").val();
            var over_time = $("input#over_time").val();
            var allowance = $("input#allowance").val();
            var tap_in = $("input#tap_in").val();
            var tap_out = $("input#tap_out").val();
            var tea_petrol = $("input#tea_petrol").val();
            var bank_account = $("input#bank_account").val();
            var email = $("input#email").val();
            var address = $("input#address").val();
            var comments = $("input#comments").val();
            var user_id = $("input#user_id").val();
            var rf_id = $("input#rf_id").val();
            var modified = $("input#modified").val();
            
            var form = $(this)[0]; // Get raw DOM element
            var formData = new FormData(form); 
            $.ajax({
                url: '<?php echo base_url('Admin/updated_get_empolyee/'); ?>' + id,
                type: "post",
                data: new FormData(this),
                processData: false,
                contentType: false,
                cache: false,
                async: false,
                dataType: 'json',
                success: function (data) {
                    if (data.status === 'true') {
                        $("#emp_add").attr('disabled', true);
                        console.log('second' + data.status);
                        $('#empolyee_success').show().html('Empolyee Updated Successfully').hide(3000);
                        setTimeout(function () { location.href = "<?php echo base_url('Admin/empolyee'); ?>" }, 3000);
                    } else {
                        $('#empolyee_issue').show().html('Update Empolyee Some Issues');
                    }
                }
            });
            // }
        });


        function delete_data(id) {
            var id = id;
            if (confirm('Are you sure you want to Delete.?')) {

                $.ajax({
                    type: 'POST',
                    url: '<?php echo base_url('Admin/delete_empolyee/'); ?>' + id,
                    data: id,
                    dataType: 'json',
                    success: function (data) {
                        console.log('first' + data.status);

                        console.log('second' + data.status);
                        //debugger;
                        $('#empolyee_danger').show().html('Empolyee Deleted Successfully');
                        setTimeout(function () { location.href = "<?php echo base_url('Admin/empolyee'); ?>" }, 3000);

                    },
                    error: function (data) { console.log(data.responseText); }
                });
            }

        }


        function btnExport_monthly() {

            var tab_text = "<table border='2px'><tr bgcolor='#ebebeb'>";
            var textRange; var j = 0;
            tab = document.getElementById('example5'); // id of table

            for (j = 0; j < tab.rows.length; j++) {
                tab_text = tab_text + tab.rows[j].innerHTML + "</tr>";
                //tab_text=tab_text+"</tr>";
            }

            tab_text = tab_text + "</table>";
            tab_text = tab_text.replace(/<A[^>]*>|<\/A>/g, "");//remove if u want links in your table
            tab_text = tab_text.replace(/<img[^>]*>/gi, ""); // remove if u want images in your table
            tab_text = tab_text.replace(/<input[^>]*>|<\/input>/gi, ""); // reomves input params


            var ua = window.navigator.userAgent;
            var msie = ua.indexOf("MSIE ");

            if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))      // If Internet Explorer
            {
                txtArea2.document.open("txt/html", "replace");
                txtArea2.document.write(tab_text);
                txtArea2.document.close();
                txtArea2.focus();
                sa = txtArea2.document.execCommand("SaveAs", true, "Generation_School_Report");
            }
            else                 //other browser not tested on IE 11
                sa = window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text));

            return (sa);
        }
    </script>
    <!--**********************************
        Main wrapper end
    ***********************************-->

    <!--**********************************
        Scripts
    ***********************************-->
    <!-- Required vendors -->

    <?php $this->load->view('footer'); ?>

</body>

<!-- Mirrored from edumin.dexignlab.com/xhtml/add-departments.html by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 17 Nov 2020 13:56:15 GMT -->

</html>