function licensing_customerscontent_licensing_BeforeInsert(&$sender) { $licensing_customerscontent_licensing_BeforeInsert = true; $Component =& $sender; $Container =& CCGetParentContainer($sender); global $licensing_customerscontent; //Compatibility //End licensing_customerscontent_licensing_BeforeInsert //Custom Code @188-2A29BDB7 // ------------------------- // Write your own code here. $suiteId = $licensing_customerscontent->licensing->suite_code->GetValue(); $params = array(); $params["suite_id"] = $suiteId; $products = new Alm\Products(); $suiteStatus = $products->getSuiteStatusById($params); //Check if suite status is active or legacy before adding any new licenses to a customer if ($suiteStatus["suiteStatus"] == "1" || $suiteStatus["suiteStatus"] == "2") { $guid = uuid_create(); global $lastguid; $lastguid = $guid; $licensing_customerscontent->licensing->created_iduser->SetValue(CCGetUserID()); $licensing_customerscontent->licensing->hidguid->SetValue($guid); //Customer ID for the license $customer_guid = trim($licensing_customerscontent->licensing->hidcustomer_guid->GetValue()); $db = new clsDBdbConnection(); $customer_id = CCDLookup("id", "alm_customers", "guid = '{$customer_guid}'", $db); $db->close(); $licensing_customerscontent->licensing->hidcustomer_id->SetValue($customer_id); //Changing license status to active when inactive and grant,expdate,expirdate are present $grantNo = trim($licensing_customerscontent->licensing->grant_number->GetValue()); $expDate = $licensing_customerscontent->licensing->expedition_date->GetValue(); $expirDate = $licensing_customerscontent->licensing->expiration_date->GetValue(); $licenseStatus = (int) $licensing_customerscontent->licensing->hidlicensestatus->GetValue(); $licenseType = (int) $licensing_customerscontent->licensing->id_license_type->GetValue(); $o = trim($licensing_customerscontent->licensing->hido->GetValue()); $dguid = trim($licensing_customerscontent->licensing->hiddguid->GetValue()); $params = array(); $params["guid"] = $dguid; if ($o == "renew") { //Keeps the expired license guid reference on the new renewed license $licensing_customerscontent->licensing->hidexpired_license_guid->SetValue($dguid); } //Making sure that perpetual licenses dont get expiration date values //And change status to active if grantnumber, expiration date have values //This changed, perpetuals will be autoactivated and user redirected to add the support license automatically if ($licenseStatus == 1 && strlen($grantNo) > 0 && count($expDate) > 1 && count($expirDate) > 1) { if ($licenseType == 7 || $licenseType == 12) { $licensing_customerscontent->licensing->expiration_date->SetValue(""); } $licensing_customerscontent->licensing->hidlicensestatus->SetValue("2"); //If renewing and new license is activated, sets expired license as archived if ($o == "renew") { $products = new Alm\Products(); $products->setLicenseArchivedByGuid($params); } } else { //Its a perpetual license if ($licenseStatus == 1 && ($licenseType == 7 || $licenseType == 12)) { $licensing_customerscontent->licensing->expiration_date->SetValue(""); $licensing_customerscontent->licensing->hidlicensestatus->SetValue("2"); } } //Checking if its an addsupport operation to set the support parent perpetual license $parentLicenseGuid = trim($licensing_customerscontent->licensing->hiddguid->GetValue()); $o = trim($licensing_customerscontent->licensing->hido->GetValue()); if ($o == "addsupport" && strlen($parentLicenseGuid) > 0) { $licensing_customerscontent->licensing->hidparent_license_guid->SetValue($parentLicenseGuid); } //Upgrade licensing $o = $licensing_customerscontent->licensing->hido->GetValue(); if (strlen($dguid) > 0 && $o == "upgrade_license") { //Keeps the expired license guid reference on the new renewed license $licensing_customerscontent->licensing->hidexpired_license_guid->SetValue($dguid); $params = array(); $params["guid"] = $dguid; $products = new Alm\Products(); $products->setLicenseArchivedByGuid($params); } } else { global $CCSLocales; $licensing_customerscontent->licensing->InsertAllowed = false; $licensing_customerscontent->licensing->Errors->clear(); $licensing_customerscontent->licensing->Errors->addError($CCSLocales->GetText("suite_status_notactivelegacy")); } // ------------------------- //End Custom Code //Close licensing_customerscontent_licensing_BeforeInsert @154-8C89F39C return $licensing_customerscontent_licensing_BeforeInsert; }
function products_maintcontent_alm_products_BeforeInsert(&$sender) { $products_maintcontent_alm_products_BeforeInsert = true; $Component =& $sender; $Container =& CCGetParentContainer($sender); global $products_maintcontent; //Compatibility //End products_maintcontent_alm_products_BeforeInsert //Custom Code @34-2A29BDB7 // ------------------------- // Write your own code here. //Check if the suite is active before adding a product for it $suiteId = $products_maintcontent->alm_products->suite_code->GetValue(); $params = array(); $params["suite_id"] = $suiteId; $products = new Alm\Products(); $suiteStatus = $products->getSuiteStatusById($params); //Check if suite status is active before adding any new product for it if ($suiteStatus["suiteStatus"] == "1" || $suiteStatus["suiteStatus"] == "2") { $guid = uuid_create(); global $lastguid; $lastguid = $guid; $products_maintcontent->alm_products->created_iduser->SetValue(CCGetUserID()); $products_maintcontent->alm_products->hidguid->SetValue($guid); } else { global $CCSLocales; $products_maintcontent->alm_products->InsertAllowed = false; $products_maintcontent->alm_products->Errors->clear(); $products_maintcontent->alm_products->Errors->addError($CCSLocales->GetText("suite_status_notactive")); } // ------------------------- //End Custom Code //Close products_maintcontent_alm_products_BeforeInsert @2-A4122BFF return $products_maintcontent_alm_products_BeforeInsert; }