Commit 032d5f13 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix(transfers): lock qualification on separation form to the one chosen at fee calculation

The qualification (مؤهل) chosen during separation fee calculation is now
locked in the form fill step — it cannot be changed. This ensures the new
member gets the correct qualification_id, and all dependent fee calculations
(children, spouses) use the full price of that qualification.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 68851585
...@@ -532,10 +532,20 @@ class TransferController extends Controller ...@@ -532,10 +532,20 @@ class TransferController extends Controller
$child = $transfer['child_id'] ? $db->selectOne("SELECT * FROM children WHERE id = ?", [(int) $transfer['child_id']]) : null; $child = $transfer['child_id'] ? $db->selectOne("SELECT * FROM children WHERE id = ?", [(int) $transfer['child_id']]) : null;
$sourceMember = $db->selectOne("SELECT * FROM members WHERE id = ?", [(int) $transfer['source_member_id']]); $sourceMember = $db->selectOne("SELECT * FROM members WHERE id = ?", [(int) $transfer['source_member_id']]);
// Resolve the locked qualification from the transfer request
$lockedQualification = null;
if (!empty($transfer['qualification_code'])) {
$lockedQualification = $db->selectOne(
"SELECT id, code, name_ar FROM qualifications WHERE code = ? AND is_active = 1",
[$transfer['qualification_code']]
);
}
return $this->view('Transfers.Views.form_fill', [ return $this->view('Transfers.Views.form_fill', [
'transfer' => $transfer, 'transfer' => $transfer,
'child' => $child, 'child' => $child,
'sourceMember' => $sourceMember, 'sourceMember' => $sourceMember,
'lockedQualification' => $lockedQualification,
'qualifications' => $db->select("SELECT id, name_ar FROM qualifications WHERE is_active = 1 ORDER BY sort_order"), 'qualifications' => $db->select("SELECT id, name_ar FROM qualifications WHERE is_active = 1 ORDER BY sort_order"),
]); ]);
} }
...@@ -551,6 +561,17 @@ class TransferController extends Controller ...@@ -551,6 +561,17 @@ class TransferController extends Controller
$data = $request->all(); $data = $request->all();
unset($data['_csrf_token']); unset($data['_csrf_token']);
// Force qualification from transfer request (locked at fee calculation time)
if (!empty($transfer['qualification_code'])) {
$lockedQual = $db->selectOne(
"SELECT id FROM qualifications WHERE code = ? AND is_active = 1",
[$transfer['qualification_code']]
);
if ($lockedQual) {
$data['qualification_id'] = (string) $lockedQual['id'];
}
}
$nid = trim((string) ($data['national_id'] ?? '')); $nid = trim((string) ($data['national_id'] ?? ''));
if ($nid !== '' && strlen($nid) === 14) { if ($nid !== '' && strlen($nid) === 14) {
$parsed = NationalIdParser::parse($nid); $parsed = NationalIdParser::parse($nid);
......
...@@ -66,12 +66,18 @@ ...@@ -66,12 +66,18 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-label">المؤهل <span style="color:#DC2626;">*</span></label> <label class="form-label">المؤهل <span style="color:#DC2626;">*</span></label>
<?php if (!empty($lockedQualification)): ?>
<input type="text" value="<?= e($lockedQualification['name_ar']) ?>" class="form-input" readonly style="background:#ECFDF5;font-weight:700;color:#059669;border-color:#059669;">
<input type="hidden" name="qualification_id" value="<?= (int) $lockedQualification['id'] ?>">
<small style="color:#059669;margin-top:4px;display:block;">تم تحديد المؤهل عند حساب رسوم الفصل — لا يمكن تغييره</small>
<?php else: ?>
<select name="qualification_id" class="form-select" required> <select name="qualification_id" class="form-select" required>
<option value="">-- اختر المؤهل --</option> <option value="">-- اختر المؤهل --</option>
<?php foreach ($qualifications as $q): ?> <?php foreach ($qualifications as $q): ?>
<option value="<?= (int) $q['id'] ?>"><?= e($q['name_ar']) ?></option> <option value="<?= (int) $q['id'] ?>"><?= e($q['name_ar']) ?></option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
<?php endif; ?>
</div> </div>
</div> </div>
</div> </div>
......
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