Files
itflow/agent/modals/expense/expense_bulk_delete.php
johnnyq c93cb20f14 Expenses stage 1: rebuilt expenses list with this month against the same days last month, year so far with monthly average, recurring cost a month and expenses without a receipt in the last 90 days along the top, pills for client, no receipt and refunds with counts, vendor, category, client, date, account and payment method filters and a total of what the filters leave, an expense quick look showing the receipt inline with attach from the window, who entered it, refunds against it and the stock it paid for, one shared form for New, Edit, Copy and Refund with icons on every field, payment method saved from the default in Settings, vendor picks filling in the category, account and method of the last expense with them, refunds linked to the expense they give back and starting at what has not come back, receipts replaced or removed in Edit and served through agent/expense_receipt.php after the Financial and client checks with uploads/expenses closed to the web, bulk set category, account, payment method or client in one window and a single bulk delete, export with the list filters plus paid by, receipt and entered by columns, expenses in global search with open on load, the vendor page, Transactions and product stock history opening the quick look and Client Profitability linking direct costs to the client's expenses, fixes for the dead bulk delete button, bulk set client ignoring client restrictions, the New Expense window opening without write access, unlink warnings on empty receipts and photo receipts downloading as pdf, functions/expenses.php shared by the list, windows, export and search, database 2.9.9 with expense_created_by backfilled from the audit log and expense_refund_of_id, CHANGELOG updated
2026-10-16 17:43:11 -04:00

49 lines
2.0 KiB
PHP

<?php
/*
* Delete the ticked expenses, with their receipts. Transfers between
* accounts are left alone.
*/
require_once '../../../includes/modal_header.php';
enforceUserPermission('module_financial', 3);
$expense_ids = array_values(array_unique(array_filter(array_map('intval', (array) ($_GET['expense_ids'] ?? [])))));
$count = count($expense_ids);
if (!$count) {
echo json_encode(['error' => 'Tick the expenses to delete first.']);
exit;
}
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fas fa-fw fa-trash me-2"></i>Delete <?= $count ?> Expense<?= $count === 1 ? '' : 's' ?></h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<?php foreach ($expense_ids as $expense_id) { ?>
<input type="hidden" name="expense_ids[]" value="<?= $expense_id ?>">
<?php } ?>
<div class="modal-body">
<div class="d-flex gap-3 align-items-start">
<i class="fas fa-exclamation-triangle fa-2x text-danger"></i>
<div>
<div class="fw-semibold"><?= $count === 1 ? 'This expense goes' : "These $count expenses go" ?> for good, with <?= $count === 1 ? 'its receipt' : 'their receipts' ?>.</div>
<div class="text-body-secondary small mt-1">They come out of the account balances and the reports. Stock deliveries that named them stay, unlinked. This can't be undone.</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="bulk_delete_expenses" class="btn btn-danger text-bold"><i class="fas fa-trash me-2"></i>Delete <?= $count ?></button>
<button type="button" class="btn btn-light" data-bs-dismiss="modal"><i class="fas fa-times me-2"></i>Cancel</button>
</div>
</form>
<?php
require_once '../../../includes/modal_footer.php';