<?php
$comment_reply_type = 'new-tickets-reply';
if (!empty($comment_reply_details)) {
	foreach ($comment_reply_details as $v_reply) {
		$r_profile_info = $this->db->where(array('user_id' => $v_reply->replierid))->get('tbl_account_details')->row();
		$reply_info = $this->db->where(array('ticket_reply_id' => $v_reply->ticket_reply_id))->get('tbl_tickets_replies')->row();

		$avatar = !empty($r_profile_info->avatar)
			? base_url() . ltrim($r_profile_info->avatar, '/')
			: base_url('uploads/default_avatar.jpg');
?>
		<div id="<?= $comment_reply_type . '-comment-form-container-' . $v_reply->tickets_replies_id ?>" class="ml-0 mt-3 md:ml-10">
			<div class="rounded-lg border border-border bg-muted/30 p-4">
				<div class="flex items-start gap-3">
					<img alt="Avatar" src="<?= $avatar; ?>" class="h-9 w-9 rounded-full border border-border object-cover">

					<div class="min-w-0 flex-1">
						<div class="flex flex-wrap items-center justify-between gap-2">
							<a href="<?= base_url('admin/user/user_details/' . $v_reply->replierid) ?>" class="text-sm font-semibold text-foreground hover:underline">
								<?= !empty($r_profile_info->fullname) ? html_escape($r_profile_info->fullname) : '-' ?>
							</a>
							<div class="inline-flex items-center gap-2 text-xs text-muted-foreground">
								<span><?= time_ago($v_reply->time) ?></span>
								<?php if ($v_reply->replierid == $this->session->userdata('user_id')) { ?>
									<?= ajax_anchor(base_url("admin/tickets/delete/delete_ticket_replay/" . $v_reply->tickets_id . '/' . $v_reply->tickets_replies_id), "", array("class" => "inline-flex items-center", "title" => lang('delete'), 'data-fade-out-on-success' => '#' . $comment_reply_type . '-comment-form-container-' . $v_reply->tickets_replies_id)); ?>
								<?php } ?>
							</div>
						</div>

						<div class="mt-2 text-sm leading-6 text-foreground/90 break-words">
							<?php if (!empty($v_reply->body)) echo $v_reply->body; ?>
						</div>
					</div>
				</div>
			</div>
		</div>
<?php
	}
}
?>
