<div class="container-fluid py-4" dir="rtl">
	<div class="row justify-content-center">
		<div class="col-12 col-lg-10">
			<div class="card border-0 shadow-sm rounded-4 overflow-hidden">
				<div class="card-header bg-danger bg-opacity-10 border-0 py-3 px-4">
					<h5
						class="mb-0 fw-bold text-danger d-flex align-items-center justify-content-start urdu-regular fs-4">
						<i class="bi bi-trash3 ms-2"></i>درجہ حذف کریں
					</h5>
					<p class="text-end text-muted small mb-0 mt-2 urdu-regular">
						کسی بھی درجہ کو مٹانے کے لیے اس کے سامنے والے بٹن پر کلک کریں
					</p>
				</div>
				<div class="card-body p-0">
					<div class="table-responsive">
						<table class="table table-hover align-middle mb-0 text-end" id="darjaDeleteTable">
							<?php
							$crud = new App_DB(DBU::$dba_user);
							$sqlShoba = "SELECT sno, shoba FROM shobajaat WHERE is_active = 1 ORDER BY sno ASC";
							$shobajaat = $crud->getRecordSet($sqlShoba);

							foreach ($shobajaat as $row1) {
								?>
								<tr class="table-light">
									<th colspan="3" class="bg-default bg-opacity-5 py-3 px-4 border-bottom text-end">
										<span class="text-primary fw-bold fs-5 urdu-regular">
											<i
												class="bi bi-diagram-3 ms-2"></i><?php echo htmlspecialchars($row1['shoba']); ?>
										</span>
									</th>
								</tr>
								<?php
								$sqlDarja = "SELECT derjaCode, darja FROM darjaat WHERE shoba_sno = :shoba_sno ORDER BY derjaCode ASC";
								$darjaat = $crud->getRecordSet($sqlDarja, ['shoba_sno' => $row1['sno']]);

								if (empty($darjaat)) {
									?>
									<tr>
										<td colspan="3" class="text-center text-muted py-4 urdu-regular">اس شعبہ میں کوئی درجہ
											موجود نہیں ہے</td>
									</tr>
									<?php
								} else {
									$counter = 0;
									foreach ($darjaat as $row) {
										$counter++;
										?>
										<tr>
											<td class="text-center text-muted col-1" style="width: 60px;"><?php echo $counter; ?>
											</td>
											<td class="fw-medium text-end urdu-regular fs-5">
									
												<?php echo htmlspecialchars($row["darja"]); ?></td>
											<td class="text-start px-4" style="width: 150px;">
												<button type="button"
													class="btn btn-outline-danger btn-sm rounded-3 py-2 px-3 urdu-regular btn-delete-darja"
													data-id="<?php echo $row["derjaCode"]; ?>"
													data-name="<?php echo htmlspecialchars($row["darja"]); ?>">
													<i class="bi bi-trash ms-1"></i> مٹائیں
												</button>
											</td>
										</tr>
													<?php
									}
								}
							}
							?>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<!-- Custom Delete JS -->
<script src="assets/js/delete_darja.js"></script>