|
@@ -54,7 +54,7 @@ class OrderModel
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function updateOrderStatus(int $orderId, int $companyId, int $statusId, ?string $orderFlag = null): bool
|
|
|
|
|
|
|
+ public function updateOrderStatus(int $orderId, int $companyId, int $statusId, ?string $orderFlag = null): bool|string
|
|
|
{
|
|
{
|
|
|
$stmtStatus = $this->pdo->prepare("
|
|
$stmtStatus = $this->pdo->prepare("
|
|
|
SELECT status_status
|
|
SELECT status_status
|
|
@@ -64,6 +64,29 @@ class OrderModel
|
|
|
$stmtStatus->execute(['status_id' => $statusId]);
|
|
$stmtStatus->execute(['status_id' => $statusId]);
|
|
|
$statusName = $stmtStatus->fetchColumn();
|
|
$statusName = $stmtStatus->fetchColumn();
|
|
|
|
|
|
|
|
|
|
+ if (strtolower($statusName) === 'finalizada') {
|
|
|
|
|
+ $stmtCheck = $this->pdo->prepare("
|
|
|
|
|
+ SELECT COUNT(*)
|
|
|
|
|
+ FROM order_item
|
|
|
|
|
+ NATURAL JOIN product
|
|
|
|
|
+ NATURAL JOIN 'order'
|
|
|
|
|
+ WHERE order_id = :order_id
|
|
|
|
|
+ AND company_id = :company_id
|
|
|
|
|
+ AND product_is_kitchen = 1
|
|
|
|
|
+ AND order_flag = 'a';
|
|
|
|
|
+ ");
|
|
|
|
|
+ $stmtCheck->execute([
|
|
|
|
|
+ 'order_id' => $orderId,
|
|
|
|
|
+ 'company_id' => $companyId
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $pendingKitchen = (int)$stmtCheck->fetchColumn();
|
|
|
|
|
+
|
|
|
|
|
+ if ($pendingKitchen > 0) {
|
|
|
|
|
+ return "Comanda possui itens de cozinha não finalizados.";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$sql = "
|
|
$sql = "
|
|
|
UPDATE `order`
|
|
UPDATE `order`
|
|
|
SET status_id = :status_id
|
|
SET status_id = :status_id
|
|
@@ -102,8 +125,6 @@ class OrderModel
|
|
|
return $executed && $stmt->rowCount() > 0;
|
|
return $executed && $stmt->rowCount() > 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
public function deleteOrder(int $orderId, int $companyId, bool $hardDelete = false): bool
|
|
public function deleteOrder(int $orderId, int $companyId, bool $hardDelete = false): bool
|
|
|
{
|
|
{
|
|
|
if ($hardDelete) {
|
|
if ($hardDelete) {
|