<?php 
$this->load->view('site/templates/header');
$this->load->model('product_model');
$this->load->model('user_model');
?>

	<section>
    	<div class="main">
        	<ul class="bread_crumbs">
            	<li><a href="<?php echo base_url(); ?>">Home</a></li>
                <span>›</span>
                <li><a href="view-profile/<?php echo $this->session->userdata['shopsy_session_user_name']; ?>">Profile</a></li>
                <span>›</span>
                <li><a >Conversation</a></li>
            </ul>
            <div class="convers">                
                <div class="conversation_container">
                    <div class="conversation_container_left">
                        <div class="side_bar">
                            <ul>
                                <li <?php if($viewfolder=='inbox'){ echo 'class="active"'; }?>>
                                    <a href="people/<?php echo $this->session->userdata['shopsy_session_user_name'];?>/conversations?qv=inbox">Inbox</a>
                                </li>
                                <li <?php if($viewfolder=='sent'){ echo 'class="active"'; }?>>
                                    <a href="people/<?php echo $this->session->userdata['shopsy_session_user_name'];?>/conversations?qv=sent">Sent</a>
                                </li>
                                <li <?php if($viewfolder=='all'){ echo 'class="active"'; }?>>
                                    <a href="people/<?php echo $this->session->userdata['shopsy_session_user_name'];?>/conversations?qv=all">All</a>
                                </li>
                                <li <?php if($viewfolder=='trash'){ echo 'class="active"'; }?>>
                                    <a href="people/<?php echo $this->session->userdata['shopsy_session_user_name'];?>/conversations?qv=trash">Trash</a>
                                </li>
                            </ul>
                        </div>
                    </div>                    
                    <div class="conversation_container_right">        
                        <?php if ($MessageDetail->num_rows() > 0){ ?> 
                        <?php foreach ($MessageDetail->result() as $row){ ?> 
                        	<table class="tab_form_list_table" align="center" width="100">
                        <thead>     
                            <tr class="table-header">
                            	<?php 
								if($row->sender_id==$this->session->userdata['shopsy_session_user_id']){ 
								$receiverEmail=$row->receiver_email; 
								$receiverID=$row->receiver_id;
								$action='Forward';
								?>
                                	<th><span>To :</span> <?php echo $row->user_name;?></th>
                                <?php }else{ $receiverEmail=$row->sender_email; $receiverID=$row->sender_id; $action='Replay';?>
                                	<th><span>From :</span> <?php echo $row->sender_name;?></th>
                                <?php } ?>
                                <th><span>Date :</span> <?php echo $row->dataAdded;?></th>                                
                                <th><span><a href="javascript:void(0);" class="contact-popup"><?php echo $action; ?></a></span></th>
                            </tr>
                        </thead>
                        <tbody align="center">
                            <tr>                            
                                <td colspan="3" align="left"><strong>Subject:</strong> <?php echo $row->subject;?></td>
                            </tr>
                            <tr>
                                <td colspan="3" align="left"><?php echo $row->message;?></td>
                            </tr>
                        </tbody>
                     </table>
                        <?php } }else{ ?>
                        	No Records Found
                        <?php } ?>
           			</div>
                </div>
			</div>
		</div>
	</section>
<div style='display:none'>
        <div id='contact_reg' style='background:#fff;'>  
            <div style="width:96.7%" class="conversation">
                <div style="padding:20px; width:94.5%;" class="conversation_container">
                    <!--<h2 class="conversation_headline">Replay to : <?php echo $row->username;?></h2>-->
                    <div class="conversation_right" style="width:680px;">
                        <form name="contactpeople" id="contactpeople" method="post" action="site/user/contactpeople" onsubmit="return contactsCheck();">
                            <input class="conversation-subject" type="text" name="subject" id="subject" placeholder="Subject" style="width:610px;" value="" >
                            <textarea class="conversation-textarea" style="width:610px;" rows="11" name="message_text" id="message_text" placeholder="<?php if($this->lang->line('user_msgtxt') != '') { echo stripslashes($this->lang->line('user_msgtxt')); } else echo 'Message text'; ?>"></textarea>
                            <input type="hidden" name="sender_email" id="sender_email" value="<?php echo $this->session->userdata['shopsy_session_user_email']; ?>" >
                            <input type="hidden" name="sender_id" id="sender_id" value="<?php echo $this->session->userdata['shopsy_session_user_id']; ?>" >
                            <input type="hidden" name="receiver_email" id="receiver_email" value="<?php echo $receiverEmail;?>" >
                            <input type="hidden" name="receiver_id" id="receiver_id" value="<?php echo $receiverID;?>" >
                            <input type="hidden" name="current_user" value="<?php echo $this->session->userdata['shopsy_session_user_name']; ?>" >
                            <input type="hidden" name="FromURL" value="Conversation" >
                            <input class="subscribe_btn" type="submit" value="send" style="height: auto; padding: 7px 10px; margin: 10px 0 7px 20px; font-weight: bold;">
                            <span class="error" id="ErrPUP"></span>
                        </form>		
                    </div> 
                </div>
            </div>
        </div>
	</div>
<script>
$(document).ready(function(){

		$(".cboxClose1").click(function(){
			$("#cboxOverlay,#colorbox").hide();
			});
		
			$(".contact-popup").colorbox({width:"765", height:"auto", inline:true, href:"#contact_reg"});
		
			//Example of preserving a JavaScript event for inline calls.
			$("#onLoad").click(function(){ 
				$('#onLoad').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
				return false;
			});

});
</script>


<style>

#cboxLoadedContent{background:none;}


#cboxClose {  right: 15px;
    text-indent: -9999px;
    top: 11px;}
</style>

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