feat: Add software licenses management page and update payment handling
- Introduced a new licenses management page with functionality to create, update, and view software licenses. - Updated payment return handling in softwaretool.php to check payment status from the database and display appropriate modals for success, pending, and failure states. - Enhanced webhook_mollie.php to log webhook calls, handle payment status updates directly in the database, and generate invoices based on payment status. - Improved CSS styles for better alignment of buttons and modal components. - Added JavaScript for modal interactions and bulk license creation functionality.
This commit is contained in:
@@ -1418,7 +1418,8 @@ function getWhereclauselvl2($table_name,$permission,$partner,$method){
|
||||
"software" => "p.accounthierarchy",
|
||||
"transactions" => "tx.accounthierarchy",
|
||||
"dealers" => "d.accounthierarchy",
|
||||
"categories" => "c.accounthierarchy"
|
||||
"categories" => "c.accounthierarchy",
|
||||
"products_software_licenses" => "l.accounthierarchy"
|
||||
];
|
||||
|
||||
$table = ($table_name != '') ? $table[$table_name] : 'accounthierarchy';
|
||||
@@ -5154,23 +5155,7 @@ function updateSoftwareVersionStatus($pdo, $serialnumber = null) {
|
||||
$stmt->execute($bind_params);
|
||||
|
||||
//------------------------------------------
|
||||
// STEP 3: Set sw_version_latest = 0 for equipment NOT matching latest version
|
||||
//------------------------------------------
|
||||
$sql = 'UPDATE equipment e
|
||||
JOIN products_software_assignment psa ON e.productrowid = psa.product_id AND psa.status = 1
|
||||
JOIN products_software_versions psv ON psa.software_version_id = psv.rowID
|
||||
SET e.sw_version_latest = 0
|
||||
WHERE psv.latest = 1
|
||||
AND psv.status = 1
|
||||
AND lower(e.sw_version) <> lower(psv.version)
|
||||
AND (psv.hw_version = e.hw_version OR psv.hw_version IS NULL OR psv.hw_version = "")
|
||||
AND e.sw_version_latest = 1' . $sn_clause;
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($bind_params);
|
||||
|
||||
//------------------------------------------
|
||||
// STEP 4: Set sw_version_latest = 1 for equipment matching latest version
|
||||
// STEP 3: Set sw_version_latest = 1 for equipment matching latest version
|
||||
//------------------------------------------
|
||||
$sql = 'UPDATE equipment e
|
||||
JOIN products_software_assignment psa ON e.productrowid = psa.product_id AND psa.status = 1
|
||||
@@ -5179,7 +5164,7 @@ function updateSoftwareVersionStatus($pdo, $serialnumber = null) {
|
||||
WHERE psv.latest = 1
|
||||
AND psv.status = 1
|
||||
AND lower(e.sw_version) = lower(psv.version)
|
||||
AND (psv.hw_version = e.hw_version OR psv.hw_version IS NULL OR psv.hw_version = "")
|
||||
AND (lower(psv.hw_version) = lower(e.hw_version) OR lower(psv.hw_version) IS NULL OR lower(psv.hw_version) = "")
|
||||
AND e.sw_version_latest = 0' . $sn_clause;
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
@@ -5542,4 +5527,49 @@ function generateSoftwareInvoice($invoice_data, $order_id, $language = 'US') {
|
||||
</html>';
|
||||
|
||||
return [$html, $customer_email, $order_id];
|
||||
}
|
||||
|
||||
/**
|
||||
* Update latest flags for software versions
|
||||
* Max 2 latest flags per hw_version: 1 with price (has upgrade path with price) and 1 without
|
||||
*
|
||||
* @param PDO $pdo - Database connection
|
||||
* @param int $version_id - The version ID being set as latest
|
||||
* @param string $hw_version - Hardware version
|
||||
*/
|
||||
function updateSoftwareLatestFlags($pdo, $version_id, $hw_version) {
|
||||
//Check if current version has a priced upgrade path
|
||||
$sql = 'SELECT COUNT(*) as has_price
|
||||
FROM products_software_upgrade_paths
|
||||
WHERE to_version_id = ? AND is_active = 1 AND price > 0';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$version_id]);
|
||||
$current_has_price = $stmt->fetch(PDO::FETCH_ASSOC)['has_price'] > 0;
|
||||
|
||||
//Remove latest flag only from versions in the same category (priced or free)
|
||||
//Get all versions with same hw_version and check their pricing
|
||||
$sql = 'SELECT psv.rowID,
|
||||
CASE
|
||||
WHEN EXISTS(
|
||||
SELECT 1 FROM products_software_upgrade_paths pup
|
||||
WHERE pup.to_version_id = psv.rowID
|
||||
AND pup.is_active = 1
|
||||
AND pup.price > 0
|
||||
) THEN 1
|
||||
ELSE 0
|
||||
END as has_price
|
||||
FROM products_software_versions psv
|
||||
WHERE psv.hw_version = ? AND psv.rowID != ?';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$hw_version, $version_id]);
|
||||
$versions = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
//Update only versions in the same price category
|
||||
foreach ($versions as $version) {
|
||||
if ($version['has_price'] == ($current_has_price ? 1 : 0)) {
|
||||
$sql = 'UPDATE products_software_versions SET latest = 0 WHERE rowID = ?';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$version['rowID']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user