mirror of
https://github.com/Solo-Web-Works/BillTrak.git
synced 2026-01-29 09:50:34 +00:00
✨feature: Initial commit
This commit is contained in:
31
includes/bill.php
Normal file
31
includes/bill.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
class Bill {
|
||||
public static function getAll() {
|
||||
$db = DB::connect();
|
||||
|
||||
return $db->query("SELECT * FROM bills ORDER BY billDate DESC");
|
||||
}
|
||||
|
||||
public static function add($data) {
|
||||
$db = DB::connect();
|
||||
|
||||
$stmt = $db->prepare("INSERT INTO bills
|
||||
(billDate, billName, amount, paymentId, year)
|
||||
VALUES (?, ?, ?, ?, ?)");
|
||||
|
||||
return $stmt->execute([
|
||||
$data['date'],
|
||||
$data['billName'],
|
||||
$data['amount'],
|
||||
$data['paymentId'],
|
||||
$data['year']
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getYearlyTotals() {
|
||||
$db = DB::connect();
|
||||
|
||||
return $db->query("SELECT year, billName, SUM(amount) as total
|
||||
FROM bills GROUP BY year, billName");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user