<?php
$unread_class = '';
$message = Wo_GetMessagesHeader(array('user_id' => $wo['message']['user_id']), 'user');

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['text'] = Wo_Emo($message['text']);

$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">
            <?php if (!empty($wo['message']['is_open_to_work']) && $wo['config']['website_mode'] == 'linkedin') { ?>
         <span title="<?php echo($wo['lang']['open_to_work']); ?>"><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" style="color:#4caf50;"><rect x="2" y="7" width="20" height="14" rx="2" ry="2"></rect><path d="M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16"></path></svg></span>
      <?php } ?>
         </div>
         <div class="notification-text">
            <div class="color">
				<b><?php echo $wo['message']['name']; ?></b>
				<span class="notification-time active">
					<span class="ajax-time" title="<?php echo (!empty($message['time'])) ? date('c',$message['time']) : '';?>">
						<?php echo (!empty($message['time'])) ? Wo_Time_Elapsed_String($message['time']) : '';?>
					</span>
				</span>
            </div>
            <?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']) && !empty($message['product_id'])) ? '<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']); ?>
                  <?php if (empty($message['text'])) {?>
                     <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> <?php echo $wo['lang']['media']?>
                  <?php } ?>
            </div>
            <?php endif ?>
         </div>
         <div class="clear"></div>
   </div>
</li>