CMXX - Firmware update improvements

This commit is contained in:
“VeLiTi”
2025-03-12 12:40:35 +01:00
parent faf5a5156b
commit ecc045f98a
8 changed files with 6452 additions and 4877 deletions

View File

@@ -3401,7 +3401,7 @@ class ShoppingCartCalculator {
private function getTaxRate() {
$sql = "SELECT rate FROM taxes WHERE country = ?";
$sql = "SELECT rate FROM taxes WHERE id = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute([$this->selected_country]);
$tax = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -3557,7 +3557,7 @@ class ShoppingCartCalculator {
}
private function calculateTaxTotal($amount_to_tax) {
$sql = "SELECT rate FROM taxes WHERE country = ?";
$sql = "SELECT rate FROM taxes WHERE id = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute([$this->selected_country]);
$tax = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -3866,4 +3866,47 @@ function createGiftCart($pdo, $orderID, $giftcard_categoryID,$accounthierarchy){
}
}
}
//=======================================
// findGitCommitHash
//=======================================
function findShortGitCommitHash($string) {
// Step 1: Find all hexadecimal sequences
preg_match_all('/[0-9a-f]+/i', $string, $matches);
$allHexMatches = $matches[0] ?? [];
// Step 2: Filter to only include those with exactly 6 or 7 characters
$commitHashes = array_filter($allHexMatches, function($match) {
return strlen($match) === 6 || strlen($match) === 7;
});
return array_values($commitHashes); // Re-index array
}
function compareCommitCodes($stringA, $stringB) {
// Get commit codes from both strings
$commitCodesA = findShortGitCommitHash($stringA);
$commitCodesB = findShortGitCommitHash($stringB);
// Case 1: Check if there are matching commit codes between A and B
foreach ($commitCodesA as $codeA) {
if (in_array($codeA, $commitCodesB)) {
return $codeA; // Return the first matching commit code
}
}
// Case 2: If A has commit code but B doesn't
if (count($commitCodesA) > 0 && count($commitCodesB) === 0) {
return $commitCodesA[0]; // Return the first commit code from A
}
// Case 3: If A has no commit code but B does
if (count($commitCodesA) === 0 && count($commitCodesB) > 0) {
return $commitCodesB[0]; // Return the first commit code from B
}
// Case 4: Neither has commit code
return "";
}