<?php
$unread_class = '';
$message = Wo_GetMessagesHeader(array('user_id' => $wo['message']['user_id']), 1);
if (!empty($message['from_id'])) {
   if ($message['seen'] == 0 && $wo['message']['user_id'] == $message['from_id']) {
    $unread_class = ' unread';
   }
   $message['text'] = mb_substr( $message['text'], 0, 70, "utf-8") . '...';
}

$message_event = "Wo_OpenChatTab({$wo['message']['user_id']});";

if (strpos($_SERVER["HTTP_REFERER"], 'messages') !== false) {
   $message_event = "Wo_GetUserMessages({$wo['message']['user_id']},'{$wo['message']['name']}');";
}

?>
<li>
   <div class="notification-list messages-list <?php echo $unread_class;?>" onclick="<?php echo $message_event ?>">
         <div class="notification-user-avatar <?php echo Wo_RightToLeft('pull-left');?>">
            <img src="<?php echo $wo['message']['avatar']; ?>" alt="<?php echo $wo['message']['name']; ?> Profile picture">
         </div>
         <div class="notification-text">
			<div class="notification-time active <?php echo Wo_RightToLeft('pull-right');?>">
               <div class="ajax-time" title="<?php echo (!empty($message['time'])) ? date('c',$message['time']) : '';?>">
                <?php echo (!empty($message['time'])) ? Wo_Time_Elapsed_String($message['time']) : '';?>
               </div>
            </div>
            <span class="main-color">
            <?php echo $wo['message']['name']; ?>
            </span>
            <?php if (!empty($message['from_id'])): ?>
            <div class="header-message">
                  <?php echo ($wo['message']['user_id'] != $message['from_id']) ? $wo['lang']['me'] . ': ' : '';?>
                  <?php echo (!empty($message['media'])) ? '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-paperclip"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"></path></svg> ' . $wo['lang']['file_n_label'] : !empty($message['product_id']) ? $wo['lang']['sent_product_to_you'] : $message['text']; ?>
            </div>
            <?php endif ?>
         </div>
         <div class="clear"></div>
   </div>
</li>
<li class="divider"></li>