<?php 
	// koneksi database
	include 'urutan.nik.php';

	// menangkap data yang di kirim dari form
	if (isset($_POST['SETAS'])) {
		$NIK		= $KODENIK;
		$NOREG		= $_POST['NOREG'];
		$NAMA		= $_POST['NAMA'];
		$TGLJOIN	= $_POST['TGL_AWAL_KONTRAK'];
		$TGLAKHIR	= $_POST['TGL_AKHIR_KONTRAK'];
		$POSISI		= $_POST['POSISI_KERJA'];
		$PT			= $_POST['PERUSAHAAN'];
		$LOKASI		= $_POST['LOKASI_KERJA'];
		$DEPART		= $_POST['DEPARTEMENT'];
		$NOID		= $_POST['NO_ID'];
		$NOKK		= $_POST['NO_KK'];
		$T_LAHIR	= $_POST['TEMPAT_LAHIR'];
		$TGL_LAHIR	= $_POST['TANGGAL_LAHIR'];
		$J_KELAMIN	= $_POST['JENIS_KELAMIN'];
		$GOL_DARAH	= $_POST['GOL_DARAH'];
		$ALMT		= $_POST['ALAMAT'];
		$RT			= $_POST['RT'];
		$RW			= $_POST['RW'];
		$KEL		= $_POST['KEL'];
		$KEC		= $_POST['KEC'];
		$KOTA		= $_POST['KOTA'];
		$PROV		= $_POST['PROVINSI'];
		$KODEPOS 	= $_POST['KODEPOS'];
		$STS 		= $_POST['STATUS_PERNIKAHAN'];
		$AGAMA 		= $_POST['AGAMA'];
		$JLH_ANAK 	= $_POST['JUMLAH_ANAK'];
		$NOHP 		= $_POST['HP'];
		$NO_REK 	= $_POST['NO_REKENING'];
		$NAMA_REK 	= $_POST['NAMA_PEMILIK_REKENING'];
		$NAMABANK 	= $_POST['NAMA_BANK'];
		$NAMAIBU 	= $_POST['NAMA_IBU'];
		$EMAIL 		= $_POST['EMAIL'];
		
		$a=mysqli_query($koneksi,"INSERT INTO personal VALUES ('$NIK','$NOREG','$NAMA','$TGLJOIN','','$TGLAKHIR','$POSISI','$PT','$LOKASI','$DEPART','$NOID','$NOKK','$ALMT','$RT','$RW','$KEL','$KEC','$KOTA','$PROV','$KODEPOS','$NOHP','$J_KELAMIN','$GOL_DARAH','$T_LAHIR','$TGL_LAHIR','$STS','$AGAMA','$JLH_ANAK','$NO_REK','$NAMA_REK','$NAMABANK','$NAMAIBU','','','','$EMAIL','KONTRAK')")or die(mysqli_error($koneksi));

			if(!$a){
				echo '<meta http-equiv="refresh" content="3;url=index.php">';
			}else{
				echo '<div class="alert alert-success alert-dismissible fade in" role="alert">
				<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<strong> Sukses..!</strong> Data Berhasil Tersimpan.!
				<br>
				</div>';
				
				$query = mysqli_query($koneksi, "SELECT * FROM daftar");
				$b="UPDATE daftar SET STATUS = 'KARYAWAN' WHERE NOREG = '$NOREG'";
				mysqli_query($koneksi, $b) or die(mysqli_error($koneksi));
				
				include 'Password.php';
				$c=mysqli_query($koneksi,"INSERT INTO masuk VALUES ('$NOREG','$NIK','$NAMA','$PASS','$EMAIL','KONTRAK')")or die(mysqli_error($koneksi));
				$d=mysqli_query($koneksi,"INSERT INTO bpjs VALUES ('$NIK','$NAMA','','','','$GOL_DARAH','$NO_REK','$NAMA_REK','$NAMABANK','')")or die(mysqli_error($koneksi));
				
				echo '<meta http-equiv="refresh" content="3;url=Pages-Emp-Info.php?NIK='.$KODENIK.'">';
			}
	}
?>