Commit 3479e8e6 authored by DevPilot's avatar DevPilot

fix(accounting): 3 forms crash or silently discard data on submit

اكتشفت أثناء توثيق الشاشات المتبقية إن تلات فورمات معطلة فعليًا:

- إنشاء اعتماد مستندي: أسماء الحقول (credit_number، supplier_id،
  bank_account_id، currency) ما تطابقش اللي الكنترولر بيقراه
  (issuing_bank_id، beneficiary_supplier_id، currency_code)، ومفيش حقل
  أصلًا لـ beneficiary_name رغم إنه NOT NULL في القاعدة — يعني أي محاولة
  حفظ كانت بتطلّع 500 من قاعدة البيانات.
- خطاب ضمان جديد: نفس المشكلة بالظبط — beneficiary بدل beneficiary_name
  NOT NULL، فأي حفظ كان بيقع.
- قرض بنكي جديد: خانة الضمان اسمها collateral بس الكنترولر بيقرا
  collateral_description، فأي نص كان بيتكتب فيها بيتفقد بصمت. وقائمة
  نوع القرض فيها قيم (term_loan، equipment) مش موجودة في enum القاعدة
  أصلًا (term، revolving، overdraft، mortgage) — اختيارها كان هيفشل
  الحفظ أو يبوّظ العمود. رقم القرض واسم البنك كانا حقول قابلة للتعديل
  بالمصادفة بس الكنترولر بيتجاهلهم دايمًا — بقوا معروضين للقراءة بس.
parent 05a6e6f8
......@@ -11,8 +11,13 @@
<div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;margin-bottom:15px;">
<div>
<label class="form-label">رقم الاعتماد</label>
<input type="text" name="credit_number" value="<?= e($credit['credit_number'] ?? '') ?>" class="form-control" required>
<label class="form-label">البنك الفاتح للاعتماد</label>
<select name="issuing_bank_id" class="form-select" required>
<option value="">— اختر بنك —</option>
<?php foreach ($bankAccounts as $ba): ?>
<option value="<?= (int)$ba['id'] ?>" <?= ((int)($credit['issuing_bank_id'] ?? 0)) === (int)$ba['id'] ? 'selected' : '' ?>><?= e($ba['account_name_ar']) ?></option>
<?php endforeach; ?>
</select>
</div>
<div>
<label class="form-label">تاريخ الفتح</label>
......@@ -22,22 +27,18 @@
<div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;margin-bottom:15px;">
<div>
<label class="form-label">المورد</label>
<select name="supplier_id" class="form-select" required>
<option value="">اختر مورد</option>
<label class="form-label">المورد (اختياري)</label>
<select name="beneficiary_supplier_id" class="form-select">
<option value="">بدون</option>
<?php foreach ($suppliers as $s): ?>
<option value="<?= (int)$s['id'] ?>" <?= ((int)($credit['supplier_id'] ?? 0)) === (int)$s['id'] ? 'selected' : '' ?>><?= e($s['name_ar']) ?></option>
<option value="<?= (int)$s['id'] ?>" <?= ((int)($credit['beneficiary_supplier_id'] ?? 0)) === (int)$s['id'] ? 'selected' : '' ?>><?= e($s['name_ar']) ?></option>
<?php endforeach; ?>
</select>
</div>
<div>
<label class="form-label">البنك</label>
<select name="bank_account_id" class="form-select" required>
<option value="">— اختر بنك —</option>
<?php foreach ($bankAccounts as $ba): ?>
<option value="<?= (int)$ba['id'] ?>" <?= ((int)($credit['bank_account_id'] ?? 0)) === (int)$ba['id'] ? 'selected' : '' ?>><?= e($ba['account_name_ar']) ?></option>
<?php endforeach; ?>
</select>
<label class="form-label">اسم المستفيد</label>
<input type="text" name="beneficiary_name" value="<?= e($credit['beneficiary_name'] ?? '') ?>" class="form-control" required
placeholder="اسم المورد/الجهة المستفيدة كما يظهر في الاعتماد">
</div>
</div>
......@@ -48,17 +49,33 @@
</div>
<div>
<label class="form-label">العملة</label>
<input type="text" name="currency" value="<?= e($credit['currency'] ?? 'EGP') ?>" class="form-control">
<input type="text" name="currency_code" value="<?= e($credit['currency_code'] ?? 'EGP') ?>" class="form-control">
</div>
<div>
<label class="form-label">هامش الاعتماد %</label>
<input type="number" name="margin_percentage" step="0.01" min="0" max="100" value="<?= e($credit['margin_percentage'] ?? '0') ?>" class="form-control">
</div>
</div>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;margin-bottom:15px;">
<div>
<label class="form-label">تاريخ الانتهاء</label>
<input type="date" name="expiry_date" value="<?= e($credit['expiry_date'] ?? '') ?>" class="form-control">
</div>
<div>
<label class="form-label">تاريخ الشحن (اختياري)</label>
<input type="date" name="shipment_date" value="<?= e($credit['shipment_date'] ?? '') ?>" class="form-control">
</div>
</div>
<div style="margin-bottom:15px;">
<label class="form-label">الشروط</label>
<textarea name="terms" class="form-control" rows="2"><?= e($credit['terms'] ?? '') ?></textarea>
</div>
<div style="margin-bottom:15px;">
<label class="form-label">الوصف</label>
<textarea name="description" class="form-control" rows="3"><?= e($credit['description'] ?? '') ?></textarea>
<label class="form-label">ملاحظات</label>
<textarea name="notes" class="form-control" rows="3"><?= e($credit['notes'] ?? '') ?></textarea>
</div>
<div style="display:flex;gap:10px;">
......
......@@ -38,7 +38,7 @@
</div>
<div>
<label class="form-label">الجهة المستفيدة</label>
<input type="text" name="beneficiary" value="<?= e($guarantee['beneficiary'] ?? '') ?>" class="form-control" required>
<input type="text" name="beneficiary_name" value="<?= e($guarantee['beneficiary_name'] ?? '') ?>" class="form-control" required>
</div>
</div>
......@@ -57,6 +57,17 @@
</div>
</div>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;margin-bottom:15px;">
<div>
<label class="form-label">العملة</label>
<input type="text" name="currency_code" value="<?= e($guarantee['currency_code'] ?? 'EGP') ?>" class="form-control">
</div>
<div>
<label class="form-label">نسبة العمولة % (سنويًا)</label>
<input type="number" name="commission_rate" step="0.01" min="0" value="<?= e($guarantee['commission_rate'] ?? '0') ?>" class="form-control">
</div>
</div>
<div style="margin-bottom:15px;">
<label class="form-label">ملاحظات</label>
<textarea name="notes" class="form-control" rows="3"><?= e($guarantee['notes'] ?? '') ?></textarea>
......
......@@ -24,11 +24,10 @@
<label class="form-label">نوع القرض <span style="color:#DC2626;">*</span></label>
<select name="loan_type" class="form-select" required>
<option value="">— اختر —</option>
<option value="term_loan" <?= ($loan['loan_type'] ?? '') === 'term_loan' ? 'selected' : '' ?>>قرض لأجل</option>
<option value="term" <?= ($loan['loan_type'] ?? '') === 'term' ? 'selected' : '' ?>>قرض لأجل</option>
<option value="revolving" <?= ($loan['loan_type'] ?? '') === 'revolving' ? 'selected' : '' ?>>تسهيل ائتماني متجدد</option>
<option value="overdraft" <?= ($loan['loan_type'] ?? '') === 'overdraft' ? 'selected' : '' ?>>سحب على المكشوف</option>
<option value="mortgage" <?= ($loan['loan_type'] ?? '') === 'mortgage' ? 'selected' : '' ?>>قرض عقاري</option>
<option value="equipment" <?= ($loan['loan_type'] ?? '') === 'equipment' ? 'selected' : '' ?>>تمويل معدات</option>
</select>
</div>
<div>
......@@ -47,17 +46,21 @@
<label class="form-label">تاريخ البداية <span style="color:#DC2626;">*</span></label>
<input type="date" name="start_date" class="form-input" required dir="ltr" value="<?= e($loan['start_date'] ?? date('Y-m-d')) ?>">
</div>
<?php if (!empty($loan['loan_number'])): ?>
<div>
<label class="form-label">رقم القرض</label>
<input type="text" name="loan_number" class="form-input" dir="ltr" value="<?= e($loan['loan_number'] ?? '') ?>">
<input type="text" class="form-input" dir="ltr" value="<?= e($loan['loan_number']) ?>" disabled>
<small style="color:#6B7280;">مُولَّد تلقائيًا — لا يمكن تعديله</small>
</div>
<div>
<label class="form-label">اسم البنك</label>
<input type="text" name="bank_name" class="form-input" value="<?= e($loan['bank_name'] ?? '') ?>">
<input type="text" class="form-input" value="<?= e($loan['bank_name'] ?? '') ?>" disabled>
<small style="color:#6B7280;">مأخوذ من الحساب البنكي المختار</small>
</div>
<?php endif; ?>
<div style="grid-column:1/-1;">
<label class="form-label">الضمان</label>
<textarea name="collateral" class="form-textarea" rows="2"><?= e($loan['collateral'] ?? '') ?></textarea>
<textarea name="collateral_description" class="form-textarea" rows="2"><?= e($loan['collateral_description'] ?? '') ?></textarea>
</div>
<div style="grid-column:1/-1;">
<label class="form-label">ملاحظات</label>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment