<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<?php
 include("db.php");
 include("pdate.php");
 $date=date("Y-n-j");
  
 //$date = "1998-08-14";
$newdate = strtotime ( '-1 day' , strtotime ( $date ) ) ;
 $newdate = pdate ( 'Y-m-d' , $newdate ); 
 
	//select database name from file
$file_db = fopen("database_name.txt","r+");
$fname = fgets($file_db);
// sleect from database 
 
?>  
<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">  
  <style>
   body{
	   
	font-size: 22px;   
   }
  
  </style>
</head>
<body>

	<div id="wrap">
		 
		<div id="contentt">
			 
			<div id="menu">
				<?php  //include("menu.php") ;   ?>
			</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/mony.png" width="150px" height="120px">  </td>
							<td > </td>
						</tr>
					</table>
			   </div>
		    	<form method="post" action="assetRegistrationCheck_insertion.php">
               <table border="1"   cellpadding="0" cellspacing="0" dir="rtl"  width="800px"   style="margin: auto">
				
				<tr style='border: 1px solid #000'>
					<th colspan='5' style='text-align: center;padding: 5px;background: silver'>  
						<span style='color: blue;'>قیمـــت گــذاری پــــولهـا</span> 
						<br>
					 <?php if($old=="old"){ echo "<span style='color:red'>  شما وارید دوره قبلی شده اید و نمی توانید  اطلاعات ثبت کنید</span>";} ?>
						</br>
						<span style='color: green'><?php echo $newdate?> </span> 
					</th></tr><tr style='border: 1px solid #000'>
					<th style='text-align: center;height: 30px;background: silver'>شماره</th> 
					<th style='text-align: center;background: silver'>نوعیت پـول</th> 
					<th style='text-align: center;background: silver'>مقدار</th>  
					<th style='text-align: center;background: silver'>نرخ</th> 													
				</tr>
				<tr>
					<?php
						
                     //==============Checking============================
					      $check_Asset_sql="select * from dailyasset where date='$newdate'";
                          $check_Asset_Query=$db ->query($check_Asset_sql);
						  $check_Asset_Row=$check_Asset_Query ->fetch_array();
						  $check_Asset=$check_Asset_Row['amount'];
                         if(isset($check_Asset)){

                              header("location:index.php");
						}						 
                        else{
					//==============Checking============================

                    						
					 
					$assetBalanceSql="select * from assets where amount!=0";
					$assetBalanceQuery= $db ->query($assetBalanceSql);
					$i=0;
				   while($assetBalanceRow=$assetBalanceQuery ->fetch_array()){
																  
						$amount=$assetBalanceRow['amount'];
						$currencies_id=$assetBalanceRow['currencies_id'];
						$dollarAmount=$assetBalanceRow['amount'];
						//============================================
						$currencyName_sql="select * from currencies where id='$currencies_id' and remove=0";
						$currencyName_query= $db ->query($currencyName_sql);
						$currencyName_row=$currencyName_query ->fetch_array();
						$currencyName=$currencyName_row['name'];
					   //============================================
																
						$i++;
																  
						echo"<td>$i</td>";
						echo"<td>
								<input style='border: 0px;background: #fff'  disabled  type='text' value='$currencyName'     >
								<input type='hidden' name='currencyId[]' value='$currencies_id'>
								<input type='hidden' name='date' value='$newdate'>
							</td>";
						echo"<td>
								<input style='border: 0px;background: #fff' disabled value=".number_format($dollarAmount,2) ." style='width:100%'   >
								<input type='hidden' name='amount[]' value='$dollarAmount'>
							</td>";		   
							echo"<td><input style='border: 0px' type='text' name='rate[]'  style='width:100%'  ></td>";
																  
																 
					echo "<tr>";
																
																 
															
				}
					$i= $i ;
					 echo "<input type='hidden' name='length' value='$i'  style='width:100%' >";
			
			}
			?>
			</tr>
			</table>
			<table border="0"    dir="rtl"  width="800px" class="font" style="margin: auto">
				
			 <tr>
			    <td style="width:230px"> 
				<input type="submit" id="save"   <?php if($old=="old") echo "disabled"; ?>  name="save"  value="ذخیره">
				<input type="submit" id="back"   name="back"  value="انصراف">
							
			    </td>
			 
			 </tr>
			</table>
		    	 
				</form>
		    </div>


		</div>
		 
	</div>
</body>
</html>
 