|
@@ -156,42 +156,50 @@ class OrderModel
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getOrders(int $companyId, ?int $statusId = null): array
|
|
public function getOrders(int $companyId, ?int $statusId = null): array
|
|
|
- {
|
|
|
|
|
- $sql = "SELECT * FROM `order` WHERE company_id = :company_id AND order_flag = 'a'";
|
|
|
|
|
- $params = ['company_id' => $companyId];
|
|
|
|
|
|
|
+{
|
|
|
|
|
+ $sql = "SELECT *
|
|
|
|
|
+ FROM `order`
|
|
|
|
|
+ WHERE company_id = :company_id
|
|
|
|
|
+ AND order_flag IN ('a', 'p')";
|
|
|
|
|
+ $params = ['company_id' => $companyId];
|
|
|
|
|
+
|
|
|
|
|
+ if ($statusId !== null) {
|
|
|
|
|
+ $sql .= " AND status_id = :status_id";
|
|
|
|
|
+ $params['status_id'] = $statusId;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if ($statusId !== null) {
|
|
|
|
|
- $sql .= " AND status_id = :status_id";
|
|
|
|
|
- $params['status_id'] = $statusId;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $stmt = $this->pdo->prepare($sql);
|
|
|
|
|
+ $stmt->execute($params);
|
|
|
|
|
+ return $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- $stmt = $this->pdo->prepare($sql);
|
|
|
|
|
- $stmt->execute($params);
|
|
|
|
|
- return $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
|
|
|
|
|
|
+public function getOrdersByTable(int $tableId, int $companyId, ?int $statusId = null): array
|
|
|
|
|
+{
|
|
|
|
|
+ if (!$this->tableExists($tableId, $companyId)) {
|
|
|
|
|
+ error_log("Tentativa de obter pedidos de mesa inválida: table_id={$tableId}, company_id={$companyId}");
|
|
|
|
|
+ return [];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getOrdersByTable(int $tableId, int $companyId, ?int $statusId = null): array
|
|
|
|
|
- {
|
|
|
|
|
- if (!$this->tableExists($tableId, $companyId)) {
|
|
|
|
|
- error_log("Tentativa de obter pedidos de mesa inválida: table_id={$tableId}, company_id={$companyId}");
|
|
|
|
|
- return [];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $sql = "SELECT * FROM `order` WHERE table_id = :table_id AND company_id = :company_id AND order_flag = 'a'";
|
|
|
|
|
- $params = [
|
|
|
|
|
- 'table_id' => $tableId,
|
|
|
|
|
- 'company_id' => $companyId
|
|
|
|
|
- ];
|
|
|
|
|
|
|
+ $sql = "SELECT *
|
|
|
|
|
+ FROM `order`
|
|
|
|
|
+ WHERE table_id = :table_id
|
|
|
|
|
+ AND company_id = :company_id
|
|
|
|
|
+ AND order_flag IN ('a', 'p')";
|
|
|
|
|
+ $params = [
|
|
|
|
|
+ 'table_id' => $tableId,
|
|
|
|
|
+ 'company_id' => $companyId
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ if ($statusId !== null) {
|
|
|
|
|
+ $sql .= " AND status_id = :status_id";
|
|
|
|
|
+ $params['status_id'] = $statusId;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if ($statusId !== null) {
|
|
|
|
|
- $sql .= " AND status_id = :status_id";
|
|
|
|
|
- $params['status_id'] = $statusId;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $stmt = $this->pdo->prepare($sql);
|
|
|
|
|
+ $stmt->execute($params);
|
|
|
|
|
+ return $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- $stmt = $this->pdo->prepare($sql);
|
|
|
|
|
- $stmt->execute($params);
|
|
|
|
|
- return $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
public function getOrderById(int $orderId, int $companyId, bool $onlyActive = true): ?array
|
|
public function getOrderById(int $orderId, int $companyId, bool $onlyActive = true): ?array
|
|
|
{
|
|
{
|