<?php
/**
 * ==========================================================
 * SIMPAS v1.0
 * Import Data Siswa
 * ==========================================================
 */

include "../../config/koneksi.php";
include "../../config/session.php";

include "../../templates/header.php";
include "../../templates/navbar.php";
include "../../templates/sidebar.php";

// Hitung jumlah siswa
$qJumlah = mysqli_query($conn,"SELECT COUNT(*) AS total FROM siswa");
$jml = mysqli_fetch_assoc($qJumlah);
?>

<div class="content-wrapper">

<section class="content-header">

<div class="container-fluid">

<div class="row mb-2">

<div class="col-sm-6">
<h1>
<i class="fas fa-file-excel text-success"></i>
Import Data Siswa
</h1>
</div>

<div class="col-sm-6 text-right">

<a href="index.php" class="btn btn-secondary">
<i class="fas fa-arrow-left"></i>
Kembali
</a>

</div>

</div>

</div>

</section>

<section class="content">

<div class="container-fluid">

<div class="row">

<div class="col-md-4">

<div class="small-box bg-success">

<div class="inner">

<h3><?= $jml['total']; ?></h3>

<p>Total Data Siswa</p>

</div>

<div class="icon">

<i class="fas fa-users"></i>

</div>

</div>

</div>

</div>

<div class="card card-success shadow">

<div class="card-header">

<h3 class="card-title">

Import Data Siswa Excel (.xlsx)

</h3>

</div>

<div class="card-body">

<div class="alert alert-info">

<b>Petunjuk Import</b>

<hr>

<ol>

<li>Gunakan file Microsoft Excel (.xlsx)</li>

<li>Baris pertama adalah judul kolom.</li>

<li>Nama kelas harus sama dengan Data Kelas.</li>

<li>Jenis Kelamin diisi L atau P.</li>

<li>Status boleh dikosongkan (otomatis Aktif).</li>

</ol>

</div>

<form
action="preview_import.php"
method="POST"
enctype="multipart/form-data">

<div class="form-group">

<label>

Pilih File Excel

</label>

<input
type="file"
name="file_excel"
class="form-control"
accept=".xlsx"
required>

<small class="text-muted">

Hanya file Excel (.xlsx)

</small>

</div>

<div class="mt-4">

<button
type="submit"
class="btn btn-success">

<i class="fas fa-search"></i>

Preview Data

</button>

<a
href="../../templates/template_siswa.xlsx"
class="btn btn-primary">

<i class="fas fa-download"></i>

Download Template

</a>

<a
href="index.php"
class="btn btn-secondary">

Batal

</a>

</div>

</form>

<hr>

<h5>Format Kolom Excel</h5>

<table class="table table-bordered">

<thead class="bg-success">

<tr>

<th>No</th>

<th>Kolom</th>

<th>Contoh</th>

</tr>

</thead>

<tbody>

<tr>

<td>1</td>

<td>NIS</td>

<td>240001</td>

</tr>

<tr>

<td>2</td>

<td>NISN</td>

<td>0098877665</td>

</tr>

<tr>

<td>3</td>

<td>Nama Siswa</td>

<td>Ahmad Fauzan</td>

</tr>

<tr>

<td>4</td>

<td>JK</td>

<td>L / P</td>

</tr>

<tr>

<td>5</td>

<td>Kelas</td>

<td>VII A</td>

</tr>

<tr>

<td>6</td>

<td>Status</td>

<td>Aktif</td>

</tr>

</tbody>

</table>

</div>

</div>

</div>

</section>

</div>

<?php
include "../../templates/footer.php";
?>