<!DOCTYPE html>
<html>
<head>
	<?php include('include/head.php'); ?>
	<!-- <title>Add City</title> -->
</head>
<body>
	<?php include('include/header.php'); ?>
	<?php include('include/sidebar.php'); ?>
	<div class="main-container">
		<div class="pd-ltr-20 customscroll customscroll-10-p height-100-p xs-pd-20-10">
			<div class="min-height-200px">
				<div class="page-header">
					<div class="row">
						<div class="col-md-6 col-sm-12">
							<div class="title">
								<h4>Add Voucher Category</h4>
							</div>
							<nav aria-label="breadcrumb" role="navigation">
								<ol class="breadcrumb">
									<li class="breadcrumb-item"><a href="dashboard.php">Dashboard</a></li>
									<!-- <li class="breadcrumb-item"><a href="#">Gallery</a></li> -->
									<li class="breadcrumb-item"><a href="view_voucher_category.php">Voucher Category</a></li>
									<li class="breadcrumb-item active" aria-current="page">Add Voucher Category</li>
								</ol>
							</nav>
						</div>
						<div class="col-md-6 col-sm-12 text-right">
							<div class="dropdown">
								<a class="btn btn-primary" href="view_voucher_category.php" role="button">
									View Voucher Category
								</a>
							</div>
						</div>
					</div>
				</div>


				
<div class="pd-20 bg-white border-radius-4 box-shadow mb-30">
					<div class="clearfix">
						<div class="pull-left">
							<!-- <h4 class="text-blue">Add Image Title</h4> -->
						</div>
						
					</div><br> 

								<?php
                                    
                                    if (isset($_POST['submit'])) 
                                    {
                                        
                                        extract($_POST);
                                       
					                $sel=mysqli_query($connect,"select * from tbl_voucher_category where fld_voucher_category_id!='".$_POST['voucher_category']."' and fld_voucher_category='".$_POST['voucher_category']."'") or die(mysqli_error($connect));

                                        if(mysqli_num_rows($sel)==1)
                                        {
                                        	echo "<script>";
                                            echo "alert('Voucher Category Alredy Exist');";
                                            echo "window.location.href='add_voucher_category.php';";
                                            echo "</script>";
                                        }
                                        else
                                        {

	                                        $query="INSERT INTO tbl_voucher_category(fld_voucher_category) VALUES ('$voucher_category')";
	                                        //echo $query."<br>";
	                                        $row=mysqli_query($connect,$query) or die(mysqli_error($connect));
	                                        if ($row) 
	                                        {
	                                            echo "<script>";
	                                            echo "alert('Voucher Category Added Successfully');";
	                                            echo "window.location.href='view_voucher_category.php';";
	                                            echo "</script>";                 
	                                        }
	                                        else
	                                        {
	                                            echo "<script>";
	                                            echo "alert('Error');";
	                                            echo "</script>";
	                                        }
	                                    }
                                    }
                                ?>						
					<form method="post">
						<div class="form-group row">
							<label class="col-sm-12 col-md-2 col-form-label">Voucher Category <span class="text-danger">*</span> : </label>
							<div class="col-sm-12 col-md-10">
								<input class="form-control" type="text" name="voucher_category" placeholder="Enter Voucher Category" required="" oninput="this.value = this.value.replace(/[^a-zA-Z\s.]/g, '').replace(/(\..*)\./g, '$1');">
							</div>
						</div>

						
						<div class="form-group row">
							<div class="col-sm-12 col-md-10">
							<center><input class="btn btn-success" value="Submit" type="submit" name="submit">&nbsp;
								<input class="btn btn-danger" value="Reset" type="reset">&nbsp;
								<a href="view_voucher_category.php" class="btn btn-warning">Back</a></center>
							</div>
						</div>
					</form>

					 
	</div>
			<?php include('include/footer.php'); ?>
		</div>
	</div>
	<?php include('include/script.php'); ?>
</body>
</html>