<?php
date_default_timezone_set('Asia/Kolkata');
require_once("config/configDB.php"); 
require "userPermission.php";
$edit_id=$_POST['edit_id'];
$salary_no   = $_POST['salary_no'];
$given_date    = $_POST['given_date'];
$ecode   = $_POST['ecode'];
$employee_name    = $_POST['employee_name'];
$fromDate   = $_POST['fromDate'];
$toDate    = $_POST['toDate'];
$advance   = $_POST['advance'];
$collected_amt    = $_POST['collected_amt'];
$remaining_amt   = $_POST['remaining_amt'];
$total_shift    = $_POST['total_shift'];
$total_ot   = $_POST['total_ot'];
$salary_amount    = $_POST['salary_amount'];
$pending_salary    = $_POST['pending_salary'];

$total_salary   = $_POST['total_salary'];
$paidamount    = $_POST['paidamount'];
$givenby    = $_POST['givenby'];


$paytype   = $_POST['paytype'];
$refno    = $_POST['refno'];
$remarks    = $_POST['remarks'];

$createdate  	= date("Y-m-d");
    $createdby      = $_SESSION['username'];
    $userID         = $_SESSION['user_id'];


		
		$delhdr=mysqli_query($conn,"update  employee_payment set status='Deleted'  where id='$edit_id' and status=''");


$autoinc=mysqli_query($conn,"ALTER TABLE employee_payment CHANGE id id INT(11) NOT NULL AUTO_INCREMENT ");

$sql  = "INSERT INTO employee_payment (salary_no, given_date, ecode, employee_name, fromdate, todate, advance_amount, collected_amt, remaining_amt, total_shift, total_ot, salary_amount, pending_salary, total_salary, paidamount, givenby, paytype, refno,remarks,status, createddate, userId, isdelete) VALUES ('$salary_no', '$given_date', '$ecode', '$employee_name', '$fromDate', '$toDate', '$advance', '$collected_amt', '$remaining_amt', '$total_shift', '$total_ot', '$salary_amount', '$pending_salary', '$total_salary', '$paidamount', '$givenby', '$paytype', '$refno','$remarks','', '$createdate', '$userID', '1');";
//print_r($sql);die;

mysqli_query($conn,$sql);

$last_id = mysqli_insert_id($conn);



$conn->close();

// productID, customerID, driver_name, given_date, prodct_cash, hsn_code, givenby, batta_amount, sale_rate



header("Location:EmployeePaymentDashboard.php");


?>