connect_error) { die("Database Connection Failed: " . $conn->connect_error); } // Data Entry Logic $message = ""; if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['add_sale'])) { $buying_price = floatval($_POST['buying_price']); $selling_price = floatval($_POST['selling_price']); $commission = floatval($_POST['commission']); $total_cost = $buying_price + $commission; $profit = $selling_price - $total_cost; $stmt = $conn->prepare("INSERT INTO sales (buying_price, selling_price, commission, total_cost, profit) VALUES (?, ?, ?, ?, ?)"); if ($stmt) { $stmt->bind_param("ddddd", $buying_price, $selling_price, $commission, $total_cost, $profit); if ($stmt->execute()) { $message = "হিসাব সফলভাবে সংরক্ষণ করা হয়েছে!"; } else { $message = "ত্রুটি: " . $stmt->error; } $stmt->close(); } else { $message = "টেবিল বা কোয়েরিতে সমস্যা: " . $conn->error; } } // Filter Logic by Date Range $start_date = isset($_GET['start_date']) ? $_GET['start_date'] : ''; $end_date = isset($_GET['end_date']) ? $_GET['end_date'] : ''; $sql = "SELECT * FROM sales"; if (!empty($start_date) && !empty($end_date)) { $sql .= " WHERE DATE(created_at) BETWEEN '$start_date' AND '$end_date'"; } $sql .= " ORDER BY created_at DESC"; $result = $conn->query($sql); $total_selling = 0; $total_profit = 0; $sales_data = []; if ($result && $result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $total_selling += $row['selling_price']; $total_profit += $row['profit']; $sales_data[] = $row; } } ?>
| তারিখ ও সময় | কেনা দাম | কমিশন | মোট খরচ | বিক্রি দাম | লাভ |
|---|---|---|---|---|---|
| ৳ | ৳ | ৳ | ৳ | ৳ | |
| কোনো তথ্য পাওয়া যায়নি। | |||||