<?php $check=$check??[]; $cashboxes=$cashboxes??[]; $form=$form??[]; $errors=$errors??[]; ?>
<div class="d-flex justify-content-between align-items-center mb-3">
  <div><h4 class="mb-1">تسوية شيك مرتد نقدًا</h4><div class="text-muted small">سيتم تحصيل قيمة الشيك نقدًا من العميل وإدخالها إلى الخزنة</div></div>
  <a class="btn btn-outline-secondary" href="<?= e((url($check_view_base_url ?? '/finance/checks/view')) . '?id='.(int)$check['id']) ?>">رجوع للشيك</a>
</div>
<?php if ($errors): ?><div class="alert alert-danger"><ul class="mb-0"><?php foreach($errors as $er): ?><li><?= e($er) ?></li><?php endforeach; ?></ul></div><?php endif; ?>
<div class="card mb-3"><div class="card-body row g-3">
  <div class="col-md-4"><div class="text-muted small">رقم الشيك</div><div class="fw-bold"><?= e((string)$check['check_no']) ?></div></div>
  <div class="col-md-4"><div class="text-muted small">العميل</div><div class="fw-bold"><?= e((string)$check['drawer_name']) ?></div></div>
  <div class="col-md-4"><div class="text-muted small">القيمة</div><div class="fw-bold"><?= e(format_money((float)$check['amount'])) ?></div></div>
</div></div>
<div class="card"><div class="card-body">
<form method="post" class="row g-3">
  <?= csrf_field() ?>
  <div class="col-md-4"><label class="form-label">تاريخ التسوية</label><input type="datetime-local" class="form-control" name="movement_date" value="<?= e((string)($form['movement_date']??'')) ?>"></div>
  <div class="col-md-4"><label class="form-label">الخزنة</label><select class="form-select" name="cashbox_id"><option value="">اختر</option><?php foreach($cashboxes as $cb): ?><option value="<?= (int)$cb['id'] ?>" <?= (int)($form['cashbox_id']??0)===(int)$cb['id']?'selected':'' ?>><?= e((string)$cb['name']) ?></option><?php endforeach; ?></select></div>
  <div class="col-md-4"><label class="form-label">المبلغ</label><input class="form-control" value="<?= e(format_money((float)$check['amount'])) ?>" readonly></div>
  <div class="col-12"><label class="form-label">ملاحظات</label><input class="form-control" name="notes" value="<?= e((string)($form['notes']??'')) ?>"></div>
  <div class="col-12 d-flex justify-content-end"><button class="btn btn-success">تأكيد التسوية النقدية</button></div>
</form></div></div>
