<div class='row'>
   <div class='col-md-12'>
      <div class="card">
             <div class="card-header">
                    
					<h5 class='card-title'><i class="fas fa-th"></i> Kondisi Bangunan Sekolah</h5>
                </div>
						 
                <div class='card-body'>
                    <div class='table-responsive'>
                        <table  id='datatable1' class='table table-hover'>
                            <thead>
                                <tr>
                                    <th width='3px'>No</th>
									<th>Nama Ruang</th>
									  <th>Nilai Kerusakan</th>
                                    <th>Keterangan</th>  
                                     <th>Usulan Bantuan</th> 	
										<th>Action</th>		  
                                </tr>
                            </thead>
							
							<tbody>
							
                                <?php
								$no = 0;
								 
								 $query = mysqli_query($koneksi, "select * from sapras WHERE jenis='ruang'");								  
                            while ($kondisi = mysqli_fetch_array($query)) {
							$kerusakan = $kondisi['atap']+$kondisi['plafon']+$kondisi['dinding']+$kondisi['kusen']+$kondisi['lante']+$kondisi['pondasi']+$kondisi['utilitas'];
                              $rusak = ($kerusakan/7);
							  
							    if($rusak<=30){
								{$ket="Rusak ringan";}
								}elseif($rusak>=30 && $rusak<=45){
								{$ket="Rusak sedang";}
								}elseif($rusak>=45 && $rusak<=65){
								{$ket="Rusak berat";}
								}elseif($rusak>=65){
								{$ket="Rusak total";}
								}	
								$no++;
                            ?>
							 <tr>
                                    <td><?= $no; ?></td>
									 <td style="color:blue"><?= $kondisi['nama'] ?></td>
									 <td><?= number_format($rusak) ?> %</td>
							        <td><?= $ket ?> </td>
									<td>
									<?php if($rusak >=45){ ?>
									<b>RKB <?= $kondisi['nama'] ?></b>
									<?php }else{ ?>
									<b>Rehab <?= $kondisi['nama'] ?></b>
									<?php } ?>
									</td>
									
                                   <td style="text-align:center">
								   <button type="button" class="btn btn-sm btn-outline-info" data-bs-toggle="modal" data-bs-target="#modal<?= $no ?>"><i class='fas fa-eye'></i></button>
								  
                                   </td>
								   <div class="modal fade" id="modal<?= $no ?>" tabindex="-1" aria-labelledby="modal<?= $no ?>" aria-hidden="true">
                                                    <div class="modal-dialog">
                                                        <div class="modal-content">
                                                            <div class="modal-header">
                                                                <h5 class="modal-title" id="modal<?= $no ?>">Foto kondisi</h5>
                                                                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                                                            </div>
                                                            <div class="modal-body">
                                                              <div id="carouselExampleSlidesOnly" class="carousel slide" data-bs-ride="carousel">
															<div class="carousel-inner">
																<div class="carousel-item active">
																<?php if($kondisi['foto']<>''): ?>
																	<img src="../<?= $kondisi['foto'] ?>" class="d-block w-100" alt="...">
																<?php else: ?>
																<img src="../foto/sapras/avatar.png" class="d-block w-100" alt="...">
																<?php endif ?>
																</div>
																<div class="carousel-item">
																<?php if($kondisi['foto']<>''): ?>
																	<img src="../<?= $kondisi['foto'] ?>" class="d-block w-100" alt="...">
																<?php else: ?>
																<img src="../foto/sapras/avatar.png" class="d-block w-100" alt="...">
																<?php endif ?>
																</div>
																<div class="carousel-item">
																<?php if($kondisi['foto']<>''): ?>
																	<img src="../<?= $kondisi['foto'] ?>" class="d-block w-100" alt="...">
																<?php else: ?>
																<img src="../foto/sapras/avatar.png" class="d-block w-100" alt="...">
																<?php endif ?>
																</div>
															</div>
														</div>
                                                            </div>
                                                            <div class="modal-footer">
                                                                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
                                                                
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                     
							       </tr>
                            <?php } ?>
                        </tbody>
                        </table>
                    </div>
                    </div>
					</div>
                     