<?php if(!defined('ADMIN_INCLUDED')) { exit; } ?>
<?php
if(!m_authority(m_admin('authoritys'),'reports'))
{
m_redirect(ADMIN_URL);
}
if($_GET['date'])
{
$dates = explode(" - ",$_GET["date"]);
$dates[0] = date("Y-m-d",strtotime($dates[0]));
$dates[1] = date("Y-m-d",strtotime($dates[1]));
}
?>
<div class="card mt-2 mb-3">
<div class="card-header fw-bold">Filtrele</div>
<div class="card-body">
<form action="">
<input type="hidden" name="page" value="case_reports">
<div class="mb-2">
<label class="form-label fw-bold">Tarih Aralığı</label>
<input type="text" name="date" class="form-control daterange-ranges" autocomplete="off" <?php if($_GET["date"]!="") { echo 'value="'.$_GET["date"].'"'; } ?>>
</div>
<button class="btn btn-primary w-100" type="submit"><i class="fa fa-search"></i> Filtrele</button>
</form>
</div>
</div>
<?php
if($_GET['date'])
{
$total_sales = $db->select('sum(total_price) as total')->table('sales')->where_set('DATE(date)',"BETWEEN '".$dates[0]."' AND ","'".$dates[1]."'")->get();
$total_sale_products = $db->select('sum(quantity) as total')->table('sales_products')->where_set('DATE(date)',"BETWEEN '".$dates[0]."' AND ","'".$dates[1]."'")->get();
$total_sale = $db->table('sales')->where_set('DATE(date)',"BETWEEN '".$dates[0]."' AND ","'".$dates[1]."'")->count();
}
else
{
$total_sales = $db->select('sum(total_price) as total')->table('sales')->get();
$total_sale_products = $db->select('sum(quantity) as total')->table('sales_products')->get();
$total_sale = $db->table('sales')->count();
}
?>
<div class="row">
<div class="col-4">
<div class="card bg-info text-white">
<div class="card-header fw-bold">Toplam Satış</div>
<div class="card-body text-center fw-bold">
<?php echo m_currency($total_sales['data'][0]['total']); ?> $
</div>
</div>
</div>
<div class="col-4">
<div class="card bg-danger text-white">
<div class="card-header fw-bold">Toplam Satılan Ürün</div>
<div class="card-body text-center fw-bold">
<?php echo number_format($total_sale_products['data'][0]['total']); ?>
</div>
</div>
</div>
<div class="col-4">
<div class="card bg-success text-white">
<div class="card-header fw-bold">Toplam Satışlar</div>
<div class="card-body text-center fw-bold">
<?php echo number_format($total_sale); ?>
</div>
</div>
</div>
</div>
<div class="card mt-2 mb-3">
<div class="card-header fw-bold">Ciro Raporları</div>
<div class="card-body">
<table class="table align-middle table-nowrap table-striped datatable">
<thead class="table-light">
<tr>
<th>Tarih</th>
<th>Satış</th>
</tr>
</thead>
<tbody>
<?php
if($_GET['date'])
{
$informations = $db->select('sum(total_price) as total,date')->table('sales')->where_set('DATE(date)',"BETWEEN '".$dates[0]."' AND ","'".$dates[1]."'")->group('DATE(date)')->order('date','desc')->get();
}
else
{
$informations = $db->select('sum(total_price) as total,date')->table('sales')->group('DATE(date)')->order('date','desc')->get();
}
foreach($informations['data'] as $info)
{
echo
'
<tr>
<td data-order="'.strtotime($info['date']).'">'.m_date($info['date']).'</td>
<td>'.m_currency($info['total']).' $</td>
</tr>
';
}
?>
</tbody>
</table>
</div>
</div> |