/** * test grabbing an Alert Level that does not exist **/ public function testGetInvalidAlertLevelByAlertId() { // grab a alert id that exceeds the maximum allowable alert id $alertLevel = AlertLevel::getAlertLevelByAlertId($this->getPDO(), InventoryTextTest::INVALID_KEY); $this->assertNull($alertLevel); }
} // post a new AlertLevel } else { if ($method === "POST") { // convert POSTed JSON to an object verifyXsrf(); $requestContent = file_get_contents("php://input"); $requestObject = json_decode($requestContent); $alertLevel = new AlertLevel($alertId, $requestObject->alertCode, $requestObject->alertFrequency, $requestObject->alertPoint, $requestObject->alertOperator); $alertLevel->insert($pdo); $reply->data = "AlertLevel created OK"; // delete an existing AlertLevel } else { if ($method === "DELETE") { verifyXsrf(); $alertLevel = AlertLevel::getAlertLevelByAlertId($pdo, $alertId); $alertLevel->delete($pdo); $reply->data = "AlertLevel deleted OK"; // put to an existing AlertLevel } else { if ($method === "PUT") { // convert PUTed JSON to an object verifyXsrf(); $requestContent = file_get_contents("php://input"); $requestObject = json_decode($requestContent); $alertLevel = new AlertLevel($alertId, $requestObject->alertCode, $requestObject->alertFrequency, $requestObject->alertPoint, $requestObject->alertOperator); $alertLevel->update($pdo); $reply->data = "AlertLevel Updated Ok"; } } }
\t\t\t\t\t</tr> \t\t\t\t</thead> \t\t\t\t<tbody> EOF; $allProducts = Product::getAllProducts($pdo, 0); foreach ($allProducts as $product) { $numberOfProducts = 0; // Make an array of product location from the above product $productLocations = ProductLocation::getProductLocationByProductId($pdo, $product->getProductId()); foreach ($productLocations as $productLocation) { $numberOfProducts = $numberOfProducts + $productLocation->getQuantity(); } // check if levels trigger notification according to alert operator $productAlerts = ProductAlert::getProductAlertByProductId($pdo, $product->getProductId()); foreach ($productAlerts as $productAlert) { $alertLevel = AlertLevel::getAlertLevelByAlertId($pdo, $productAlert->getAlertId()); if ($alertLevel->getAlertOperator() === "<" && $numberOfProducts < $alertLevel->getAlertPoint() || $alertLevel->getAlertOperator() === ">" && $numberOfProducts > $alertLevel->getAlertPoint()) { // give warning $productTitle = $product->getTitle(); $vendor = Vendor::getVendorByVendorId($pdo, $product->getVendorId()); $vendorName = $vendor->getVendorName(); $message = $message . <<<EOF \t\t\t\t<tr> \t\t\t\t\t<td>{$productTitle}</td> \t\t\t\t\t<td>{$numberOfProducts}</td> \t\t\t\t\t<td>{$vendorName}</td> \t\t\t\t</tr> EOF; } } }