<? for($i=0;$i<$post_count;$i++) { ?>
<article class="panel panel-default pos-rlt clearfix m-b-md vis_max_img_size" id="post_<?= $post_details[$i]['post_id'];?>">
 <div class="b-light padder-v col-sm-12 ">
     <div class="col-sm-8 no-padder">
        <div class="pull-left clear">
            <? if($staffSettings[0]['content']==1 && $post_details[$i]['submitter']==0) $image=($post_details[$i]['image']!='')?$post_details[$i]['image']:'default.jpg'; 
               elseif($staffSettings[0]['content']==0 && $post_details[$i]['submitter']==0) $image='default.jpg';
               else $image=($post_details[$i]['image']!='')?$post_details[$i]['image']:'default.jpg'; ?>
               <? if($post_details[$i]['image']=='' || $post_details[$i]['image']=='default.jpg'){?>
<div class="l-avatar m-r-sm">
<? if($post_details[$i]['full_name']!=''){
$namearr=explode(' ',$post_details[$i]['full_name']);
$fullname='';
if(count($namearr)>1){ 
$lastname=preg_split('//u', $namearr[1], -1, PREG_SPLIT_NO_EMPTY); 
$firstname=preg_split('//u', $namearr[0], -1, PREG_SPLIT_NO_EMPTY);
$fullname=ucfirst($firstname[0]).ucfirst($lastname[0]);
}else{
	$firstname=preg_split('//u', $namearr[0], -1, PREG_SPLIT_NO_EMPTY);
	$fullname=ucfirst($firstname[0]);
}
	?>
   <div class="thumb"><? echo $fullname;?></div>
    <? }else{ ?>
    <img src="<?= VIS_PATH_PROFILE.'default.jpg';?>">
    <? }?>

</div>
<? }else{ ?>
<div class="l-avatar m-r-sm">
<img src="<?php echo VIS_PATH_PROFILE.$image; ?>" >
</div>
<? }?>
            <!--<a class="thumb m-r-sm avatar"><img src="<?php //echo VIS_PATH_PROFILE.$image; ?>"></a>-->
        </div>
        <div class="col-sm-10">
            <? if($staffSettings[0]['content'] == 1): ?>
                <span class="font-bold"><?= ($post_details[$i]['submitter']==0)?$vis_language['TXTSTAFF']:$vis_language['TXTCLIENT']; ?></span><span class="m-l-xs"><?php echo $post_details[$i]['full_name']; ?></span>	
            <? else: ?>
                <? if($post_details[$i]['submitter']!=0): ?>
                    <span class="font-bold"><?= $vis_language['TXTCLIENT']; ?></span> <span><?php echo $post_details[$i]['full_name']; ?></span>
                <? else: ?>
                    <span class="font-bold"><?= $vis_language['TXTSTAFF']; ?></span> 
                <? endif; ?>
            <? endif; ?>
        </div>
         <div class="col-sm-10"><span><?php echo $post_details[$i]['submitter_email']; ?></span></div>
        <div class="col-sm-10">
            <? /*if($post_details[$i]['as_client']==1){
                echo '<span class="font-bold">'.$vis_language['TXTTICKETCREATEDBY'].'</span> <span>'.$post_details[$i]['submitter_name'].'</span>';
            }
            else*/ if(isset($post_details[$i]['receiver_to']) && $post_details[$i]['receiver_to']!=""){?>				
            <label class="font-bold"><?= ($post_details[$i]['reply_forward']==0) ? $vis_language['TXTTO'] : (($post_details[$i]['reply_forward']==1) ? $vis_language['TXTREPLIEDTO'] : $vis_language['TXTFORWARDEDTO']);?></label>
            <span><?= str_replace(',', ', ', $post_details[$i]['receiver_to']);?></span>
           <? } else echo "&nbsp;"; ?>
        </div>
     </div>
	
     <div class="col-sm-4 no-padder">
       <div class="pull-right m-r"><span class="font-bold"><? echo $vis_language['TXTPOSTON']; ?></span><span class="text-muted m-l-xs"><?php echo format_datetime($post_details[$i]['receive_date']); ?></span></div>
     </div>
		<? 	if($post_details[$i]['submitter'] && $post_details[$i]['submitter_id']==$ticket_details['client_id'] && $post_details[$i]['received_via']==1)
				echo '<span class="">'.$vis_language['TXTVIACLIENTPORTAL'].'</span>';
		 ?>
	</div>
	<div class="line b-b col-sm-12"></div>
	<div class="chat-item m-b col-sm-12 vh-ticket-post">
		<div><?php 	if (extension_loaded('mbstring')) { // chk if mbstring module loaded
						$post_details[$i]['content'] = get_substitute_entities($post_details[$i]['content']); // replace missing html entity
					}
			preg_match('/(<img[^>]+>)/i', $post_details[$i]['content'], $matches);echo $post_details[$i]['content']; ?></div>
		</div>
	<? if($post_details[$i]['attachment']!=-1) { ?>	  
	  <div class="chat-item m-b m-l">
      
		<div class="vis_content_post_area"><? 
			for($j=0;$j<count($post_details[$i]['attachment']);$j++) 
				echo '<div class="btn-group wrapper-xxs"><a href="'.$post_details[$i]['attachment'][$j]['domain_url'].'?vis_module=export&vis_operation=get_attachment&vis_client_id='.$ticket_details['client_id'].'&vis_attachment='.$post_details[$i]['attachment'][$j]['attachment_id'].'&auth='.$ticket_details['salt'].'"><label class="btn btn-xs alert-success">'.$post_details[$i]['attachment'][$j]['file_name'].'</label></a></div>'; ?>
		</div> 
	  </div><? }?>
</article><? } ?>
