<?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');
}
?>
<!DOCTYPE html>
<html lang="en">
    <head>
      <?php include("link_head.php");?>  
    <!-- END HEAD -->

<!--  <style>
		::-webkit-scrollbar {
			display: none;
			overflow: hidden;
		}
	  </style>
<!--  <script>
		window.onscroll = function () {
		window.scrollTo(0,0);
		}
	  </script>-->
	</head>
    <body class="" onload="changecolor5();">
        <!-- BEGIN HEADER -->
		<?php include("header.php");?>
        <!-- END HEADER -->
		
        <!-- BEGIN CONTAINER -->
        <div class="container-fluid">
            <div class="page-content page-content-popup" style="margin-top:18px; max-height:542px;">
                <div class="page-content-fixed-header">
                    <!-- BEGIN BREADCRUMBS 
                    <ul class="page-breadcrumb">
                        <li>
                            <a href="#">Dashboard</a>
                        </li>
                        <li>Admin Dashboard</li>
                    </ul>
                    <!-- END BREADCRUMBS -->  
                </div>
                <div class="page-sidebar-wrapper">
                    <!-- BEGIN SIDEBAR -->
                    <?php include("menu.php");?> 
				    <!-- END SIDEBAR -->
                </div>
				
				<?php
				
						date_default_timezone_set('Asia/Calcutta');
						$cdate1  = date("Y-m-d");
						
						if(isset($_POST['searchd']))
						{
							$txn_date_from=$_POST['txn_date_from'];
							$txn_date_to=$_POST['txn_date_to'];
							$cdate=$_POST['search'];
							
							$res ="SELECT tbl_master_product.*,tbl_master_category.category_id,tbl_master_category.category_name,tbl_master_category.brand_id,tbl_master_brand.brand_id,tbl_master_brand.brand_name FROM tbl_master_brand,tbl_master_category,tbl_master_product WHERE tbl_master_brand.brand_id=tbl_master_category.brand_id AND tbl_master_category.category_id=tbl_master_product.category_id AND tbl_master_brand.distributor_id='$ver'";
							
							/*if($txn_date_from!="")
							{
							 $res=$res." && tbl_master_product.insert_date>='$txn_date_from' && tbl_master_product.insert_date<='$txn_date_to'";	
							}*/
							if($cdate!="")
							{
							 $res=$res." AND (tbl_master_product.product_name LIKE '%$cdate%' OR tbl_master_category.category_name LIKE '%$cdate%' OR tbl_master_brand.brand_name LIKE '%$cdate%' and tbl_master_product.status in ('Active','Deactive'))";	
							}
							$res = mysqli_query($con,$res);							
						}
						else
						{  
							$res = mysqli_query($con,"SELECT tbl_master_product.*,tbl_master_category.category_id,tbl_master_category.category_name,tbl_master_category.brand_id,tbl_master_brand.brand_id,tbl_master_brand.brand_name FROM tbl_master_brand,tbl_master_category,tbl_master_product WHERE tbl_master_brand.brand_id=tbl_master_category.brand_id AND tbl_master_category.category_id=tbl_master_product.category_id AND tbl_master_brand.distributor_id='$ver'");
						}
					?> 
				
                <div class="page-fixed-main-content" style="margin-bottom:-10px;">
                    <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>All Product
							</div>
							</div>
							
							<div class="portlet-title" style="padding:0; margin:0;">
							 <div class="col-md-4" style="padding:0; margin:0;">
							  <?php //if($user_role=="Admin") { ?>  
									<a href="add-product.php" class="btn btn-outline btn-circle blue btn-sm blue"> Add Product </a>  
							  <?php //} else { echo "Product Detail"; } ?>
							 </div>
							 
							 <div class="col-md-8" style="padding:0; margin:0;">
								<form method="post" name="searchdate">
								 <div class="col-md-2" style="padding:0px;"></div>
								 <div class="col-md-3" style="padding:0px;">
								 <!--<div class="form-group" style="padding-top:0; margin-bottom:0; padding-bottom:0;">
								   <input type="date"  class="form-control" name="txn_date_from" value="<?php // if(isset($_POST['txn_date_from'])){ echo $txn_date_from; } else { echo date("Y-m-d"); }?>" max="<? //=date("Y-m-d")?>" style="font-size:12px; padding-left:5px; padding-right:0;"/>
								  </div>-->
								 </div>
								 
								 <div class="col-md-3" style="padding:0px;">
								<!--<div class="form-group" style="padding:0; margin:0;">
								   <input type="date"  class="form-control" name="txn_date_to" value="<?php // if(isset($_POST['txn_date_to'])){ echo $txn_date_to; } else { echo date("Y-m-d"); }?>" max="<? //=date("Y-m-d")?>" style="font-size:12px; padding-left:5px; padding-right:0;" />
								  </div>-->
								 </div>
								 <div class="col-md-3" style="padding:0px;">
								  <div class="form-group" style="padding:0; margin:0;">
								   <input type="text"  class="form-control" name="search" value="<?php echo $cdate; ?>" style="font-size:12px; padding-left:5px; padding-right:0;" placeholder="Product Name" />
								  </div>
								 </div>
								 
								 <div class="col-md-1" style="padding-left:0px;">
								  <div class="form-group" style="padding-top:0; margin-bottom:0; padding-bottom:0;">
								   <button type="submit" class="btn green" name="searchd"> <i class="fa fa-search"></i></button>
								  </div>
								 </div>
								</form>
							 </div>
							</div>
							
								<div class="scroller portlet-body" style="padding-bottom:0; margin-bottom:0.8%; height:390px; overflow-Y:scroll; overflow-X:hidden; padding-top:0;">
									<div class="table-scrollable" style="padding-top:0; margin-bottom:0; padding-bottom:0; padding-top:0;">
										<table class="table table-striped table-bordered table-advance table-hover" style="padding-top:0; margin-bottom:0; padding-bottom:0; padding-top:0;">
											<thead>
											<tr>
												<th><b>#</b></th>
												<th><b>Brand Name</b></th>
												<th><b>Category Name</b></th>
												<th><b>Product Name</b></th>
												<th><b>HSN Code</b></th>
												<th><b>MRP</b></th>
												<th><b>Price</b></th>
												<th><b>mAh Compatible</b></th>
												<th><b>Warranty</b></th>
												<th><b>Warranty Desc.</b></th>													
												<?php if($user_role=="Admin") { ?>
												<th><b>Action</b></th>
												<?php } ?>
											</tr>
											</thead>
											<tbody>
											<?php
											$c=1;
											date_default_timezone_set('Asia/Calcutta');
											$da  = date("Y-m-d"); 
											// $res=mysqli_query($con,"SELECT * FROM tbl_master_brand,tbl_master_category,tbl_master_product WHERE tbl_master_brand.brand_id=tbl_master_category.brand_id AND tbl_master_category.category_id=tbl_master_product.category_id AND tbl_master_brand.distributor_id='$ver'" );
											 if(mysqli_num_rows($res)>0)
											{
											 while($fetch_product=mysqli_fetch_assoc($res))
											 {	extract($fetch_product);
											?>
											<tr>
												<td title="S.No."><?php echo $c++; ?></td>
												<td> <?=$brand_name; ?></td>
												<td> <?=$category_name; ?> </td>
												<td> <?=$product_name; ?> </td> 
												<td> <?=$hsn_code; ?> </td>
												<td> <?=$mrp; ?> </td> 
												<td> <?=$product_price; ?> </td>
												<td> <?=$mAh_compatible; ?> </td>
												<td> <?=$warranty; ?> </td>	
												<td> <?=$warranty_description; ?> </td>
												<?php if($user_role=="Admin") { ?>
												<td>
												
												<a href="edit-product-detail.php?id=<?php echo $product_id;?>" class="btn btn-outline btn-circle btn-sm blue" title="Edit Product Detail"><i class="fa fa-pencil-square-o"></i></a>
												
												<?php if($status=='Deactive') { ?>
												  <a href="product-detail-status.php?id=<?php echo $product_id;?>" onClick="return confirm('Are you sure to edit this status')" class="btn btn-outline btn-circle green btn-sm blue">Activate</a>
												<?php } else { ?>
												  <a href="product-detail-status.php?id=<?php echo $product_id;?>" onClick="return confirm('Are you sure to edit this status')" class="btn btn-outline btn-circle red btn-sm blue">Deactivate</a>
												<?php } ?>
												</td>
												<?php } ?>
												</tr>
												<?php } } else { echo "No Data Available"; } ?>
										
											</tbody>
										</table>
									</div>

								</div>
								
								
							</div>
							<!-- END SAMPLE TABLE PORTLET-->
						</div>
							   
					</div>
					
                    <div class="clearfix"></div>
                    <!-- END DASHBOARD STATS 1-->
                    <!-- END PAGE BASE CONTENT -->
                </div>
                <!-- BEGIN FOOTER -->
                
                <!-- BEGIN QUICK SIDEBAR TOGGLER 
                <button type="button" class="quick-sidebar-toggler" data-toggle="collapse">
                    <span class="sr-only">Toggle Quick Sidebar</span>
                    <i class="icon-logout"></i>
                    <div class="quick-sidebar-notification">
                        <span class="badge badge-danger">7</span>
                    </div>
                </button>
                <!-- END QUICK SIDEBAR TOGGLER -->
                <a href="#index" class="go2top">
                    <i class="icon-arrow-up"></i>
                </a>
                <!-- END FOOTER -->
            </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>
        </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>

