<?php 
include("../config.php");
if(!empty($_POST)){
	$bill_no           		 = mysqli_real_escape_string($conn, $_POST['invoice_no']);
	$bill_submited_by      = mysqli_real_escape_string($conn, $_POST['bill_submited_by']);
	$bill_submited_date    = mysqli_real_escape_string($conn, date('Y-m-d', strtotime($_POST['bill_submited_date'])));
	$updated_datetime   = date('Y-m-d H:i:s');
	$updated_id         = $_SESSION['user_detail']['id'];

	if($_POST["id"] != ''){
  	$type      = 'general_sales_conformation';
		$user_id   = $_SESSION['user_detail']['id'];
		$data      = serialize($_POST);
  	 	
  	$update = mysqli_query($conn, "UPDATE `general_sales` SET `bill_submited_by` = '".$bill_submited_by."', `bill_submited_date` = '".$bill_submited_date."' WHERE `id` = '".$_POST['id']."'");

		$activiti = mysqli_query($conn, "INSERT INTO `activities`(`type`, `user_id`, `data`, `created_id`, `created_datetime`, `updated_id`, `updated_datetime`) VALUES ('".$type."','".$user_id."','".$data."','".$created_id."','".$created_datetime."','".$updated_id."','".$updated_datetime."')");
	}
  echo json_encode( array('response' => 1, 'msg' => 'DATA SAVED SUCCESSFULLY....!!!', 'alert' => 1, 'redirect' => 'index.php?page=general_sales/list.php') );die();
}else{
  echo json_encode( array('response' => 2, 'msg' => 'Opps', 'alert' => 1, 'redirect' => 'index.php?page=general_sales/add.php') );die();
} 