<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<?php
ob_start();
ini_set('session.bug_compat_warn', 0);
ini_set('session.bug_compat_42', 1);

 include("db.php");
 include("../pdate.php");
 echo $get_id=$_GET['editID'];
 echo "<br>";
 echo $table=$_GET['table'];
 
    
    
     echo $customerRetriveSql="select * from $table  where id='$get_id'";
	 $customerRetriveQuery=$db ->query($customerRetriveSql);
	 $customerRetriveRow=$customerRetriveQuery ->fetch_array();
	 $id_retrive=$customerRetriveRow['id'];
	 $dateretrive=$customerRetriveRow['date'];
	 $counterCurrency_retrive=$customerRetriveRow['counterCurrency'];
	 $rate_retrive=$customerRetriveRow['rate'];
	  
	  
	 
	   
?>  
<html>
<head>
	<title>ویـرایـش ارز خـریداری شـده</title>
	 
	<link rel="stylesheet" type="text/css" href="../css/style.css">
   <script src="dist/sweetalert-dev.js"></script>
  <link rel="stylesheet" href="dist/sweetalert.css"> 
  
<!---==========================================================================-->
 
 <script type="text/javascript" src="../js/decimal.js"></script>
 <script type="text/javascript" src="../js/NumberFormat.js"></script>
<!---==========================================================================-->
<link href="css/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery-1.5.2.min.js"></script>
<script type="text/javascript" src="../js/jquery.autocomplete.pack.js"></script>
<script type="text/javascript" src="../js/script.js"></script>
<!---==========================================================================-->
<!--========================================================================-->
 
   
</head>
<body onload="assetCash();dollarPrice();calculateDollar();findingcalculation();customerBalance();findCash();get_amount();calculate();assetCash()">

	<div id="wrap">
		 
		<div id="contentt">
			 
			<div id="menu">
				 
			</div>
		    <div id="matlab" >
			<div id="title"><p>ویـرایـش ارز خـریداری شـده</p> </div>
			<div id="picture">
					<table border="0" width="400px">
						<tr>
							<td style="width:180px;"><img src="../img/currency_edit.png" width="150px" height="120px">  </td>
							<td > </td>
						</tr>
					</table>
			   </div>
		    	<form method="post" action="" name="form">
               <table border="0"   id="rgistera_cart" width="800px" class="font">
		    		<tr>
						<td style="width:190px">&nbsp;</td>
		    			<th style="width:150px">تاریخ </th>
						<td style="width:250px" >
							<input type="text" name="date" id="newdate" placeholder="" class="form-control" value="<?php echo $dateretrive;?>"/>
							<input type="hidden" name="customerId" id="customerId"   class="form-control" value="<?php echo $customerId_retrive  ;?>"/>
						</td>
						<td style="width:280px;">
							 
						 </td>
		    		</tr>
					<tr>
						<td style="width:190px">&nbsp;</td>
		    			<th style="width:150px">ارزش</th>
						<td style="width:250px" >
							<input type="text" style="padding-right: 1px" disabled   value="1" class="form-control"   />
							 
						</td>
						 
		    		</tr> 
					<tr>
						<td style="width:190px">&nbsp;</td>
		    			<th style="width:150px">ارز پـایـه</th>
						<td style="width:250px" >
							<input type="text" style="padding-right: 1px" disabled   value="دالر" class="form-control"   />
							 
						</td>
						 
		    		</tr> 
					 
					<tr>
						<td style="width:190px">&nbsp;</td>
		    			<th style="width:150px">ارز مورد معاوضه</th>
						<td style="width:250px" >
						 <select name="counterCurrency"  id='counterCurrency'  style="width:100%" onchange="dollarPrice();get_amount();findingCounterCurrency();calculate()" onclick="get_amount();findingCounterCurrency();calculate();dollarPrice()">
							<?php
						 
							$sql="select * from currencies";
							$query=$db ->query($sql);
							while($row=$query ->fetch_array()){
							$id=$row['id'];
							$name=$row['name'];
							//echo "<option value='$id'>$name</option>";

                            if($counterCurrency_retrive == $row['id']){
								echo "<option value=$row[id] selected>$row[name] </option>";
								}else{
								    echo "<option value=$row[id]>$row[name]</option>";
								}


							
							}
							echo "</select>";
														
							?>
						 
						 </td>
						 
		    		</tr>
					<tr>
						<td style="width:190px">&nbsp;</td>
		    			<th style="width:150px">نرخ ارز پایه دربرابر ارز مورد معاوضه</th>
						<td style="width:250px" >
							<input type="text" name="counterAmount" autocomplete="off" onkeyup="addSeparator(this)" id="counterAmount"   value="<?php echo $rate_retrive ?>"/>
							 
						</td>
						 
		    		 
					</tr>
						 
					 
					<tr>
						<td style="width:190px">&nbsp;</td>
		    			<th style="width:150px"> </th>
						<td style="width:230px"> 
						    <input type="submit" id="save"   name="save"  value="ذخیره">
							<input type="submit" id="back"   name="back"  value="انصراف">
							
						</td>
						<td style="width:300px;"> </td> 
		    		</tr>
                    
		    	</table>
		    	 
				</form>
		    </div>


		</div>
		 
	</div>
</body>
</html>
<?php
if($_POST['back']){
  header("location:../currencyRate.php");
}
if($_POST['save']){
   
  
//===============================================
   $date=$_POST['date'];
   $counterAmount=$_POST['counterAmount'];
   $updateCurrencyRate_Sql="update crrencyrate set rate='$counterAmount' where id='$get_id'";
   $updateCurrencyRate_Query= $db ->query($updateCurrencyRate_Sql);
 
  
   //header("location:../currencyRate.php");		
   header("location:../$page");		

}



?>