<?php $action=$_REQUEST['action'];?>




<Script language="javascript">



function checkKeyCode(evt)



{







var evt = (evt) ? evt : ((event) ? event : null);



var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);



if(event.keyCode==116)



{



evt.keyCode=0;



return false



}



}



document.onkeydown=checkKeyCode;



</script>




<script language="javascript">







function formcheck()



{







if(document.myform.member_id.value=="")















			{















				alert("Please Enter Associate ID!");















				document.myform.member_id.focus()















				return false;















			}



if(document.myform.bill_type.value=="")















			{















				alert("Please Select Bill Type!");















				document.myform.bill_type.focus()















				return false;















			}















			



		







			















		return true;







	



			















}











</script>



<script language="javascript">















function duplicate_domain_check(member_id)















{ 















xmlHttp=GetXmlHttpObject()















if (xmlHttp==null)















 {















 alert ("Browser does not support HTTP Request")















 return















 }































 	















		var url="record.php";















		url=url+"?member_id="+member_id















		url=url+"&sid="+Math.random()















		xmlHttp.onreadystatechange=stateChanged_answer 















		xmlHttp.open("GET",url,true)















		xmlHttp.send(null)















		















}































function stateChanged_answer() 















{ 















  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")















  { 















  















	document.getElementById("msg").innerHTML='<font size=1>'+xmlHttp.responseText+'</font>';















  }















  else















  {















       document.getElementById("msg").innerHTML="<img src='images/loadingAnimation.gif' border=0  height=5 width=20 >";















  }















}























































































function GetXmlHttpObject()















{















var xmlHttp=null;















try















 {















 // Firefox, Opera 8.0+, Safari















 xmlHttp=new XMLHttpRequest();















 }















catch (e)















 {















 //Internet Explorer















 try















  {















  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");















  }















 catch (e)















  {















  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");















  }















 }















return xmlHttp;















}















function test()















{















alert('as');















}















</script>






<?php







							$stock_id=$_SESSION['admin_id']; 



							







					







							?>

</nav>

                </div>

                <!--  END TOPBAR  -->



            </ul>









            <ul class="navbar-item flex-row ml-auto">

                <li class="nav-item align-self-center search-animated">

                    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search toggle-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>

                    <form class="form-inline search-full form-inline search" role="search">

                        <div class="search-bar">

                            <input type="text" class="form-control search-form-control  ml-lg-auto" placeholder="Search...">

                        </div>

                    </form>

                </li>

            </ul>



            <ul class="navbar-item flex-row nav-dropdowns">

               



               



                <li class="nav-item dropdown notification-dropdown">

                    <a href="javascript:void(0);" class="nav-link dropdown-toggle" id="notificationDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">

                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-bell"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path><path d="M13.73 21a2 2 0 0 1-3.46 0"></path></svg><span class="badge badge-success"></span>

                    </a>

                    <div class="dropdown-menu position-absolute" aria-labelledby="notificationDropdown">

                        <div class="notification-scroll">

						  <?

		   





							 $query_not = $mysqli->prepare("select heading, content from notice_shop");



													$query_not->execute();



													$query_not->bind_result($heading, $content);

		   

		   ?>

		   <?

		                                 while ($query_not->fetch()){

		                                  ?>



                            <div class="dropdown-item">

                                <div class="media server-log">

                                    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-server"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect><rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect><line x1="6" y1="6" x2="6" y2="6"></line><line x1="6" y1="18" x2="6" y2="18"></line></svg>

                                    <div class="media-body">

                                        <div class="data-info">

                                            <h6 class=""><? echo $heading;?></h6>

                                            <p class=""><? echo $content;?></p>

                                        </div>



                                        <div class="icon-status">

                                            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>

                                        </div>

                                    </div>

                                </div>

                            </div>

							<? } ?>



                            



                            

                        </div>

                    </div>

                </li>

				

											

                <li class="nav-item dropdown user-profile-dropdown order-lg-0 order-1">

                    <a href="javascript:void(0);" class="nav-link dropdown-toggle user" id="user-profile-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">

                        <div class="media">

                            <img src="assets/img/90x90.jpg" class="img-fluid" alt="admin-profile">

                        </div>

                    </a>

                    <div class="dropdown-menu position-absolute" aria-labelledby="userProfileDropdown">

                        <div class="user-profile-section">

                            <div class="media mx-auto">

                                <div class="media-body">

                                    <h5>Name : <? echo $name;?></h5>

                                   
                                </div>

                            </div>

                        </div>

                        <div class="dropdown-item">

                            <a href="update_profile.php">

                                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-user"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg> <span>Profile</span>

                            </a>

                        </div>

                       

                        <div class="dropdown-item">

                            <a href="logout.php">

                                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-log-out"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"></path><polyline points="16 17 21 12 16 7"></polyline><line x1="21" y1="12" x2="9" y2="12"></line></svg> <span>Log Out</span>

                            </a>

                        </div>

                    </div>



                </li>

            </ul>

        </header>

    </div>

    <!--  END NAVBAR  -->



    <!--  BEGIN MAIN CONTAINER  -->

    <div class="main-container" id="container">



        <div class="overlay"></div>

        <div class="search-overlay"></div>

        

        <!--  BEGIN CONTENT PART  -->

        <div id="content" class="main-content">

            <div class="layout-px-spacing">



                <div class="page-header">

                    <div class="page-title">

                        <h3><? echo $name;?></h3>

                    </div>

                    

                    <div class="toggle-switch">

                        <label class="switch s-icons s-outline  s-outline-secondary">

                            <input type="checkbox" checked="" class="theme-shifter">

                            <span class="slider round">

                                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-sun"><circle cx="12" cy="12" r="5"></circle><line x1="12" y1="1" x2="12" y2="3"></line><line x1="12" y1="21" x2="12" y2="23"></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line><line x1="1" y1="12" x2="3" y2="12"></line><line x1="21" y1="12" x2="23" y2="12"></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line></svg>



                                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-moon"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path></svg>

                            </span>

                        </label>

                    </div>

                </div>



                <div class="row layout-top-spacing">



          

     <div id="basic" class="col-lg-12 col-sm-12 col-12 layout-spacing">

                            <div class="statbox widget box box-shadow">

                                <div class="widget-header">                                

                                    <div class="row">

                                        <div class="col-xl-12 col-md-12 col-sm-12 col-12">

                                            <h4>Activation </h4>

                                        </div>

                                    </div>

                                </div>

								<?php







						  if($_SESSION['msg_box2']!="")







						  {?>

                                <div class="alert alert-light-success border-0 mb-4" role="alert"> <font color="#FF3300"><? echo $_SESSION['msg_box2'];?> </font></div>

								<?	} 







						 unset($_SESSION['msg_box2']);











						?>

						<?

						

								



								  ?>

								  <? if($action==""){?>
 <form action="first_sale.php?action=before_process" method="post" name="myform" enctype="multipart/form-data" onSubmit="return formcheck();">
                      <table class="table table-bordered mb-4">





										<tr>















<td align="left" colspan="2"><b>Enter Member ID.</b>&nbsp;<input type="text" id="member_id" name="member_id" onblur=duplicate_domain_check(this.value)  /> &nbsp;<span class=red id=msg></span></td>























</tr>







<?







$stock_id=$_SESSION['admin_id'];







$z=0;







$crr=0;







  $query = $mysqli->prepare("select prod_id,current_stock from stock_record where stock_id=? and current_stock>?");







$query->bind_param('ss', $stock_id,$crr);







$query->execute();







$query->bind_result($prod_id,$current_stock);







while($query->fetch())







{







$z++;















$prd[$z]=$prod_id;



$crt_stk[$z]=$current_stock;











} 







































?>







<tr>















<td align="left" colspan="2"><b>Product 1.</b>&nbsp;<select name="item1">







															<option value="">Please Select</option>







								<?	     for($kk=1;$kk<=$z;$kk++)































                                       {















									$prod_id=$prd[$kk];







									$current_stock=$crt_stk[$kk];















$query_prd = $mysqli->prepare("select name,batch_no,expiry_date,mrp from product_resale where id=?");







$query_prd->bind_param('s', $prod_id);







$query_prd->execute();







$query_prd->bind_result($pname,$batch_no,$expiry_date,$mrp);







while($query_prd->fetch())







{







$pname=$pname;



$batch_no=$batch_no;



$expiry_date=$expiry_date;



$mrp=$mrp;



}







?>















															<option value="<? echo $prod_id;?>"><? echo $pname;?> Batch No : <? echo $batch_no;?> Expiry : <? echo $expiry_date;?> MRP : <? echo $mrp;?> Stock : <? echo $current_stock;?></option>







															<? } ?>







													</select>		















													Quantity<input type="text" name="qty1" value="0" size="10"><input type="hidden" name="dis1" value="0" size="10"></td>























</tr>







<?







$stock_id=$_SESSION['admin_id'];







$z=0;







$crr=0;







  $query2 = $mysqli->prepare("select prod_id,current_stock from stock_record where stock_id=? and current_stock>?");







$query2->bind_param('ss', $stock_id,$crr);







$query2->execute();







$query2->bind_result($prod_id,$current_stock);







while($query2->fetch())







{







$z++;















$prd[$z]=$prod_id;



$crt_stk[$z]=$current_stock;



















} 







































?>







<tr>















<td align="left" colspan="2"><b>Product 2.</b>&nbsp;<select name="item2">







															<option value="">Please Select</option>







																				<?	     for($kk=1;$kk<=$z;$kk++)































                                       {















									$prod_id=$prd[$kk];







									$current_stock=$crt_stk[$kk];







$query_prd = $mysqli->prepare("select name,batch_no,expiry_date,mrp from product_resale where id=?");







$query_prd->bind_param('s', $prod_id);







$query_prd->execute();







$query_prd->bind_result($pname,$batch_no,$expiry_date,$mrp);







while($query_prd->fetch())







{







$pname=$pname;



$batch_no=$batch_no;



$expiry_date=$expiry_date;



$mrp=$mrp;



}







?>







															<option value="<? echo $prod_id;?>"><? echo $pname;?> Batch No : <? echo $batch_no;?> Expiry : <? echo $expiry_date;?> MRP : <? echo $mrp;?> Stock : <? echo $current_stock;?></option>







															<? } ?>







													</select>Quantity<input type="text" name="qty2" value="0" size="10"><input type="hidden" name="dis2" value="0" size="10"></td>























</tr>







<?







$stock_id=$_SESSION['admin_id'];







$z=0;







$crr=0;







  $query3 = $mysqli->prepare("select prod_id,current_stock from stock_record where stock_id=? and current_stock>?");







$query3->bind_param('ss', $stock_id,$crr);







$query3->execute();







$query3->bind_result($prod_id,$current_stock);







while($query3->fetch())







{







$z++;















$prd[$z]=$prod_id;







$crt_stk[$z]=$current_stock;







} 







































?>







<tr>















<td align="left" colspan="2"><b>Product 3.</b>&nbsp;<select name="item3">







															<option value="">Please Select</option>







															<?	     for($kk=1;$kk<=$z;$kk++)































                                       {















									$prod_id=$prd[$kk];







									







$current_stock=$crt_stk[$kk];







$query_prd = $mysqli->prepare("select name,batch_no,expiry_date,mrp from product_resale where id=?");







$query_prd->bind_param('s', $prod_id);







$query_prd->execute();







$query_prd->bind_result($pname,$batch_no,$expiry_date,$mrp);







while($query_prd->fetch())







{







$pname=$pname;



$batch_no=$batch_no;



$expiry_date=$expiry_date;



$mrp=$mrp;



}







?>







															<option value="<? echo $prod_id;?>"><? echo $pname;?> Batch No : <? echo $batch_no;?> Expiry : <? echo $expiry_date;?> MRP : <? echo $mrp;?> Stock : <? echo $current_stock;?></option>







															<? } ?>







													</select>Quantity<input type="text" name="qty3" value="0" size="10"><input type="hidden" name="dis3" value="0" size="10"></td>























</tr>







<?







$stock_id=$_SESSION['admin_id'];







$z=0;







$crr=0;







  $query4 = $mysqli->prepare("select prod_id,current_stock from stock_record where stock_id=? and current_stock>?");







$query4->bind_param('ss', $stock_id,$crr);







$query4->execute();







$query4->bind_result($prod_id,$current_stock);







while($query4->fetch())







{







$z++;















$prd[$z]=$prod_id;



$crt_stk[$z]=$current_stock;











} 







































?>







<tr>















<td align="left" colspan="2"><b>Product 4.</b>&nbsp;<select name="item4">







															<option value="">Please Select</option>







															<?	     for($kk=1;$kk<=$z;$kk++)































                                       {















									$prod_id=$prd[$kk];







									







$current_stock=$crt_stk[$kk];







$query_prd = $mysqli->prepare("select name,batch_no,expiry_date,mrp from product_resale where id=?");







$query_prd->bind_param('s', $prod_id);







$query_prd->execute();







$query_prd->bind_result($pname,$batch_no,$expiry_date,$mrp);







while($query_prd->fetch())







{







$pname=$pname;



$batch_no=$batch_no;



$expiry_date=$expiry_date;



$mrp=$mrp;



}







?>







															<option value="<? echo $prod_id;?>"><? echo $pname;?> Batch No : <? echo $batch_no;?> Expiry : <? echo $expiry_date;?> MRP : <? echo $mrp;?> Stock : <? echo $current_stock;?></option>







															<? } ?>







													</select>Quantity<input type="text" name="qty4" value="0" size="10"><input type="hidden" name="dis4" value="0" size="10"></td>























</tr>







<?







$stock_id=$_SESSION['admin_id'];







$z=0;







$crr=0;







  $query5 = $mysqli->prepare("select prod_id,current_stock from stock_record where stock_id=? and current_stock>?");







$query5->bind_param('ss', $stock_id,$crr);







$query5->execute();







$query5->bind_result($prod_id,$current_stock);







while($query5->fetch())







{







$z++;















$prd[$z]=$prod_id;



$crt_stk[$z]=$current_stock;











} 







































?>







<tr>















<td align="left" colspan="2"><b>Product 5.</b>&nbsp;<select name="item5">







															<option value="">Please Select</option>







															<?	     for($kk=1;$kk<=$z;$kk++)































                                       {















									$prod_id=$prd[$kk];







									







$current_stock=$crt_stk[$kk];







$query_prd = $mysqli->prepare("select name,batch_no,expiry_date,mrp from product_resale where id=?");







$query_prd->bind_param('s', $prod_id);







$query_prd->execute();







$query_prd->bind_result($pname,$batch_no,$expiry_date,$mrp);







while($query_prd->fetch())







{







$pname=$pname;



$batch_no=$batch_no;



$expiry_date=$expiry_date;



$mrp=$mrp;



}







?>







															<option value="<? echo $prod_id;?>"><? echo $pname;?> Batch No : <? echo $batch_no;?> Expiry : <? echo $expiry_date;?> MRP : <? echo $mrp;?> Stock : <? echo $current_stock;?></option>







															<? } ?>







													</select>Quantity<input type="text" name="qty5" value="0" size="10"><input type="hidden" name="dis5" value="0" size="10"></td>























</tr>







<?







$stock_id=$_SESSION['admin_id'];







$z=0;







$crr=0;







  $query6 = $mysqli->prepare("select prod_id,current_stock from stock_record where stock_id=? and current_stock>?");







$query6->bind_param('ss', $stock_id,$crr);







$query6->execute();







$query6->bind_result($prod_id,$current_stock);







while($query6->fetch())







{







$z++;















$prd[$z]=$prod_id;



$crt_stk[$z]=$current_stock;











} 







































?>







<tr>















<td align="left" colspan="2"><b>Product 6.</b>&nbsp;<select name="item6">







															<option value="">Please Select</option>







															<?	     for($kk=1;$kk<=$z;$kk++)































                                       {















									$prod_id=$prd[$kk];







									







$current_stock=$crt_stk[$kk];







$query_prd = $mysqli->prepare("select name,batch_no,expiry_date,mrp from product_resale where id=?");







$query_prd->bind_param('s', $prod_id);







$query_prd->execute();







$query_prd->bind_result($pname,$batch_no,$expiry_date,$mrp);







while($query_prd->fetch())







{







$pname=$pname;



$batch_no=$batch_no;



$expiry_date=$expiry_date;



$mrp=$mrp;



}







?>







															<option value="<? echo $prod_id;?>"><? echo $pname;?> Batch No : <? echo $batch_no;?> Expiry : <? echo $expiry_date;?> MRP : <? echo $mrp;?> Stock : <? echo $current_stock;?></option>







															<? } ?>







													</select>Quantity<input type="text" name="qty6" value="0" size="10"><input type="hidden" name="dis6" value="0" size="10"></td>























</tr>







<?







$stock_id=$_SESSION['admin_id'];







$z=0;







$crr=0;







  $query7 = $mysqli->prepare("select prod_id,current_stock from stock_record where stock_id=? and current_stock>?");







$query7->bind_param('ss', $stock_id,$crr);







$query7->execute();







$query7->bind_result($prod_id,$current_stock);







while($query7->fetch())







{







$z++;















$prd[$z]=$prod_id;



$crt_stk[$z]=$current_stock;











} 







































?>







<tr>















<td align="left" colspan="2"><b>Product 7.</b>&nbsp;<select name="item7">







															<option value="">Please Select</option>







															<?	     for($kk=1;$kk<=$z;$kk++)































                                       {















									$prod_id=$prd[$kk];







									







$current_stock=$crt_stk[$kk];







$query_prd = $mysqli->prepare("select name,batch_no,expiry_date,mrp from product_resale where id=?");







$query_prd->bind_param('s', $prod_id);







$query_prd->execute();







$query_prd->bind_result($pname,$batch_no,$expiry_date,$mrp);







while($query_prd->fetch())







{







$pname=$pname;



$batch_no=$batch_no;



$expiry_date=$expiry_date;



$mrp=$mrp;



}







?>







															<option value="<? echo $prod_id;?>"><? echo $pname;?> Batch No : <? echo $batch_no;?> Expiry : <? echo $expiry_date;?> MRP : <? echo $mrp;?> Stock : <? echo $current_stock;?></option>







															<? } ?>







													</select>Quantity<input type="text" name="qty7" value="0" size="10"><input type="hidden" name="dis7" value="0" size="10"></td>























</tr>







<?







$stock_id=$_SESSION['admin_id'];







$z=0;







$crr=0;







  $query8 = $mysqli->prepare("select prod_id,current_stock from stock_record where stock_id=? and current_stock>?");







$query8->bind_param('ss', $stock_id,$crr);







$query8->execute();







$query8->bind_result($prod_id,$current_stock);







while($query8->fetch())







{







$z++;















$prd[$z]=$prod_id;



$crt_stk[$z]=$current_stock;











} 







































?>







<tr>















<td align="left" colspan="2"><b>Product 8.</b>&nbsp;<select name="item8">







															<option value="">Please Select</option>







															<?	     for($kk=1;$kk<=$z;$kk++)































                                       {















									$prod_id=$prd[$kk];







									







$current_stock=$crt_stk[$kk];







$query_prd = $mysqli->prepare("select name,batch_no,expiry_date,mrp from product_resale where id=?");







$query_prd->bind_param('s', $prod_id);







$query_prd->execute();







$query_prd->bind_result($pname,$batch_no,$expiry_date,$mrp);







while($query_prd->fetch())







{







$pname=$pname;



$batch_no=$batch_no;



$expiry_date=$expiry_date;



$mrp=$mrp;



}







?>







															<option value="<? echo $prod_id;?>"><? echo $pname;?> Batch No : <? echo $batch_no;?> Expiry : <? echo $expiry_date;?> MRP : <? echo $mrp;?> Stock : <? echo $current_stock;?></option>







															<? } ?>







													</select>Quantity<input type="text" name="qty8" value="0" size="10"><input type="hidden" name="dis8" value="0" size="10"></td>























</tr>







<?







$stock_id=$_SESSION['admin_id'];







$z=0;







$crr=0;







  $query9 = $mysqli->prepare("select prod_id,current_stock from stock_record where stock_id=? and current_stock>?");







$query9->bind_param('ss', $stock_id,$crr);







$query9->execute();







$query9->bind_result($prod_id,$current_stock);







while($query9->fetch())







{







$z++;















$prd[$z]=$prod_id;



$crt_stk[$z]=$current_stock;











} 







































?>







<tr>















<td align="left" colspan="2"><b>Product 9.</b>&nbsp;<select name="item9">







															<option value="">Please Select</option>







															<?	     for($kk=1;$kk<=$z;$kk++)































                                       {















									$prod_id=$prd[$kk];







									







$current_stock=$crt_stk[$kk];







$query_prd = $mysqli->prepare("select name,batch_no,expiry_date,mrp from product_resale where id=?");







$query_prd->bind_param('s', $prod_id);







$query_prd->execute();







$query_prd->bind_result($pname,$batch_no,$expiry_date,$mrp);







while($query_prd->fetch())







{







$pname=$pname;



$batch_no=$batch_no;



$expiry_date=$expiry_date;



$mrp=$mrp;



}







?>







															<option value="<? echo $prod_id;?>"><? echo $pname;?> Batch No : <? echo $batch_no;?> Expiry : <? echo $expiry_date;?> MRP : <? echo $mrp;?> Stock : <? echo $current_stock;?></option>







															<? } ?>







													</select>Quantity<input type="text" name="qty9" value="0" size="10"><input type="hidden" name="dis9" value="0" size="10"></td>























</tr>







<?







$stock_id=$_SESSION['admin_id'];







$z=0;







$crr=0;







  $query10 = $mysqli->prepare("select prod_id,current_stock from stock_record where stock_id=? and current_stock>?");







$query10->bind_param('ss', $stock_id,$crr);







$query10->execute();







$query10->bind_result($prod_id,$current_stock);







while($query10->fetch())







{







$z++;















$prd[$z]=$prod_id;







$crt_stk[$z]=$current_stock;







} 







































?>







<tr>















<td align="left" colspan="2"><b>Product 10.</b>&nbsp;<select name="item10">







															<option value="">Please Select</option>







															<?	     for($kk=1;$kk<=$z;$kk++)































                                       {















									$prod_id=$prd[$kk];








									







$current_stock=$crt_stk[$kk];







$query_prd = $mysqli->prepare("select name,batch_no,expiry_date,mrp from product_resale where id=?");







$query_prd->bind_param('s', $prod_id);







$query_prd->execute();







$query_prd->bind_result($pname,$batch_no,$expiry_date,$mrp);







while($query_prd->fetch())







{







$pname=$pname;



$batch_no=$batch_no;



$expiry_date=$expiry_date;



$mrp=$mrp;



}







?>







															<option value="<? echo $prod_id;?>"><? echo $pname;?> Batch No : <? echo $batch_no;?> Expiry : <? echo $expiry_date;?> MRP : <? echo $mrp;?> Stock : <? echo $current_stock;?></option>







															<? } ?>







													</select>Quantity<input type="text" name="qty10" value="0" size="10"><input type="hidden" name="dis10" value="0" size="10"></td>























</tr>























<tr>







	<td width="117" align="left"><b>Bill Type</b></td>







	<td width="447" align="left"><select name="bill_type">







															<option value="">Please Select</option>







														







															<option value="state">State</option>







															<option value="central">central</option>







														







													</select>







						







						







								 







	</td>







</tr>



<tr>



	<td align="left"><b>GST No</b></td>



	<td align="left"><input type="text" name="gst_no" id="gst_no">



	</td>



</tr>


<input type="hidden" name="discount" id="discount" value="0">







	







<tr>







	<td align="left"><b>Entry Date</b></td>







	<td align="left"><input type="text" name="ent_date" id="ent_date" value="<?php echo date("d-m-Y");?>" readonly>







						







						







								 







													(dd-mm-yyyy) 







	</td>







</tr>















<tr>







	







	<td align="right" colspan="2"><input type="submit" name="submit" value="Submit.."></td>







</tr>







</table>
						  

						</form>		


								<? } ?>

								

								<? if($action=="before_process"){ 



						

$member_id=$_REQUEST['member_id'];







$bill_type=$_REQUEST['bill_type'];







$delevery=$_REQUEST['delevery'];



$gst_no=$_REQUEST['gst_no'];











$qry_mem = $mysqli->prepare("select title,name from member where member_id=?");















				$qry_mem->bind_param('s', $member_id);								







                $qry_mem->execute();







                $qry_mem->bind_result($title,$mem_name);







				while ($qry_mem->fetch())







				{







				$title=$title;







				$mem_name=$mem_name;







				}















//$name=$_REQUEST['name'];







$ent_date=$_REQUEST['ent_date'];







$qty1=$_REQUEST['qty1'];







$qty2=$_REQUEST['qty2'];







$qty3=$_REQUEST['qty3'];







$qty4=$_REQUEST['qty4'];







$qty5=$_REQUEST['qty5'];







$qty6=$_REQUEST['qty6'];







$qty7=$_REQUEST['qty7'];







$qty8=$_REQUEST['qty8'];







$qty9=$_REQUEST['qty9'];







$qty10=$_REQUEST['qty10'];















$item1=$_REQUEST['item1'];







$item2=$_REQUEST['item2'];







$item3=$_REQUEST['item3'];







$item4=$_REQUEST['item4'];







$item5=$_REQUEST['item5'];







$item7=$_REQUEST['item7'];







$item8=$_REQUEST['item8'];







$item6=$_REQUEST['item6'];







$item9=$_REQUEST['item9'];







$item10=$_REQUEST['item10'];















$dis1=$_REQUEST['dis1'];







$dis2=$_REQUEST['dis2'];







$dis3=$_REQUEST['dis3'];







$dis4=$_REQUEST['dis4'];







$dis5=$_REQUEST['dis5'];







$dis6=$_REQUEST['dis6'];







$dis7=$_REQUEST['dis7'];







$dis8=$_REQUEST['dis8'];







$dis9=$_REQUEST['dis9'];







$dis10=$_REQUEST['dis10'];















$del1=$_REQUEST['del1'];







$del2=$_REQUEST['del2'];







$del3=$_REQUEST['del3'];







$del4=$_REQUEST['del4'];







$del5=$_REQUEST['del5'];







$del6=$_REQUEST['del6'];







$del7=$_REQUEST['del7'];







$del8=$_REQUEST['del8'];







$del9=$_REQUEST['del9'];







$del10=$_REQUEST['del10'];















$discount=$_REQUEST['discount'];















$out_stock=0;







$stock_id=$_SESSION['admin_id'];







if($item1!="")







{















$query_itm1 = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");















				$query_itm1->bind_param('ss', $stock_id,$item1);								







                $query_itm1->execute();







                $query_itm1->bind_result($current_stock1);







				while($query_itm1->fetch())







				{







				$current_stock1=$current_stock1;







				}















if($current_stock1<$qty1){  $out_stock=1;}







							 	







}















if($item2!="")







{























$query_itm2 = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");















				$query_itm2->bind_param('ss', $stock_id,$item2);								







                $query_itm2->execute();







                $query_itm2->bind_result($current_stock2);







				while($query_itm2->fetch())







				{







				$current_stock2=$current_stock2;







				}















if($current_stock2<$qty2){  $out_stock=1;}







							 	







}







if($item3!="")







{























$query_itm3 = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");















				$query_itm3->bind_param('ss', $stock_id,$item3);								







                $query_itm3->execute();







                $query_itm3->bind_result($current_stock3);







				while($query_itm3->fetch())







				{







				$current_stock3=$current_stock3;







				}















if($current_stock3<$qty3){  $out_stock=1;}







							 	







}







if($item4!="")







{























$query_itm4 = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");















				$query_itm4->bind_param('ss', $stock_id,$item4);								







                $query_itm4->execute();







                $query_itm4->bind_result($current_stock4);







				while($query_itm4->fetch())







				{







				$current_stock4=$current_stock4;







				}















if($current_stock4<$qty4){  $out_stock=1;}







							 	







}







if($item5!="")







{























$query_itm5 = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");















				$query_itm5->bind_param('ss', $stock_id,$item5);								







                $query_itm5->execute();







                $query_itm5->bind_result($current_stock5);







				while($query_itm5->fetch())







				{







				$current_stock5=$current_stock5;







				}















if($current_stock5<$qty5){  $out_stock=1;}







							 	







}







if($item6!="")







{























$query_itm6 = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");















				$query_itm6->bind_param('ss', $stock_id,$item6);								







                $query_itm6->execute();







                $query_itm6->bind_result($current_stock6);







				while($query_itm6->fetch())







				{







				$current_stock6=$current_stock6;







				}















if($current_stock6<$qty6){  $out_stock=1;}







							 	







}







if($item7!="")







{























$query_itm7 = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");















				$query_itm7->bind_param('ss', $stock_id,$item7);								







                $query_itm7->execute();







                $query_itm7->bind_result($current_stock7);







				while($query_itm7->fetch())







				{







				$current_stock7=$current_stock7;







				}















if($current_stock7<$qty7){  $out_stock=1;}







							 	







}







if($item8!="")







{























$query_itm8 = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");















				$query_itm8->bind_param('ss', $stock_id,$item8);								







                $query_itm8->execute();







                $query_itm8->bind_result($current_stock8);







				while($query_itm8->fetch())







				{







				$current_stock8=$current_stock8;







				}















if($current_stock8<$qty8){  $out_stock=1;}







							 	







}







if($item9!="")







{























$query_itm9 = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");















				$query_itm9->bind_param('ss', $stock_id,$item9);								







                $query_itm9->execute();







                $query_itm9->bind_result($current_stock9);







				while($query_itm9->fetch())







				{







				$current_stock9=$current_stock9;







				}















if($current_stock9<$qty9){  $out_stock=1;}







							 	







}







if($item10!="")







{























$query_itm10 = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");















				$query_itm10->bind_param('ss', $stock_id,$item10);								







                $query_itm10->execute();







                $query_itm10->bind_result($current_stock10);







				while($query_itm10->fetch())







				{







				$current_stock10=$current_stock10;







				}















if($current_stock10<$qty10){  $out_stock=1;}







							 	







}


						



						if($out_stock==1)







{







 $_SESSION['msg_box2']="Out Of Stock. Try Again.";







// $_SESSION['class_notification']="notification success png_bg";	







header("location:first_sale.php?tab_id=tab1&default=first_sale&member_id=$member_id");







}







else







{



$qq_spot = $mysqli->prepare('SELECT * FROM member where member_id=?');







  $qq_spot->bind_param('s', $member_id);







						$qq_spot->execute();







						$qq_spot->store_result();







						$no_spot=$qq_spot->num_rows;



if($no_spot==0)







{







 $_SESSION['msg_box2']="No Such Member ID Found. Try Again.";







// $_SESSION['class_notification']="notification success png_bg";	







header("location:first_sale.php?tab_id=tab1&default=first_sale&member_id=$member_id");







}







else







{











$query_sts = $mysqli->prepare("select active from member where member_id=?");















				$query_sts->bind_param('s', $member_id);								







                $query_sts->execute();







                $query_sts->bind_result($active);







				while($query_sts->fetch())







				{







				$active=$active;







				}



				



if($active=="y")







{







 $_SESSION['msg_box2']="This Member is Already Activated. Try Again.";







// $_SESSION['class_notification']="notification success png_bg";	







header("location:first_sale.php?tab_id=tab1&default=first_sale&member_id=$member_id");







}







else







{







?>







<form action="first_sale.php?action=add_process" method="post" name="myform4" enctype="multipart/form-data">







<table class="table table-striped table-bordered zero-configuration" >







<tr>







	<td bgcolor="#0099FF" align="left" colspan="8"><b>  Bill Details </b></td>
</tr>







<tr>







<td colspan="6"><b>Distributor Name</b></td>







<td colspan="6"><b><? echo $mem_name;?>  </b></td>
</tr>







<tr>







<td colspan="6"><b>Date </b></td>







<td colspan="6"><b><? echo $ent_date;?> </b></td>
</tr>







<tr>







<td><b>Description Of Goods</b></td>







<td><b>HSN Code</b></td>







<td><b>QTY</b></td>



<td><b>Batch No</b></td>



<td><b>UOM</b></td>







<td><b>Rate</b></td>







<td><b>Gross Value</b></td>







<td><b>MRP</b></td>







<td><b>Discount</b></td>







<td><b>Taxable Value</b></td>







<td><table border="1"><tr><td colspan="2"><b>CGST</b></td></tr><tr><td><b>Rate</b></td><td><b>Amount</b></td></tr></table></td>







<td><table border="1"><tr><td colspan="2"><b>SGST</b></td></tr><tr><td><b>Rate</b></td><td><b>Amount</b></td></tr></table></td>







<td><table border="1"><tr><td colspan="2"><b>IGST</b></td></tr><tr><td><b>Rate</b></td><td><b>Amount</b></td></tr></table></td>
</tr>







<? if($item1!=""){















$qry = $mysqli->prepare("select code,name,rate,pv,cgst,sgst,igst,uom,batch_no,mrp,bv from product_resale where id=?");
$qry->bind_param('s', $item1);								
   $qry->execute();
$qry->bind_result($code,$prod_name,$rate,$pv,$cgst,$sgst,$igst,$uom,$batch_no,$mrp,$cc);

				while ($qry->fetch())







				{







				$code=$code;



 $batch_no=$batch_no;$mrp=$mrp;



				$prod_name=$prod_name;







				$rate=$rate;







				$pv=$pv;







				$cgst=$cgst;







				$sgst=$sgst;







				$igst=$igst;







				$uom=$uom;


$cc=$cc;




				}















$diss1=$rate*$dis1;







?>







<tr>







<td><? echo $prod_name;?></td>







<td><? echo $code;?></td>







<td><? echo $qty1;?></td>



<td><? echo $batch_no;?></td>



<td><? echo $uom;?></td>







<?







$g_val1=$rate*$qty1;















$taxable_val=$g_val1+$del1-$diss1;







$cgst_val=$taxable_val*$cgst/100;







$igst_val=$taxable_val*$igst/100;







$sgst_val=$taxable_val*$sgst/100;







$gs_val1=$g_val1+$del1-$diss1;







?>







<td><? echo $rate;?></td>















<td><? echo $g_val1;?></td>







<td><? echo $mrp;?></td>







<td><? echo $diss1;?></td>







<td><? echo $taxable_val;?></td>







<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $cgst;  } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $cgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $sgst; } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $sgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="central"){echo $igst; } ?></td>







  <td width="50"><? if($bill_type=="central"){echo $igst_val; } ?></td>
  </tr></table></td>















<? if($bill_type=="central"){ $tax_rebate1=$igst_val; } ?>







<? if($bill_type=="state"){ $tax_rebate1=$cgst_val+$sgst_val; } ?>







<? 















 $total1=$taxable_val+$tax_rebate1;?>
</tr>







<?







if($bill_type=="state"){$cgs1=$cgst_val;$sgs1=$sgst_val;$igs1=0;}







if($bill_type=="central"){$cgs1=0;$sgs1=0;$igs1=$igst_val;}







$dis_pv1=$pv*$dis1;







$pv1=$pv*$qty1;

$cc1=$cc*$qty1;





?>







<? } ?>







<? if($item2!=""){























$qry = $mysqli->prepare("select code,name,rate,pv,cgst,sgst,igst,uom,batch_no,mrp,bv from product_resale where id=?");



				$qry->bind_param('s', $item2);								







                $qry->execute();







                $qry->bind_result($code,$prod_name,$rate,$pv,$cgst,$sgst,$igst,$uom,$batch_no,$mrp,$cc);







				while ($qry->fetch())







				{







				$code=$code;



 $batch_no=$batch_no;$mrp=$mrp;



				$prod_name=$prod_name;







				$rate=$rate;







				$pv=$pv;







				$cgst=$cgst;







				$sgst=$sgst;







				$igst=$igst;







				$uom=$uom;


$cc=$cc;




				}























$diss2=$rate*$dis2;







?>







<tr>







<td><? echo $prod_name;?></td>







<td><? echo $code;?></td>







<td><? echo $qty2;?></td>



<td><? echo $batch_no;?></td>



<td><? echo $uom;?></td>







<?







$g_val2=$rate*$qty2;















$taxable_val=$g_val2+$del2-$diss2;







$cgst_val=$taxable_val*$cgst/100;







$igst_val=$taxable_val*$igst/100;







$sgst_val=$taxable_val*$sgst/100;







$gs_val2=$g_val2+$del2-$diss2;







?>







<td><? echo $rate;?></td>















<td><? echo $g_val2;?></td>







<td><? echo $mrp;?></td>







<td><? echo $diss2;?></td>







<td><? echo $taxable_val;?></td>







<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $cgst; } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $cgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $sgst; } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $sgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="central"){echo $igst; } ?></td>







  <td width="50"><? if($bill_type=="central"){echo $igst_val; } ?></td>
  </tr></table></td>















<? if($bill_type=="central"){ $tax_rebate2=$igst_val; } ?>







<? if($bill_type=="state"){ $tax_rebate2=$cgst_val+$sgst_val; } ?>







<? 







if($bill_type=="state"){$cgs2=$cgst_val;$sgs2=$sgst_val;$igs2=0;}







if($bill_type=="central"){$cgs2=0;$sgs2=0;$igs2=$igst_val;}







 $total2=$taxable_val+$tax_rebate2;?>
</tr>







<?







$dis_pv2=$pv*$dis2;







$pv2=$pv*$qty2;

$cc2=$cc*$qty2;





?>







<? } ?>







<? if($item3!=""){















$qry = $mysqli->prepare("select code,name,rate,pv,cgst,sgst,igst,uom,batch_no,mrp,bv from product_resale where id=?");















				$qry->bind_param('s', $item3);								







                $qry->execute();







                $qry->bind_result($code,$prod_name,$rate,$pv,$cgst,$sgst,$igst,$uom,$batch_no,$mrp,$cc);







				while ($qry->fetch())







				{







				$code=$code;



 $batch_no=$batch_no;$mrp=$mrp;



				$prod_name=$prod_name;







				$rate=$rate;







				$pv=$pv;







				$cgst=$cgst;







				$sgst=$sgst;







				$igst=$igst;







				$uom=$uom;

$cc=$cc;





				}















$diss3=$rate*$dis3;







?>







<tr>







<td><? echo $prod_name;?></td>







<td><? echo $code;?></td>







<td><? echo $qty3;?></td>



<td><? echo $batch_no;?></td>



<td><? echo $uom;?></td>







<?







$g_val3=$rate*$qty3;















$taxable_val=$g_val3+$del3-$diss3;







$cgst_val=$taxable_val*$cgst/100;







$igst_val=$taxable_val*$igst/100;







$sgst_val=$taxable_val*$sgst/100;







$gs_val3=$g_val3+$del3-$diss3;







?>







<td><? echo $rate;?></td>















<td><? echo $g_val3;?></td>







<td><? echo $mrp;?></td>







<td><? echo $diss3;?></td>







<td><? echo $taxable_val;?></td>







<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $cgst; } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $cgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $sgst; } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $sgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="central"){echo $igst; } ?></td>







  <td width="50"><? if($bill_type=="central"){echo $igst_val; } ?></td>
  </tr></table></td>















<? if($bill_type=="central"){ $tax_rebate3=$igst_val; } ?>







<? if($bill_type=="state"){ $tax_rebate3=$cgst_val+$sgst_val; } ?>







<? 







if($bill_type=="state"){$cgs3=$cgst_val;$sgs3=$sgst_val;$igs3=0;}







if($bill_type=="central"){$cgs3=0;$sgs3=0;$igs3=$igst_val;}







 $total3=$taxable_val+$tax_rebate3;?>
</tr>







<?







$dis_pv3=$pv*$dis3;







$pv3=$pv*$qty3;

$cc3=$cc*$qty3;





?>







<? } ?>







<? if($item4!=""){







$qry = $mysqli->prepare("select code,name,rate,pv,cgst,sgst,igst,uom,batch_no,mrp,bv from product_resale where id=?");
















				$qry->bind_param('s', $item4);								







                $qry->execute();







                $qry->bind_result($code,$prod_name,$rate,$pv,$cgst,$sgst,$igst,$uom,$batch_no,$mrp,$cc);







				while ($qry->fetch())







				{







				$code=$code;







				$prod_name=$prod_name;



 $batch_no=$batch_no;$mrp=$mrp;



				$rate=$rate;







				$pv=$pv;







				$cgst=$cgst;







				$sgst=$sgst;







				$igst=$igst;







				$uom=$uom;


$cc=$cc;




				}















$diss4=$rate*$dis4;







?>







<tr>







<td><? echo $prod_name;?></td>







<td><? echo $code;?></td>







<td><? echo $qty4;?></td>



<td><? echo $batch_no;?></td>



<td><? echo $uom;?></td>







<?







$g_val4=$rate*$qty4;















$taxable_val=$g_val4+$del4-$diss4;







$cgst_val=$taxable_val*$cgst/100;







$igst_val=$taxable_val*$igst/100;







$sgst_val=$taxable_val*$sgst/100;







$gs_val4=$g_val4+$del4-$diss4;







?>







<td><? echo $rate;?></td>















<td><? echo $g_val4;?></td>







<td><? echo $mrp;?></td>







<td><? echo $diss4;?></td>







<td><? echo $taxable_val;?></td>







<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $cgst; } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $cgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $sgst; } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $sgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="central"){echo $igst; } ?></td>







  <td width="50"><? if($bill_type=="central"){echo $igst_val; } ?></td>
  </tr></table></td>















<? if($bill_type=="central"){ $tax_rebate4=$igst_val; } ?>







<? if($bill_type=="state"){ $tax_rebate4=$cgst_val+$sgst_val; } ?>







<? 







if($bill_type=="state"){$cgs4=$cgst_val;$sgs4=$sgst_val;$igs4=0;}







if($bill_type=="central"){$cgs4=0;$sgs4=0;$igs4=$igst_val;}







 $total4=$taxable_val+$tax_rebate4;?>
</tr>







<?







$dis_pv4=$pv*$dis4;







$pv4=$pv*$qty4;


$cc4=$cc*$qty4;




?>







<? } ?>























<? if($item5!=""){







$qry = $mysqli->prepare("select code,name,rate,pv,cgst,sgst,igst,uom,batch_no,mrp,bv from product_resale where id=?");















				$qry->bind_param('s', $item5);								







                $qry->execute();







                $qry->bind_result($code,$prod_name,$rate,$pv,$cgst,$sgst,$igst,$uom,$batch_no,$mrp,$cc);







				while ($qry->fetch())







				{







				$code=$code;







				$prod_name=$prod_name;



 $batch_no=$batch_no;$mrp=$mrp;



				$rate=$rate;







				$pv=$pv;







				$cgst=$cgst;







				$sgst=$sgst;







				$igst=$igst;







				$uom=$uom;

$cc=$cc;





				}







$diss5=$rate*$dis5;







?>







<tr>







<td><? echo $prod_name;?></td>







<td><? echo $code;?></td>







<td><? echo $qty5;?></td>



<td><? echo $batch_no;?></td>



<td><? echo $uom;?></td>







<?







$g_val5=$rate*$qty5;















$taxable_val=$g_val5+$del5-$diss5;







$cgst_val=$taxable_val*$cgst/100;







$igst_val=$taxable_val*$igst/100;







$sgst_val=$taxable_val*$sgst/100;







$gs_val5=$g_val5+$del5-$diss5;







?>







<td><? echo $rate;?></td>















<td><? echo $g_val5;?></td>







<td><? echo $mrp;?></td>







<td><? echo $diss5;?></td>







<td><? echo $taxable_val;?></td>







<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $cgst; } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $cgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $sgst; } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $sgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="central"){echo $igst; } ?></td>







  <td width="50"><? if($bill_type=="central"){echo $igst_val; } ?></td>
  </tr></table></td>















<? if($bill_type=="central"){ $tax_rebate5=$igst_val; } ?>







<? if($bill_type=="state"){ $tax_rebate5=$cgst_val+$sgst_val; } ?>







<? 







if($bill_type=="state"){$cgs5=$cgst_val;$sgs5=$sgst_val;$igs5=0;}







if($bill_type=="central"){$cgs5=0;$sgs5=0;$igs5=$igst_val;}







 $total5=$taxable_val+$tax_rebate5;?>
</tr>







<?







$dis_pv5=$pv*$dis5;







$pv5=$pv*$qty5;
$cc5=$cc*$qty5;






?>







<? } ?>















<? if($item6!=""){







$qry = $mysqli->prepare("select code,name,rate,pv,cgst,sgst,igst,uom,batch_no,mrp,bv from product_resale where id=?");















				$qry->bind_param('s', $item6);								







                $qry->execute();







                $qry->bind_result($code,$prod_name,$rate,$pv,$cgst,$sgst,$igst,$uom,$batch_no,$mrp,$cc);







				while ($qry->fetch())







				{







				$code=$code;







				$prod_name=$prod_name;



 $batch_no=$batch_no;$mrp=$mrp;



				$rate=$rate;







				$pv=$pv;







				$cgst=$cgst;







				$sgst=$sgst;







				$igst=$igst;







				$uom=$uom;

$cc=$cc;





				}







$diss6=$rate*$dis6;







?>







<tr>







<td><? echo $prod_name;?></td>







<td><? echo $code;?></td>







<td><? echo $qty6;?></td>



<td><? echo $batch_no;?></td>



<td><? echo $uom;?></td>







<?







$g_val6=$rate*$qty6;















$taxable_val=$g_val6+$del6-$diss6;







$cgst_val=$taxable_val*$cgst/100;







$igst_val=$taxable_val*$igst/100;







$sgst_val=$taxable_val*$sgst/100;







$gs_val6=$g_val6+$del6-$diss6;







?>







<td><? echo $rate;?></td>















<td><? echo $g_val6;?></td>







<td><? echo $mrp;?></td>







<td><? echo $diss6;?></td>







<td><? echo $taxable_val;?></td>







<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $cgst; } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $cgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $sgst; } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $sgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="central"){echo $igst; } ?></td>







  <td width="50"><? if($bill_type=="central"){echo $igst_val; } ?></td>
  </tr></table></td>















<? if($bill_type=="central"){ $tax_rebate6=$igst_val; } ?>







<? if($bill_type=="state"){ $tax_rebate6=$cgst_val+$sgst_val; } ?>







<? 







if($bill_type=="state"){$cgs6=$cgst_val;$sgs6=$sgst_val;$igs6=0;}







if($bill_type=="central"){$cgs6=0;$sgs6=0;$igs6=$igst_val;}







 $total6=$taxable_val+$tax_rebate6;?>
</tr>







<?







$dis_pv6=$pv*$dis6;







$pv6=$pv*$qty6;

$cc6=$cc*$qty6;





?>







<? } ?>















<? if($item7!=""){







$qry = $mysqli->prepare("select code,name,rate,pv,cgst,sgst,igst,uom,batch_no,mrp,bv from product_resale where id=?");















				$qry->bind_param('s', $item7);								







                $qry->execute();







                $qry->bind_result($code,$prod_name,$rate,$pv,$cgst,$sgst,$igst,$uom,$batch_no,$mrp,$cc);







				while ($qry->fetch())







				{







				$code=$code;







				$prod_name=$prod_name;



 $batch_no=$batch_no;$mrp=$mrp;



				$rate=$rate;







				$pv=$pv;







				$cgst=$cgst;







				$sgst=$sgst;







				$igst=$igst;







				$uom=$uom;

                 $cc=$cc;





				}







$diss7=$rate*$dis7;







?>







<tr>







<td><? echo $prod_name;?></td>







<td><? echo $code;?></td>







<td><? echo $qty7;?></td>



<td><? echo $batch_no;?></td>



<td><? echo $uom;?></td>







<?







$g_val7=$rate*$qty7;















$taxable_val=$g_val7+$del7-$diss7;







$cgst_val=$taxable_val*$cgst/100;







$igst_val=$taxable_val*$igst/100;







$sgst_val=$taxable_val*$sgst/100;







$gs_val7=$g_val7+$del7-$diss7;







?>







<td><? echo $rate;?></td>















<td><? echo $g_val7;?></td>







<td><? echo $mrp;?></td>







<td><? echo $diss7;?></td>







<td><? echo $taxable_val;?></td>







<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $cgst; } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $cgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $sgst; } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $sgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="central"){echo $igst; } ?></td>







  <td width="50"><? if($bill_type=="central"){echo $igst_val; } ?></td>
  </tr></table></td>















<? if($bill_type=="central"){ $tax_rebate7=$igst_val; } ?>







<? if($bill_type=="state"){ $tax_rebate7=$cgst_val+$sgst_val; } ?>







<? 







if($bill_type=="state"){$cgs7=$cgst_val;$sgs7=$sgst_val;$igs7=0;}







if($bill_type=="central"){$cgs7=0;$sgs7=0;$igs7=$igst_val;}







 $total7=$taxable_val+$tax_rebate7;?>
</tr>







<?







$dis_pv7=$pv*$dis7;







$pv7=$pv*$qty7;

$cc7=$cc*$qty7;





?>







<? } ?>















<? if($item8!=""){







$qry = $mysqli->prepare("select code,name,rate,pv,cgst,sgst,igst,uom,batch_no,mrp,bv from product_resale where id=?");















				$qry->bind_param('s', $item8);								







                $qry->execute();







                $qry->bind_result($code,$prod_name,$rate,$pv,$cgst,$sgst,$igst,$uom,$batch_no,$mrp,$cc);







				while ($qry->fetch())







				{







				$code=$code;







				$prod_name=$prod_name;



 $batch_no=$batch_no;$mrp=$mrp;



				$rate=$rate;







				$pv=$pv;







				$cgst=$cgst;







				$sgst=$sgst;







				$igst=$igst;







				$uom=$uom;


                $cc=$cc;




				}







$diss8=$rate*$dis8;







?>







<tr>







<td><? echo $prod_name;?></td>







<td><? echo $code;?></td>







<td><? echo $qty8;?></td>



<td><? echo $batch_no;?></td>



<td><? echo $uom;?></td>







<?







$g_val8=$rate*$qty8;















$taxable_val=$g_val8+$del8-$diss8;







$cgst_val=$taxable_val*$cgst/100;







$igst_val=$taxable_val*$igst/100;







$sgst_val=$taxable_val*$sgst/100;







$gs_val8=$g_val8+$del8-$diss8;







?>







<td><? echo $rate;?></td>















<td><? echo $g_val8;?></td>







<td><? echo $mrp;?></td>







<td><? echo $diss8;?></td>







<td><? echo $taxable_val;?></td>







<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $cgst; } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $cgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $sgst; } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $sgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="central"){echo $igst; } ?></td>







  <td width="50"><? if($bill_type=="central"){echo $igst_val; } ?></td>
  </tr></table></td>















<? if($bill_type=="central"){ $tax_rebate8=$igst_val; } ?>







<? if($bill_type=="state"){ $tax_rebate8=$cgst_val+$sgst_val; } ?>







<? 







if($bill_type=="state"){$cgs8=$cgst_val;$sgs8=$sgst_val;$igs8=0;}







if($bill_type=="central"){$cgs8=0;$sgs8=0;$igs8=$igst_val;}







 $total8=$taxable_val+$tax_rebate8;?>
</tr>







<?







$dis_pv8=$pv*$dis8;







$pv8=$pv*$qty8;

$cc8=$cc*$qty8;





?>







<? } ?>















<? if($item9!=""){







$qry = $mysqli->prepare("select code,name,rate,pv,cgst,sgst,igst,uom,batch_no,mrp,bv from product_resale where id=?");















				$qry->bind_param('s', $item9);								







                $qry->execute();







                $qry->bind_result($code,$prod_name,$rate,$pv,$cgst,$sgst,$igst,$uom,$batch_no,$mrp,$cc);







				while ($qry->fetch())







				{







				$code=$code;







				$prod_name=$prod_name;







				$rate=$rate;







				$pv=$pv;



 $batch_no=$batch_no;$mrp=$mrp;



				$cgst=$cgst;







				$sgst=$sgst;







				$igst=$igst;







				$uom=$uom;


                 $cc=$cc;




				}







$diss9=$rate*$dis9;







?>







<tr>







<td><? echo $prod_name;?></td>







<td><? echo $code;?></td>







<td><? echo $qty9;?></td>



<td><? echo $batch_no;?></td>



<td><? echo $uom;?></td>







<?







$g_val9=$rate*$qty9;















$taxable_val=$g_val9+$del9-$diss9;







$cgst_val=$taxable_val*$cgst/100;







$igst_val=$taxable_val*$igst/100;







$sgst_val=$taxable_val*$sgst/100;







$gs_val9=$g_val9+$del9-$diss9;







?>







<td><? echo $rate;?></td>















<td><? echo $g_val9;?></td>







<td><? echo $mrp;?></td>







<td><? echo $diss9;?></td>







<td><? echo $taxable_val;?></td>







<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $cgst; } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $cgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $sgst; } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $sgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="central"){echo $igst; } ?></td>







  <td width="50"><? if($bill_type=="central"){echo $igst_val; } ?></td>
  </tr></table></td>















<? if($bill_type=="central"){ $tax_rebate9=$igst_val; } ?>







<? if($bill_type=="state"){ $tax_rebate9=$cgst_val+$sgst_val; } ?>







<? 







if($bill_type=="state"){$cgs9=$cgst_val;$sgs9=$sgst_val;$igs9=0;}







if($bill_type=="central"){$cgs9=0;$sgs9=0;$igs9=$igst_val;}







 $total9=$taxable_val+$tax_rebate9;?>
</tr>







<?







$dis_pv9=$pv*$dis9;







$pv9=$pv*$qty9;

$cc9=$cc*$qty9;





?>







<? } ?>















<? if($item10!=""){







$qry = $mysqli->prepare("select code,name,rate,pv,cgst,sgst,igst,uom,batch_no,mrp,bv from product_resale where id=?");















				$qry->bind_param('s', $item10);								







                $qry->execute();







                $qry->bind_result($code,$prod_name,$rate,$pv,$cgst,$sgst,$igst,$uom,$batch_no,$mrp,$cc);







				while ($qry->fetch())







				{







				$code=$code;



 $batch_no=$batch_no;$mrp=$mrp;



				$prod_name=$prod_name;







				$rate=$rate;







				$pv=$pv;







				$cgst=$cgst;







				$sgst=$sgst;







				$igst=$igst;







				$uom=$uom;

                 $cc=$cc;





				}







$diss10=$rate*$dis10;







?>







<tr>







<td><? echo $prod_name;?></td>







<td><? echo $code;?></td>







<td><? echo $qty10;?></td>



<td><? echo $batch_no;?></td>



<td><? echo $uom;?></td>







<?







$g_val10=$rate*$qty10;















$taxable_val=$g_val10+$del10-$diss10;







$cgst_val=$taxable_val*$cgst/100;







$igst_val=$taxable_val*$igst/100;







$sgst_val=$taxable_val*$sgst/100;







$gs_val10=$g_val10+$del10-$diss10;







?>







<td><? echo $rate;?></td>















<td><? echo $g_val10;?></td>







<td><? echo $mrp;?></td>







<td><? echo $diss10;?></td>







<td><? echo $taxable_val;?></td>







<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $cgst; } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $cgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="state"){echo $sgst; } ?></td>







  <td width="50"><? if($bill_type=="state"){echo $sgst_val; } ?></td>
  </tr></table></td>















<td><table width="102" border="1">







  <tr><td width="35"><? if($bill_type=="central"){echo $igst; } ?></td>







  <td width="50"><? if($bill_type=="central"){echo $igst_val; } ?></td>
  </tr></table></td>















<? if($bill_type=="central"){ $tax_rebate10=$igst_val; } ?>







<? if($bill_type=="state"){ $tax_rebate10=$cgst_val+$sgst_val; } ?>







<? 







if($bill_type=="state"){$cgs10=$cgst_val;$sgs10=$sgst_val;$igs10=0;}







if($bill_type=="central"){$cgs10=0;$sgs10=0;$igs10=$igst_val;}







 $total10=$taxable_val+$tax_rebate10;?>
</tr>







<?







$dis_pv10=$pv*$dis10;







$pv10=$pv*$qty10;

$cc10=$cc*$qty10;





?>







<? } ?>







<?  $total=$total1+$total2+$total3+$total4+$total5+$total6+$total7+$total8+$total9+$total10;







$tot_qty=$qty1+$qty2+$qty3+$qty4+$qty5+$qty6+$qty7+$qty8+$qty9+$qty10;







$tot_vat=$tax_rebate1+$tax_rebate2+$tax_rebate3+$tax_rebate4+$tax_rebate5+$tax_rebate6+$tax_rebate7+$tax_rebate8+$tax_rebate9+$tax_rebate10;







$tot_dis_pv=$dis_pv1+$dis_pv2+$dis_pv3+$dis_pv4+$dis_pv5+$dis_pv6+$dis_pv7+$dis_pv8+$dis_pv9+$dis_pv10;







$tot_pvv=$pv1+$pv2+$pv3+$pv4+$pv5+$pv6+$pv7+$pv8+$pv9+$pv10;
$tot_cc=$cc1+$cc2+$cc3+$cc4+$cc5+$cc6+$cc7+$cc8+$cc9+$cc10;






$tot_pv=$tot_pvv-$tot_dis_pv;







$tot_g_val=$gs_val1+$gs_val2+$gs_val3+$gs_val4+$gs_val5+$gs_val6+$gs_val7+$gs_val8+$gs_val9+$gs_val10;















$tot_cgst=$cgs1+$cgs2+$cgs3+$cgs4+$cgs5+$cgs6+$cgs7+$cgs8+$cgs9+$cgs10;







$tot_sgst=$sgs1+$sgs2+$sgs3+$sgs4+$sgs5+$sgs6+$sgs7+$sgs8+$sgs9+$sgs10;







$tot_igst=$igs1+$igs2+$igs3+$igs4+$igs5+$igs6+$igs7+$igs8+$igs9+$igs10;







?>







<tr>







<td colspan="9" align="right"><b>Gross Total</b></td>







<td><?  echo $tot_qty;?></td>















<td colspan="3"><?  echo sprintf("%01.2f",$tot_g_val);?></td>
</tr>







<tr>







<td colspan="10" align="right"><b>CGST</b></td>















<td colspan="3"><?  echo sprintf("%01.2f",$tot_cgst);?></td>
</tr>







<tr>







<td colspan="10" align="right"><b>SGST</b></td>















<td colspan="3"><?  echo sprintf("%01.2f",$tot_sgst);?></td>
</tr>







<tr>







<td colspan="10" align="right"><b>IGST</b></td>















<td colspan="3"><?  echo sprintf("%01.2f",$tot_igst);?></td>
</tr>







<?







$net_bill=$total-$dis;







$dists=0;







$net_bill2=$total-$dists;







?>







<tr>







<td colspan="10" align="right"><b>Net Amount</b></td>







<td colspan="3"><?  echo sprintf("%01.2f",$total);?></td>
</tr>















<tr>















<td colspan="3" align="right"><b>Total B.P </b>: <? echo $tot_pv;?></td>







<td colspan="7" align="right"><b>Payable</b></td>







<td colspan="3"><?  echo round($net_bill2);?></td>
</tr>







<input type="hidden" name="name" value="<? echo $name;?>">







<input type="hidden" name="member_id" value="<? echo $member_id;?>">







<input type="hidden" name="ent_date" value="<? echo $ent_date;?>">







<input type="hidden" name="discount" value="<? echo $dis;?>">







<input type="hidden" name="dists" value="<? echo $dists;?>">







<input type="hidden" name="qty1" value="<? echo $qty1;?>">







<input type="hidden" name="qty2" value="<? echo $qty2;?>">







<input type="hidden" name="qty3" value="<? echo $qty3;?>">







<input type="hidden" name="qty4" value="<? echo $qty4;?>">







<input type="hidden" name="qty5" value="<? echo $qty5;?>">







<input type="hidden" name="qty6" value="<? echo $qty6;?>">







<input type="hidden" name="qty7" value="<? echo $qty7;?>">







<input type="hidden" name="qty8" value="<? echo $qty8;?>">







<input type="hidden" name="qty9" value="<? echo $qty9;?>">







<input type="hidden" name="qty10" value="<? echo $qty10;?>">















<input type="hidden" name="item1" value="<? echo $item1;?>">







<input type="hidden" name="item2" value="<? echo $item2;?>">







<input type="hidden" name="item3" value="<? echo $item3;?>">







<input type="hidden" name="item4" value="<? echo $item4;?>">







<input type="hidden" name="item5" value="<? echo $item5;?>">







<input type="hidden" name="item6" value="<? echo $item6;?>">







<input type="hidden" name="item7" value="<? echo $item7;?>">







<input type="hidden" name="item8" value="<? echo $item8;?>">







<input type="hidden" name="item9" value="<? echo $item9;?>">







<input type="hidden" name="item10" value="<? echo $item10;?>">







<input type="hidden" name="gst_no" value="<? echo $gst_no;?>">







<input type="hidden" name="dis1" value="<? echo $dis1;?>">







<input type="hidden" name="dis2" value="<? echo $dis2;?>">







<input type="hidden" name="dis3" value="<? echo $dis3;?>">







<input type="hidden" name="dis4" value="<? echo $dis4;?>">







<input type="hidden" name="dis5" value="<? echo $dis5;?>">







<input type="hidden" name="dis6" value="<? echo $dis6;?>">







<input type="hidden" name="dis7" value="<? echo $dis7;?>">







<input type="hidden" name="dis8" value="<? echo $dis8;?>">







<input type="hidden" name="dis9" value="<? echo $dis9;?>">







<input type="hidden" name="dis10" value="<? echo $dis10;?>">















<input type="hidden" name="del1" value="<? echo $del1;?>">







<input type="hidden" name="del2" value="<? echo $del2;?>">







<input type="hidden" name="del3" value="<? echo $del3;?>">







<input type="hidden" name="del4" value="<? echo $del4;?>">







<input type="hidden" name="del5" value="<? echo $del5;?>">







<input type="hidden" name="del6" value="<? echo $del6;?>">







<input type="hidden" name="del7" value="<? echo $del7;?>">







<input type="hidden" name="del8" value="<? echo $del8;?>">







<input type="hidden" name="del9" value="<? echo $del9;?>">







<input type="hidden" name="del10" value="<? echo $del10;?>">















<input type="hidden" name="total" value="<? echo $total;?>">







<input type="hidden" name="vat" value="<? echo $tot_vat;?>">







<input type="hidden" name="tot_pv" value="<? echo $tot_pv;?>">
<input type="hidden" name="tot_cc" value="<? echo $tot_cc;?>">














<input type="hidden" name="tot_g_val" value="<? echo $tot_g_val;?>">







<input type="hidden" name="tot_cgst" value="<? echo $tot_cgst;?>">







<input type="hidden" name="tot_sgst" value="<? echo $tot_sgst;?>">







<input type="hidden" name="tot_igst" value="<? echo $tot_igst;?>">







<input type="hidden" name="bill_type" value="<? echo $bill_type;?>">















<tr>







	







	<td align="center" colspan="13"><input type="submit" name="submit" value="Submit.."></td>
</tr>
</table>







</form>















<? } }}?>



						<? } ?>
					



<?php if($action=="voucher")



				{



				$member_id=$_REQUEST['member_id'];



				$bill_no=$_REQUEST['bill_no'];



				 ?>



				



				<? 



				



				?>



				



                                

 <table class="table table-bordered mb-4">




<tr>



                                  <td valign="top" align="center"> Invoice</td>



                                </tr>



								 <tr>



										   <td colspan="4" align="center">



										   <input type="button" value="PRINT Invoice" onclick="window.open('print_bill.php?bill_no=<? echo $bill_no;?>', '','width=740,height=500,scrollbars=yes,resizable=yes,toolbar=yes,directories=no,location=no,menubar=no,status=no,left=50,top=0'); return true;" />



										   </td>



										 </tr>



										  



</table>







					



				<?php 



				



				



				}?>
						
						



                            </div>

                        </div>



                    

                



                    



                    



                </div>

				

<?







if($action=="add_process")







{







$member_id=$_REQUEST['member_id'];







$stock_id=$_SESSION['admin_id'];







$gr_date=date("Y-m-d:his");







$qry = $mysqli->prepare('SELECT * FROM bill where bill_no=?');







						 $qry->bind_param('s', $gr_date);







						$qry->execute();







						$qry->store_result();







						$bill_entry=$qry->num_rows;







while($bill_entry == 1) // If find same user ID in DB







{







$gr_date=date("Y-m-d:his");















$qry = $mysqli->prepare('SELECT * FROM bill where bill_no=?');







						 $qry->bind_param('s', $gr_date);







						$qry->execute();







						$qry->store_result();







						$bill_entry=$qry->num_rows;







}







$bill_type=$_REQUEST['bill_type'];







$total=$_REQUEST['total'];















$temp_no= mt_rand (1000000001, 9999999999); // Syntex : int mt_rand ( [int min, int max])



$temp_no=$temp_no;







														







$bill_no=$gr_date.$temp_no;														







$vat_no=$temp_no;







//$doc_name=$_REQUEST['doc_name'];







//$name=$_REQUEST['name'];







$ent_date=$_REQUEST['ent_date'];















$en_dat=explode("-",$ent_date);







$en_date_val=$en_dat[2].$en_dat[1].$en_dat[0];







$qq_spot = $mysqli->prepare('SELECT * FROM report where member_id=? and total=? and date=?');







  $qq_spot->bind_param('sss', $member_id,$total,$ent_date);







						$qq_spot->execute();







						$qq_spot->store_result();







						$no_spot=$qq_spot->num_rows;



						



if($no_spot>0)	



{







 $_SESSION['msg_box2']="Please do not Refress. Try Again.";







// $_SESSION['class_notification']="notification success png_bg";	







header("location:first_sale.php?tab_id=tab1&default=first_sale&member_id=$member_id");







}



else



{					







$qty1=$_REQUEST['qty1'];







$qty2=$_REQUEST['qty2'];







$qty3=$_REQUEST['qty3'];







$qty4=$_REQUEST['qty4'];







$qty5=$_REQUEST['qty5'];







$qty6=$_REQUEST['qty6'];







$qty7=$_REQUEST['qty7'];







$qty8=$_REQUEST['qty8'];







$qty9=$_REQUEST['qty9'];







$qty10=$_REQUEST['qty10'];















$item1=$_REQUEST['item1'];







$item2=$_REQUEST['item2'];







$item3=$_REQUEST['item3'];







$item4=$_REQUEST['item4'];







$item5=$_REQUEST['item5'];







$item6=$_REQUEST['item6'];







$item7=$_REQUEST['item7'];







$item8=$_REQUEST['item8'];







$item9=$_REQUEST['item9'];







$item10=$_REQUEST['item10'];















$dis1=$_REQUEST['dis1'];







$dis2=$_REQUEST['dis2'];







$dis3=$_REQUEST['dis3'];







$dis4=$_REQUEST['dis4'];







$dis5=$_REQUEST['dis5'];







$dis6=$_REQUEST['dis6'];







$dis7=$_REQUEST['dis7'];







$dis8=$_REQUEST['dis8'];







$dis9=$_REQUEST['dis9'];







$dis10=$_REQUEST['dis10'];















$del1=$_REQUEST['del1'];







$del2=$_REQUEST['del2'];







$del3=$_REQUEST['del3'];







$del4=$_REQUEST['del4'];







$del5=$_REQUEST['del5'];







$del6=$_REQUEST['del6'];







$del7=$_REQUEST['del7'];







$del8=$_REQUEST['del8'];







$del9=$_REQUEST['del9'];







$del10=$_REQUEST['del10'];















$discount=$_REQUEST['discount'];







$dists=$_REQUEST['dists'];







$total=$_REQUEST['total'];







$vat=$_REQUEST['vat'];







$tot_pv=$_REQUEST['tot_pv'];







$tot_g_val=$_REQUEST['tot_g_val'];







$tot_cgst=$_REQUEST['tot_cgst'];







$tot_sgst=$_REQUEST['tot_sgst'];







$tot_igst=$_REQUEST['tot_igst'];







$gst_no=$_REQUEST['gst_no'];



if($gst_no==""){$gst_no="N";}











if($item1!="")







{







$insert1=$mysqli->prepare("insert into bill (item_code, bill_no, qty, vat_no, date, date_val, member_id, dis, del) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");















	$insert1->bind_param("sssssssss", $item1, $bill_no, $qty1, $vat_no, $ent_date, $en_date_val, $member_id, $dis1, $del1);















$insert1->execute();















$remark="Debit For Bill No".$bill_no;















$type="Dredit";















$queryd=$mysqli->prepare("insert into stock_details2 (prod_id, qty, remark, date, date_val,type,stock_id) VALUES (?, ?, ?, ?, ?, ?,?)");















	$queryd->bind_param("sssssss", $item1, $qty1, $remark, $ent_date, $en_date_val,$type,$stock_id);















	















$queryd->execute();















 $query_stk = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");







$query_stk->bind_param('ss', $stock_id,$item1);







$query_stk->execute();







$query_stk->bind_result($stock1);







while ($query_stk->fetch())







{







$curr_stock1=$stock1;													







}







$new_stock1=$curr_stock1-$qty1;















$qry_stk=$mysqli->prepare("update stock_record set current_stock=? where prod_id=? and stock_id=?");















			$qry_stk->bind_param('sss', $new_stock1,$item1,$stock_id);















			$qry_stk->execute();















$qry_stk->close();























   







   







}















if($item2!="")







{















$insert2=$mysqli->prepare("insert into bill (item_code, bill_no, qty, vat_no, date, date_val, member_id, dis, del) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");















	$insert2->bind_param("sssssssss", $item2, $bill_no, $qty2, $vat_no, $ent_date, $en_date_val, $member_id, $dis2, $del2);















$insert2->execute();















$remark="Debit For Bill No".$bill_no;















$type="Dredit";















$queryd=$mysqli->prepare("insert into stock_details2 (prod_id, qty, remark, date, date_val,type,stock_id) VALUES (?, ?, ?, ?, ?, ?,?)");















	$queryd->bind_param("sssssss", $item2, $qty2, $remark, $ent_date, $en_date_val,$type,$stock_id);















	















$queryd->execute();























$query_stk = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");







$query_stk->bind_param('ss', $stock_id,$item2);







$query_stk->execute();







$query_stk->bind_result($stock2);







while ($query_stk->fetch())







{







$curr_stock2=$stock2;													







}







$new_stock2=$curr_stock2-$qty2;















$qry_stk=$mysqli->prepare("update stock_record set current_stock=? where prod_id=? and stock_id=?");















			$qry_stk->bind_param('sss', $new_stock2,$item2,$stock_id);















			$qry_stk->execute();















$qry_stk->close();















   







}







if($item3!="")







{















$insert3=$mysqli->prepare("insert into bill (item_code, bill_no, qty, vat_no, date, date_val, member_id, dis, del) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");















	$insert3->bind_param("sssssssss", $item3, $bill_no, $qty3, $vat_no, $ent_date, $en_date_val, $member_id, $dis3, $del3);















$insert3->execute();















$remark="Debit For Bill No".$bill_no;















$type="Dredit";















$queryd=$mysqli->prepare("insert into stock_details2 (prod_id, qty, remark, date, date_val,type,stock_id) VALUES (?, ?, ?, ?, ?, ?,?)");















	$queryd->bind_param("sssssss", $item3, $qty3, $remark, $ent_date, $en_date_val,$type,$stock_id);















	















$queryd->execute();















$query_stk = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");







$query_stk->bind_param('ss', $stock_id,$item3);;







$query_stk->execute();







$query_stk->bind_result($stock3);







while ($query_stk->fetch())







{







$curr_stock3=$stock3;													







}







$new_stock3=$curr_stock3-$qty3;















$qry_stk=$mysqli->prepare("update stock_record set current_stock=? where prod_id=? and stock_id=?");















			$qry_stk->bind_param('sss', $new_stock3,$item3,$stock_id);















			$qry_stk->execute();















$qry_stk->close();   







  







}















if($item4!="")







{























$insert4=$mysqli->prepare("insert into bill (item_code, bill_no, qty, vat_no, date, date_val, member_id, dis, del) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");















	$insert4->bind_param("sssssssss", $item4, $bill_no, $qty4, $vat_no, $ent_date, $en_date_val, $member_id, $dis4, $del4);















$insert4->execute();















$remark="Debit For Bill No".$bill_no;















$type="Dredit";















$queryd=$mysqli->prepare("insert into stock_details2 (prod_id, qty, remark, date, date_val,type,stock_id) VALUES (?, ?, ?, ?, ?, ?,?)");















	$queryd->bind_param("sssssss", $item4, $qty4, $remark, $ent_date, $en_date_val,$type,$stock_id);















	















$queryd->execute();







   







$query_stk = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");







$query_stk->bind_param('ss', $stock_id,$item4);







$query_stk->execute();







$query_stk->bind_result($stock4);







while ($query_stk->fetch())







{







$curr_stock4=$stock4;													







}







$new_stock4=$curr_stock4-$qty4;















$qry_stk=$mysqli->prepare("update stock_record set current_stock=? where prod_id=? and stock_id=?");















			$qry_stk->bind_param('sss', $new_stock4,$item4,$stock_id);















			$qry_stk->execute();















$qry_stk->close();  







   







}







if($item5!="")







{























$insert5=$mysqli->prepare("insert into bill (item_code, bill_no, qty, vat_no, date, date_val, member_id, dis, del) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");















	$insert5->bind_param("sssssssss", $item5, $bill_no, $qty5, $vat_no, $ent_date, $en_date_val, $member_id, $dis5, $del5);















$insert5->execute();















$remark="Debit For Bill No".$bill_no;















$type="Dredit";















$queryd=$mysqli->prepare("insert into stock_details2 (prod_id, qty, remark, date, date_val,type,stock_id) VALUES (?, ?, ?, ?, ?, ?,?)");
















	$queryd->bind_param("sssssss", $item5, $qty5, $remark, $ent_date, $en_date_val,$type,$stock_id);















	















$queryd->execute();   







$query_stk = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");







$query_stk->bind_param('ss', $stock_id,$item5);







$query_stk->execute();







$query_stk->bind_result($stock5);







while ($query_stk->fetch())







{







$curr_stock5=$stock5;													







}







$new_stock5=$curr_stock5-$qty5;















$qry_stk=$mysqli->prepare("update stock_record set current_stock=? where prod_id=? and stock_id=?");















			$qry_stk->bind_param('sss', $new_stock5,$item5,$stock_id);















			$qry_stk->execute();















$qry_stk->close();   







  







}







if($item6!="")







{























$insert6=$mysqli->prepare("insert into bill (item_code, bill_no, qty, vat_no, date, date_val, member_id, dis, del) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");















	$insert6->bind_param("sssssssss", $item6, $bill_no, $qty6, $vat_no, $ent_date, $en_date_val, $member_id, $dis6, $del6);















$insert6->execute();















$remark="Debit For Bill No".$bill_no;















$type="Dredit";















$queryd=$mysqli->prepare("insert into stock_details2 (prod_id, qty, remark, date, date_val,type,stock_id) VALUES (?, ?, ?, ?, ?, ?,?)");















	$queryd->bind_param("sssssss", $item6, $qty6, $remark, $ent_date, $en_date_val,$type,$stock_id);















	















$queryd->execute();







$query_stk = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");







$query_stk->bind_param('ss', $stock_id,$item6);







$query_stk->execute();







$query_stk->bind_result($stock6);







while ($query_stk->fetch())







{







$curr_stock6=$stock6;													







}







$new_stock6=$curr_stock6-$qty6;















$qry_stk=$mysqli->prepare("update stock_record set current_stock=? where prod_id=? and stock_id=?");















			$qry_stk->bind_param('sss', $new_stock6,$item6,$stock_id);















			$qry_stk->execute();















$qry_stk->close();







}







if($item7!="")







{























$insert7=$mysqli->prepare("insert into bill (item_code, bill_no, qty, vat_no, date, date_val, member_id, dis, del) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");















	$insert7->bind_param("sssssssss", $item7, $bill_no, $qty7, $vat_no, $ent_date, $en_date_val, $member_id, $dis7, $del7);















$insert7->execute();















$remark="Debit For Bill No".$bill_no;















$type="Dredit";















$queryd=$mysqli->prepare("insert into stock_details2 (prod_id, qty, remark, date, date_val,type,stock_id) VALUES (?, ?, ?, ?, ?, ?,?)");















	$queryd->bind_param("sssssss", $item7, $qty7, $remark, $ent_date, $en_date_val,$type,$stock_id);















	















$queryd->execute();















$query_stk = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");







$query_stk->bind_param('ss', $stock_id,$item7);







$query_stk->execute();







$query_stk->bind_result($stock7);







while ($query_stk->fetch())







{







$curr_stock7=$stock7;													








}







$new_stock7=$curr_stock7-$qty7;















$qry_stk=$mysqli->prepare("update stock_record set current_stock=? where prod_id=? and stock_id=?");















			$qry_stk->bind_param('sss', $new_stock7,$item7,$stock_id);















			$qry_stk->execute();















$qry_stk->close();















}







if($item8!="")







{























$insert8=$mysqli->prepare("insert into bill (item_code, bill_no, qty, vat_no, date, date_val, member_id, dis, del) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");















	$insert8->bind_param("sssssssss", $item8, $bill_no, $qty8, $vat_no, $ent_date, $en_date_val, $member_id, $dis8, $del8);















$insert8->execute();















$remark="Debit For Bill No".$bill_no;















$type="Dredit";















$queryd=$mysqli->prepare("insert into stock_details2 (prod_id, qty, remark, date, date_val,type,stock_id) VALUES (?, ?, ?, ?, ?, ?,?)");















	$queryd->bind_param("sssssss", $item8, $qty8, $remark, $ent_date, $en_date_val,$type,$stock_id);















	















$queryd->execute();















$query_stk = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");







$query_stk->bind_param('ss', $stock_id,$item8);







$query_stk->execute();







$query_stk->bind_result($stock8);







while ($query_stk->fetch())







{







$curr_stock8=$stock8;													







}







$new_stock8=$curr_stock8-$qty8;















$qry_stk=$mysqli->prepare("update stock_record set current_stock=? where prod_id=? and stock_id=?");















			$qry_stk->bind_param('sss', $new_stock8,$item8,$stock_id);















			$qry_stk->execute();















$qry_stk->close();















}







if($item9!="")







{























 $insert9=$mysqli->prepare("insert into bill (item_code, bill_no, qty, vat_no, date, date_val, member_id, dis, del) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");















	$insert9->bind_param("sssssssss", $item9, $bill_no, $qty9, $vat_no, $ent_date, $en_date_val, $member_id, $dis9, $del9);















$insert9->execute();















$remark="Debit For Bill No".$bill_no;















$type="Dredit";















$queryd=$mysqli->prepare("insert into stock_details2 (prod_id, qty, remark, date, date_val,type,stock_id) VALUES (?, ?, ?, ?, ?, ?,?)");















	$queryd->bind_param("sssssss", $item9, $qty9, $remark, $ent_date, $en_date_val,$type,$stock_id);















	















$queryd->execute(); 















$query_stk = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");







$query_stk->bind_param('ss', $stock_id,$item9);







$query_stk->execute();







$query_stk->bind_result($stock9);







while ($query_stk->fetch())







{







$curr_stock9=$stock9;													







}







$new_stock9=$curr_stock9-$qty9;















$qry_stk=$mysqli->prepare("update stock_record set current_stock=? where prod_id=? and stock_id=?");















			$qry_stk->bind_param('sss', $new_stock9,$item9,$stock_id);















			$qry_stk->execute();















$qry_stk->close();







  







}







if($item10!="")







{















$insert10=$mysqli->prepare("insert into bill (item_code, bill_no, qty, vat_no, date, date_val, member_id, dis, del) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");















	$insert10->bind_param("sssssssss", $item10, $bill_no, $qty10, $vat_no, $ent_date, $en_date_val, $member_id, $dis10, $del10);















$insert10->execute();















$remark="Debit For Bill No".$bill_no;















$type="Dredit";















$queryd=$mysqli->prepare("insert into stock_details2 (prod_id, qty, remark, date, date_val,type,stock_id) VALUES (?, ?, ?, ?, ?, ?, ?)");















	$queryd->bind_param("sssssss", $item10, $qty10, $remark, $ent_date, $en_date_val,$type,$stock_id);















	















$queryd->execute();















$query_stk = $mysqli->prepare("select current_stock from stock_record where stock_id=? and prod_id=?");







$query_stk->bind_param('ss', $stock_id,$item10);







$query_stk->execute();







$query_stk->bind_result($stock10);







while ($query_stk->fetch())







{







$curr_stock10=$stock10;													







}







$new_stock10=$curr_stock10-$qty10;















$qry_stk=$mysqli->prepare("update stock_record set current_stock=? where prod_id=? and stock_id=?");















			$qry_stk->bind_param('sss', $new_stock10,$item10,$stock_id);















			$qry_stk->execute();















$qry_stk->close();







		







}















  















$admin_id=$_SESSION['admin_id'];  







 	 	 	 	 














$type="A";
$qry_ins=$mysqli->prepare("insert into report (bill_no, vat_no, total, member_id, date, date_val, discount, admin_id, gross_bill, total_pv,vat,sgst,cgst,igst,bill_type,stock_id,gst_no,type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");


	$qry_ins->bind_param("ssssssssssssssssss", $bill_no, $vat_no, $total, $member_id, $ent_date, $en_date_val, $dists,$admin_id,$total,$tot_pv,$vat,$tot_sgst,$tot_cgst,$tot_igst,$bill_type,$stock_id,$gst_no,$type);

$qry_ins->execute();









$member_id=$_REQUEST['member_id'];







$quryinIN=$mysqli->prepare("select intro_id,position  from member where member_id=?");
$quryinIN->bind_param("s", $member_id);
$quryinIN->execute();
$quryinIN->bind_result( $intro_id,$position);
 while($quryinIN->fetch())
{
$intro_id=$intro_id;
$position=$position;
}


$query3=$mysqli->prepare("select direct_join, intro_no,left_direct,right_direct,left_direct1,right_direct1,joining_date,rwallet  from member where member_id=?");



					 $query3->bind_param("s", $intro_id);



                  $query3->execute();



$query3->bind_result($direct_join,$intro_no,$left_direct,$right_direct,$left_direct1,$right_direct1,$joining_date,$in_rwallet);



								  while($query3->fetch())



									{





									$direct_join=$direct_join;



									$intro_no=$intro_no;



									$left_direct=$left_direct;



									$right_direct=$right_direct;

									

									$left_direct1=$left_direct1;

									$right_direct1=$right_direct1;

									$joining_date=$joining_date;

									$in_rwallet=$in_rwallet;





									}


		 //-----------------------------------------Self Add End ----------------------------------------//
$active="y";
$date=date("d-m-Y");
$date_val=date("Ymd");
$activation_time=date("H:i:s");
$up_drt2=$mysqli->prepare("update member set active=?,active_date=?,active_date_val=?,activation_time=? where member_id=?");
$up_drt2->bind_param('sssss', $active,$date,$date_val,$activation_time,$member_id);
$up_drt2->execute();

$curr_direct_join=$direct_join+1;													
$up_drt=$mysqli->prepare("update member set direct_join=? where member_id=?");
$up_drt->bind_param('ss', $curr_direct_join, $intro_id);
$up_drt->execute();


if($position=="L")
{



$current_left_direct=$left_direct+1;



$up_drtL=$mysqli->prepare("update member set left_direct=? where member_id=?");



$up_drtL->bind_param('ss', $current_left_direct, $intro_id);



$up_drtL->execute();



}
if($position=="R")
{



$current_right_direct=$right_direct+1;



$up_drtR=$mysqli->prepare("update member set right_direct=? where member_id=?");



$up_drtR->bind_param('ss', $current_right_direct, $intro_id);



$up_drtR->execute();



}
		 //------------------------------------------End---------------------------------------//


$quryin2=$mysqli->prepare("select rwallet,self_bv_int  from member where member_id=?");
								 $quryin2->bind_param("s", $member_id);
								 $quryin2->execute();
								  $quryin2->bind_result($rwallet,$self_bv_int);
								  while($quryin2->fetch())
									{

									$rwallet=$rwallet;
									$self_bv_int=$self_bv_int;
									
									}
									
									$now_rwallet=$rwallet+$total;
									$now_self_bv=$self_bv_int+$tot_pv;
									$up_ewt=$mysqli->prepare("update member set rwallet=?,self_bv_int=? where member_id=?");
                                    $up_ewt->bind_param('sss', $now_rwallet,$now_self_bv,$member_id);
                                    $up_ewt->execute();	


$date=date("d-m-Y");
$date_val=date("Ymd");
$p_tp="self_com";
$self_com=$tot_pv*5/100;
$inst2=$mysqli->prepare("insert into payment (member_id, pay_amount, pay_type, date,date_val) VALUES (?, ?, ?, ?, ?)");
$inst2->bind_param("sssss", $member_id, $self_com, $p_tp,$date,$date_val);
$inst2->execute();

$quryin2=$mysqli->prepare("select ewallet,ewallet_in  from member where member_id=?");
$quryin2->bind_param("s", $member_id);
$quryin2->execute();
$quryin2->bind_result($ewallet,$ewallet_in);
while($quryin2->fetch())
{
$ewallet=$ewallet;
$ewallet_in=$ewallet_in;
}

$deduction=$self_com*10/100;
$now_ewallet=$ewallet+$self_com-$deduction;
$now_total_income=$total_income+$self_com;
$up_ewt2=$mysqli->prepare("update member set ewallet=?,ewallet_in=?,total_income=? where member_id=?");
$up_ewt2->bind_param('ssss', $now_ewallet,$now_ewallet,$now_total_income,$member_id);
$up_ewt2->execute();

$direct_com2=$tot_pv*20/100;
$level_income1=$direct_com2;
$date=date("d-m-Y");

$date_val=date("Ymd");

$p_tp="spot";

$inst2=$mysqli->prepare("insert into payment (member_id, pay_amount, pay_type, date,date_val) VALUES (?, ?, ?, ?, ?)");

$inst2->bind_param("sssss", $intro_id, $direct_com2, $p_tp,$date,$date_val);

$inst2->execute();

$quryin2=$mysqli->prepare("select ewallet,ewallet_in  from member where member_id=?");

$quryin2->bind_param("s", $intro_id);

$quryin2->execute();

$quryin2->bind_result($ewallet,$ewallet_in);

while($quryin2->fetch())

{

$ewallet=$ewallet;

$ewallet_in=$ewallet_in;

}

$deduction=$direct_com2*10/100;
$now_ewallet=$ewallet+$direct_com2-$deduction;

$now_total_income=$total_income+$direct_com2;



$up_ewt2=$mysqli->prepare("update member set ewallet=?,ewallet_in=?,total_income=? where member_id=?");

$up_ewt2->bind_param('ssss', $now_ewallet,$now_ewallet,$now_total_income,$intro_id);

$up_ewt2->execute();

$new_bid=$_REQUEST['member_id'];




					while($new_bid!="ABCD1234")	



						{









												$prt_id="";

												$pos="";

												$qq=$mysqli->prepare("select parent_id,position from member where member_id=?");

													$qq->bind_param("s", $new_bid);

													$qq->execute();

													$qq->bind_result($parent_id,$position);

													while($qq->fetch())

													{

													$parent_id=$parent_id;

													 $pos=$position;

													}

													 $prt_id=$parent_id;

											$qq->close();



												$q2q=$mysqli->prepare("select direct_join,left_point,total_left_point,right_point,total_right_point,left_pv,right_pv,total_left_pv,total_right_pv,today_left,today_right from member where id=?");

													$q2q->bind_param("s", $prt_id);

													$q2q->execute();

													$q2q->bind_result($direct_join,$left_point,$total_left_point,$right_point,$total_right_point,$left_pv,$right_pv,$total_left_pv,$total_right_pv,$today_left,$today_right);

													while($q2q->fetch())


													{

													$dr_joint=$direct_join;
													$left_point=$left_point;
													$total_left_point=$total_left_point;
													$right_point=$right_point;
													$total_right_point=$total_right_point;
													$left_pv=$left_pv;
													$right_pv=$right_pv;
													$total_left_pv=$total_left_pv;
													$total_right_pv=$total_right_pv;
													$today_left=$today_left;
													$today_right=$today_right;
													
													

													

													 if($pos=="L")

														{







														$left_pt=$left_point+1;



														$total_left_pt=$total_left_point+1;

														

														$left_pv=$left_pv+$tot_pv;

														$total_left_pv=$total_left_pv+$tot_pv;

														





														$right_pt=$right_point;

														$total_right_pt=$total_right_point;

														

														$right_pv=$right_pv;

														$total_right_pv=$total_right_pv;
														
														$today_left=$today_left+$tot_pv;
													    $today_right=$today_right;
														
														
													

														





														}





													    if($pos=="R")

														{







														$left_pt=$left_point;



														$total_left_pt=$total_left_point;

														

														$left_pv=$left_pv;

														$total_left_pv=$total_left_pv;

														





														$right_pt=$right_point+1;

														$total_right_pt=$total_right_point+1;

														

														$right_pv=$right_pv+$tot_pv;

														$total_right_pv=$total_right_pv+$tot_pv;
														
														$today_left=$today_left;
													    $today_right=$today_right+$tot_pv;

														


														}

													}

													

													$q2q->close();

													

													$updat_mem=$mysqli->prepare("update member set total_left_point=?,total_right_point=?,left_point=?,right_point=?,total_left_pv=?,total_right_pv=?,left_pv=?,right_pv=?,today_left=?,today_right=? where id=?");

			$updat_mem->bind_param('sssssssssss', $total_left_pt,$total_right_pt,$left_pt,$right_pt,$total_left_pv,$total_right_pv,$left_pv,$right_pv,$today_left,$today_right,$prt_id);

			$updat_mem->execute();

			$updat_mem->close();

													



														

//$member_idd="";



$qq3=$mysqli->prepare("select member_id from member where id=?");

													$qq3->bind_param("s", $prt_id);

													$qq3->execute();

													$qq3->bind_result($member_id);

													while($qq3->fetch())

													{

													 $member_idd=$member_id;

													

													}

												

												





										 $new_bid=$member_idd;

										//echo "<br>";



$qq3->close();



										}



$member_id=$_REQUEST['member_id'];

$total=$_REQUEST['total'];

$value_coup=$tot_pv/250;

$coupon_value=intval($value_coup);

if($coupon_value==1){$no_of_coupon=20;}
if($coupon_value==2){$no_of_coupon=40;}
if($coupon_value==3){$no_of_coupon=40;}
if($coupon_value==4){$no_of_coupon=80;}
if($coupon_value>4){$no_of_coupon=80;}

for($kk=1;$kk<=$no_of_coupon;$kk++)
{
$characters=5;
$possible = 'ABCDEFGHIJKLMNPQRSTUVWXYZ';
$code = '';
$ii = 0;
while ($ii < $characters) 
{ 
$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
$ii++;
}

$amt=25;

$coupon=$code.$member_id;

$instc=$mysqli->prepare("insert into coupon_details (member_id, coupon_no,amount) VALUES (?, ?, ?)");

$instc->bind_param("sss", $member_id, $coupon,$amt);

$instc->execute();
}


$quryin=$mysqli->prepare("select coupon_wallet,no_coupon  from member where member_id=?");

$quryin->bind_param("s", $member_id);

$quryin->execute();

$quryin->bind_result($coupon_wallet,$no_coupon);

 while($quryin->fetch())

{

$coupon_wallet=$coupon_wallet;
$no_coupon=$no_coupon;


}

$add_coupon=$no_of_coupon;
$amount=25*$no_of_coupon;
$nwallt=$coupon_wallet+$amount;
$now_cpno=$no_coupon+$add_coupon;


$up_lvl1=$mysqli->prepare("update member set coupon_wallet=?,no_coupon=? where member_id=?");

$up_lvl1->bind_param('sss', $nwallt,$now_cpno,$member_id);

$up_lvl1->execute();












										





								







								











							







$pv=$tot_pv;										







$sts="n";







 $qq_spot2 = $mysqli->prepare('SELECT * FROM bv_business_resale where status=?');







  $qq_spot2->bind_param('s',$sts);







						$qq_spot2->execute();







						$qq_spot2->store_result();







						$no_spot2=$qq_spot2->num_rows;































	if($no_spot2!=0)







		 {







		 







		 $qq_spot3 = $mysqli->prepare("select total_bv,total_amt from bv_business_resale where status=?");







          $qq_spot3->bind_param('s',$sts);







          $qq_spot3->execute();







		   $qq_spot3->bind_result($total_bv,$total_amt);







		  while ($qq_spot3->fetch())







           {







            $total_bv=$total_bv;
			$total_amt=$total_amt;

			}















		   $sts="n";







		   $sp_amt2=$total_bv+$pv;
		   $total_amt2=$total_amt+$total;






		   $up_spot2=$mysqli->prepare("update bv_business_resale set total_bv=?,total_amt=? where status=?");

			$up_spot2->bind_param('sss', $sp_amt2,$total_amt2, $sts);















			$up_spot2->execute();







		   







		







		 }







		 else







		 {







		    







		    







			







			$inst2=$mysqli->prepare("insert into bv_business_resale (total_bv,total_amt) VALUES (?, ?)");


	$inst2->bind_param("ss", $pv,$total);

$inst2->execute();







		 }







//---------------------------------	 











	



$sts="n";







 



		 







		//---------------------------------	 







$member_id=$_REQUEST['member_id'];	



















								























										







										$sts="n";



$total=$_REQUEST['total'];



 $qq_spots2 = $mysqli->prepare('SELECT * FROM stock_business where status=? and stock_id=?');







  $qq_spots2->bind_param('ss',$sts,$stock_id);







						$qq_spots2->execute();







						$qq_spots2->store_result();







						$no_spots2=$qq_spots2->num_rows;















		 







		 







		 if($no_spots2!=0)







		 {







		 







		 $qq_spot3 = $mysqli->prepare("select business,bv from stock_business where status=? and stock_id=?");







          $qq_spot3->bind_param('ss',$sts,$stock_id);







          $qq_spot3->execute();







		   $qq_spot3->bind_result($business,$bv);







		  while ($qq_spot3->fetch())







           {







            $business=$business;


 $bv=$bv;




			







			}















		   $sts="n";







		   $curr_buss=$business+$total;

 $curr_bv=$bv+$tot_pv;





		  







		   







		   $up_spot2=$mysqli->prepare("update stock_business set business=?,bv=? where status=? and stock_id=?");















			$up_spot2->bind_param('ssss', $curr_buss,$curr_bv, $sts,$stock_id);















			$up_spot2->execute();







		   







		







		 }







		 else







		 {







		    







		    







			







			$inst2=$mysqli->prepare("insert into stock_business (business,stock_id,bv) VALUES (?,?,?)");















	$inst2->bind_param("sss", $total,$stock_id,$tot_pv);















$inst2->execute();







		 }







		 







		 //-----------







	$member_id=$_REQUEST['member_id'];







$qry=$mysqli->prepare("select name,mob from member where member_id=?");



$qry->bind_param("s", $member_id);



$qry->execute();



$qry->bind_result($name,$mob);



while($qry->fetch())



{



$name=$name;







$mob=$mob;



}









	$member_id=$_REQUEST['member_id'];







$total=$_REQUEST['total'];




$quryin2=$mysqli->prepare("select name,mob  from member where member_id=?");
								 $quryin2->bind_param("s", $member_id);
								 $quryin2->execute();
								  $quryin2->bind_result($name,$mob);
								  while($quryin2->fetch())
									{

									$name=$name;
									$mob=$mob;
									
									
									}

							

/*$mob="91".$mob;


$apiKey = urlencode('NjUzNzYyNTk2MzM3Nzk2MzU2NTQ2MzQ0NGM2YzY4NGI=');
	
	// Message details
	
	$numbers = array($mob);
	$sender = urlencode('MORLIF');
	
	
	 $msgtext="Congratulations! Dear ".$name." your purchase of worth Rs. ".$total." in MORLIFE HEALTHCARE PRIVATE LIMITED is successful. Please visit morlife.in for more details.";
	$message = rawurlencode($msgtext);
 
	$numbers = implode(',', $numbers);
 
	// Prepare data for POST request
	$data = array('apikey' => $apiKey, 'numbers' => $numbers, "sender" => $sender, "message" => $message);
 
	// Send the POST request with cURL
	$ch = curl_init('https://api.textlocal.in/send/');
	curl_setopt($ch, CURLOPT_POST, true);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	 $response = curl_exec($ch);
	curl_close($ch);*/



										 











										 







										 







 $_SESSION['msg_box']="<a href=# class=close><img src=resources/images/icons/cross_grey_small.png title=Close this notification alt=close /></a>







				<div>







					New Purchase Added Successfully.







				</div>";







 $_SESSION['class_notification']="notification success png_bg";	







header("location:first_sale.php?tab_id=tab1&default=first_sale&action=voucher&member_id=$member_id&bill_no=$bill_no");























}



}



?>