Document
Warranty valid from Date of Invoice!
$serialNumber,
);
// Convert data array to JSON
$jsonData = json_encode($data);
// Initialize cURL
$ch = curl_init($url);
// Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
‘Content-Type: application/json’,
‘Content-Length: ‘ . strlen($jsonData)
));
// Execute cURL request
$response = curl_exec($ch);
// Check for errors
if ($response === false) {
echo ‘
cURL Error: ‘ . curl_error($ch) . ‘
‘;
} else {
// Decode the JSON response
$result = json_decode($response, true);
// Check if the response is valid
if (isset($result[‘Status’]) && $result[‘Status’] == 1 && isset($result[‘JsonData’]) && !empty($result[‘JsonData’][‘Sales’])) {
$sales = $result[‘JsonData’][‘Sales’];
$found = false;
foreach ($sales as $item) {
if ($item[‘SerialNo’] == $serialNumber) {
echo “
“;
echo “
“;
echo “
Serial No: |
” . htmlspecialchars($item[‘SerialNo’]) . “ |
“;
echo “
Item Name: |
” . htmlspecialchars($item[‘ItemName’]) . “ |
“;
echo “
Warranty: |
” . htmlspecialchars($item[‘Warranty’]) . “ |
“;
echo “
“;
echo “
“;
$found = true;
break; // Break the loop once a match is found
}
}
if (!$found) {
echo ‘
No records found for the given serial number.
‘;
}
} else {
echo ‘
Invalid response from the API or no sales data available.
‘;
}
// Handle “ConsumedDetail” section
if (!empty($result[‘JsonData’][‘Productions’][0][‘ConsumedDetail’])) {
echo “
“;
echo “
“;
foreach ($result[‘JsonData’][‘Productions’][0][‘ConsumedDetail’] as $consumed) {
$itemName = htmlspecialchars($consumed[‘ItemName’]); // Get the original ItemName
$itemCategory = htmlspecialchars($consumed[‘ItemCategory’]); // Get the original ItemCategory
// Modify ItemName based on specific conditions for each category
if ($itemCategory == ‘HARD DISK’) {
$itemName = ‘VOLTRIQ ‘ . substr($itemName, 0, -10);
} elseif ($itemCategory == ‘BATTERY’) {
continue;
} elseif ($itemCategory == ‘SSD’) {
$itemName = ‘VOLTRIQ ‘ . substr($itemName, 0, -8);
} elseif ($itemCategory == ‘RAM’) {
$itemName = ‘VOLTRIQ ‘ . substr($itemName, 0, 14);
} elseif ($itemCategory == ‘ALL IN ONE STOCK’) {
continue;
} elseif ($itemCategory == ‘ACCESSORIES’) {
$itemName = ‘VOLTRIQ ‘ .$itemName;
} elseif ($itemCategory == ‘GRAPHIC CARD’) {
continue;
} elseif ($itemCategory == ‘MOTHER BOARD’) {
$itemName = ‘INTEL SUPPORTING BOARD’;
} elseif ($itemCategory == ‘MONITOR’) {
continue;
} elseif ($itemCategory == ‘DESKTOP’) {
continue;
} elseif ($itemCategory == ‘AIR COOLER’) {
continue;
} elseif ($itemCategory == ‘CPU FAN’) {
continue;
} elseif ($itemCategory == ‘PROCESSOR’) {
$itemName = substr($itemName, 0, 29);
} elseif ($itemCategory == ‘General’) {
continue;
} elseif ($itemCategory == ‘SMPS’) {
continue;
} elseif ($itemCategory == ‘CABINET’) {
continue;
} elseif ($itemCategory == ‘DVD WRITER’) {
continue;
} elseif ($itemCategory == ‘CABLE’) {
continue;
} elseif ($itemCategory == ‘CHIMNEY’) {
continue;
} elseif ($itemCategory == ‘PRINTER’) {
continue;
} elseif ($itemCategory == ‘DEEP FREEZER’) {
continue;
} elseif ($itemCategory == ‘CHAIR’) {
continue;
} elseif ($itemCategory == ‘KEYBOARD MOUSE’) {
$itemName = substr($itemName, 0, -6);
} elseif ($itemCategory == ‘Indirect Expenses’) {
continue;
} elseif ($itemCategory == ‘UPS’) {
continue;
} elseif ($itemCategory == ‘AIR CONDITIONER’) {
continue;
} elseif ($itemCategory == ‘LAN CARD’) {
continue;
} elseif ($itemCategory == ‘USB HUB’) {
continue;
} elseif ($itemCategory == ‘SPEAKER’) {
continue;
} elseif ($itemCategory == ‘MIC’) {
continue;
} elseif ($itemCategory == ‘COMPUTER ACCESSORIES / PERIPHERALS’) {
continue;
} elseif ($itemCategory == ‘WEB CAM’) {
continue;
} elseif ($itemCategory == ‘WATER DISPENSER’) {
continue;
} elseif ($itemCategory == ‘SOFTWARE’) {
continue;
} elseif ($itemCategory == ‘LED’) {
continue;
} elseif ($itemCategory == ‘LED PARTS’) {
continue;
} elseif ($itemCategory == ‘WIFI CARD’) {
continue;
} elseif ($itemCategory == ‘Microsoft Windows’) {
continue;
} elseif ($itemCategory == ‘MOBILE’) {
continue;
} elseif ($itemCategory == ‘ADAPTOR’) {
continue;
} elseif ($itemCategory == ‘RO & WATER PURIFIER’) {
continue;
} elseif ($itemCategory == ‘AIR PURIFIER’) {
continue;
} elseif ($itemCategory == ‘HEATER’) {
continue;
} elseif ($itemCategory == ‘WIFI ADAPTOR’) {
continue;
} elseif ($itemCategory == ‘COFFEE MACHINE’) {
continue;
} elseif ($itemCategory == ‘STABILIZER’) {
continue;
} elseif ($itemCategory == ‘DC (SINGLE DOOR)’) {
continue;
} elseif ($itemCategory == ‘BOX’) {
continue;
} elseif ($itemCategory == ‘WINDOW KEY’) {
continue;
} else {
// If no match is found in the array, no modification is done
}
// Display the table row with the modified ItemName
echo “
“;
echo “
” . $itemCategory . “ |
“;
echo “
” . $itemName . “ |
“;
echo “
“;
}
echo “
“;
echo “
“;
} else {
echo “
No Consumed Detail available for this item.
“;
}
echo ‘Back‘;
}
// Close cURL session
curl_close($ch);
}
?>