<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

$order_id = $args['p_id'] ?? '';

if ( ! $order_id ) {
	return;
}
$freelancer_profile_id = $args['freelancer_profile_id'] ?? '';
$employer_profile_id   = $args['profile_id'] ?? '';
$profile_id            = $args['profile_id'] ?? '';
$date_format           = $args['date_format'] ?? '';
$time_format           = $args['time_format'] ?? '';

$price_plan     = gigneo_post_meta( $order_id, '_gigneo_pm_price_plan' );
$total_revision = ! empty( $price_plan['revisions'] ) ? $price_plan['revisions'] : 'unlimited';
$revision_used  = gigneo_post_meta( $order_id, '_gigneo_pm_revision_used' );
$revision_used  = ! empty( $revision_used ) ? intval( $revision_used ) : 0;
$revision_left  = is_numeric( $total_revision ) ? intval( $total_revision ) - $revision_used : 0;

$current_stage           = gigneo_post_meta( $order_id, '_gigneo_pm_activity_stage' );
$final_delivery_activity = gigneo_post_meta( $order_id, '_gigneo_pm_delivery_activity' );

$status_labels = gigneo_status_label();

// Get comments for this order
$activity_comments = get_comments(
	array(
		'post_id' => $order_id,
		'type'    => 'order_activity',
		'orderby' => 'comment_date',
		'order'   => 'DESC',
		'parent'  => 0,
	)
);

//Thumbnails
$freelancer_profile_thumbnail_id = ! empty( $freelancer_profile_id ) ? get_post_thumbnail_id( $freelancer_profile_id ) : 0;
$employer_profile_thumbnail_id   = ! empty( $employer_profile_id ) ? get_post_thumbnail_id( $employer_profile_id ) : 0;

//Activities
$freelancer_review_activity   = gigneo_post_meta( $order_id, '_gigneo_pm_freelancer_review_activity' );
$employer_review_activity     = gigneo_post_meta( $order_id, '_gigneo_pm_employer_review_activity' );
$cancel_request_activity      = gigneo_post_meta( $order_id, '_gigneo_pm_cancel_request_activity' );
$extend_date_request_activity = gigneo_post_meta( $order_id, '_gigneo_pm_extend_delivery_date_activity' );

$service_detail_url = get_edit_post_link( $order_id );
$requirement_url    = add_query_arg(
	array(
		'tab' => 'requirements',
	),
	$service_detail_url
);
$attachment_url     = add_query_arg(
	array(
		'tab' => 'attachments',
	),
	$service_detail_url
);
$dispute_url        = add_query_arg(
	array(
		'tab' => 'dispute',
	),
	$service_detail_url
);

//Moderator
$gn_moderator_name     = gigneo_moderator_name();
$moderator_designation = gigneo_moderator_label();
$moderator_avatar_id   = gigneo_moderator_avatar_id();
?>
<div class="gn-order-section gn-order-activity">
	<div class="gn-head">
		<h3 class="gn-title"><?php esc_html_e( 'Recent activity', 'gigneo' ); ?></h3>
	</div>
	<div class="gn-body">
		<?php if ( ! empty( $activity_comments ) ) : ?>
			<div class="gn-activity-logs">
				<?php
				$current_date = '';
				foreach ( $activity_comments as $activity ) {
					$activity_date              = gmdate( $date_format, strtotime( gigneo_datetime( $activity->comment_date_gmt ) ) );
					$activity_time              = gmdate( $time_format, strtotime( gigneo_datetime( $activity->comment_date_gmt ) ) );
					$activity_profile_id        = get_comment_meta( $activity->comment_ID, '_gigneo_cm_profile_id', true );
					$activity_type              = get_comment_meta( $activity->comment_ID, '_gigneo_cm_activity_type', true );
					$activity_meta              = get_comment_meta( $activity->comment_ID, '_gigneo_cm_activity_meta', true );
					$message                    = gigneo_activity_message( $activity_type );
					$message                    = ! empty( $message ) && is_string( $message ) ? $message : $activity->comment_content;
					$activity_profile_thumbnail = ! empty( $activity_profile_id ) ? get_post_thumbnail_id( $activity_profile_id ) : '';
					$activity_profile_name      = ! empty( $activity_profile_id ) ? gigneo_profile_name( $activity_profile_id ) : '';
					$icon                       = gigneo_activity_icon( $activity_type );
					$icon_class                 = ! empty( $icon['icon'] ) ? $icon['icon'] : 'hi hi-exclamation-circle';
					$icon_status                = ! empty( $icon['status'] ) ? $icon['status'] : 'info';
					//Date
					if ( $activity_date !== $current_date ) {
						$current_date = $activity_date;
						?>
						<div class="gn-activity-date">
							<span class="gn-date"><?php echo esc_html( $current_date ); ?></span>
						</div>
						<?php
					}
					$is_system = in_array( $activity_type, array( 'requirement_pending', 'order_started', 'order_completed', 'order_payment_released', 'order_cancelled', 'order_payment_refunded' ), true );
					?>
					<div class="gn-activity-log gn-<?php echo esc_attr( ! $is_system ? 'general' : 'system' ); ?>-activity gn-activity-type-<?php echo esc_html( $activity_type ?? 'info' ); ?>" id="<?php echo esc_attr( 'gn-activity-' . $activity->comment_ID ); ?>">
						<div class="gn-activity-info">
							<?php
							if ( ! $is_system ) {
								if ( in_array( $activity_type, array( 'order_completed_by_moderator', 'order_cancelled_by_moderator', 'order_dispute_approved_by_moderator', 'order_dispute_rejected_by_moderator', 'order_continue_and_dispute_rejected_by_moderator' ), true ) ) {
									$activity_profile_name      = $gn_moderator_name;
									$activity_profile_thumbnail = $moderator_avatar_id;
								}
								?>
								<div class="gn-author-info">
									<figure class="gn-avatar">
										<?php gigneo_attachment_image_src( $activity_profile_thumbnail, 'thumbnail', 'profile' ); ?>
									</figure>
									<div class="gn-info">
										<span class="gn-name"><?php echo esc_html( $activity_profile_name ); ?></span>
									</div>
								</div>
							<?php } else { ?>
								<span class="gn-icon gn-status-<?php echo esc_attr( $icon_status ); ?>">
									<i class="<?php echo esc_attr( $icon_class ); ?>" aria-hidden="true"></i>
								</span>
							<?php } ?>
							<div class="gn-detail">
								<p class="gn-description"><?php echo esc_html( $message ); ?></p>
								<?php
								if ( 'order_final_delivery' === $activity_type ) {
									$order_delivered_info   = get_comment_meta( $activity->comment_ID, '_gigneo_cm_order_delivery_info', true );
									$order_delivered_status = $order_delivered_info['status'] ?? '';
									if ( isset( $status_labels[ $order_delivered_status ] ) ) {
										?>
										<span class="gn-status-tag gn-<?php echo esc_attr( $order_delivered_status ); ?>"><?php echo esc_html( $status_labels[ $order_delivered_status ] ); ?></span>
										<?php
									}
								}

								if ( 'order_revision_requested' === $activity_type ) {
									$order_revision_info = get_comment_meta( $activity->comment_ID, '_gigneo_cm_revision_info', true );
									$order_revision_info = $order_revision_info['status'] ?? '';
									if ( isset( $status_labels[ $order_revision_info ] ) ) {
										?>
										<span class="gn-status-tag gn-<?php echo esc_attr( $order_revision_info ); ?>"><?php echo esc_html( $status_labels[ $order_revision_info ] ); ?></span>
										<?php
									}
								}
								if ( 'order_cancel_requested' === $activity_type ) {
									$order_cancel_info        = get_comment_meta( $activity->comment_ID, '_gigneo_cm_cancel_request_info', true );
									$order_cancel_info_status = $order_cancel_info['status'] ?? '';
									if ( isset( $status_labels[ $order_cancel_info_status ] ) ) {
										?>
										<span class="gn-status-tag <?php echo esc_attr( gigneo_status_class( $order_cancel_info_status ) ); ?>"><?php echo esc_html( $status_labels[ $order_cancel_info_status ] ); ?></span>
									<?php } ?>
									<?php
								}

								if ( 'delivery_date_extend_request' === $activity_type ) {
									$extend_delivery_info        = get_comment_meta( $activity->comment_ID, '_gigneo_cm_extend_delivery_date_info', true );
									$extend_delivery_info_status = $extend_delivery_info['status'] ?? '';
									if ( isset( $status_labels[ $extend_delivery_info_status ] ) ) {
										?>
										<span class="gn-status-tag gn-<?php echo esc_attr( $extend_delivery_info_status ); ?>"><?php echo esc_html( $status_labels[ $extend_delivery_info_status ] ); ?></span>
										<?php
									}
								}
								if ( 'order_disputed_by_freelancer' === $activity_type || 'order_disputed_by_employer' === $activity_type ) {
									$order_dispute_profile_id = get_comment_meta( $activity->comment_ID, '_gigneo_cm_profile_id', true );
									$order_disputed_info      = get_comment_meta( $activity->comment_ID, '_gigneo_cm_dispute_info', true );
									$order_disputed_status    = $order_disputed_info['status'] ?? '';
									if ( isset( $status_labels[ $order_disputed_status ] ) ) {
										?>
										<span class="gn-status-tag gn-<?php echo esc_attr( $order_disputed_status ); ?>"><?php echo esc_html( $status_labels[ $order_disputed_status ] ); ?></span>
										<?php
									}
								}
								?>
							</div>
							<?php if ( 'requirement_submitted' === $activity_type || 'requirement_updated' === $activity_type ) { ?>
								<a href="<?php echo esc_url( $requirement_url ); ?>" class="gn-link gn-link-sm gn-link-primary"><?php esc_html_e( 'View requirements', 'gigneo' ); ?></a>
							<?php } ?>
							<?php if ( 'attachment_upload' === $activity_type ) { ?>
								<a href="<?php echo esc_url( $attachment_url ); ?>" class="gn-link gn-link-sm gn-link-primary"><?php esc_html_e( 'View attachments', 'gigneo' ); ?></a>
							<?php } ?>
							<?php if ( 'order_disputed_by_employer' === $activity_type || 'order_disputed_by_freelancer' === $activity_type ) { ?>
								<a href="<?php echo esc_url( $dispute_url ); ?>" class="gn-link gn-link-sm gn-link-primary"><?php esc_html_e( 'View dispute', 'gigneo' ); ?></a>
							<?php } ?>
						</div>
						<?php
						//Delivery
						if ( 'order_draft_delivery' === $activity_type || 'order_final_delivery' === $activity_type ) {
							$order_delivered_info        = get_comment_meta( $activity->comment_ID, '_gigneo_cm_order_delivery_info', true );
							$order_delivered_description = ! empty( $order_delivered_info['description'] ) ? $order_delivered_info['description'] : '';
							$order_delivered_attachments = ! empty( $order_delivered_info['attachments'] ) ? $order_delivered_info['attachments'] : '';

							if ( ! empty( $order_delivered_description ) ) {
								?>
								<div class="gn-activity-detail-wrapper gn-activity-detail-delivery">
									<div class="gn-activity-detail">
										<div class="gn-head">
											<h4 class="gn-title"><?php echo 'order_final_delivery' === $activity_type ? esc_html__( 'Final Delivery', 'gigneo' ) : esc_html__( 'Draft Delivery', 'gigneo' ); ?></h4>
										</div>
										<div class="gn-body">
											<div class="gn-info">
												<pre class="gn-pre"><?php echo wp_kses_post( $order_delivered_description ); ?></pre>
												<?php if ( ! empty( $order_delivered_attachments ) ) { ?>
													<div class="gn-attachments">
														<h6 class="gn-title"><?php echo esc_html__( 'Attached files', 'gigneo' ); ?></h6>
														<?php
														global $wpdb;
														foreach ( $order_delivered_attachments as $at => $attachment ) {
                                                            // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery , WordPress.DB.DirectDatabaseQuery.NoCaching
															$attachment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}gigneo_attachments WHERE id = %d LIMIT 1", $attachment ) );
															if ( $attachment ) {
																$attachment_path = gigneo_upload_dir_path( $attachment->path );
																$attachment_url  = gigneo_upload_dir_url( $attachment->path );
																if ( file_exists( $attachment_path ) ) {
																	?>
																	<div class="gn-attachment">
																		<div class="gn-attachment-info">
																			<i class="hi hi-link" aria-hidden="true"></i>
																			<h6 class="gn-name"><?php echo esc_html( $attachment->name ); ?></h6>
																		</div>
																		<a href="<?php echo esc_url( $attachment_url ); ?>" class="gn-btn-download" download>
																			<i class="hi hi-arrow-down-tray" aria-hidden="true"></i>
																		</a>
																	</div>
																	<?php
																}
															}
															?>
														<?php } ?>
													</div>
												<?php } ?>
											</div>
										</div>
									</div>
								</div>
								<?php
							}
						}
						//Revision Requested
						if ( 'order_revision_requested' === $activity_type ) {
							$order_revision_info        = get_comment_meta( $activity->comment_ID, '_gigneo_cm_revision_info', true );
							$order_revision_description = ! empty( $order_revision_info['description'] ) ? $order_revision_info['description'] : '';
							$order_revision_attachments = ! empty( $order_revision_info['attachments'] ) ? $order_revision_info['attachments'] : '';
							if ( ! empty( $order_revision_description ) ) {
								?>
								<div class="gn-activity-detail-wrapper gn-activity-detail-revision">
									<div class="gn-activity-detail">
										<div class="gn-head">
											<h4 class="gn-title"><?php echo esc_html__( 'Revision details', 'gigneo' ); ?></h4>
										</div>
										<div class="gn-body">
											<div class="gn-info">
												<pre class="gn-pre"><?php echo wp_kses_post( $order_revision_description ); ?></pre>
												<?php if ( ! empty( $order_revision_attachments ) ) { ?>
													<div class="gn-attachments">
														<h6 class="gn-title"><?php echo esc_html__( 'Attached files', 'gigneo' ); ?></h6>
														<?php
														global $wpdb;
														foreach ( $order_revision_attachments as $at => $attachment ) {
															// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery , WordPress.DB.DirectDatabaseQuery.NoCaching
															$attachment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}gigneo_attachments WHERE id = %d LIMIT 1", $attachment ) );
															if ( $attachment ) {
																$attachment_path = gigneo_upload_dir_path( $attachment->path );
																$attachment_url  = gigneo_upload_dir_url( $attachment->path );
																if ( file_exists( $attachment_path ) ) {
																	?>
																	<div class="gn-attachment">
																		<div class="gn-attachment-info">
																			<i class="hi hi-link" aria-hidden="true"></i>
																			<h6 class="gn-name"><?php echo esc_html( $attachment->name ); ?></h6>
																		</div>
																		<a href="<?php echo esc_url( $attachment_url ); ?>" class="gn-btn-download" download>
																			<i class="hi hi-arrow-down-tray" aria-hidden="true"></i>
																		</a>
																	</div>
																	<?php
																}
															}
															?>
														<?php } ?>
													</div>
												<?php } ?>
											</div>
										</div>
									</div>
								</div>
								<?php
							}
						}
						//View Freelancer Review
						if ( 'freelancer_review' === $activity_type && ! empty( $freelancer_review_activity ) ) {
							$freelancer_review_meta                = get_comment_meta( $freelancer_review_activity, '_gigneo_cm_review_info', true );
							$freelancer_review_communication_level = ! empty( $freelancer_review_meta['communication_level'] ) ? intval( $freelancer_review_meta['communication_level'] ) : 0;
							$freelancer_review_quality_work        = ! empty( $freelancer_review_meta['quality_work'] ) ? intval( $freelancer_review_meta['quality_work'] ) : 0;
							$freelancer_review_understanding       = ! empty( $freelancer_review_meta['understanding'] ) ? intval( $freelancer_review_meta['understanding'] ) : 0;
							$freelancer_review_feedback            = ! empty( $freelancer_review_meta['feedback'] ) ? $freelancer_review_meta['feedback'] : '';
							$freelancer_review_stars               = $freelancer_review_communication_level + $freelancer_review_quality_work + $freelancer_review_understanding;
							$freelancer_review_star_average        = number_format( $freelancer_review_stars / 3, 1 );
							?>
							<div class="gn-activity-detail-wrapper gn-activity-detail-freelancer-review">
								<div class="gn-activity-detail">
									<div class="gn-head">
										<h4 class="gn-title"><?php echo esc_html__( 'Review details', 'gigneo' ); ?></h4>
									</div>
									<div class="gn-body">
										<div class="gn-info">
											<div class="gn-review-stars">
												<?php
												for ( $i = 1; $i <= 5; $i++ ) {
													if ( $freelancer_review_star_average >= $i ) {
														echo '<i class="hi hi-star-alt gn-filled"></i>';
													} elseif ( $freelancer_review_star_average >= ( $i - 0.5 ) ) {
														echo '<i class="hi hi-star-half-alt gn-filled"></i>';
													} else {
														echo '<i class="hi hi-star-alt"></i>';
													}
												}
												?>
											</div>
											<pre class="gn-pre"><?php echo wp_kses_post( $freelancer_review_feedback ); ?></pre>
											<div class="gn-review-details">
												<div class="gn-review">
													<span class="gn-label"><?php echo esc_html__( 'Communication Level', 'gigneo' ); ?></span>
													<span class="gn-value"><i class="hi hi-star-alt"></i><?php echo esc_attr( number_format( $freelancer_review_communication_level, 1 ) ); ?></span>
												</div>
												<div class="gn-review">
													<span class="gn-label"><?php echo esc_html__( 'Quality of Work', 'gigneo' ); ?></span>
													<span class="gn-value"><i class="hi hi-star-alt"></i><?php echo esc_attr( number_format( $freelancer_review_quality_work, 1 ) ); ?></span>
												</div>
												<div class="gn-review">
													<span class="gn-label"><?php echo esc_html__( 'Understanding of Needs', 'gigneo' ); ?></span>
													<span class="gn-value"><i class="hi hi-star-alt"></i><?php echo esc_attr( number_format( $freelancer_review_understanding, 1 ) ); ?></span>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
							<?php
						}
						//View Employer Review
						if ( 'employer_review' === $activity_type && ! empty( $employer_review_activity ) ) {
							$employer_review_meta                    = get_comment_meta( $employer_review_activity, '_gigneo_cm_employer_review_info', true );
							$employer_review_feedback                = ! empty( $employer_review_meta['feedback'] ) ? $employer_review_meta['feedback'] : '';
							$employer_review_communication_level     = ! empty( $employer_review_meta['communication_level'] ) ? $employer_review_meta['communication_level'] : '';
							$employer_review_clarity_of_requirements = ! empty( $employer_review_meta['clarity_of_requirements'] ) ? $employer_review_meta['clarity_of_requirements'] : '';
							$employer_review_professionalism         = ! empty( $employer_review_meta['professionalism'] ) ? $employer_review_meta['professionalism'] : '';
							$employer_review_stars                   = $employer_review_communication_level + $employer_review_clarity_of_requirements + $employer_review_professionalism;
							$employer_review_star_average            = number_format( $employer_review_stars / 3, 1 );
							if ( ! empty( $employer_review_feedback || $employer_review_communication_level || $employer_review_clarity_of_requirements || $employer_review_professionalism ) ) {
								?>
								<div class="gn-activity-detail-wrapper gn-activity-detail-freelancer-review">
									<div class="gn-activity-detail">
										<div class="gn-head">
											<h4 class="gn-title"><?php echo esc_html__( 'Review details', 'gigneo' ); ?></h4>
										</div>
										<div class="gn-body">
										<div class="gn-info">
											<div class="gn-review-stars">
												<?php
												for ( $i = 1; $i <= 5; $i++ ) {
													if ( $employer_review_star_average >= $i ) {
														echo '<i class="hi hi-star-alt gn-filled"></i>';
													} elseif ( $employer_review_star_average >= ( $i - 0.5 ) ) {
														echo '<i class="hi hi-star-half-alt gn-filled"></i>';
													} else {
														echo '<i class="hi hi-star-alt"></i>';
													}
												}
												?>
											</div>
											<pre class="gn-pre"><?php echo wp_kses_post( $employer_review_feedback ); ?></pre>
											<div class="gn-review-details">
												<div class="gn-review">
													<span class="gn-label"><?php echo esc_html__( 'Communication Level', 'gigneo' ); ?></span>
													<span class="gn-value"><i
																class="hi hi-star-alt"></i><?php echo esc_attr( number_format( $employer_review_communication_level, 1 ) ); ?></span>
												</div>
												<div class="gn-review">
													<span class="gn-label"><?php echo esc_html__( 'Clarity of Requirements', 'gigneo' ); ?></span>
													<span class="gn-value"><i
																class="hi hi-star-alt"></i><?php echo esc_attr( number_format( $employer_review_clarity_of_requirements, 1 ) ); ?></span>
												</div>
												<div class="gn-review">
													<span class="gn-label"><?php echo esc_html__( 'Professionalism', 'gigneo' ); ?></span>
													<span class="gn-value"><i
																class="hi hi-star-alt"></i><?php echo esc_attr( number_format( $employer_review_professionalism, 1 ) ); ?></span>
												</div>
											</div>
										</div>
										</div>
									</div>
								</div>
								<?php
							}
							?>
							<?php
						}
						//Cancel Request
						if ( 'order_cancel_requested' === $activity_type ) {
							$cancel_activity_meta  = get_comment_meta( $activity->comment_ID, '_gigneo_cm_cancel_request_info', true );
							$cancel_request_status = $cancel_activity_meta['status'] ?? '';
							$cancel_reason         = $cancel_activity_meta['reason'] ?? esc_html__( 'Cancel order request', 'gigneo' );
							$cancel_description    = $cancel_activity_meta['description'] ?? '';
							if ( ! empty( $cancel_description ) ) {
								?>
								<div class="gn-activity-detail-wrapper gn-activity-detail-cancel-request">
									<div class="gn-activity-detail">
										<div class="gn-head">
											<h4 class="gn-title"><?php echo esc_html( $cancel_reason ); ?></h4>
										</div>
										<div class="gn-body">
											<figure class="gn-avatar">
												<?php gigneo_attachment_image_src( $employer_profile_thumbnail_id, 'thumbnail', 'profile' ); ?>
											</figure>
											<div class="gn-info">
												<h5 class="gn-name"><?php echo esc_html( gigneo_profile_name( $employer_profile_id ) ); ?></h5>
												<pre class="gn-pre"><?php echo wp_kses_post( $cancel_description ); ?></pre>
											</div>
										</div>
									</div>
								</div>
								<?php
							}
						}
						//Extend Delivery Request
						if ( 'delivery_date_extend_request' === $activity_type ) {
							$extend_delivery_meta_info = get_comment_meta( $activity->comment_ID, '_gigneo_cm_extend_delivery_date_info', true );
							$extend_delivery_status    = ! empty( $extend_delivery_meta_info['status'] ) ? $extend_delivery_meta_info['status'] : '';
							$extend_delivery_reason    = ! empty( $extend_delivery_meta_info['reason'] ) ? $extend_delivery_meta_info['reason'] : '';
							$extend_delivery_old_date  = ! empty( $extend_delivery_meta_info['old_date_time_gmt'] ) ? $extend_delivery_meta_info['old_date_time_gmt'] : '';
							$extend_delivery_new_date  = ! empty( $extend_delivery_meta_info['new_date_time_gmt'] ) ? $extend_delivery_meta_info['new_date_time_gmt'] : '';

							if ( ! empty( $extend_delivery_old_date ) && ! empty( $extend_delivery_new_date ) && ! empty( $extend_delivery_reason ) ) {
								$date_time_format = $date_format . ' ' . $time_format;
								?>
								<div class="gn-activity-detail-wrapper gn-activity-detail-extend-delivery-request">
									<div class="gn-activity-detail">
										<div class="gn-head">
											<h4 class="gn-title"><?php echo esc_html__( 'Extend delivery request', 'gigneo' ); ?></h4>
										</div>
										<div class="gn-body">
											<figure class="gn-avatar">
												<?php gigneo_attachment_image_src( $freelancer_profile_thumbnail_id, 'thumbnail', 'profile' ); ?>
											</figure>
											<div class="gn-info">
												<h5 class="gn-name"><?php echo esc_html( gigneo_profile_name( $freelancer_profile_id ) ); ?></h5>
												<pre class="gn-pre"><?php echo wp_kses( $extend_delivery_reason, gigneo_allowed_html_tags() ); ?></pre>
												<ul class="gn-dates">
													<li>
														<span class="gn-label"><i class="hi hi-calendar" aria-hidden="true"></i><?php echo esc_html__( 'Current Due Date:', 'gigneo' ); ?></span>
														<span class="gn-value"><?php echo esc_html( gigneo_datetime( $extend_delivery_old_date, $date_time_format ) ); ?></span>
													</li>
													<li>
														<span class="gn-label"><i class="hi hi-calendar" aria-hidden="true"></i><?php echo esc_html__( 'New Requested Date:', 'gigneo' ); ?></span>
														<span class="gn-value"><?php echo esc_html( gigneo_datetime( $extend_delivery_new_date, $date_time_format ) ); ?></span>
													</li>
												</ul>
											</div>
										</div>
									</div>
								</div>
								<?php
							}
						}
						//Disputed
						if ( 'order_disputed_by_freelancer' === $activity_type || 'order_disputed_by_employer' === $activity_type ) {
							$dispute_profile_id           = get_comment_meta( $activity->comment_ID, '_gigneo_cm_profile_id', true );
							$dispute_activity_meta        = get_comment_meta( $activity->comment_ID, '_gigneo_cm_dispute_info', true );
							$dispute_activity_status      = $cancel_activity_meta['status'] ?? '';
							$dispute_activity_reason      = $dispute_activity_meta['reason'] ?? '';
							$dispute_activity_description = $dispute_activity_meta['description'] ?? '';

							if ( ! empty( $dispute_activity_reason ) || ! empty( $dispute_activity_description ) || intval( $employer_profile_id ) !== intval( $dispute_profile_id ) ) {
								?>
								<div class="gn-activity-detail-wrapper gn-activity-detail-dispute">
									<div class="gn-activity-detail">
										<div class="gn-head">
											<h4 class="gn-title"><?php echo esc_html( $dispute_activity_reason ); ?></h4>
										</div>
										<div class="gn-body">
											<pre class="gn-pre"><?php echo wp_kses_post( $dispute_activity_description ); ?></pre>
										</div>
									</div>
								</div>
								<?php
							}
						}
						//Canceled by Moderator
						if ( 'order_cancelled_by_moderator' === $activity_type ) {
							$moderator_cancel_activity_meta        = get_comment_meta( $activity->comment_ID, '_gigneo_cm_cancel_info', true );
							$moderator_cancel_activity_reason      = $moderator_cancel_activity_meta['reason'] ?? esc_html__( 'Cancelled by Moderator', 'gigneo' );
							$moderator_cancel_activity_description = $moderator_cancel_activity_meta['description'] ?? '';
							if ( ! empty( $moderator_cancel_activity_description ) ) {
								?>
								<div class="gn-activity-detail-wrapper gn-activity-detail-dispute">
									<div class="gn-activity-detail">
										<div class="gn-head">
											<h4 class="gn-title"><?php echo esc_html( $moderator_cancel_activity_reason ); ?></h4>
										</div>
										<div class="gn-body">
											<pre class="gn-pre"><?php echo wp_kses( $moderator_cancel_activity_description, gigneo_allowed_html_tags() ); ?></pre>
										</div>
									</div>
								</div>
								<?php
							}
						}
						//Completed by Moderator
						if ( 'order_completed_by_moderator' === $activity_type ) {
							$moderator_completed_activity_meta        = get_comment_meta( $activity->comment_ID, '_gigneo_cm_complete_info', true );
							$moderator_completed_activity_reason      = $moderator_completed_activity_meta['reason'] ?? esc_html__( 'Completed by Moderator', 'gigneo' );
							$moderator_completed_activity_description = $moderator_completed_activity_meta['description'] ?? '';
							if ( ! empty( $moderator_completed_activity_description ) ) {
								?>
								<div class="gn-activity-detail-wrapper gn-activity-detail-dispute">
									<div class="gn-activity-detail">
										<div class="gn-head">
											<h4 class="gn-title"><?php echo esc_html( $moderator_completed_activity_reason ); ?></h4>
										</div>
										<div class="gn-body">
											<pre class="gn-pre"><?php echo wp_kses( $moderator_completed_activity_description, gigneo_allowed_html_tags() ); ?></pre>
										</div>
									</div>
								</div>
								<?php
							}
						}
						?>
						<div class="gn-activity-time">
							<span><?php echo esc_html( $activity_time ); ?></span>
						</div>
					</div>
				<?php } ?>
			</div>
		<?php endif; ?>
	</div>
</div>

