<div class="col-sm-8">
    <div class="row ">
        <div class="col-sm-12 " style="padding: 0">
            <div class="col-sm-12" >
                <h3 class="pull-right">&nbsp;
                    <a href="<?php echo base_url() ?>send-message"> <span style="font-size: 18px;padding: 10px"><i class="fa fa-envelope" title=" Send Message"></i></span></a>
                    <a href="<?php echo base_url() ?>reply-message"> <span style="font-size: 18px;padding: 10px"><i class="fa  fa-mail-reply" title="Reply Message"></i></span></a>
                    <a href="javascript:;" onclick="dustbin();"> <span style="font-size: 18px;padding: 10px"><i class="fa fa-trash-o" title="Delete "></i></span></a>
                </h3>
            </div>
            <div class="col-sm-12" >
                <div class="col-sm-12 gray_ttc text-left" style="border-bottom: 2px solid #8CC73F;font-weight: bold">
                    <div class="col-sm-4" style="padding:10px 0">
                        <div class="checkbox checkbox-success">
                            <input id="checkbox1" name="checkbox1"class="styled" type="checkbox" ><label for="checkbox1" > <strong>Sender</strong></label>

                        </div>
                    </div>
                    <div class="col-sm-4" style="padding:23px 0">Message</div>
                    <div class="col-sm-4" style="padding:23px 0">Date & Time</div>
                </div>
                <div class="col-sm-12"><br></div> 

<?php 
if($rcv){
foreach ($rcv as $val){
    if($receive_message[$val->message_id]){
     
    ?>
                <div class="col-sm-12 gray_ttc text-left" >

                    <div class="col-sm-4" style="padding:10px 0">
                        <div class="checkbox checkbox-success">
                            <input class="checkbox2" name="checkbox2[]" class="styled" type="checkbox" value="<?php echo $val->message_id ?>" ><label for="checkbox2" >
                                <a href="#"><?php foreach( $person_name[$val->sender_id] as $name){
                                    //print_r($name->person_id);
                                        echo $name->person_email;
                                        $recieve_id =$val->receiver_id; 
                                        $recieve_id_array=explode(",", $recieve_id);
                                        echo "(".count($recieve_id_array).")";
                                
                               
                                }
                                ?></a></label>

                        </div>

                    </div>
                    <div class="col-sm-4" style="padding:23px 0">
                        <p class="text-left col-sm-12">
                            <?php 
                            $message_view=$val->message_viewer_id;
                            $message_view_array=  explode(",",$message_view);
                            //print_r($message_view_array);
                           
                            $user_id = $this->session->userdata('user_id');
                            if(!in_array($user_id,$message_view_array)){ ?>
                            <strong>
                          <?php 
                            $mess= $receive_message[$val->message_id]->message_body; 
                            echo substr($mess, 0,20)."...";
                 
                            ?>
                            </strong>
                            
                            <?php }
                            else { ?>
                           
                          <?php 
                            $mess= $receive_message[$val->message_id]->message_body;
                            echo substr($mess, 0,20)."...";
                            }
                            ?>
                         
                            
                             <?php 
                                  foreach($receive_message_attachment[$val->message_id] as $value){
                                  
                                      if($value->message_receiver_attachment){
                                  
                            ?>
                            <i class="fa fa-paperclip" style="color: #80c12c;"></i>
                                  <?php } break;}?>
                            <a href="<?php echo base_url() ?>view-received-message/<?php $message_id= $this->encrypt->encode($val->message_id);echo str_replace("/","%F2", $message_id); ?>">
                           View
                        </a>
                      
                        </p>
                        
                    </div>

                    <div class="col-sm-4" style="padding:23px 0">
                        <p>
                            
                            <?php                                                        
                         $today_day= date("d m");
                          $message_day=date("d m",strtotime($receive_message[$val->message_id]->message_datetime));
                          $today_year=date("y");
                          //echo $today_year;
                          $message_year=date("y",strtotime($receive_message[$val->message_id]->message_datetime));
                          //echo $message_year;
                          if($message_year==$today_year){
                          if($today_day>$message_day)
                         {
                        echo date('h:i a' , strtotime($receive_message[$val->message_id]->message_datetime)).",";
                        echo date('d F'  , strtotime($receive_message[$val->message_id]->message_datetime));
                             
                         }
                        else {
                        echo date('h:i a' , strtotime($receive_message[$val->message_id]->message_datetime))."<br>";
                        
                        }
                          }
                          else 
                          {
                        echo date('h:i a' , strtotime($receive_message[$val->message_id]->message_datetime)).",";
                        echo date('d F y'  , strtotime($receive_message[$val->message_id]->message_datetime));
                          }
                        ?> 
                        </p>
                    </div>
                </div>
                <div class="col-sm-12"><br></div> 


    <?php } } }?>

            </div>
        </div><!-- /.row gray -->
    </div>
</div>