<?php
	
	
	include "koneksi.php";
	$id=mysqli_real_escape_string($conn,$_GET["id"]);
	
	//select ke data_promosi sesuai id\\\\
	$a = "SELECT * FROM data_promosi WHERE id=".$id;
	$res = mysqli_query($conn, $a);
	//nyimpan hasil query data promosi\\
	$nik;
	$jabatan_baru = '';
	$divisi_baru = '';
	
	while ($row = mysqli_fetch_assoc($res)) 
	{
              $nik = $row["nik"];
			  $jabatan_baru = $row["divisi_baru"];
			  $divisi_baru = $row["jabatan_baru"];
	}
	
    $tanggal_disetujui = date('d / m / yy');
	
	//$query="UPDATE mahasiswa SET nim='$nim',nama='$nama',jurusan='$jurusan',jenis_kelamin='$jenis_kelamin',alamat='$alamat' where id_mahasiswa='$id_mahasiswa'";

	
	$query = "UPDATE data_karyawan 
	      SET jabatan='$divisi_baru', 
		      departement='$jabatan_baru' 
	      WHERE nik=".$nik;
    $result = mysqli_query($conn, $query);	
	
    $q = "UPDATE data_promosi SET status='2',tanggal_disetujui='$tanggal_disetujui' WHERE id=".$id;
	$result2 = mysqli_query($conn, $q);

	if($result & $result2)
	{
		
		//header("location:suratSkUsulanMutasi.php?p=1");
		echo "ini yg update db mutasi".$q;
	
		echo "ini update data karyawan".$query;
	}
	else
	{
		//header("location:tambahkaryawan.php?pesan=gagalInput");
		
		//header("location:suratSkUsulanMutasi.php?p=3");
	echo $query;
	}
	//echo "namanya : " . $nama;
	
	//$q="INSERT INTO kriteria (nama,id_kategori) VALUES ('$nama','$id')";
	//mysqli_query($conn,$q);
	//header("location:kriteria.php?p=1&id=".$id);
	
	//echo $q;
?>