<?php

function cekidmac($mac)
{
    //mengambil id mac
    global $conn; // panggil koneksi
    $mac_id = mysqli_query($conn, "SELECT * FROM mac_akses WHERE mac='$mac'");
    $id_mac = mysqli_fetch_array($mac_id);

    return $id_mac['id'];
}

function historysimpan($id_tran, $id_peg, $mac, $jen)
{

    global $conn; // panggil koneksi
    $id_mac = cekidmac($mac);

    mysqli_query($conn, "INSERT INTO daerah(id_pegawai,id_transaksi,aksi,id_mac,id_jenis) VALUES(
                                                 '$id_peg',
                                                 '$id_tran',
												 '1','$id_mac',$jen
                                                 )");
}

function historyedit($id_tran, $id_peg, $mac, $jen)
{

    global $conn; // panggil koneksi
    $id_mac = cekidmac($mac);

    mysqli_query($conn, "INSERT INTO daerah(id_pegawai,id_transaksi,aksi,id_mac,id_jenis) VALUES(
                                                 '$id_peg',
                                                 '$id_tran',
												 '2','$id_mac',$jen
                                                 )");
}

function historyhapus($id_tran, $id_peg, $mac, $jen)
{

    global $conn; // panggil koneksi
    $id_mac = cekidmac($mac);

    mysqli_query($conn, "INSERT INTO daerah(id_pegawai,id_transaksi,aksi,id_mac,id_jenis) VALUES(
                                                 '$id_peg',
                                                 '$id_tran',
												 '3','$id_mac',$jen
                                                 )");
}

function historydatasimpan($id_peg, $mac, $id_data)
{
    global $conn; // panggil koneksi
    $id_mac = cekidmac($mac);

    mysqli_query($conn, "INSERT INTO daerah(id_pegawai,id_data,aksi,id_mac) VALUES(
                                                 '$id_peg',
                                                 '$id_data',
												 '1','$id_mac'
                                                 )");
}

function historydataedit($id_peg, $mac, $id_data)
{
    global $conn; // panggil koneksi
    $id_mac = cekidmac($mac);

    mysqli_query($conn, "INSERT INTO daerah(id_pegawai,id_data,aksi,id_mac) VALUES(
                                                 '$id_peg',
                                                 '$id_data',
												 '2','$id_mac'
                                                 )");
}

function historydatahapus($id_peg, $mac, $id_data)
{
    global $conn; // panggil koneksi
    $id_mac = cekidmac($mac);

    mysqli_query($conn, "INSERT INTO daerah(id_pegawai,id_data,aksi,id_mac) VALUES(
                                                 '$id_peg',
                                                 '$id_data',
												 '3','$id_mac'
                                                 )");
}
