<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;

$this->title = 'Buka Kasir';
?>

<h3>Buka Kasir</h3>

<?php $form = ActiveForm::begin(); ?>

<?php if($shiftTerakhir): ?>

    <div class="card p-3 mb-3" style="background:#f8f9fa;border-radius:10px;">
        <h5>Informasi Shift Terakhir</h5>

        <p>
            Saldo akhir shift terakhir:<br>
            <strong class="text-primary">
                Rp <?= number_format($shiftTerakhir->saldo_akhir_sistem,0,',','.') ?>
            </strong>
        </p>

        <?php if(isset($saldoKemarin)): ?>
        <p>
            Saldo akhir kemarin:<br>
            <strong class="text-success">
                Rp <?= number_format($saldoKemarin,0,',','.') ?>
            </strong>
        </p>
        <?php endif; ?>
    </div>

    <!-- Modal otomatis -->
    <?= $form->field($model, 'modal_awal')->textInput([
        'type' => 'number',
        'value' => $shiftTerakhir->saldo_akhir_sistem,
        // 'readonly' => true
    ]) ?>

<?php else: ?>

    <div class="alert alert-warning">
        Ini adalah shift pertama hari ini.<br>
        Silakan masukkan modal awal.
    </div>

    <?php if(isset($saldoKemarin)): ?>
        <p>
            Saldo akhir kemarin:<br>
            <strong class="text-success">
                Rp <?= number_format($saldoKemarin,0,',','.') ?>
            </strong>
        </p>
        <?php endif; ?>

    <?= $form->field($model, 'modal_awal')->textInput([
        'type' => 'number',
        'required' => true
    ]) ?>

<?php endif; ?>

<div class="form-group">
    <?= Html::submitButton('Buka Kasir', [
        'class' => 'btn btn-success'
    ]) ?>
</div>

<?php ActiveForm::end(); ?>
