<?php

  include("db.php");
  include("pdate.php");
   $date=pdate("Y-m-d");
   
  $takeAssets_sql="select * from assets  ";
  $takeAssets_query= $db ->query($takeAssets_sql);
  while($takeAssets_row=$takeAssets_query ->fetch_array()){
	  
	$takeAssets_amount=$takeAssets_row['amount'];
    	
	$takeAssets_currencies_id=$takeAssets_row['currencies_id'];
    	
	 $takeAssets_dollarAmount=$takeAssets_row['dollarAmount']; 
     	
	$takeAssets_bank_id=$takeAssets_row['bank_id']; 
     	
	$takeAssets_date=$takeAssets_row['date'];  
	   
	$assets_sql="select * from assets_report where date='$date' and currencies_id='$takeAssets_currencies_id'";
	 
    $assets_query= $db ->query($assets_sql);
	$assets_row=$assets_query ->fetch_array(); 
	$amount=$assets_row['amount']; 
	$currencies_id=$assets_row['currencies_id']; 
	$asset_date=$assets_row['date']; 
	 
	if(isset($asset_date)){
     $update_sql="update assets_report set amount='$takeAssets_amount',currencies_id='$takeAssets_currencies_id',date='$date' where date='$date' and currencies_id='$takeAssets_currencies_id'";
     $update_query =$db ->query($update_sql);
	}	
	if(!isset($asset_date)){

     $insert_sql="insert into assets_report (amount,currencies_id,date) 
	 values('$takeAssets_amount','$takeAssets_currencies_id','$date')";
	 $insert_query=$db ->query($insert_sql);
	  
	}	
	} 
	  
	  
  

?>