Enhance orders_o, order_items_o, and InvoicingPeriodRoute: add transaction and calculation methods, implement debug execution timing, refine invoicing period handling, optimize order retrieval, improve caching, and expand database query logic.

This commit is contained in:
Jepp9350
2025-07-01 13:01:01 +02:00
parent e583a269d0
commit f503a5379e
5 changed files with 265 additions and 81 deletions
+10 -5
View File
@@ -236,17 +236,22 @@ class order_items_o extends db
];
}
public function getAllItemsAsArray(int $orderId): array
public function getAllItemsAsArray(int $orderId, ?array $onlySpecificColumns = null): array
{
global $db;
$sql = "SELECT * FROM $this->table WHERE order_id = $orderId AND deleted_at IS NULL";
// Get all items for the order
if ($onlySpecificColumns) {
$columns = implode(', ', $onlySpecificColumns);
} else {
$columns = '*';
}
$sql = "SELECT $columns FROM $this->table WHERE order_id = $orderId AND deleted_at IS NULL";
$result = $db->query($sql);
// Circumvent the repeated instantiation of the object, by just selecting the fields
$items = [];
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$items[] = $row;
}
// Fetch all rows
return $result->fetch_all(MYSQLI_ASSOC);
}
return $items;
}