<?php
	include 'inc/conx.php';
	
	$date = (trim($_POST['date']));
	$fullname = (trim($_POST['fullname']));
	$email = (trim($_POST['email']));
	$phone_number = (trim($_POST['phone_number']));
	$address = (trim($_POST['address']));
	$city = (trim($_POST['city']));
	$ntn = (trim($_POST['ntn']));
	$gst = (trim($_POST['gst']));
	$comments = (trim($_POST['comments']));
	$balance = (trim($_POST['balance']));
	$credit_limit = (trim($_POST['credit_limit']));
	$company_name = (trim($_POST['company_name']));
	$account_number = (trim($_POST['account_number']));

	$change_date = explode("/", $date);
	$show_date = $change_date[1]."/".$change_date[0]."/".$change_date[2];
	$php_date = $change_date[2]."/".$change_date[0]."/".$change_date[1];

	
	$sql = $db->query("INSERT INTO customer_setup (date, customer_name, email, phone, address, city, ntn, gst, comments, open_balance, amountLimit, company_name, account_no, current_balance, active) VALUES ('$date', '$fullname', '$email', '$phone_number', '$address', '$city', '$ntn', '$gst', '$comments', '$balance', '$credit_limit', '$company_name', '$account_number', '$balance', 1)");

 		$GetID = $db->query("SELECT * FROM customer_setup ORDER BY id DESC LIMIT 1");
 		$ID = $GetID->fetchArray();

 		$sql = $db->query("INSERT INTO customerinvoice (payment_type, date, php_date, show_date, name, subtotal, remaining) VALUES ('Opening Balance', '$date', '$php_date', '$show_date', 'c".$ID['id']."', '$balance', '$balance')");

 		echo '<option value="'.$fullname.'">:customer';

	die();
?>

