
<div class="col-sm-8">

    <div class="row gray_ttc">
        <br>

        <div class="col-sm-5 col-sm-offset-1 text-left" style="padding: 10px">
            <strong>Message</strong>
        </div>

        <div class="col-sm-5  text-right" >
            <!--<a href=""> <i class="fa fa-reply" title="Reply"> </i></a>&nbsp;&nbsp;-->

            <a href="javascript:;" onclick="remove_invitation_msg(<?php echo $invitation_details_view->invitation_message_id?>)" > <i class="fa fa-trash-o" title="Remove"></i></a>&nbsp;&nbsp;
            
            <a href="javascript:;" onclick="unread(<?php echo $invitation_details_view->invitation_message_id?>)" id="unread"> 
                <i class="fa fa-envelope" title="Mark as Unread" > </i></a>&nbsp;&nbsp
          
         
           <a href="javascript:;" onclick="read(<?php echo $invitation_details_view->invitation_message_id?>)" id="read" style="display: none; "> <i class="fa  fa-envelope-o" title="Mark as Read"> </i></a> &nbsp;&nbsp;
          

   <!--<a href="#"><i class="fa fa-envelope" title=""></i>-->

        </div>

        <div class="col-sm-10 col-sm-offset-1 ">
            <hr><br>
        </div>


        <div class="col-sm-10 col-sm-offset-1 text-left" style="padding: 0">
            <div class="col-sm-12 " style="padding: 0">

                <div class="col-sm-2">Form</div>
                <div class="col-sm-1">:</div>
                <div class="col-sm-9"><?php echo $person_info->person_email; ?></div>

            </div>
            <input type="hidden" name="invitation_message" id="invitation_message" value="<?php echo $invitation_details_view->invitation_message_body; ?>" >              
            <div class="col-sm-12 " style="padding: 0">
                <div class="col-sm-2">Date</div>
                <div class="col-sm-1">:</div>
                <div class="col-sm-9"><?php echo date('h:i a', strtotime($invitation_details_view->invitation_message_datetime)) . "," . "&nbsp;";
echo date('d F y', strtotime($invitation_details_view->invitation_message_datetime)) . ".";
?></div>

            </div>
            <div class="col-sm-12 " style="padding: 0">
                <div class="col-sm-2">To</div>
                <div class="col-sm-1">:</div>

                <div class="col-sm-9">


                    <span id="fewContent">
                        <?php
                        $email = array();
                        $email = explode(",", $invitation_details_view->invitation_receiver_email);
                        echo $email[0];
                        ?>

                    </span>
                    <span id="moreContent" style="display: none">
<?php echo $invitation_details_view->invitation_receiver_email; ?>
                    </span>

                    <a id="more" class="text-right" href="#" onclick=" ViewMoreContent();">More..</a>
                    <a id="less" style="display: none" class="text-right" href="#" onclick="LessMoreContent('')">Less..</a>

                </div>
            </div>
            <script>

                function ViewMoreContent() {

                    var less = document.getElementById('less');
                    var more = document.getElementById('more');
                    var fewContent = document.getElementById('fewContent');
                    var moreContent = document.getElementById('moreContent');
                    moreContent.setAttribute('style', 'display:block');
                    fewContent.setAttribute('style', 'display:none');
                    more.setAttribute('style', 'display:none');
                    less.setAttribute('style', 'display:inline');

                }
                function LessMoreContent() {

                    var less = document.getElementById('less');
                    var more = document.getElementById('more');
                    var moreContent = document.getElementById('moreContent');
                    var fewContent = document.getElementById('fewContent');
                    moreContent.setAttribute('style', 'display:none');
                    fewContent.setAttribute('style', 'display:block');
                    more.setAttribute('style', 'display:inline');
                    less.setAttribute('style', 'display:none');

                }

            </script>

            <div class="col-sm-12 " style="padding: 0">
                <br>
                <div class="col-sm-2">Subject</div>
                <div class="col-sm-1">:</div>
                <div class="col-sm-9"><a id="hello" href="javascript:;" onclick="preview3('<?php echo $invitation_details_view->course_id; ?>')"><?php echo $invitation_details_view->invitation_message_subject; ?></a></div>

            </div>

        

        </div>



        <div class="col-sm-12" id="email_preview"></div>
        <div class="col-sm-10 col-sm-offset-1 ">
            <hr> <br>
        </div>
        <div class="form-group  col-sm-10 col-sm-offset-1 ">
            <div class="input-group">

                <div class="message_show text-justify "></div> 









            </div>
        </div>


    </div>

</div>

<script>
   
    function preview3(course_id) {
        //alert(course_id);

       var invitationMessage = document.getElementById('invitation_message').value;
      //alert(invitationMessage);
 
       var formdata = new FormData();
       formdata.append("message", invitationMessage);
       xmlhttp.open("POST",'<?php echo base_url() ?>'+'preview_email/'+course_id );

       xmlhttp.addEventListener("load", function () {
          _("email_preview").innerHTML = xmlhttp.responseText;
     }, false);

      xmlhttp.send(formdata);

    }
     function unread(message_id)
   {
       
       
    var xmlhttp1 = false;
        try {
            xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp1 = false;
            }
        }
        if (!xmlhttp1 && typeof XMLHttpRequest != 'undefined') {
            xmlhttp1 = new XMLHttpRequest();
        }
       var url= '<?php echo base_url();?>'+'invitation-unread';
        
        //alert(message_id);
        
        var formdata = new FormData();
        formdata.append("message_id",message_id);
        
        
        xmlhttp1.addEventListener("load", function () {
          //  alert(xmlhttp1.responseText);
            if(xmlhttp1.responseText == "allow"){
                 
                var unread = document.getElementById('unread');
                    unread.setAttribute('style','display:none');
               var read=document.getElementById('read');
               read.setAttribute('style','display:inline');
            }
         
              
            }, false);
            xmlhttp1.addEventListener("error", function () {
                alert("not sent");
            }, false);
            xmlhttp1.addEventListener("abort", function () {
                alert("Aborted");
            }, false);

            xmlhttp1.open("POST", url);
            xmlhttp1.send(formdata);

        
    
        
    }
    function read(message_id)
    {
     
       
    var xmlhttp2 = false;
        try {
            xmlhttp2 = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp2 = false;
            }
        }
        if (!xmlhttp2 && typeof XMLHttpRequest != 'undefined') {
            xmlhttp2 = new XMLHttpRequest();
        }
       var url= '<?php echo base_url();?>'+'invitation-read';
        
       // alert(message_id);
        
        var formdata = new FormData();
        formdata.append("message_id",message_id);
        
        
        xmlhttp2.addEventListener("load", function () {
             
                //alert(xmlhttp1.responseText);
            if(xmlhttp2.responseText == "allow"){
                alert(xmlhttp2.responseText);
                 var read=document.getElementById('read');
               read.setAttribute('style','display:none');
                var unread = document.getElementById('unread');
                    unread.setAttribute('style','display:inline');
              
            }
         
              
            }, false);
            xmlhttp2.addEventListener("error", function () {
                alert("not sent");
            }, false);
            xmlhttp2.addEventListener("abort", function () {
                alert("Aborted");
            }, false);

            xmlhttp2.open("POST", url);
            xmlhttp2.send(formdata);

        

        
    }
    function  remove_invitation_msg(invitation_message_id){
      //alert(invitation_message_id);
      swal({
                title: "", text: "Do you really want to delete the entire conversation??",
                showCancelButton: true,
                confirmButtonColor: '#DD6B55',
                confirmButtonText: 'Yes!',
                cancelButtonText: "No", closeOnConfirm: true,
                closeOnCancel: true
            },
            function (isConfirm) {
                if (isConfirm) {
                 
                 var xmlhttp5 = false;
        try {
            xmlhttp5 = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp5 = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp5 = false;
            }
        }
        if (!xmlhttp5 && typeof XMLHttpRequest != 'undefined') {
            xmlhttp5 = new XMLHttpRequest();
        }
        var url= '<?php echo base_url();?>'+'rcv-invitation-msg-remove';
        //var message_id=invitation_message_id;
        //  alert(invitation_message_id);
        
        var formdata = new FormData();
        formdata.append("invitation_message_id",invitation_message_id);
       // formdata.append("message_attachmen_id",messageAttachid);
        
        xmlhttp5.addEventListener("load", function () {
           //alert(xmlhttp5.responseText);
           if(xmlhttp5.responseText==='redirect'){
               location.href = "invitations-received-message";
           }
            
              
            }, false);
            xmlhttp5.addEventListener("error", function () {
                alert("not sent");
            }, false);
            xmlhttp5.addEventListener("abort", function () {
                alert("Aborted");
            }, false);

            xmlhttp5.open("POST", url);
            xmlhttp5.send(formdata);

        
                }
            });

  }


</script>



