<?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');
}
?>
<?php
if(isset($_POST['sub']))
{   
	$brand_id=$_POST['brand_id'];
	$brand_name=$_POST['brand_name'];
    $category_id=$_POST['category_id'];
	$category_name=$_POST['category_name'];
	$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'];	
}
?>

<?php
//$id2=$_GET['id1'];
?>

<!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> Edit Product Detail 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>
											<input type="text" value="<?=$brand_name; ?>" name="brand_name" placeholder="BRAND NAME" class="form-control" readonly>
											<input type="hidden" value="<?=$brand_id; ?>" name="brand_id"> 
											</div>
											
											<?php
											$cname=mysqli_query($con,"select * from tbl_master_category where category_id='$category_id'");
											if($cname){
												while($fetch_product=mysqli_fetch_assoc($cname))
											 {	extract($fetch_product);
											?>
											<div class="col-md-4">
											 <label>Category Name</label>
									<!--	 <input type="text" value="<?php // $category_name; ?>" name="category_name" placeholder="CATEGORY NAME" class="form-control" readonly> -->
											 <input type="text" value="<?=$category_name; ?>" name="category_name" placeholder="CATEGORY NAME" class="form-control" readonly> 
											 <input type="hidden" value="<?=$category_id; ?>" name="category_id">
											</div>
											<?php } }?>
											
											<div class="col-md-4">
											 <label>Product Name</label>
											 <input type="text" value="<?=$product_name; ?>" name="product_name" placeholder="PRODUCT NAME" class="form-control" readonly> 
											</div>
											
											</div>
											<br clear="all"><br>
											
											<div class="col-md-4">
											 <label>HSN Code</label>
											 <input type="text" value="<?=$hsn_code; ?>" name="hsn_code" placeholder="HSN CODE" class="form-control" readonly> 
											</div>

											<div class="col-md-4">
											<label>MRP <span style="color:red;">*</span></label>
                                             <input type="text" value="<?=$mrp; ?>" class="form-control" readonly placeholder="MRP" name="mrp" onkeypress='return event.charCode >= 48 && event.charCode <= 57' maxlength="6"> 
											</div>
											
											<div class="form-group">
											<div class="col-md-4">
											<label>Product Price</label>
                                              <input type="text" value="<?=$product_price; ?>" class="form-control" placeholder="PRODUCT PRICE" name="product_price" required readonly> 
											</div>
											
											</div>
											<br clear="all"><br>
											
											<div class="col-md-4">
											<label>mAh Compatible <span style="color:red;">*</span></label>
                                             <input type="text" class="form-control" value="<?=$mAh_compatible; ?>" readonly placeholder="mAh Compatible" name="mAh_compatible"> 
											</div>
											
											<div class="col-md-4">
											<label>Warranty</label>
                                             <input type="text" value="<?=$warranty; ?>" class="form-control" required placeholder="WARRANTY" name="warranty" style="text-transform:uppercase;" readonly> 
											</div>
											
											<div class="col-md-4">
											<label>Warranty Description</label>
                                             <input type="text" value="<?=$warranty_description; ?>" class="form-control" required placeholder="WARRANTY DESCRIPTION" name="warranty_description" style="text-transform:uppercase;" readonly> 
											</div>
											
											<br clear="all"><br>
                                            </div>
										
                                            <div class="form-actions">
											<?php if($user_role=="Admin") { ?>
                                               <p>Are you sure to edit product detail!</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>
											<?php } ?>
                                            </div> 
                                        </form>
										
										<?php
										
										if(isset($_POST['sub11']))
										{ 
										$id=$_GET['id'];
										header("location:edit-product-detail.php?id=".$id); 
										}
										if(isset($_POST['subcancel']))
										{ 
										header("location:product_detail.php");
										}
										if(isset($_POST['sub1']))
										{
											$brand_id=$_POST['brand_id'];
											$brand_name=$_POST['brand_name'];
											$category_id=$_POST['category_id'];
											$category_name=$_POST['category_name'];
											$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_detail=mysqli_query($con,"UPDATE tbl_master_product set category_id='$category_id', product_name='$product_name', hsn_code='$hsn_code', mrp='$mrp',product_price='$product_price', warranty='$warranty', warranty_description='$warranty_description', status='Active', tb_updatedatetime='$cdate' where product_id='$id'");
											  
											if($insert_product_detail)
											{
											   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>
			<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>				
		    <!-- END CONTAINER -->
            <!-- BEGIN FOOTER -->
			<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>
            