<?php 
session_start();
if(empty($_SESSION['id'])):
header('Location:../index.php');
endif;
include('../dist/includes/dbcon.php');

date_default_timezone_set('Asia/Manila');
	$myid = $_SESSION['id'];
	$adminpasscode = $_POST['adminpasscode'];	
	$remitid = $_POST['remitid'];

	date_default_timezone_set("Asia/Manila"); 
	$date = date("Y-m-d");
	$id = $_SESSION['id'];
	$date1 = date("Y-m-d H:i:s");
	$query2=mysqli_query($con,"select * from user where user_id='6'")or die(mysqli_error($con));
    $row2=mysqli_fetch_array($query2);	
	$gamevoid=$row2['void'];
	
	
	$query3=mysqli_query($con,"select * from user where user_id='9'")or die(mysqli_error($con));
    $row3=mysqli_fetch_array($query3);	
	$gamevoid2=$row3['void'];
	
	
	
	
	if($gamevoid == $adminpasscode){

$result=mysqli_query($con,"DELETE FROM remit WHERE id ='$remitid'")
	or die(mysqli_error());

		$name="CASHIER";
		$remarks="Delete Remitt of ID $remitid ";  
	
		mysqli_query($con,"INSERT INTO history_log(user_id,action,date) VALUES('$id','$remarks','$date')")or die(mysqli_error($con));
		echo "<script type='text/javascript'>alert('Successfully Delete Remit!');</script>";
		echo "<script>document.location='remittances.php?cid=$cid'</script>";
	}else if($gamevoid2 == $adminpasscode){
		$result=mysqli_query($con,"DELETE FROM remit WHERE id ='$remitid'")
	or die(mysqli_error());

		$name="CASHIER";
		$remarks="Delete Remitt of ID $remitid ";  
	
		mysqli_query($con,"INSERT INTO history_log(user_id,action,date) VALUES('$id','$remarks','$date')")or die(mysqli_error($con));
		echo "<script type='text/javascript'>alert('Successfully Delete Remit!');</script>";
		echo "<script>document.location='remittances.php?cid=$cid'</script>";
		
		
	}else{
		
echo "<script type='text/javascript'>alert('DELETE REMITT ADMIN VOID CODE ERROR!');</script>";
		echo "<script>document.location='remittances.php?cid=$cid'</script>";
	}		
				
    						
   
	
?>