/home2/kerimkazan/dvf/inc/sale.php
<?php if(!defined('ADMIN_INCLUDED')) { exit; } ?>
<?php
if(!m_authority(m_admin('authoritys'),'reports'))
{
		m_redirect(ADMIN_URL);
}
?>
<?php
	$informations = $db->table('sales')->where('id','=',m_a_g('id'))->get();
	if($informations['total_count']=='0')
	{
		m_redirect(ADMIN_URL);
	}
	$info = $informations['data'][0];
	
	$products = $db->select('sum(quantity) as total')->table('sales_products')->where('s_id','=',$info['id'])->get();
	$products = $products['data'][0]['total'];
?>
<div class="card mt-2 mb-3">
		<div class="card-header fw-bold">Satış Detayı</div>
		<div class="card-body">
		<form action="" method="post" enctype="multipart/form-data">
		<div class="mb-2">
		  <label class="form-label fw-bold">Tarih</label>
		  <input type="text" class="form-control" value="<?php echo m_date_to_tr($info['date']); ?>" disabled>
		</div>
		<div class="mb-2">
		  <label class="form-label fw-bold">Yetkili</label>
		  <input type="text" class="form-control" value="<?php echo m_admin('name',$info['u_id']); ?>" disabled>
		</div>
		<div class="mb-2">
		  <label class="form-label fw-bold">Müşteri</label>
		  <input type="text" class="form-control" value="<?php echo $info['customer']; ?>" disabled>
		</div>
		<div class="mb-2">
		  <label class="form-label fw-bold">Toplam Ürün</label>
		  <input type="text" class="form-control" value="<?php echo $products; ?>" disabled>
		</div>
		<div class="mb-2">
		  <label class="form-label fw-bold">Tutar</label>
		  <input type="text" class="form-control" value="<?php echo m_currency($info['total']); ?> €" disabled>
		</div>
		<div class="mb-2">
		  <label class="form-label fw-bold">İskonto</label>
		  <input type="text" class="form-control" value="%<?php echo $info['discount']; ?>" disabled>
		</div>
		<div class="mb-2">
		  <label class="form-label fw-bold">İskonto Tutarı</label>
		  <input type="text" class="form-control" value="<?php echo m_currency($info['discounted']); ?> €" disabled>
		</div>
		<div class="mb-2">
		  <label class="form-label fw-bold">Toplam</label>
		  <input type="text" class="form-control" value="<?php echo m_currency($info['total_price']); ?> €" disabled>
		</div>
		
		<h2>Ürünler</h2>
		
		<hr>
		
		<br>
		
		
		<table class="table">
		  <thead>
			<tr>
			  <th>Ürün</th>
			  <th>Miktar</th>
			  <th>Fiyat</th>
			  <th>Tutar</th>
			</tr>
		  </thead>
		  <tbody>
			<?php
			$products = $db->table('sales_products')->where('s_id','=',$info['id'])->order('id','asc')->get();
			foreach($products['data'] as $product)
			{
				$info = $db->table('products')->where('id','=',$product['p_id'])->get_vars();
				
				$variant_info = '';
		
				if($product['variant']!='')
				{
					$variant_info = ' ( '.$product['variant'].' )';
				}
		
				echo '
				<tr>
				<td>'.$info['name'].''.$variant_info.'</td>
				<td>'.$product['quantity'].'</td>
				<td>'.m_currency($product['sale_price']).' €</td>
				<td>'.m_currency($product['total_price']).' €</td>
				</tr>
				';
			}
			?>
		  </tbody>
		</table>
				
		
		
		</form>
		
		
		</div>
</div>