edit eid order2

This commit is contained in:
Flatlogic Bot 2026-05-04 06:01:30 +00:00
parent aa9007e0be
commit ea4bf1e47f

View File

@ -34,26 +34,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['
redirect_to('eid_orders.php', $_GET);
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'delete_order') {
$id = (int) ($_POST['id'] ?? 0);
try {
$stmt = db()->prepare("DELETE FROM sales_orders WHERE id = :id AND order_type = :order_type LIMIT 1");
$stmt->execute([
':id' => $id,
':order_type' => 'eid',
]);
if ($stmt->rowCount() > 0) {
set_flash('success', tr('تم حذف طلب العيد بنجاح.', 'Eid order deleted successfully.'));
} else {
set_flash('warning', tr('تعذر العثور على طلب العيد المطلوب حذفه.', 'The Eid order to delete could not be found.'));
}
} catch (Throwable $e) {
set_flash('danger', tr('تعذر حذف طلب العيد.', 'Failed to delete the Eid order.'));
}
redirect_to('eid_orders.php', $_GET);
}
$activeNav = 'eid_orders';
$pageTitle = tr('طلبات العيد', 'Eid Orders');
@ -525,9 +505,6 @@ require __DIR__ . '/includes/header.php';
</div>
<a class="btn btn-sm btn-light border text-primary" href="<?= h(url_for('sale.php', ['id' => $order['id']])) ?>" title="<?= h(tr('تفاصيل', 'Detail')) ?>"><i class="bi bi-eye"></i></a>
<a class="btn btn-sm btn-outline-secondary" href="<?= h(url_for('edit_sale.php', ['id' => $order['id']])) ?>" title="<?= h(tr('تعديل', 'Edit')) ?>"><i class="bi bi-pencil"></i></a>
<button type="button" class="btn btn-sm btn-outline-danger" onclick='confirmDeleteEidOrder(<?= (int) $order['id'] ?>, <?= json_encode((string) ($order['receipt_no'] ?? '')) ?>)' title="<?= h(tr('حذف', 'Delete')) ?>">
<i class="bi bi-trash"></i>
</button>
</div>
</td>
</tr>
@ -554,62 +531,6 @@ function formatPaymentPopupAmount(value) {
return Number(value || 0).toFixed(3);
}
async function confirmDeleteEidOrder(id, receiptNo) {
const displayReceiptNo = receiptNo || '#'+id;
const result = await Swal.fire({
icon: 'warning',
title: '<?= h(tr('حذف طلب العيد', 'Delete Eid order')) ?>',
text: '<?= h(tr('سيتم حذف الطلب نهائياً من القائمة. هل تريد المتابعة؟', 'This will permanently remove the order from the list. Do you want to continue?')) ?>' + ' (' + displayReceiptNo + ')',
showCancelButton: true,
confirmButtonColor: '#dc3545',
confirmButtonText: '<?= h(tr('نعم، احذف', 'Yes, delete')) ?>',
cancelButtonText: '<?= h(tr('إلغاء', 'Cancel')) ?>'
});
if (!result.isConfirmed) {
return;
}
const form = document.createElement('form');
form.method = 'post';
form.action = '';
const fields = {
action: 'delete_order',
id: String(id)
};
Object.entries(fields).forEach(([name, value]) => {
const input = document.createElement('input');
input.type = 'hidden';
input.name = name;
input.value = value;
form.appendChild(input);
});
const query = window.location.search ? window.location.search.substring(1) : '';
if (query) {
query.split('&').forEach((pair) => {
if (!pair) {
return;
}
const parts = pair.split('=');
const name = decodeURIComponent(parts[0] || '').trim();
if (!name || name === 'action' || name === 'id') {
return;
}
const input = document.createElement('input');
input.type = 'hidden';
input.name = name;
input.value = decodeURIComponent((parts[1] || '').replace(/\+/g, ' '));
form.appendChild(input);
});
}
document.body.appendChild(form);
form.submit();
}
async function receivePayment(id, totalAmount, paidAmount, dueAmount, completeOrder = false) {
const popupHtml = `
<div class="text-start">