You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
3.2 KiB
96 lines
3.2 KiB
<?php
|
|
include "./header.php";
|
|
$type = $_GET['type'];
|
|
$InvoiceNo = empty($_POST['InvoiceNo']) ? '' : str_replace('-', '', trim($_POST['InvoiceNo']));
|
|
$InvoiceDate = isset($_POST['InvoiceDate']) ? $_POST['InvoiceDate'] : '';
|
|
$Bill = $_POST['Bill'];
|
|
|
|
$invoice_amount = empty($_POST['InvoiceAmount']) ? 0 : $_POST['InvoiceAmount'];
|
|
$received_amount = empty($_POST['ReceivedAmount']) ? 0 : $_POST['ReceivedAmount'];
|
|
$received_date = isset($_POST['ReceivedDate']) ? $_POST['ReceivedDate'] : '';
|
|
$remark = isset($_POST['remark']) ? $_POST['remark'] : '';
|
|
|
|
if ($type == 'edit') {
|
|
$pay_id = $_POST['pay_id'];
|
|
$status = $_POST['status'];
|
|
$sql_query_pay = "SELECT * from account_received where pay_id = $pay_id";
|
|
$pay = mysqli_query($link, $sql_query_pay);
|
|
$pay = mysqli_fetch_assoc($pay);
|
|
|
|
$sql1 = "UPDATE account_received SET ";
|
|
if ($InvoiceNo !== $pay['invoice_no']) {
|
|
$sql1 .= "invoice_no = '$InvoiceNo',";
|
|
}
|
|
if ($InvoiceDate != $pay['invoice_date']) {
|
|
|
|
$sql1 .= "invoice_date = '$InvoiceDate',";
|
|
}
|
|
if ($invoice_amount != $pay['invoice_amount']) {
|
|
$sql1 .= "invoice_amount = $invoice_amount,";
|
|
}
|
|
if ($received_amount != $pay['received_amount']) {
|
|
$sql1 .= "received_amount = $received_amount,";
|
|
}
|
|
if ($received_date != $pay['received_date']) {
|
|
$sql1 .= "received_date = '$received_date',";
|
|
}
|
|
if ($remark != $pay['remark']) {
|
|
$sql1 .= "remark = '$remark',";
|
|
}
|
|
if ($status != $pay['status']) {
|
|
$sql1 .= "status = $status,";
|
|
}
|
|
// $sql1 = substr($sql1, 0, -1);
|
|
$sql = $sql1 . "LastOperatorId = '$user_id' WHERE pay_id = $pay_id";
|
|
} else {
|
|
$BillNo = $_POST['BillNo'];
|
|
$dept_id = $_POST['DeptId'];
|
|
$dept_name = $_POST['DeptName'];
|
|
$manager_name = $_POST['ManagerName'];
|
|
$person_id = $_POST['PersonId'];
|
|
$person_name = $_POST['PersonName'];
|
|
$cust_name = $_POST['CustName'];
|
|
$sql1 = "INSERT INTO account_received (
|
|
BillNo,dept_id,dept_name,manager_name,person_id,person_name,cust_name";
|
|
$sql2 = ",CreatorId) VALUES ('$BillNo','$dept_id','$dept_name','$manager_name','$person_id','$person_name','$cust_name'";
|
|
if (isset($InvoiceNo)) {
|
|
$sql1 .= ",invoice_no";
|
|
$sql2 .= ",'$InvoiceNo'";
|
|
}
|
|
if ((!empty($InvoiceDate))) {
|
|
$sql1 .= ",invoice_date";
|
|
$sql2 .= ",'$InvoiceDate'";
|
|
}
|
|
if (isset($invoice_amount)) {
|
|
$sql1 .= ",invoice_amount";
|
|
$sql2 .= ",$invoice_amount";
|
|
}
|
|
if (isset($received_amount)) {
|
|
$sql1 .= ",received_amount";
|
|
$sql2 .= ",$received_amount";
|
|
}
|
|
if (!(empty($received_date))) {
|
|
$sql1 .= ",received_date";
|
|
$sql2 .= ",'$received_date'";
|
|
}
|
|
if (!(empty($remark))) {
|
|
$sql1 .= ",remark";
|
|
$sql2 .= ",'$remark'";
|
|
}
|
|
$sql = $sql1 . $sql2 . ",'$user_id')";
|
|
}
|
|
mysqli_query($link, $sql);
|
|
?>
|
|
<script>
|
|
var Bill = <?= $Bill ?>;
|
|
var form = document.createElement("form");
|
|
form.method = 'POST';
|
|
form.action = "account-receivable-check.php?<?= $token_link ?>";
|
|
var input = document.createElement("input");
|
|
input.type = "hidden";
|
|
input.name = "Bill";
|
|
input.value = JSON.stringify(Bill);
|
|
form.appendChild(input);
|
|
document.body.appendChild(form);
|
|
form.submit();
|
|
</script>
|