<?php
	include'session.php';
	include'../connection.php';
	include'../functions.php';
?>
<html>
<head>
	<title>Seller List</title>
	<!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    
	<link rel="icon" href="images/logo.png" type="image/gif" sizes="16x16">
	
	<!-- Admin CSS File Link -->
	<link rel="stylesheet" href="css/style.css">
	
	<!-- User JAVA SCRIPT File Link -->
	<script type="text/javascript" src="js/script.js"></script>
	
	
	<!-- Font Awesome Icone -->
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
	
	<style>
	    .data-content{background:; height:auto;}
		.div1{
			background:;
			width:98%;
			margin:1%;
			padding:10px;
			height:auto;
		}
		.div1 input, .div1 select{
			height:35px;
			width:200px;
			font-size:18px;
			padding:2px 10px;
			border-radius:5px;
			border:solid #6b5127 1px;
			overflow:hidden;
			margin:10px 10px 0 10px;
		}
		input[type=submit]{
			background:#6b5127;
			color:white;
			cursor:pointer;
			transition:1s;
		}
		input[type=submit]:hover{
			background:white;
			color:#883333;
			border:solid #6b5127 1px;
			transition:1s;
		}
		.fa-check, .fa-ban{font-size:20px;}
		.divHead1{background:; height:auto;} 
		
		.tbl1{width:98%; margin:1%;  text-align:left;}
		.tbl1 th{background:#5C3B3B; color:white; padding:2px 5px; font-size:17px;}
		.tbl1 td{background:#E3DCDC; padding:5px; font-size:15px;}
		
		.fa-Minus{display:none;}
		.inpApiOp{display:none; width:80px; padding:2px 5px; text-align:center; margin-left:50%; transform:translate(-50%,0%);}
		.inpBtn{width:auto; text-align:center; float:left; margin:4px 10px;}
		
		.width1{width:10%;}
		.width2{width:20%;}
		.width3{width:30%;}
		
		@media(max-width:768px)
		{
			.div1{
				background:;
				width:100%;
				height:auto;
				margin:10px 0 0 0;
				padding:0;
				text-align:center;
			}
			.div1 input, .div1 select{
				width:90%;
				margin:10px;
			}
			.div2{
				width:100%;
				margin:10px 0 0 0;
				padding:0px;
				text-align:center;
			}
		}
	</style>
	<link rel="stylesheet" href="css/mediaStyle.css">
</head>
<body>
	<!--Header Divison-->
	<?php
		require'header.php';
	?>
	
	<!--Container Division-->
	<div class="container">
		<?php
			include'menu.php';
		?>
		<div class="content">
			<div class="head">
				<div class="title"><p>Active Sellers :-</p></div>
				<div class="msg"><marquee><?php include'../msg.php'; ?></marquee></msg>
			</div><hr>
			<div class="data-content">
			    <div class="div1">
			        <form method="post">
					    <select name="status">
					        <?php
					        echo "<OPTION ".$selected6.">ACTIVE</OPTION>
					              <OPTION ".$selected7.">DEACTIVE</OPTION>";
					        ?>
					    </select>
						<input type="submit" name="submit" value="Submit"  onclick='showLoader()'>
				    </form>
				    
				    <div class="divHead1">
				        <table class="tbl1">
				            <tr>
				                <th>Sl</th>
				                <th>Seller</th>
				                <th>Mobile</th>
				                <th>City</th>
				                <th>Firm Name</th>
				                <th>Gst No.</th>
				                <th>Owner</th>
				            </tr>
				            <?php
							    $sl=0;
							    if(isset($_POST['submit']))
			    			    {
							        $status = $_POST['status'];
							        $UsrQu="SELECT Seller.Id, Seller.Name, Seller.Mobile, Seller.City, Seller.Status, seller_firm.Id, seller_firm.FirmName, seller_firm.GstNo, seller_firm.OwnerName, seller_firm.Status FROM seller_firm INNER JOIN Seller ON seller_firm.SellerId=Seller.Id WHERE Seller.Status='$status' ORDER By Seller.Name";
							    }
							    else
							    {
							        $UsrQu="SELECT Seller.Id, Seller.Name, Seller.Mobile, Seller.City, Seller.Status, seller_firm.Id, seller_firm.FirmName, seller_firm.GstNo, seller_firm.OwnerName, seller_firm.Status FROM seller_firm INNER JOIN Seller ON seller_firm.SellerId=Seller.Id WHERE Seller.Status='ACTIVE' ORDER By Seller.Name";
							    }
							    $UsrResult=mysqli_query($con,$UsrQu);
							    while($UsrData=mysqli_fetch_array($UsrResult))
							    {
    							    $sl=$sl+1;
    							    $sellerId = $UsrData[0];
    							    $firmId   = $UsrData[5];
    							    echo "<tr>";
    							        echo "<td>".$sl."</td>";
    							        echo "<td id='pSeller".$sellerId."'>";
    							        if($UsrData[4]=="ACTIVE")
    							        {
    							            echo "<p style='color:green;' ondblclick='updateSeller($sellerId)'>".$UsrData[1]."</p>";
    							        }
    							        else
    							        {
    							            echo "<p style='color:red;' ondblclick='updateSeller($sellerId)'>".$UsrData[1]."</p>";
    							        }
    							        echo "</td>";
    							        echo "<td>".$UsrData[2]."</td>";
    							        echo "<td>".$UsrData[3]."</td>";
    							        echo "<td id='pFirm".$firmId."'>";
    							        if($UsrData[9]=="ACTIVE")
    							        {
    							            echo "<p style='color:green;' ondblclick='updateFirm($firmId)'>".$UsrData[6]."</p>";
    							        }
    							        else
    							        {
    							            echo "<p style='color:red;' ondblclick='updateFirm($firmId)'>".$UsrData[6]."</p>";
    							        }
    							        echo "<td>".$UsrData[7]."</td>";
    							        echo "<td>".$UsrData[8]."</td>";
    							    echo "</tr>";
    					
							    }
						    ?>
				        </table>
					</div>
					<script>
					    function updateSeller(Arg)
					    {
					        var AjaxName     = "Ajax9";
	                        var sellerId     = Arg;
	                        var confrim_rslt = confirm("Are You Sure ?");
			            
			                if(confrim_rslt==true)
			                {
	                            var xmlhttpSponser = new XMLHttpRequest();
		    	                xmlhttpSponser.open("GET","Ajax.php?AjaxName="+AjaxName+"&sellerId="+sellerId, false)
			                    xmlhttpSponser.send(null);
			                    document.getElementById("pSeller"+Arg).innerHTML = xmlhttpSponser.responseText;
			                }
					    }
					    
					    function updateFirm(Arg)
					    {
					        var AjaxName     = "Ajax10";
	                        var firmId       = Arg;
	                        var confrim_rslt = confirm("Are You Sure ?");
			            
			                if(confrim_rslt==true)
			                {
	                            var xmlhttpSponser = new XMLHttpRequest();
		    	                xmlhttpSponser.open("GET","Ajax.php?AjaxName="+AjaxName+"&firmId="+firmId, false)
			                    xmlhttpSponser.send(null);
			                    document.getElementById("pFirm"+Arg).innerHTML = xmlhttpSponser.responseText;
			                }
					    }
					</script>
				    
				</div>
			</div>
	<?php
		require'footer.php';
	?>
</body>
</html>