 <?php if(count($response)>0): ?>
            <?php  foreach($response as  $rows){
			  $rows = json_decode(json_encode($rows), True); //convert std array to simple array
			   ?>
            <?php if(isset($rows['Timeline_type']) && $rows['Timeline_type']==Task::Mail): ?>
            <li id="timeline-<?php echo $key; ?>" class="count-li timeline_mail_entry">
              <time class="cbp_tmtime" datetime="<?php echo date("Y-m-d h:i",strtotime($rows['created_at'])); ?>">
                <?php if(date("Y-m-d h:i",strtotime($rows['created_at'])) == date('Y-m-d h:i')) { ?>
                <span>Now</span>
                <?php }else{ ?>
                <span><?php echo date("h:i a",strtotime($rows['created_at']));  ?></span> <span>
                <?php if(date("Y-m-d",strtotime($rows['created_at'])) == date('Y-m-d')){echo "Today";}else{echo date("Y-m-d",strtotime($rows['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 $rows['AccountEmailLogID']; ?>" action_type="forward" class="pull-right edit-deal email_action" title="Forward"><i class="entypo-forward"></i></a>            
         <a email_number="<?php echo $rows['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 $rows['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($rows['CreatedBy']==$current_user_title): ?> You <?php else: ?> <?php echo $rows['CreatedBy']; ?>  <?php endif; ?> <span>sent an email to</span> <?php if($rows['EmailToName']==$current_user_title): ?> You <?php else: ?> <?php echo $rows['EmailToName']; ?>  <?php endif; ?> <br> <p class="mail_subject">Subject: <?php echo $rows['EmailSubject']; ?></p>
</h2>
                <div id="hidden-timeline-<?php echo $key; ?>" class="details no-display">
                  <?php if($rows['EmailCc']): ?><p>CC: <?php echo $rows['EmailCc']; ?></p><?php endif; ?>
                  <?php if($rows['EmailBcc']): ?><p>BCC: <?php echo $rows['EmailBcc']; ?></p><?php endif; ?>
                  <?php
	  if($rows['EmailAttachments']!='')
	  {
    		$attachments = unserialize($rows['EmailAttachments']);
			
			if(count($attachments)>0)
			{
				 echo "<p>Attachments: ";
				foreach($attachments as $key_acttachment => $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/'.$rows['AccountEmailLogID'].'/getattachment/'.$key_acttachment);
					if($key_acttachment==(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">Messsage:<br><?php echo $rows['EmailMessage']; ?></p><br>
                  <p><a data_fetch_id="<?php echo $rows['AccountEmailLogID']; ?>" conversations_type="mail"  class="ticket_conversations">View Conversation</a></p>
                </div>
              </div>
            </li>
            <?php elseif(isset($rows['Timeline_type']) && $rows['Timeline_type']==Task::Tasks): ?>
            <li id="timeline-<?php echo $key; ?>" class="count-li timeline_task_entry <?php if($rows['followup_task']): ?>followup_task <?php endif; ?>">
              <time class="cbp_tmtime" datetime="<?php echo date("Y-m-d h:i",strtotime($rows['created_at'])); ?>">
                <?php if(date("Y-m-d h:i",strtotime($rows['created_at'])) == date('Y-m-d h:i')) { ?>
                <span>Now</span>
                <?php }else{ ?>
                <span><?php echo date("h:i a",strtotime($rows['created_at']));  ?></span> <span>
                <?php if(date("Y-m-d",strtotime($rows['created_at'])) == date('Y-m-d')){echo "Today";}else{echo date("Y-m-d",strtotime($rows['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 <?php if(!$rows['followup_task']): ?> normal_tag <?php endif; ?> ">  
                <a id="edit_task_<?php echo $rows['TaskID']; ?>" task-id="<?php echo $rows['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 $rows['TaskID']; ?>" task-id="<?php echo $rows['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($rows['TaskPriority']=='High'): ?>  <i class="edit-deal entypo-record" style="color:#cc2424;font-size:15px;"></i> <?php endif; ?>
                <?php if($rows['CreatedBy']==$current_user_title && $rows['TaskName']==$current_user_title): ?><span>You created a <?php if($rows['followup_task']): ?> follow up <?php endif; ?> task</span>
                 <?php elseif($rows['CreatedBy']==$current_user_title && $rows['TaskName']!=$current_user_title): ?><span>You assign <?php if($rows['followup_task']): ?> follow up <?php endif; ?> task to <?php echo $rows['TaskName']; ?> </span> 
                 <?php elseif($rows['CreatedBy']!=$current_user_title && $rows['TaskName']==$current_user_title): ?><span> <?php echo $rows['CreatedBy']; ?> assign <?php if($rows['followup_task']): ?> follow up <?php endif; ?> task to  You </span>
                 <?php else: ?>  <span> <?php echo $rows['CreatedBy']; ?> assign <?php if($rows['followup_task']): ?> follow up <?php endif; ?> task to  <?php echo $rows['TaskName']; ?> </span> 
                 <?php endif; ?>
</h2>
               <div id="hidden-timeline-<?php echo $key; ?>"  class="details no-display">
                  <p>Subject: <?php echo $rows['TaskTitle']; ?></p>
                  <p>Assign To: <?php echo $rows['TaskName']; ?></p>
                  <p>priority: <?php echo $rows['TaskPriority']; ?></p>
                  <p>Due Date: <?php echo $rows['DueDate']; ?></p>
                  <p>Status: <?php echo $rows['TaskStatus']; ?>. </p>
                  <p>Description: <?php echo $rows['TaskDescription']; ?> </p>
                </div>
              </div>
            </li>
            <?php elseif(isset($rows['Timeline_type']) && $rows['Timeline_type']==Task::Note): ?>
            <li id="timeline-<?php echo $key; ?>" class="count-li timeline_note_entry">
              <time class="cbp_tmtime" datetime="<?php echo date("Y-m-d h:i",strtotime($rows['created_at'])); ?>">
                <?php if(date("Y-m-d h:i",strtotime($rows['created_at'])) == date('Y-m-d h:i')) { ?>
                <span>Now</span>
                <?php }else{ ?>
                <span><?php echo date("h:i a",strtotime($rows['created_at']));  ?></span> <span>
                <?php if(date("Y-m-d",strtotime($rows['created_at'])) == date('Y-m-d')){echo "Today";}else{echo date("Y-m-d",strtotime($rows['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($rows['NoteID'])?'NoteID':'ContactNote'; 
					$noteID		= 	isset($rows['NoteID'])?$rows['NoteID']:$rows['ContactNoteID'];
				?>
              <div class="cbp_tmlabel normal_tag"> 
               <a id="edit_note_<?php echo $noteID; ?>" note-id="<?php echo $noteID; ?>" note_type="<?php echo $note_type; ?>"  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-id="<?php echo $noteID; ?>" note_type="<?php echo $note_type; ?>"  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($rows['CreatedBy']==$current_user_title): ?> You <?php else: ?> <?php echo $rows['CreatedBy']; ?>  <?php endif; ?> <span>added a note</span></h2>
                <div id="hidden-timeline-<?php echo $key; ?>" class="details no-display">
                  <p><?php echo $rows['Note']; ?></p>
                </div>
              </div>
            </li>
             <?php elseif(isset($rows['Timeline_type']) && $rows['Timeline_type']==Task::Ticket): ?>
          <li id="timeline-<?php echo $key; ?>" class="count-li timeline_ticket_entry">
            <time class="cbp_tmtime" datetime="<?php echo date("Y-m-d h:i",strtotime($rows['created_at'])); ?>">
              <?php if(date("Y-m-d h:i",strtotime($rows['created_at'])) == date('Y-m-d h:i')) { ?>
              <span>Now</span>
              <?php }else{ ?>
              <span><?php echo date("h:i a",strtotime($rows['created_at']));  ?></span> <span>
              <?php if(date("Y-m-d",strtotime($rows['created_at'])) == date('Y-m-d')){echo "Today";}else{echo date("Y-m-d",strtotime($rows['created_at']));} ?>
              </span>
              <?php } ?>
            </time>
            <div id_toggle="<?php echo $key; ?>" class="cbp_tmicon bg-danger"><i class="entypo-ticket"></i></div>
            <div class="cbp_tmlabel normal_tag">  
              <h2 class="toggle_open" id_toggle="<?php echo $key; ?>">Ticket<br><p>Subject: <?php echo $rows['TicketSubject']; ?></p></span></h2>
              <div id="hidden-timeline-<?php echo $key; ?>" class="details no-display">
                <p>Status: <?php echo $rows['TicketStatus']; ?></p>
                <p>Requester: <?php echo $rows['RequestEmail']; ?></p>
                <p>Priority: <?php echo $rows['TicketPriority']; ?></p>
                <p>Type: <?php echo $rows['TicketType']; ?></p>
                <p>Group: <?php echo $rows['TicketGroup']; ?></p>
                <p>Date Created: <?php echo $rows['created_at']; ?></p>
                <p>Description: <?php echo $rows['TicketDescription']; ?></p>
                <p><a data_fetch_id="<?php echo $rows['TicketID']; ?>" conversations_type="ticket" class="ticket_conversations">View Ticket Conversations</a></p>
              </div>
            </div>
          </li>
          <?php endif; ?>
            <?php $key++;  } ?>
            <?php endif; ?>
