<?php
	include "koneksi.php";
	//mengambil id dari user yg login
	if (!isset($_SESSION["UserID"]))
{
	header("location:login.php?p=3");
}
    //mengambil nik
    $q="SELECT * FROM user WHERE id='". $_SESSION["UserID"] ."'";
						$res=mysqli_query($conn,$q);
						$dataUser=mysqli_fetch_assoc($res);
					
						$nik = $dataUser["nik_data_karyawan"];
						$level = $dataUser["level"];
						echo "NIK :".$nik;

    //mengambil nama
	 $d="SELECT * FROM data_karyawan WHERE nik=".$nik;
						$resi=mysqli_query($conn,$d);
						$dataUser1=mysqli_fetch_assoc($resi);				
						$nama = $dataUser1["nama_karyawan"];
						echo "NAMA :".$nama;


	//$id=mysqli_real_escape_string($conn,$_POST["id"]);
	
	// mengambil data inputan dari tambah pengajuan purchasing
	$nik = $dataUser["nik_data_karyawan"];
	$nama = $dataUser1["nama_karyawan"];
	$pr_no=$_POST["pr_no"];
	$type_of_material=$_POST["type_of_material"];
    $prt=$_POST["prt"];
	$document_no=$_POST["document_no"];
	$pr_date = date('d-m-Y');
	$note = $_POST["note"];
	
	//barang 1
	$matr_master1=$_POST["matr_master1"];
	$description1=$_POST["description1"];
	$part_no1=$_POST["part_no1"];
	$qty1=$_POST["qty1"];
	$unit1=$_POST["unit1"];
	$justification1=$_POST["justification1"];
	$acc_code1=$_POST["acc_code1"];
	
	//barang 2
	$matr_master2=$_POST["matr_master2"];
	$description2=$_POST["description2"];
	$part_no2=$_POST["part_no2"];
	$qty2=$_POST["qty2"];
	$unit2=$_POST["unit2"];
	$justification2=$_POST["justification2"];
	$acc_code2=$_POST["acc_code2"];
	
	//barang 3
	$matr_master3=$_POST["matr_master3"];
	$description3=$_POST["description3"];
	$part_no3=$_POST["part_no3"];
	$qty3=$_POST["qty3"];
	$unit3=$_POST["unit3"];
	$justification3=$_POST["justification3"];
	$acc_code3=$_POST["acc_code3"];
	
	//barang 4
	$matr_master4=$_POST["matr_master4"];
	$description4=$_POST["description4"];
	$part_no4=$_POST["part_no4"];
	$qty4=$_POST["qty4"];
	$unit4=$_POST["unit4"];
	$justification4=$_POST["justification4"];
	$acc_code4=$_POST["acc_code4"];

    //barang 5
	$matr_master5=$_POST["matr_master5"];
	$description5=$_POST["description5"];
	$part_no5=$_POST["part_no5"];
	$qty5=$_POST["qty5"];
	$unit5=$_POST["unit5"];
	$justification5=$_POST["justification5"];
	$acc_code5=$_POST["acc_code5"];	
	
	 //barang 6
	$matr_master6=$_POST["matr_master6"];
	$description6=$_POST["description6"];
	$part_no6=$_POST["part_no6"];
	$qty6=$_POST["qty6"];
	$unit6=$_POST["unit6"];
	$justification6=$_POST["justification6"];
	$acc_code6=$_POST["acc_code6"];	
	
	//barang 7
	$matr_master7=$_POST["matr_master7"];
	$description7=$_POST["description7"];
	$part_no7=$_POST["part_no7"];
	$qty7=$_POST["qty7"];
	$unit7=$_POST["unit7"];
	$justification7=$_POST["justification7"];
	$acc_code7=$_POST["acc_code7"];	
	
	//barang 8
	$matr_master8=$_POST["matr_master8"];
	$description8=$_POST["description8"];
	$part_no8=$_POST["part_no8"];
	$qty8=$_POST["qty8"];
	$unit8=$_POST["unit8"];
	$justification8=$_POST["justification8"];
	$acc_code8=$_POST["acc_code8"];	
	
	//barang 9
	$matr_master9=$_POST["matr_master9"];
	$description9=$_POST["description9"];
	$part_no9=$_POST["part_no9"];
	$qty9=$_POST["qty9"];
	$unit9=$_POST["unit9"];
	$justification9=$_POST["justification9"];
	$acc_code9=$_POST["acc_code9"];	
	
	//barang 10
	$matr_master10=$_POST["matr_master10"];
	$description10=$_POST["description10"];
	$part_no10=$_POST["part_no10"];
	$qty10=$_POST["qty10"];
	$unit10=$_POST["unit10"];
	$justification10=$_POST["justification10"];
	$acc_code10=$_POST["acc_code10"];
	
	
	//$jenis_card_list=$_POST["jenis_card_list"]; // jenis pembayaran jika 1 maka cash jika 2 maka invoice

   // coba cuery pr masuk ke db berulang
  
    $muncul = 0;
	echo $muncul;
   if ($matr_master1 == !NULL && $matr_master2 == NULL)
   {
      //echo "<br></br>"."query 1 terisi"."<br></br>";
	 if ($muncul == 0)
	 {
		 echo "<br></br>"."query 1 terisi"."<br></br>";
	 }
	 else if ($muncul == 1)
	 {
		 echo "<br></br>"."tidak query"."<br></br>";
	 }
//////////////////////////////////////////////////////////query 1\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
	  //$query = "INSERT INTO data_purchasing_requisition (pr_no,pr_date,type_of_material,document_no,note,purchase_request_type,
	    //        matr_master,description,part_no,quantity,unit,justification,acc_code)
			//    VALUE
			 //  ('$pr_no','$pr_date','$type_of_material','$document_no','$note','$prt',
			   // '$matr_master1','$description1','$part_no1','$qty1','$unit1','$justification1','$acc_code1')";
			   
			   //$result = mysqli_query($conn, $query);
			   //echo "<br></br>";
	    //if($result)
	    //{
		  //  echo "query 1 ".$query;
		   // echo "Data berhasil masuk"."<br></br>";
		    ////header("location:tambahInvoice.php?p=1");
	    //}
	    //else
	    //{
		  //  //header("location:tambahInvoice.php?p=2");
		    //die("Error");
	    //}
   }
	  if ($matr_master2 == !NULL AND $matr_master3 == NULL)
      {
		  //echo "<br></br>"."1 terisi, 2 terisi, 3 kosong"."<br></br>";
		  echo "<br></br>";
		 ////////////////////////////////////////////////////////// 2\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
	 		   
	    //$query2 = "INSERT INTO data_purchasing_requisition (pr_no,pr_date,type_of_material,document_no,note,purchase_request_type,
	      //      matr_master,description,part_no,quantity,unit,justification,acc_code)
			//    VALUE
			  // ('$pr_no','$pr_date','$type_of_material','$document_no','$note','$prt',
			    //'$matr_master2','$description2','$part_no2','$qty2','$unit2','$justification2','$acc_code2')";
			   
			   //$result2 = mysqli_query($conn, $query2);
			   ////echo "query".$query1;
	    //if($result2)
	    //{
		   
			//echo "query 2 ".$query2;
		    //echo "Data berhasil masuk";
		    ////header("location:tambahInvoice.php?p=1");
	    //}
	    //else
	    //{
		  //  //header("location:tambahInvoice.php?p=2");
		    //die("Error");
	    //}
		if ($matr_master1 == NULL)
		{
			echo "1 kosong, isi secara berurut";
		}
		else
		{
			echo "Querry 2 terisi";
		}
      }
	  if ($matr_master3 == !NULL AND $matr_master4 == NULL)
      {
         //echo "<br></br>"."1 terisi, 2 terisi, 3 terisi, 4 kosong"."<br></br>";
		 if ($matr_master1 == NULL OR $matr_master2 == NULL)
		{
			echo "1 atau 2 kosong, isi secara berurut";
			$muncul += 1; // pertanyaan ini kenapa tidak mau naik
		}
		else if ($matr_master1 == !NULL AND $matr_master2 == !NULL)
		{
			echo "query 2,3 terisi";
			
		}
      }
	  if ($matr_master4 == !NULL AND $matr_master5 == NULL)
      {
         echo "<br></br>"."1 terisi, 2 terisi, 3 terisi, 4 terisi, 5 kosong"."<br></br>";
      }
	  if ($matr_master5 == !NULL AND $matr_master6 == NULL)
      {
         echo "<br></br>"."1 terisi, 2 terisi, 3 terisi, 4 terisi, 5 terisi, 6 kosong"."<br></br>";
      }
	  if ($matr_master6 == !NULL AND $matr_master7 == NULL)
      {
         echo "<br></br>"."1 terisi, 2 terisi, 3 terisi, 4 terisi, 5 terisi, 6 terisi, 7 kosong"."<br></br>";
      }
	  if ($matr_master7 == !NULL AND $matr_master8 == NULL)
      {
         echo "<br></br>"."1 terisi, 2 terisi, 3 terisi, 4 terisi, 5 terisi, 6 terisi, 7 terisi, 8 kosong"."<br></br>";
      }
	  if ($matr_master8 == !NULL AND $matr_master9 == NULL)
      {
         echo "<br></br>"."1 terisi, 2 terisi, 3 terisi, 4 terisi, 5 terisi, 6 terisi, 7 terisi, 8 terisi, 9 kosong"."<br></br>";
      }
	  if ($matr_master9 == !NULL AND $matr_master10 == NULL)
      {
         echo "<br></br>"."1 terisi, 2 terisi, 3 terisi, 4 terisi, 5 terisi, 6 terisi, 7 terisi, 8 terisi, 9 terisi, 10 kosong"."<br></br>";
      }
	  if ($matr_master10 == !NULL)
      {
         echo "<br></br>"."1 terisi, 2 terisi, 3 terisi, 4 terisi, 5 terisi, 6 terisi, 7 terisi, 8 terisi, 9 terisi, 10 terisi"."<br></br>";
      }
   
   //else
   //{
     // echo "Maaf, anda harus mengakses halaman ini dari form.html";
   //}



	//$query = "INSERT INTO invoice (id_kode_suplier,no_invoice,tanggal_invoice,jumlah,tanggal_input,jenis_pembayaran)
		//					VALUE
			//				('$nama_suplier','$nomor_invoice','$tanggal_invoice','$jumlah','$tanggal_pembuatan','$jenis_card_list')";
	

	//$query2 = "INSERT INTO data_pasangan (nama,jenis_kelamin,tempat_lahir,tanggal_lahir,nik_pasangan)
		//					VALUE ('$namapasangan','$jeniskelamin','$tempatlahir','$tanggallahirpasangan','$nikpasangan','$nikpasangan')";
	//\\$result = mysqli_query($conn, $query);
	//$result2 = mysqli_query($conn, $query2);

	//\\echo "query = " . $query . "</br>";
	//echo "query2 = " . $query2 . "</br>";
///\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\	
	//if($result)
	{
		//echo "jenis pembayaran".$jenis_card_list;
		//echo "Data berhasil masuk";
		//header("location:tambahInvoice.php?p=1");
	}
///	else
	{
		//header("location:tambahInvoice.php?p=2");
		//die("Error");
	}
	//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;
?>