	
    <select id="product1" name="product1" data-placeholder="اختر" class="chzn-select aw_m1 chosenproduct" tabindex="7">
    
								<option value="-1"></option>
                              
							{foreach $productData as $product}
								
				<option value="{$product->productid}">{$product->productName} </option>
								
	 						{/foreach}
                              
								</select>
                                
                                
    
    <script>
	$(document).ready(function(e) {
      // here the frist action on frist dropdownlist
	/************************/
	$("#product1").chosen().change( function() {
		
	  //here get the price of product from ajax
	  //the selected value of drop downlsit
	  var theselectedvalue = $(this).val();
	  
	   var storeid = document.getElementById("storeid").value;
		
	  //using the load method to load the price	
	  $("#productunitdiv1").html('<img src="../views/default/images/loader/6.gif" alt="">');		  
	
		 
		  
		   //using the load method to load the product Unit	
		   $('#productunitdiv1').load(''+productpricepagename+'?do=getunit&itrs=1&tabindex=7&productid='+theselectedvalue+'',function() {
			 
			   $("#addunit").empty();
		 $("#productunitdiv1 option").clone().appendTo("#addunit");
		 
			 
			   //using the load method to load the parcode
			    $('#productparcode1').load(''+productpricepagename+'?do=getparcode&itrs=1&tabindex=7&productid='+theselectedvalue+'',function() {
			   
		
		  
		  //here all code that will happend with loading contants
		  //the number of rows of products
		  var noitr = document.getElementById("hidden_itr").value;
		  
		   document.getElementById("proprice1").value=0;
		  document.getElementById("pronum1").value=1;
		  document.getElementById("prodis1").value=0;
	
		  
			
	 //***** get the total of product *****
		 // calcuproduct(1);
		  
		 var price = Number(document.getElementById("proprice1").value);
		var amount =Number(document.getElementById("pronum1").value);
		var pricebefore = price * amount ;
		
		var discountbefore = document.getElementById("prodis1").value;
		
		if(discountbefore > pricebefore)
		{
			document.getElementById("prodis1").value=pricebefore;
			var discountbefore = Number(document.getElementById("prodis1").value);
		}
		
		//var discountnum = discountbefore / 100 ;
		//var discount  = pricebefore * discountnum;
		var totalprice = pricebefore - discountbefore;
		document.getElementById("hidden_prototal1").value = totalprice;
		$("#prototal1").html(totalprice);
	//********************************************//
		
		  
		  
		  
		  
		  
		  
		  
		 //***** get the total price of product ********
		 // totalprice(noitr);
		  
		  // varaible that will carry total price
		var thealltotal ="";
		
		//loop to sum the all prices
		for($x=1; $x<=noitr; $x++)
		{
			var numco = $x;
			var inputname = "#hidden_prototal"+numco ;
			
			//to make sure that all input is created
			if ($("#hidden_prototal"+numco).length == 0)
			{
			  continue;
			}
			else
			{
			  // sum method
			  thealltotal = Number(thealltotal) +  Number(document.getElementById("hidden_prototal"+numco).value)
			  $("#gentotal").html(thealltotal);
			  
			  /////////////////////add by sara ////
			  document.getElementById("sellbilltotalbill").value=thealltotal;
			  
			}
		}
		//insert the value in div
		$("#gentotal").html(thealltotal);
		
		/////////////////////add by sara ////
		document.getElementById("sellbilltotalbill").value=thealltotal;
		//********************************************//
		
		
		
		
		  
		//******** get the general discount *****************
		 // thegeneraldiscount();
		  
		  //calculate the dicount
		var genetalprice = $("#gentotal").html();
		var generaldiscount = document.getElementById("gendis").value;
		
		
		////////////////add by sara////////////////////////////
		if(generaldiscount > 100)
		{
			document.getElementById("gendis").value=100;
			var generaldiscount = document.getElementById("gendis").value;
		}
		///////////////////////end/////////////////////////////
		
		
		var resultdiscountbefore = generaldiscount / 100;
		var resultdiscount = resultdiscountbefore * genetalprice;
		var netprice = genetalprice - resultdiscount;
		$("#gen2total").html(netprice);
		
		/////////////////////add by sara ////
		document.getElementById("sellbillaftertotalbill").value=netprice;
		
		//********************************************//
			
			
			
			
		//******** get the general discount *****************	
		var netpriceto = $("#gen2total").html();//الصافى
		var generalpayedto = document.getElementById("genpay").value;//المدفوع
		var generaldiscountto = document.getElementById("gendis").value;//الخصم
		var genetalpriceto = $("#gentotal").html();//قيمة الفاتورة
		
		if(generaldiscountto > 0)
		{
			if(Number(generalpayedto) > Number(netpriceto))
			{
				document.getElementById("genpay").value=netpriceto;
			}
		}
		else
		{
			if( Number(generalpayedto) >  Number(genetalpriceto))
			{
				document.getElementById("genpay").value=genetalpriceto;
			}
		}
			//********************************************//
			
			
				
			
		  
		// *************** get the general payed ***********
		 // thegeneralpayed();
		  
		  var netprice = $("#gen2total").html();
		var generalpayed = document.getElementById("genpay").value;

		var resultpayed = netprice - generalpayed;
		$("#gen3total").html(resultpayed);
		
		//********************************************//
		
		  
		  
		  
		  
		  
		  
		  
	//************** calculate the rest of debt ***********
		  //therestofdebt();
		  
		 
			var generalpayed = document.getElementById("genpay").value;
			var debt = document.getElementById("hidden_debt").value;
			var resultpayed = $("#gen3total").html();
			var therestdebt = Number(debt) +Number(resultpayed) ;
			$("#gen4total").html(therestdebt);

			/////////////////////add by sara ////
		document.getElementById("clientdebtafter").value=therestdebt;
		
		
	//********************************************//

	//daiable price  type
	$('#pricetype').attr("disabled", "disabled"); 
	$("#pricetype").trigger('liszt:updated');
	
	
	document.getElementById("hiddenpricetype").value=document.getElementById("pricetype").value;

	//********************************************//

		  //load the jquery checker for number only
		//  $.getScript('../views/default/js/head_scripts.js');
		  
		   //$('select').chosen();
				});
		   });
	  
	 
		  
	});
	/************************/
    });
	</script>                            