<div class="modal fade" id="add-form-container" tabindex="-1" role="dialog" aria-labelledby="editModalLabel"
    aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="editModalLabel">Thêm Mới</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12">
                        <form method="POST" action="">
                            <input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>"
                                value="<?php echo $this->security->get_csrf_hash(); ?>" />
                            <div class="form-row">
                                <span>
                                    <label for="Ngay_ghi_so">Ngày ghi sổ:</label>
                                    <input type="date" name="Ngay_ghi_so" id="Ngay_ghi_so" require
                                        value="<?php echo date('Y-m-d'); ?>"></span>
                                
                                    <div class="form-group" app-field-wrapper="amount">
                                        <label for="So_xe">Số xe:</label>
                                        <select name="So_xe" class="selectpicker form-control" data-width="100%"
                                        data-none-selected-text="Chưa chọn" data-live-search="true" tabindex="-98"
                                        aria-invalid="false">
                                            <?php 
                                            $selected_tai_xe = isset($_GET['so_xe']) ? $_GET['so_xe'] : '';
                                            foreach ($staff as $staffs): 
                                                if($staffs['role']==2 && $staffs['active']==1):
                                            ?>
                                            <option value="<?php echo $staffs['staffid']; ?>" 
                                                <?php echo ($staffs['staffid'] == $selected_tai_xe) ? 'selected' : ''; ?>>
                                                <?php echo $staffs['staff_identifi']?></option>
                                            <?php endif; 
                                            endforeach; ?>
                                        </select>
                                    </div>
                                <span>
                                    <label for="UNG">Ứng</label>
                                    <input type="number" name="UNG" id="UNG"></span>
                                </span>
                                <span>
                                    <label for="QTOAN">Quyết Toán</label>
                                    <input type="number" name="QTOAN" id="QTOAN"></span>
                                </span>
                                <input type="hidden" name="manual_entry" id="manual_entry" value="1" />
                            </div>
                            <button type="submit">Lưu</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script>
document.addEventListener('DOMContentLoaded', function() {
    var formContainer = document.querySelector('#add-form-container');
    var addButton = document.querySelector('#add-button');
    addButton.addEventListener('click', function() {
        $('#add-form-container').modal('show');
    });
});
</script>