<?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>
	  <style>
	  #abc{
		  text-align:center;
		  align:center;
	  }
	  </style>
	</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-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>
				
				
                <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>Orders Details
							</div>
							<div class="actions">
								<div class="form-group">
									<a href="pending-orders.php"><button type="submit" style="padding:3px 10px;" class="btn btn-outline btn-circle blue btn-sm blue" name="searchd">Back </button></a>
								</div>
							</div>
							</div>
							<div class="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;">
										<thead>
										<tr>
											<th><b>S.No</b></th>
											<th><b>Bill No.</b></th>
											<th><b>Customer Name</b></th>
									<!--	<th><b>Product Name</b></th> -->
											<th><b>Total Amount</b></th>
									<!--	<th><b>Quantity</b></th>
											<th><b>Price</b></th>
											<th><b>CGST Amount</b></th>
											<th><b>SGST Amount</b></th>-->
											<?php if($user_role=="Admin") { ?>
											<th><b>Action</b></th> 
											<?php } ?>
										</tr>
										</thead>
										<tbody>
										<?php
										$c=1;
										$id=$_GET['id'];
//										echo "ver: ".$ver."<br>";
//										echo "id: ".$id."<br>";
										$res=mysqli_query($con,"select * from tbl_master_customer,tbl_transaction where tbl_transaction.customer_id=tbl_master_customer.customer_id and tbl_master_customer.distributor_id='$ver' && tbl_transaction.transaction_id='$id' &&
										tbl_transaction.transaction_status='Pending'");
																			
										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> <?=$customer_transaction_id; ?></td>
											<td> <?=$customer_name; ?></td>
											<td> <?=$total_amount; ?></td>
									<!--	<td> <?=$product_name; ?></td> -->
									<!--	<td> <?=$quantity; ?></td>
											<td> <?=$price; ?></td>
											<td> <?=$cgst_amount; ?></td>
											<td> <?=$sgst_amount; ?></td>-->
											<?php
											$vars = array('id' => $id, 'tid' => $txn_detail_id);
											$querystring = http_build_query($vars);

											if($user_role=="Admin") { ?>
											<td>
											<a href="edit-all.php?id=<?php echo $transaction_id;?>"><button type="submit" style="padding:3px 10px;" class="btn btn-outline btn-circle blue btn-sm blue" name="searchd">Edit All</button></a>
											</td> 
											<?php } ?>
											</tr>
											<?php } } else { echo "No Data Available"; } ?>
										</tbody>
									</table>
									</div>
									<div style="margin-top:20px; margin-bottom:-30px;" class="table-bordered"><b><p id="abc">Orders</p></b></div>
									<div class="table-scrollable">
									
									<table class="table table-striped table-bordered table-advance table-hover" style="padding:50px;">
										<thead>
								<!--	<tr><b id="abc">Orders</b></tr> -->
										<tr>
											<th><b>S.No</b></th>
									<!--	<th><b>Customer Name</b></th> -->
											<th><b>Product Name</b></th>
									<!--	<th><b>Bill No.</b></th> -->
											<th><b>Quantity</b></th>
											<th><b>MRP</b></th>
											<th><b>Price</b></th>
									<!--	<th><b>CGST</b></th>
											<th><b>SGST</b></th>-->
											<?php //if($user_role=="All") { ?>
											<th><b>Action</b></th>
											<?php //} ?>
										</tr>
										</thead>
										<tbody>
										<?php
										$c=1;
										$id=$_GET['id'];
//										echo "ver: ".$ver."<br>";
//										echo "id: ".$id."<br>";
										$res=mysqli_query($con,"select * from tbl_master_customer,tbl_transaction,tbl_transaction_detail,tbl_master_product where
										tbl_master_customer.customer_id=tbl_transaction.customer_id AND 
										tbl_transaction.transaction_id=tbl_transaction_detail.transaction_id AND
										tbl_transaction_detail.product_id=tbl_master_product.product_id AND
										tbl_master_customer.distributor_id='$ver' and tbl_transaction.transaction_id='$id'");
																			
										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> <?=$customer_name; ?></td> -->
											<td> <?=$product_name; ?></td>
									<!--	<td> <?=$customer_transaction_id; ?></td> -->
											<td> <?=$quantity; ?></td>
											<td> <?=$mrp; ?></td>
											<td> <?=$price; ?></td>
									<!--	<td> <?=$cgst_amount; ?></td>
											<td> <?=$sgst_amount; ?></td>-->
											<?php
											$vars = array('id' => $id, 'tid' => $txn_detail_id);
											$querystring = http_build_query($vars);

											if($user_role=="Admin") { ?>
											<td>
											<a href="edit-order-detail.php?<?php echo $querystring;?>" class="btn btn-outline btn-circle btn-sm blue" title="Order Detail"><i class="fa fa-pencil-square-o"></i></a>
											</td>
											<?php } ?>
											</tr>
											<?php } } else { echo "No Data Available"; } ?>
										</tbody>
									</table>
								</div>
							</div>
								
								<?php 
								if(!isset($_POST['searchd']))
								{ /*
									$res1  = mysqli_query($con,"select * from tbl_acc_m_bank where distributor_id='$ver' and status in ('Active','Deactive')");
									$cou = mysqli_num_rows($res1); 
									$total_pages = $cou/10;
									$total_pages =ceil($total_pages);
									echo " <ul class='pagination pagination-sm no-margin pull-right'><li><a href='user-detail.php'>".'First'."</a></li> ";
									for ($i=1; $i<=$total_pages; $i++) { 
												echo "<li><a href='user-detail.php?page=".$i."'>".$i."</a> </li>";
									}; 
									echo "<li><a href='user-detail.php?page=".$total_pages."'>".'Last'."</a></li></ul> "; */
								}
								?>
									
							</div>
							<!-- END SAMPLE TABLE PORTLET-->
						</div>   
					</div>
				</div>				
                <!-- BEGIN FOOTER -->
                <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 -->
        <!--[if lt IE 9]>
<script src="../assets/global/plugins/respond.min.js"></script>
<script src="../assets/global/plugins/excanvas.min.js"></script> 
<script src="../assets/global/plugins/ie8.fix.min.js"></script> 
<![endif]-->
        <!-- BEGIN CORE PLUGINS -->
        <script src="../assets/global/plugins/jquery.min.js" type="text/javascript"></script>
        <script src="../assets/global/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
        <script src="../assets/global/plugins/js.cookie.min.js" type="text/javascript"></script>
        <script src="../assets/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
        <script src="../assets/global/plugins/jquery.blockui.min.js" type="text/javascript"></script>
        <script src="../assets/global/plugins/bootstrap-switch/js/bootstrap-switch.min.js" type="text/javascript"></script>
        <!-- END CORE PLUGINS -->
        <!-- BEGIN THEME GLOBAL SCRIPTS -->
        <script src="../assets/global/scripts/app.min.js" type="text/javascript"></script>
        <!-- END THEME GLOBAL SCRIPTS -->
        <!-- BEGIN THEME LAYOUT SCRIPTS -->
        <script src="../assets/layouts/layout6/scripts/layout.min.js" type="text/javascript"></script>
        <script src="../assets/layouts/global/scripts/quick-sidebar.min.js" type="text/javascript"></script>
        <script src="../assets/layouts/global/scripts/quick-nav.min.js" type="text/javascript"></script>
        <!-- END THEME LAYOUT SCRIPTS -->
        <script>
            $(document).ready(function()
            {
                $('#clickmewow').click(function()
                {
                    $('#radio1003').attr('checked', 'checked');
                });
            })
        </script>
    </body>
</html>