<?php
if (isset($tpl['status']))
{
	$status = __('status', true);
	switch ($tpl['status'])
	{
		case 2:
			pjUtil::printNotice(NULL, $status[2]);
			break;
	}
} else {
	$week_start = isset($tpl['option_arr']['o_week_start']) && in_array((int) $tpl['option_arr']['o_week_start'], range(0,6)) ? (int) $tpl['option_arr']['o_week_start'] : 0;
	$jqDateFormat = pjUtil::jqDateFormat($tpl['option_arr']['o_date_format']);
	?>
	<div class="ui-tabs ui-widget ui-widget-content ui-corner-all b10">
		<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
			<li class="ui-state-default ui-corner-top"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminComments&amp;action=pjActionIndex"><?php __('menuComments'); ?></a></li>
			<li class="ui-state-default ui-corner-top ui-tabs-active ui-state-active"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminComments&amp;action=pjActionUpdate&id=<?php echo $tpl['arr']['id'];?>"><?php __('lblUpdateComment'); ?></a></li>
		</ul>
	</div>
	
	<form action="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminComments&amp;action=pjActionUpdate" method="post" id="frmUpdateComment" class="form pj-form">
			<input type="hidden" name="csrf_token" value="<?php echo pjAppController::getCsrfToken(); ?>">
		<input type="hidden" name="comment_update" value="1" />
		<input type="hidden" name="id" value="<?php echo $tpl['arr']['id']; ?>" />
		
		<div class="clear_both">
			<p style="overflow: visible">
				<label class="title"><?php __('lblCommentPackage'); ?></label>
				<span class="inline_block">
					<select name="listing_id" id="listing_id" class="pj-form-field w300 required">
						<option value="">-- <?php __('lblChoose'); ?> --</option>
						<?php
						if (isset($tpl['listing_arr']) && count($tpl['listing_arr']) > 0)
						{
							foreach ($tpl['listing_arr'] as $v)
							{
								if($v['id'] == $tpl['arr']['listing_id'])
								{
									?><option value="<?php echo $v['id']; ?>" selected="selected"><?php echo pjMultibyte::substr(stripslashes($v['title'] . sprintf(" (%s)", $v['listing_refid'])), 0, 50); ?></option><?php
								}else{
									?><option value="<?php echo $v['id']; ?>"><?php echo pjMultibyte::substr(stripslashes($v['title'] . sprintf(" (%s)", $v['listing_refid'])), 0, 50); ?></option><?php
								}
							}
						}
						?>
					</select>
				</span>
			</p>
			<p>
				<label class="title"><?php __('lblCommentStatus'); ?></label>
				<span class="inline_block">
					<select name="status" id="status" class="pj-form-field w220 required">
						<option value="">-- <?php __('lblChoose'); ?> --</option>
						<?php
						foreach (__('comment_statuses', true) as $k => $v)
						{
							if($k == $tpl['arr']['status'])
							{
								?><option value="<?php echo $k; ?>" selected="selected"><?php echo stripslashes($v); ?></option><?php
							}else{
								?><option value="<?php echo $k; ?>"><?php echo stripslashes($v); ?></option><?php
							}
						}
						?>
					</select>
				</span>
			</p>
			
			<p>
				<label class="title"><?php __('lblCommentName'); ?></label>
				<span class="inline_block">
					<input type="text" name="name" id="name" value="<?php echo stripslashes($tpl['arr']['name']);?>" class="pj-form-field w200 required" />
				</span>
			</p>
			<p>
				<label class="title"><?php __('lblCommentEmail'); ?></label>
				<span class="pj-form-field-custom pj-form-field-custom-before">
					<span class="pj-form-field-before"><abbr class="pj-form-field-icon-email"></abbr></span>
					<input type="text" name="email" id="email" value="<?php echo stripslashes($tpl['arr']['email']);?>"  class="pj-form-field email w200" />
				</span>
			</p>
			<p>
				<label class="title"><?php __('lblRating'); ?></label>
				<span class="inline_block">
					<select name="rating" id="rating" class="pj-form-field w100">
						<option value="">-- <?php __('lblChoose'); ?> --</option>
						<?php
						for ($i = 1; $i <= 5; $i++)
						{
							?><option value="<?php echo $i; ?>"  <?php echo $tpl['arr']['rating'] == $i ? 'selected="selected"' : null;?>><?php echo $i; ?></option><?php
						}
						?>
					</select>
				</span>
			</p>
			<p>
				<label class="title"><?php __('lblCommentTitle'); ?></label>
				<span class="inline_block">
					<input type="text" name="title" id="title" value="<?php echo stripslashes($tpl['arr']['title']);?>" class="pj-form-field w300" />
				</span>
			</p>
			<p>
				<label class="title"><?php __('lblCommentComment'); ?>:</label>
				<span class="inline_block">
					<textarea name="comment" class="pj-form-field w500 h80"><?php echo stripslashes($tpl['arr']['comment']);?></textarea>
				</span>
			</p>
				
			<p>
				<label class="title">&nbsp;</label>
				<input type="submit" value="<?php __('btnSave'); ?>" class="pj-button" />
				<input type="button" value="<?php __('btnCancel'); ?>" class="pj-button" onclick="window.location.href='<?php echo PJ_INSTALL_URL; ?>index.php?controller=pjAdminComments&action=pjActionIndex';" />
			</p>
		</div>
	</form>
	<script type="text/javascript">
	var myLabel = myLabel || {};
	myLabel.field_required = "<?php __('vk_field_required'); ?>";
	myLabel.email_invalid = "<?php __('vk_email_invalid'); ?>";
	myLabel.csrf_token = "<?php echo pjAppController::getCsrfToken(); ?>";
	
	</script>
	<?php
}
?>