diff --git a/source/packages/plg_system_mokosuitefield/src/Helper/WarrantyHelper.php b/source/packages/plg_system_mokosuitefield/src/Helper/WarrantyHelper.php index c1f3eb0..093fef5 100644 --- a/source/packages/plg_system_mokosuitefield/src/Helper/WarrantyHelper.php +++ b/source/packages/plg_system_mokosuitefield/src/Helper/WarrantyHelper.php @@ -54,9 +54,16 @@ class WarrantyHelper { $warranty = self::checkWarranty($equipmentId); - if (!$warranty->found ?? true) return (object) ['success' => false, 'error' => 'Equipment not found']; + if (empty($warranty->id)) return (object) ['success' => false, 'error' => 'Equipment not found']; if (!$warranty->under_warranty) return (object) ['success' => false, 'error' => 'Warranty expired']; + // Verify work order exists and is linked to this equipment + $db->setQuery($db->getQuery(true)->select('id')->from('#__mokosuitefield_work_orders') + ->where('id = ' . (int) $woId)); + if (!(int) $db->loadResult()) { + return (object) ['success' => false, 'error' => 'Invalid work order']; + } + $db = Factory::getContainer()->get(DatabaseInterface::class); $now = Factory::getDate()->toSql();