diff --git a/index.php b/index.php index 78fed77..500bba7 100644 --- a/index.php +++ b/index.php @@ -725,7 +725,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $customer_id = $_POST['customer_id'] ?: null; $quotation_date = $_POST['quotation_date'] ?: date('Y-m-d'); $valid_until = $_POST['valid_until'] ?: null; - $terms_conditions = $_POST['terms_conditions'] ?? ''; $item_ids = $_POST['item_ids'] ?? []; $quantities = $_POST['quantities'] ?? []; $prices = $_POST['prices'] ?? []; @@ -750,8 +749,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $items_data[] = ['id' => $item_id, 'qty' => $qty, 'price' => $price, 'total' => $line_total]; } $total_with_vat = $subtotal + $total_vat; - $stmt = $db->prepare("INSERT INTO quotations (customer_id, quotation_date, valid_until, total_amount, vat_amount, total_with_vat, terms_conditions) VALUES (?, ?, ?, ?, ?, ?, ?)"); - $stmt->execute([$customer_id, $quotation_date, $valid_until, $subtotal, $total_vat, $total_with_vat, $terms_conditions]); + $stmt = $db->prepare("INSERT INTO quotations (customer_id, quotation_date, valid_until, total_amount, vat_amount, total_with_vat) VALUES (?, ?, ?, ?, ?, ?)"); + $stmt->execute([$customer_id, $quotation_date, $valid_until, $subtotal, $total_vat, $total_with_vat]); $quotation_id = $db->lastInsertId(); foreach ($items_data as $item) { $stmt = $db->prepare("INSERT INTO quotation_items (quotation_id, item_id, quantity, unit_price, total_price) VALUES (?, ?, ?, ?, ?)"); @@ -772,7 +771,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $quotation_date = $_POST['quotation_date'] ?: date('Y-m-d'); $valid_until = $_POST['valid_until'] ?: null; $status = $_POST['status'] ?? 'pending'; - $terms_conditions = $_POST['terms_conditions'] ?? ''; $item_ids = $_POST['item_ids'] ?? []; $quantities = $_POST['quantities'] ?? []; $prices = $_POST['prices'] ?? []; @@ -799,8 +797,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $items_data[] = ['id' => $item_id, 'qty' => $qty, 'price' => $price, 'total' => $line_total]; } $total_with_vat = $subtotal + $total_vat; - $stmt = $db->prepare("UPDATE quotations SET customer_id = ?, quotation_date = ?, valid_until = ?, status = ?, total_amount = ?, vat_amount = ?, total_with_vat = ?, terms_conditions = ? WHERE id = ?"); - $stmt->execute([$customer_id, $quotation_date, $valid_until, $status, $subtotal, $total_vat, $total_with_vat, $terms_conditions, $quotation_id]); + $stmt = $db->prepare("UPDATE quotations SET customer_id = ?, quotation_date = ?, valid_until = ?, status = ?, total_amount = ?, vat_amount = ?, total_with_vat = ? WHERE id = ?"); + $stmt->execute([$customer_id, $quotation_date, $valid_until, $status, $subtotal, $total_vat, $total_with_vat, $quotation_id]); foreach ($items_data as $item) { $stmt = $db->prepare("INSERT INTO quotation_items (quotation_id, item_id, quantity, unit_price, total_price) VALUES (?, ?, ?, ?, ?)"); $stmt->execute([$quotation_id, $item['id'], $item['qty'], $item['price'], $item['total']]); @@ -840,8 +838,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $items = $stmt->fetchAll(); // Create Invoice - $stmt = $db->prepare("INSERT INTO invoices (customer_id, invoice_date, type, status, total_amount, vat_amount, total_with_vat, paid_amount, terms_conditions) VALUES (?, CURDATE(), 'sale', 'unpaid', ?, ?, ?, 0, ?)"); - $stmt->execute([$q['customer_id'], $q['total_amount'], $q['vat_amount'], $q['total_with_vat'], $q['terms_conditions']]); + $stmt = $db->prepare("INSERT INTO invoices (customer_id, invoice_date, type, status, total_amount, vat_amount, total_with_vat, paid_amount) VALUES (?, CURDATE(), 'sale', 'unpaid', ?, ?, ?, 0)"); + $stmt->execute([$q['customer_id'], $q['total_amount'], $q['vat_amount'], $q['total_with_vat']]); $invoice_id = $db->lastInsertId(); foreach ($items as $item) { @@ -1127,7 +1125,7 @@ switch ($page) { $params[] = $_GET['end_date']; } $whereSql = implode(" AND ", $where); - $stmt = db()->prepare("SELECT q.*, c.name as customer_name, c.phone as customer_phone, c.tax_id as customer_tax_id + $stmt = db()->prepare("SELECT q.*, c.name as customer_name FROM quotations q LEFT JOIN customers c ON q.customer_id = c.id WHERE $whereSql @@ -2793,7 +2791,7 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';
- + @@ -3443,175 +3441,7 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';
- + @@ -4307,10 +4262,6 @@ document.addEventListener('DOMContentLoaded', function() { -
- - -
-
- - -