 <? global $vis_language;
   $operationsTicket = array (	0  => $vis_language['MSGNEWTKTCRT'], 
							  	1  => $vis_language['MSGTKTRPLD'], 
								2  => $vis_language['MSGSTSUPD'], 
								3  => $vis_language['MSGPRIOUPD'], 
								4  => $vis_language['MSGDEPTCHNG'], 
								5  => $vis_language['MSGTKTTYPCHG'], 
								6  => $vis_language['MSGFLGCHG'], 
								7  => $vis_language['MSGTKTASSIG'], 
								8  => $vis_language['MSGTKTTRSH'], 
								9  => $vis_language['MSGTKTMRGD'], 
								10 => $vis_language['MSGTKTMRGD'], 
								11 => $vis_language['MSGTKTFRWD'], 
								12 => $vis_language['MSGTKTDELETED'], 
								13 => $vis_language['MSGSLACHG'], 
								14 => $vis_language['MSGSPAMMRK'], 
								15 => $vis_language['MSGUNSPAM'],
								16 => $vis_language['MSGTASKLINKED'],
								17 => $vis_language['TXTDETACHEDATTACHEDTASK'],
								18 => $vis_language['MSGCILINKED'],
								19 => $vis_language['TXTDETACHCI'],
								20 => $vis_language['MSGPROBLEMLINKED'],
								22 => $vis_language['MSGCHANGESLINKED'],
								23 => $vis_language['TXTDETACHEDATTACHEDCHANGE'],
								24 => $vis_language['MSGTICKETLINKED'],
                             	25 => $vis_language['MSGTICKETPOSTDELETE'],  
								26 => $vis_language['MSGTICKETSPLIT'],
								29 => $vis_language['TXTADDLABEL'],
								30 => $vis_language['TXTPINNED'],
								31 => $vis_language['TXTREMOVEDLABEL'],
								33 => $vis_language['MSGTICKETNOTEADDED'],
								34 => $vis_language['MSGTICKETNOTEDELETED'],
								35 => $vis_language['MSGTICKETCOMMENTADDED'],
								36 => $vis_language['MSGTICKETCOMMENTDELETED'],
								42 => $vis_language['MSGADDEDNEWTAG'],
								43 => $vis_language['MSGTICKHASHLINK'],
								44 => $vis_language['MSGNEWSCHEDULETKTCRT'],
								45 => $vis_language['MSGTICKETLEVELCHANGED'],
								46 => $vis_language['MSGTICKETCATEGORYCHANGED'],
								47 => $vis_language['MSGTICKETSUBCATEGORYCHANGED'],
								48 => $vis_language['MSGTICKETITEMCHANGED'],
								49 => $vis_language['MSGITILLOCATIONCHANGED'],
								50=> $vis_language['TXTSLAPAUSED'],
								51=> $vis_language['TXTSLARESUMED'],
								52=>$vis_language['TXTREADTICKETFORSTAFF'],
								53 => $vis_language['TXTSENDTICKETAPPROVAL'],
								54 => $vis_language['TXTCHANGETICKETAPPROVALSTATUS']);								
    $channel_colors=array(1=>'vh-brown-bg', 2=>'vh-green-bg', 3=>'vh-facebook-bgcolor', 4=>'vh-twitter-bgcolor');
 ?>
                      <div class="timeline no-padder" id="vis_recent_activities">
						   <? if($recentActivities != -1 ){
									$cnt = $n = 0;  foreach ($recentActivities as $activity): $n++;
									if($activity['channel_id'] == 3) { if (strpos($activity['image'], 'color')) $activity['image'] = str_replace("color","bgcolor",$activity['image']);}
									?>
									<? if($cnt%5==0) $cnt=0;
									if(($n%2)!=0) { 
										if($activity['operation_id']==2 || $activity['operation_id']==3 || $activity['operation_id']==4 || $activity['operation_id']==5 || $activity['operation_id']==6) $activity_msg=$operationsTicket[$activity['operation_id']].' from '.$activity['old_info'].' to '.$activity['new_info'];
										else if($activity['operation_id']==7){                          
											if($activity['new_info']>0)
												$activity_msg = $operationsTicket[$activity['operation_id']].' to '. $activity['user_info'];
											elseif($activity['new_info']==0 && $activity['old_info']>0)
												$activity_msg = $vis_language['TXTTICKETUNASSIGNEDFROM'].' '. $activity['user_info'];
											elseif($activity['new_info']==0) 
												$activity_msg = $vis_language['TXTTICKETASSIGNEDTONOBODY'];
											else
												$activity_msg = $operationsTicket[$activity['operation_id']];
										}else if($activity['operation_id']==13){
											if($activity['new_info']!='' && $activity['old_info']!='')
												$activity_msg = $vis_language['TXTSLACHANGEDFROM'].' '. $activity['old_info']. ' to '. $activity['new_info'];
				else if($activity['old_info']=='' && $activity['new_info']!='')
					$activity_msg = $vis_language['TXTSLASETTO'].' '. $activity['new_info'];
												else if($activity['new_info']==0)
					$activity_msg = $vis_language['TXTAPPLIEDCUSTOMSLAPLAN'];
										}else if($activity['operation_id']==24) {
											$activity_msg=$activity['old_info'].' '.$operationsTicket[$activity['operation_id']].' '.$activity['new_info'];
										}else if($activity['operation_id']==45 || $activity['operation_id']==46 || $activity['operation_id']==47 || $activity['operation_id']==48 || $activity['operation_id']==49){
													$activity_msg = ($activity['old_info'] == '')?$operationsTicket[$activity['operation_id']].' '.$activity['old_info'].' to '.$activity['new_info']:$operationsTicket[$activity['operation_id']].' from '.$activity['old_info'].' to '.$activity['new_info'];
										}else if($activity['operation_id']==29){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==30){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==31){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==33){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==34){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==35){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==36){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==42){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==43){ // Added by Sachin E.
							   		$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==8 && $activity['old_info']==0 && $activity['new_info']==''){ // Added by Sachin E.
									$activity_msg = $vis_language['TXTTKTMOVEINBOCFROMTRASH'];
							   }else if($activity['operation_id']==14 && $activity['old_info']==1 && $activity['new_info']==0){ // Added by Sachin E.
									$activity_msg = $vis_language['MSGUNSPAM'];				
							   }else if($activity['operation_id']==53){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']].' to '.$activity['old_info'];$activity['operator_id']=0;
							   }else if($activity['operation_id']==50){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']].' to '.$activity['new_info'];$activity['operator_id']=0;
							   }else if($activity['operation_id']==51){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']].' to '.$activity['new_info'];$activity['operator_id']=0;
							   }else if($activity['operation_id']==52){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==54){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']].' to '.$activity['old_info'];$activity['operator_id']=0;
							   }else $activity_msg=$operationsTicket[$activity['operation_id']]; ?>
									<? if($activity['ticket_hash']): ?>	
									 <article class="timeline-item">
										<div class="timeline-caption">
										  <div class="panel panel-default">
											<div class="panel-body">
											  <span class="arrow left"></span>
											  <span class="timeline-icon"><i class="<? echo $activity['image'].' time-icon '.(($channel_colors[$activity['channel_id']]=='')?'vh-grey-bg vh-warning-bg':$channel_colors[$activity['channel_id']]); ?>"></i></span>
											  <span class="timeline-date"><?= format_datetime($activity['entry_date']); ?></span>
											  <div class="text-sm"><a class="link" href="#/ticket/ticket_details/<? echo $activity['ticket_hash']; ?>/<? echo $activity['ticket_id']; ?>" ><? echo $activity['ticket_hash']." : ".$activity['subject']; ?></a></div>
											  <span>  <?  $user_name=($activity['name']!="")?$activity['name'].' - ':''; if($activity['operator_id']!=0) { $user=($activity['operator'] ==1)? ' by '.$user_name.$activity['email']:  ' by '.$activity['name']; } else { $user=""; }?>                          
											   <? echo $activity_msg.$user; ?>
											  </span>
											</div>       
										  </div>
										</div>
									</article>                 
									<? endif; ?><?  } else {
										if($activity['operation_id']==2 || $activity['operation_id']==3 || $activity['operation_id']==4 || $activity['operation_id']==5 || $activity['operation_id']==6) $activity_msg=$operationsTicket[$activity['operation_id']].' from '.$activity['old_info'].' to '.$activity['new_info'];
										else if($activity['operation_id']==7){                          
											if($activity['new_info']>0)
												$activity_msg = $operationsTicket[$activity['operation_id']].' to '. $activity['user_info'];
											elseif($activity['new_info']==0 && $activity['old_info']>0)
												$activity_msg = $vis_language['TXTTICKETUNASSIGNEDFROM'].' '. $activity['user_info'];
											elseif($activity['new_info']==0) 
												$activity_msg = $vis_language['TXTTICKETUNASSIGNED'];
											else
												$activity_msg = $operationsTicket[$activity['operation_id']];
										}else if($activity['operation_id']==45 || $activity['operation_id']==46 || $activity['operation_id']==47 || $activity['operation_id']==48 || $activity['operation_id']==49){
													$activity_msg = ($activity['old_info'] == '')?$operationsTicket[$activity['operation_id']].' '.$activity['old_info'].' to '.$activity['new_info']:$operationsTicket[$activity['operation_id']].' from '.$activity['old_info'].' to '.$activity['new_info'];
											 }else if($activity['operation_id']==29){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==30){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==31){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==33){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==34){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==35){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==36){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==42){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==43){ // Added by Sachin E.
							   		$activity_msg = $operationsTicket[$activity['operation_id']];
							   }else if($activity['operation_id']==8 && $activity['old_info']==0 && $activity['new_info']==''){ // Added by Sachin E.
									$activity_msg = $vis_language['TXTTKTMOVEINBOCFROMTRASH'];
							   }else if($activity['operation_id']==14 && $activity['old_info']==1 && $activity['new_info']==0){ // Added by Sachin E.
									$activity_msg = $vis_language['MSGUNSPAM'];				
							   }else if($activity['operation_id']==53){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']].' to '.$activity['old_info'];$activity['operator_id']=0;
							   }else if($activity['operation_id']==54){ // Added by Sachin E.
									$activity_msg = $operationsTicket[$activity['operation_id']].' to '.$activity['old_info'];$activity['operator_id']=0;
							   }else $activity_msg=$operationsTicket[$activity['operation_id']]; ?>
									<? if($activity['ticket_hash']): ?>	
									<article class="timeline-item alt">
										<div class="timeline-caption">                
										  <div class="panel panel-default">
											<div class="panel-body">
											  <span class="arrow right"></span>
											  <span class="timeline-icon"><i class="<? echo $activity['image'].' time-icon '.(($channel_colors[$activity['channel_id']]=='')?'vh-grey-bg vh-warning-bg':$channel_colors[$activity['channel_id']]); ?>"></i></span>
											  <span class="timeline-date"><?= format_datetime($activity['entry_date']); ?></span>
											  <div class="text-sm"><a class="link" href="#/ticket/ticket_details/<? echo $activity['ticket_hash']; ?>/<? echo $activity['ticket_id']; ?>" ><? echo $activity['ticket_hash']." : ".$activity['subject']; ?></a></div>
											  <span>   <? $user_name=($activity['name']!="")?$activity['name'].' - ':''; if($activity['operator_id']!=0) { $user=($activity['operator'] ==1)? ' by '.$user_name.$activity['email']:  ' by '.$activity['name']; } else { $user=""; }?>                          
												<? echo $activity_msg.$user; ?>
											  </span>
											</div>
										  </div>
										</div>
									</article>          
									<? endif; ?> <? } $cnt++;?>       							
									<? endforeach;?>	
								</div>
							 <?} if($load_more_activities != ''){ ?>
								  <div id="load_more_activities1" onclick="javascript:load_more_recent_activities1(<?= $page+1;?>);">
								<div style="text-align: center;">
									<span class="link vis-pointer"><?= $vis_language['TXTLOADMORE'];?></span>
								</div>
								</div><? } ?>

											
<script>
 function load_more_recent_activities1(page){
	$.post("index.php?vis_module=home&vis_operation=load_more_recent_activities&vis_tmpst="+new Date().getTime(),{'vis_page': page}, function(data) {	
	$("#load_more_activities1").last().remove();
	$("#vis_recent_activities").last().append(data);
	/*if(data.length > 1){		
		$("#vis_left_panel_div nav ul.nav-main").last().append(data[0]);
		$("#load_more_activities").before(data[1]);
	}
	else
		$("#load_more_activities").before(data);
		$(".vis_leftpanel_domain_span").last().remove();
	}, 'json');*/
});
}
</script>
