<?php

session_start();


?>





<?php  
include("dbcon.php");         //form and imge code
//include("admin/header.php");
if(isset($_POST['submit']))
{
    
$dist=$_POST['dist'];
$cat=$_POST['cat'];

$product=$_POST['product'];

$mobile=$_POST['mobile'];

$web=$_POST['web'];
$name=$_POST['name'];
$desc=$_POST['desc'];




//$sub=$_POST['status'];


$image_name=$_FILES['image']['name'];
$image_size=$_FILES['image']['size'];
$image_type=$_FILES['image']['type'];
$image_temp=$_FILES['image']['tmp_name'];
$store="images/".$image_name;
$upload=move_uploaded_file($image_temp, $store);


$qry = mysqli_query($con,"INSERT INTO tbl_product(manudist_id,cat_id,product,mobile,website,name,description,status,image,date) VALUES ('$dist','$cat','','','','$name','$desc','1','$image_name',now())"); 
if($qry==true)
{
$_SESSION['status']="Photo Advertisement has been Uploaded Seccessfully..";
        $_SESSION['status_code']="success";
				 ?>
		 <script>
		 setTimeout(function () {
       window.location.href = "product.php"; //will redirect to your stud_registration page after 3000 ms
    }, 3000);
	</script>
	<?php 
}
else
{
	$_SESSION['status']="Photo Advertisement has not been Uploaded Seccessfully..";
        $_SESSION['status_code']="error";
				 ?>
		 <script>
		 setTimeout(function () {
       window.location.href = "product.php"; //will redirect to your stud_registration page after 3000 ms
    }, 3000);
	</script>
	<?php 
}
}
?>
 


<!DOCTYPE html>
<html lang="en">


<head>
  <meta charset="utf-8"/>
  <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
  <meta name="description" content=""/>
  <meta name="author" content=""/>
  <title>Manufacturer Advertisement</title>
  <!--favicon-->
  <link rel="icon" href="assets/images/favicon.ico" type="image/x-icon">
  <!-- simplebar CSS-->
  <link href="assets/plugins/simplebar/css/simplebar.css" rel="stylesheet"/>
  <!-- Bootstrap core CSS-->
  <link href="assets/css/bootstrap.min.css" rel="stylesheet"/>
  <!-- animate CSS-->
  <link href="assets/css/animate.css" rel="stylesheet" type="text/css"/>
  <!-- Icons CSS-->
  <link href="assets/css/icons.css" rel="stylesheet" type="text/css"/>
  <!-- Sidebar CSS-->
  <link href="assets/css/sidebar-menu.css" rel="stylesheet"/>
  <!-- Custom Style-->
  <link href="assets/css/app-style.css" rel="stylesheet"/>


  <script src="ckeditor/ckeditor.js"></script>
  
  
   <!---start code for dependent dropdown---->
      <script type="text/javascript">
    function myfunction(datavalue)
    {
        $.ajax({
        url: 'ajax.php',
        type: 'post',
        data: { datapost : datavalue},

        success : function(result){
        $('#dataget').html(result);
        }
        });
    }
    
    </script>     
<!---end code of dependent dropdown--->
  
</head>

<body>

<!-- Start wrapper-->
 <div id="wrapper">
 
   <!--Start sidebar-wrapper-->
   
   <?php include('sidebar.php');?>
   
   <!--End sidebar-wrapper-->

<!--Start topbar header-->

<?php include('header.php');?>
<!--End topbar header-->

<div class="clearfix"></div>
	
  <div class="content-wrapper">
    <div class="container-fluid">
      <!-- Breadcrumb-->
     <!--<div class="row pt-2 pb-2">
        <div class="col-sm-9">
		    <h4 class="page-title">Gallery</h4>
		    <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="javaScript:void();">Rukada</a></li>
            <li class="breadcrumb-item"><a href="javaScript:void();">Forms</a></li>
            <li class="breadcrumb-item active" aria-current="page">Form Validation</li>
         </ol>
	   </div>
	   <div class="col-sm-3">
       <div class="btn-group float-sm-right">
        <button type="button" class="btn btn-outline-primary waves-effect waves-light"><i class="fa fa-cog mr-1"></i> Setting</button>
        <button type="button" class="btn btn-outline-primary dropdown-toggle dropdown-toggle-split waves-effect waves-light" data-toggle="dropdown">
        <span class="caret"></span>
        </button>
        <div class="dropdown-menu">
          <a href="javaScript:void();" class="dropdown-item">Action</a>
          <a href="javaScript:void();" class="dropdown-item">Another action</a>
          <a href="javaScript:void();" class="dropdown-item">Something else here</a>
          <div class="dropdown-divider"></div>
          <a href="javaScript:void();" class="dropdown-item">Separated link</a>
        </div>
      </div>
     </div>
     </div>-->
    <!-- End Breadcrumb-->
	
	

      <div class="row">
        <div class="col-lg-12">
          <div class="card">
            <div class="card-body">
              <form id="signupForm" method="post" enctype="multipart/form-data">
			  
              
				
				
                <h4 class="form-header text-uppercase">
                  Add Images
                </h4>
                
                
                <div class="form-group row">
                    
                    
                    <label for="input-11" class="col-sm-2 col-form-label">Manufacturer</label>
                  <?php 
                 
                  $nitin=mysqli_query($con,"SELECT * FROM tbl_manudistributor");
                  ?>
                  <div class="col-sm-4">
                   <select class="form-control"  onchange="myfunction(this.value)"  name="dist">
                   	
                    <?php while($row=mysqli_fetch_array($nitin)){?>
                    <option value="<?php echo $row['manudist_id'];?>"><?php echo $row['manudistributor_name'];?></option>
                  <?php }?>
                    </select>
                  </div>
                    
                    
                    
                    <label for="input-11" class="col-sm-2 col-form-label">Product</label>
                  <?php 
                 
                  $nitin=mysqli_query($con,"SELECT * FROM tbl_category");
                  ?>
                  <div class="col-sm-4">
                   <select class="form-control"  id="dataget"  name="cat">
                   	<option>Select</option>
                    <?php while($row=mysqli_fetch_array($nitin)){?>
                    <option value="<?php echo $row['cat_id'];?>"><?php echo $row['category_name'];?></option>
                  <?php }?>
                    </select>
                  </div>
                  
                 
                  </div>

                
                  
                 <div class="form-group row">
                  <label for="input-16" class="col-sm-2 col-form-label">Upload Image</label>
                  <div class="col-sm-10">
                    <input type="file" class="form-control" id="input-16" name="image">
                  </div>
                </div>
                
                 
                
                 
                 <div class="form-group row">
                  <label for="input-14" class="col-sm-2 col-form-label">Name</label>
                  <div class="col-sm-4">
                    <input type="text"  name="name" class="form-control" id="input-14" onkeypress="return this.value.length < 10;" placeholder="nter Name...">
                  </div>

                </div>
                 



                <textarea class="ckeditor" name="desc"></textarea>
				
                <div class="form-footer">
                   <center> <button type="text" class="btn btn-danger"><i class="fa fa-times"></i> CANCEL</button>
                    <button type="text" name="submit" class="btn btn-success"><i class="fa fa-check-square-o"></i> SAVE</button></center>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div><!--End Row-->
	  
	  
      <!--<div class="row">
        <div class="col-lg-12">
          <div class="card">
            <div class="card-header"><i class="fa fa-table"></i>Image Details</div>
            <div class="card-body">
              <div class="table-responsive">
              <table id="example" class="table table-bordered">
                <thead>
                    <tr>
                        <th>Sr No.</th>
                        <th>Name</th>
                        <th>Image</th>
                        <th>Date</th>
                        <th>Actions</th>
                      
                    </tr>
                </thead>
                <tbody>
				
				<?php 
		$a=1;
		$query=mysqli_query($con,"SELECT * FROM tbl_gallery order by id desc limit 10"); ?>
		<?php while($row=mysqli_fetch_array($query)){?>
			
                    <tr>
                        <td><?php echo $a;?></td>
                        <td><?php echo $row['name'];?></td>
						<td><?php echo $row['date'];?></td>
                        <td><img src="gym_image/<?php echo $row['image'];?>" style="height:90px;width:90px;"></td>
                        
                     
                       <td>
			
                   <a onclick="return confirm('Are you sure want to delete ?');" style="color:white" href="gallery?dashboard/state/id=<?php echo $row['id'];?>"> <button type="submit"  class="btn btn-danger"><i class="fa fa-times"></i>DElete</button></a>
					</td>
                    </tr>

		<?php $a++;}?>
		
		
                   
                </tbody>
               
            </table><br>
			
			<div class="form-footer">
                  <center>  <a href="gallery_list" style="color:white"><button type="submit"  class="btn btn-primary">View More</button></a></center>
                  
                </div>
			
            </div>
			
            </div>
          </div>
        </div>
		
      </div>--><!-- End Row-->
	  
	  

    </div>
    <!-- End container-fluid-->
    
    </div><!--End content-wrapper-->
	
	
	

   <!--Start Back To Top Button-->
    <a href="javaScript:void();" class="back-to-top"><i class="fa fa-angle-double-up"></i> </a>
    <!--End Back To Top Button-->
	
	<!--Start footer-->
	<?php include('footer.php');?>
	<!--End footer-->
   
  </div><!--End wrapper-->


  <!-- Bootstrap core JavaScript-->
  <script src="assets/js/jquery.min.js"></script>
  <script src="assets/js/popper.min.js"></script>
  <script src="assets/js/bootstrap.min.js"></script>
	
	<!-- simplebar js -->
	<script src="assets/plugins/simplebar/js/simplebar.js"></script>
  <!-- waves effect js -->
  <script src="assets/js/waves.js"></script>
	<!-- sidebar-menu js -->
	<script src="assets/js/sidebar-menu.js"></script>
  <!-- Custom scripts -->
  <script src="assets/js/app-script.js"></script>

  <!--Form Validatin Script-->
    <script src="assets/plugins/jquery-validation/js/jquery.validate.min.js"></script>
	
<!--Sweet Alerts -->
  <script src="assets/plugins/alerts-boxes/js/sweetalert.min.js"></script>
  <script src="assets/plugins/alerts-boxes/js/sweet-alert-script.js"></script>	
	
	
	
	
	
	
	
	
    <script>

    $().ready(function() {

    $("#personal-info").validate();

   // validate signup form on keyup and submit
    $("#signupForm").validate({
        rules: {
            firstname: "required",
            lastname: "required",
            username: {
                required: true,
                minlength: 2
            },
            password: {
                required: true,
                minlength: 5
            },
            confirm_password: {
                required: true,
                minlength: 5,
                equalTo: "#password"
            },
            email: {
                required: true,
                email: true
            },
             contactnumber: {
                required: true,
                minlength: 10
            },
            topic: {
                required: "#newsletter:checked",
                minlength: 2
            },
            agree: "required"
        },
        messages: {
            firstname: "Please enter your firstname",
            lastname: "Please enter your lastname",
            username: {
                required: "Please enter a username",
                minlength: "Your username must consist of at least 2 characters"
            },
            password: {
                required: "Please provide a password",
                minlength: "Your password must be at least 5 characters long"
            },
            confirm_password: {
                required: "Please provide a password",
                minlength: "Your password must be at least 5 characters long",
                equalTo: "Please enter the same password as above"
            },
            email: "Please enter a valid email address",
            contactnumber: "Please enter your 10 digit number",
            agree: "Please accept our policy",
            topic: "Please select at least 2 topics"
        }
    });

});

    </script>
	
	<!-- SWeet Alert Js -->
	<script src="js/sweetalert.js"></script>
   <?php 
   if(isset($_SESSION['status']) && $_SESSION['status']!=''	)
   {
	  
   ?>
  <script>
 swal({
  title: "<?php echo $_SESSION['status'];?>",
  //text: "You clicked the button!",
  icon: "<?php echo $_SESSION['status_code'];?>",
  button: "Ok!",
});
  </script>
  <?php 
   unset($_SESSION['status']);
   }
   ?> 
	
</body>


</html>
