<?php if(!defined('ADMIN_INCLUDED')) { exit; } ?>
<?php
if(!m_authority(m_admin('authoritys'),'reports'))
{
m_redirect(ADMIN_URL);
}
?>
<div class="card mt-2 mb-3">
<div class="card-header fw-bold">Satış Raporları</div>
<div class="card-body">
<table class="table align-middle table-nowrap table-striped datatable">
<thead class="table-light">
<tr>
<th>Müşteri</th>
<th>Adet</th>
<th>Tutar</th>
<th>Toplam</th>
<th>Tarih</th>
<th>#</th>
<th>Prnt</th>
</tr>
</thead>
<tbody>
<?php
$informations = $db->table('sales')->order('id','desc')->get();
foreach($informations['data'] as $info)
{
$products = $db->select('sum(quantity) as total')->table('sales_products')->where('s_id','=',$info['id'])->order('id','desc')->get();
$products = $products['data'][0]['total'];
echo
'
<tr>
<td>'.$info['customer'].'</td>
<td>'.$products.'</td>
<td>'.m_currency($info['total']).' $</td>
<td>'.m_currency($info['total_price']).' $</td>
<td data-order="'.strtotime($info['date']).'">'.m_date_to_tr($info['date']).'</td>
<td>
<a href="'.SITE_DOMAIN.'/index.php?page=sale&id='.$info['id'].'"><span class="btn btn-primary btn-sm"><i class="fa fa-pen-square"></i></span></a>
<a href="'.SITE_DOMAIN.'/index.php?page=delete&table=sales&id='.$info['id'].'" class="delete"><span class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></span></a>
</td>
<td>
<button class="btn btn-success btn-sm" onclick="printSale('.$info['id'].')"><i class="fa fa-print"></i></button>
</td>
</tr>
';
}
?>
</tbody>
</table>
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", function() {
// Create the CSS styles
var style = document.createElement('style');
style.setAttribute('id', 'responsive-styles');
style.innerHTML = `
table {
border: 1px solid #ccc;
border-collapse: collapse;
margin: 0;
padding: 0;
width: 100%;
table-layout: fixed;
}
table caption {
font-size: 1.5em;
margin: .5em 0 .75em;
}
table tr {
background-color: #f8f8f8;
border: 1px solid #ddd;
padding: .35em;
}
table th,
table td {
padding: .625em;
text-align: center;
}
table th {
font-size: .85em;
letter-spacing: .1em;
text-transform: uppercase;
}
@media screen and (max-width: 600px) {
table {
border: 0;
}
table caption {
font-size: 1.3em;
}
table thead {
border: none;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
table tr {
border-bottom: 3px solid #ddd;
display: block;
margin-bottom: .625em;
}
table td {
border-bottom: 1px solid #ddd;
display: block;
font-size: .8em;
text-align: right;
}
table td::before {
content: attr(data-label);
float: left;
font-weight: bold;
text-transform: uppercase;
}
table td:last-child {
border-bottom: 0;
}
}
`;
document.head.appendChild(style);
// Modify the table
var table = document.querySelector('.datatable');
if (table) {
var headers = [];
table.querySelectorAll('thead th').forEach(function(header) {
headers.push(header.innerText);
});
table.querySelectorAll('tbody tr').forEach(function(row) {
row.querySelectorAll('td').forEach(function(cell, index) {
cell.setAttribute('data-label', headers[index]);
});
});
}
// Add event listeners for print events
window.addEventListener('beforeprint', function() {
document.getElementById('responsive-styles').disabled = true;
});
window.addEventListener('afterprint', function() {
document.getElementById('responsive-styles').disabled = false;
});
});
</script>
|