<?
global $vis_language;
if($blabs!=-1) 
{
	for($i=0;$i<count($blab_list);$i++)
	{
?>
<form name="vis_blab_form_<? echo $blab_list[$i]['info']['blab_id']; ?>" id="vis_blab_form_<? echo $blab_list[$i]['info']['blab_id']; ?>" class="form-horizontal" onsubmit="return false;">
	  <article class="chat-item chat-item-b left">
   <? if($blab_list[$i]['info']['image_name']!='' && is_file(VIS_PATH_PROFILE.$blab_list[$i]['info']['image_name']) && $blab_list[$i]['info']['image_name']!='default.jpg'){?>
   	<div class="l-avatar pull-left m-t-lg">
				<img src="<?= VIS_PATH_PROFILE.$blab_list[$i]['info']['image_name'];?>" class="sm">
		    </div>
   <? }else{?>
   <div class="l-avatar pull-left m-t-lg">
   <? if($blab_list[$i]['info']['first_name']!=''){
				$firstname=preg_split('//u', $blab_list[$i]['info']['first_name'], -1, PREG_SPLIT_NO_EMPTY);
$lastname=preg_split('//u', $blab_list[$i]['info']['last_name'], -1, PREG_SPLIT_NO_EMPTY);
				?>
    <div class="sm"><? echo ucfirst($firstname[0]).ucfirst($lastname[0]);?></div>
    <? }else{ ?>
    <img class="sm" src="<?= VIS_PATH_PROFILE.'default.jpg';?>">
    <? }?>
				
		    </div>
   <? }?>
   
	<!--	<a href="#" class="pull-left m-t-lg thumb-sm avatar">			
			<img src="<? //= VIS_PATH_PROFILE.($blab_list[$i]['info']['image_name']!='' && is_file(VIS_PATH_PROFILE.$blab_list[$i]['info']['image_name']) ? $blab_list[$i]['info']['image_name'] : 'default.jpg');?>">		
		</a>-->
		<span class="font-bold text-default m-l"><? echo $blab_list[$i]['info']['first_name'].' '.$blab_list[$i]['info']['last_name'] ?></span>
		<small class="text-muted m-l-sm"><?echo format_datetime($blab_list[$i]['info']['entry_date']); ?></small>
		<? if($blab_list[$i]['info']['owner'] == VIS_STAFF_ID): ?>					
			<button data-dismiss="modal" class="close" type="button" title="<? echo $vis_language['TXTDELETE']; ?>" data-toggle="ajaxModal" data-modal-arguments="vis_module=blabber&vis_operation=get_delete_blab&vis_blab_id=<? echo $blab_list[$i]['info']['blab_id'] ?>&vis_static_area=vis_blab_form_<? echo $blab_list[$i]['info']['blab_id']; ?>" >×</button>
		<? endif; ?>
		<section class="chat-body m-t-xs">
		  <div class="panel b-light m-b-none">
			<div class="panel-body">
			  <span class="arrow left"></span>
			  <p class="m-b-none br_wd"><? echo $blab_list[$i]['info']['content']; ?></p>
				<? 
				if($blab_list[$i]['attachment']!=-1) {?>		
				<? 
				$img = $attach = "";
				for($j=0;$j<count($blab_list[$i]['attachment']);$j++){
					$blab_attach=$blab_list[$i]['attachment'][$j];	
					if(strpos($blab_attach['file_type'],'image')!== false)
					{ 
						$img.='<span class="thumb-lg m-r-xs m-t-xs"><span class="thumbnail">
									<img src="'.VIS_PATH_FILES.$blab_attach['content'].'" class="bg-white img-responsive" />
							   </span></span>';
					 }
					else
					{
						$attach.='<span class="m-r-xs m-t-xs"><div class="btn-group wrapper-xxs"><a href="?vis_module=export&vis_operation=get_attachment&vis_attachment='.$blab_attach['attachment_id'].'&'.VIS_STAFF_COOKIE.'='.$_COOKIE[VIS_STAFF_COOKIE].'"><label class="btn btn-xs alert-success">'.$blab_attach['file_name'].'</label></a></div>
						</span>';
					}			
				}
					if(($attach!="" && $img!="") || $attach!='')
					{
						echo $img.'<div class="line b-b line-lg pull-in"></div></br>'.$attach;
					}
					else
					{
						echo $img.$attach;
					}
				}  ?> 
				<? 
				if($blab_list[$i]['info']['owner'] == VIS_STAFF_ID): ?>
					<? 
					
					  if(!empty($sharedStaff)): 
						  if(array_key_exists($blab_list[$i]['info']['blab_id'],$sharedStaff)):?>			
							<p class="m-b-none"><span class="font-bold"><? echo $vis_language['TXTBLABSHAREDWITH']." : ";?></span><? echo $sharedStaff[$blab_list[$i]['info']['blab_id']]; ?></p>
						<? endif;
					 endif; ?>
				<? endif; ?>
			</div>
		  </div>
		</section>
	  </article>
	  <div id="vis_blab_comment_list_<? echo $blab_list[$i]['info']['blab_id']; ?>">
	  <? for($j=0;$j<count($blab_list[$i]['comment']);$j++){ if($blab_list[$i]['comment']!=-1) {
            $blabId = $blab_list[$i]['info']['blab_id'];
            $blab_comment=$blab_list[$i]['comment'][$j];
            include(VIS_PATH_TEMPLATE.'blab_comment_list.php');
            
        }} ?>
      </div> 
      <article class="chat-item chat-item-comment left">
      <? if($staffs[0]['image_name']!='' && is_file(VIS_PATH_PROFILE.$staffs[0]['image_name']) && $staffs[0]['image_name']!='default.jpg' ){?>
      <div class="l-avatar pull-left m-t-lg">
				<img src="<?= VIS_PATH_PROFILE.$staffs[0]['image_name'];?>" class="sm">
		    </div>
      <? }else{ ?>
      <div class="l-avatar pull-left m-t-lg">
      <? if($staffs[0]['first_name']!=''){
							$firstname=preg_split('//u', $staffs[0]['first_name'], -1, PREG_SPLIT_NO_EMPTY);
$lastname=preg_split('//u', $staffs[0]['last_name'], -1, PREG_SPLIT_NO_EMPTY);
							?>
    <div class="sm"><? echo ucfirst($firstname[0]).ucfirst($lastname[0]);?></div>
    <? }else{ ?>
    <img class="sm" src="<?= VIS_PATH_PROFILE.'default.jpg';?>">
    <? }?>
				
		    </div>
      <? }?>
      
			
      
		<!--<a href="#" class="pull-left m-t-lg thumb-sm avatar">
			<img src="<? //= VIS_PATH_PROFILE.($staff[0]['image_name']!='' && is_file(VIS_PATH_PROFILE.$staff[0]['image_name']) ? $staff[0]['image_name'] : 'default.jpg');?>">	
		</a>-->
		<span class="font-bold text-default m-l"><? echo $staff[0]['first_name'].' '.$staff[0]['last_name'] ?></span>
		<section class="chat-body m-t-xs">
		  <div class="panel bg-light dk text-sm m-b-none">
			<div class="panel-body">
			  <span class="arrow left"></span>				
				<div class="input-group">
					<input class="input-sm form-control input-s-sm" type="text" name="vis_blab_comment" id="vis_blab_comment_<? echo $blab_list[$i]['info']['blab_id']; ?>" placeholder="<? echo $vis_language['TXTTYPECOMMENTHERE']; ?>">
					<div class="input-group-btn">
						<? $shared_staff_list = ($sharedStaffId[$blab_list[$i]['info']['blab_id']]!='')?$sharedStaffId[$blab_list[$i]['info']['blab_id']].','.$blab_list[$i]['info']['owner']:$blab_list[$i]['info']['owner'];?>
						<button class="btn btn-sm btn-default" id="blabComment" type="button" onclick="$(this).visExecution('submit_form',{'vis_module':'blabber', 'vis_operation':'comment_blab', 'vis_form':'vis_blab_form_<? echo $blab_list[$i]['info']['blab_id']; ?>' ,'vis_staff_id_list':'<? echo $shared_staff_list; ?>'})"><? echo $vis_language['TXTPOST'];?></button>
					</div>
				</div>				
			</div>
		  </div>
		</section>
	  </article>  	
	<input type="hidden" name="vis_blab_id" value="<? echo $blab_list[$i]['info']['blab_id']; ?>" />
</form>		  
 <? } 
	 if(isset($staffView) && $staffView !='')
	 { $staffID = $staffView[0]['staff_id'];}
	 else
	 { $staffID = $staff[0]['staff_id'];}
	 if(!isset($criteria))
	 {
		 $criteria='';
	 }
     if($page!=0)echo '<script>$("#vis_blab_more_cmd_'.$area.'").remove(); </script>';
	 if( $remain== 1) echo '<div class="btn btn-default m-b-lg m-t-lg btn-block" href="#" id="vis_blab_more_cmd_'.$area.'" onclick="$(\'#'.$area.'\').visExecution(\'load_area\', {\'vis_module\':\'blabber\', \'vis_operation\':\''.$operation['vis_operation'].'\', \'vis_action\':\'no_load\', \'vis_dadd_type\':\'yes\', \'vis_staff_id\':\''.$staffID.'\', \'criteria\': \''.$criteria .'\',\'vis_page\':'.($page+1).((isset($operation['vis_trend']) && $operation['vis_trend']!='')?', \'vis_trend\':\''.trim($operation['vis_trend']).'\'':'').'})">More</div>'; 
    }
    else { 
		if($page==0)
		{
			echo "<div class='com-sm-12 clearfix'>";
            echo '<section class="wrapper fullFrame b-light"><div class="fullMiddle">'.$vis_language['TXTNOTHINGTODISPLAY'].'</div></section>';
            echo '</div><script>$("#vis_blab_more_cmd_'.$area.'").remove(); </script>';
		}
		else
		{
			echo '<script>$("#vis_blab_more_cmd_'.$area.'").remove(); </script>';
		}
		}
		?>
