<div class="col-sm-12 gray_ttc text-center" style="border-bottom: 2px solid #8CC73F;padding: 10px 0 10px 0;font-weight: bold">

    <div class="col-sm-4" style="padding: 0">Note</div>
    <div class="col-sm-4" style="padding: 0">By</div>
    <div class="col-sm-2" style="padding: 0">Date</div>
    <div class="col-sm-2" style="padding: 0">Action</div>
</div>
<div class="col-sm-12"><br></div> 
 <input type="hidden" name="url_id" id="url_id" value="<?php echo $group_url; ?>">
<span class="padding-zero" id="view_group_note">
    <?php
    $user_id = $this->session->userdata('user_id');
    if ($group_note_post) {
        foreach ($group_note_post as $v_note) {
            ?>
            <div class="col-sm-12 gray text-center" >

                <div class="col-sm-4" style="padding: 10px 0 0 0  "> 
                    <?php
                    $mess = $v_note->post_details;
                    echo substr($mess, 0, 50) . "...";
                    ?>
                    <a href="<?php echo base_url() . 'view-content-group/' . $this->utility_model->encode_id($v_note->post_id, '/', 'Tt') . '/1'; ?>">view</a>
                </div>
                <div class="col-sm-4" style="padding: 10px 0 0 0; cursor: pointer; color: #80c12c;" id="viewGroup<?php echo $v_note->url ?>">
                    <?php
                    //echo $v_note->person_first_name . ' ' . $v_note->person_last_name; 
                    if (strlen($v_note->person_first_name) && strlen($v_note->person_last_name) < 20) {
                        echo $v_note->person_first_name . ' ' . $v_note->person_last_name;
                    } else {
                        echo substr($v_note->person_first_name, 0, 30) . ' ' . substr($v_note->person_last_name, 0, 20) . '...';
                    }
                    ?>
                </div>
                <div class="col-sm-2" style="padding: 10px 0 0 0  ">
                    <?php echo $v_note->post_date_time; ?>
                </div>

                <div class="col-sm-2" style="padding: 10px 0 0 0  ">

                    <?php
                    $post_status = $v_note->post_status;
                    if ($v_note->posted_by == $user_id || $group_details->group_created_by == $user_id) {
                        if ($post_status != 2) {
                            ?>
                            <a href="#" onclick="return checkForDelete('<?php echo $v_note->post_id; ?>', '<?php echo $group_details->group_id; ?>')"><i class="fa fa-trash-o" title="Delete"></i></a>&nbsp;&nbsp;
                            <?php
                        }
                    }
                    ?>

                </div>
            </div>
            <div class="col-sm-12"><br></div>
                <?php
            }
        }
        ?>
</span>
        <?php echo $group_detail_note_pagination_link; ?>
<script>
    function checkForDelete(post_id, group_id) {
        swal({
            title: "",
            text: "Are you sure you want to Delete this Group Member?",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: '#8CC73F',
            confirmButtonText: 'Yes',
            cancelButtonText: "No",
            closeOnConfirm: true,
            closeOnCancel: true
        },
                function (isConfirm) {
                    if (isConfirm) {
                        var xmlhttp4 = false;
                        try {
                            xmlhttp4 = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch (e) {
                            try {
                                xmlhttp4 = new ActiveXObject("Microsoft.XMLHTTP");
                            } catch (E) {
                                xmlhttp4 = false;
                            }
                        }
                        if (!xmlhttp4 && typeof XMLHttpRequest != 'undefined') {
                            xmlhttp4 = new XMLHttpRequest();
                        }



                        var url = '<?php echo base_url(); ?>' + 'remove-fornt-group-media-file-backend';
                        //   alert(post_id);
                        // var group_id=document.getElementById("group_id").value;
                        var url_name = document.getElementById("url_id").value;

                        var formdata = new FormData();
                        formdata.append("post_id", post_id);
                        formdata.append("group_id", group_id);

                        xmlhttp4.addEventListener("load", function () {
                            //  alert( xmlhttp4.responseText);
                            if (xmlhttp4.responseText == 1) {
                                swal('you can not delete this group.');

                            } else {
                                window.location = '<?php echo base_url(); ?>' + 'group/' + url_name + '/note';

                            }


                        }, false);
                        xmlhttp4.addEventListener("error", function () {
                            alert("not upload");
                        }, false);
                        xmlhttp4.addEventListener("abort", function () {
                            alert("Aborted");
                        }, false);

                        xmlhttp4.open("POST", url);
                        xmlhttp4.send(formdata);
                    }
                });
    }
    $(document).ready(function () {
        var ajaxGroupUrl = '<?php echo base_url('group/ajax-group-post'); ?>';
        $(document).on('click', 'div[id^="viewGroup"]', function () {
            var url = this.id.replace('viewGroup', '');
            var groupUrl = $('#url_id').val();

            $.post(ajaxGroupUrl, {person_url: url, group_url: groupUrl, type: 1}, function (data) {
                $('#view_group_note').html(data);
            });
        });
    });
</script>