<?php
	include'session.php';
	include'../connection.php';
	include'../functions.php';
?>
<html>
<head>
	<title>Users 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>
		.div1{
			background:;
			width:98%;
			margin:1%;
			padding:10px;
		}
		.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;
		}
		.div2{
			background:#f7f7f7;
			width:100%;
			text-align:center;
			overflow:auto;
		}
		#inpDataList{display:none; }
		.fa-check, .fa-ban{font-size:20px;}
		
		.mainDiv1{background:; text-align:center; overflow:auto;}
		
		.divHead1{background:; margin:0px 1%; float:left; width:98%;}
		.divHead2,.divHead2Ac{background:#5C3B3B; margin:3px 3px 0px 3px; padding:5px; font-size:15px; width:14%; float:left; text-align:center; color:white;}
		.divHead2Ac{width:16%;}
		.bgClass1{background:#EACDCD; color:black; padding:2px;}
		.divHead2A{float:left; margin:0px 10px;}
		
		.divHead3{width:96%; float:left; text-align:center; display:none;}
		.divHead3A{width:100%; float:left;}
		.divHead3A1{background:#CDCDEA; margin:5px; width:17%; float:left; padding:3px; text-align:center;}
		.divHead3A1Ac{background:#CDCDEA; margin:5px; width:17%; float:left; padding:3px; text-align:center;}
		.divHead3A2{float:left; padding-left:20px;}
		.bgClass2{background:#3B3D5C; color:white; padding:5px;}
		
		.divHead4{width:100%;  float:left; text-align:center; display:none; overflow:auto;}
		.divHead4A{margin-left:30px; width:150%; float:left; }
		.divHead4A1{background:#CDEACD; margin:2px; width:6%; float:left; padding:5px; font-size:13px;}
		.divHead4A2{background:#FAFBFA; margin:2px 2%; padding:2px;  width:20%;  float:left; height:30px;}
		.bgClass3{background:#3F5C3B; color:white; padding:5px; }
		.divWidth1{width:18%; padding:5px; background:;}
		.divWidth2{width:18%; padding:0; background:#FAFBFA; border:solid black 2px;}
		
		.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;}
		
		
		@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 Distributer :-</p></div>
				<div class="msg"><marquee><?php include'../msg.php'; ?></marquee></msg>
			</div><hr>
			<div class="data-content">
			    <script>
			        function searchAnyone()
			        {
			            var UsrType = document.getElementById("UsrType").value;
			            if(UsrType=="ANYONE USER")
			            {
			                document.getElementById("inpDataList").style.display = "inline";
			            }
			            else
			            {
			                document.getElementById("inpDataList").style.display = "none";
			            }
			        }
			        
			        function updateUsrStatus(Arg)
			        {
			            var AjaxName = "Ajax7";
			            var inpid = Arg;
			            var usrId = document.getElementById(inpid).value;
			            var confrim_rslt = confirm("Are You Sure ?");
			            
			            if(confrim_rslt==true)
			            {
			                var xmlhttpState = new XMLHttpRequest();
							xmlhttpState.open("GET","Ajax.php?AjaxName="+AjaxName+"&usrId="+usrId+"&inpid="+inpid, false)
							xmlhttpState.send(null);
							document.getElementById("ip"+inpid).innerHTML = xmlhttpState.responseText;
			            }	
			        }
			        
			        function updateOpStatus(Arg)
			        {
			            var AjaxName     = "Ajax6";
			            var inpid = Arg;
			            var opusr = document.getElementById("opusr"+inpid).value;
			            var opcode = document.getElementById("opcode"+inpid).value;
			            var confrim_rslt = confirm("Are You Sure ?");
			            
			            if(confrim_rslt==true)
			            {
			                var xmlhttpState = new XMLHttpRequest();
							xmlhttpState.open("GET","Ajax.php?AjaxName="+AjaxName+"&opusr="+opusr+"&opcode="+opcode+"&inpid="+inpid, false)
							xmlhttpState.send(null);
							if(xmlhttpState.responseText=="Commsission Invalid !")
							{   
							    alert(xmlhttpState.responseText);
							}
							else
							{   
							    document.getElementById("iop"+inpid).innerHTML = xmlhttpState.responseText;
							}
			            }	
			        }
			    </script>
				<form method="post">
					<div class="div1">
					    <SELECT NAME="userType" id="UsrType" ONCHANGE="searchAnyone()" >
					    <?php
					        if(isset($_POST['submit']))
					        {
					            $userType = $_POST['userType'];
					            $status   = $_POST['status'];
					            $opStatus = $_POST['opStatus'];
					                if($userType=="ADMIN")
								    {
								        $selected1 ="SELECTED";
								    }
								    elseif($userType=="API")
								    {
								        $selected2 ="SELECTED";
								    }
								    elseif($userType=="MASTER")
								    {
								        $selected3 ="SELECTED";
								    }
								    elseif($userType=="DISTRIBUTER")
								    {
								        $selected4 ="SELECTED";
								    }
								    elseif($userType=="RETAILER")
								    {
								        $selected5 ="SELECTED";
								    }
								    
								    if($status=="ACTIVE")
								    {
								        $selected6 ="SELECTED";
								    }
								    elseif($status=="DEACTIVE")
								    {
								        $selected7 ="SELECTED";
								    }
								    
								    if($opStatus=="ACTIVE")
								    {
								        $selected8 ="SELECTED";
								    }
								    elseif($opStatus=="DEACTIVE")
								    {
								        $selected9 ="SELECTED";
								    }
					        }
						    else
						    {
						       $selected2 ="SELECTED"; 
						    }
					        echo "<OPTION ".$selected1.">ADMIN</OPTION>
					        <OPTION ".$selected2.">API</OPTION>
					        <OPTION ".$selected3.">MASTER</OPTION>
					        <OPTION ".$selected4.">DISTRIBUTER</OPTION>
					        <OPTION ".$selected5.">RETAILER</OPTION>";
					   ?>
					    </SELECT>
					    <select name="status">
					        <?php
					        echo "<OPTION ".$selected6.">ACTIVE</OPTION>
					              <OPTION ".$selected7.">DEACTIVE</OPTION>";
					        ?>
					    </select>
					    <select name="opStatus">
					        <?php
					        echo "<OPTION ".$selected8.">ACTIVE</OPTION>
					              <OPTION ".$selected9.">DEACTIVE</OPTION>";
					        ?>
					    </select>
						<input type="submit" name="submit" value="Submit"  onclick='showLoader()'>
					</div>
				</form>
				<div class="div2" id="downlinePlace">
					<div class='mainDiv1'> 
						<div class="divHead1">
							<div class="divHead2">Sl.</div>
							<div class="divHead2">Userid</div>
							<div class="divHead2">Name</div>
							<div class="divHead2">Mobile</div>
							<div class="divHead2">Parent</div>
							<div class="divHead2Ac" >Action</div>
						</div>
						<?php	
	    					$date1=date_create($date);
		                    date_sub($date1,date_interval_create_from_date_string("7 days"));
		                    $resultdate=date_format($date1,"Y-m-d");
		
							$sl=0;
							if(isset($_POST['submit']))
			    			{
							    $userType = $_POST['userType'];
							    $status   = $_POST['status'];
							    $opStatus = $_POST['opStatus'];
							    $UsrQu    = "SELECT * FROM user WHERE Type='$userType' AND Status='$status'";
							}
							else
							{
							    $UsrQu    = "SELECT * FROM user WHERE Type='API' AND Status='ACTIVE'";
							    $opStatus = "ACTIVE";
							}
							$UsrResult=mysqli_query($con,$UsrQu);
							while($UsrData=mysqli_fetch_array($UsrResult))
							{
    							$sl=$sl+1;
								$usrid      = $UsrData['Userid'];
    							$name       = $UsrData['Name'];
    							$Mobile     = $UsrData['Mobile'];
    							$ParentId   = $UsrData['Parent'];
    							$ParentName = getName($ParentId);
    							$status     = $UsrData['Status'];
    							$rowUsrType = $UsrData['Type'];
    							if(empty($ParentName))
    							{
    							    $ParentName="NULL";
    							}
    							echo "<div class='divHead1'>
						                <div class='divHead2 bgClass1'>$sl</div>
						                <div class='divHead2 bgClass1'>$usrid</div>
							            <div class='divHead2 bgClass1'>$name</div>
						                <div class='divHead2 bgClass1'>$Mobile</div>
						                <div class='divHead2 bgClass1'>$ParentName</div>
						                <div class='divHead2Ac bgClass1'>";
						                   echo "<div class='divHead2A' id='ip".$sl."'>";
	   						                    if($status=="ACTIVE")
	    								        {
			    						           echo "<i class='fa fa-check' style='color:lime;' onclick='updateUsrStatus(".$sl.")'></i></span>";
				    					        }
				    					        else
					    				        {
						    			           echo "<i class='fa fa-ban' style='color:red;' onclick='updateUsrStatus(".$sl.")'></i></span>";
							    		        }
						                   echo "</div>";
							                           echo "<input style='display:none' type='hide' id='".$sl."' value='".$UsrData['Userid']."'>";
						                   echo "<div class='divHead2A'><a href='../go_direct_user.php?id=".$UsrData['Userid']."' target='_blank'><i class='fa fa-arrow-right'></i></a></div>";
						                   echo "<div class='divHead2A'><a href='change_profile.php?uid=".$UsrData['Userid']."' target='_blank'><i class='fa fa-user'></i></a></div>";
						                   echo "<div class='divHead2A'><i class='fa fa-plus' id='iconPlus".$sl."' onclick='showOpDiv($sl)'></i>
						                         <i class='fa fa-Minus' id='iconMinus".$sl."' onclick='hideOpDiv($sl)'></i></div>";
	    					               echo "</div>";
							               echo "<div class='divHead3' id='divOP".$sl."'.>";
							                    echo "<div class='divHead3A'>";
													echo "<div class='divHead3A1 bgClass2'>Op Name</div>";
													echo "<div class='divHead3A1 bgClass2'>Op Code</div>";
													echo "<div class='divHead3A1 bgClass2'>Parent C.</div>";
													echo "<div class='divHead3A1 bgClass2'>User C.</div>";
													echo "<div class='divHead3A1Ac bgClass2'>Action</div>";
												echo "</div>";
												
												$quCommSlab="SELECT * FROM comm_slab WHERE Userid='$usrid' AND Status='$opStatus' ORDER By OpName";
												$reCommSlab=mysqli_query($con,$quCommSlab);
												while($dataCommSlab=mysqli_fetch_array($reCommSlab))
												{
		    				                        $sl         = $sl+1;
							                        $OpName     = $dataCommSlab['OpName'];
						                            $OpCode     = $dataCommSlab['OpCode'];
						                            $Comm       = $dataCommSlab['Comm'];
						                            $ParentComm = getComm($ParentId,$OpCode);
						                            $opStatus   = $dataCommSlab['Status'];
							                        if($ParentComm=="")
							                        {
							                            $ParentComm="NULL";
							                        }
							                        echo "<div class='divHead3A'>";
							                            echo "<div class='divHead3A1'>$OpName</div>";
							                            echo "<div class='divHead3A1'>$OpCode</div>";
							                            echo "<div class='divHead3A1'>$ParentComm</div>";
							                            echo "<div class='divHead3A1'><p class='pApiOp' id='pOpCode".$sl."' ondblclick='showInput($sl)'>".$Comm."</p>
										                            <input class='inpApiOp' type='number' id='inpOpCode".$sl."' onfocusout='editOpComm($sl)' value='".$Comm."' name='".$OpCode."' step='0.01' target='_blank'></div>";
							                            echo "<div class='divHead3A1Ac'>";
	            						                    echo "<div class='divHead3A2' id='iop".$sl."'>";
	    		            				                    if($opStatus=="ACTIVE")
		    				            				        {
			    						            	           echo "<i class='fa fa-check' style='color:lime;' onclick='updateOpStatus(".$sl.")'></i></span>";
				    						                    }
	            				    					        else
				            		    				        {
							                			           echo "<i class='fa fa-ban' style='color:red;' onclick='updateOpStatus(".$sl.")'></i></span>";
								    	            	        }
			            				                    echo "</div>";
	        						                            echo "<input style='display:none' type='hide' id='opcode".$sl."' value='".$OpCode."'>";
	        						                            echo "<input style='display:none' type='hide' id='opusr".$sl."' value='".$usrid."'>";
	        						                            if($rowUsrType=="API" || $rowUsrType=="MASTER")
	        						                            {
						            	                            echo "<div class='divHead3A2'><i class='fa fa-plus' id='iconApiPlus".$sl."' onclick='showApiDiv($sl)'></i>
			            				                            <i class='fa fa-Minus' id='iconApiMinus".$sl."' onclick='hideApiDiv($sl)'></i></div>";
	        						                            }
							                            echo "</div>";
							                            
							                 echo "<div class='divHead4' id='divApi".$sl."'.>";
							                    echo "<div class='divHead4A'>";
													echo "<div class='divHead4A1 bgClass3'>Id</div>";
													echo "<div class='divHead4A1 bgClass3'>Use Api</div>";
													echo "<div class='divHead4A1 bgClass3'> AOC</div>";
													echo "<div class='divHead4A1 bgClass3'>R Offer</div>";
													echo "<div class='divHead4A1 bgClass3'>STV</div>";
													echo "<div class='divHead4A1 bgClass3'>Circle</div>";
													echo "<div class='divHead4A1 bgClass3'>Alw Amt</div>";
													echo "<div class='divHead4A1 bgClass3'>Blk Amt</div>";
													echo "<div class='divHead4A1 bgClass3'>Group</div>";
													echo "<div class='divHead4A1 bgClass3'>ReqRoffer</div>";
													echo "<div class='divHead4A1 bgClass3 divWidth1'>Action</div>";
												echo "</div>";
												$sl2=0;
												$quSetApi="SELECT * FROM set_api WHERE Userid='$usrid' AND OpCode='$OpCode' ORDER By Id ASC";
												$reSetApi=mysqli_query($con,$quSetApi);
												while($dataSetApi=mysqli_fetch_array($reSetApi))
												{
		    				                        $sl=$sl+1;
		    				                        $sl2=$sl2+1;
							                        $UseApiId  = $dataSetApi['Id'];
							                        $ApiUserId = $dataSetApi['Userid'];
							                        $UseApi    = $dataSetApi['UseApi'];
						                            $ApiOpCode = $dataSetApi['ApiOpCode'];
						                            $R_offer   = $dataSetApi['R_offer'];
						                            $STV       = $dataSetApi['STV'];
						                            $Circle    = $dataSetApi['Circle'];
						                            $AlwAmt    = $dataSetApi['AlwAmt'];
						                            $BlkAmt    = $dataSetApi['BlkAmt'];
						                            $LapuGroup = $dataSetApi['LapuGroup'];
						                            $ReqRoffer = $dataSetApi['ReqRoffer'];
						                            $apiStatus = $dataSetApi['Status'];
							                            
							                        echo "<div class='divHead4A' id='setApiRowDiv".$sl."'>";
	        				                            echo "<input style='display:none' type='hide' id='myOpCode".$sl."' value='".$OpCode."'>";
	        				                            echo "<input style='display:none' type='hide' id='setApiId".$sl."' value='".$UseApiId."'>";
	       					                            echo "<input style='display:none' type='hide' id='apiUsrId".$sl."' value='".$ApiUserId."'>";
							                            echo "<div class='divHead4A1'>$UseApiId</div>";
							                            echo "<div class='divHead4A1'>";
							                                echo "<select id='apiName".$sl."'>";
							                                $setApiSl=0;
							                                    $quApi="SELECT * FROM api WHERE Status='ACTIVE'";
							                                    $reApi=mysqli_query($con,$quApi);
							                                    while($dataApi=mysqli_fetch_array($reApi))
							                                    {  
							                                        $setApiSl=$setApiSl+1;
							                                        if($dataApi['ApiName']==$UseApi)
							                                        {
							                                            echo "<option selected>".$dataApi['ApiName']."</option>";
							                                        }
							                                        else
							                                        {
							                                            echo "<option>".$dataApi['ApiName']."</option>";
							                                        }
							                                    }
							                                echo "</select>";
							                            echo "</div>";
							                            echo "<div class='divHead4A1' id='apiOpCodeDiv".$sl."'>$ApiOpCode</div>";
							                            echo "<div class='divHead4A1'>";
							                                echo "<select id='Roffer".$sl."'>";
							                                    if($R_offer=="true")
							                                    {
							                                        echo "<option selected>true</option>";
							                                        echo "<option>false</option>";
							                                    }
							                                    else
							                                    {
							                                        echo "<option>true</option>";
							                                        echo "<option selected>false</option>";
							                                    }
							                                    
							                                echo "</select>";
							                            echo "</div>";
							                            echo "<div class='divHead4A1'>";
							                                echo "<select id='stv".$sl."'>";
							                                    if($STV=="true")
							                                    {
							                                        echo "<option selected>true</option>";
							                                        echo "<option>false</option>";
							                                    }
							                                    else
							                                    {
							                                        echo "<option>true</option>";
							                                        echo "<option selected>false</option>";
							                                    }
							                                echo "</select>";
							                            echo "</div>";
							                            echo "<div class='divHead4A1'>";
							                                echo "<select  id='circle".$sl."'>";
							                                    if($Circle=="true")
							                                    {
							                                        echo "<option selected>true</option>";
							                                        echo "<option>false</option>";
							                                    }
							                                    else
							                                    {
							                                        echo "<option>true</option>";
							                                        echo "<option selected>false</option>";
							                                    }
							                                echo "</select>";
							                            echo "</div>";
							                            echo "<div class='divHead4A1'>";
							                                echo "<p id='pAlwAmt".$sl."' ondblclick='showInpAlwAmt($sl)'>$AlwAmt</p>";
							                                echo "<input type='text' class='inpApiOp' style='display:none;' id='inpAlwAmt".$sl."' Value='".$AlwAmt."'>";
							                            echo "</div>";
							                            echo "<div class='divHead4A1'>";
							                                echo "<p id='pBlkAmt".$sl."' ondblclick='showInpBlkAmt($sl)'>$BlkAmt</p>";
							                                echo "<input type='text' class='inpApiOp' style='display:none;' id='inpBlkAmt".$sl."' Value='".$BlkAmt."'>";
							                            echo "</div>";
							                            echo "<div class='divHead4A1'>";
							                                echo "<p id='pGroup".$sl."' ondblclick='showInpGroup($sl)'>$LapuGroup</p>";
							                                echo "<input type='number' class='inpApiOp' style='display:none;' id='inpGroup".$sl."' Value='".$LapuGroup."'>";
							                            echo "</div>";
							                            echo "<div class='divHead4A1'>";
							                                echo "<p id='pReqRoffer".$sl."' ondblclick='showInpReqRoffer($sl)'>$ReqRoffer</p>";
							                                echo "<input type='number' class='inpApiOp' style='display:none;' id='inpReqRoffer".$sl."' Value='".$ReqRoffer."'>";
							                            echo "</div>";
							                            echo "<div class='divHead4A1 divWidth2'>";
							                                echo "<div class='divHead4A2'>";
	    		            				                    if($apiStatus=="ACTIVE")
		    				            				        {
			    						            	           echo "<i class='fa fa-check' style='color:lime;' onclick='updateSetApiStatus(".$sl.")'></i>";
				    						                    }
	            				    					        else
				            		    				        {
							                			           echo "<i class='fa fa-ban' style='color:red;' onclick='updateOpStatus(".$sl.")'></i>";
								    	            	        }
								    	            	    echo "</div>";
							                                echo "<div class='divHead4A2'><button class='inpBtn' type='button' onclick='updateApi($sl)'>Update</button></div>";
							                                echo "<div class='divHead4A2'><button class='inpBtn' type='button' onclick='addApi($sl)'>New+</button></div>";
							                                if($sl2>1)
							                                {
							                                    echo "<div class='divHead4A2'><i class='fa fa-close' style='color:red; font-size:25px;' onclick='deleteApi($sl)'></i></div>";
							                                }
							                            echo "</div>";
													echo "</div>";
							                    }
							                echo "</div>";
							                            
													echo "</div>";
							                    }
							                echo "</div>";
						                echo "</div>";
							         echo "</div>";
					             }
							     echo "</div>";
						      echo "</div>";
						?>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div id="alertDiv">
	</div>
	<script>
	    function updateApi(Arg)
	    {
	        var AjaxName     = "Ajax1";
	        var setApiId     = document.getElementById("setApiId"+Arg).value;
	        var myOpCode     = document.getElementById("myOpCode"+Arg).value;
	        var apiName      = document.getElementById("apiName"+Arg).value;
	        var Roffer       = document.getElementById("Roffer"+Arg).value;
	        var stv          = document.getElementById("stv"+Arg).value;
	        var circle       = document.getElementById("circle"+Arg).value;
	        var AlwAmt       = document.getElementById("inpAlwAmt"+Arg).value;
	        var BlkAmt       = document.getElementById("inpBlkAmt"+Arg).value;
	        var inpGroup     = document.getElementById("inpGroup"+Arg).value;
	        var inpReqRoffer = document.getElementById("inpReqRoffer"+Arg).value;
	        var xmlhttpSponser = new XMLHttpRequest();
			xmlhttpSponser.open("GET","Ajax.php?AjaxName="+AjaxName+"&setApiId="+setApiId+"&myOpCode="+myOpCode+"&apiName="+apiName+"&Roffer="+Roffer+"&stv="+stv+"&circle="+circle+"&AlwAmt="+AlwAmt+"&BlkAmt="+BlkAmt+"&inpGroup="+inpGroup+"&inpReqRoffer="+inpReqRoffer, false)
			xmlhttpSponser.send(null);
			alert(xmlhttpSponser.responseText);
	    }
	    
	    function addApi(Arg)
	    {
	        var AjaxName     = "Ajax2";
	        var apiUsrId     = document.getElementById("apiUsrId"+Arg).value;
	        var setApiId     = document.getElementById("setApiId"+Arg).value;
	        var myOpCode     = document.getElementById("myOpCode"+Arg).value;
	        var apiName      = document.getElementById("apiName"+Arg).value;
	        var Roffer       = document.getElementById("Roffer"+Arg).value;
	        var stv          = document.getElementById("stv"+Arg).value;
	        var circle       = document.getElementById("circle"+Arg).value;
	        var AlwAmt       = document.getElementById("inpAlwAmt"+Arg).value;
	        var BlkAmt       = document.getElementById("inpBlkAmt"+Arg).value;
	        var inpGroup     = document.getElementById("inpGroup"+Arg).value;
	        var inpReqRoffer = document.getElementById("inpReqRoffer"+Arg).value;
	        
	        var xmlhttpSponser = new XMLHttpRequest();
			xmlhttpSponser.open("GET","Ajax.php?AjaxName="+AjaxName+"&apiUsrId="+apiUsrId+"&setApiId="+setApiId+"&myOpCode="+myOpCode+"&apiName="+apiName+"&Roffer="+Roffer+"&stv="+stv+"&circle="+circle+"&AlwAmt="+AlwAmt+"&BlkAmt="+BlkAmt+"&inpGroup="+inpGroup+"&inpReqRoffer="+inpReqRoffer, false)
			xmlhttpSponser.send(null);
			alert(xmlhttpSponser.responseText);
	    }
	    
	    function deleteApi(Arg)
	    {
	        var AjaxName     = "Ajax4";
	        var setApiId     = document.getElementById("setApiId"+Arg).value;
	        var confrim_rslt = confirm("Are You Sure To Delete This Set Api ?");
			            
			if(confrim_rslt==true)
			{
	            var xmlhttpSponser = new XMLHttpRequest();
		    	xmlhttpSponser.open("GET","Ajax.php?AjaxName="+AjaxName+"&setApiId="+setApiId, false)
			    xmlhttpSponser.send(null);
			    var respoMsg = xmlhttpSponser.responseText;
			    alert(respoMsg);
	    		if(respoMsg=="Api Deleted Successfully !")
		    	{
			        document.getElementById("setApiRowDiv"+Arg).style.display = "none";
			    }
			}
			
	    }
	    
	    function showInpAlwAmt(Arg)
	    {
	        var sl    = Arg;
	        document.getElementById("pAlwAmt"+sl).style.display = "none";
	        document.getElementById("inpAlwAmt"+sl).style.display = "block";
	    }
	    function showInpBlkAmt(Arg)
	    {
	        var sl    = Arg;
	        document.getElementById("pBlkAmt"+sl).style.display = "none";
	        document.getElementById("inpBlkAmt"+sl).style.display = "block";
	    }
	    function showInpGroup(Arg)
	    {
	        var sl    = Arg;
	        document.getElementById("pGroup"+sl).style.display = "none";
	        document.getElementById("inpGroup"+sl).style.display = "block";
	    }
	    function showInpReqRoffer(Arg)
	    {
	        var sl    = Arg;
	        document.getElementById("pReqRoffer"+sl).style.display = "none";
	        document.getElementById("inpReqRoffer"+sl).style.display = "block";
	    }
	    function showInput(Arg)
	    {
	        var sl    = Arg;
	        document.getElementById("pOpCode"+sl).style.display = "none";
	        document.getElementById("inpOpCode"+sl).style.display = "block";
	    }
	    
	    function editOpComm(Arg)
	    {
	        var AjaxName     = "Ajax5";
	        var opComm       = document.getElementById("inpOpCode"+Arg).value;
	        var opusr        = document.getElementById("opusr"+Arg).value;
	        var opcode       = document.getElementById("opcode"+Arg).value;
			var xmlhttpAjax  = new XMLHttpRequest();
			xmlhttpAjax.open("GET","Ajax.php?AjaxName="+AjaxName+"&opComm="+opComm+"&opusr="+opusr+"&opcode="+opcode, false)
			xmlhttpAjax.send(null);
		    var respoMsg = xmlhttpAjax.responseText;
		    alert(respoMsg);
		    if(respoMsg=="Commission Updated Successfully !")
		    {
	            document.getElementById("pOpCode"+Arg).innerHTML = opComm;
		    }
	        document.getElementById("pOpCode"+Arg).style.display = "block";
	        document.getElementById("inpOpCode"+Arg).style.display = "none";
	    }
	    
	    function showOpDiv(Arg)
	    {
	        var sl    = Arg;
	                document.getElementById("divOP"+sl).style.display = "block";
	                document.getElementById("iconPlus"+sl).style.display = "none";
	                document.getElementById("iconMinus"+sl).style.display = "block";
	    }
	    function hideOpDiv(Arg)
	    {
	        var sl    = Arg;
	        document.getElementById("divOP"+sl).style.display = "none";
	        document.getElementById("iconPlus"+sl).style.display = "block";
	        document.getElementById("iconMinus"+sl).style.display = "none";
	    }
	    
	    function showApiDiv(Arg)
	    {
	        var sl    = Arg;
	        document.getElementById("divApi"+sl).style.display = "block";
	        document.getElementById("iconApiPlus"+sl).style.display = "none";
	        document.getElementById("iconApiMinus"+sl).style.display = "block";
	    }
	    
	    function hideApiDiv(Arg)
	    {
	        var sl    = Arg;
	        document.getElementById("divApi"+sl).style.display = "none";
	        document.getElementById("iconApiPlus"+sl).style.display = "block";
	        document.getElementById("iconApiMinus"+sl).style.display = "none";
	    }
	</script>
	<?php
		require'footer.php';
	?>
</body>
</html>