<?php
if(isset($tpl['arr']))
{
	$v = $tpl['arr'];

	$rating_arr = __('rating_arr', true);
	$by_name = empty($v['user_name']) ? pjSanitize::html($v['client_name']) : pjSanitize::html($v['user_name']);
	$file_arr = isset($tpl['file_arr']) ? $tpl['file_arr'] : array();
	?>
	<p class="pjTsTicketMeta">
		<em><?php __('lblPostedOn'); ?>: </em>
		<span><?php echo pjUtil::formatDate(date('Y-m-d', strtotime($v['created'])), "Y-m-d", $tpl['option_arr']['o_date_format']) . ', ' . date($tpl['option_arr']['o_time_format'], strtotime($v['created'])); ?></span><em> <?php __('lblPostedBy'); ?> </em>
		<strong><?php echo $by_name;?></strong>
		
		<?php
		if((int) $v['user_id'] > 0 && $tpl['option_arr']['o_allow_rating'] == 'Yes' && empty($v['rate']))
		{ 
			?>
			<span class="pjTsRating">
				<a class="btn btn-link pjTsBtnLink" role="button" data-toggle="collapse" href="#pjTsRatingWrapper<?php echo $v['id'];?>" aria-expanded="false" aria-controls="pjTsRatingWrapper<?php echo $v['id'];?>">
					<span><?php __('front_rate_this_reply');?></span>
				</a>
			</span>
			<?php
		} else if((int) $v['user_id'] > 0 && (int)$v['rate'] > 0){
			?><span class="pjTsRating"><span><?php __('front_rated');?>: <?php echo $rating_arr[$v['rate']];?></span></span><?php
		}
		?>
	</p><!-- /.pjTsTicketMeta -->

	<?php
	if((int) $v['user_id'] > 0 && $tpl['option_arr']['o_allow_rating'] == 'Yes' && empty($v['rate']))
	{ 
		
		?>
		<div class="pjTsRatingWrapper collapse" id="pjTsRatingWrapper<?php echo $v['id'];?>">
			<div class="pjSrRateBody">
				<ul class="pjSrListRates">
					<li class="pjSrRateBad">
						<a href="#" class="pjTsRateLink" data-id="<?php echo $v['id'];?>" data-rate="1">
							<span><?php echo $rating_arr[1];?></span>
						</a>
					</li>
					
					<li class="pjSrRateNotBad">
						<a href="#" class="pjTsRateLink" data-id="<?php echo $v['id'];?>" data-rate="2">
							<span><?php echo $rating_arr[2];?></span>
						</a>
					</li>
					
					<li class="pjSrRateGood">
						<a href="#" class="pjTsRateLink" data-id="<?php echo $v['id'];?>" data-rate="3">
							<span><?php echo $rating_arr[3];?></span>
						</a>
					</li>
					
					<li class="pjSrRateVeryGood">
						<a href="#" class="pjTsRateLink" data-id="<?php echo $v['id'];?>" data-rate="4">
							<span><?php echo $rating_arr[4];?></span>
						</a>
					</li>
					
					<li class="pjSrRateExcellent">
						<a href="#" class="pjTsRateLink" data-id="<?php echo $v['id'];?>" data-rate="5">
							<span><?php echo $rating_arr[5];?></span>
						</a>
					</li>
					
				</ul><!-- /.pjSrListRates -->
			</div><!-- /.pjSrRateBody -->
		</div><!-- /#sendByEmail.pjSlForm pjSlFormDirection collapse -->
		<?php
	} 
	?>
	
	<div class="pjTsTicketContent"><?php echo !empty($v['reply_text']) ? nl2br(htmlspecialchars(stripslashes($v['reply_text']))) : '';?></div>
	
	<?php
	if(!empty($file_arr))
	{
		?>
		<br/>
		<div class="files">
			<p class="pull-left"><?php __('lblReplyFiles');?>:&nbsp;&nbsp;</p>
			<?php
			foreach($file_arr as $k => $f)
			{
				?>
				<a target="_blank" href="<?php echo $_SERVER['SCRIPT_NAME']; ?>?controller=pjLoad&action=pjActionDownloadFile&id=<?php echo $f['id']; ?>"><?php echo $f['file_name'];?></a><?php echo $k+1 < count($file_arr) ? '&nbsp;|&nbsp;' : NULL; ?>
				<?php 
			}	 
			?>
		</div>
		<?php 
	} 
}
?>