<?php
ob_start();
error_reporting(0);
include("connect.php");
session_start();
$ver = $_SESSION['distributor_user_id'];
$user_role= $_SESSION['user_role']; 
if(!isset($_SESSION["distributor_user_id"])){
   header('location:https://tarkashcorp.appexperts.net/index.php');
}

if(isset($_POST['sub']))
{   
    $brand_id=$_POST['brand_id'];
	$category_id=$_POST['category_id'];
	$product_name=$_POST['product_name'];
	$hsn_code=$_POST['hsn_code'];
	$mrp=$_POST['mrp'];
	$product_price=$_POST['product_price'];
	$mAh_compatible=$_POST['mAh_compatible'];
	$warranty=$_POST['warranty'];
	$warranty_description=$_POST['warranty_description'];
}

?>
<!DOCTYPE html>
<html lang="en">
    <head>
      <?php include("link_head.php");?>  
    <!-- END HEAD -->
			<script>
			function myFunction() {
				var txt;
				var r = confirm("Are you sure to cancel!");
				if (r == true) {
					window.location.href="product_detail.php";
				} 
			}
			</script>
	<style>
	::-webkit-scrollbar {
		display: none;
		overflow: hidden;
	}
	</style>
	<script>
	window.onscroll = function () {
	window.scrollTo(0,0);
	}
	</script>			
	</head>
	
    <body class="">
        <!-- BEGIN HEADER -->
		<?php include("header.php");?>
        <!-- END HEADER -->
		
        <!-- BEGIN CONTAINER -->
        <div class="container-fluid">
            <div class="page-content page-content-popup">
                
                <div class="page-sidebar-wrapper">
                    <!-- BEGIN SIDEBAR -->
                    <?php include("menu.php");?> 
				    <!-- END SIDEBAR -->
                </div>
                <div class="page-fixed-main-content">
                        <div class="row">
                            <div class="col-md-12">
                                <!-- BEGIN SAMPLE TABLE PORTLET-->
                                <div class="portlet">
                                    <div class="portlet-title">
                                        <div class="caption">
                                            <i class="fa fa-bell-o"></i> Add Product Confirmation
										</div>
                                    </div>
									
                                    <div class="portlet-body form" >
                                        <form method="post" name="form1"  enctype="multipart/form-data">
                                            <div class="form-body">
											<div class="form-group">
											
											<div class="col-md-4">
											 <label>Brand Name</label>
											  <?php
											  $select_nm_qry=mysqli_query($con,"select * from tbl_master_brand where distributor_id='$ver' and  brand_id='$brand_id'");	
											  while($fetch_brand=mysqli_fetch_array($select_nm_qry))
											  {	?> 
										  
											   <input type="text" value="<?=$fetch_brand['brand_name']; ?>" readonly class="form-control">
											   <input type="hidden" value="<?=$fetch_brand['brand_id']; ?>" name="brand_id">
											  
											  <?php } ?>
											</div>
                                     
											
											<div class="col-md-4">
											 <label>Category Name</label>
											 <?php
											  $select_pname_qry=mysqli_query($con,"select * from tbl_master_category where category_id='$category_id'");	
											  $fetch_category=mysqli_fetch_assoc($select_pname_qry);
											 ?> 
											 <input type="text" value="<?=$fetch_category['category_name']?>" name="category_id" class="form-control" readonly> 
											 <input type="hidden" value="<?php if(isset($_POST['sub'])){ echo $category_id; }?>" name="category_id"> 
											</div>
											
											<div class="col-md-4">
											<label>Product Name</label>
                                              <input type="text" value="<?php if(isset($_POST['sub'])){ echo $product_name; }?>" class="form-control" placeholder="PRODUCT NAME" name="product_name" required readonly> 
											</div>
											
											</div>
											<br clear="all"><br>
											
											<div class="form-group">
											<div class="col-md-4">
											<label>HSN Code</label>
                                              <input type="text" value="<?php if(isset($_POST['sub'])){ echo $hsn_code; }?>" class="form-control" placeholder="HSN CODE" name="hsn_code" required readonly> 
											</div>
											
											
											
											<div class="col-md-4">
											<label>MRP</label>
                                             <input type="text" value="<?php if(isset($_POST['sub'])){ echo $mrp; }?>" class="form-control" required placeholder="MRP" name="mrp" style="text-transform:uppercase;" readonly> 
											</div>
											
											<div class="col-md-4">
											<label>Price</label>
                                             <input type="text" value="<?php if(isset($_POST['sub'])){ echo $product_price; }?>" class="form-control" required placeholder="Price" name="product_price" style="text-transform:uppercase;" readonly> 
											</div>
											
											</div>
											<br clear="all"><br>
											<div class="col-md-4">
											<label>mAh Compatible</label>
                                             <input type="text" value="<?php if(isset($_POST['sub'])){ echo $mAh_compatible; }?>" class="form-control" required placeholder="mAh Compatible" name="mAh_compatible" style="text-transform:uppercase;" readonly> 
											</div>
											
											
											
											<div class="col-md-4">
											<label>Warranty</label>
                                            <input type="text" value="<?php if(isset($_POST['sub'])){ echo $warranty; }?>" class="form-control" placeholder="YES/NO" name="warranty" style="text-transform:uppercase;" readonly> 
											</div>
											
											<div class="col-md-4">
											<label>Warranty Description</label>
                                            <input type="text" value="<?php if(isset($_POST['sub'])){ echo $warranty_description; }?>" class="form-control" placeholder="Warranty Description" name="warranty_description" style="text-transform:uppercase;" readonly>
											</div>
											
										<!--</div>-->
											<br clear="all"><br>
                                            </div>
										
                                            <div class="form-actions">
											   <p>Are you sure to add new product</p> 
											   <button type="submit" name="sub1" class="btn blue">Ok</button>
											   <button type="submit" name="sub11" class="btn blue">Back</button>
											   <button type="submit" name="subcancel" class="btn blue" onClick="return confirm('Are you sure to cancel!')">Cancel</button>
											</div>
                                        </form>
										
										<?php
										if(isset($_POST['sub11']))
										{ header("location:add-product.php"); }
										if(isset($_POST['subcancel']))
										{ header("location:product_detail.php");}
										 
										if(isset($_POST['sub1']))
										{
											$brand_id=$_POST['brand_id'];
											$category_id=$_POST['category_id'];
											$product_name=$_POST['product_name'];
											$hsn_code=$_POST['hsn_code'];
											$mrp=$_POST['mrp'];
											$product_price=$_POST['product_price'];
											$mAh_compatible=$_POST['mAh_compatible'];
											$warranty=$_POST['warranty'];
											$warranty_description=$_POST['warranty_description'];
											
											date_default_timezone_set('Asia/Calcutta');
											$cdate  = date("Y-m-d")." ".date('H:i:sa');
											$scro=date("Y-m-d");
											$scri=date('H:i:s');	
											
											$insert_product=mysqli_query($con,"INSERT INTO `tbl_master_product`(category_id,product_name,hsn_code,mrp,product_price,mAh_compatible,warranty,warranty_description,insert_date,tb_insertdatetime,status) VALUES ('$category_id','$product_name','$hsn_code','$mrp','$product_price','$mAh_compatible','$warranty','$warranty_description','$scro','$cdate','Active')");
											
											if($insert_product)
											{
											   header("location:product_detail.php");
											}
										}
										?>
										
                                    </div>
									
                                </div>
                                <!-- END SAMPLE TABLE PORTLET-->
                            </div>
						</div>
                    </div>
                    <div class="clearfix"></div>
                    <!-- END DASHBOARD STATS 1-->
                    <!-- END PAGE BASE CONTENT -->
                </div>		
		    <!-- END CONTAINER -->
            <!-- BEGIN FOOTER -->
			<div class="copyright-v2" style="padding:3px; margin-top:-18px;"> 
			<?=date("Y")?> &copy; Tarkashcorp Developed By <a target="_blank" href="	http://www.belltechnology.in">Bell Technology</a>
			</div>
			<a href="#index" class="go2top">
                    <i class="icon-arrow-up"></i>
                </a>
                <!-- END FOOTER -->
            </div>
        </div>
        <!-- END CONTAINER -->
        <!-- BEGIN QUICK SIDEBAR -->
        <a href="javascript:;" class="page-quick-sidebar-toggler">
            <i class="icon-login"></i>
        </a>
        
        <!-- END QUICK SIDEBAR -->
        <!-- BEGIN QUICK NAV -->
        
        <div class="quick-nav-overlay"></div>
        <!-- END QUICK NAV -->
        
        <!-- BEGIN CORE PLUGINS -->
        <?php include("link_script.php");?>  
        <!-- END THEME LAYOUT SCRIPTS -->
        <script>
            $(document).ready(function()
            {
                $('#clickmewow').click(function()
                {
                    $('#radio1003').attr('checked', 'checked');
                });
            })
        </script>
    </body>
</html>
            