<?php
 	session_start(); 

	if(!isset($_SESSION['tulsilogin']))
	{
		header('Location: index.php');
		return;
	}

date_default_timezone_set("Asia/Kolkata");
	$mdate1= date('Y-m-d H:i:s');
	

$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
	
	
	include("connect.php");
include("mylibrary.php");
	$umid = $_SESSION['umid'];
	//$tmdocument=$_POST['tmdocument'];
	
	
	$branchmid = $_POST['branchmid'];
	$expensetypemid = $_POST['expensetypemid'];
	$paymode = $_POST['paymode'];
	$payamount = $_POST['payamount'];
	$paydate = date("Y-m-d",strtotime($_POST['paydate']));
	$premark = $_POST['premark'];
	$pdocument='';
	if(empty($_FILES['pdocument']['name']) == false  )
	{
		$pdocument = date("YmdHis").$_FILES['pdocument']['name'];
		$path = "docs/";
		move_uploaded_file( $_FILES['pdocument']['tmp_name'], $path ."/". $pdocument );
	
	}
	
		 $eve1 = "INSERT INTO res_pettycash_detail (branchmid,expensetypemid,paddedby,paddedon,pupdatedby,pupdatedon,paymode,payamount,paydate,premark,pdocument) VALUES('$branchmid','$expensetypemid','$umid','$mdate1','$umid','$mdate1','$paymode','$payamount','$paydate','$premark','$pdocument')";
		$re1 = mysqli_query($conn, $eve1);
		
		$_SESSION['msg'] = "Record saved successfully";
	header('Location: pettycash.php');
	
	
	
			
	
			
	
?>