<?php

include('views/_header.tpl.php');
$timenow = date('Y/m/d h:i:s', time());
$displaytime = date('m/d/Y h:i:s a', time());
//date('m/d/Y h:i:s a', time());
// 2021-07-23 12:12:47

if (isset($_GET['saved'])) {
	//$msg = htmlentities(strip_tags($_GET['msg']));
	$saved = "Saved Successfully!";
}
?>

<style>
	#mmen, #header { background: #fff; }
	#mmen { display:none; }
	div.spacer { padding-top:40px; }
	button, html input[type="button"], input[type="reset"], input[type="submit"] {
		padding:15px 35px;
	}
	.form .row-item .btn {
	    padding: 5px 10px;
		margin-top:0px;
	    margin-bottom: 0px;
	    margin-left: 0px;
		font-size:14px; 
		font-weight:300;
	}
	.form .row-item .lbl {
		float: left;
		padding-top: 11px;
		width: 100px;
		min-width:100px;
		text-align: right;
		background:none;
	}	
	.form .txt, input.datepicker {
		padding:10px;
		font-size:17px;
		font-weight: 300;
	}
	.saved  {
		background:#cd1000; margin-top:20px; color:#fff; text-align:center; padding:10px;
	}
	.saved a, .saved a:active, .saved a:visited { background:#fff;  color:#28d52d; border-radius:50px; padding:3px 10px; font-weight:800; }
	.saved a:hover { color:#fff;  background:#28d52d; }

	.rounded { border-radius: 50px; -moz-border-radius: 50px; -webkit-border-radius: 50px; padding-left:20px; padding-right:20px; }

/**
* 
* @image rotate styles *
* 
*/
#container {
  width: 100%;
  min-height: 1200px;
  overflow: hidden;
}
#container.rotate90,
#container.rotate270 {
  width: 100%;
  min-height: 1200px
}
#image {
  transform-origin: top left;
  /* IE 10+, Firefox, etc. */
  -webkit-transform-origin: top left;
  /* Chrome */
  -ms-transform-origin: top left;
  /* IE 9 */
}
#container.rotate90 #image {
  transform: rotate(90deg) translateY(-100%);
  -webkit-transform: rotate(90deg) translateY(-100%);
  -ms-transform: rotate(90deg) translateY(-100%);
}
#container.rotate180 #image {
  transform: rotate(180deg) translate(-100%, -100%);
  -webkit-transform: rotate(180deg) translate(-100%, -100%);
  -ms-transform: rotate(180deg) translateX(-100%, -100%);
}
#container.rotate270 #image {
  transform: rotate(270deg) translateX(-100%);
  -webkit-transform: rotate(270deg) translateX(-100%);
  -ms-transform: rotate(270deg) translateX(-100%);
}
/* IMAGE ROTATE STYLE ENDS */
</style>

		<?php
		if (isset($saved)) {
			echo "<div class='saved' />$saved &nbsp;&nbsp;&nbsp; <a href='/admin/?ticket&edit={$ticket['id']}'>Ok</a></div>";
		}
		?>
<br />
<div class="clear"></div>
<div class="home-feature-category" style="background:none; border:none;">
	<div class="container_12 clearfix">
		<div class="grid_12 marked-category">

			<h1 style="margin-bottom:0px; padding-bottom:0px; font-size:17px; font-weight:500; width:225px; float:left;">
				<a href="/admin/tickets">&laquo; Back</a> | <?php

				if ($ticket) {
					echo "Edit";
				} else {
					echo "Add";
					$def = "static/uploads/storecats/placeholder.jpg";
				}

				?> Support Ticket
			</h1>

			<form method="post" class="form form-profile" enctype="multipart/form-data" style="padding:0px 0px 0px; margin-top:0px;">
				<div class="row-item clearfix" style="padding-bottom:10px;">
					<!--<label class="lbl" for="txt_name1" style="width:auto; margin-right:5px;">Image:</label>-->
					<div class="val" style="margin-left:0px; margin-bottom:10px; padding-top:0px;">
						
						<div style="background:none; width:100%; color:#000; height:50px;">
						
							<?php if($ticket['is_verified'] ==  0) { 
								$status_style = "#999999";
							} else if($ticket['is_verified'] ==  1) { 
								$status_style = "#cd1000";
							} else { 			
								$status_style = "#00c000";	
							}	
							?>

							<select name="is_verified" id="is_verified" class="txt" style="margin-top:7px; padding:5px; float:right; width:150px;
							background:<?= $status_style ?>; color:#fff;"">
								<!--<option value="">Select One</option>-->
								<option value="0" <?php if ($ticket['is_verified'] == '0') { echo 'selected="selected"'; } ?>>New Ticket</option>
								<option value="1" <?php if ($ticket['is_verified'] == '1') { echo 'selected="selected"'; } ?>>In Process</option>
								<option value="2" <?php if ($ticket['is_verified'] == '2') { echo 'selected="selected"'; } ?>>Resolved</option>
							</select>
							<div style="font-weight:300; font-size:17px; background:none; height:50px; line-height:50px; margin-top:0px; 
							float:right; padding-right:5px;">Status: 
							</div>
						</div>
						
						<br />
						<div style="font-weight:300; font-size:12px; background:#eee; display:block; text-align: center;
							margin:0px; padding:5px 20px 20px; letter-spacing: 2px; color:#000; border-radius:8px; min-height:150px; max-height:600px;
							-webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; overflow:auto;">
							IMAGE OF ISSUE:
							<br />
							
							<?php if($ticket['main_img']==""){ ?>
								<img src="/static/images/placeholder.jpg" alt="Image of Issue" onerror="this.src='/static/images/placeholder.jpg'" 
								style="width:100%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;" />
							<?php } else { ?>
								<img src="/<?= $ticket['main_img'] ?>" alt="Image of Issue" onerror="this.src='/static/images/placeholder.jpg'" 
								style="width:100%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; " />
							<?php } ?>

						</div>
						<!-- style="height:auto; width:90%; max-width:700px; margin:5% auto;" onerror="this.src='/static/images/no_image.png'"-->
						
						<p class="rs description-input"></p>
					</div>

	                <label class="lbl" for="txt_name1" style="width:auto; margin-right:5px;">Issue Img:</label>
	                <div class="val" style="margin-left:0px; padding-top:10px;">
	                    <input type="file" name="main_img">
	                    <p class="rs description-input"></p>
	                </div>	

					<br />

					<label class="lbl" for="txt_name1" style="width:auto; margin-right:5px;">Ticket ID#:</label>
					<div class="val" style="margin-left:0px;">
						<input class="txt" type="text" name="id" value="<?= $ticket['id'] ?>" disabled="disabled" readonly="readonly" style="border:none; background:none;">
						<p class="rs description-input"></p>
					</div>

					<label class="lbl" for="txt_name1" style="width:auto; margin-right:5px;">Requestor ID#:</label>
					<div class="val" style="margin-left:0px;">
						<input class="txt" type="text" name="submitted_by" value="<?= $ticket['submitted_by'] ?>" 
						disabled="disabled" readonly="readonly" style="width:70px; border:none; background:none;"> 
						<a href="/admin/?squareuser&edit=<?= $ticket['submitted_by'] ?>" 
						class="btn btn-blue rounded" target="_blank" style="padding:10px 20px;">View Requestor Account &raquo;</a>
						<p class="rs description-input" style="margin-left:111px;">Note: Requestor Account opens in new tab</p>
					</div>

					<label class="lbl" for="txt_name1" style="width:auto; margin-right:5px;">Date:</label>
					<div class="val" style="margin-left:0px;">
						<input class="txt" type="text" name="timestamp_posted" value="<?= $ticket['timestamp_posted'] ?>" 
						style="border:none; background:none;" disabled="disabled" readonly="readonly">
						<p class="rs description-input"></p>
					</div>
					
					<label class="lbl" for="txt_name1" style="width:auto; margin-right:5px;">Related To:</label>
					<div class="val" style="margin-left:0px;">
						<input class="txt" type="text" name="vaccine_type" value="<?= $ticket['vaccine_type'] ?>" >
						<p class="rs description-input"></p>
					</div>

					<label class="lbl" for="txt_name1" style="width:auto; margin-right:5px;">First Name:</label>
					<div class="val" style="margin-left:0px;">
						<input class="txt" type="text" name="first_name" value="<?= $ticket['first_name'] ?>" >
						<p class="rs description-input"></p>
					</div>
					
					<label class="lbl" for="txt_name1" style="width:auto; margin-right:5px;">Last Name:</label>
					<div class="val" style="margin-left:0px;">
						<input class="txt" type="text" name="last_name" value="<?= $ticket['last_name'] ?>" >
						<p class="rs description-input"></p>
					</div>	

	                <label class="lbl" for="txt_name1" style="width:auto; margin-right:5px;">Phone:</label>
	                <div class="val" style="margin-left:0px;">
	                    <input class="txt" type="text" name="phone" value="<?= format_phone($ticket['phone']) ?>">
	                    <p class="rs description-input"  style="color:#ff0000; font-style:normal;"></p>
	                </div>       					
					
					<label class="lbl" for="txt_name1" style="width:auto; margin-right:5px;">Comments:</label>
					<div class="val" style="margin-left:0px;">
						<textarea class="txt full-width"
						style="width:100%; height:100px" name="comments"><?= $ticket['comments'] ?></textarea>
						<p class="rs description-input"></p>
					</div>	
					
					<label class="lbl" for="txt_name1" style="width:auto; margin-right:5px;">Admin&rsquo;d By:</label>
					<div class="val" style="margin-left:0px;">
						<input class="txt" type="text" name="administered" value="<?= $ticket['administered'] ?>" >
						<p class="rs description-input" style="margin-left:105px;">Administered By:</p>
					</div>	
					
					<br /><br />
					<div style="border-top:2px solid #ccc;">&nbsp;</div>
					
					<div style="width:100%; background:none; font-size:33px; font-weight:800; color:#ccc; margin-top:0px; padding-top:0px;">
						<h2 style="font-size:33px; font-weight:800; color:#ccc; margin-bottom:0px; padding-bottom:0px; margin-top:5px; padding-top:5px;">
								TECH SUPPORT NOTES
						</h2>
					</div>
					<br />

					Notes by Tech Support about this Ticket/Issue.
					<br /><br />

					<label class="lbl" for="txt_name1" style="width:auto; margin-right:5px;">Notes:</label>
					<div class="val" style="margin-left:0px;">
						<textarea class="txt full-width"
						style="width:100%; height:150px; line-height:25px;" name="admin_notes"><?= $ticket['admin_notes'] ?></textarea>
						<p class="rs description-input"></p>
					</div>	
					
					<label class="lbl" for="txt_name1" style="width:auto; margin-right:5px;">Last Edited By:</label>
					<div class="val" style="margin-left:0px;">
						<div style="height:25px; margin-top:8px; line-height:25px; font-weight:800; font-size:14px; color:#ff0000"><?= $ticket['admin_id'] ?> <span style="font-weight:300; color:#ccc;">(CK Staff Admin ID)</span></div>
						<input class="txt" type="text" name="admin_id" value="<?= $_SESSION["user_id"]; ?>" hidden>
						<p class="rs description-input"></p>
					</div>										
	
					<label class="lbl" for="txt_name1" style="width:auto; margin-right:5px;">Last Edited:</label>
					<div class="val" style="margin-left:0px;">
						<input class="txt" type="text" name="timestamp_edited" value="<?= $timenow ?>" hidden>	
						<div style="height:25px; margin-top:8px; line-height:25px; font-weight:300; font-size:14px;"><?= $ticket['timestamp_edited'] ?></div>
					</div>	
				
					<label class="lbl" for="txt_name1" style="width:auto; margin-right:5px; color:#ccc;">Time Now:</label>
					<div class="val" style="margin-left:0px;">
						<div style="height:25px; margin-top:8px; line-height:25px; font-weight:300; font-size:14px; color:#ccc;"><?= $displaytime ?></div>
					</div>						
									
				</div>
				<br />
	
				<input type="submit" style="font-weight:300" class="btn btn-black" />
				<input type="button" value="Cancel" class="btn btn-black" onclick="location = '/admin/tickets'" />
			</form>

		</div>
	</div>
</div>

<script type="text/javascript">
$(document).ready(function() {

});
</script>

<?php

include('views/_footer.tpl.php');

?>