mirror of https://github.com/itflow-org/itflow
Edit Expense now deletes old receipt and adds new receipt when attached
This commit is contained in:
parent
9634d7a1e4
commit
acd5f840f2
|
|
@ -7,9 +7,10 @@
|
|||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<form action="post.php" method="post" enctype="multipart/form-data" autocomplete="off">
|
||||
<div class="modal-body bg-white">
|
||||
<input type="hidden" name="expense_id" value="<?php echo $expense_id; ?>">
|
||||
<input type="hidden" name="expense_receipt" value="<?php echo $expense_receipt; ?>">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md">
|
||||
<label>Date</label>
|
||||
|
|
|
|||
16
post.php
16
post.php
|
|
@ -641,8 +641,20 @@ if(isset($_POST['edit_expense'])){
|
|||
$category = intval($_POST['category']);
|
||||
$description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']));
|
||||
$reference = strip_tags(mysqli_real_escape_string($mysqli,$_POST['reference']));
|
||||
$receipt = strip_tags(mysqli_real_escape_string($mysqli,$_POST['expense_receipt']));
|
||||
|
||||
mysqli_query($mysqli,"UPDATE expenses SET expense_date = '$date', expense_amount = '$amount', account_id = $account, vendor_id = $vendor, category_id = $category, expense_description = '$description', expense_reference = '$reference' expense_updated_at = NOW() WHERE expense_id = $expense_id");
|
||||
if($_FILES['file']['tmp_name']!='') {
|
||||
$path = "uploads/expenses/$vendor/";
|
||||
$path = $path . basename( $_FILES['file']['name']);
|
||||
$file_name = basename($path);
|
||||
move_uploaded_file($_FILES['file']['tmp_name'], $path);
|
||||
//remove old receipt
|
||||
unlink($receipt);
|
||||
}else{
|
||||
$path = $receipt;
|
||||
}
|
||||
|
||||
mysqli_query($mysqli,"UPDATE expenses SET expense_date = '$date', expense_amount = '$amount', account_id = $account, vendor_id = $vendor, category_id = $category, expense_description = '$description', expense_reference = '$reference', expense_receipt = '$path', expense_updated_at = NOW() WHERE expense_id = $expense_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Expense modified";
|
||||
|
||||
|
|
@ -978,7 +990,7 @@ if(isset($_GET['delete_invoice'])){
|
|||
$payment_id = $row['payment_id'];
|
||||
mysqli_query($mysqli,"DELETE FROM payments WHERE payment_id = $payment_id");
|
||||
}
|
||||
|
||||
|
||||
$_SESSION['alert_message'] = "Invoice deleted";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue