<?php if(!defined('ADMIN_INCLUDED')) { exit; } ?>
<?php
$informations = $db->table('settings')->where('id','=',1)->get();
if($informations['total_count']=='0')
{
m_redirect(ADMIN_URL);
}
$info = $informations['data'][0];
?>
<ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="pills-home-tab" data-bs-toggle="pill" data-bs-target="#pills-home" type="button" role="tab" aria-controls="pills-home" aria-selected="true">BARKOD TARA</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-profile-tab" data-bs-toggle="pill" data-bs-target="#pills-profile" type="button" role="tab" aria-controls="pills-profile" aria-selected="false">MANUEL</button>
</li>
</ul>
<div class="tab-content" id="pills-tabContent">
<div class="tab-pane fade show active" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab">
<div id="reader" width="600px" height="600px"></div>
<button type="button" class="btn btn-success w-100 sale_barcode_scan"><i class="fa fa-search"></i> BARKOD TARA</button>
</div>
<div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab">
<select class="select2 manuel_product " data-placeholder="Ürün arayın">
<option value="">Ürün Seçiniz</option>
<?php
$products = $db->table('products')->where('status','=','1')->order('name','asc')->get();
foreach($products['data'] as $product)
{
echo '<option value="'.$product['barcode'].'">'.$product['name'].'</option>';
}
?>
</select>
</div>
</div>
<form class="sale_form" action="" method="post" enctype="multipart/form-data">
<div class="card mt-2 mb-3">
<div class="card-header fw-bold">ÜRÜNLER</div>
<div class="card-body">
<div class="sale_products">
</div>
</div>
</div>
<div class="card mt-2 mb-3">
<div class="card-header fw-bold">SATIŞ</div>
<div class="card-body">
<div class="mb-2">
<label class="form-label fw-bold">Müşteri</label>
<input type="text" class="form-control" name="customer" required>
</div>
<div class="mb-2" style="display: none;">
<label class="form-label fw-bold">İskonto %</label>
<input type="number" class="form-control" name="discount" value="<?php echo m_setting('discount'); ?>" required>
</div>
<div class="mt-2 mb-2 float-end">
<b style="font-size:20px;width:100px;display:inline-block;">(USD):</b>
<span class="net_total_price" style="font-size:20px">0.00</span> $
<br>
<b style="font-size:20px;width:100px;display:inline-block;">(TRY):</b>
<span class="total_price_try" style="font-size:20px">0.00</span> ₺
<br>
<b style="font-size:20px;width:100px;display:inline-block;">(EUR):</b>
<span class="total_price_eur" style="font-size:20px">0.00</span> €
</div>
<script>
// PHP değişkenlerini JavaScript'e aktar
const usdToTryRate = <?php echo $info['usd_try']; ?>;
const tryToEurRate = <?php echo $info['eur_try']; ?>;
// Para birimlerini güncelleyen fonksiyon
function updateCurrencyValues() {
// Net toplam fiyatı (USD) al
const netTotalPriceUSD = parseFloat(document.querySelector('.net_total_price').innerText);
if (!isNaN(netTotalPriceUSD)) {
// TRY cinsinden toplam fiyatı hesapla
const totalPriceTRY = netTotalPriceUSD * usdToTryRate;
document.querySelector('.total_price_try').innerText = totalPriceTRY.toFixed(2);
// EUR cinsinden toplam fiyatı hesapla
const totalPriceEUR = totalPriceTRY / tryToEurRate;
document.querySelector('.total_price_eur').innerText = totalPriceEUR.toFixed(2);
// Fiş kısmını da güncelle
document.querySelector('.print_total_price_try').innerText = totalPriceTRY.toFixed(2);
document.querySelector('.print_total_price_eur').innerText = totalPriceEUR.toFixed(2);
}
}
// Net toplam fiyat dinamik olarak değiştiğinde değerleri güncelle
const observer = new MutationObserver(updateCurrencyValues);
observer.observe(document.querySelector('.net_total_price'), { childList: true, subtree: true });
// İlk başta değerleri güncelle
updateCurrencyValues();
</script>
<button class="btn btn-primary w-100 print_btn mb-2" type="button"><i class="fa fa-print"></i> FİŞ YAZDIR</button>
<button class="btn btn-success w-100" type="submit"><i class="fa fa-plus-circle"></i> SATIŞI TAMAMLA</button>
</form>
</div>
</div>
<!-- Bootstrap Alert -->
<div id="alert-container" class="container mt-3">
</div>
<div class="print">
<div class="row mb-5">
<div class="col-6">
<h1 style="font-size:24px;"><?php echo m_setting('brand'); ?></h1>
</div>
<div class="col-6 text-start">
<i class="fa fa-map"></i> <?php echo m_setting('address'); ?> <br>
<i class="fa fa-phone"></i> <?php echo m_setting('phone'); ?> <br>
<i class="fa fa-envelope"></i> <?php echo m_setting('email'); ?>
</div>
</div>
<div style="padding-left:5px;" class="mb-2">
<b>Müşteri:</b> <span class="sale_customer"></span><br><br>
<b>Tarih:</b> <span class="sale_date"></span>
</div>
<table class="table">
<thead>
<tr>
<th>Ürün</th>
<th>Miktar</th>
<th>Fiyat</th>
<th>Tutar</th>
</tr>
</thead>
<tbody class="print_products">
</tbody>
</table>
<div class="mt-2 mb-2 float-end">
<b style="font-size:20px;width:100px;display:inline-block;">(USD):</b> <span class="net_total_price" style="font-size:20px">0.00</span> $
<br>
<b style="font-size:20px;width:100px;display:inline-block;">(TRY):</b> <span class="print_total_price_try" style="font-size:20px">0.00</span> ₺
<br>
<b style="font-size:20px;width:100px;display:inline-block;">(EUR):</b> <span class="print_total_price_eur" style="font-size:20px">0.00</span> €
</div>
</div>
</div>