 <?php if(count($response)): ?>
          <?php if($response->type==Task::Mail): ?>
          <li id="timeline-<?php echo $key; ?>" row-id="<?php echo $response->LogID; ?>" class="count-li timeline_mail_entry">
  <time class="cbp_tmtime" datetime="<?php echo date("Y-m-d h:i",strtotime($response->created_at)); ?>">
              <?php if(date("Y-m-d h:i",strtotime($response->created_at)) == date('Y-m-d h:i')) { ?>
              <span>Now</span>
              <?php }else{ ?>
              <span><?php echo date("h:i a",strtotime($response->created_at));  ?></span> <span>
    <?php if(date("Y-m-d",strtotime($response->created_at)) == date('Y-m-d')){echo "Today";}else{echo date("Y-m-d",strtotime($response->created_at));} ?>
    </span>
              <?php } ?>
            </time>
  <div id_toggle="<?php echo $key; ?>" class="cbp_tmicon bg-gold"> <i class="entypo-mail"></i> </div>
  <div class="cbp_tmlabel normal_tag">  
  <a email_number="<?php echo $response->AccountEmailLogID; ?>" action_type="forward" class="pull-right edit-deal email_action" title="Forward"><i class="entypo-forward"></i></a>            
         <a email_number="<?php echo $response->AccountEmailLogID; ?>" action_type="reply-all" class=" pull-right edit-deal email_action" title="Reply All"><i class="entypo-reply-all"></i></a>           
         <a email_number="<?php echo $response->AccountEmailLogID; ?>" action_type="reply" class="pull-right edit-deal email_action" title="Reply"><i class="entypo-reply"></i></a>
              <h2 class="toggle_open" id_toggle="<?php echo $key; ?>"><?php if($response->CreatedBy==$current_user_title): ?> You <?php else: ?> <?php echo $response->CreatedBy; ?>  <?php endif; ?> <span>sent an email to</span> <?php if($response->EmailTo==$current_user_title): ?> You <?php else: ?> <?php echo $response->EmailTo; ?>  <?php endif; ?> <br> <p class="mail_subject">Subject: <?php echo $response->Subject; ?></p></h2>
              <div id="hidden-timeline-<?php echo $key; ?>" class="details no-display">
      <?php if($response->Cc): ?><p>CC: <?php echo $response->Cc; ?></p><?php endif; ?>
      <?php if($response->Bcc): ?><p>BCC: <?php echo $response->Bcc; ?></p><?php endif; ?>
      <?php
	  if($response->AttachmentPaths!='')
	  {
    		$attachments = unserialize($response->AttachmentPaths);
			if(count($attachments)>0 && is_array($attachments))
			{
				 echo "<p>Attachments: ";
				foreach($attachments as $key => $attachments_data)
				{
					//
					/* if(is_amazon() == true)
					{
						$Attachmenturl =  AmazonS3::preSignedUrl($attachments_data['filepath']);
					}
					else
					{
						$Attachmenturl = CompanyConfiguration::get('UPLOAD_PATH')."/".$attachments_data['filepath'];
					}*/
                    $Attachmenturl = URL::to('emails/'.$response->AccountEmailLogID.'/getattachment/'.$key);
					if($key==(count($attachments)-1)){
						echo "<a target='_blank' href=".$Attachmenturl.">".$attachments_data['filename']."</a><br><br>";
					}else{
						echo "<a target='_blank' href=".$Attachmenturl.">".$attachments_data['filename']."</a><br>";
					}
				}
				echo "</p>";
			}			
	  }
	   ?>
      <p class="mail_message">Message:<br><?php echo $response->Message; ?>. </p>
      <p><a data_fetch_id="<?php echo $response->AccountEmailLogID; ?>" conversations_type="mail"  class="ticket_conversations">View Conversation</a></p>
    </div>
            </div>
</li>
<?php elseif($response->type==Task::Tasks): ?>

          <li id="timeline-<?php echo $key; ?>" class="count-li timeline_task_entry">
           <time class="cbp_tmtime" datetime="<?php echo date("Y-m-d h:i",strtotime($response->created_at)); ?>">
              <?php if(date("Y-m-d h:i",strtotime($response->created_at)) == date('Y-m-d h:i')) { ?>
              <span>Now</span>
              <?php }else{ ?>
              <span><?php echo date("h:i a",strtotime($response->created_at));  ?></span> <span>
              <?php if(date("Y-m-d",strtotime($response->created_at)) == date('Y-m-d')){echo "Today";}else{echo date("Y-m-d",strtotime($response->created_at));} ?>
              </span>
              <?php } ?>
            </time>
            <div id_toggle="<?php echo $key; ?>" class="cbp_tmicon bg-info"> <i class="entypo-tag"></i> </div>
            <div class="cbp_tmlabel normal_tag">
             <a id="edit_task_<?php echo $response->TaskID; ?>" task-id="<?php echo $response->TaskID; ?>"  key_id="<?php echo $key; ?>" class="pull-right edit-deal edit_task_link"><i class="entypo-pencil"></i>&nbsp;</a>
            <a id="delete_task_<?php echo $response->TaskID; ?>" task-id="<?php echo $response->TaskID; ?>"  key_id="<?php echo $key; ?>" class="pull-right edit-deal delete_task_link"><i class="entypo-trash"></i></a>
                  <h2 class="toggle_open" id_toggle="<?php echo $key; ?>">
                <?php if($response->Priority=='High'): ?>  <i class="edit-deal entypo-record" style="color:#cc2424;font-size:15px;"></i> <?php endif; ?>
                <?php if($response->created_by==$current_user_title && $response->Name==$current_user_title): ?><span>You created a task</span>
                 <?php elseif($response->created_by==$current_user_title && $response->Name!=$current_user_title): ?><span>You assigned task to <?php echo $response->Name; ?> </span> 
                 <?php elseif($response->created_by!=$current_user_title && $response->Name==$current_user_title): ?><span> <?php echo $response->created_by; ?> assigned task to  You </span>
                 <?php else: ?>  <span> <?php echo $response->created_by; ?> assigned task to  <?php echo $response->Name; ?> </span> 
                 <?php endif; ?>
</h2>
              
              <div id="hidden-timeline-<?php echo $key; ?>"  class="details no-display">
                <p>Subject: <?php echo $response->Subject; ?></p>
                <p>Assigned To: <?php echo $response->Name; ?></p>
                <p>priority: <?php echo $response->Priority; ?></p>
              <?php if($response->DueDate!='' && $response->DueDate!='0000-00-00 00:00:00'): ?>  <p>Due Date: <?php echo $response->DueDate; ?></p><?php endif; ?>
                <p>Status: <?php echo $response->TaskStatus; ?>. </p>
                <p>Description: <?php echo $response->Description; ?> </p>
                 </div>
            </div>
          </li>
<?php elseif($response->type==Task::Note): ?>
<li id="timeline-<?php echo $key; ?>" row-id="<?php echo $response->NoteID; ?>" class="count-li timeline_note_entry">
  <time class="cbp_tmtime" datetime="<?php echo date("Y-m-d h:i",strtotime($response->created_at)); ?>">
    <?php if(date("Y-m-d h:i",strtotime($response->created_at)) == date('Y-m-d h:i')) { ?>
    <span>Now</span>
    <?php }else{ ?>
    <span><?php echo date("h:i a",strtotime($response->created_at));  ?></span> <span>
    <?php if(date("Y-m-d",strtotime($response->created_at)) == date('Y-m-d')){echo "Today";}else{echo date("Y-m-d",strtotime($response->created_at));} ?>
    </span>
    <?php } ?>
  </time>
  <div id_toggle="<?php echo $key; ?>" class="cbp_tmicon bg-success"><i class="entypo-doc-text"></i></div>
   <?php
				 $note_type 	= 	isset($response->NoteID)?'NoteID':'ContactNote'; 
				 $noteID		= 	isset($response->NoteID)?$response->NoteID:$response->ContactNoteID;
	?>
  <div class="cbp_tmlabel normal_tag">  
    <a id="edit_note_<?php echo $noteID; ?>" note_type="<?php echo $note_type; ?>" note-id="<?php echo $noteID; ?>"  key_id="<?php echo $key; ?>" class="pull-right edit-deal edit_note_link"><i class="entypo-pencil"></i>&nbsp;</a>
    <a id="delete_note_<?php echo $noteID; ?>" note_type="<?php echo $note_type; ?>" note-id="<?php echo $noteID; ?>"  key_id="<?php echo $key; ?>" class="pull-right edit-deal delete_note_link"><i class="entypo-trash"></i></a>
    <h2 class="toggle_open" id_toggle="<?php echo $key; ?>"><?php if($response->created_by==$current_user_title): ?> You <?php else: ?> <?php echo $response->created_by; ?>  <?php endif; ?> <span>added a note</span></h2>
    <div id="hidden-timeline-<?php echo $key; ?>" class="details no-display">
      <p><?php echo $response->Note; ?></p>
        <?php
        if($response->NoteAttachmentPaths!='')
        {
            $attachments = unserialize($response->NoteAttachmentPaths);
            if(count($attachments)>0 && is_array($attachments))
            {
                echo "<p>Attachments: ";
                foreach($attachments as $key => $attachments_data)
                {
                    //
                    /* if(is_amazon() == true)
                    {
                        $Attachmenturl =  AmazonS3::preSignedUrl($attachments_data['filepath']);
                    }
                    else
                    {
                        $Attachmenturl = CompanyConfiguration::get('UPLOAD_PATH')."/".$attachments_data['filepath'];
                    }*/
                    $Attachmenturl = URL::to('notes/'.$response->NoteID.'/getattachment/'.$key);
                    if($key==(count($attachments)-1)){
                        echo "<a target='_blank' href=".$Attachmenturl.">".$attachments_data['filename']."</a><br><br>";
                    }else{
                        echo "<a target='_blank' href=".$Attachmenturl.">".$attachments_data['filename']."</a><br>";
                    }
                }
                echo "</p>";
            }
        }
        ?>
    </div>
  </div>
</li>
<?php endif; ?>
          
        <?php endif; ?> 