<?php
session_start();
include("today_date.php");
include("jdf.php");
include("db.php");
if (isset($_SESSION['username']) && isset($_SESSION['password'])) {

include("checking_word.php");
$page_title = "معاملات روزانه -خریداری";	
$targetAddress="dailyTransactionsale.php";	

	 //گرفتن تاریخ روز و تبدیل به یک روز عقب
$totady=$today_date_miladi;

$otherDate=strtotime($totady);

$finding=$otherDate-86400;

$yesterday=$jalali_date = jdate("Y-m-d", $finding);
   
//====================================================
//===============تاریخ روز
 $pdate1=jdate("Y-m-d", strtotime($totady));
 
//select database name from file
$file_db = fopen("database_name.txt","r+");
$fname = fgets($file_db);
//fclose($fname);
// sleect from database 
 
  //موجودی دخل کنونی
	    //dollar (2)
	       $assets_dollar_sql="select  * from assets where currencies_id='2'  ";
	       $assets_dollar_query= $db ->query($assets_dollar_sql);
		   $assets_dollar_row=$assets_dollar_query ->fetch_array(); 
		   $assets_dollar_amount=$assets_dollar_row['amount'];
		    
	 //afghani (1)
	       $assets_af_sql="select  * from assets where currencies_id='1'  ";
	       $assets_af_query= $db ->query($assets_af_sql);
		   $assets_af_row=$assets_af_query ->fetch_array(); 
		   $assets_af_amount=$assets_af_row['amount'];
		   
	 //toman (5)
	       $assets_toman_sql="select  * from assets where currencies_id='5'  ";
	       $assets_toman_query= $db ->query($assets_toman_sql);
		   $assets_toman_row=$assets_toman_query ->fetch_array(); 
		   $assets_toman_amount=$assets_toman_row['amount'];
		    
		  
	 //Pakistan (4)
	       $assets_pakistn_sql="select  * from assets where currencies_id='4'  ";
	       $assets_pakistan_query= $db ->query($assets_pakistn_sql);
		   $assets_pakistan_row=$assets_pakistan_query ->fetch_array(); 
		   $assets_pakistan_amount=$assets_pakistan_row['amount'];
		   
	 //Euro (3)
	       $assets_euro_sql="select  * from assets where currencies_id='3'  ";
	       $assets_euro_query= $db ->query($assets_euro_sql);
		   $assets_euro_row=$assets_euro_query ->fetch_array(); 
		   $assets_euro_amount=$assets_euro_row['amount'];
//================================================================================================
 //*************************مجموع امد افغانی*****************//          
		  //afghani recive
		        $af_recive_sql="SELECT sum(amount) FROM `customerpayment` where remove='0' and  transacttype='1'  and transactCurrency='1' and date='$pdate1'"; 
                $af_recive_query= $db ->query($af_recive_sql);
				$af_recive_row=$af_recive_query ->fetch_array();
				$af_recive=$af_recive_row['sum(amount)'];
			//خریداریهای افغانی
				$afBuy_sql="select sum(counterAmount) from transaction where counterCurrency='1' and date='$pdate1' and remove='0' and treatment='1' and extra='0'  ";
				$afBuy_query=$db ->query($afBuy_sql);
				$afBuy_row=$afBuy_query ->fetch_array();
				$afBuy=$afBuy_row['sum(counterAmount)'];		
				 
            //اضافه شدن از فروش سایر پولها به افغانی
				$ezafe_AF_azfrosh_sql="select sum(baseAmount) from transaction where baseCurrency='1' and date='$pdate1' and remove='0' and treatment='2' and extra='0'  ";
				$ezafe_AF_azfrosh_query=$db ->query($ezafe_AF_azfrosh_sql);
				$ezafe_AF_azfrosh_row=$ezafe_AF_azfrosh_query ->fetch_array();
				$ezafe_AF_azfrosh=$ezafe_AF_azfrosh_row['sum(baseAmount)'];		
				
				//اضافه شده به افغانی از بخش درامدهای متفرقه
				$totalIncome_sql="select sum(amount) from others where currencyId='1' and  typeOthers='2' and date='$pdate1' and remover='0'    ";
				$totalIncome_query=$db ->query($totalIncome_sql);
				$totalIncome_row=$totalIncome_query ->fetch_array();
				$totalIncome=$totalIncome_row['sum(amount)'];	
				
				$avordegi_AF=$af_recive+$afBuy+$ezafe_AF_azfrosh+$totalIncome;
            //*************************انتهای مجموع امد از افغانی*****************//          
            //---------------------------------------------------------------------
			//******** مجموع از رفته افغانی*************************************		
			//afghani payment
		        $af_payment_sql="SELECT sum(amount) FROM `customerpayment` where remove='0' and  transacttype='2'  and transactCurrency='1' and date='$pdate1'"; 
                $af_payment_query= $db ->query($af_payment_sql);
				$af_payment_row=$af_payment_query ->fetch_array();
				$af_payment=$af_payment_row['sum(amount)'];
			//خریداری از پول افغانی(کم شدن از افغانی)
				$afSales_sql="select sum(baseAmount) from transaction where baseCurrency='1' and date='$pdate1' and remove='0'  and extra='0' and treatment='1' ";
				$afSales_query=$db ->query($afSales_sql);
				$afSales_row=$afSales_query ->fetch_array();
				$afSales=$afSales_row['sum(baseAmount)'];
             //فروش از افغانی				
 			    $frosh_as_AF_sql="select sum(counterAmount) from transaction where counterCurrency='1' and date='$pdate1' and remove='0' and treatment='2' and extra='0'  ";
				$frosh_as_AF_query=$db ->query($afBuy_sql);
				$frosh_as_AF_row=$afBuy_query ->fetch_array();
				$frosh_as_AF=$afBuy_row['sum(counterAmount)'];	
			 //پرداخت مصارف ازافغانی
				$totalExpenses_sql="select sum(amount) from others where currencyId='1' and  typeOthers='1' and date='$pdate1' and remover='0'    ";
				$totalExpenses_query=$db ->query($totalExpenses_sql);
				$totalExpenses_row=$totalExpenses_query ->fetch_array();
				$totalExpenses=$totalExpenses_row['sum(amount)'];	
				 
			    $bordegi_AF=($af_payment+$afSales+$frosh_as_AF+$totalExpenses); 
				 
			//================================================================================================
          //*************************مجموع امد دالر*****************//          
		  //dollar recive
		        $dollar_recive_sql="SELECT sum(amount) FROM `customerpayment` where remove='0' and  transacttype='1'  and transactCurrency='2' and date='$pdate1'"; 
                $dollar_recive_query= $db ->query($dollar_recive_sql);
				$dollar_recive_row=$dollar_recive_query ->fetch_array();
				$dollar_recive=$dollar_recive_row['sum(amount)'];
			    
			//خریداری های دلار	
			    $dollarBuy_sql="select sum(counterAmount) from transaction where counterCurrency='2' and date='$pdate1' and remove='0' and treatment='1' and extra='0'";
		    	$dollarBuy_query=$db ->query($dollarBuy_sql);
				$dollarBuy_row=$dollarBuy_query ->fetch_array();
				$dollarBuy=$dollarBuy_row['sum(counterAmount)'];
                				
            //اضافه شدن از فروش سایر پولها به افغانی
				$ezafe_dollar_azfrosh_sql="select sum(baseAmount) from transaction where baseCurrency='2' and date='$pdate1' and remove='0' and treatment='2' and extra='0'  ";
				$ezafe_dollar_azfrosh_query=$db ->query($ezafe_dollar_azfrosh_sql);
				$ezafe_dollar_azfrosh_row=$ezafe_dollar_azfrosh_query ->fetch_array();
				$ezafe_dollar_azfrosh=$ezafe_dollar_azfrosh_row['sum(baseAmount)'];		
				 //اضافه شدن به دالر از بخش درامدهای متفرقه 
				 
				$totalIncome_dollar_sql="select sum(amount) from others where currencyId='2' and  typeOthers='2' and date='$pdate1' and remover='0'    ";
				$totalIncome_dollar_query=$db ->query($totalIncome_dollar_sql);
				$totalIncome_dollar_row=$totalIncome_dollar_query ->fetch_array();
				$totalIncome_dollar=$totalIncome_dollar_row['sum(amount)'];	 
				 
				$avordegi_dollar=$dollar_recive+$dollarBuy+$ezafe_dollar_azfrosh+$totalIncome_dollar;
				 
            //*************************انتهای مجموع امد از افغانی*****************//          
            //---------------------------------------------------------------------
			//******** مجموع از رفته دالر*************************************		
			 
				//dollar payment
		        $dollar_payment_sql="SELECT sum(amount) FROM `customerpayment` where remove='0' and  transacttype='2'  and transactCurrency='2' and date='$pdate1'"; 
                $dollar_payment_query= $db ->query($dollar_payment_sql);
				$dollar_payment_row=$dollar_payment_query ->fetch_array();
				$dollar_payment=$dollar_payment_row['sum(amount)'];
			//خریداری از دلار وکم شدن از دلار
				$dollar_Sales_sql="select sum(baseAmount) from transaction where baseCurrency='2' and date='$pdate1' and remove='0'  and extra='0' and treatment='1' ";
				$dollar_Sales_query=$db ->query($dollar_Sales_sql);
				$dollar_Sales_row=$dollar_Sales_query ->fetch_array();
				$dollar_Sales=$dollar_Sales_row['sum(baseAmount)'];
             //فروش دلار				
 			    $frosh_dollar_sql="select sum(counterAmount) from transaction where counterCurrency='2' and date='$pdate1' and remove='0' and treatment='2' and extra='0'  ";
				$frosh_dollar_query=$db ->query($frosh_dollar_sql);
				$frosh_dollar_row=$frosh_dollar_query ->fetch_array();
				$frosh_dollar=$frosh_dollar_row['sum(counterAmount)'];
 				
                //پرداخت مصارف از دالر
				$totalExpenses_dollar_sql="select sum(amount) from others where currencyId='2' and  typeOthers='1' and date='$pdate1' and remover='0'    ";
				$totalExpenses_dollar_query=$db ->query($totalExpenses_dollar_sql);
				$totalExpenses_dollar_row=$totalExpenses_dollar_query ->fetch_array();
				$totalExpenses_dollar=$totalExpenses_dollar_row['sum(amount)'];	 
				$bordegi_dollar=($dollar_payment+$dollar_Sales+$frosh_dollar+$totalExpenses_dollar); 
				
			//=========================================DOLLAR=============================================	
			
			//========================================END OF DOLLAR========================================	
			//========================================PAKISTANIN=========================================
			//================================================================================================
          //*************************مجموع امد کالدار*****************//          
		  //pakistan recive
		        $pak_recive_sql="SELECT sum(amount) FROM `customerpayment` where remove='0' and  transacttype='1'  and transactCurrency='4' and date='$pdate1'"; 
                $pak_recive_query= $db ->query($pak_recive_sql);
				$pak_recive_row=$pak_recive_query ->fetch_array();
				$pak_recive=$pak_recive_row['sum(amount)'];
			 
			//خریداریهای کالدار	
			    $pak_Buy_sql="select sum(counterAmount) from transaction where counterCurrency='4' and date='$pdate1' and remove='0' and treatment='1' and extra='0'";
		    	$pak_Buy_query=$db ->query($pak_Buy_sql);
				$pak_Buy_row=$pak_Buy_query ->fetch_array();
				$pak_Buy=$pak_Buy_row['sum(counterAmount)'];	
            //اضافه شدن از فروش سایر پولها به افغانی
            //اضافه شدن از فروش سایر پولها به کالدار
				$ezafe_pak_azfrosh_sql="select sum(baseAmount) from transaction where baseCurrency='4' and date='$pdate1' and remove='0' and treatment='2' and extra='0'  ";
				$ezafe_pak_azfrosh_query=$db ->query($ezafe_pak_azfrosh_sql);
				$ezafe_pak_azfrosh_row=$ezafe_pak_azfrosh_query ->fetch_array();
				$ezafe_pak_azfrosh=$ezafe_pak_azfrosh_row['sum(baseAmount)'];		
			//اضافه شدن به کالدار از بخش درآمدهای متفرقه
				$totalInomce_pakistan_sql="select sum(amount) from others where currencyId='4' and  typeOthers='2' and date='$pdate1' and remover='0'    ";
				$totalInomce_pakistan_query=$db ->query($totalInomce_pakistan_sql);
				$totalInomce_pakistan_row=$totalInomce_pakistan_query ->fetch_array();
				$totalInomce_pakistan=$totalInomce_pakistan_row['sum(amount)'];	  
				
				$avordegi_pakistan=$pak_recive+$pak_Buy+$ezafe_pak_azfrosh+$totalInomce_pakistan;
            //*************************انتهای مجموع امد از کالدار*****************//          
            //---------------------------------------------------------------------
			//******** مجموعه رفت از کالدار*************************************		
			 
				//pakistan payment
		        $pakistan_payment_sql="SELECT sum(amount) FROM `customerpayment` where remove='0' and  transacttype='2'  and transactCurrency='4' and date='$pdate1'"; 
                $pakistan_payment_query= $db ->query($pakistan_payment_sql);
				$pakistan_payment_row=$pakistan_payment_query ->fetch_array();
				$pakistan_payment=$pakistan_payment_row['sum(amount)'];
				 
			//خریداری از کالدار و کم شدن از کالدار
				$pkistan_Sales_sql="select sum(baseAmount) from transaction where baseCurrency='4' and date='$pdate1' and remove='0'  and extra='0' and treatment='1' ";
				$pakistan_Sales_query=$db ->query($pkistan_Sales_sql);
				$pakistan_Sales_row=$pakistan_Sales_query ->fetch_array();
				$pakistan_Sales=$pakistan_Sales_row['sum(baseAmount)'];
				 
             //فروش کالدار			
 			    $frosh_pakistan_sql="select sum(counterAmount) from transaction where counterCurrency='4' and date='$pdate1' and remove='0' and treatment='2' and extra='0'  ";
				$frosh_pakistan_query=$db ->query($frosh_pakistan_sql);
				$frosh_pakistan_row=$frosh_pakistan_query ->fetch_array();
				$frosh_pakistan=$frosh_pakistan_row['sum(counterAmount)'];	
             //پرداخت مصارف از کالدار
				$totalExpenses_pakistan_sql="select sum(amount) from others where currencyId='4' and  typeOthers='1' and date='$pdate1' and remover='0'    ";
				$totalExpenses_pakistan_query=$db ->query($totalExpenses_pakistan_sql);
				$totalExpenses_pakistan_row=$totalExpenses_pakistan_query ->fetch_array();
				$totalExpenses_pakistan=$totalExpenses_pakistan_row['sum(amount)'];	  
				
				$bordegi_pakistan=($pakistan_payment+$pakistan_Sales+$frosh_pakistan+$totalExpenses_pakistan); 
				
			  
			//=================================================END OF PAKISTANIN==============================	
			//========================================TOMAMN=========================================
			//================================================================================================
          //*************************مجموع امد تومان*****************//          
		  //Toman recive
		        $toman_recive_sql="SELECT sum(amount) FROM `customerpayment` where remove='0' and  transacttype='1'  and transactCurrency='5' and date='$pdate1'"; 
                $toman_recive_query= $db ->query($toman_recive_sql);
				$toman_recive_row=$toman_recive_query ->fetch_array();
				$toman_recive=$toman_recive_row['sum(amount)'];
			 
			//خریداریهای تومان
			    $toman_Buy_sql="select sum(counterAmount) from transaction where counterCurrency='5' and date='$pdate1' and remove='0' and treatment='1' and extra='0'";
		    	$toman_Buy_query=$db ->query($toman_Buy_sql);
				$toman_Buy_row=$toman_Buy_query ->fetch_array();
				$toman_Buy=$toman_Buy_row['sum(counterAmount)'];	
            
            //اضافه شدن از فروش سایر پولها به تومان
				$ezafe_toman_azfrosh_sql="select sum(baseAmount) from transaction where baseCurrency='5' and date='$pdate1' and remove='0' and treatment='2' and extra='0'  ";
				$ezafe_toman_azfrosh_query=$db ->query($ezafe_toman_azfrosh_sql);
				$ezafe_toman_azfrosh_row=$ezafe_toman_azfrosh_query ->fetch_array();
				$ezafe_toman_azfrosh=$ezafe_toman_azfrosh_row['sum(baseAmount)'];		
			//اضافه شدن به تومان از بخش درآمدهای متفرقه
				$totaltoman_toman_sql="select sum(amount) from others where currencyId='5' and  typeOthers='2' and date='$pdate1' and remover='0'    ";
				$totaltoman_toman_query=$db ->query($totaltoman_toman_sql);
				$totaltoman_toman_row=$totaltoman_toman_query ->fetch_array();
				$totaltoman_toman=$totaltoman_toman_row['sum(amount)'];	  
				
				$avordegi_toman=$toman_recive+$toman_Buy+$ezafe_toman_azfrosh+$totaltoman_toman;
            //*************************انتهای مجموع امد از تومان*****************//          
            //---------------------------------------------------------------------
			//******** مجموع رفت از تومان*************************************		
			 
				//toman payment
		        $toman_payment_sql="SELECT sum(amount) FROM `customerpayment` where remove='0' and  transacttype='2'  and transactCurrency='5' and date='$pdate1'"; 
                $toman_payment_query= $db ->query($toman_payment_sql);
				$toman_payment_row=$toman_payment_query ->fetch_array();
				$toman_payment=$toman_payment_row['sum(amount)'];
			//خریداری از تومان و کم شدن از تومان
				$toman_Sales_sql="select sum(baseAmount) from transaction where baseCurrency='5' and date='$pdate1' and remove='0'  and extra='0' and treatment='1' ";
				$toman_Sales_query=$db ->query($toman_Sales_sql);
				$toman_Sales_row=$toman_Sales_query ->fetch_array();
				$toman_Sales=$toman_Sales_row['sum(baseAmount)'];
             //فروش تومان			
 			    $frosh_toman_sql="select sum(counterAmount) from transaction where counterCurrency='5' and date='$pdate1' and remove='0' and treatment='2' and extra='0'  ";
				$frosh_toman_query=$db ->query($frosh_toman_sql);
				$frosh_toman_row=$frosh_toman_query ->fetch_array();
				$frosh_toman=$frosh_toman_row['sum(counterAmount)'];	
                 //پرداخت مصارف از تومان
				$totalExpenses_toman_sql="select sum(amount) from others where currencyId='5' and  typeOthers='1' and date='$pdate1' and remover='0'    ";
				$totalExpenses_toman_query=$db ->query($totalExpenses_toman_sql);
				$totalExpenses_toman_row=$totalExpenses_toman_query ->fetch_array();
				$totalExpenses_toman=$totalExpenses_toman_row['sum(amount)'];	  
				
				$bordegi_toman=($toman_payment+$toman_Sales+$frosh_toman+$totalExpenses_toman); 
				
			 	
			//=================================================END OF PAKISTANIN==============================	
			//========================================Ero=========================================
			//================================================================================================
          //*************************مجموع امد یورو*****************//          
		  //Euro recive
		        $euro_recive_sql="SELECT sum(amount) FROM `customerpayment` where remove='0' and  transacttype='1'  and transactCurrency='3' and date='$pdate1'"; 
                $euro_recive_query= $db ->query($euro_recive_sql);
				$euro_recive_row=$euro_recive_query ->fetch_array();
				$euro_recive=$euro_recive_row['sum(amount)'];
			 
			//خریداریهای یورو
			    $euro_Buy_sql="select sum(counterAmount) from transaction where counterCurrency='3' and date='$pdate1' and remove='0' and treatment='1' and extra='0'";
		    	$euro_Buy_query=$db ->query($euro_Buy_sql);
				$euro_Buy_row=$euro_Buy_query ->fetch_array();
				$euro_Buy=$euro_Buy_row['sum(counterAmount)'];	
            
            //اضافه شدن از فروش سایر پولها به یورو
				$ezafe_euro_azfrosh_sql="select sum(baseAmount) from transaction where baseCurrency='3' and date='$pdate1' and remove='0' and treatment='2' and extra='0'  ";
				$ezafe_euro_azfrosh_query=$db ->query($ezafe_euro_azfrosh_sql);
				$ezafe_euro_azfrosh_row=$ezafe_euro_azfrosh_query ->fetch_array();
				$ezafe_euro_azfrosh=$ezafe_euro_azfrosh_row['sum(baseAmount)'];		
			//اضافه شدن به یورو از بخش درآمدهای متفرقه
				$totalIncome_euro_sql="select sum(amount) from others where currencyId='3' and  typeOthers='2' and date='$pdate1' and remover='0'    ";
				$totalIncome_euro_query=$db ->query($totalIncome_euro_sql);
				$totalIncome_euro_row=$totalIncome_euro_query ->fetch_array();
				$totalIncome_euro=$totalIncome_euro_row['sum(amount)'];	  
				
				$avordegi_euro=$euro_recive+$euro_Buy+$ezafe_euro_azfrosh+$totalIncome_euro;
            //*************************انتهای مجموع امد از تومان*****************//          
            //---------------------------------------------------------------------
			//******** مجموع رفت از یورو*************************************		
			 
				//euro payment
		        $euro_payment_sql="SELECT sum(amount) FROM `customerpayment` where remove='0' and  transacttype='2'  and transactCurrency='3' and date='$pdate1'"; 
                $euro_payment_query= $db ->query($euro_payment_sql);
				$euro_payment_row=$euro_payment_query ->fetch_array();
				$euro_payment=$euro_payment_row['sum(amount)'];
			//خریداری از یورو و کم شدن از یورو
				$euro_Sales_sql="select sum(baseAmount) from transaction where baseCurrency='3' and date='$pdate1' and remove='0'  and extra='0' and treatment='1' ";
				$euro_Sales_query=$db ->query($euro_Sales_sql);
				$euro_Sales_row=$euro_Sales_query ->fetch_array();
				$euro_Sales=$euro_Sales_row['sum(baseAmount)'];
             //فروش یورو		
 			    $frosh_euro_sql="select sum(counterAmount) from transaction where counterCurrency='3' and date='$pdate1' and remove='0' and treatment='2' and extra='0'  ";
				$frosh_euro_query=$db ->query($frosh_euro_sql);
				$frosh_euro_row=$frosh_euro_query ->fetch_array();
				$frosh_euro=$frosh_euro_row['sum(counterAmount)'];	
                 //پرداخت مصارف از یورو
				$totalExpenses_euro_sql="select sum(amount) from others where currencyId='3' and  typeOthers='1' and date='$pdate1' and remover='0'    ";
				$totalExpenses_euro_query=$db ->query($totalExpenses_euro_sql);
				$totalExpenses_euro_row=$totalExpenses_euro_query ->fetch_array();
				$totalExpenses_euro=$totalExpenses_euro_row['sum(amount)'];	  
				
				$bordegi_euro=($euro_payment+$euro_Sales+$frosh_euro+$totalExpenses_euro); 
				
				
	 		
	include("yesterday_assets_date_plagin.php");			
	include("today_assets_date_plagin.php");			
	 

?>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
 <style>
#hekmat_menu ul{
 list-style-type: none;
 margin: 0;
 padding: 0;
 overflow: hidden;
  
}
#hekmat_menu li  {
  float: right;

}
 #hekmat_menu li a  {
   display: block;
   color: white;
   text-align: center;
   padding: 14px 16px;
   text-decoration: none;
}
#hekmat_menu li a:hover{

  background:-color: #111;
   
}
.activeMenu{
	
	border: 0px solid #a1a1a1;
	padding: 10px;
	 background: #00bfff;
     border-radius: 25px;
	
}		

</style>
<title><?php echo $page_title;?></title>
<script>
   
function myconfirm()
{
    if(confirm('آیا اطلاعات را می خواهید به طور دائم پاک کنید؟'))
        return true;
    return false;
}
      
	   
  
	 </script>
	 <script>
  function bayerAmount(){
	    $('#buyerAmount').hide();
		$.post('retrivebuyeramount.php', {bCurrencyA:form.counterCurrency.value},
			function(output){
				$('#buyerAmount').html(output).fadeIn(10);
		})
	
	}	      
	   
   
      function get_amount(){
	    $('#rate').hide();
		$.post('retiverate.php', {
		   bCurrency:form.basecurrency.value, 
		   cCurrency:form.counterCurrency.value
		   },
			function(output){
				$('#rate').html(output).fadeIn(10);
		})
	
	}  
	   
    function findCash(){
	    $('#cash').hide();
		$.post('retiveCash.php', {
		   currencyId:form.basecurrency.value
		   },
			function(output){
				$('#cash').html(output).fadeIn(10);
		})
	
	} 
//====================================================================================
								//Dollar Price
//====================================================================================
   function dollarPrice(){
	    $('#dollarPrice').hide();
		$.post('retiveDollarrate.php', {
		   rateOfDollar:form.counterCurrency.value
		   },
			function(output){
				$('#dollarPrice').html(output).fadeIn(10);
		})
	
	} 

//====================================================================================	
	
	function calculate(){
	     insertval=setInterval("multipal()",1);
	    }
		function multipal(){
		 taraz_amount=document.getElementById('taraz_amount').value;
		 
		  amount_p  =document.getElementById('counterAmount').value;
		  var decimalCharacter = ".",
          regex = new RegExp("[\\d" + decimalCharacter + "]+", "g"),
          num_caldar=amount_p;
          var amount=+num_caldar.match(regex).join("");
		  
		  take_Mode=document.getElementById('mode').value; 
		  
		  if(take_Mode=="mode_1"){
			
		  rate_mixData=document.getElementById('rate_mixData').value; 
		  mixData=document.getElementById('mixData').value; 
		  takeData=mixData.split('/');
		  mainrate=takeData[0];
		  unit=takeData[1];
		  
		  var exactresult=amount/unit;
		    row=(exactresult*1)*(rate_mixData*1);
		    
			pourCalculation=row.toFixed(2);			
			  
		  }
		  
		  if(take_Mode=="mode_2"){
	      
		  rate_mixData=document.getElementById('rate_mixData').value; 
		  mixData=document.getElementById('mixData').value; 
		  takeData=mixData.split('/');
		  mainrate=takeData[0];
		  unit=takeData[1];
		  
		  var exactresult=amount/rate_mixData;
		    row=(exactresult*1)*(mainrate*1);
		    
			pourCalculation=row.toFixed(2);		  
			  
		  }
		  
		  
		  if(taraz_amount==null){document.getElementById('taraz_amount').value=0;}
		  pourCalculation=(pourCalculation*1)+(taraz_amount*1);
		 
		   document.getElementById('baceAmount').value=FormatNumberBy3(pourCalculation*1) ;
		   //document.getElementById('baceAmount').value= take_Mode ;
		    
		
		}
		//====================================================================================	
	
	function calculateDollar(){
	     insertval=setInterval("multipalDollar()",1);
	    }
		function multipalDollar(){
		 //dollarRatePrice=document.getElementById('dollarRatePrice').value;
		 amount_p  =document.getElementById('counterAmount').value;
		 var decimalCharacter = ".",
         regex = new RegExp("[\\d" + decimalCharacter + "]+", "g"),
         num_caldar=amount_p;
         var amount=+num_caldar.match(regex).join("");
		  
		  // نرخ قدیم
		  dollarmixData=document.getElementById('dollarmixData').value; 
		  dollartakeData=dollarmixData.split('/');
		  dollarmainrate=dollartakeData[0];
		  dollarunit=dollartakeData[1];
		  
		  var dollarexactresult=amount/dollarunit;
		  
		  totalDollar=(dollarexactresult*1)*(dollarmainrate*1);
		  findTotalDollar=totalDollar.toFixed(2); 
		  
		  document.getElementById('totalDollar').value=FormatNumberBy3(findTotalDollar);
		 
		/*  totalDollar=(dollarRatePrice*1)*(amount*1);
         findTotalDollar=totalDollar.toFixed(2);	  
		 document.getElementById('totalDollar').value=FormatNumberBy3(findTotalDollar*1);
		 */
		
		}
</script>
	 
<!--=========================================================-->
     <script src="js/jquery/jquery-1.4.1.min.js" type="text/javascript"></script>
	 <script src="js/validation.js"></script>
     <script src="dist/sweetalert-dev.js"></script>
     <link rel="stylesheet" href="dist/sweetalert.css">
     <link rel="stylesheet" href="css/screen.css" type="text/css"   />
	 <script type="text/javascript" src="js/decimal.js"></script>
     <script type="text/javascript" src="js/NumberFormat.js"></script>
<!--=========================================================-->
<!-- BEGIN GLOBAL MANDATORY STYLES -->
<link href="../../assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
<link href="../../assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css"/>
<link href="../../assets/global/plugins/bootstrap/css/bootstrap-rtl.min.css" rel="stylesheet" type="text/css"/>
<link href="../../assets/global/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css"/>
<link href="../../assets/global/plugins/bootstrap-switch/css/bootstrap-switch-rtl.min.css" rel="stylesheet" type="text/css"/>
<!-- END GLOBAL MANDATORY STYLES -->
<!-- BEGIN PAGE LEVEL PLUGIN STYLES -->
<link href="../../assets/global/plugins/bootstrap-daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css"/>
<!-- END PAGE LEVEL PLUGIN STYLES -->
<!-- BEGIN PAGE LEVEL PLUGIN STYLES -->
<link rel="stylesheet" type="text/css" href="../../assets/global/plugins/select2/select2.css"/>
<link rel="stylesheet" type="text/css" href="../../assets/global/plugins/datatables/extensions/Scroller/css/dataTables.scroller.min.css"/>
<link rel="stylesheet" type="text/css" href="../../assets/global/plugins/datatables/extensions/ColReorder/css/dataTables.colReorder.min.css"/>
<link rel="stylesheet" type="text/css" href="../../assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap-rtl.css"/>
<link href="../../assets/global/plugins/bootstrap-daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css"/>
<!-- END PAGE LEVEL PLUGIN STYLES -->
<!-- BEGIN PAGE LEVEL STYLES -->
<link rel="stylesheet" type="text/css" href="../../assets/global/plugins/select2/select2.css"/>
<!-- END PAGE LEVEL SCRIPTS -->
<!-- BEGIN THEME STYLES -->
<link href="../../assets/global/css/components-md-rtl.css" id="style_components" rel="stylesheet" type="text/css"/>
<link href="../../assets/global/css/plugins-md-rtl.css" rel="stylesheet" type="text/css"/>
<link href="../../assets/admin/layout/css/layout-rtl.css" rel="stylesheet" type="text/css"/>
<link id="style_color" href="../../assets/admin/layout/css/themes/darkblue-rtl.css" rel="stylesheet" type="text/css"/>
<link href="../../assets/admin/layout/css/custom-rtl.css" rel="stylesheet" type="text/css"/>
<link href="css/fontstyle.css" rel="stylesheet" type="text/css"/>
<!-- END THEME STYLES -->
<link rel="shortcut icon" href="favicon.ico"/>
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-md page-header-fixed page-quick-sidebar-over-content">

<?php //require_once('header.php');?>

<div class="clearfix"    >
</div>
<!-- BEGIN CONTAINER -->
<div class="page-container" style="border: 0px solid red;margin-top: -100px;background: #3598dc;">
	<!-- BEGIN SIDEBAR -->
	<?php
	$menu_selected="dailyTransaction";
	require_once('sidebar.php');?>
	<!-- END SIDEBAR -->
	<!-- BEGIN CONTENT -->
	<div class="page-content-wrapper">
		<div class="page-content">
			<!-- BEGIN PAGE CONTENT-->
			<!--BEGIN PAGE HEADER-->
			<div class="page-bar">
				<ul class="page-breadcrumb">
					 
					<li>
						 <table border='1' width='790px' style="float: right;background: #ffffcc;margin-top: 5px" >
						 <tr>
						     <th colspan="5" style="width: 40px;text-align: center;background: #ffffcc" id="public_style">موجودی صندوق<span dir="ltr"><?php echo $yesterday ?></span></th>
						 </tr>
						 <tr>
						    <th style="width: 40px;text-align: center;background: #ffffe6;font-size: 12px">دالر</th>
							<th style="width: 40px;text-align: center;background: #ffffe6;font-size: 12px">افغانی</th>
							<th style="width: 40px;text-align: center;background: #ffffe6;font-size: 12px">تومان</th>
							<th style="width: 40px;text-align: center;background: #ffffe6;font-size: 12px">کالدار</th>
							<th style="width: 40px;text-align: center;background: #ffffe6;font-size: 12px">یورو</th>
						 </tr>
						 <tr>
						    <td  style="width: 40px;text-align: center;background: #ffffff;font-size: 12px"><?php echo number_format($yesterday_finalAccount_dollar)?></td>
						    <td  style="width: 40px;text-align: center;background: #ffffff;font-size: 12px"><?php echo number_format($yesterday_finalAccount_AFN)?></td>
						    <td  style="width: 40px;text-align: center;background: #ffffff;font-size: 12px"><?php echo number_format($yesterday_finalAccount_toman)?></td>
						    <td  style="width: 40px;text-align: center;background: #ffffff;font-size: 12px"><?php echo number_format($yesterday_finalAccount_pakistan)?></td>
						    <td  style="width: 40px;text-align: center;background: #ffffff;font-size: 12px"><?php echo number_format($yesterday_finalAccount_euro)?></td>
						  
						</tr>
						</table>
					     <table border='1' style=" width: 790px;margin-top: 70px">
						<tr>
						     <th colspan="10" style="width: 40px;text-align: center;background: #ffffcc" id="public_style">مجموع برد و رسید روز  <span dir="ltr"><?php echo $pdate1;  ?></span></th>
						 </tr>
						<tr>
						    <th style="width: 60px;text-align: center;background: #ffffe6;font-size: 12px" id="public_style">رسیدگی دالر</th>
						    <th style="width: 60px;text-align: center;background: #ffffe6;font-size: 12px" id="public_style">  بردگی دالر</th>
						    <th style="width: 60px;text-align: center;background: #ffffe6;font-size: 12px" id="public_style"> رسیدگی افغانی</th>
						    <th style="width: 60px;text-align: center;background: #ffffe6;font-size: 12px" id="public_style"> بردگی افغانی</th>
						    <th style="width: 60px;text-align: center;background: #ffffe6;font-size: 12px" id="public_style">  رسیدگی تومان</th>
						    <th style="width: 60px;text-align: center;background: #ffffe6;font-size: 12px" id="public_style">  بردگی تومان</th>
						    <th style="width: 60px;text-align: center;background: #ffffe6;font-size: 12px" id="public_style"> رسیدگی کالدار</th>
						    <th style="width: 60px;text-align: center;background: #ffffe6;font-size: 12px" id="public_style"> بردگی کالدار</th>
						    <th style="width: 60px;text-align: center;background: #ffffe6;font-size: 12px" id="public_style"> رسیدگی یورو</th>
						    <th style="width: 60px;text-align: center;background: #ffffe6;font-size: 12px" id="public_style"> بردگی یورو</th>
						</tr>
						<tr>
                        <td  style="width: 80px;text-align: center;background: #ffffff;font-size: 12px"><a href="report/dailly_residegi.php?date= <?php echo $pdate1  ?> & currency=2" target="_blank"><?php echo number_format($avordegi_dollar+$yesterday_finalAccount_dollar)?></a></td>
						    <td  style="width: 80px;text-align: center;background: #ffffff;font-size: 12px"><a href="report/dailly_bordegi.php?date=  <?php echo $pdate1  ?> & currency=2" target="_blank"><?php echo number_format($bordegi_dollar)?></td>
						    <td  style="width: 80px;text-align: center;background: #ffffff;font-size: 12px"><a href="report/dailly_residegi.php?date= <?php echo $pdate1  ?> & currency=1" target="_blank"><?php echo number_format($avordegi_AF+$yesterday_finalAccount_AFN)?></a></td>
						    <td  style="width: 80px;text-align: center;background: #ffffff;font-size: 12px"><a href="report/dailly_bordegi.php?date=  <?php echo $pdate1  ?> & currency=1" target="_blank"><?php echo number_format($bordegi_AF)?></td>
						    <td  style="width: 80px;text-align: center;background: #ffffff;font-size: 12px"><a href="report/dailly_residegi.php?date= <?php echo $pdate1  ?> & currency=5" target="_blank"><?php echo number_format($avordegi_toman+$yesterday_finalAccount_toman)?></a></td>
						    <td  style="width: 80px;text-align: center;background: #ffffff;font-size: 12px"><a href="report/dailly_bordegi.php?date=  <?php echo $pdate1  ?> & currency=5" target="_blank"><?php echo number_format($bordegi_toman)?></a></td>
						    <td  style="width: 80px;text-align: center;background: #ffffff;font-size: 12px"><a href="report/dailly_residegi.php?date= <?php echo $pdate1  ?> & currency=4" target="_blank"><?php echo number_format($avordegi_pakistan+$yesterday_finalAccount_pakistan)?></a></td>
						    <td  style="width: 80px;text-align: center;background: #ffffff;font-size: 12px"><a href="report/dailly_bordegi.php?date=  <?php echo $pdate1  ?> & currency=4" target="_blank"><?php echo number_format($bordegi_pakistan)?></a></td>
						    <td  style="width: 80px;text-align: center;background: #ffffff;font-size: 12px"><a href="report/dailly_residegi.php?date= <?php echo $pdate1  ?> & currency=3" target="_blank"><?php echo number_format($avordegi_euro+$yesterday_finalAccount_euro)?></a></td>
						    <td  style="width: 80px;text-align: center;background: #ffffff;font-size: 12px"><a href="report/dailly_bordegi.php?date=  <?php echo $pdate1  ?> & currency=3" target="_blank"><?php echo number_format($bordegi_euro)?></a></td>
						  
						</tr>
						 
						</table>
						 <table border='1' width='790px' style="float: right;background: #ffffcc;margin-top: 5px" >
						 <tr>
						     <th colspan="5" style="width: 40px;text-align: center;background: #ffffcc" id="public_style">موجودی صندوق <span dir="ltr"><?php echo $pdate1;  ?></span></th>
						 </tr>
						 <tr>
						    <th style="width: 40px;text-align: center;background: #ffffe6;font-size: 12px">دالر</th>
							<th style="width: 40px;text-align: center;background: #ffffe6;font-size: 12px">افغانی</th>
							<th style="width: 40px;text-align: center;background: #ffffe6;font-size: 12px">تومان</th>
							<th style="width: 40px;text-align: center;background: #ffffe6;font-size: 12px">کالدار</th>
							<th style="width: 40px;text-align: center;background: #ffffe6;font-size: 12px">یورو</th>
						 </tr>
						 <tr>
						     <td  style="width: 40px;text-align: center;background: #ffffff;font-size: 12px"><?php echo number_format($today_finalAccount_dollar)?></td>
						    <td  style="width: 40px;text-align: center;background: #ffffff;font-size: 12px"><?php echo number_format($today_finalAccount_AFN)?></td>
						    <td  style="width: 40px;text-align: center;background: #ffffff;font-size: 12px"><?php echo number_format($today_finalAccount_toman)?></td>
						    <td  style="width: 40px;text-align: center;background: #ffffff;font-size: 12px"><?php echo number_format($today_finalAccount_pakistan)?></td>
						    <td  style="width: 40px;text-align: center;background: #ffffff;font-size: 12px"><?php echo number_format($today_finalAccount_euro)?></td>
						  
						</tr>
						</table>
					</li>
				</ul>
			</div>
			<!-- END PAGE HEADER-->
			<div class="row">
				<div class="col-md-12">
					<div class="portlet box blue" id="form_wizard_1">
						<div class="portlet-title">
							<div class="caption">
								 
								
								   
								 <div id="hekmat_menu" >
									<ul>
									<li><a href="dailyTransaction.php"> خرید</a></li>
									<li id="main_title"> <a href="dailyTransactionsale.php"><span class="activeMenu" id="main_title" style="color: #fff">فروش</span></a></li>
									<li id="main_title"> <a href="dailyTransactionCustomer.php"> معاملات بین مشتریان</a></li>
									<li id="main_title"> <a href="naqlo_enteqal_been_hesab.php" > انتقالات بین مشتریان</a></li> 
									<li id="main_title"> <a href="intern_transaction.php" >حواله جات</a></li> 
									<li id="main_title"> <a href="journal_search.php" target =' _ ' > روزنامچه</a></li> 
									<li id="main_title"> <a href="journal_search_2.php" target =' _ ' > روزنامچه 2</a></li> 
									<li id="main_title"> <a href="customerSearch_report.php" target =' _ ' >راپور مشتریان</a></li> 
									</ul>
									 
								 </div>
								
								
								<span class="step-title"></span>
							</div>
							<div class="tools hidden-xs">
								<a href="javascript:;" class="collapse">
								</a>
							</div>
						</div>
						<div class="portlet-body form">
							<form action="registerSell.php" class="form-horizontal"  name="form" id="submit_form" method="POST">
								<div class="form-wizard">
									<div class="form-body">
										<div class="tab-content">
											 
											<div class="tab-pane active" id="tab1">
												<h3 class="block" id="sub_title">فروش</h3>
												<div class="form-group">
													<label class="control-label col-md-2" style="width: 200px" id="public_style">تاریخ<span class="required">
													</span>
													</label>
													<div class="col-md-4">
													   <?php  include("datepicker.php"); ?>
														<input type="hidden" name="target"   value="<?php echo $targetAddress;?>"/>
														<span class="help-block">
														</span>
													</div>
												</div>
												<div class="form-group">
													<label class="control-label col-md-2" style="width: 200px" id="public_style">ارز مورد فروش<span class="required">
													</span>
													</label>
													<div class="col-md-4">
													<select name="counterCurrency" id="counterCurrency" style="width:300px" onClick="get_amount();bayerAmount();dollarPrice()" onChange="get_amount();bayerAmount();dollarPrice()">
													<option></option>
														<?php
															include("config/views/db_const.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>";	
															}
															echo "</select>";
														?>
														<span class="help-block">
														</span>
													</div>
												</div>
												<div class="form-group">
													<label class="control-label col-md-2" style="width: 200px" id="public_style">موجودی ارز مورد فروش<span class="required">
													</span>
													</label>
													<div class="col-md-4">
														<div id='buyerAmount'><input type='text' placeholder="" class="filed"  ></div>
														<span class="help-block">
														</span>
													</div>
												</div>
												<div class="form-group">
													<label class="control-label col-md-2" style="width: 200px" id="public_style">مقدار<span class="required">
													</span>
													</label>
													<div class="col-md-4">
														<input type="text" autocomplete="off" onkeyup="addSeparator(this)" name="counterAmount" id="counterAmount"  placeholder="" class="filed"  onChange="calculateDollar();nazari();"  onclick="calculateDollar();nazari()"/>
														
														<span class="help-block">
														</span>
													</div>
												</div>
												<div class="form-group">
													<label class="control-label col-md-2" style="width: 200px" id="public_style">ارز پایه<span class="required">
													</span>
													</label>
													<div class="col-md-4">
													<select name="basecurrency"  id='basecurrency' style="width:300px" onchange="findCash();get_amount();calculate()" onclick="get_amount();calculate();findCash()">
															<option></option>
													<?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>";
													   }
													echo "</select>";
													?>
														<span class="help-block">
														</span>
													</div>
												</div>
												<div class="form-group">
													<label class="control-label col-md-2" style="width: 200px" id="public_style">موجودی ارز پایه<span class="required">
													</span>
													</label>
													<div class="col-md-4">
														<div id='cash'><input type="text" class='filed'></div>
														<span class="help-block">
														</span>
													</div>
												</div>
												<div class="form-group">
													<label class="control-label col-md-2" style="width: 200px" id="public_style">قیمت<span class="required">
													</span>
													</label>
													<div class="col-md-4">
													    
														<td><div id='rate'><input type="text" name="rateOfCurrency" id='rateOfCurrency' class='filed' ></div></td>
														<span class="help-block">
														</span>
													</div>
												</div>
												<div class="form-group">
													<label class="control-label col-md-2" id="public_style" style="width: 200px">مقدار تراز<span class="required">
													</span>
													</label>
													<div class="col-md-4">
														<td><div id='rate'><input type="text" name="taraz_amount" id='taraz_amount' class='filed' ></div></td>
														<span class="help-block">
														</span>
													</div>
												</div>
												<div class="form-group">
													<label class="control-label col-md-2" style="width: 200px" id="public_style">ارزش به ارز پایه<span class="required">
													</span>
													</label>
													<div class="col-md-4">
														<input type='text' name='baceAmount' id="baceAmount" class='filed'   >
														<input type='hidden' name='buyAmount' id="buyAmount"   >
														<span class="help-block">
														</span>
													</div>
												</div>
											  <!-- <div class="form-group">
													<label class="control-label col-md-2" style="width: 200px" id="public_style">توضیحات <span class="required">
													</span>
													</label>
													<div class="col-md-4">
														<textarea  rows="6"  cols="26" name="desc" ></textarea>
														<span class="help-block">
														</span>
													</div>
												</div>	--> 
												 
											</div>
										</div>
									</div>
									<div class="button_wrapper">
										<div class="row">
											<div class="col-md-offset-3 col-md-4">
												<input type="submit" id="submitbtn" value="&nbsp;&nbsp;ذخیره&nbsp;&nbsp;" class="btn green button-submit" name="submit"/>
											</div>
										</div>
									</div>	
								</div>
							</form>
                            <!-- BEGIN PAGE CONTENT-->
							<div class="row">
								<div class="col-md-12">
									<!-- BEGIN EXAMPLE TABLE PORTLET-->
									<div class="table-wrapper">
										<hr class="horizontal-line" />
										<div class="portlet-body">
											<table class="table table-striped table-bordered table-hover" id="sample1">
											<thead>
											<tr>
											   <th class="table-number" id="public_style">
													شماره
												</th>
												<th id="public_style">
													تاریخ
												</th>
												<th class="table-operation-header" id="public_style">
													ارز مورد معاوضه
												</th>
												<th class="table-operation-header" id="public_style">
													مقدار
												</th>
												<th class="table-operation-header" id="public_style">
													ارز پایه
												</th>
												<th class="table-operation-header" id="public_style">
													قیمت
												</th>
												<th class="table-operation-header" id="public_style">
													ارزش به ارز پایه
												</th><th class="table-operation-header" id="public_style">
													توضیحات
												</th>
												<th class="table-operation-header" id="public_style">
													ویرایش
												</th>
											</tr>
											</thead>
											<tbody >
                                             
                                               <?php
												     include("db.php");
													  
												     $allSql="select * from transaction where treatment='2' and date='$pdate1' and counterAmount!=0 and baseAmount!=0  ";
													 $allQuery= $db ->query($allSql);
													 $ii=1;
													  while($allRow=$allQuery ->fetch_array()){
													       $date=$allRow['date'];
													       $counterCurrencyId=$allRow['counterCurrency'];
													       $counterAmount=$allRow['counterAmount'];
													       $rate=$allRow['rate'];
													       $baseCurrencyId=$allRow['baseCurrency'];
													       $baseAmount=$allRow['baseAmount'];
														   $editID=$allRow['id'];
														   
														   $table_name='transaction';
														   
														   //basecurrency
														   $basecurrencySQl="select name from currencies where id='$baseCurrencyId'";
														   $basecurrencyQuery= $db ->query($basecurrencySQl);
														   $basecurrencyRow=$basecurrencyQuery ->fetch_array();
														   $basecurrency=$basecurrencyRow['name'];

														   //countercurrency
														   $countercurrencySQl="select name from currencies where id='$counterCurrencyId'";
														   $countercurrencyQuery= $db ->query($countercurrencySQl);
														   $countercurrencyRow=$countercurrencyQuery ->fetch_array();
														   $countercurrency=$countercurrencyRow['name'];
														   
														    //=============finding Unit====================================
															  $unit_sql="select unit from crrencyrate where counterCurrency='$counterCurrencyId'";
															  $unit_query=$db ->query($unit_sql);
															  $unit_Row=$unit_query ->fetch_array();
															  $unit=$unit_Row['unit'];
															//=============end finding Unit====================================
															 
													        echo "<tr>
															      <td>$ii</td> 
															      <td>$date</td> 
															      <td id='public_style'>$countercurrency</td> 
															      <td>".number_format($counterAmount)."</td> 
															      <td id='public_style'>$basecurrency</td> 
															      <td>".$rate*$unit."</td> 
															      <td>".number_format($baseAmount)."</td>";
																  echo" <td class='table-operation'><a  href='edit/edit_registerSell.php?editID=".$editID."  & table=".$table_name."'  ><img alt='Submit' src='img/edit.png'   class='dontPrint' title='ویرایش'></a> </td>";
															      echo" <td class='table-operation'><a  href='sales_voucher.php?editID=".$editID."  & table=".$table_name."' target='_blank' ><img alt='Submit' src='img/voucher.png'   class='dontPrint' title='سند مالی'></a> </td>"; 
													    $ii++;    
													 }  
												?>
												</tr>
											</tbody>
										</table>
									</div>
								</div>
							</div>
						</div>
                        </div>
					</div>
				</div>
			</div>
			<!-- END PAGE CONTENT-->
		</div>
	</div>
<!-- BEGIN FOOTER -->
<?php
	require_once('footer.php');

?>
<!-- END FOOTER -->
</div>
<?php
	if (isset($_GET['save'])) {
		echo "<script>alert('ولایت موفقانه در سیستم ذخیره شد.');</script>";
	}
?>
<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
<!-- BEGIN CORE PLUGINS -->
<!--[if lt IE 9]>
<script src="../../assets/global/plugins/respond.min.js"></script>
<script src="../../assets/global/plugins/excanvas.min.js"></script> 
<![endif]-->
<script src="../../assets/global/plugins/jquery.min.js" type="text/javascript"></script>
<script src="../../assets/global/plugins/jquery-migrate.min.js" type="text/javascript"></script>
<!-- IMPORTANT! Load jquery-ui.min.js before bootstrap.min.js to fix bootstrap tooltip conflict with jquery ui tooltip -->
<script src="../../assets/global/plugins/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
<script src="../../assets/global/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="../../assets/global/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js" type="text/javascript"></script>
<script src="../../assets/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
<script src="../../assets/global/plugins/jquery.blockui.min.js" type="text/javascript"></script>
<script src="../../assets/global/plugins/jquery.cokie.min.js" type="text/javascript"></script>
<script src="../../assets/global/plugins/uniform/jquery.uniform.min.js" type="text/javascript"></script>
<script src="../../assets/global/plugins/bootstrap-switch/js/bootstrap-switch.min.js" type="text/javascript"></script>
<!-- END CORE PLUGINS -->
<!-- BEGIN PAGE LEVEL PLUGINS -->
<script type="text/javascript" src="../../assets/global/plugins/select2/select2.min.js"></script>
<script type="text/javascript" src="../../assets/global/plugins/datatables/media/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../../assets/global/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.min.js"></script>
<script type="text/javascript" src="../../assets/global/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.min.js"></script>
<script type="text/javascript" src="../../assets/global/plugins/datatables/extensions/Scroller/js/dataTables.scroller.min.js"></script>
<script type="text/javascript" src="../../assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js"></script>
<!-- END PAGE LEVEL PLUGINS -->
<!-- BEGIN PAGE LEVEL PLUGINS -->
<script type="text/javascript" src="../../assets/global/plugins/jquery-validation/js/jquery.validate.min.js"></script>
<script type="text/javascript" src="../../assets/global/plugins/jquery-validation/js/additional-methods.min.js"></script>
<script type="text/javascript" src="../../assets/global/plugins/bootstrap-wizard/jquery.bootstrap.wizard.min.js"></script>
<!-- END PAGE LEVEL PLUGINS -->
<!-- BEGIN PAGE LEVEL PLUGINS -->
<script type="text/javascript" src="../../assets/global/plugins/select2/select2.min.js"></script>
<!-- END PAGE LEVEL PLUGINS -->
<!-- BEGIN PAGE LEVEL SCRIPTS -->
<script src="../../assets/global/scripts/metronic.js" type="text/javascript"></script>
<script src="../../assets/admin/layout/scripts/layout.js" type="text/javascript"></script>
<script src="../../assets/admin/layout/scripts/demo.js" type="text/javascript"></script>
<script src="../../assets/admin/pages/scripts/table-advanced.js"></script>
<script src="../../assets/admin/pages/scripts/form-wizard.js"></script>
<!-- END PAGE LEVEL SCRIPTS -->
<script>
jQuery(document).ready(function() { 
    
    $('#totalUSD').hide(); $('#currency').hide();
    var b = $('#balance');
    b.blur(function(){
       if(b.val() != "0"){
            $('#totalUSD').show(); $('#currency').show();
       } 
    });
    
   // initiate layout and plugins
   Metronic.init(); // init metronic core components
   Layout.init(); // init current layout
   Demo.init(); // init demo features
   TableAdvanced.init();
   FormWizard.init(); 
});
</script>

<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>
<?php
 }
else{
	header("Location: login.php");
}  
?>