<?php
use yii\helpers\Html;

$this->title = "Shift Kasir #{$shift->id}";
$this->params['breadcrumbs'][] = ['label' => 'Data Shift Kasir', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>

<h3><?= Html::encode($this->title) ?></h3>

<div class="row mb-4">
    <div class="col-md-6">
        <div class="card p-3 mb-2">
            <strong>Kasir:</strong> <?= $shift->user->vNama ?? '-' ?><br>
            <strong>Status:</strong>
            <?php if($shift->status == 'open'): ?>
                <span class="badge bg-warning">OPEN</span>
            <?php else: ?>
                <span class="badge bg-success">CLOSED</span>
            <?php endif; ?>
        </div>
    </div>

    <div class="col-md-6">
        <div class="card p-3 mb-2">
            <strong>Tanggal Buka:</strong> <?= $shift->tanggal_buka ?><br>
            <strong>Tanggal Tutup:</strong> <?= $shift->tanggal_tutup ?? '-' ?>
        </div>
    </div>
</div>

<div class="row mb-4">
    <div class="col-md-3">
        <div class="card text-white bg-primary p-3">
            Modal Awal<br>
            <h5>Rp <?= number_format($shift->modal_awal,0,',','.') ?></h5>
        </div>
    </div>

    <div class="col-md-3">
        <div class="card text-white bg-success p-3">
            Total Penjualan<br>
            <h5>Rp <?= number_format($shift->total_penjualan,0,',','.') ?></h5>
        </div>
    </div>

    <div class="col-md-3">
        <div class="card text-white bg-info p-3">
            Total Cash<br>
            <h5>Rp <?= number_format($shift->total_cash_shift,0,',','.') ?></h5>
        </div>
    </div>

    <div class="col-md-3">
        <div class="card text-white bg-danger p-3">
            Selisih<br>
            <h5 style="color: <?= $shift->selisih < 0 ? 'yellow' : 'white' ?>">
                Rp <?= number_format($shift->selisih,0,',','.') ?>
            </h5>
        </div>
    </div>
</div>

<div class="mb-3">
    <?php if($shift->status == 'open'): ?>
        <?= Html::a('Tutup Kasir', ['tutup', 'id'=>$shift->id], ['class'=>'btn btn-danger']) ?>
    <?php else: ?>
        <?= Html::a('Print', ['print', 'id'=>$shift->id], ['class'=>'btn btn-primary', 'target'=>'_blank']) ?>
        <?= Html::a('PDF', ['pdf', 'id'=>$shift->id], ['class'=>'btn btn-danger']) ?>
    <?php endif; ?>

    <?= Html::a('Kembali', ['index'], ['class'=>'btn btn-secondary']) ?>
</div>

<script>
if ({$shift->status == 'open' ? 'true' : 'false'}) {
    Swal.fire({
        title: 'Shift Masih OPEN!',
        text: 'Silakan tutup kasir sebelum logout.',
        icon: 'warning'
    });
}
</script>