<?php include("../header.php"); ?>
		
		<div class="container-fluid">
			<div class="animated fadeIn">
				<div class="row">
					<div class="col-lg-6">
						
						<div class="card">
							<div class="card-header">
								Web Categories
							</div>
							<div class="card-body">
						
								<form method="post" action="" name="web-cat" role="form" id="web-cat-form" enctype="multipart/form-data">
									
									<?php
									if(isset($errMSG)) {
										?>
										<div class="form-group">
											<div class="alert alert-<?php echo ($errTyp = "success") ? "success" : $errTyp; ?>">
												<span><?php echo $errMSG; ?></span>
											</div>
										</div>
										<?php
									}
									?>
									
									<div class="form-group">
										<label>Category Name</label>
										<input type="text" name="cat_name" class="form-control">
									</div>
									<div class="form-group">
										<label>Category Description</label>
										<textarea name="cat_desc" class="form-control" rows="5"></textarea>
									</div>
									<div class="row">
										<div class="col-lg-4">
											<div class="form-group">
												<label>Is Active?</label>
												<select name="is_active" class="form-control">
													<option value="1" selected>Yes</option>
													<option value="0">No</option>
												</select>
											</div>
										</div>
										<div class="col-lg-8">
											<div class="form-group">
												<label>Category Image</label>
												<input type="file" name="cat_image" class="form-control">
												<div class="text-danger"><?php echo $image; ?></div>
											</div>
										</div>
									</div>
									<div class="form-group">
										<label>Subcategory</label>
										<input type="text" name="subcat" class="form-control">
									</div>
									<div class="row">
										<div class="col-lg-4">
											<div class="form-group">
												<label>Category Tags</label>
												<input type="text" name="cat_tags" class="form-control">
											</div>
										</div>
										<div class="col-lg-4">
											<div class="form-group">
												<label>Order By</label>
												<input type="text" name="order_by" class="form-control">
											</div>
										</div>
										<div class="col-lg-4">
											<div class="form-group">
												<label>Item Updated?</label>
												<input type="text" name="item_update" class="form-control">
											</div>
										</div>
									</div>
									<div class="form-group">
										<button type="submit" name="cat_submit" class="btn btn-primary px-4" id="cat-submit">Submit</button>
									</div>
									
								</form>
								
							</div>
						</div>
						
					</div>
				</div>
			</div>
		</div>
	
<?php include("../footer.php"); ?>

<script>
$(document).ready(function(){
	$('#web-cat-form').submit(function(e){
		
		e.preventDefault(); // Prevent Default Submission
		
		$.ajax({
			url: 'web_categories_submit.php',
			type: 'POST',
			data: $(this).serialize() 
		})
		.done(function(data){
			console.log(data);
		})
		.fail(function(){
			
		});
	});
});
</script>