<?php
session_start();
include('../config/setup.php');
$service_index = "ACS";
$action = $_GET['action'];

if($action == "editbrand"){
	$brand_id = $_GET['brand_id'];
	$sql = "SELECT * FROM brand_master WHERE brand_id > 0 and brand_id=$brand_id";
	$query = mysqli_query($conn, $sql);
	while($row = mysqli_fetch_array($query)) {
		$brand_id = $row["brand_id"];
		$brand_name = $row["brand_name"];
		$status = $row["status"];
		$brand_image = $row["brand_image"];
		$filepath = "uploads/brand/";
	}
	?>
	<form action="brand.php" method="POST" enctype="multipart/form-data">
		<div class="form-group">
			<label for="exampleFormControlInput1">Name&nbsp;<span class="text-danger">*</span></label>
			<input type="text" class="form-control" id="brand_name" name="brand_name" value="<?php echo $brand_name; ?>" required />
			<input type="hidden" class="form-control" id="action" name="action" value="edit">
			<input type="hidden" class="form-control" id="brand_id" name="brand_id" value="<?php echo $brand_id; ?>">
			<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
		</div>
		<div class="form-group">
			<!-- bootstrap-imageupload. -->
			<div class="imageuploadedit ibox ibox-grey">
				<div class="ibox-heading clearfix">
					<h3 class="ibox-title pull-left">Image</h3>
					<a href="<?php echo $filepath.$brand_image; ?>" download><img src="<?php echo $filepath.$brand_image; ?>" width="50" class="img-reponsive"  /></a>
				</div>
				<div class="file-tab ibox-body">
					<label class="btn btn-default btn-file">
						<span>Browse</span>
						<!-- The file is stored here. -->
						<input type="file" name="brandimg" >

					</label>
					<p class="help-block text-danger">*accept only jpg,png - Size : 200px X 200px</p>
					<button type="button" class="btn btn-default">Remove</button>
				</div>
			</div>
		</div>
		<script>
			var $imageupload = $('.imageuploadedit');
			$imageupload.imageupload();
		</script>
		<div class="form-group">
			<label>Status</label>
			<select name="status" class="form-control" id="status">
				<option value="1" <?php if($status == 1){echo "SELECTED";} ?>>Enable</option>
				<option value="0" <?php if($status == 0){echo "SELECTED";} ?>>Disable</option>
			</select>
		</div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php } 
if($action == "editservicetype"){
	$ser_type_id = $_GET['ser_type_id'];
	$sql = "SELECT * FROM service_type WHERE ser_type_id > 0 and ser_type_id=$ser_type_id";
	$query = mysqli_query($conn, $sql);
	while($row = mysqli_fetch_array($query)) {
		$ser_type_id = $row["ser_type_id"];
		$ser_type = $row["ser_type"];
		$service_days = $row["service_days"];
		$status = $row["status"];
	}
	?>
	<form action="service_type.php" method="POST" enctype="multipart/form-data">
		<div class="form-group">
			<label for="exampleFormControlInput1">Service Type&nbsp;<span class="text-danger">*</span></label>
			<input type="text" class="form-control" id="ser_type" name="ser_type" value="<?php echo $ser_type; ?>" required />
			<input type="hidden" class="form-control" id="action" name="action" value="edit">
			<input type="hidden" class="form-control" id="ser_type_id" name="ser_type_id" value="<?php echo $ser_type_id; ?>">
			<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
		</div>
		<div class="form-group">
			<label for="name">Service Days&nbsp;<span class="text-danger">*</span></label>
			<input type="number" class="form-control" id="service_days" name="service_days" required minlength="0" maxlength="3" value="<?php echo $service_days; ?>" />
			<p class="text-danger" id="service-days-warn-message"></p>
		</div>
		<div class="form-group">
			<label>Status</label>
			<select name="status" class="form-control" id="status">
				<option value="1" <?php if($status == 1){echo "SELECTED";} ?>>Enable</option>
				<option value="0" <?php if($status == 0){echo "SELECTED";} ?>>Disable</option>
			</select>
		</div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php } 
if($action == "editservicetime"){
	$ser_time_mgt_id = $_GET['ser_time_mgt_id'];
	$sql = "SELECT * FROM service_time_mgt_details WHERE ser_time_mgt_id > 0 and ser_time_mgt_id=$ser_time_mgt_id";
	$query = mysqli_query($conn, $sql);
	while($row = mysqli_fetch_array($query)) {
		$ser_time_mgt_id 	= $row["ser_time_mgt_id"];
		$start_time			= date('h:i:s',strtotime($row['start_time']));
		$end_time			= date('h:i:s',strtotime($row['end_time']));
		$status				= $row["status"];
		$cur_time = date('h:i');
	}
	?>
	<form action="service_time_management.php" method="POST" enctype="multipart/form-data">
		<div class="form-group">
			<label for="exampleFormControlInput1">Start Time&nbsp;<span class="text-danger">*</span></label>
			<input type="time" class="form-control" name="start_time" id="start_time" autocomplete="off" value="<?php if($start_time) echo $start_time; else echo $cur_time; ?>" required />
			<input type="hidden" class="form-control" id="ser_time_mgt_id" name="ser_time_mgt_id" value="<?php echo $ser_time_mgt_id; ?>">
			<input type="hidden" class="form-control" id="action" name="action" value="edit">
		</div>
		<div class="form-group">
			<label for="exampleFormControlInput1">End Time&nbsp;<span class="text-danger">*</span></label>
			<input type="time" class="form-control" name="end_time" id="end_time" autocomplete="off" value="<?php if($end_time) echo $end_time; else echo $cur_time; ?>" required />
		</div>
		<div class="form-group">
			<label>Status</label>
			<select name="status" class="form-control" id="status">
				<option value="1" <?php if($status == 1){echo "SELECTED";} ?>>Enable</option>
				<option value="0" <?php if($status == 0){echo "SELECTED";} ?>>Disable</option>
			</select>
		</div>
	  <button type="submit" class="btn btn-info pull-right">Submit</button>
	</form>
<?php } 
if($action == "editcategory"){
	$catid = $_GET['catid'];
	$sql = "SELECT * FROM category WHERE sno=$catid";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$name = $row["name"];
		$status = $row["status"];
		$pin = $row["pin"];
		$path = $row["path"];
	}
	?>
	<form action="category.php" method="POST" enctype="multipart/form-data">
		<div class="form-group">
			<label for="exampleFormControlInput1">Name</label>
			<input type="text" class="form-control" id="name" name="name" value="<?php echo $name; ?>" required>
			<input type="hidden" class="form-control" id="action" name="action" value="edit">
			<input type="hidden" class="form-control" id="catid" name="catid" value="<?php echo $catid; ?>">
			<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
		</div>
		<div class="form-group">
			<!-- bootstrap-imageupload. -->
			<div class="imageuploadedit ibox ibox-grey">
				<div class="ibox-heading clearfix">
					<h3 class="ibox-title pull-left">Image</h3>
					<img src="<?php echo $path; ?>" width="100" class="img-reponsive" />
				</div>
				<div class="file-tab ibox-body">
					<label class="btn btn-default btn-file">
						<span>Browse</span>
						<!-- The file is stored here. -->
						<input type="file" name="frontimg" required >

					</label>
					<p class="help-block">*accept only jpg,png - Size : 200px X 200px</p>
					<button type="button" class="btn btn-default">Remove</button>
				</div>
			</div>
		</div>
		<script>
			var $imageupload = $('.imageuploadedit');
			$imageupload.imageupload();
		</script>
		<div class="form-check">
			<input type="hidden" name="pin" value="0">
			<input type="checkbox" class="form-check-input" value="1" id="pin" name="pin" <?php if($pin == 1){ echo "CHECKED"; } ?>>
			<label class="form-check-label" for="exampleCheck1">Pin this Category to Home Page?</label>
		</div>
		<div class="form-group">
			<label>Status</label>
			<select name="status" class="form-control" id="status"  required >
				<option></option>
				<option value="1" <?php if($status == 1){echo "SELECTED";} ?>>Enable</option>
				<option value="0" <?php if($status == 0){echo "SELECTED";} ?>>Disable</option>
			</select>
		</div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php }

if($action == "editsubcategory"){
	$subcatid = $_GET['catid'];
	$sql = "SELECT * FROM subcategory WHERE sno=$subcatid";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$cid = $row["cid"];
		$name = $row["name"];
		$status = $row["status"];
	}
	?>
	<form action="subcategory.php" method="POST">
	  <div class="form-group">
		<label for="category">Category</label><br>
		<select class="form-control select2bs4" name="category" style="width: 100%;">
		  <option value="">-SELECT-</option>
		  <?php
		  $sql = "SELECT * FROM category ";
		  $query=mysqli_query($conn, $sql);
		  while( $row=mysqli_fetch_array($query) ) {
			$catid = $row["sno"];
			$catname = $row["name"]; ?>
			<option value="<?php echo $catid; ?>" <?php if($catid == $cid){ echo "SELECTED"; } ?> ><?php echo $catname; ?></option>
		  <?php } ?>
		</select>
	  </div>
	  <div class="form-group">
		<label for="exampleFormControlInput1">Name</label>
		<input type="text" class="form-control" id="name" name="name" value="<?php echo $name; ?>" required>
		<input type="hidden" class="form-control" id="action" name="action" value="edit">
		<input type="hidden" class="form-control" id="subcatid" name="subcatid" value="<?php echo $subcatid; ?>">
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
		<div class="form-group">
			<label>Status</label>
			<select name="status" class="form-control" id="status"  required >
				<option></option>
				<option value="1" <?php if($status == 1){echo "SELECTED";} ?>>Enable</option>
				<option value="0" <?php if($status == 0){echo "SELECTED";} ?>>Disable</option>
			</select>
		</div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php }
if($action == "editjobscategory"){
	$catid = $_GET['catid'];
	$sql = "SELECT * FROM jobs_category WHERE sno=$catid";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$name = $row["name"];
		$status = $row["status"];
		$pin = $row["pin"];
		$path = $row["path"];
	}
	?>
	<form action="jobs_category.php" method="POST" enctype="multipart/form-data">
		<div class="form-group">
			<label for="exampleFormControlInput1">Name</label>
			<input type="text" class="form-control" id="name" name="name" value="<?php echo $name; ?>" required>
			<input type="hidden" class="form-control" id="action" name="action" value="edit">
			<input type="hidden" class="form-control" id="catid" name="catid" value="<?php echo $catid; ?>">
			<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
		</div>
		<div class="form-group">
			<!-- bootstrap-imageupload. -->
			<div class="imageuploadedit ibox ibox-grey">
				<div class="ibox-heading clearfix">
					<h3 class="ibox-title pull-left">Image</h3>
					<img src="<?php echo $path; ?>" width="100" class="img-reponsive" />
				</div>
				<div class="file-tab ibox-body">
					<label class="btn btn-default btn-file">
						<span>Browse</span>
						<!-- The file is stored here. -->
						<input type="file" name="frontimg" >

					</label>
					<p class="help-block">*accept only jpg,png - Size : 200px X 200px</p>
					<button type="button" class="btn btn-default">Remove</button>
				</div>
			</div>
		</div>
		<script>
			var $imageupload = $('.imageuploadedit');
			$imageupload.imageupload();
		</script>
		<div class="form-check">
			<input type="hidden" name="pin" value="0">
			<input type="checkbox" class="form-check-input" value="1" id="pin" name="pin" <?php if($pin == 1){ echo "CHECKED"; } ?>>
			<label class="form-check-label" for="exampleCheck1">Pin this Category to Home Page?</label>
		</div>
		<div class="form-group">
			<label>Status</label>
			<select name="status" class="form-control" id="status"  required >
				<option></option>
				<option value="1" <?php if($status == 1){echo "SELECTED";} ?>>Enable</option>
				<option value="0" <?php if($status == 0){echo "SELECTED";} ?>>Disable</option>
			</select>
		</div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php }

if($action == "editjobssubcategory"){
	$subcatid = $_GET['catid'];
	$sql = "SELECT * FROM jobs_subcategory WHERE sno=$subcatid";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$cid = $row["cid"];
		$name = $row["name"];
		$status = $row["status"];
	}
	?>
	<form action="jobs_subcategory.php" method="POST">
	  <div class="form-group">
		<label for="category">Category</label><br>
		<select class="form-control select2bs4" name="category" style="width: 100%;">
		  <option value="">-SELECT-</option>
		  <?php
		  $sql = "SELECT * FROM jobs_category ";
		  $query=mysqli_query($conn, $sql);
		  while( $row=mysqli_fetch_array($query) ) {
			$catid = $row["sno"];
			$catname = $row["name"]; ?>
			<option value="<?php echo $catid; ?>" <?php if($catid == $cid){ echo "SELECTED"; } ?> ><?php echo $catname; ?></option>
		  <?php } ?>
		</select>
	  </div>
	  <div class="form-group">
		<label for="exampleFormControlInput1">Name</label>
		<input type="text" class="form-control" id="name" name="name" value="<?php echo $name; ?>" required>
		<input type="hidden" class="form-control" id="action" name="action" value="edit">
		<input type="hidden" class="form-control" id="subcatid" name="subcatid" value="<?php echo $subcatid; ?>">
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
		<div class="form-group">
			<label>Status</label>
			<select name="status" class="form-control" id="status"  required >
				<option></option>
				<option value="1" <?php if($status == 1){echo "SELECTED";} ?>>Enable</option>
				<option value="0" <?php if($status == 0){echo "SELECTED";} ?>>Disable</option>
			</select>
		</div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php }
if($action == "editpropertycategory"){
	$catid = $_GET['catid'];
	$sql = "SELECT * FROM property_category WHERE sno=$catid";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$name = $row["name"];
		$status = $row["status"];
		$pin = $row["pin"];
		$path = $row["path"];
	}
	?>
	<form action="property_category.php" method="POST" enctype="multipart/form-data">
		<div class="form-group">
			<label for="exampleFormControlInput1">Name</label>
			<input type="text" class="form-control" id="name" name="name" value="<?php echo $name; ?>" required>
			<input type="hidden" class="form-control" id="action" name="action" value="edit">
			<input type="hidden" class="form-control" id="catid" name="catid" value="<?php echo $catid; ?>">
			<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
		</div>
		<div class="form-group">
			<!-- bootstrap-imageupload. -->
			<div class="imageuploadedit ibox ibox-grey">
				<div class="ibox-heading clearfix">
					<h3 class="ibox-title pull-left">Image</h3>
					<img src="<?php echo $path; ?>" width="100" class="img-reponsive" />
				</div>
				<div class="file-tab ibox-body">
					<label class="btn btn-default btn-file">
						<span>Browse</span>
						<!-- The file is stored here. -->
						<input type="file" name="frontimg" >

					</label>
					<p class="help-block">*accept only jpg,png - Size : 200px X 200px</p>
					<button type="button" class="btn btn-default">Remove</button>
				</div>
			</div>
		</div>
		<script>
			var $imageupload = $('.imageuploadedit');
			$imageupload.imageupload();
		</script>
		<div class="form-check">
			<input type="hidden" name="pin" value="0">
			<input type="checkbox" class="form-check-input" value="1" id="pin" name="pin" <?php if($pin == 1){ echo "CHECKED"; } ?>>
			<label class="form-check-label" for="exampleCheck1">Pin this Category to Home Page?</label>
		</div>
		<div class="form-group">
			<label>Status</label>
			<select name="status" class="form-control" id="status"  required >
				<option></option>
				<option value="1" <?php if($status == 1){echo "SELECTED";} ?>>Enable</option>
				<option value="0" <?php if($status == 0){echo "SELECTED";} ?>>Disable</option>
			</select>
		</div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php }

if($action == "editpropertysubcategory"){
	$subcatid = $_GET['catid'];
	$sql = "SELECT * FROM property_subcategory WHERE sno=$subcatid";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$cid = $row["cid"];
		$name = $row["name"];
		$status = $row["status"];
	}
	?>
	<form action="property_subcategory.php" method="POST">
	  <div class="form-group">
		<label for="category">Category</label><br>
		<select class="form-control select2bs4" name="category" style="width: 100%;">
		  <option value="">-SELECT-</option>
		  <?php
		  $sql = "SELECT * FROM property_category ";
		  $query=mysqli_query($conn, $sql);
		  while( $row=mysqli_fetch_array($query) ) {
			$catid = $row["sno"];
			$catname = $row["name"]; ?>
			<option value="<?php echo $catid; ?>" <?php if($catid == $cid){ echo "SELECTED"; } ?> ><?php echo $catname; ?></option>
		  <?php } ?>
		</select>
	  </div>
	  <div class="form-group">
		<label for="exampleFormControlInput1">Name</label>
		<input type="text" class="form-control" id="name" name="name" value="<?php echo $name; ?>" required>
		<input type="hidden" class="form-control" id="action" name="action" value="edit">
		<input type="hidden" class="form-control" id="subcatid" name="subcatid" value="<?php echo $subcatid; ?>">
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
		<div class="form-group">
			<label>Status</label>
			<select name="status" class="form-control" id="status"  required >
				<option></option>
				<option value="1" <?php if($status == 1){echo "SELECTED";} ?>>Enable</option>
				<option value="0" <?php if($status == 0){echo "SELECTED";} ?>>Disable</option>
			</select>
		</div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php }
if($action == "editclassifiedcategory"){
	$catid = $_GET['catid'];
	$sql = "SELECT * FROM classified_category WHERE sno=$catid";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$name = $row["name"];
		$status = $row["status"];
		$pin = $row["pin"];
		$path = $row["path"];
	}
	?>
	<form action="classified_category.php" method="POST" enctype="multipart/form-data">
		<div class="form-group">
			<label for="exampleFormControlInput1">Name</label>
			<input type="text" class="form-control" id="name" name="name" value="<?php echo $name; ?>" required>
			<input type="hidden" class="form-control" id="action" name="action" value="edit">
			<input type="hidden" class="form-control" id="catid" name="catid" value="<?php echo $catid; ?>">
			<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
		</div>
		<div class="form-group">
			<!-- bootstrap-imageupload. -->
			<div class="imageuploadedit ibox ibox-grey">
				<div class="ibox-heading clearfix">
					<h3 class="ibox-title pull-left">Image</h3>
					<img src="<?php echo $path; ?>" width="100" class="img-reponsive" />
				</div>
				<div class="file-tab ibox-body">
					<label class="btn btn-default btn-file">
						<span>Browse</span>
						<!-- The file is stored here. -->
						<input type="file" name="frontimg" >

					</label>
					<p class="help-block">*accept only jpg,png - Size : 200px X 200px</p>
					<button type="button" class="btn btn-default">Remove</button>
				</div>
			</div>
		</div>
		<script>
			var $imageupload = $('.imageuploadedit');
			$imageupload.imageupload();
		</script>
		<div class="form-check">
			<input type="hidden" name="pin" value="0">
			<input type="checkbox" class="form-check-input" value="1" id="pin" name="pin" <?php if($pin == 1){ echo "CHECKED"; } ?>>
			<label class="form-check-label" for="exampleCheck1">Pin this Category to Home Page?</label>
		</div>
		<div class="form-group">
			<label>Status</label>
			<select name="status" class="form-control" id="status"  required >
				<option></option>
				<option value="1" <?php if($status == 1){echo "SELECTED";} ?>>Enable</option>
				<option value="0" <?php if($status == 0){echo "SELECTED";} ?>>Disable</option>
			</select>
		</div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php }

if($action == "editclassifiedsubcategory"){
	$subcatid = $_GET['catid'];
	$sql = "SELECT * FROM classified_subcategory WHERE sno=$subcatid";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$cid = $row["cid"];
		$name = $row["name"];
		$status = $row["status"];
	}
	?>
	<form action="classified_subcategory.php" method="POST">
	  <div class="form-group">
		<label for="category">Category</label><br>
		<select class="form-control select2bs4" name="category" style="width: 100%;">
		  <option value="">-SELECT-</option>
		  <?php
		  $sql = "SELECT * FROM classified_category ";
		  $query=mysqli_query($conn, $sql);
		  while( $row=mysqli_fetch_array($query) ) {
			$catid = $row["sno"];
			$catname = $row["name"]; ?>
			<option value="<?php echo $catid; ?>" <?php if($catid == $cid){ echo "SELECTED"; } ?> ><?php echo $catname; ?></option>
		  <?php } ?>
		</select>
	  </div>
	  <div class="form-group">
		<label for="exampleFormControlInput1">Name</label>
		<input type="text" class="form-control" id="name" name="name" value="<?php echo $name; ?>" required>
		<input type="hidden" class="form-control" id="action" name="action" value="edit">
		<input type="hidden" class="form-control" id="subcatid" name="subcatid" value="<?php echo $subcatid; ?>">
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
		<div class="form-group">
			<label>Status</label>
			<select name="status" class="form-control" id="status"  required >
				<option></option>
				<option value="1" <?php if($status == 1){echo "SELECTED";} ?>>Enable</option>
				<option value="0" <?php if($status == 0){echo "SELECTED";} ?>>Disable</option>
			</select>
		</div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php }

if($action == "editblogcategory"){
	$catid = $_GET['catid'];
	$sql = "SELECT * FROM blog_category WHERE sno=$catid";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$name = $row["name"];
		$status = $row["status"];
		$pin = $row["pin"];
		$path = $row["path"];
	}
	?>
	<form action="blog_category.php" method="POST" enctype="multipart/form-data">
		<div class="form-group">
			<label for="exampleFormControlInput1">Name</label>
			<input type="text" class="form-control" id="name" name="name" value="<?php echo $name; ?>" required>
			<input type="hidden" class="form-control" id="action" name="action" value="edit">
			<input type="hidden" class="form-control" id="catid" name="catid" value="<?php echo $catid; ?>">
			<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
		</div>
		<div class="form-group">
			<!-- bootstrap-imageupload. -->
			<div class="imageuploadedit ibox ibox-grey">
				<div class="ibox-heading clearfix">
					<h3 class="ibox-title pull-left">Image</h3>
					<img src="<?php echo $path; ?>" width="100" class="img-reponsive" />
				</div>
				<div class="file-tab ibox-body">
					<label class="btn btn-default btn-file">
						<span>Browse</span>
						<!-- The file is stored here. -->
						<input type="file" name="frontimg" >

					</label>
					<p class="help-block">*accept only jpg,png - Size : 200px X 200px</p>
					<button type="button" class="btn btn-default">Remove</button>
				</div>
			</div>
		</div>
		<script>
			var $imageupload = $('.imageuploadedit');
			$imageupload.imageupload();
		</script>
		<div class="form-check">
			<input type="hidden" name="pin" value="0">
			<input type="checkbox" class="form-check-input" value="1" id="pin" name="pin" <?php if($pin == 1){ echo "CHECKED"; } ?>>
			<label class="form-check-label" for="exampleCheck1">Pin this Category to Home Page?</label>
		</div>
		<div class="form-group">
			<label>Status</label>
			<select name="status" class="form-control" id="status"  required >
				<option></option>
				<option value="1" <?php if($status == 1){echo "SELECTED";} ?>>Enable</option>
				<option value="0" <?php if($status == 0){echo "SELECTED";} ?>>Disable</option>
			</select>
		</div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php }

if($action == "editblogsubcategory"){
	$subcatid = $_GET['catid'];
	$sql = "SELECT * FROM blog_subcategory WHERE sno=$subcatid";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$cid = $row["cid"];
		$name = $row["name"];
		$status = $row["status"];
	}
	?>
	<form action="blog_subcategory.php" method="POST">
	  <div class="form-group">
		<label for="category">Category</label><br>
		<select class="form-control select2bs4" name="category" style="width: 100%;">
		  <option value="">-SELECT-</option>
		  <?php
		  $sql = "SELECT * FROM blog_category ";
		  $query=mysqli_query($conn, $sql);
		  while( $row=mysqli_fetch_array($query) ) {
			$catid = $row["sno"];
			$catname = $row["name"]; ?>
			<option value="<?php echo $catid; ?>" <?php if($catid == $cid){ echo "SELECTED"; } ?> ><?php echo $catname; ?></option>
		  <?php } ?>
		</select>
	  </div>
	  <div class="form-group">
		<label for="exampleFormControlInput1">Name</label>
		<input type="text" class="form-control" id="name" name="name" value="<?php echo $name; ?>" required>
		<input type="hidden" class="form-control" id="action" name="action" value="edit">
		<input type="hidden" class="form-control" id="subcatid" name="subcatid" value="<?php echo $subcatid; ?>">
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
		<div class="form-group">
			<label>Status</label>
			<select name="status" class="form-control" id="status"  required >
				<option></option>
				<option value="1" <?php if($status == 1){echo "SELECTED";} ?>>Enable</option>
				<option value="0" <?php if($status == 0){echo "SELECTED";} ?>>Disable</option>
			</select>
		</div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php }

if($action == "serviceview"){
	$serviceid = $_GET['serviceid'];
	$newsql = "SELECT * FROM services WHERE sno > 0 and sno=$serviceid ";
	$newquery=mysqli_query($conn, $newsql);
	while( $rows=mysqli_fetch_array($newquery) ) {
		$sno			= $rows['sno'];
		$name			= $rows['name'];
		$cid			= $rows['cid'];
		$mobile			= $rows['mobile'];
		$email			= $rows['email'];
		$address		= $rows['address'];
		$landmark		= $rows['landmark'];
		$area			= $rows['area'];
		$district_id	= $rows['district_id'];
		$state_id		= $rows['state_id'];
		$category		= $rows['category'];
		$subcategory	= $rows['subcategory'];
		$date			= $rows['date'];
		$ser_time_mgt_id= $rows['ser_time_mgt_id'];
		$ser_type_id	= $rows['service_type'];
		$brand_id		= $rows['brand_id'];
		$remarks		= $rows['remarks'];
		$createdat		= $rows['createdat'];
		$status			= $rows['status'];
		$paidamnt		= $rows['paidamnt'];
		$serviceremarks	= $rows['serviceremarks'];
		$invoice_no		= $rows['invoice_no'];
		$invoice_image	= $rows['invoice_image'];
		$cust_remarks	= $rows['cust_remarks'];
		
		if($invoice_image!="") {
			$inv_image = "uploads/invoice/".$rows['sno'].'/'.$invoice_image;
		} else {
			$inv_image = "";
		}
	}
	$categoryname = $subcategoryname = "";
	if($category > 0) {
		$sql = "SELECT * FROM servicecategory WHERE sno=$category ";
		$query = mysqli_query($conn, $sql);
		$row = mysqli_fetch_array($query);
		$categoryname = $row['name'];
	} else {
		$categoryname = "";
	}
	/* $sql = "SELECT * FROM servicesubcategory WHERE sno=$subcategory ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$subcategoryname = $row['name'];
	} */
	
	if($district_id > 0) {
		$district	= "SELECT * FROM district WHERE sno = $district_id ";
		$districts	= mysqli_query($conn, $district);
		$get_district	= mysqli_fetch_array($districts);
		$district_name = $get_district['district'];
	} else {
		$district_name = "";
	}

	if($state_id > 0) {
		$state		= "SELECT * FROM district WHERE sno = $state_id ";
		$states		= mysqli_query($conn, $state);
		$get_state	= mysqli_fetch_array($states);
		$state_name = $get_state['state'];
	} else {
		$state_name = "";
	}
	
	if($ser_time_mgt_id > 0) {
		$ser_time	= "SELECT * FROM service_time_mgt_details WHERE ser_time_mgt_id = $ser_time_mgt_id ";
		$ser_times	= mysqli_query($conn, $ser_time);
		$get_ser_time	= mysqli_fetch_array($ser_times);
		$ser_time = date('h:i a',strtotime($get_ser_time['start_time'])).' - '.date('h:i a',strtotime($get_ser_time['end_time']));
	} else {
		$ser_time = "";
	}
	
	if($ser_type_id > 0) {
		$ser_type	= "SELECT * FROM service_type WHERE ser_type_id = $ser_type_id ";
		$ser_types	= mysqli_query($conn, $ser_type);
		$get_ser_type	= mysqli_fetch_array($ser_types);
		$ser_type = $get_ser_type['ser_type'].' - '.$get_ser_type['service_days'];
	} else {
		$ser_type = "";
	}
	
	if($brand_id > 0) {
		$brand	= "SELECT * FROM brand_master WHERE brand_id = $brand_id ";
		$brands	= mysqli_query($conn, $brand);
		$get_brand	= mysqli_fetch_array($brands);
		$brand_name = $get_brand['brand_name'];
	} else {
		$brand_name = "";
	}
	
	$address1 = "";
	if($address!="") { $address1 = $address; }
	if($landmark!="") { $address1 .= ', '.$landmark; }
	if($area!="") { $address1 .= ', '.$area.' - '; }
	if($district_name!="") { $address1 .= ', '.$district_name; }
	if($state_name!="") { $address1 .= ', '.$state_name; }
	//$address1 = $address.', '.$landmark.', '.$area.', '.$district_name.', '.$state_name;
	$cust_name = $name.' - '.$mobile;
	if($createdat!="0000-00-00 00:00:00") {
		if($createdat!="1970-01-01 00:00:00") {
			$createdate		= date("d-M-Y", strtotime($createdat));
		} else {
			$createdate		= '';
		}
	} else {
		$createdate		= '';
	}
	if($date!="0000-00-00") {
		if($date!="1970-01-01") {
			$requestdate	= date("d-M-Y", strtotime($date));
		} else {
			$requestdate	= '';
		}
	} else {
		$requestdate	= '';
	}
	?>
	<table class="table" id="example-table">
		<tr>
			<td><h6><b> Service Id </b></h6></td>
			<td><?php echo $service_index.$sno; ?></td>
		</tr>
		<tr>
			<td><h6><b> Service Type </b></h6></td>
			<?php //echo $categoryname." -> ".$subcategoryname; ?>
			<td><?php echo $categoryname; ?></td>
		</tr>
		<tr>
			<td><h6><b>Name </b></h6></td>
			<td><?php echo $cust_name; ?></td>
		</tr>
		<tr>
			<td><h6><b> Address </b></h6></td>
			<td><?php echo $address1; ?></td>
		</tr>
		<tr>
			<td><h6><b> Service Request Date </b></h6></td>
			<td><?php echo $requestdate; ?></td>
		</tr>
		<tr>
			<td><h6><b> Service Timing </b></h6></td>
			<td><?php echo $ser_time; ?></td>
		</tr>
		<tr>
			<td><h6><b> Request Created Date </b></h6></td>
			<td><?php echo $createdate; ?></td>
		</tr>
		<tr>
			<td><h6><b> Remarks </b></h6></td>
			<td><?php echo $remarks; ?></td>
		</tr>
		<?php ?>
			<tr>
				<td><h6><b> Paid Amnt </b></h6></td>
				<td><?php if($paidamnt > 0){ echo "Rs. ".$paidamnt." /-"; } ?></td>
			</tr>
		<?php   ?>
			<tr>
				<td><h6><b> Service Remarks </b></h6></td>
				<td><?php if($serviceremarks !== "") { echo $serviceremarks; } ?></td>
			</tr>
		<?php  ?>
			<tr>
				<td><h6><b> Invoice No </b></h6></td>
				<td><?php if($invoice_no !== "") { echo $invoice_no; } ?></td>
			</tr>
		<?php  ?>
			<tr>
				<td><h6><b> Invoice Image </b></h6></td>
				<td><a href="<?php if($inv_image !== "") { echo $inv_image; } ?>" download><img src="<?php if($inv_image !== "") { echo $inv_image; } ?>" width="50"/></a></td>
			</tr>
		<?php  ?>
			<tr>
				<td><h6><b> Service Type </b></h6></td>
				<td><?php if($ser_type !== "") { echo $ser_type; } ?></td>
			</tr>
		<?php ?>
			<tr>
				<td><h6><b> Brand </b></h6></td>
				<td><?php if($brand_name !== "") { echo $brand_name; } ?></td>
			</tr>
		<?php ?>
			<tr>
				<td><h6><b> Customer Remarks </b></h6></td>
				<td><?php if($cust_remarks !== "") { echo $cust_remarks; } ?></td>
			</tr>
		<?php ?>
	</table>
<?php }
if($action == "addfeedbacks"){
	$serviceid		= $_GET['serviceid'];
	$get_service	= "SELECT * FROM services WHERE sno=$serviceid ";
	$get_services	= mysqli_query($conn, $get_service);
	while($rows = mysqli_fetch_array($get_services)) {
		$sno			= $rows['sno'];
		$name			= $rows['name'];
		$cid			= $rows['cid'];
		$mobile			= $rows['mobile'];
		$email			= $rows['email'];
		$address		= $rows['address'];
		$landmark		= $rows['landmark'];
		$area			= $rows['area'];
		$district_id	= $rows['district_id'];
		$state_id		= $rows['state_id'];
		$category		= $rows['category'];
		$subcategory	= $rows['subcategory'];
		$date			= $rows['date'];
		$ser_time_mgt_id= $rows['ser_time_mgt_id'];
		$ser_type_id	= $rows['service_type'];
		$brand_id		= $rows['brand_id'];
		$remarks		= $rows['remarks'];
		$createdat		= $rows['createdat'];
		$status			= $rows['status'];
		$paidamnt		= $rows['paidamnt'];
		$serviceremarks	= $rows['serviceremarks'];
		$invoice_no		= $rows['invoice_no'];
		$invoice_image	= $rows['invoice_image'];
		$cust_remarks	= $rows['cust_remarks'];
		
		if($invoice_image!="") {
			$inv_image = "uploads/invoice/".$rows['sno'].'/'.$invoice_image;
		} else {
			$inv_image = "";
		}
	}
	$categoryname = $subcategoryname = "";
	if($category > 0) {
		$sql = "SELECT * FROM servicecategory WHERE sno=$category ";
		$query = mysqli_query($conn, $sql);
		while($row=mysqli_fetch_array($query)) {
			$categoryname = $row['name'];
		}
	} else {
		$categoryname = "";
	}
	/* $sql = "SELECT * FROM servicesubcategory WHERE sno=$subcategory ";
	$query=mysqli_query($conn, $sql);
	while($row=mysqli_fetch_array($query)) {
		$subcategoryname = $row['name'];
	} */
	if($district_id > 0) {
		$district	= "SELECT * FROM district WHERE sno = $district_id ";
		$districts	= mysqli_query($conn, $district);
		$get_district	= mysqli_fetch_array($districts);
		$district_name = $get_district['district'];
	} else {
		$district_name = "";
	}

	if($state_id > 0) {
		$state		= "SELECT * FROM district WHERE sno = $state_id ";
		$states		= mysqli_query($conn, $state);
		$get_state	= mysqli_fetch_array($states);
		$state_name = $get_state['state'];
	} else {
		$state_name = "";
	}
	
	if($ser_time_mgt_id > 0) {
		$ser_time	= "SELECT * FROM service_time_mgt_details WHERE ser_time_mgt_id = $ser_time_mgt_id ";
		$ser_times	= mysqli_query($conn, $ser_time);
		$get_ser_time	= mysqli_fetch_array($ser_times);
		$ser_time = date('h:i a',strtotime($get_ser_time['start_time'])).' - '.date('h:i a',strtotime($get_ser_time['end_time']));
	} else {
		$ser_time = "";
	}
	
	if($ser_type_id > 0) {
		$ser_type	= "SELECT * FROM service_type WHERE ser_type_id = $ser_type_id ";
		$ser_types	= mysqli_query($conn, $ser_type);
		$get_ser_type	= mysqli_fetch_array($ser_types);
		$ser_type = $get_ser_type['ser_type'].' - '.$get_ser_type['service_days'];
	} else {
		$ser_type = "";
	}
	
	if($brand_id > 0) {
		$brand	= "SELECT * FROM brand_master WHERE brand_id = $brand_id ";
		$brands	= mysqli_query($conn, $brand);
		$get_brand	= mysqli_fetch_array($brands);
		$brand_name = $get_brand['brand_name'];
	} else {
		$brand_name = "";
	}
	
	if($address!="") { $address1 = $address; }
	if($landmark!="") { $address1 .= ', '.$landmark; }
	if($area!="") { $address1 .= ', '.$area; }
	if($district_name!="") { $address1 .= ', '.$district_name; }
	if($state_name!="") { $address1 .= ', '.$state_name; }
	//$address1 = $address.', '.$landmark.', '.$area.', '.$district_name.', '.$state_name;
	$cust_name = $name.' - '.$mobile;
	if($createdat!="0000-00-00 00:00:00") {
		if($createdat!="1970-01-01 00:00:00") {
			$createdate		= date("d-M-Y", strtotime($createdat));
		} else {
			$createdate		= '';
		}
	} else {
		$createdate		= '';
	}
	if($date!="0000-00-00") {
		if($date!="1970-01-01") {
			$requestdate	= date("d-M-Y", strtotime($date));
		} else {
			$requestdate	= '';
		}
	} else {
		$requestdate	= '';
	}
	?>
	<form action="completedserviceview.php" method="POST">
		<table class="table">
		<tr>
			<td><h6><b> Service Id </b></h6></td>
			<td><?php echo $service_index.$sno; ?></td>
		</tr>
		<tr>
			<td><h6><b> Service Type </b></h6></td>
			<?php //echo $categoryname." -> ".$subcategoryname; ?>
			<td><?php echo $categoryname; ?></td>
		</tr>
		<tr>
			<td><h6><b>Name </b></h6></td>
			<td><?php echo $cust_name; ?></td>
		</tr>
		<tr>
			<td><h6><b> Address </b></h6></td>
			<td><?php echo $address1; ?></td>
		</tr>
		<tr>
			<td><h6><b> Service Request Date </b></h6></td>
			<td><?php echo $requestdate; ?></td>
		</tr>
		<tr>
			<td><h6><b> Service Timing </b></h6></td>
			<td><?php echo $ser_time; ?></td>
		</tr>
		<tr>
			<td><h6><b> Request Created Date </b></h6></td>
			<td><?php echo $createdate; ?></td>
		</tr>
		<tr>
			<td><h6><b> Remarks </b></h6></td>
			<td><?php echo $remarks; ?></td>
		</tr>
		<?php ?>
			<tr>
				<td><h6><b> Paid Amnt </b></h6></td>
				<td><?php if($paidamnt > 0){ echo "Rs. ".$paidamnt." /-"; } ?></td>
			</tr>
		<?php   ?>
			<tr>
				<td><h6><b> Service Remarks </b></h6></td>
				<td><?php if($serviceremarks !== "") { echo $serviceremarks; } ?></td>
			</tr>
		<?php  ?>
			<tr>
				<td><h6><b> Invoice No </b></h6></td>
				<td><?php if($invoice_no !== "") { echo $invoice_no; } ?></td>
			</tr>
		<?php  ?>
			<tr>
				<td><h6><b> Invoice Image </b></h6></td>
				<td><a href="<?php if($inv_image !== "") { echo $inv_image; } ?>" download><img src="<?php if($inv_image !== "") { echo $inv_image; } ?>" width="50"/></a></td>
			</tr>
		<?php  ?>
			<tr>
				<td><h6><b> Service Type </b></h6></td>
				<td><?php if($ser_type !== "") { echo $ser_type; } ?></td>
			</tr>
		<?php ?>
			<tr>
				<td><h6><b> Brand </b></h6></td>
				<td><?php if($brand_name !== "") { echo $brand_name; } ?></td>
			</tr>
		<?php ?>
			<tr>
				<td><h6><b> Customer Remarks </b></h6></td>
				<td><?php if($cust_remarks !== "") { echo $cust_remarks; } ?></td>
			</tr>
		<?php ?>
		</table>
		<input type="hidden" name="service_id" id="service_id" value="<?php echo $serviceid; ?>" />
		<div class="form-group">
			<label for="technician">Customer Feedback&nbsp;<span class="text-danger">*</span></label><br>
			<input type="hidden" class="form-control" id="action" name="action" value="customer_feedback">
			<textarea class="form-control" rows="3" name="feedback" id="feedback" value="" required></textarea>
		</div>
		<div class="form-group col-md-2 pull-right">
			<button type="submit" class="btn btn-success btn-block">Update</button>
		</div>
	</form>
<?php }
/* if($action == "assignservice"){
	$serviceid		= $_GET['serviceid'];
	$get_service	= "SELECT * FROM services WHERE sno=$serviceid ";
	$get_services	= mysqli_query($conn, $get_service);
	while($rows = mysqli_fetch_array($get_services)) {
		$name					= $rows['name'];
		$mobile 				= $rows['mobile'];
		$email					= $rows['email'];
		$address				= $rows['address'];
		$category				= $rows['category'];
		$subcategory			= $rows['subcategory'];
		$date					= $rows['date'];
		$remarks				= $rows['remarks'];
		$primary_user_id 		= $rows['primary_user_id'];
		$primary_assignedto 	= $rows['primary_assignedto'];
		$secondary_user_id 		= $rows['secondary_user_id'];
		$secondary_assignedto 	= $rows['secondary_assignedto'];
		$createdat				= $rows['createdat'];
		$status					= $rows['status'];
		$createdat				= date("d-M-Y", strtotime($createdat));
		$requestdate			= date("d-M-Y", strtotime($date));
	}
	$categoryname = $subcategoryname = "";
	$sql = "SELECT * FROM servicecategory WHERE sno=$category ";
	$query = mysqli_query($conn, $sql);
	while($row=mysqli_fetch_array($query)) {
		$categoryname = $row['name'];
	}
	$sql = "SELECT * FROM servicesubcategory WHERE sno=$subcategory ";
	$query=mysqli_query($conn, $sql);
	while($row=mysqli_fetch_array($query)) {
		$subcategoryname = $row['name'];
	}
	?>
	<form>
		<table class="table">
			<tr>
				<td><h6><b> Address </b></h6></td><td>:</td>
				<td><?php echo $address; ?></td>
			</tr>
			<tr>
				<td><h6><b> Service Type </b></h6></td><td>:</td>
				<td><?php echo $categoryname." -> ".$subcategoryname; ?></td>
			</tr>
			<tr>
				<td><h6><b> Service Request Date </b></h6></td><td>:</td>
				<td><?php echo $requestdate; ?></td>
			</tr>
			<tr>
				<td><h6><b> Remarks </b></h6></td><td>:</td>
				<td><?php echo $remarks; ?></td>
			</tr>
		</table>
		<input type="hidden" name="serviceid" id="serviceid" value="<?php echo $serviceid; ?>" />
		<div class="form-group">
			<label for="technician">Primary Technician</label><br>
			<select class="form-control" name="primary_technician" id="primary_technician" style="width: 100%;" onchange="get_secondary_technicians();">
				<option value="">-Select Technician-</option>
				<?php $sql = "SELECT * FROM user WHERE sno > 0 and status=1 and usertype = 3";
					$query = mysqli_query($conn, $sql);
					while($row=mysqli_fetch_array($query)) {
						$user_id	= $row["sno"];
						$mobile		= $row["mobile"];
						$techname	= $row["name"]; 
						$userid		= $row["userid"]; 
						$tech_det	= $techname." (".$userid." - ".$mobile.")";
					?>
					<option value="<?php echo $userid; ?>"  ><?php echo $tech_det; ?></option>
				<?php } ?>
			</select>
		</div>
		<div class="form-group">
			<label for="technician">Secondary Technician</label><br>
			<select class="form-control select2bs4" name="secondary_technician[]" id="secondary_technician" style="width: 100%;" multiple="multiple">
			<?php ?>
				<option value="">-Select Technician-</option>
				<?php $sql = "SELECT * FROM user WHERE sno > 0 and status=1 and usertype = 3";
					$query = mysqli_query($conn, $sql);
					while($row=mysqli_fetch_array($query)) {
						$user_id = $row["sno"];
						$mobile = $row["mobile"];
						$techname = $row["name"]; 
						$userid = $row["userid"]; 
					?>
					<option value="<?php echo $userid; ?>"  ><?php echo $techname." (".$userid." - ".$mobile.")"; ?></option>
				<?php } ?>
			<?php ?>
			</select>
		</div>
		<button type="button" class="btn btn-success btn-block" onclick="assigntechnician();">Submit</button>
	</form>
<?php } */
// Kit Master Edit - Starts
if($action == "editkitmaster") {
	$kit_id	= $_GET['kit_id'];
	$sql	= "SELECT * FROM kit_master WHERE kit_id > 0 and kit_id = '".$kit_id."' ";
	$query	= mysqli_query($conn, $sql);
	$row	= mysqli_fetch_array($query); 
	$kit_name 	= $row["kit_name"];
	$status		= $row["status"];
?>
	<form action="kit_master.php" method="POST" enctype="multipart/form-data">
		<div class="form-group">
			<label for="exampleFormControlInput1">Kit Name&nbsp;<span class="text-danger">*</span></label>
			<input type="text" class="form-control" id="kit_name" name="kit_name" value="<?php echo $kit_name; ?>" required />
			<input type="hidden" class="form-control" id="action" name="action" value="edit" />
			<input type="hidden" class="form-control" id="kit_id" name="kit_id" value="<?php echo $kit_id; ?>" />
		</div>
		<div class="form-group">
			<label>Kit Products</label>
			<select name="kit_master_product_name[]" class="form-control select2bs4" id="kit_master_product_name" multiple="multiple">
				<option value="">Select Kit Products</option>
				<?php $kit_product = "SELECT * FROM kit_master_products where kit_mas_prod_id > 0 and status = 1 ";
					$kit_product .= " order by kit_mas_prod_id asc ";
					$kit_products = mysqli_query($conn, $kit_product);
					//$sno = 1;
					while($row1 = mysqli_fetch_array($kit_products)) { 
						$sql2	= "SELECT * FROM kit_master_details WHERE kit_det_id > 0 and kit_id = '".$kit_id."' and kit_mas_prod_id = '".$row1['kit_mas_prod_id']."' ";
						$query2	= mysqli_query($conn, $sql2);
						$rowcount= mysqli_num_rows($query2);
						if($rowcount > 0) { $sel = "selected"; } else { $sel = ""; }
				?>
					<option value="<?php echo $row1['kit_mas_prod_id']; ?>" <?php echo $sel; ?>><?php echo $row1['kit_mas_prod_name']; ?></option>
				<?php } ?>
			</select>
		</div>
		<div class="form-group">
			<label>Status</label>
			<select name="status" class="form-control" id="status">
				<option value="1" <?php if($status == 1){ echo "SELECTED"; } ?>>Active</option>
				<option value="0" <?php if($status == 0){ echo "SELECTED"; } ?>>Inactive</option>
			</select>
		</div>
	  <button type="submit" class="btn btn-info pull-right">Submit</button>
	</form>
<?php }
// Kit Master Edit - Ends
// Kit Master Product Edit - Starts
if($action == "editkitmasterproducts") {
	$kit_mas_prod_id	= $_GET['kit_mas_prod_id'];
	$sql	= "SELECT * FROM kit_master_products WHERE kit_mas_prod_id > 0 and kit_mas_prod_id=$kit_mas_prod_id";
	$query	= mysqli_query($conn, $sql);
	$row	= mysqli_fetch_array($query); 
	$kit_mas_prod_name 	= $row["kit_mas_prod_name"];
	$status				= $row["status"];
?>
	<form action="kit_master_products.php" method="POST" enctype="multipart/form-data">
		<div class="form-group">
			<label for="exampleFormControlInput1">Product Name&nbsp;<span class="text-danger">*</span></label>
			<input type="text" class="form-control" id="kit_product_name" name="kit_product_name" value="<?php echo $kit_mas_prod_name; ?>" required />
			<input type="hidden" class="form-control" id="action" name="action" value="edit" />
			<input type="hidden" class="form-control" id="kit_mas_prod_id" name="kit_mas_prod_id" value="<?php echo $kit_mas_prod_id; ?>" />
		</div>
		<div class="form-group">
			<label>Status</label>
			<select name="status" class="form-control" id="status">
				<option value="1" <?php if($status == 1){ echo "SELECTED"; } ?>>Active</option>
				<option value="0" <?php if($status == 0){ echo "SELECTED"; } ?>>Inactive</option>
			</select>
		</div>
	  <button type="submit" class="btn btn-info pull-right">Submit</button>
	</form>
<?php }
// Kit Master Product Edit - Ends
// Service Category Edit - Starts
if($action == "editservicecategory") {
	$catid	= $_GET['catid'];
	$sql	= "SELECT * FROM servicecategory WHERE sno=$catid";
	$query	= mysqli_query($conn, $sql);
	$row	= mysqli_fetch_array($query); 
	$name 	= $row["name"];
	$status = $row["status"];
	if($row['ser_cat_image']!="") {
		$ser_cat_image1	= "uploads/servicecategory/".$row['ser_cat_image'];
	} else {
		$ser_cat_image1	= 'uploads/no_image.jpg';
	}
	?>
	<form action="servicecategory.php" method="POST" enctype="multipart/form-data">
		<div class="form-group">
			<label for="exampleFormControlInput1">Name&nbsp;<span class="text-danger">*</span></label>
			<input type="text" class="form-control" id="name" name="name" value="<?php echo $name; ?>" required>
			<input type="hidden" class="form-control" id="action" name="action" value="edit">
			<input type="hidden" class="form-control" id="catid" name="catid" value="<?php echo $catid; ?>">
			<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
		</div>
		<div class="form-group">
			<!-- bootstrap-imageupload. -->
			<div class="imageupload ibox ibox-grey">
				<div class="ibox-heading clearfix">
					<?php /* ?><h3 class="ibox-title pull-left">Image</h3><?php */ ?>
					<label for="exampleFormControlInput1">Image</label>&nbsp;&nbsp;
					<a href="<?php echo $ser_cat_image1; ?>" download><img src="<?php echo $ser_cat_image1; ?>" width="50"/></a>
				</div>
				<div class="file-tab ibox-body">
					<label class="btn btn-default btn-file">
						<span>Browse</span>
						<!-- The file is stored here. -->
						<input type="file" name="ser_cat_image" id="ser_cat_image" accept="image/*" />
					</label>
					<p class="help-block text-danger">* Accept only jpg, png - Size : 200px X 200px. Attach clear image</p>
					<button type="button" class="btn btn-default">Remove</button>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label>Status</label>
			<select name="status" class="form-control" id="status">
				<option value="1" <?php if($status == 1){echo "SELECTED";} ?>>Active</option>
				<option value="0" <?php if($status == 0){echo "SELECTED";} ?>>Inactive</option>
			</select>
		</div>
	  <button type="submit" class="btn btn-info pull-right">Submit</button>
	</form>
<?php }
// Service Category Edit - Ends
if($action == "editservicesubcategory"){
	$subcatid = $_GET['catid'];
	$sql = "SELECT * FROM servicesubcategory WHERE sno=$subcatid";
	$query = mysqli_query($conn, $sql);
	while($row = mysqli_fetch_array($query)) {
		$cid			= $row["cid"];
		$name			= $row["name"];
		$status 		= $row["status"];
		$cost			= $row["cost"];
		$service_days	= $row["service_days"]; 
	}
	?>
	<form action="servicesubcategory.php" method="POST">
		<div class="form-group">
			<label for="category">Category&nbsp;<span class="text-danger">*</span></label><br>
			<select class="form-control select2bs4" name="category" id="category" style="width: 100%;" required>
				<option value="">Select Category</option>
				<?php $sql = "SELECT * FROM servicecategory where sno > 0 and status = 1 ";
				$query = mysqli_query($conn, $sql);
				while($row = mysqli_fetch_array($query)) {
					$catid			= $row["sno"];
					$catname		= $row["name"]; 
				?>
					<option value="<?php echo $catid; ?>" <?php if($catid == $cid){ echo "SELECTED"; } ?> ><?php echo $catname; ?></option>
				<?php } ?>
			</select>
		</div>
		<div class="form-group">
			<label for="name">Sub Category&nbsp;<span class="text-danger">*</span></label>
			<input type="text" class="form-control" id="sub_category" name="sub_category" value="<?php echo $name; ?>" required />
			<input type="hidden" class="form-control" id="action" name="action" value="edit">
			<input type="hidden" class="form-control" id="subcatid" name="subcatid" value="<?php echo $subcatid; ?>">
			<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
		</div>
		<?php /* ?><div class="form-group">
            <label for="name">Cost</label>
            <input type="number" class="form-control" id="cost" name="cost" value="<?php echo $cost; ?>" step="0.01" min="0" required >
            <!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
        </div><?php */ ?>
		<div class="form-group">
			<label for="name">Service Days&nbsp;<span class="text-danger">*</span></label>
			<input type="number" class="form-control" id="service_days" name="service_days" value="<?php echo $service_days; ?>" required minlength="0" maxlength="3" />
			<p class="text-danger" id="service-days-warn-message"></p>
		</div>
		<div class="form-group">
			<label>Status&nbsp;<span class="text-danger">*</span></label>
			<select name="status" class="form-control" id="status" required>
				<option value="1" <?php if($status == 1){echo "SELECTED";} ?>>Enable</option>
				<option value="0" <?php if($status == 0){echo "SELECTED";} ?>>Disable</option>
			</select>
		</div>
		<button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php }
if($action == "statuschange"){
	$orderid = $_GET['orderid'];
	$sql = "SELECT * FROM ordermaster WHERE orderid='$orderid'";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$status = $row["status"];
	}
	?>
	<form>
	  <div class="form-group">
		<label for="exampleFormControlInput1">Order Id</label>
		<input type="text" class="form-control" id="orderidmodal" name="orderidmodal" value="<?php echo $orderid; ?>" required readonly>
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
		<div class="form-group">
			<label>Status</label>
			<select name="statusmodal" class="form-control" id="statusmodal"  required >
				<option></option>
				<option value="Process" <?php if($status == 'Process'){echo "SELECTED";} ?>>Process</option>
				<option value="Delivered" <?php if($status == 'Delivered'){echo "SELECTED";} ?>>Delivered</option>
				<option value="Cancel" <?php if($status == 'Cancel'){echo "SELECTED";} ?>>Cancel</option>
				<option value="Delete" <?php if($status == 'Delete'){echo "SELECTED";} ?>>Delete</option>
			</select>
		</div>
	  <button type="button" onclick="statusupdate();" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php }
if($action == "contactuschange"){
	$sno = $_GET['sno'];
	$newsql = "SELECT * FROM enquiry WHERE enquiryId=$sno ";
	$newquery=mysqli_query($conn, $newsql);
	while( $rows=mysqli_fetch_array($newquery) ) {
		// $snos = $rows['sno'];
		// $name = $rows['name'];
		// $subject = $rows['subject'];
		// $mobile = $rows['mobile'];
		// $email = $rows['email'];
		echo$message = $rows['message'];
		// $createdat = $rows['createdat'];
		// $createdat = date("d-M-Y", strtotime($createdat));
	}
	$newsql = "UPDATE enquiry SET status=1 WHERE enquiryId = $sno";
	$newquery=mysqli_query($conn, $newsql);
	?>
	<!-- <table class="table">
		<tr>
			<td>
				<h6><b> Name </b></h6>
			</td>
			<td>:</td>
			<td>
				<?php echo $name; ?>
			</td>
		</tr>
		<tr>
			<td>
				<h6><b> Subject </b></h6>
			</td>
			<td>:</td>
			<td>
				<?php echo $subject; ?>
			</td>
		</tr>
		<tr>
			<td>
				<h6><b> Mobile </b></h6>
			</td>
			<td>:</td>
			<td>
				<?php echo $mobile; ?>
			</td>
		</tr>
		<tr>
			<td>
				<h6><b> Email </b></h6>
			</td>
			<td>:</td>
			<td>
				<?php echo $email; ?>
			</td>
		</tr>
		<tr>
			<td>
				<h6><b> Message </b></h6>
			</td>
			<td>:</td>
			<td>
				<?php echo $message; ?>
			</td>
		</tr>
		<tr>
			<td>
				<h6><b> Created At </b></h6>
			</td>
			<td>:</td>
			<td>
				<?php echo $createdat; ?>
			</td>
		</tr>
	</table> -->
<?php }
if($action == "walletrequeststatus"){
	$requestid = $_GET['requestid'];

	$sql = "SELECT * FROM walletrequest WHERE requestid='$requestid'";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$requestpoint = $row["requestpoint"];
		$requestby = $row["requestby"];
		$requesttype = $row["requesttype"];
		$requestamnt = $row["requestamnt"];
		$status = $row["status"];
	}
	if($requesttype == "3"){
		$reqtype = "Technician";
		$sql = "SELECT * FROM technician WHERE technicianid='$requestby' ";
		$query=mysqli_query($conn, $sql);
		while( $row=mysqli_fetch_array($query)) {
			$requestname = $row['name'];
		}
	}
	?>
	<table class="table">
		<tr>
			<td>
				<h6><b> Request Id </b></h6>
			</td>
			<td>:</td>
			<td>
				<?php echo $requestid; ?>
			</td>
		</tr>
		<tr>
			<td>
				<h6><b> Request By </b></h6>
			</td>
			<td>:</td>
			<td>
				<?php echo $requestby."(".$requestname.")"; ?>
			</td>
		</tr>
		<tr>
			<td>
				<h6><b> Request Type </b></h6>
			</td>
			<td>:</td>
			<td>
				<?php echo $reqtype; ?>
			</td>
		</tr>
		<?php
		if($requestpoint > 0){ ?>
		<tr>
			<td>
				<h6><b> Request Point </b></h6>
			</td>
			<td>:</td>
			<td>
				<?php echo $requestpoint; ?>
			</td>
		</tr>
		<?php
		}
		if($requestamnt > 0){ ?>
		<tr>
			<td>
				<h6><b> Request Walletamnt </b></h6>
			</td>
			<td>:</td>
			<td>
				<?php echo $requestamnt; ?>
			</td>
		</tr>
	<?php } ?>
	</table>
	<form action="walletrequest.php" method="POST">
		<div class="form-group">
			<label for="exampleFormControlInput1">Settled Amount</label>
			<input type="number" class="form-control" id="settledamnt" name="settledamnt" value="0" required step="0.01">
			<input type="hidden" class="form-control" id="requestid" name="requestid" value="<?php echo $requestid; ?>" >
			<input type="hidden" class="form-control" id="action" name="action" value="walletstatus" >
		</div>
		<div class="form-group">
			<label>Status</label>
			<select name="statusmodal" class="form-control" id="statusmodal"  required >
				<option></option>
				<option value="Complete" <?php if($status == 'Complete'){echo "SELECTED";} ?>> Settled </option>
				<option value="Reject" <?php if($status == 'Reject'){echo "SELECTED";} ?>> Reject </option>
			</select>
		</div>
	  <button type="submit" class="btn btn-success">Submit</button>
	</form>
<?php }
if($action == "orderview"){
	$orderid = $_GET['orderid'];

	/*$query="SELECT * FROM `ordermaster` WHERE orderid='$orderid' ";
	$results = $conn->query($query);
	while($rows = $results->fetch_assoc()) {
		$cid = $rows['cid'];
		$name = $rows['name'];
		$address1 = $rows['address1'];
		$address2 = $rows['address2'];
		$city = $rows['city'];
		$state = $rows['state'];
		$mobile = $rows['mobile'];
		$email = $rows['email'];
		$postcode = $rows['postcode'];
		$subtotal = $rows['subtotal'];
		$tax = $rows['tax'];
		$round = $rows['round'];
		$discount = $rows['discount'];
		$gross = $rows['gross'];
		$status = $rows['status'];
		$createdat = $rows['createdat'];
		$paymentmethod = $rows['paymentmethod'];
	}
	$currenttimeformt = date("d-M-Y", strtotime($createdat));
	$mailbody = "";

	$mailbody .= '<table class="table">';
	$mailbody .= '<tr>';
	$mailbody .= '<td colspan="2" style="background: #8e8e8e; width: 100%; Padding: 5px; color: #fff;">Order Details</td>';
	$mailbody .= '</tr>';
	$mailbody .= '<tr>';
	$mailbody .= '<td>
				<b>Order Id: </b>'.$orderid.'<br><b>Created At: </b>'.$currenttimeformt.'<br><b>Payment Method: </b>'.$paymentmethod.'
				</td>';
	$mailbody .= '<td>
				<b>Email: </b>'.$email.'<br><b>Mobile: </b>'.$mobile.'<br><b>Order Status: </b>'.$status.'
				</td>';
	$mailbody .= '</tr>';

	$mailbody .= '<tr>';
	$mailbody .= '<td>&nbsp;</td>';
	$mailbody .= '<td>&nbsp;</td>';
	$mailbody .= '</tr>';
	$mailbody .= '<tr>';

	$mailbody .= '<tr>';
	$mailbody .= '<td style="background: #8e8e8e; width: 100%; Padding: 5px; color: #fff;">Payment Address</td>';
	$mailbody .= '<td style="background: #8e8e8e; width: 100%; Padding: 5px; color: #fff;">Delivery Address</td>';
	$mailbody .= '</tr>';
	$mailbody .= '<tr>';
	$mailbody .= '<td>
				'.$name.'<br>'.$address1.'<br>'.$address2.'<br>'.$city.' - '.$postcode.'<br>'.$state.'<br>India
				</td>';
	$mailbody .= '<td>
				'.$name.'<br>'.$address1.'<br>'.$address2.'<br>'.$city.' - '.$postcode.'<br>'.$state.'<br>India
				</td>';
	$mailbody .= '</tr>';
	$mailbody .= '</table>';
	$mailbody .= '<br>';
	$mailbody .= '<p style="background: #8e8e8e; width: 100%; Padding: 5px; color: #fff;">Order Details</p>';
	$mailbody .= '<table class="table">';
	$mailbody .= '<tr><td align="center"><b>Product</b></td><td align="center"><b>Qty</b></td><td align="center"><b>Rate</b></td><td align="center"><b>Tax</b></td><td align="center"><b>Total</b></td></tr>';
	$query="SELECT * FROM `orderdetail` WHERE orderid='$orderid' ";
	$results = $conn->query($query);
	while($rows = $results->fetch_assoc()) {
		$cartpdtqty = $rows['qty'];
		$pdtid = $rows['pdtid'];
		$rate = $rows['rate'];
		$igst = $rows['igst'];
		$total = $rows['total'];
		$name = "";
		$querys="SELECT * FROM `product` WHERE pdtid='$pdtid' ";
		$result = $conn->query($querys);
		while($row = $result->fetch_assoc()) {
			$name = $row['name'];
			$image1 = $row['image1'];
		}

		$mailbody .= '<tr><td>'.$name.'</td><td align="center">'.$cartpdtqty.'</td><td align="center">'.$rate.'</td><td align="center">'.$igst.'</td><td align="right">'.$total.'</td></tr>';
	}
	$mailbody .= '<tr><td colspan="4" align="right">Subtotal</td><td align="right">'.$subtotal.'</td></tr>';
	$discount = number_format((float)$discount, 2, '.', '');
	if($discount > 0){
	$mailbody .= '<tr><td colspan="4" align="right">Discount</td><td align="right">'.$discount.'</td></tr>';
	}
	
	if($round > 0){
	$mailbody .= '<tr><td colspan="4" align="right">Discount</td><td align="right">'.$round.'</td></tr>';
	}
	$mailbody .= '<tr><td colspan="4" align="right"><h4>Total</h4></td><td align="right"><h4>'.$gross.'</h4></td></tr>';
	$mailbody .= '</table>';
	echo $mailbody;
	*/
	
	$query="SELECT * FROM `ordermaster` WHERE orderid='$orderid' ";
	$results = $conn->query($query);
	while($rows = $results->fetch_assoc()) {
		$cid = $rows['cid'];
		$name = $rows['name'];
		$address1 = $rows['address1'];
		$address2 = $rows['address2'];
		$city = $rows['city'];
		$state = $rows['state'];
		$mobile = $rows['mobile'];
		$email = $rows['email'];
		$postcode = $rows['postcode'];
		$subtotal = $rows['subtotal'];
		$tax = $rows['tax'];
		$round = $rows['round'];
		$discount = $rows['discount'];
		$gross = $rows['gross'];
		$status = $rows['status'];
		$createdat = $rows['createdat'];
		$paymentmethod = $rows['paymentmethod'];
		$paymentid = $rows['paymentid'];
		$transactionid = $rows['transactionid'];
	}
	
	$query="SELECT * FROM `settings` WHERE options='address1' ";
	$results = $conn->query($query);
	while($rows = $results->fetch_assoc()) {
		$staddress1 = $rows['value'];
	}
	$query="SELECT * FROM `settings` WHERE options='address2' ";
	$results = $conn->query($query);
	while($rows = $results->fetch_assoc()) {
		$staddress2 = $rows['value'];
	}
	$query="SELECT * FROM `settings` WHERE options='city' ";
	$results = $conn->query($query);
	while($rows = $results->fetch_assoc()) {
		$stcity = $rows['value'];
	}
	$query="SELECT * FROM `settings` WHERE options='state' ";
	$results = $conn->query($query);
	while($rows = $results->fetch_assoc()) {
		$ststate = $rows['value'];
	}
	$query="SELECT * FROM `settings` WHERE options='email' ";
	$results = $conn->query($query);
	while($rows = $results->fetch_assoc()) {
		$stemail = $rows['value'];
	}
	$query="SELECT * FROM `settings` WHERE options='mobile' ";
	$results = $conn->query($query);
	while($rows = $results->fetch_assoc()) {
		$stmobile = $rows['value'];
	}
	$query="SELECT * FROM `settings` WHERE options='gst' ";
	$results = $conn->query($query);
	while($rows = $results->fetch_assoc()) {
		$stgst = $rows['value'];
	}
	$query="SELECT * FROM `settings` WHERE options='pan' ";
	$results = $conn->query($query);
	while($rows = $results->fetch_assoc()) {
		$stpan = $rows['value'];
	}
	if($staddress2==""){
		$staddress = $staddress1;
	} else {
		$staddress = $staddress1."<br>".$staddress2;
	}
	$currenttimeformt = date("d-M-Y", strtotime($createdat));
	$mailbody = "";
	$mailbody .= '<table style="width: 100%"><tr><td><img src="https://thagaval.in/images/logo.jpg" style="width: 200px;" /></td><td align="right"><h6> Tax Invoice/Bill of Supply/Cash Memo</h6><p>(Original for Recipient)</p></td></tr></table><br><br>';
	
	$mailbody .= '<table style="width: 100%"><tr><td><h6>THAGAVAL Shopbee</h6><p>'.$staddress.',<br>'.$stcity.', '.$ststate.'</td><td align="right"><b>Billing Address :<br></b>'.$name.'<br>'.$address1.'<br>'.$address2.'<br>'.$city.' - '.$postcode.', '.$state.', India</td></tr></table>';
	
	$mailbody .= '<table style="width: 100%"><tr><td><p>PAN No.: '.$stpan.'<br>GST No.: '.$stgst.'</td><td align="right"><b>Shipping Address :<br></b>'.$name.'<br>'.$address1.'<br>'.$address2.'<br>'.$city.' - '.$postcode.', '.$state.', India</td></tr></table>';
	
	$mailbody .= '<table style="width: 100%">';
	$mailbody .= '<tr>';
	$mailbody .= '<td>
				<b>Order Id: </b>'.$orderid.'<br><b>Created At: </b>'.$currenttimeformt.'<br><b>Payment Method: </b>'.strtoupper($paymentmethod);
				if($paymentmethod == "razorpay"){
					$mailbody .= '<br><b>Transaction Id: </b>'.strtoupper($transactionid).'<br><b>Paymrnt Id: </b>'.strtoupper($paymentid);
				}
	$mailbody .= '</td>';
	$mailbody .= '<td align="right">
				<b>Email: </b>'.$email.'<br><b>Mobile: </b>'.$mobile.'<br><b>Order Status: </b>'.$status.'
				</td>';
	$mailbody .= '</tr>';
	$mailbody .= '</table>';
	$mailbody .= '<br>';
	$mailbody .= '<table border="1" cellpadding="3" style="width: 100%">';
	$sno = 1;
	$totaltax = 0;
	$mailbody .= '<tr style="background: #000; color: #fff;"><td align="center"><b>#</b></td><td align="center"><b>Product</b></td><td align="center"><b>Qty</b></td><td align="center"><b>Rate</b></td><td align="center"><b>Tax %</b></td><td align="center"><b>Tax</b></td><td align="center"><b>Total</b></td></tr>';
	$query="SELECT * FROM `orderdetail` WHERE orderid='$orderid' ";
	$results = $conn->query($query);
	while($rows = $results->fetch_assoc()) {
		$cartpdtqty = $rows['qty'];
		$pdtid = $rows['pdtid'];
		$rate = $rows['rate'];
		$igst = $rows['igst'];
		$total = $rows['total'];
		$name = "";
		$querys="SELECT * FROM `product` WHERE pdtid='$pdtid' ";
		$result = $conn->query($querys);
		while($row = $result->fetch_assoc()) {
			$name = $row['name'];
			$image1 = $row['image1'];
			$taxpercent = $row['taxpercent'];
		}
		$totaltax = $totaltax + $igst;
		$mailbody .= '<tr><td align="center" style="padding: 5px;">'.$sno.'</td><td style="padding: 5px;">'.$name.'</td><td align="center" style="padding: 5px;">'.$cartpdtqty.'</td><td align="center" style="padding: 5px;">'.$rate.'</td><td align="center" style="padding: 5px;">'.$taxpercent.'</td><td align="right" style="padding: 5px;">'.$igst.'</td><td align="right" style="padding: 5px;">'.$total.'</td></tr>';
		$sno = $sno + 1;
	}
	$totaltax = number_format((float)$totaltax, 2, '.', '');
	$mailbody .= '<tr><td colspan="5" align="left" style="padding: 5px;">Subtotal</td><td align="right" style="padding: 5px;">'.$totaltax.'</td><td align="right" style="padding: 5px;">'.$subtotal.'</td></tr>';
	$discount = number_format((float)$discount, 2, '.', '');
	if($discount > 0){
	$mailbody .= '<tr><td colspan="6" align="right" style="padding: 5px;">Discount</td><td align="right" style="padding: 5px;">'.$discount.'</td></tr>';
	}
	
	if($round > 0){
	$mailbody .= '<tr><td colspan="6" align="right" style="padding: 5px;">Discount</td><td align="right" style="padding: 5px;">'.$round.'</td></tr>';	
	}
	$mailbody .= '<tr><td colspan="6" align="right" style="font-weight: bold;padding: 5px;">Total</td><td align="right" style="font-weight: bold;padding: 5px;"">'.$gross.'</td></tr>';
	
	$number = $gross;
	$no = floor($number);
	$point = round($number - $no, 2) * 100;
	$hundred = null;
	$digits_1 = strlen($no);
	$i = 0;
	$str = array();
	$words = array('0' => '', '1' => 'one', '2' => 'two',
	'3' => 'three', '4' => 'four', '5' => 'five', '6' => 'six',
	'7' => 'seven', '8' => 'eight', '9' => 'nine',
	'10' => 'ten', '11' => 'eleven', '12' => 'twelve',
	'13' => 'thirteen', '14' => 'fourteen',
	'15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen',
	'18' => 'eighteen', '19' =>'nineteen', '20' => 'twenty',
	'30' => 'thirty', '40' => 'forty', '50' => 'fifty',
	'60' => 'sixty', '70' => 'seventy',
	'80' => 'eighty', '90' => 'ninety');
	$digits = array('', 'hundred', 'thousand', 'lakh', 'crore');
	while ($i < $digits_1) {
	 $divider = ($i == 2) ? 10 : 100;
	 $number = floor($no % $divider);
	 $no = floor($no / $divider);
	 $i += ($divider == 10) ? 1 : 2;
	 if ($number) {
		$plural = (($counter = count($str)) && $number > 9) ? 's' : null;
		$hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
		$str [] = ($number < 21) ? $words[$number] .
			" " . $digits[$counter] . $plural . " " . $hundred
			:
			$words[floor($number / 10) * 10]
			. " " . $words[$number % 10] . " "
			. $digits[$counter] . $plural . " " . $hundred;
	 } else $str[] = null;
	}
	$str = array_reverse($str);
	$result = implode('', $str);
	$points = ($point) ?
	"." . $words[$point / 10] . " " .
		  $words[$point = $point % 10] : '';
	if($points !== ""){
		$words = $result . "Rupees  " . $points . " Paise only";
	} else {
		$words = $result . "Rupees only";
	}
	$mailbody .= '<tr><td colspan="7" align="left" style="padding: 5px;"><b>Amount in Words : </b>'.ucwords($words).'</td></tr>';
	$mailbody .= '<tr><td colspan="7" align="right" style="padding: 5px;"><b>For THAGAVAL Shopbee <br><br>Authorized Signatory</b></td></tr>';
	$mailbody .= '</table>';
	$mailbody .= '<span>Whether tax is payable under reverse charge - No</span>';
	echo $mailbody;

}
if($action == "messageview") {
	$msgid = $_GET['msgid'];
	$sql = "SELECT * FROM remainderinbox WHERE sno=$msgid ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$subject = $row["subject"];
		$message = $row["message"];
	}
	?>
	<?php print_r($message); ?>
<?php }
if($action == "dealerorderview") {
	$orderid = $_GET['orderid'];

	$query="UPDATE `dealerorders` SET status=1 WHERE sno=$orderid ";
	$results = $conn->query($query);

	$query="SELECT * FROM `dealerorders` WHERE sno=$orderid ";
	$results = $conn->query($query);
	while($rows = $results->fetch_assoc()) {
		$bill = $rows['bill'];
	}
	$query="SELECT * FROM `dealerordersdetails` WHERE orderid='$orderid' ";
	$results = $conn->query($query);
	$num = $results->num_rows;
	$totqty = 0;
	if($num > 0){ ?>
		<table class="table">
			<tr>
				<td>Sno</td>
				<td>Pdtid</td>
				<td>Name</td>
				<td>Qty</td>
				<td>Remarks</td>
				<td>Action</td>
			</tr>
			<?php
			$sno = 1;
			$totqty = 0;
			while($rows = $results->fetch_assoc()) {
				$pdtid = $rows['pdtid'];
				$remarks = $rows['remarks'];

				$newsql = "SELECT * FROM product WHERE pdtid='$pdtid'";
				$newquery=mysqli_query($conn, $newsql);
				while( $row=mysqli_fetch_array($newquery) ) {
					$name = $row["name"];
				}
				?>
				<tr>
					<td><?php echo $sno; ?></td>
					<td><?php echo $pdtid; ?></td>
					<td><?php echo $name; ?></td>
					<td><?php echo $rows['qty']; ?></td>
					<td><?php echo $remarks; ?></td>
					<td><button class="btn btn-danger btn-xs"><i class="fa fa-trash"></i></td>
				</tr>
			<?php
			$totqty = $totqty + $rows['qty'];
			$sno = $sno + 1;
			} ?>
		</table>
	<?php } ?>
	
<?php }
if($action == "branchrequestview") {
	$requestid = $_GET['requestid'];

	$query="UPDATE `branchrequest` SET status='Complete' WHERE requestid='$requestid' ";
	$results = $conn->query($query);

	$query="SELECT * FROM `requestdetail` WHERE requestid='$requestid' ";
	$results = $conn->query($query);
	$num = $results->num_rows;
	$totqty = 0;
	if($num > 0){ ?>
		<table class="table">
			<tr>
				<td>Sno</td>
				<td>Pdtid</td>
				<td>Name</td>
				<td>Qty</td>
			</tr>
			<?php
			$sno = 1;
			$totqty = 0;
			while($rows = $results->fetch_assoc()) {
				$pdtid = $rows['pdtid'];

				$newsql = "SELECT * FROM product WHERE pdtid='$pdtid'";
				$newquery=mysqli_query($conn, $newsql);
				while( $row=mysqli_fetch_array($newquery) ) {
					$name = $row["name"];
				}
				?>
				<tr>
					<td><?php echo $sno; ?></td>
					<td><?php echo $pdtid; ?></td>
					<td><?php echo $name; ?></td>
					<td><?php echo $rows['qty']; ?></td>
				</tr>
			<?php
			$totqty = $totqty + $rows['qty'];
			$sno = $sno + 1;
			} ?>
		</table>
	<?php } ?>
<?php }
if($action == "completeservice") {
	$serviceid = $_GET['serviceid'];
	$newsql = "SELECT * FROM services WHERE sno > 0 and sno=$serviceid ";
	$newquery=mysqli_query($conn, $newsql);
	while($rows=mysqli_fetch_array($newquery)) {
		$name = $rows['name'];
		$mobile = $rows['mobile'];
		$email = $rows['email'];
		$address = $rows['address'];
		$category = $rows['category'];
		$subcategory = $rows['subcategory'];
		$date = $rows['date'];
		$remarks = $rows['remarks'];
		$createdat = $rows['createdat'];
		$status = $rows['status'];
		$createdat = date("d-M-Y", strtotime($createdat));
		$requestdate = date("d-M-Y", strtotime($date));
	}
	$categoryname = $subcategoryname = "";
	$sql = "SELECT * FROM servicecategory WHERE sno=$category ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$categoryname = $row['name'];
	}
	/* $sql = "SELECT * FROM servicesubcategory WHERE sno=$subcategory ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$subcategoryname = $row['name'];
	} */
	?>
	<!--<table class="table">
		<tr>
			<td>
				<h6><b> Address </b></h6>
			</td>
			<td>:</td>
			<td>
				<?php echo $address; ?>
			</td>
		</tr>
		<tr>
			<td>
				<h6><b> Service Type </b></h6>
			</td>
			<td>:</td>
			<td>
				<?php echo $categoryname." -> ".$subcategoryname; ?>
			</td>
		</tr>

		<tr>
			<td>
				<h6><b> Service Request Date </b></h6>
			</td>
			<td>:</td>
			<td>
				<?php echo $requestdate; ?>
			</td>
		</tr>
		<tr>
			<td>
				<h6><b> Request Created Date </b></h6>
			</td>
			<td>:</td>
			<td>
				<?php echo $createdat; ?>
			</td>
		</tr>
		<tr>
			<td>
				<h6><b> Remarks </b></h6>
			</td>
			<td>:</td>
			<td>
				<?php echo $remarks; ?>
			</td>
		</tr>
	</table>-->
	<form action="acceptedserviceview.php" method="post" enctype="multipart/form-data" onsubmit="return confirm('Are you sure you want to Complete this?');">
		<div class="form-group">
			<label for="name">Paid Amount&nbsp;<span class="text-danger">*</span></label>
			<input type="number" class="form-control" name="paidamnt" id="paidamnt" step="0.01" min="1" placeholder="Enter Paid Amount" required />
		</div>
		<div class="form-group">
			<label for="name">Service / Customer Remarks&nbsp;<span class="text-danger">*</span></label>
			<textarea class="form-control" name="serviceremarks" id="serviceremarks" placeholder="Enter Service Remarks" required ></textarea>
		</div>
		<div class="form-group">
			<label for="name">Bill No&nbsp;<span class="text-danger">*</span></label>
			<input type="text" class="form-control" name="invoice_no" id="invoice_no" placeholder="Enter Bill no" required />
		</div>
		<div class="form-group">
			<label for="name">Attachment File</label>
			<input type="file" class="form-control" name="invoice_attachment" id="invoice_attachment" />
		</div>
		<div class="form-group">
			<label for="name">Service Type&nbsp;<span class="text-danger">*</span></label>
			<select name="service_type" class="form-control select2bs4" id="service_type" required>
				<option value="">Select Service Type</option>
				<?php $sql = "SELECT * FROM service_type WHERE ser_type_id > 0 and status = 1 ";
					$query = mysqli_query($conn, $sql);
					while($row = mysqli_fetch_array($query)) {
				?>
					<option value="<?php echo $row['ser_type_id']; ?>" ><?php echo $row['ser_type'].' - '.$row['service_days']; ?></option>
				<?php } ?>
			</select>
		</div>
		<div class="form-group">
			<label for="name">Brand Type&nbsp;<span class="text-danger">*</span></label>
			<select name="brand_type" class="form-control select2bs4" id="brand_type" required>
				<option value="">Select Brand</option>
				<?php $sql = "SELECT * FROM brand_master WHERE brand_id > 0 and status = 1 ";
					$query = mysqli_query($conn, $sql);
					while($row = mysqli_fetch_array($query)) {
				?>
					<option value="<?php echo $row['brand_id']; ?>" ><?php echo $row['brand_name']; ?></option>
				<?php } ?>
			</select>
		</div>
		<input type="hidden" class="form-control" id="id" name="id" value="<?php echo $serviceid; ?>">
		<input type="hidden" class="form-control" id="action" name="action" value="servicecomments">
		<button type="submit" class="btn btn-sm btn-info pull-right">Submit</button>
	</form>
<?php }
if($action == "referalpdtview") {
	$referalid = $_GET['referalid'];
	$sno = 1;
	echo "<table class='table'><tr><td align='center'><b>Sno</b></td><td align='center'><b>Products</b></td></tr>";
	$sql = "SELECT * FROM techreferal WHERE sno=$referalid ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$pdts = $row["pdts"];
		$remarks = $row["remarks"];
	}
	$pdtsarray = explode(",", $pdts);
	foreach($pdtsarray as $pdt){
		$sql = "SELECT * FROM product WHERE pdtid='$pdt' ";
		$query=mysqli_query($conn, $sql);
		while( $row=mysqli_fetch_array($query) ) {
			$name = $row["name"];
		}
		echo "<tr><td align='center'>".$sno."</td><td>".$name."</td></tr>";
		$sno = $sno + 1;
	}
	echo "</table>";
	if($remarks !== ""){
		echo "<hr><p><b>Remarks:</b></p>";
		echo "<p>".$remarks."</p>";
	}
}
if($action == "referalsalecomplete") {
	$referalid = $_GET['referalid'];
	$page = $_GET['page'];
	$sql = "SELECT * FROM techreferal WHERE sno=$referalid ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$pdts = $row["pdts"];
		$remarks = $row["remarks"];
		$customer = $row["customer"];
		$status = $row["status"];
	}
	$pdtsarray = explode(",", $pdts);
	?>

	<form action="<?php echo $page; ?>.php" method="POST" enctype="multipart/form-data">
		<div class="form-group">
			<label for="exampleFormControlInput1">Status</label>
			<select class="form-control select2bs4" name="status" id="status" onchange="statuscheck();" required>
				<option value="">-SELECT-</option>
				<option value="Pending" <?php if($status == "Pending"){ echo "SELECTED"; } ?>>Pending</option>
				<option value="Complete" <?php if($status == "Complete"){ echo "SELECTED"; } ?>>Complete</option>
				<option value="Reject" <?php if($status == "Reject"){ echo "SELECTED"; } ?>>Reject</option>
			</select>
		</div>
		<div class="form-group">
			<label for="exampleFormControlInput1">Refer Products</label>
			<select class="form-control select2bs4" name="referpdts[]" id="referpdts" multiple="multiple" required>
				<option value="">-SELECT-</option>
				<?php
				$newsql = "SELECT * FROM product WHERE status=1 ";
				$newquery=mysqli_query($conn, $newsql);
				while( $rows=mysqli_fetch_array($newquery) ) {
					$pdtid = $rows["pdtid"];
					$name = $rows["name"];
				?>
				<option value="<?php echo $pdtid; ?>" <?php if (in_array($pdtid, $pdtsarray)){echo "SELECTED"; } ?>><?php echo $name; ?></option>
				<?php } ?>
			</select>
		</div>
		<div class="form-group">
			<label for="exampleFormControlInput1">Customer Bills</label>
			<select class="form-control select2bs4" name="bills" id="bills" <?php if($status == "Complete"){echo "required"; } ?>>
				<option value="">-SELECT-</option>
				<?php
				$newsql = "SELECT * FROM sales WHERE customer='$customer' ";
				$newquery=mysqli_query($conn, $newsql);
				while( $rows=mysqli_fetch_array($newquery) ) {
					$referenceno = $rows["referenceno"];
				?>
				<option value="<?php echo $referenceno; ?>"><?php echo $referenceno; ?></option>
				<?php } ?>
			</select>
		</div>
		<input type="hidden" class="form-control" id="referalid" name="referalid" value="<?php echo $referalid; ?>">
		<input type="hidden" class="form-control" id="action" name="action" value="referalstatus">
		<button type="submit" class="btn btn-success">Submit</button>
	</form>
	<script>
	function statuscheck(){
		var status = $('#status').val();
		if(status == "Complete"){
			$("#bills").prop("required", true);
		} else {
			$("#bills").prop("required", false);
		}
	}
	</script>
<?php
}
if($action == "editjobpackage"){
	$packageid = $_GET['packageid'];
	$sql = "SELECT * FROM jobs_packages WHERE packageid='$packageid' ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$packagename = $row["packagename"];
		$contenttype = $row["contenttype"];
		$duration = $row["duration"];
		$amount = $row["amount"];
		$status = $row["status"];
	}
	?>
	<form action="jobs_package.php" method="POST" enctype="multipart/form-data">
		<div class="form-group">
			<label for="exampleFormControlInput1">Package Id</label>
			<input type="text" class="form-control" id="id" name="id" value="<?php echo $packageid; ?>" required readonly >
			<input type="hidden" class="form-control" id="packagetype" name="packagetype" value="Jobs">
		</div>
		<div class="form-group">
			<label for="exampleFormControlInput1">Name</label>
			<input type="text" class="form-control" id="name" name="name" value="<?php echo $packagename; ?>" required>
			<input type="hidden" class="form-control" id="action" name="action" value="edit">
		</div>
		<div class="form-group">
			<label for="exampleFormControlInput1">Type</label>
			<select name="type" id="type" class="form-control" required>
				<option value="Text" <?php if($contenttype == "Text"){ echo "SELECTED"; } ?>>Text</option>
				<option value="Color" <?php if($contenttype == "Color"){ echo "SELECTED"; } ?>>Color</option>
				<option value="Image" <?php if($contenttype == "Image"){ echo "SELECTED"; } ?>>Image</option>
			</select>
		</div>
		<div class="form-group">
			<label for="exampleFormControlInput1">Duration</label>
			<input type="number" class="form-control" id="duration" name="duration" value="<?php echo $duration; ?>" required>
		</div>
		<div class="form-group">
			<label for="exampleFormControlInput1">Pricing</label>
			<input type="number" class="form-control" id="pricing" name="pricing" step="0.01" min="0" value="<?php echo $amount; ?>" required>
		</div>
		<div class="form-group">
			<label>Status</label>
			<select name="status" class="form-control" id="status"  required >
				<option></option>
				<option value="1" <?php if($status == 1){echo "SELECTED";} ?>>Enable</option>
				<option value="0" <?php if($status == 0){echo "SELECTED";} ?>>Disable</option>
			</select>
		</div>
		<button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php }
if($action == "editpropertypackage"){
	$packageid = $_GET['packageid'];
	$sql = "SELECT * FROM property_packages WHERE packageid='$packageid' ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$packagename = $row["packagename"];
		$contenttype = $row["contenttype"];
		$duration = $row["duration"];
		$amount = $row["amount"];
		$status = $row["status"];
	}
	?>
	<form action="property_package.php" method="POST" enctype="multipart/form-data">
		<div class="form-group">
			<label for="exampleFormControlInput1">Package Id</label>
			<input type="text" class="form-control" id="id" name="id" value="<?php echo $packageid; ?>" required readonly >
			<input type="hidden" class="form-control" id="packagetype" name="packagetype" value="Property">
		</div>
		<div class="form-group">
			<label for="exampleFormControlInput1">Name</label>
			<input type="text" class="form-control" id="name" name="name" value="<?php echo $packagename; ?>" required>
			<input type="hidden" class="form-control" id="action" name="action" value="edit">
		</div>
		<div class="form-group">
			<label for="exampleFormControlInput1">Type</label>
			<select name="type" id="type" class="form-control" required>
				<option value="Text" <?php if($contenttype == "Text"){ echo "SELECTED"; } ?>>Text</option>
				<option value="Color" <?php if($contenttype == "Color"){ echo "SELECTED"; } ?>>Color</option>
				<option value="Image" <?php if($contenttype == "Image"){ echo "SELECTED"; } ?>>Image</option>
			</select>
		</div>
		<div class="form-group">
			<label for="exampleFormControlInput1">Duration</label>
			<input type="number" class="form-control" id="duration" name="duration" value="<?php echo $duration; ?>" required>
		</div>
		<div class="form-group">
			<label for="exampleFormControlInput1">Pricing</label>
			<input type="number" class="form-control" id="pricing" name="pricing" step="0.01" min="0" value="<?php echo $amount; ?>" required>
		</div>
		<div class="form-group">
			<label>Status</label>
			<select name="status" class="form-control" id="status"  required >
				<option></option>
				<option value="1" <?php if($status == 1){echo "SELECTED";} ?>>Enable</option>
				<option value="0" <?php if($status == 0){echo "SELECTED";} ?>>Disable</option>
			</select>
		</div>
		<button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php }
if($action == "editclassifiedpackage"){
	$packageid = $_GET['packageid'];
	$sql = "SELECT * FROM classified_packages WHERE packageid='$packageid' ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$packagename = $row["packagename"];
		$contenttype = $row["contenttype"];
		$duration = $row["duration"];
		$amount = $row["amount"];
		$status = $row["status"];
	}
	?>
	<form action="classified_package.php" method="POST" enctype="multipart/form-data">
		<div class="form-group">
			<label for="exampleFormControlInput1">Package Id</label>
			<input type="text" class="form-control" id="id" name="id" value="<?php echo $packageid; ?>" required readonly >
			<input type="hidden" class="form-control" id="packagetype" name="packagetype" value="Property">
		</div>
		<div class="form-group">
			<label for="exampleFormControlInput1">Name</label>
			<input type="text" class="form-control" id="name" name="name" value="<?php echo $packagename; ?>" required>
			<input type="hidden" class="form-control" id="action" name="action" value="edit">
		</div>
		<div class="form-group">
			<label for="exampleFormControlInput1">Type</label>
			<select name="type" id="type" class="form-control" required>
				<option value="Text" <?php if($contenttype == "Text"){ echo "SELECTED"; } ?>>Text</option>
				<option value="Color" <?php if($contenttype == "Color"){ echo "SELECTED"; } ?>>Color</option>
				<option value="Image" <?php if($contenttype == "Image"){ echo "SELECTED"; } ?>>Image</option>
			</select>
		</div>
		<div class="form-group">
			<label for="exampleFormControlInput1">Duration</label>
			<input type="number" class="form-control" id="duration" name="duration" value="<?php echo $duration; ?>" required>
		</div>
		<div class="form-group">
			<label for="exampleFormControlInput1">Pricing</label>
			<input type="number" class="form-control" id="pricing" name="pricing" step="0.01" min="0" value="<?php echo $amount; ?>" required>
		</div>
		<div class="form-group">
			<label>Status</label>
			<select name="status" class="form-control" id="status"  required >
				<option></option>
				<option value="1" <?php if($status == 1){echo "SELECTED";} ?>>Enable</option>
				<option value="0" <?php if($status == 0){echo "SELECTED";} ?>>Disable</option>
			</select>
		</div>
		<button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php }
if($action == "changepoststatus"){
	$postid = $_GET['postid'];
	$types = $_GET['types'];
	if($types == "jobs"){
		$table = "jobpost";
	} elseif($types == "property") {
		$table = "propertypost";
	} elseif($types == "classified"){
		$table = "classifiedpost";
	} elseif($types == "blog"){
		$table = "blogpost";
	}
	$sql = "SELECT * FROM ".$table." WHERE postid='$postid' ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$status = $row["status"];
		$postid = $row["postid"];
	}
	?>
	<form>	
		<div class="form-group">
			<label for="exampleFormControlInput1">Postid</label>
			<input type="text" name="postid" id="postid" value="<?php echo $postid; ?>" class="form-control" readonly />
		</div>	
		<div class="form-group">
			<label for="exampleFormControlInput1">Status</label>
			<select name="status" id="status" class="form-control" required>
				<option value="Pending" <?php if($status == "Pending"){ echo "SELECTED"; } ?>>Pending</option>
				<option value="Active" <?php if($status == "Active"){ echo "SELECTED"; } ?>>Active</option>
				<?php 
				if($types == "blog"){ ?>
					<option value="Inactive" <?php if($status == "Inactive"){ echo "SELECTED"; } ?>>Inactive</option>
				<?php } else { ?>
					<option value="Expired" <?php if($status == "Expired"){ echo "SELECTED"; } ?>>Expired</option>
				<?php } ?>
				<option value="Delete" <?php if($status == "Delete"){ echo "SELECTED"; } ?>>Delete</option>
			</select>
		</div>		
		<input type="hidden" name="types" id="types" value="<?php echo $types; ?>" />
		<button type="button" class="btn btn-primary btn-default" onclick="updatestatus();">Submit</button>
	</form>
	<script>
	function updatestatus(){
		var postid = $('#postid').val();
		var status = $('#status').val();
		var action = "updatestatus";
		var types = $('#types').val();
		$.ajax({
			type: "POST",
			url: "functions.php",
			data: { postid: postid, status: status, types: types, action: action },
			dataType: "html",
			success: function(data){
				window.location.reload();
			}
		});
	}
	</script>
<?php }
if($action == "changereviewstatus"){
	$id = $_GET['postid'];
	$types = $_GET['types'];
	if($types == "jobs"){
		$table = "jobpost";
	} elseif($types == "property") {
		$table = "propertypost";
		$reviewtable = "propertyreview";
	} elseif($types == "classified"){
		$table = "classifiedpost";
		$reviewtable = "classifiedreview";
	} elseif($types == "blog"){
		$table = "blogpost";
		$reviewtable = "blogreview";
	}
	$sql = "SELECT * FROM ".$reviewtable." WHERE sno=$id ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$status = $row["status"];
		$postid = $row["postid"];
	}
	?>
	<form>	
		
		<div class="form-group">
			<label for="exampleFormControlInput1">Status</label>
			<select name="status" id="status" class="form-control" required>
				<option value="Pending" <?php if($status == "Pending"){ echo "SELECTED"; } ?>>Pending</option>
				<option value="Approved" <?php if($status == "Approved"){ echo "SELECTED"; } ?>>Approved</option>
				<option value="Delete" <?php if($status == "Delete"){ echo "SELECTED"; } ?>>Delete</option>
			</select>
		</div>		
		<input type="hidden" name="types" id="types" value="<?php echo $types; ?>" />
		<input type="hidden" name="id" id="id" value="<?php echo $id; ?>" />
		<button type="button" class="btn btn-primary btn-default" onclick="updatereviewstatus();">Submit</button>
	</form>
	<script>
	function updatereviewstatus(){
		var postid = $('#id').val();
		var status = $('#status').val();
		var action = "updatereviewstatus";
		var types = $('#types').val();
		$.ajax({
			type: "POST",
			url: "functions.php",
			data: { postid: postid, status: status, types: types, action: action },
			dataType: "html",
			success: function(data){
				window.location.reload();
			}
		});
	}
	</script>
<?php }
if($action == "viewpost"){
	$postid = $_GET['postid'];
	$sql = "SELECT * FROM jobpost WHERE postid='$postid' ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$status = $row["status"];
		$postid = $row["postid"];
		$description = $row["description"];
		$minsalary = $row["minsalary"];
		$maxsalary = $row["maxsalary"];
		$city = $row["city"];
		$area = $row["area"];
		$gender = $row["gender"];
		$expiredat = $row["expiredat"];
		$packageid = $row["packageid"];
		$packagetype = $row["packagetype"];
		$image = $row["image"];
		$category = $row["category"];
		$subcategory = $row["subcategory"];
		$mobile = $row["mobile"];
		$experience = $row["experience"];
		$brandlogo = $row["brandlogo"];
	}
	$sql = "SELECT * FROM jobs_packages WHERE packageid='$packageid' ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$duration = $row["duration"];
		$amount = $row["amount"];
		$contenttype = $row["contenttype"];
	}
	$sql = "SELECT * FROM jobs_city WHERE sno=$city ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$cityname = $row["name"];
	}
	$sql = "SELECT * FROM jobs_area WHERE sno=$area ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$areaname = $row["area"];
	}
	$sql = "SELECT * FROM jobs_category WHERE sno=$category ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$categoryname = $row["name"];
	}
	$sql = "SELECT * FROM jobs_subcategory WHERE sno=$subcategory ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$subcategoryname = $row["name"];
	}
	$expiredat = date("d-M-Y", strtotime($expiredat));
	?>
	<table class="table">
		<tr><td><b>Post Id</b></td><td>:</td><td><?php echo $postid; ?></td></tr>
		<tr><td><b>Packagetype</b></td><td>:</td><td><?php echo $packagetype; ?></td></tr>
		<tr>
			<td><b>Description / Image</b></td><td>:</td><td><?php if($packagetype == "Image"){ ?><img src="uploads/<?php echo $image; ?>" width="150" class="img-responsive" /> <?php } else { echo $description; } ?></td>
		</tr>
		<tr><td><b>Salary</b></td><td>:</td><td><?php echo $minsalary." - ".$maxsalary; ?></td></tr>
		<tr><td><b>Category</b></td><td>:</td><td><?php echo $categoryname." -> ".$subcategoryname; ?></td></tr>
		<tr><td><b>Area</b></td><td>:</td><td><?php echo $cityname." -> ".$areaname; ?></td></tr>
		<tr><td><b>Gender</b></td><td>:</td><td><?php echo $gender; ?></td></tr>
		<tr>
			<td><b>Experience</b></td>
			<td>:</td>
			<td>
				<?php 
				if($experience == 0){ echo "Fresher"; } 
				if($experience == 1){ echo "1 Year Experience"; } 
				if($experience > 1){ echo $experience." Years Experience"; } 
				?>
			</td>
		</tr>
		<tr><td><b>Expired At</b></td><td>:</td><td><?php echo $expiredat; ?></td></tr>
		<tr><td><b>Package</b></td><td>:</td><td><?php echo $contenttype." for ".$duration." days of Rs. ".$amount." /-"; ?></td></tr>
		<tr><td><b>Contact</b></td><td>:</td><td><?php echo $mobile; ?></td></tr>
		<?php 
		if($brandlogo !== ""){ ?>
		<tr>
			<td><b>Brand Logo</b></td><td>:</td><td><img src="uploads/<?php echo $brandlogo; ?>" width="150" class="img-responsive" /></td>
		</tr>
		<?php } ?>
	</table>
<?php }
if($action == "editpost"){
	$postid = $_GET['postid'];
	$sql = "SELECT * FROM jobpost WHERE postid='$postid' ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$status = $row["status"];
		$postid = $row["postid"];
		$idno = $row["idno"];
		$description = $row["description"];
		$minsalary = $row["minsalary"];
		$maxsalary = $row["maxsalary"];
		$experience = $row["experience"];
		$city = $row["city"];
		$area = $row["area"];
		$gender = $row["gender"];
		$expiredat = $row["expiredat"];
		$packageid = $row["packageid"];
		$packagetype = $row["packagetype"];
		$image = $row["image"];
		$title = $row["name"];
		$category = $row["category"];
		$subcategory = $row["subcategory"];
		$brandlogo = $row["brandlogo"];
		$brand = $row["brand"];
		$premium = $row["premium"];
		$color = $row["color"];
		$mobile = $row["mobile"];
		$packagetype = $row["packagetype"];
	}
	
	?>
	
		
	<div class="row">
		<div class="col-md-6">
			<div class="form-group">
				<label for="exampleFormControlInput1">Type</label>
				<select name="type" id="type" class="form-control" required onchange="packagetype();">
					<option value="">-SELECT-</option>
					<option value="Text" <?php if($packagetype == "Text"){ echo "SELECTED";} ?>>Text</option>
					<option value="Color" <?php if($packagetype == "Color"){ echo "SELECTED";} ?>>Color</option>
					<option value="Image" <?php if($packagetype == "Image"){ echo "SELECTED";} ?>>Image</option>
				</select>
			</div>
		</div>	
		<div class="col-md-6">
			<div class="form-group">
				<label for="exampleFormControlInput1">Color</label>
				<select name="color" id="color" class="form-control">
					<option value="">-SELECT-</option>
					<option value="Green" <?php if($color == "Green"){ echo "SELECTED";} ?>>Green</option>
					<option value="Blue" <?php if($color == "Blue"){ echo "SELECTED";} ?>>Blue</option>
					<option value="Pink" <?php if($color == "Pink"){ echo "SELECTED";} ?>>Pink</option>
					<option value="Orange" <?php if($color == "Orange"){ echo "SELECTED";} ?>>Orange</option>
				</select>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-md-6">
			<div class="form-group">
				<label for="exampleFormControlInput1">Category</label>
				<select name="category" id="category" class="form-control" onchange="changecategory();" required>
					<option value="">-SELECT-</option>
					<?php
					  $newsql = "SELECT * FROM jobs_category WHERE status=1 ";
					  $newquery=mysqli_query($conn, $newsql);
					  while( $rows=mysqli_fetch_array($newquery) ) {
						  $name = $rows["name"];
						  $cid = $rows["sno"];
						  ?>
						  <option value="<?php echo $cid; ?>" <?php if($category == $cid){ echo "SELECTED"; } ?>><?php echo $name; ?></option>
					  <?php } ?>
				</select>
			</div>
		</div>
		<div class="col-md-6">
			<div class="form-group">
				<label for="exampleFormControlInput1">Sub Categroy</label>
				<select name="subcategory" id="subcategory" class="form-control" required>
					<option value="">-SELECT-</option>
					<?php
					  $newsql = "SELECT * FROM jobs_subcategory WHERE status=1 AND cid=$category ";
					  $newquery=mysqli_query($conn, $newsql);
					  while( $rows=mysqli_fetch_array($newquery) ) {
						  $name = $rows["name"];
						  $scid = $rows["sno"];
						  ?>
						  <option value="<?php echo $scid; ?>" <?php if($subcategory == $scid){ echo "SELECTED"; } ?>><?php echo $name; ?></option>
					  <?php } ?>
				</select>
			</div>
		</div>
		
	</div>
	<div class="row">
		<div class="col-md-4">
			<div class="form-group">
				<label for="exampleFormControlInput1">City</label>
				<select name="district" id="district" class="form-control" onchange="changedistric();" required>
					<option value="">-SELECT-</option>
					<?php
					  $newsql = "SELECT * FROM jobs_city ORDER BY name";
					  $newquery=mysqli_query($conn, $newsql);
					  while( $rows=mysqli_fetch_array($newquery) ) {
					  $name = $rows["name"];
					  $sno = $rows["sno"];
					  ?>
					  <option value="<?php echo $sno; ?>" <?php if($sno == $city){ echo "SELECTED"; } ?>><?php echo $name; ?></option>
					  <?php } ?>
				</select>
			</div>
		</div>
		<div class="col-md-4">
			<div class="form-group">
				<label for="exampleFormControlInput1">Area</label>
				<select name="area" id="area" class="form-control" required>
					<option value="">-SELECT-</option>
					<?php
					  $newsql = "SELECT * FROM jobs_area WHERE district=$city ORDER BY area";
					  $newquery=mysqli_query($conn, $newsql);
					  while( $rows=mysqli_fetch_array($newquery) ) {
					  $name = $rows["area"];
					  $sno = $rows["sno"];
					  ?>
					  <option value="<?php echo $sno; ?>" <?php if($sno == $area){ echo "SELECTED";} ?>><?php echo $name; ?></option>
					  <?php } ?>
				</select>
			</div>
		</div>
		<div class="col-md-4">
			<div class="form-group">
				<label for="exampleFormControlInput1">Gender</label>
				<select name="gender" id="gender" class="form-control" >
					<option value="">-SELECT-</option>
					<option value="Male" <?php if($gender == "Male"){ echo "SELECTED";} ?>>Male</option>
					<option value="Female" <?php if($gender == "Female"){ echo "SELECTED";} ?>>Female</option>
					<option value="Male / Female" <?php if($gender == "Male / Female"){ echo "SELECTED";} ?>>Male / Female</option>
				</select>
			</div>
		</div>
	</div>
	<div class="form-group">
		<label for="exampleFormControlInput1">Title</label>
		<input type="text" class="form-control" id="name" name="name" required value="<?php echo $title; ?>" >
		<input type="hidden" class="form-control" id="action" name="action" value="edit">
		<input type="hidden" class="form-control" id="id" name="id" value="<?php echo $postid; ?>">
	</div>
	<div class="form-group">
		<label for="exampleFormControlInput1">Description</label>
		<textarea name="description" id="description" class="form-control" rows="5"><?php echo $description; ?></textarea>
	</div>
	<div class="form-group">		
		<label for="exampleFormControlInput1">Image(Best View : 620px X 500px)</label>
		<?php 
		if($image !== ""){ ?>
		<br><img src="uploads/<?php echo $image; ?>"  class="img-fluid" />
		<?php } ?>
		<input type="file" name="postimage" id="postimage" class="form-control" disabled />
	</div>
	<div class="form-group">
		<label for="exampleFormControlInput1">Brand Logo(Best View : 200px X 80px)</label>
		<?php 
		if($brandlogo !== ""){ ?>
		<br><img src="uploads/<?php echo $brandlogo; ?>"  class="img-fluid" />
		<?php } ?>
		<input type="file" name="brandlogo" id="brandlogo" class="form-control" />
	</div>
	<div class="row">
		<div class="col-md-4">			
			<div class="form-group">
				<label for="exampleFormControlInput1">Min Salary</label>
				<input type="number" class="form-control num" id="minsalary" name="minsalary" maxlength="6" value="<?php echo $minsalary; ?>" >
			</div>
		</div>
		<div class="col-md-4">			
			<div class="form-group">
				<label for="exampleFormControlInput1">Max Salary</label>
				<input type="number" class="form-control num" id="maxsalary" name="maxsalary" maxlength="6" value="<?php echo $maxsalary; ?>" >
			</div>
		</div>
		<div class="col-md-4">			
			<div class="form-group">
				<label for="exampleFormControlInput1">Experience(0 means Fresher)</label>
				<input type="number" class="form-control num" id="experience" name="experience" maxlength="2" value="<?php echo $experience; ?>" aria-describedby="emailHelp" >
			</div>
		</div>
	</div>
	<div class="form-group">
		<label for="exampleFormControlInput1">Contact No.</label>
		<input type="number" class="form-control num" id="contact" name="contact" maxlength="10" value="<?php echo $mobile; ?>" >
	</div>
	<div class="form-check">
		<input type="checkbox" class="form-check-input" value="Premium" id="Premium" name="extra[]" <?php if($premium){ echo "CHECKED"; } ?>>
		<label class="form-check-label" for="exampleCheck1">Home Page premium</label>
	</div>
	<div class="form-check">
		<input type="checkbox" class="form-check-input" value="Brand" id="Brand" name="extra[]" <?php if($brand){ echo "CHECKED"; } ?>>
		<label class="form-check-label" for="exampleCheck1">Brand Logo Premium</label>
	</div>
	<button type="submit" class="btn btn-primary btn-default">Submit</button>
	<script>
	$(".num").keypress(function() {
		if ($(this).val().length == $(this).attr("maxlength")) {
			return false;
		}
	});
	</script>
<?php }
if($action == "editstate"){ 
	$id = $_GET['id'];
	$newsql = "SELECT * FROM jobs_state WHERE sno=$id ";
	$newquery=mysqli_query($conn, $newsql);
	$sno = 1;
	while( $rows=mysqli_fetch_array($newquery) ) {
		$id = $rows["sno"];
		$statename = $rows["name"];
	}
	?>
	<form action="jobs_state.php" method="POST">
	  <div class="form-group">
		<label for="exampleFormControlInput1">State</label>
		<input type="text" class="form-control" id="state" name="state" value="<?php echo $statename; ?>" required >
		<input type="hidden" class="form-control" id="action" name="action" value="editstate">
		<input type="hidden" class="form-control" id="id" name="id" value="<?php echo $id; ?>">
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php } 
if($action == "editcity"){ 
	$id = $_GET['id'];
	$newsql = "SELECT * FROM jobs_city WHERE sno=$id ";
	$newquery=mysqli_query($conn, $newsql);
	$sno = 1;
	while( $rows=mysqli_fetch_array($newquery) ) {
		$id = $rows["sno"];
		$cityname = $rows["name"];
		$state = $rows["state"];
		$image = $rows["image"];
	}
	?>
	<form action="jobs_state.php" method="POST" enctype="multipart/form-data" >
	  <div class="form-group">
		<label for="exampleFormControlInput1">State</label>
		<select name="state" id="state" class="select2bs4 form-control">
			<?php
			  $newsql = "SELECT * FROM jobs_state ";
			  $newquery=mysqli_query($conn, $newsql);
			  while( $rows=mysqli_fetch_array($newquery) ) {
			  $name = $rows["name"];
			  $id = $rows["sno"];
			  ?>
			  <option value="<?php echo $id; ?>" <?php if($id == $state){ echo "SELECTED"; } ?>><?php echo $name; ?></option>
			  <?php } ?>
		</select>
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
	  <div class="form-group">
		<label for="exampleFormControlInput1">District</label>
		<input type="text" class="form-control" id="district" name="district" value="<?php echo $cityname; ?>" required >
		<input type="hidden" class="form-control" id="action" name="action" value="editdistrict">
		<input type="hidden" class="form-control" id="id" name="id" value="<?php echo $id; ?>">
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
	  <div class="form-group">
		<!-- bootstrap-imageupload. -->
		<div class="imageupload ibox ibox-grey">
			<div class="ibox-heading clearfix">
				<h3 class="ibox-title pull-left">Image</h3>
			</div>
			<img src="uploads/<?php echo $image; ?>" class="img-responsive" width="200" />
			<div class="file-tab ibox-body">
				<label class="btn btn-default btn-file">
					<span>Browse</span>
					<!-- The file is stored here. -->
					<input type="file" name="frontimg" >

				</label>
				<p class="help-block">*accept only jpg,png - Size : 500px X 400px</p>
				<button type="button" class="btn btn-default">Remove</button>
			</div>
		</div>
	  </div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php }
if($action == "editarea"){
	$id = $_GET['id'];
	$newsql = "SELECT * FROM jobs_area WHERE sno=$id ";
	$newquery=mysqli_query($conn, $newsql);
	$sno = 1;
	while( $rows=mysqli_fetch_array($newquery) ) {
		$id = $rows["sno"];
		$state = $rows["state"];
		$district = $rows["district"];
		$area = $rows["area"];
	}
	?>
	<form action="jobs_state.php" method="POST">
	  <div class="form-group">
		<label for="exampleFormControlInput1">District</label>
		<input type="hidden" class="form-control" id="action" name="action" value="editarea">
		<input type="hidden" class="form-control" id="id" name="id" value="<?php echo $id; ?>">
		<select name="district" id="district" class="select2bs4 form-control">
			<?php
			  $newsql = "SELECT * FROM jobs_city WHERE sno=$district ";
			  $newquery=mysqli_query($conn, $newsql);
			  while( $rows=mysqli_fetch_array($newquery) ) {
			  $name = $rows["name"];
			  $sno = $rows["sno"];
			  ?>
			  <option value="<?php echo $sno; ?>"><?php echo $name; ?></option>
			  <?php } ?>
		</select>
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
	  <div class="form-group">
		<label for="exampleFormControlInput1">Area</label>
		<input type="text" class="form-control" id="area" name="area" value="<?php echo $area; ?>" required >
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php } 
if($action == "editpropertystate"){ 
	$id = $_GET['id'];
	$newsql = "SELECT * FROM property_state WHERE sno=$id ";
	$newquery=mysqli_query($conn, $newsql);
	$sno = 1;
	while( $rows=mysqli_fetch_array($newquery) ) {
		$id = $rows["sno"];
		$statename = $rows["name"];
	}
	?>
	<form action="property_state.php" method="POST">
	  <div class="form-group">
		<label for="exampleFormControlInput1">State</label>
		<input type="text" class="form-control" id="state" name="state" value="<?php echo $statename; ?>" required >
		<input type="hidden" class="form-control" id="action" name="action" value="editstate">
		<input type="hidden" class="form-control" id="id" name="id" value="<?php echo $id; ?>">
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php } 
if($action == "editpropertycity"){ 
	$id = $_GET['id'];
	$newsql = "SELECT * FROM property_city WHERE sno=$id ";
	$newquery=mysqli_query($conn, $newsql);
	$sno = 1;
	while( $rows=mysqli_fetch_array($newquery) ) {
		$id = $rows["sno"];
		$cityname = $rows["name"];
		$state = $rows["state"];
		$image = $rows["image"];
	}
	?>
	<form action="property_state.php" method="POST" enctype="multipart/form-data" >
	  <div class="form-group">
		<label for="exampleFormControlInput1">State</label>
		<select name="state" id="state" class="select2bs4 form-control">
			<?php
			  $newsql = "SELECT * FROM property_state ";
			  $newquery=mysqli_query($conn, $newsql);
			  while( $rows=mysqli_fetch_array($newquery) ) {
			  $name = $rows["name"];
			  $id = $rows["sno"];
			  ?>
			  <option value="<?php echo $id; ?>" <?php if($id == $state){ echo "SELECTED"; } ?>><?php echo $name; ?></option>
			  <?php } ?>
		</select>
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
	  <div class="form-group">
		<label for="exampleFormControlInput1">District</label>
		<input type="text" class="form-control" id="district" name="district" value="<?php echo $cityname; ?>" required >
		<input type="hidden" class="form-control" id="action" name="action" value="editdistrict">
		<input type="hidden" class="form-control" id="id" name="id" value="<?php echo $id; ?>">
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
	  <div class="form-group">
		<!-- bootstrap-imageupload. -->
		<div class="imageupload ibox ibox-grey">
			<div class="ibox-heading clearfix">
				<h3 class="ibox-title pull-left">Image</h3>
			</div>
			<img src="uploads/<?php echo $image; ?>" class="img-responsive" width="200" />
			<div class="file-tab ibox-body">
				<label class="btn btn-default btn-file">
					<span>Browse</span>
					<!-- The file is stored here. -->
					<input type="file" name="frontimg" >

				</label>
				<p class="help-block">*accept only jpg,png - Size : 500px X 400px</p>
				<button type="button" class="btn btn-default">Remove</button>
			</div>
		</div>
	  </div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php }
if($action == "editpropertyarea"){
	$id = $_GET['id'];
	$newsql = "SELECT * FROM property_area WHERE sno=$id ";
	$newquery=mysqli_query($conn, $newsql);
	$sno = 1;
	while( $rows=mysqli_fetch_array($newquery) ) {
		$id = $rows["sno"];
		$state = $rows["state"];
		$district = $rows["district"];
		$area = $rows["area"];
	}
	?>
	<form action="property_state.php" method="POST">
	  <div class="form-group">
		<label for="exampleFormControlInput1">District</label>
		<input type="hidden" class="form-control" id="action" name="action" value="editarea">
		<input type="hidden" class="form-control" id="id" name="id" value="<?php echo $id; ?>">
		<select name="district" id="district" class="select2bs4 form-control">
			<?php
			  $newsql = "SELECT * FROM property_city WHERE sno=$district ";
			  $newquery=mysqli_query($conn, $newsql);
			  while( $rows=mysqli_fetch_array($newquery) ) {
			  $name = $rows["name"];
			  $sno = $rows["sno"];
			  ?>
			  <option value="<?php echo $sno; ?>"><?php echo $name; ?></option>
			  <?php } ?>
		</select>
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
	  <div class="form-group">
		<label for="exampleFormControlInput1">Area</label>
		<input type="text" class="form-control" id="area" name="area" value="<?php echo $area; ?>" required >
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php } 
if($action == "editclassifiedstate"){ 
	$id = $_GET['id'];
	$newsql = "SELECT * FROM classified_state WHERE sno=$id ";
	$newquery=mysqli_query($conn, $newsql);
	$sno = 1;
	while( $rows=mysqli_fetch_array($newquery) ) {
		$id = $rows["sno"];
		$statename = $rows["name"];
	}
	?>
	<form action="classified_state.php" method="POST">
	  <div class="form-group">
		<label for="exampleFormControlInput1">State</label>
		<input type="text" class="form-control" id="state" name="state" value="<?php echo $statename; ?>" required >
		<input type="hidden" class="form-control" id="action" name="action" value="editstate">
		<input type="hidden" class="form-control" id="id" name="id" value="<?php echo $id; ?>">
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php } 
if($action == "editclassifiedcity"){ 
	$id = $_GET['id'];
	$newsql = "SELECT * FROM classified_city WHERE sno=$id ";
	$newquery=mysqli_query($conn, $newsql);
	$sno = 1;
	while( $rows=mysqli_fetch_array($newquery) ) {
		$id = $rows["sno"];
		$cityname = $rows["name"];
		$state = $rows["state"];
		$image = $rows["image"];
	}
	?>
	<form action="classified_state.php" method="POST" enctype="multipart/form-data" >
	  <div class="form-group">
		<label for="exampleFormControlInput1">State</label>
		<select name="state" id="state" class="select2bs4 form-control">
			<?php
			  $newsql = "SELECT * FROM classified_state ";
			  $newquery=mysqli_query($conn, $newsql);
			  while( $rows=mysqli_fetch_array($newquery) ) {
			  $name = $rows["name"];
			  $id = $rows["sno"];
			  ?>
			  <option value="<?php echo $id; ?>" <?php if($id == $state){ echo "SELECTED"; } ?>><?php echo $name; ?></option>
			  <?php } ?>
		</select>
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
	  <div class="form-group">
		<label for="exampleFormControlInput1">District</label>
		<input type="text" class="form-control" id="district" name="district" value="<?php echo $cityname; ?>" required >
		<input type="hidden" class="form-control" id="action" name="action" value="editdistrict">
		<input type="hidden" class="form-control" id="id" name="id" value="<?php echo $id; ?>">
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
	  <div class="form-group">
		<!-- bootstrap-imageupload. -->
		<div class="imageupload ibox ibox-grey">
			<div class="ibox-heading clearfix">
				<h3 class="ibox-title pull-left">Image</h3>
			</div>
			<img src="uploads/<?php echo $image; ?>" class="img-responsive" width="200" />
			<div class="file-tab ibox-body">
				<label class="btn btn-default btn-file">
					<span>Browse</span>
					<!-- The file is stored here. -->
					<input type="file" name="frontimg" >

				</label>
				<p class="help-block">*accept only jpg,png - Size : 500px X 400px</p>
				<button type="button" class="btn btn-default">Remove</button>
			</div>
		</div>
	  </div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php }
if($action == "editclassifiedarea"){
	$id = $_GET['id'];
	$newsql = "SELECT * FROM classified_area WHERE sno=$id ";
	$newquery=mysqli_query($conn, $newsql);
	$sno = 1;
	while( $rows=mysqli_fetch_array($newquery) ) {
		$id = $rows["sno"];
		$state = $rows["state"];
		$district = $rows["district"];
		$area = $rows["area"];
	}
	?>
	<form action="classified_state.php" method="POST">
	  <div class="form-group">
		<label for="exampleFormControlInput1">District</label>
		<input type="hidden" class="form-control" id="action" name="action" value="editarea">
		<input type="hidden" class="form-control" id="id" name="id" value="<?php echo $id; ?>">
		<select name="district" id="district" class="select2bs4 form-control">
			<?php
			  $newsql = "SELECT * FROM classified_city WHERE sno=$district ";
			  $newquery=mysqli_query($conn, $newsql);
			  while( $rows=mysqli_fetch_array($newquery) ) {
			  $name = $rows["name"];
			  $sno = $rows["sno"];
			  ?>
			  <option value="<?php echo $sno; ?>"><?php echo $name; ?></option>
			  <?php } ?>
		</select>
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
	  <div class="form-group">
		<label for="exampleFormControlInput1">Area</label>
		<input type="text" class="form-control" id="area" name="area" value="<?php echo $area; ?>" required >
		<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
	  </div>
	  <button type="submit" class="btn btn-primary btn-default">Submit</button>
	</form>
<?php } 
if($action == "editpropertypost"){ 
	$postid = $_GET['postid'];
	$newsql = "SELECT * FROM propertypost WHERE postid='$postid'";
	$newquery=mysqli_query($conn, $newsql);
	while( $rows=mysqli_fetch_array($newquery) ) {
		$postid = $rows["postid"];
		$title = $rows["name"];
		$description = $rows["description"];
		$image = $rows["image"];
		$packagetype = $rows["packagetype"];
		$status = $rows["status"];
		$createdat = $rows["createdat"];
		$createdby = $rows["createdby"];
		$expiredat = $rows["expiredat"];
		$area = $rows["area"];
		$city = $rows["city"];
		$category = $rows["category"];						
		$subcategory = $rows["subcategory"];						
		$propertytype = $rows["propertytype"];						
		$propertyimages = $rows["propertyimages"];
		$furnished = $rows["furnished"];
		$budget = $rows["budget"];
		$bhk = $rows["bhk"];
		$facing = $rows["facing"];
		$construction = $rows["construction"];
		$bathroom = $rows["bathroom"];
		$bedroom = $rows["bedroom"];
		$color = $rows["color"];
		$sqft = $rows["sqft"];
		$premium = $rows["premium"];
		$brand = $rows["brand"];
		$brandlogo = $rows["brandlogo"];
		$mobile = $rows["mobile"];
		$paymentstatus = $rows["paymentstatus"];
		$packageid = $rows["packageid"];
		$postedby = $rows["postedby"];
		$youtube = $rows["youtube"];
		$postdescription = $rows["postdescription"];
		$location = $rows["location"];
		$createdat = date("d-M-Y", strtotime($createdat));
		$expiredat = date("d-M-Y", strtotime($expiredat));
		
	}
	?>
	<div class="row">
		<div class="col-md-4">
			<div class="form-group">
				<label for="exampleFormControlInput1">User</label>
				<select name="user" id="user" class="select2bs4 form-control" required>
					<option value="">-SELECT-</option>
					<?php
					  $newsql = "SELECT * FROM supplier WHERE type='Customer' ";
					  $newquery=mysqli_query($conn, $newsql);
					  while( $rows=mysqli_fetch_array($newquery) ) {
					  $username = $rows["name"];
					  $userid = $rows["id"];
					  ?>
					  <option value="<?php echo $userid; ?>" <?php if($createdby == $userid){ echo "SELECTED"; } ?> ><?php echo $username; ?></option>
					  <?php } ?>
				</select>
				<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
			</div>
		</div>
		<div class="col-md-4">
			<div class="form-group">
				<label for="exampleFormControlInput1">Post Id</label>
				<input type="text" class="form-control" id="id" name="id" value="<?php echo $postid; ?>" required readonly >
			</div>
		</div>
		<div class="col-md-4">
			<div class="form-group">
				<label for="exampleFormControlInput1">Type</label>
				<select name="type" id="type" class="form-control" required onchange="packagetype();">
					<option value="">-SELECT-</option>
					<option value="Text" <?php if($packagetype == "Text"){ echo "SELECTED"; } ?> >Text</option>
					<option value="Color" <?php if($packagetype == "Color"){ echo "SELECTED"; } ?> >Color</option>
					<option value="Image" <?php if($packagetype == "Image"){ echo "SELECTED"; } ?> >Image</option>
				</select>
			</div>
		</div>					
	</div>
	<h3>Packages</h3>
	<?php 
	$table = "property_packages";
	$newsql = "SELECT * FROM settings WHERE options='propertyhomepremium' OR options='propertybrandpremium' ";
	$newquery=mysqli_query($conn, $newsql);
	while( $rows=mysqli_fetch_array($newquery) ) {
		if($rows["options"] == "propertyhomepremium"){
			$homepremium = $rows["value"];
		}
		if($rows["options"] == "propertybrandpremium"){
			$brandpremium = $rows["value"];
		}
	}
	?>
	
	<div id="packages">
		<?php 
		$newsql = "SELECT * FROM ".$table." WHERE contenttype='$packagetype' ";
		$newquery=mysqli_query($conn, $newsql);
		$num = mysqli_num_rows($newquery);
		if($num > 0){ ?>		
			<?php 	
			while( $rows=mysqli_fetch_array($newquery) ) {
				$dbpackageid = $rows["packageid"];
				$duration = $rows["duration"];
				$amount = $rows["amount"]; ?>
				<div class="form-check">
				  <input class="form-check-input" type="radio" name="packageid" id="<?php echo $packageid; ?>" value="<?php echo $dbpackageid; ?>" <?php if($dbpackageid == $packageid){ echo "CHECKED"; } ?> required>
				  <label class="form-check-label" for="<?php echo $packageid; ?>">
					<?php echo $duration." days of Rs. ".$amount." /- "; ?>
				  </label>
				</div>
			<?php 
			} ?>		
		<?php
		}
		if($packagetype == "Color"){ ?>
			<div class="row">
				<div class="col-md-12">
					<div class="form-group">
						<label for="exampleFormControlInput1">Color</label>
						<select name="color" id="color" class="form-control" required>
							<option value="">-SELECT-</option>
							<option value="Green" <?php if($color == "Green"){ echo "SELECTED"; } ?>>Green</option>
							<option value="Blue" <?php if($color == "Blue"){ echo "SELECTED"; } ?>>Blue</option>
							<option value="Pink" <?php if($color == "Pink"){ echo "SELECTED"; } ?>>Pink</option>
							<option value="Orange" <?php if($color == "Orange"){ echo "SELECTED"; } ?>>Orange</option>
						</select>
					</div>
				</div>	
			</div>
		<?php } else { ?>
			<input type="hidden" class="form-control" id="color" name="color" value="">
		<?php } ?>
		<h3>Premium Options</h3>
		<div class="checkboxes in-row amenities_checkbox">
			<div class="form-check">
			  <input class="form-check-input" type="checkbox" name="extra[]" value="Brand" id="brandpremium"  <?php if($brand == 1){ echo "CHECKED"; } ?>>
			  <label class="form-check-label" for="brandpremium">
				Brand Logo(Extra Rs. <?php echo $brandpremium; ?> /-)
			  </label>
			</div>
			<?php 
			if($packagetype == "Color"){ ?>
			<div class="form-check">
			  <input class="form-check-input" name="extra[]" type="checkbox" value="Premium" id="homepagepremium" <?php if($premium == 1){ echo "CHECKED"; } ?>>
			  <label class="form-check-label" for="homepagepremium">
				Home page view(Extra Rs. <?php echo $homepremium; ?> /-)
			  </label>
			</div>
			<?php } ?>
		</div>
		<input type="hidden" name="types" id="types" value="<?php echo $types; ?>" />
		
	</div>
	<br>
	<div class="row">
		<div class="col-md-6">
			<div class="form-group">
				<label for="exampleFormControlInput1">Category</label>
				<select name="category" id="category" class="form-control select2bs4" onchange="changecategory();" required>
					<option value="">-SELECT-</option>
					<?php
					$newsql = "SELECT * FROM property_category WHERE status=1 ";
					$newquery=mysqli_query($conn, $newsql);
					while( $rows=mysqli_fetch_array($newquery) ) {
						$catname = $rows["name"];
						$cid = $rows["sno"];
						?>
						<option value="<?php echo $cid; ?>" <?php if($category == $cid){ echo "SELECTED"; } ?> ><?php echo $catname; ?></option>
					<?php } ?>
				</select>
			</div>
		</div>
		<div class="col-md-6">
			<div class="form-group">
				<label for="exampleFormControlInput1">Sub Categroy</label>
				<select name="subcategory" id="subcategory" class="form-control select2bs4" required>
					<option value="">-SELECT-</option>
					<?php
					$newsql = "SELECT * FROM property_subcategory WHERE cid=$category ";
					$newquery=mysqli_query($conn, $newsql);
					while( $rows=mysqli_fetch_array($newquery) ) {
						$sname = $rows["name"];
						$scid = $rows["sno"];
						?>
						<option value="<?php echo $scid; ?>" <?php if($subcategory == $scid){ echo "SELECTED"; } ?> ><?php echo $sname; ?></option>
					<?php } ?>					
				</select>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-md-6">
			<div class="form-group">
				<label for="exampleFormControlInput1">City</label>
				<select name="district" id="district" class="form-control select2bs4" onchange="changedistric();" required>
					<option value="">-SELECT-</option>
					<?php
					  $newsql = "SELECT * FROM property_city ORDER BY name";
					  $newquery=mysqli_query($conn, $newsql);
					  while( $rows=mysqli_fetch_array($newquery) ) {
					  $cityname = $rows["name"];
					  $sno = $rows["sno"];
					  ?>
					  <option value="<?php echo $sno; ?>" <?php if($city == $sno){ echo "SELECTED"; } ?> ><?php echo $cityname; ?></option>
					  <?php } ?>
				</select>
			</div>
		</div>
		<div class="col-md-6">
			<div class="form-group">
				<label for="exampleFormControlInput1">Area</label>
				<select name="area" id="area" class="form-control select2bs4" required>
					<option value="">-SELECT-</option>
					<?php
					  $newsql = "SELECT * FROM property_area WHERE district=$city ORDER BY area";
					  $newquery=mysqli_query($conn, $newsql);
					  while( $rows=mysqli_fetch_array($newquery) ) {
					  $areaname = $rows["area"];
					  $sno = $rows["sno"];
					  ?>
					  <option value="<?php echo $sno; ?>" <?php if($area == $sno){ echo "SELECTED"; } ?> ><?php echo $areaname; ?></option>
					  <?php } ?>
				</select>
			</div>
		</div>
		
	</div>
	<div class="form-group">
		<label for="exampleFormControlInput1">Title</label>
		<input type="text" class="form-control" id="name" name="name" value="<?php echo $title; ?>" required>
		<input type="hidden" class="form-control" id="action" name="action" value="edit">
	</div>
	<div class="form-group">
		<label for="exampleFormControlInput1">Description</label>
		<textarea name="description" id="description" class="form-control" rows="5" maxlength="200"><?php echo $description; ?></textarea>
	</div>
	<div class="form-group">
		<label for="exampleFormControlInput1">Post Image(Best View : 620px X 500px)</label>
		<input type="file" name="postimage" id="postimage" class="form-control" disabled />
		<?php 
		if($image !== ""){ ?>
			<img src="<?php echo "uploads/".$image; ?>" width="100" class="img-fluid" />
		<?php } ?>
	</div>
	<div class="form-group">
		<label for="exampleFormControlInput1">Brand Logo(Best View : 200px X 80px)</label>
		<input type="file" name="brandlogo" id="brandlogo" class="form-control" />
		<?php 
		if($brandlogo !== ""){ ?>
			<img src="<?php echo "uploads/".$brandlogo; ?>" width="100" class="img-fluid" />
		<?php } ?>
	</div>
	<div class="form-group">
		<label for="exampleFormControlInput1">Other</label>
		<input type="file" id="uploadImageFile" name="uploadImageFile[]" class="form-control" onchange="showImageHereFunc();" multiple />		
	</div>
	<div id="showImageHere"></div>
	<?php 
	$propertyimagesarray = explode(",", $propertyimages);
	if(sizeof($propertyimagesarray) > 0){
		foreach($propertyimagesarray as $img){ ?>
			<img src="<?php echo "uploads/".$img; ?>" width="100" class="img-fluid" style="margin: 5px; display: inline-block;" />
		<?php }
	} ?>
	
	<script>
	function showImageHereFunc() {
	  var total_file=document.getElementById("uploadImageFile").files.length;
	  for(var i=0;i<total_file;i++) {
		$('#showImageHere').append("<img src='"+URL.createObjectURL(event.target.files[i])+"' width='100px' style='display:inline-block;margin: 5px;'>");
	  }
	  $('#showImageHere').append("<button class='btn btn-danger btn-xs' onclick='removeimg();'>Clear Image</button>");
	}
	function removeimg() {
		$("#uploadImageFile").val('');
		$("#showImageHere").html('');
	}
	</script>
	
	<div class="form-group">
		<label for="exampleFormControlInput1">Youtube Video Link</label>
		<input type="text" class="form-control" id="youtube" name="youtube" value="<?php echo $youtube; ?>">
	</div>
	
	<div class="row">
		<div class="col-md-4">			
			<div class="form-group">
				<label for="exampleFormControlInput1">Furnished</label>
				<select name="furnished" id="furnished" class="form-control" >
					<option value="">-SELECT-</option>
					<option value="Full Furnished" <?php if($furnished == "Full Furnished"){ echo "SELECTED"; } ?>>Full Furnished</option>
					<option value="Semi Furnished" <?php if($furnished == "Semi Furnished"){ echo "SELECTED"; } ?>>Semi Furnished</option>
					<option value="Not Furnished" <?php if($furnished == "Not Furnished"){ echo "SELECTED"; } ?>>Not Furnished</option>
				</select>
			</div>
		</div>
		<div class="col-md-4">			
			<div class="form-group">
				<label for="exampleFormControlInput1">Budget</label>
				<input type="number" class="form-control" id="budget" name="budget" value="<?php echo $budget; ?>" >
			</div>
		</div>
		
		<div class="col-md-4">			
			<div class="form-group">
				<label for="exampleFormControlInput1">Facing</label>
				<select name="facing" id="facing" class="form-control" >
					<option value="">-SELECT-</option>
					<option value="North" <?php if($facing == "North"){ echo "SELECTED"; } ?>>North</option>
					<option value="South" <?php if($facing == "South"){ echo "SELECTED"; } ?>>South</option>
					<option value="East" <?php if($facing == "East"){ echo "SELECTED"; } ?>>East</option>
					<option value="West" <?php if($facing == "West"){ echo "SELECTED"; } ?>>West</option>
					<option value="North West" <?php if($facing == "North West"){ echo "SELECTED"; } ?>>North West</option>
					<option value="North East" <?php if($facing == "North East"){ echo "SELECTED"; } ?>>North East</option>
					<option value="South West" <?php if($facing == "South West"){ echo "SELECTED"; } ?>>South West</option>
					<option value="South East" <?php if($facing == "South East"){ echo "SELECTED"; } ?>>South East</option>
				</select>
			</div>
		</div>
	</div>
	
	<div class="row">
		<div class="col-md-6">			
			<div class="form-group">
				<label for="exampleFormControlInput1">Construction Status</label>
				<select name="construction" id="construction" class="form-control" >
					<option value="">-SELECT-</option>
					<option value="Ready to Move" <?php if($construction == "Ready to Move"){ echo "SELECTED"; } ?>>Ready to Move</option>
					<option value="Construction Working" <?php if($construction == "Construction Working"){ echo "SELECTED"; } ?>>Construction Working</option>
					<option value="Land" <?php if($construction == "Land"){ echo "SELECTED"; } ?>>Land</option>
				</select>
			</div>
		</div>
		
		<div class="col-md-6">			
			<div class="form-group">
				<label for="exampleFormControlInput1">Property Sq.Ft</label>
				<input type="number" class="form-control" id="sqft" name="sqft" value="<?php echo $sqft; ?>" step="0.001" >
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-md-4">		
			<div class="form-group">
				<label for="exampleFormControlInput1">Google Map Location</label>
				<input type="text" class="form-control" id="location" name="location" value="<?php echo $location; ?>" >
			</div>
		</div>
		<div class="col-md-4">		
			<div class="form-group">
				<label for="exampleFormControlInput1">Contact No.</label>
				<input type="number" class="form-control num" id="contact" name="contact" value="<?php echo $mobile; ?>" maxlength="10" >
			</div>
		</div>
		<div class="col-md-4">		
			<div class="form-group">
				<label for="exampleFormControlInput1">Posted by</label>
				<select name="postedby" id="postedby" class="form-control" >
					<option value="">-SELECT-</option>
					<option value="Owner" <?php if($postedby == "Owner"){ echo "SELECTED"; } ?>>Owner</option>
					<option value="Broker" <?php if($postedby == "Broker"){ echo "SELECTED"; } ?>>Broker</option>
					<option value="Others" <?php if($postedby == "Others"){ echo "SELECTED"; } ?>>Others</option>
				</select>
			</div>
		</div>
	</div>
	
	<div class="form-group">
		<label for="exampleFormControlInput1">Payment Status</label>
		<select name="pmntstatus" id="pmntstatus" class="form-control">
			<option value="">-SELECT-</option>
			<option value="success" <?php if($paymentstatus == "success"){ echo "SELECTED"; } ?>>Paid</option>
			<option value="failed" <?php if($paymentstatus == "failed" || $paymentstatus == ""){ echo "SELECTED"; } ?>>Pending</option>
		</select>
	</div>
	<input type="hidden" class="form-control" id="propertytype" name="propertytype" value="" readonly>
	<input type="hidden" class="form-control" id="bhk" name="bhk" value="0" required readonly>
	<input type="hidden" class="form-control" id="bathroom" name="bathroom" value="0" required readonly>
	<input type="hidden" class="form-control" id="bedroom" name="bedroom" value="0" required readonly>
	<button type="submit" class="btn btn-info">Submit</button>
	<script>
	$(".num").keypress(function() {
		if ($(this).val().length == $(this).attr("maxlength")) {
			return false;
		}
	});
	</script>

<?php } 
if($action == "viewpropertypost"){
	$postid = $_GET['postid'];
	$sql = "SELECT * FROM propertypost WHERE postid='$postid' ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$status = $row["status"];
		$postid = $row["postid"];
		$description = $row["description"];
		$city = $row["city"];
		$area = $row["area"];		
		$expiredat = $row["expiredat"];
		$packageid = $row["packageid"];
		$packagetype = $row["packagetype"];
		$image = $row["image"];
		$category = $row["category"];
		$subcategory = $row["subcategory"];
		$mobile = $row["mobile"];		
		$brandlogo = $row["brandlogo"];
		$propertytype = $row['propertytype'];
		$furnished = $row['furnished'];
		$budget = $row['budget'];
		$bhk = $row['bhk'];
		$facing = $row['facing'];
		$construction = $row['construction'];
		$bathroom = $row['bathroom'];
		$bedroom = $row['bedroom'];
		$sqft = $row['sqft'];	
		$postedby = $row['postedby'];
		$propertyimages = $row['propertyimages'];
	}
	$sql = "SELECT * FROM property_packages WHERE packageid='$packageid' ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$duration = $row["duration"];
		$amount = $row["amount"];
		$contenttype = $row["contenttype"];
	}
	$sql = "SELECT * FROM property_city WHERE sno=$city ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$cityname = $row["name"];
	}
	$sql = "SELECT * FROM property_area WHERE sno=$area ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$areaname = $row["area"];
	}
	$sql = "SELECT * FROM property_category WHERE sno=$category ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$categoryname = $row["name"];
	}
	$sql = "SELECT * FROM property_subcategory WHERE sno=$subcategory ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$subcategoryname = $row["name"];
	}
	$expiredat = date("d-M-Y", strtotime($expiredat));
	?>
	<table class="table">
		<tr><td><b>Post Id</b></td><td>:</td><td><?php echo $postid; ?></td></tr>
		<tr><td><b>Packagetype</b></td><td>:</td><td><?php echo $packagetype; ?></td></tr>
		<tr>
			<td style="width: 34%;"><b>Description / Image</b></td><td style="width: 2%;">:</td><td style="width: 64%;"><?php if($packagetype == "Image"){ ?><img src="uploads/<?php echo $image; ?>" width="150" class="img-responsive" /> <?php } else { echo $description; } ?></td>
		</tr>		
		<tr><td><b>Category</b></td><td>:</td><td><?php echo $categoryname." -> ".$subcategoryname; ?></td></tr>
		<tr><td><b>Area</b></td><td>:</td><td><?php echo $cityname." -> ".$areaname; ?></td></tr>		
		<tr><td><b>Expired At</b></td><td>:</td><td><?php echo $expiredat; ?></td></tr>
		<tr><td><b>Package</b></td><td>:</td><td><?php echo $contenttype." for ".$duration." days of Rs. ".$amount." /-"; ?></td></tr>
		<tr><td><b>Furnished</b></td><td>:</td><td><?php echo $furnished; ?></td></tr>
		<tr><td><b>Budget</b></td><td>:</td><td><?php echo $budget; ?></td></tr>
		<tr><td><b>Facing</b></td><td>:</td><td><?php echo $facing; ?></td></tr>
		<tr><td><b>Construction Status</b></td><td>:</td><td><?php echo $construction; ?></td></tr>
		<tr><td><b>No. of Sq.Ft</b></td><td>:</td><td><?php echo $sqft; ?></td></tr>
		<tr><td><b>Posted By</b></td><td>:</td><td><?php echo $postedby; ?></td></tr>
		
		<tr><td><b>Contact</b></td><td>:</td><td><?php echo $mobile; ?></td></tr>
		<tr>
			<td colspan="3">
				<b>Property Images</b> <br>
				<?php 
				$propertyimagesarray = explode(",", $propertyimages);
				if(sizeof($propertyimagesarray) > 0){
					foreach($propertyimagesarray as $img){ ?>
						<img src="<?php echo "uploads/".$img; ?>" width="100" class="img-fluid" style="margin: 5px; display: inline-block;" />
					<?php }
				} ?>
			</td>
		</tr>
		<?php 
		if($brandlogo !== ""){ ?>
		<tr>
			<td><b>Brand Logo</b></td><td>:</td><td><img src="uploads/<?php echo $brandlogo; ?>" width="150" class="img-responsive" /></td>
		</tr>
		<?php } ?>
	</table>
	
<?php } 
if($action == "viewclassifiedpost"){
	$postid = $_GET['postid'];
	$sql = "SELECT * FROM classifiedpost WHERE postid='$postid' ";
	$query=mysqli_query($conn, $sql);
	while( $rows=mysqli_fetch_array($query) ) {
		$postid = $rows["postid"];
		$companyname = $rows["companyname"];
		$description = $rows["description"];
		$logo = $rows["logo"];
		$name = $rows["name"];
		$mobile = $rows["mobile"];
		$status = $rows["status"];
		$createdat = $rows["createdat"];
		$createdby = $rows["createdby"];
		$expiredat = $rows["expiredat"];
		$area = $rows["area"];
		$city = $rows["city"];
		$category = $rows["category"];						
		$subcategory = $rows["subcategory"];		
		$paymentstatus = $rows["paymentstatus"];
		$address = $rows["address"];
		$email = $rows["email"];
		$since = $rows["since"];
		$images = $rows["images"];
		$packageid = $rows["packageid"];
		$workingdays = $rows["workingdays"];
		if($paymentstatus == ""){
			$paymentstatus = "failed";
		}
		$createdat = date("d-M-Y", strtotime($createdat));
		$expiredat = date("d-M-Y", strtotime($expiredat));
		
	}
	$sql = "SELECT * FROM classified_packages WHERE packageid='$packageid' ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$duration = $row["duration"];
		$amount = $row["amount"];
		$contenttype = $row["contenttype"];
	}
	$custname = $custmobile = "";
	$sql = "SELECT * FROM supplier WHERE id='$createdby' ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$custname = $row['name'];
		$custmobile = $row['mobile'];
	}
	$sql = "SELECT * FROM classified_category WHERE sno=$category ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$catname = $row['name'];
	}
	$sql = "SELECT * FROM classified_subcategory WHERE sno=$subcategory ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$subcatname = $row['name'];
	}
	$sql = "SELECT * FROM classified_city WHERE sno=$city ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$cityname = $row['name'];
	}
	$sql = "SELECT * FROM classified_area WHERE sno=$area ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$areaname = $row['area'];
	}
	?>
	<table class="table">
		<tr><td><b>Post Id</b></td><td>:</td><td><?php echo $postid; ?></td></tr>
		<tr><td><b>Title</b></td><td>:</td><td><?php echo $name; ?></td></tr>
		<tr>
			<td style="width: 34%;"><b>Description</b></td><td style="width: 2%;">:</td><td style="width: 64%;"><?php echo $description; ?></td>
		</tr>		
		<tr><td><b>Category</b></td><td>:</td><td><?php echo $catname." -> ".$subcatname; ?></td></tr>
		<tr><td><b>Area</b></td><td>:</td><td><?php echo $cityname." -> ".$areaname; ?></td></tr>		
		<tr><td><b>Expired At</b></td><td>:</td><td><?php echo $expiredat; ?></td></tr>
		<tr><td><b>Package</b></td><td>:</td><td><?php echo $contenttype." for ".$duration." days of Rs. ".$amount." /-"; ?></td></tr>
		<tr><td><b>Company Name</b></td><td>:</td><td><?php echo $companyname; ?></td></tr>
		<tr><td><b>Address</b></td><td>:</td><td><?php echo $address; ?></td></tr>
		<tr><td><b>Email</b></td><td>:</td><td><?php echo $email; ?></td></tr>
		<tr><td><b>Since</b></td><td>:</td><td><?php echo $since; ?></td></tr>
		<tr><td><b>Working Days</b></td><td>:</td><td><?php echo $workingdays; ?></td></tr>
		
		<tr><td><b>Contact</b></td><td>:</td><td><?php echo $mobile; ?></td></tr>
		<tr>
			<td colspan="3">
				<b>Classified Images</b> <br>
				<?php 
				$propertyimagesarray = explode(",", $images);
				if(sizeof($propertyimagesarray) > 0){
					foreach($propertyimagesarray as $img){ ?>
						<img src="<?php echo "uploads/".$img; ?>" width="100" class="img-fluid" style="margin: 5px; display: inline-block;" />
					<?php }
				} ?>
			</td>
		</tr>
		<?php 
		if($logo !== ""){ ?>
		<tr>
			<td><b>Brand Logo</b></td><td>:</td><td><img src="uploads/<?php echo $logo; ?>" width="150" class="img-responsive" /></td>
		</tr>
		<?php } ?>
	</table>
	
<?php } 
if($action == "editclassifiedpost"){ 
	$postid = $_GET['postid'];
	$sql = "SELECT * FROM classifiedpost WHERE postid='$postid' ";
	$query=mysqli_query($conn, $sql);
	while( $rows=mysqli_fetch_array($query) ) {
		$idno = $rows["idno"];
		$postid = $rows["postid"];
		$packagetype = $rows["packagetype"];
		$companyname = $rows["companyname"];
		$description = $rows["description"];
		$postdescription = $rows["postdescription"];
		$logo = $rows["logo"];
		$title = $rows["name"];
		$mobile = $rows["mobile"];
		$status = $rows["status"];
		$createdat = $rows["createdat"];
		$createdby = $rows["createdby"];
		$expiredat = $rows["expiredat"];
		$area = $rows["area"];
		$city = $rows["city"];
		$category = $rows["category"];						
		$subcategory = $rows["subcategory"];		
		$paymentstatus = $rows["paymentstatus"];
		$address = $rows["address"];
		$email = $rows["email"];
		$since = $rows["since"];
		$images = $rows["images"];
		$map = $rows["map"];
		$packageid = $rows["packageid"];
		$workingdays = $rows["workingdays"];
		$premium = $rows["premium"];
		$brand = $rows["brand"];
		$youtube = $rows["youtube"];
		$facebook = $rows['facebook'];
		$instagram = $rows['instagram'];
		$twitter = $rows['twitter'];
		$cyoutube = $rows['cyoutube'];
		$linkedin = $rows['linkedin'];
		$website = $rows['website'];
		
		if($paymentstatus == ""){
			$paymentstatus = "failed";
		}
		$createdat = date("d-M-Y", strtotime($createdat));
		$expiredat = date("d-M-Y", strtotime($expiredat));
		
	}
	?>
	<div class="row">
		<div class="col-md-4">
			<div class="form-group">
				<label for="exampleFormControlInput1">User</label>
				<select name="user" id="user" class="select2bs4 form-control" required>
					<option value="">-SELECT-</option>
					<?php
					  $newsql = "SELECT * FROM supplier WHERE type='Customer' ";
					  $newquery=mysqli_query($conn, $newsql);
					  while( $rows=mysqli_fetch_array($newquery) ) {
					  $username = $rows["name"];
					  $userid = $rows["id"];
					  $supmobile = $rows["mobile"];
					  ?>
					  <option value="<?php echo $userid; ?>" <?php if($userid == $createdby){ echo "SELECTED"; } ?>><?php echo $username."(".$supmobile.")"; ?></option>
					  <?php } ?>
				</select>
				<!-- <span class="mt-2 d-block">We'll never share your email with anyone else.</span> -->
			</div>
		</div>
		<div class="col-md-4">
			<div class="form-group">
				<label for="exampleFormControlInput1">Post Id</label>
				<input type="text" class="form-control" id="id" name="id" value="<?php echo $postid; ?>" required readonly >
				<input type="hidden" class="form-control" id="idno" name="idno" value="<?php echo $idno; ?>">
			</div>
		</div>
		<div class="col-md-4">
			<div class="form-group">
				<label for="exampleFormControlInput1">Type</label>
				<select name="type" id="type" class="form-control" required onchange="packagetype();">
					<option value="">-SELECT-</option>								
					<option value="Image" <?php if($packagetype == "Image"){ echo "SELECTED"; } ?>>Image</option>
				</select>
			</div>
		</div>					
	</div>
	<h3>Packages</h3>
	<?php 
	$table = "classified_packages";
	$newsql = "SELECT * FROM settings WHERE options='classifiedhomepremium' OR options='classifiedbrandpremium' ";
	$newquery=mysqli_query($conn, $newsql);
	while( $rows=mysqli_fetch_array($newquery) ) {
		if($rows["options"] == "classifiedhomepremium"){
			$homepremium = $rows["value"];
		}
		if($rows["options"] == "classifiedbrandpremium"){
			$brandpremium = $rows["value"];
		}
	}
	?>
	
	<div id="packages">
		<?php 
		$newsql = "SELECT * FROM ".$table." WHERE contenttype='$packagetype' ";
		$newquery=mysqli_query($conn, $newsql);
		$num = mysqli_num_rows($newquery);
		if($num > 0){ ?>		
			<?php 	
			while( $rows=mysqli_fetch_array($newquery) ) {
				$dbpackageid = $rows["packageid"];
				$duration = $rows["duration"];
				$amount = $rows["amount"]; ?>
				<div class="form-check">
				  <input class="form-check-input" type="radio" name="packageid" id="<?php echo $packageid; ?>" value="<?php echo $dbpackageid; ?>" <?php if($dbpackageid == $packageid){ echo "CHECKED"; } ?> required>
				  <label class="form-check-label" for="<?php echo $packageid; ?>">
					<?php echo $duration." days of Rs. ".$amount." /- "; ?>
				  </label>
				</div>
			<?php 
			} ?>		
		<?php
		}
		?>
		<h3>Premium Options</h3>
		<div class="checkboxes in-row amenities_checkbox">
			<div class="form-check">
			  <input class="form-check-input" type="checkbox" name="extra[]" value="Brand" id="brandpremium"  <?php if($brand == 1){ echo "CHECKED"; } ?>>
			  <label class="form-check-label" for="brandpremium">
				Brand Logo(Extra Rs. <?php echo $brandpremium; ?> /-)
			  </label>
			</div>
			
			<div class="form-check">
			  <input class="form-check-input" name="extra[]" type="checkbox" value="Premium" id="homepagepremium" <?php if($premium == 1){ echo "CHECKED"; } ?>>
			  <label class="form-check-label" for="homepagepremium">
				Home page view(Extra Rs. <?php echo $homepremium; ?> /-)
			  </label>
			</div>
			
		</div>
		<input type="hidden" name="types" id="types" value="<?php echo $types; ?>" />
		
	</div>
	<br>
	<div class="row">
		<div class="col-md-6">
			<div class="form-group">
				<label for="exampleFormControlInput1">Category</label>
				<select name="category" id="category" class="form-control select2bs4" onchange="changecategory();" required>
					<option value="">-SELECT-</option>
					<?php
					$newsql = "SELECT * FROM classified_category WHERE status=1 ";
					$newquery=mysqli_query($conn, $newsql);
					while( $rows=mysqli_fetch_array($newquery) ) {
						$catname = $rows["name"];
						$cid = $rows["sno"];
						?>
						<option value="<?php echo $cid; ?>" <?php if($category == $cid){ echo "SELECTED"; } ?>><?php echo $catname; ?></option>
					<?php } ?>
				</select>
			</div>
		</div>
		<div class="col-md-6">
			<div class="form-group">
				<label for="exampleFormControlInput1">Sub Categroy</label>
				<select name="subcategory" id="subcategory" class="form-control select2bs4" required>
					<option value="">-SELECT-</option>		
					<?php
					  $newsql = "SELECT * FROM classified_subcategory WHERE cid=$category ORDER BY name ";
					  $newquery=mysqli_query($conn, $newsql);
					  while( $rows=mysqli_fetch_array($newquery) ) {
						$subcatname = $rows["name"];
						$sno = $rows["sno"];
						?>
						<option value="<?php echo $sno; ?>" <?php if($subcategory == $sno){ echo "SELECTED"; } ?>><?php echo $subcatname; ?></option>
					  <?php } ?>
				</select>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-md-6">
			<div class="form-group">
				<label for="exampleFormControlInput1">City</label>
				<select name="district" id="district" class="form-control select2bs4" onchange="changedistric();" required>
					<option value="">-SELECT-</option>
					<?php
					  $newsql = "SELECT * FROM classified_city ORDER BY name";
					  $newquery=mysqli_query($conn, $newsql);
					  while( $rows=mysqli_fetch_array($newquery) ) {
					  $cityname = $rows["name"];
					  $sno = $rows["sno"];
					  ?>
					  <option value="<?php echo $sno; ?>" <?php if($city == $sno){ echo "SELECTED"; } ?>><?php echo $cityname; ?></option>
					  <?php } ?>
				</select>
			</div>
		</div>
		<div class="col-md-6">
			<div class="form-group">
				<label for="exampleFormControlInput1">Area</label>
				<select name="area" id="area" class="form-control select2bs4" required>
					<option value="">-SELECT-</option>
					<?php
					  $newsql = "SELECT * FROM classified_area WHERE district=$city ORDER BY area ";
					  $newquery=mysqli_query($conn, $newsql);
					  while( $rows=mysqli_fetch_array($newquery) ) {
						$areaname = $rows["area"];
						$sno = $rows["sno"];
						?>
						<option value="<?php echo $sno; ?>" <?php if($area == $sno){ echo "SELECTED"; } ?>><?php echo $areaname; ?></option>
					  <?php } ?>
				</select>
			</div>
		</div>
		
	</div>
	<div class="form-group">
		<label for="exampleFormControlInput1">Title</label>
		<input type="text" class="form-control" id="name" name="name" value="<?php echo $title; ?>" maxlength="28" required>
		<input type="hidden" class="form-control" id="action" name="action" value="edit">
	</div>
	<div class="form-group">
		<label for="exampleFormControlInput1">Short Description</label>
		<textarea name="description" id="description" class="form-control" rows="5" maxlength="100"><?php echo $description; ?></textarea>
	</div>
	<div class="form-group">
		<label for="exampleFormControlInput1">Features</label>
		<textarea class="textarea" name="postdescription" id="postdescription" placeholder="Place some text here"
			  style="width: 100%; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"><?php echo $postdescription; ?></textarea>
	</div>
	
	<div class="form-group">
		<label for="exampleFormControlInput1">Brand Logo(Best View : 200px X 80px)</label>
		<input type="file" name="brandlogo" id="brandlogo" class="form-control" />
		<?php 
		if($logo !== ""){ ?>
			<img src="<?php echo "uploads/".$logo; ?>" width="100" class="img-fluid" />
		<?php } ?>
	</div>
	
	<div class="form-group">
		<label for="exampleFormControlInput1">ClassifiedImages(Best View : 900px X 600px)</label>
		<input type="file" id="uploadImageFile" name="uploadImageFile[]" class="form-control" onchange="showImageHereFunc();" multiple />
		
	</div>
	<div id="showImageHere"></div>
	<?php 
	$propertyimagesarray = explode(",", $images);
	if(sizeof($propertyimagesarray) > 0){
		foreach($propertyimagesarray as $img){ ?>
			<img src="<?php echo "uploads/".$img; ?>" width="100" class="img-fluid" style="margin: 5px; display: inline-block;" />
		<?php }
	} ?>
	<script>
	$(function () {
		// Summernote
		$('.textarea').summernote()
	});
	function showImageHereFunc() {
	  var total_file=document.getElementById("uploadImageFile").files.length;
	  for(var i=0;i<total_file;i++) {
		$('#showImageHere').append("<img src='"+URL.createObjectURL(event.target.files[i])+"' width='100px' style='display:inline-block;margin: 5px;'>");
	  }
	  $('#showImageHere').append("<button class='btn btn-danger btn-xs' onclick='removeimg();'>Clear Image</button>");
	}
	function removeimg() {
		$("#uploadImageFile").val('');
		$("#showImageHere").html('');
	}
	</script>
	<div class="form-group">
		<label for="exampleFormControlInput1">Youtube Video Link</label>
		<input type="text" class="form-control" id="youtube" name="youtube" value="<?php echo $youtube; ?>" placeholder="https://www.youtube.com/embed/...">
	</div>
	<div class="form-group">
		<label for="exampleFormControlInput1">Address</label>
		<textarea class="form-control" id="address" name="address" ><?php echo $address; ?></textarea>
	</div>
	<div class="row">
		<div class="col-md-4">			
			<div class="form-group">
				<label for="exampleFormControlInput1">Company Name</label>
				<input type="text" class="form-control" id="company" name="company" value="<?php echo $companyname; ?>" required>
			</div>
		</div>
		
		
		<div class="col-md-4">			
			<div class="form-group">
				<label for="exampleFormControlInput1">Contact No.</label>
				<input type="number" class="form-control num" id="contact" name="contact" value="<?php echo $mobile; ?>" maxlength="10" required>
			</div>
		</div>
		
		<div class="col-md-4">			
			<div class="form-group">
				<label for="exampleFormControlInput1">Email</label>
				<input type="text" class="form-control" id="email" name="email" value="<?php echo $email; ?>" >
			</div>
		</div>
	</div>
	
	<div class="row">
		<div class="col-md-3">			
			<div class="form-group">
				<label for="exampleFormControlInput1">No. of Years Experience</label>
				<input type="number" class="form-control" id="bussinesssince" name="bussinesssince" max="99" value="<?php echo $since; ?>" >
			</div>
		</div>					
		<div class="col-md-3">			
			<div class="form-group">
				<label for="exampleFormControlInput1">Working Days</label>
				<input type="number" class="form-control" id="workingdays" name="workingdays" max="7" value="<?php echo $workingdays; ?>" >
			</div>
		</div>
		<div class="col-md-3">		
			<div class="form-group">
				<label for="exampleFormControlInput1">Google Map Location</label>
				<input type="text" class="form-control" id="location" name="location" value="<?php echo $map; ?>" placeholder="https://www.google.com/maps/embed?pb..." >
			</div>
		</div>
		<div class="col-md-3">		
			<div class="form-group">
				<label for="exampleFormControlInput1">Website(Dont include http://)</label>
				<input type="text" class="form-control" id="website" name="website" value="<?php echo $website; ?>" placeholder="www..." >
			</div>
		</div>
	</div>
	
	<div class="row">
		<div class="col-md-3">			
			<div class="form-group">
				<label for="exampleFormControlInput1">Facebook Page</label>
				<input type="text" class="form-control" id="facebook" name="facebook" value="<?php echo $facebook; ?>" >
			</div>
		</div>					
		<div class="col-md-3">			
			<div class="form-group">
				<label for="exampleFormControlInput1">Instagram Page</label>
				<input type="text" class="form-control" id="instagram" name="instagram" value="<?php echo $instagram; ?>" >
			</div>
		</div>
		<div class="col-md-3">		
			<div class="form-group">
				<label for="exampleFormControlInput1">Twitter Page</label>
				<input type="text" class="form-control" id="twitter" name="twitter" value="<?php echo $twitter; ?>" >
			</div>
		</div>
		<div class="col-md-3">		
			<div class="form-group">
				<label for="exampleFormControlInput1">Youtube Channel</label>
				<input type="text" class="form-control" id="cyoutube" name="cyoutube" value="<?php echo $cyoutube; ?>" >
			</div>
		</div>
	</div>
	
	<div class="form-group">
		<label for="exampleFormControlInput1">Linkedin</label>
		<input type="text" class="form-control" id="linkedin" name="linkedin" value="<?php echo $linkedin; ?>" placeholder="http://.." >
	</div>
	
	<div class="form-group">
		<label for="exampleFormControlInput1">Payment Status</label>
		<select name="pmntstatus" id="pmntstatus" class="form-control">
			<option value="">-SELECT-</option>
			<option value="success" <?php if($paymentstatus == "success"){ echo "SELECTED"; } ?>>Paid</option>
			<option value="failed" <?php if($paymentstatus == "failed"){ echo "SELECTED"; } ?>>Pending</option>
		</select>
	</div>
	<button type="submit" class="btn btn-info">Submit</button>
	<?php 
}
if($action == "viewpropertyenquiry"){
	$postid = $_GET['postid'];
	$sql = "SELECT * FROM property_enquiry WHERE sno=$postid ";
	//echo $sql;
	$query=mysqli_query($conn, $sql);
	while( $rows=mysqli_fetch_array($query) ) {
		$comments = $rows["comments"];				
	}
	echo $comments;
}
if($action == "viewclassifiedenquiry"){
	$postid = $_GET['postid'];
	$sql = "SELECT * FROM classified_enquiry WHERE sno=$postid ";
	//echo $sql;
	$query=mysqli_query($conn, $sql);
	while( $rows=mysqli_fetch_array($query) ) {
		$comments = $rows["comments"];				
	}
	echo $comments;
}
if($action == "viewblogpost"){
	$postid = $_GET['postid'];
	$sql = "SELECT * FROM blogpost WHERE postid='$postid' ";
	$query=mysqli_query($conn, $sql);
	while( $rows=mysqli_fetch_array($query) ) {
		$postid = $rows["postid"];
		$description = $rows["description"];
		$logo = $rows["logo"];
		$name = $rows["name"];		
		$status = $rows["status"];
		$youtube = $rows["youtube"];
		$createdat = $rows["createdat"];
		
		$category = $rows["category"];						
		$subcategory = $rows["subcategory"];	
		$images = $rows["images"];
		$status = $rows["status"];
		
		$createdat = date("d-M-Y", strtotime($createdat));
		
	}
	
	$sql = "SELECT * FROM blog_category WHERE sno=$category ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$catname = $row['name'];
	}
	$sql = "SELECT * FROM blog_subcategory WHERE sno=$subcategory ";
	$query=mysqli_query($conn, $sql);
	while( $row=mysqli_fetch_array($query) ) {
		$subcatname = $row['name'];
	}
	
	?>
	<table class="table">
		<tr><td><b>Status</b></td><td>:</td><td><?php echo $status; ?></td></tr>
		<tr><td><b>Post Id</b></td><td>:</td><td><?php echo $postid; ?></td></tr>
		<tr><td><b>Title</b></td><td>:</td><td><?php echo $name; ?></td></tr>
		<tr>
			<td style="width: 34%;"><b>Description</b></td><td style="width: 2%;">:</td><td style="width: 64%;"><?php echo $description; ?></td>
		</tr>		
		<tr><td><b>Category</b></td><td>:</td><td><?php echo $catname." -> ".$subcatname; ?></td></tr>
		
		<?php 
		if($logo !== ""){ ?>
		<tr>
			<td><b>Main Image</b></td><td>:</td><td><img src="uploads/<?php echo $logo; ?>" width="150" class="img-responsive" /></td>
		</tr>
		<?php } ?>
	</table>
	
<?php }
if($action == "editblogpost"){ 
	$postid = $_GET['postid'];
	$sql = "SELECT * FROM blogpost WHERE postid='$postid' ";
	$query=mysqli_query($conn, $sql);
	while( $rows=mysqli_fetch_array($query) ) {
		$idno = $rows["idno"];
		$postid = $rows["postid"];
		$category = $rows["category"];
		$subcategory = $rows["subcategory"];
		$tags = $rows["tags"];
		$description = $rows["description"];
		$postdescription = $rows["postdescription"];
		$logo = $rows["logo"];
		$title = $rows["name"]; 
		$images = $rows["images"]; 
		$youtube = $rows["youtube"]; 
	}
	?>
	<div class="row">
		<div class="col-md-12">
			<div class="form-group">
				<label for="exampleFormControlInput1">Post Id</label>
				<input type="text" class="form-control" id="id" name="id" value="<?php echo $postid; ?>" required readonly >
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-md-6">
			<div class="form-group">
				<label for="exampleFormControlInput1">Category</label>
				<select name="category" id="category" class="form-control select2bs4" onchange="changecategory();" required>
					<option value="">-SELECT-</option>
					<?php
					$newsql = "SELECT * FROM blog_category WHERE status=1 ";
					$newquery=mysqli_query($conn, $newsql);
					while( $rows=mysqli_fetch_array($newquery) ) {
						$name = $rows["name"];
						$cid = $rows["sno"];
						?>
						<option value="<?php echo $cid; ?>" <?php if($category == $cid){ echo "SELECTED"; } ?>><?php echo $name; ?></option>
					<?php } ?>
				</select>
			</div>
		</div>
		<div class="col-md-6">
			<div class="form-group">
				<label for="exampleFormControlInput1">Sub Categroy</label>
				<select name="subcategory" id="subcategory" class="form-control select2bs4" required>
					<option value="">-SELECT-</option>
					<?php
					  $newsql = "SELECT * FROM blog_subcategory WHERE cid=$category ORDER BY name ";
					  $newquery=mysqli_query($conn, $newsql);
					  while( $rows=mysqli_fetch_array($newquery) ) {
						$subcatname = $rows["name"];
						$sno = $rows["sno"];
						?>
						<option value="<?php echo $sno; ?>" <?php if($subcategory == $sno){ echo "SELECTED"; } ?>><?php echo $subcatname; ?></option>
					  <?php } ?>
				</select>
			</div>
		</div>
	</div>
	
	<div class="form-group">
		<label for="exampleFormControlInput1">Title</label>
		<input type="text" class="form-control" id="name" name="name"  maxlength="28" value="<?php echo $title; ?>" required>
		<input type="hidden" class="form-control" id="action" name="action" value="edit">
	</div>
	<div class="form-group">
		<label for="exampleFormControlInput1">Short Description</label>
		<textarea name="description" id="description" class="form-control" rows="5" maxlength="100"><?php echo $description; ?></textarea>
	</div>
	<div class="form-group">
		<label for="exampleFormControlInput1">Description</label>
		<textarea class="textarea" name="postdescription" id="postdescription" placeholder="Place some text here"
			  style="width: 100%; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"><?php echo $postdescription; ?></textarea>
	</div>
	<script>
	$(function () {
		// Summernote
		$('.textarea').summernote()
	});
	function showImageHereFunc() {
	  var total_file=document.getElementById("uploadImageFile").files.length;
	  for(var i=0;i<total_file;i++) {
		$('#showImageHere').append("<img src='"+URL.createObjectURL(event.target.files[i])+"' width='100px' style='display:inline-block;margin: 5px;'>");
	  }
	  $('#showImageHere').append("<button class='btn btn-danger btn-xs' onclick='removeimg();'>Clear Image</button>");
	}
	function removeimg() {
		$("#uploadImageFile").val('');
		$("#showImageHere").html('');
	}
	</script>
	<div class="form-group">
		<label for="exampleFormControlInput1">Tags</label>
		<textarea class="form-control" id="tags" name="tags" placeholder=", Seperated"><?php echo $tags; ?></textarea>
	</div>
	<div class="form-group">
		<label for="exampleFormControlInput1">Main Image(Best View : 950px X 460px)</label>
		<input type="file" name="brandlogo" id="brandlogo" class="form-control" />
		<?php 
		if($logo !== ""){ ?>
			<img src="<?php echo "uploads/".$logo; ?>" width="100" class="img-fluid" />
		<?php } ?>
	</div>
	<button type="submit" class="btn btn-info">Submit</button>
<?php }
?>

<script type="text/javascript">
  $(function () {
    //Initialize Select2 Elements
    $('.select2bs4').select2({
      theme: 'bootstrap4'
    })
  });
	function get_secondary_technicians(){
		var primary_technician = $('#primary_technician').val();
		var action = "load_secondary_technicians";
		$.ajax({
			type: "POST",
			url: "functions.php",
			data: { primary_technician: primary_technician, action: action  },
			dataType: "html",
			success: function(html){
				$("#secondary_technician").html(html);
			}
		});
	}
</script>
