kingkay000 commited on
Commit
f9a6399
·
verified ·
1 Parent(s): 73b8853

Upload download_receipt.php

Browse files
Files changed (1) hide show
  1. easypay/download_receipt.php +10 -6
easypay/download_receipt.php CHANGED
@@ -17,13 +17,16 @@ try {
17
  // 1. Fetch main payment records grouped by receipt
18
  // We join with student registrations to get name info
19
  // We join with school fees to get description
 
20
  $sql = "SELECT pr.*,
21
- sf.description as fee_description,
22
- sr.last_name, sr.first_name, sr.other_name, sr.student_code
23
- FROM tb_account_payment_registers pr
24
- JOIN tb_account_school_fees sf ON pr.fee_id = sf.id
25
- JOIN tb_student_registrations sr ON pr.student_id = sr.id
26
- WHERE pr.receipt_no = :receipt_no";
 
 
27
 
28
  $stmt = $pdo->prepare($sql);
29
  $stmt->execute(['receipt_no' => $receiptNo]);
@@ -39,6 +42,7 @@ WHERE pr.receipt_no = :receipt_no";
39
  'receipt_no' => $receiptNo,
40
  'student_name' => trim($firstRow['last_name'] . ' ' . $firstRow['first_name'] . ' ' . ($firstRow['other_name'] ?? '')),
41
  'student_code' => $firstRow['student_code'],
 
42
  'payment_date' => $firstRow['payment_date'],
43
  'total_paid' => 0,
44
  'allocations' => []
 
17
  // 1. Fetch main payment records grouped by receipt
18
  // We join with student registrations to get name info
19
  // We join with school fees to get description
20
+ // We join with academic levels to get level name (for Senior/Junior college logic)
21
  $sql = "SELECT pr.*,
22
+ sf.description as fee_description,
23
+ sr.last_name, sr.first_name, sr.other_name, sr.student_code,
24
+ al.level_name
25
+ FROM tb_account_payment_registers pr
26
+ JOIN tb_account_school_fees sf ON pr.fee_id = sf.id
27
+ JOIN tb_student_registrations sr ON pr.student_id = sr.id
28
+ LEFT JOIN tb_academic_levels al ON sr.level_id = al.id
29
+ WHERE pr.receipt_no = :receipt_no";
30
 
31
  $stmt = $pdo->prepare($sql);
32
  $stmt->execute(['receipt_no' => $receiptNo]);
 
42
  'receipt_no' => $receiptNo,
43
  'student_name' => trim($firstRow['last_name'] . ' ' . $firstRow['first_name'] . ' ' . ($firstRow['other_name'] ?? '')),
44
  'student_code' => $firstRow['student_code'],
45
+ 'level_name' => $firstRow['level_name'] ?? '',
46
  'payment_date' => $firstRow['payment_date'],
47
  'total_paid' => 0,
48
  'allocations' => []