<?php
require("../../../config/koneksi.php");
require("../../../config/function.php");
require("../../../config/crud.php");

(isset($_GET['pg'])) ? $pg = $_GET['pg'] : $pg = '';

if ($pg == 'tambah') {


$ket = $_POST['ket'];	
$ids = $_POST['ids'];
$kelas = $_POST['kelas'];	
$mapel = $_POST['mapel'];	
$guru = $_POST['guru'];	
$kd = $_POST['kd'];		
$nilai = $_POST['nilai'];	


	
$count = count($_POST['kelas']);
$sql   = "INSERT INTO nilai_harian(idsiswa,mapel,kelas,guru,ket,nilai,kd) VALUES ";
for( $i=0; $i < $count; $i++ )
{
$sql .= "('{$ids[$i]}','{$mapel[$i]}','{$kelas[$i]}','{$guru[$i]}','{$ket[$i]}','{$nilai[$i]}','{$kd[$i]}')";
$sql .= ",";
}
$sql = rtrim($sql,",");
$exec = $koneksi->query($sql);

echo $exec;
}
    if ($pg == 'tambah_rfid') {
$kartu = $_POST['kartu'];
$tanggal = $_POST['tgl'];
$ket = $_POST['ket'];	
$ids = $_POST['ids'];
$kelas = $_POST['kelas'];	
$mapel = $_POST['mapel'];	
$guru = $_POST['guru'];	
$blth = $_POST['blth'];			
$count = count($_POST['kelas']);
$sql   = "INSERT INTO absen_mapel(idsiswa,tanggal,mapel,kelas,guru,ket,nokartu,blth) VALUES ";
for( $i=0; $i < $count; $i++ )
{
$sql .= "('{$ids[$i]}','{$tanggal[$i]}','{$mapel[$i]}','{$kelas[$i]}','{$guru[$i]}','{$ket[$i]}','{$kartu[$i]}','{$blth[$i]}')";
$sql .= ",";
}
$sql = rtrim($sql,",");
$exec = $koneksi->query($sql);

echo $exec;
}
if ($pg == 'tambah_manual') {

$tanggal = $_POST['tgl'];
$ket = $_POST['ket'];	
$ids = $_POST['ids'];
$kelas = $_POST['kelas'];	
$mapel = $_POST['mapel'];	
$guru = $_POST['guru'];	
$blth = $_POST['blth'];			
$count = count($_POST['kelas']);
$sql   = "INSERT INTO absen_mapel(idsiswa,tanggal,mapel,kelas,guru,ket,blth) VALUES ";
for( $i=0; $i < $count; $i++ )
{
$sql .= "('{$ids[$i]}','{$tanggal[$i]}','{$mapel[$i]}','{$kelas[$i]}','{$guru[$i]}','{$ket[$i]}','{$blth[$i]}')";
$sql .= ",";
}
$sql = rtrim($sql,",");
$exec = $koneksi->query($sql);

echo $exec;
}
