コード例 #1
0
function licensing_viewfilecontent_BeforeShow(&$sender)
{
    $licensing_viewfilecontent_BeforeShow = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $licensing_viewfilecontent;
    //Compatibility
    //End licensing_viewfilecontent_BeforeShow
    //Custom Code @3-2A29BDB7
    // -------------------------
    // Write your own code here.
    $licensefile_guid = trim(CCGetFromGet("licensefile_guid", ""));
    if (strlen($licensefile_guid) > 0) {
        $params = array();
        $params["licensefile_guid"] = $licensefile_guid;
        $products = new \Alm\Products();
        $licenseFile = $products->getLicenseFileByGuid($params);
        $licenseFile = $licenseFile["licensefile"];
        foreach ($licenseFile as $licensefile) {
            $licensing_viewfilecontent->lbfileurl->SetValue($licensefile["filename"]);
        }
    } else {
        header("Location: licensing.php");
    }
    // -------------------------
    //End Custom Code
    //Close licensing_viewfilecontent_BeforeShow @1-C96E08DA
    return $licensing_viewfilecontent_BeforeShow;
}
function licensing_customerscontent_BeforeShow(&$sender)
{
    $licensing_customerscontent_BeforeShow = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $licensing_customerscontent;
    //Compatibility
    //End licensing_customerscontent_BeforeShow
    //Custom Code @152-2A29BDB7
    // -------------------------
    // Write your own code here.
    global $Tpl;
    $tab = CCGetFromGet("tab", "tab1_active");
    switch ($tab) {
        default:
        case "details":
            $Tpl->setvar("tab1_active", "active");
            break;
        case "licensing":
            $Tpl->setvar("tab2_active", "active");
            break;
        case "licenselist":
            $Tpl->setvar("tab3_active", "active");
            break;
        case "licensearchive":
            $Tpl->setvar("tab4_active", "active");
            break;
        case "competitor_renewals":
            $Tpl->setvar("tab5_active", "active");
            break;
        case "product_displacement":
            $Tpl->setvar("tab6_active", "active");
            break;
    }
    //Setting the active tab for licensing when the cssForm is present and has licensing as the form submitted
    $cssForm = trim(CCGetFromGet("ccsForm", ""));
    if ($cssForm == "licensing") {
        //Whichever tab set will be reset to avoid more than 1 tab active
        $Tpl->setvar("tab1_active", "");
        $Tpl->setvar("tab2_active", "active");
        $Tpl->setvar("tab3_active", "");
        $Tpl->setvar("tab4_active", "");
        $Tpl->setvar("tab5_active", "");
        $Tpl->setvar("tab6_active", "");
    }
    //Settingup saved message popup
    global $MainPage;
    $showalert = CCGetSession("showalert", "hide");
    $MainPage->Attributes->SetValue("showalert", $showalert);
    if ($showalert == "show") {
        CCSetSession("showalert", "hide");
    }
    //Setting up alerts to let user know the customer has not contacts yet
    $customers = new Customers();
    $customer_guid = CCGetFromGet("guid", "");
    $params = array();
    $params["customer_guid"] = $customer_guid;
    $hasContacts = $customers->customerHasContacts($params);
    if ($hasContacts["hasContacts"] == "1") {
        $MainPage->Attributes->SetValue("showalert_contacterror", "hide");
    } else {
        $MainPage->Attributes->SetValue("showalert_contacterror", "show");
    }
    //Setting up alerts to let user know the license may need support
    $license_guid = trim(CCGetFromGet("license_guid", ""));
    if (strlen($license_guid) > 0) {
        $products = new Alm\Products();
        $params = array();
        $params["license_guid"] = $license_guid;
        $hasSupport = $products->licenseHasSupport($params);
        if ($hasSupport["hasSupport"] == "1") {
            $MainPage->Attributes->SetValue("showalert_addsupport", "hide");
        } else {
            $MainPage->Attributes->SetValue("showalert_addsupport", "show");
        }
    } else {
        $MainPage->Attributes->SetValue("showalert_addsupport", "hide");
    }
    //Check if session variable showalert_addsupport has a show value
    $showalert_addsupport = CCGetSession("showalert_addsupport", "");
    if ($showalert_addsupport == "show") {
        CCSetSession("showalert_addsupport", "hide");
        $MainPage->Attributes->SetValue("showalert_addsupport", $showalert);
    }
    //Procesing file uploading
    $hidlicense_guid = trim(CCGetFromPost("hidlicense_guid", ""));
    if (!empty($_FILES) && strlen($hidlicense_guid) > 0) {
        $params = array();
        $params["license_guid"] = $hidlicense_guid;
        $products = new \Alm\Products();
        $products->uploadLicenseFile($_FILES, $params);
        //Finishing script execution for file uploads because its asyncronous
        exit;
    }
    $license_guid = trim(CCGetFromGet("license_guid", ""));
    $licensefile_guid = trim(CCGetFromGet("licensefile_guid", ""));
    $o = trim(CCGetFromGet("o", ""));
    //Delete licensing operation
    if (strlen($licensefile_guid) > 0 && $o == "dellicense") {
        $params = array();
        $params["licensefile_guid"] = $licensefile_guid;
        $products = new \Alm\Products();
        $products->deleteLicenseFileByGuid($params);
        $querystring = CCGetQueryString("QueryString", array("licensefile_guid", "o"));
        global $FileName;
        $urlRedirect = $FileName . "?{$querystring}";
        header("Location: {$urlRedirect}");
    }
    //Delete full licensing operation
    if (strlen($license_guid) > 0 && $o == "delfulllicense") {
        $params = array();
        $params["license_guid"] = $license_guid;
        $products = new \Alm\Products();
        $products->deleteFullLicenseByGuid($params);
        $querystring = CCGetQueryString("QueryString", array("license_guid", "o"));
        global $FileName;
        $urlRedirect = $FileName . "?{$querystring}";
        header("Location: {$urlRedirect}");
    }
    if (strlen($license_guid) > 0) {
        //License files grid
        $params = array();
        $params["license_guid"] = $license_guid;
        $products = new \Alm\Products();
        $licenseFiles = $products->getLicenseFiles($params);
        $licenseFiles = $licenseFiles["licensefiles"];
        $querystring = CCGetQueryString("QueryString", array("o", "licensefile_guid", "tab"));
        foreach ($licenseFiles as $licenseFile) {
            $licensefile_guid = $licenseFile["guid"];
            $linkdelete = "";
            if (CCGetGroupID() == "4") {
                //Moved linkdelete to code because issues displaying panels inside custom template blocks
                $linkdelete = "<a href='licensing_customers.php?o=dellicense&licensefile_guid={$licensefile_guid}&tab=licenselist&{$querystring}' class='dellicense' ><li class='icon-trash bigger-150 red'></li></a>";
            }
            $Tpl->setvar("linkdelete", $linkdelete);
            $Tpl->setvar("licensefile_guid", $licensefile_guid);
            $Tpl->setvar("getparams", "&" . $querystring);
            $Tpl->Parse("licensefile_list", true);
        }
    }
    // -------------------------
    //End Custom Code
    //Close licensing_customerscontent_BeforeShow @1-0B488567
    return $licensing_customerscontent_BeforeShow;
}
コード例 #3
0
function products_maintcontent_alm_products_BeforeShow(&$sender)
{
    $products_maintcontent_alm_products_BeforeShow = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $products_maintcontent;
    //Compatibility
    //End products_maintcontent_alm_products_BeforeShow
    //Custom Code @53-2A29BDB7
    // -------------------------
    // Write your own code here.
    global $MainPage;
    $o = trim(CCGetFromGet("o", ""));
    $dguid = trim(CCGetFromGet("dguid", ""));
    $querystring = CCGetQueryString("QueryString", array("o", "dguid"));
    if ($o == "duplicate") {
        $params = array();
        $params["guid"] = $dguid;
        $products = new Alm\Products();
        $product = $products->getProductByGuid($params);
        $product = $product["product"];
        if (count($product) >= 1) {
            $products_maintcontent->alm_products->suite_code->SetValue($product["id_suite"]);
            $products_maintcontent->alm_products->id_licensed_by->SetValue($product["id_licensed_by"]);
            $products_maintcontent->alm_products->licensed_amount->SetValue($product["licensed_amount"]);
            $products_maintcontent->alm_products->id_license_sector->SetValue($product["id_license_sector"]);
            $products_maintcontent->alm_products->id_product_tag->SetValue($product["id_product_tag"]);
            $products_maintcontent->alm_products->id_license_type->SetValue($product["id_license_type"]);
            $products_maintcontent->alm_products->id_product_type->SetValue($product["id_product_type"]);
            $products_maintcontent->alm_products->range_min->SetValue($product["range_min"]);
            $products_maintcontent->alm_products->range_max->SetValue($product["range_max"]);
            $products_maintcontent->alm_products->msrp_price->SetValue($product["msrp_price"]);
            $products_maintcontent->alm_products->product_content->SetValue($product["product_content"]);
            $products_maintcontent->alm_products->detaileddescription->SetValue($product["description"]);
            //Show general alert with duplication info taking place
            global $CCSLocales;
            CCSetSession("showglobal_alert", "show");
            $products_maintcontent->alm_products->showglobal_alert->SetValue("show");
            $products_maintcontent->alm_products->lbtitle->SetValue($CCSLocales->GetText("duplicate_product"));
            $products_maintcontent->alm_products->lbmessage->SetValue($CCSLocales->GetText("duplicate_message"));
        }
        $products_maintcontent->alm_products->querystring->SetValue($querystring);
    } else {
        CCSetSession("showglobal_alert", "hide");
    }
    // -------------------------
    //End Custom Code
    //Close products_maintcontent_alm_products_BeforeShow @2-F6F8DF25
    return $products_maintcontent_alm_products_BeforeShow;
}
コード例 #4
0
function products_suite_list_BeforeShow(&$sender)
{
    $products_suite_list_BeforeShow = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $products_suite_list;
    //Compatibility
    //End products_suite_list_BeforeShow
    //Custom Code @44-2A29BDB7
    // -------------------------
    // Write your own code here.
    //Delete record operation
    $del_guid = CCGetFromGet("del_guid", "");
    $o = CCGetFromGet("o", "");
    if ($o == "delrecord" && strlen($del_guid) > 0) {
        global $FileName;
        $params["del_guid"] = $del_guid;
        $products = new Alm\Products();
        $products->deleteProductSuiteByGuid($params);
        $querystring = CCGetQueryString("QueryString", array("o", "del_guid"));
        //Forcing redirect
        header("Location: {$FileName}?{$querystring}");
    }
    // -------------------------
    //End Custom Code
    //Close products_suite_list_BeforeShow @1-AB240682
    return $products_suite_list_BeforeShow;
}
function licensing_competitor_renewals_BeforeShow(&$sender)
{
    $licensing_competitor_renewals_BeforeShow = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $licensing_competitor_renewals;
    //Compatibility
    //End licensing_competitor_renewals_BeforeShow
    //Custom Code @2-2A29BDB7
    // -------------------------
    // Write your own code here.
    //********************************
    //Displaying the competitor renewal licenses
    //Code was copied from archived tab as a template, thats why variables has archived on it
    //********************************
    $guid = CCGetFromGet("guid", "");
    $license_guid = CCGetFromGet("license_guid", "");
    $tab = CCGetFromGet("tab", "");
    $o = CCGetFromGet("o", "");
    $params = array();
    $params["customer_guid"] = $guid;
    $params["license_guid"] = $license_guid;
    if (strlen($guid) > 0) {
        global $Tpl;
        global $FileName;
        $products = new \Alm\Products();
        //Will make the method return only the archived ones
        $params["isCompetitor"] = 1;
        $licenses = $products->getCustomerUniqueLicenses($params);
        $allLicenses = $licenses["licenses"];
        foreach ($allLicenses as $license) {
            $Tpl->setvar("lbguid_archived", $guid);
            $Tpl->setvar("lblicense_guid_archived", $license["guid"]);
            $Tpl->setvar("lbsuite_code_archived", $license["suite_code"]);
            $Tpl->setvar("lbsuite_description_archived", $license["suite_description"]);
            $Tpl->setvar("lbdescription_archived", $license["description"]);
            $Tpl->setvar("lbproduct_typeicon_archived", $license["type_icon_name"]);
            $Tpl->setvar("lblicense_name_archived", $license["license_name"]);
            $Tpl->setvar("lblicensedby_name_archived", $license["licensedby_name"]);
            $Tpl->setvar("lblicense_status_archived", $license["license_status_name"]);
            $Tpl->setvar("lblicense_status_css_archived", $license["alm_license_status_css_color"]);
            $Tpl->setvar("renewlicense_competitor_show_archived", "hide");
            $Tpl->setvar("renewlicense_competitordate_show_archived", "hide");
            if (strlen($license["renew_businesspartner"]) > 0) {
                $Tpl->setvar("renewlicense_competitor_archived", $license["renew_businesspartner"]);
                $Tpl->setvar("renewlicense_competitordate_archived", date("m/d/Y", strtotime($license["renew_businesspartner_date"])));
                $Tpl->setvar("renewlicense_competitor_show_archived", "show");
                $Tpl->setvar("renewlicense_competitordate_show_archived", "show");
            }
            if ($license["id_licensed_by"] == "1") {
                $Tpl->setvar("lbnodes_qty_archived", $license["nodes"]);
            } else {
                $Tpl->setvar("lbnodes_qty_archived", $license["licensed_amount"]);
            }
            //Total cost of license
            $price = $license["msrp_price"];
            $licenseBy = $license["id_licensed_by"];
            $nodes = $license["nodes"];
            $licenseAmount = $license["licensed_amount"];
            //Hides the granttype info if not value present
            if (strlen(trim($license["grant_number"])) <= 0) {
                $Tpl->setvar("lbgranttype_archived_class", "hide");
            } else {
                $Tpl->setvar("lbgranttype_archived_class", "");
                $Tpl->setvar("lbgranttype_archived", $license["granttype_name"]);
                $Tpl->setvar("lbgrantnumber_archived", $license["grant_number"]);
            }
            if (strlen(trim($license["serial_number"])) <= 0) {
                $Tpl->setvar("lbserial_archived_class", "hide");
            } else {
                $Tpl->setvar("lbserial_archived_class", "");
                $Tpl->setvar("lbserialnumber_archived", $license["serial_number"]);
            }
            $Tpl->setvar("lblicense_for_archived", $license["sector_name"]);
            if (strlen($license["expedition_date"]) <= 0) {
                $expDate = "";
            } else {
                $expDate = date("m/d/Y", strtotime($license["expedition_date"]));
            }
            $Tpl->setvar("lbexpedition_archived", $expDate);
            if (strlen($license["expiration_date"]) <= 0) {
                $expirDate = "";
            } else {
                $expirDate = date("m/d/Y", strtotime($license["expiration_date"]));
            }
            $Tpl->setvar("lbexpiration_archived", $expirDate);
            //Generate link to delete license only for admins
            $linkdelete_license = "";
            if (CCGetGroupID() == "4") {
                $licenseGuid = $license["guid"];
                global $CCSLocales;
                $deleteCaption = $CCSLocales->GetText("deletelicense");
                $linkdelete_license = "<a href='licensing_customers.php?guid={$guid}&o=delfulllicense&license_guid={$licenseGuid}&tab=licenselist' class='dellicense'>{$deleteCaption}</a>";
            }
            $Tpl->setvar("linkdelete_license_archived", $linkdelete_license);
            $parentPath = $Tpl->block_path;
            $Tpl->block_path = $Tpl->block_path . "/licensearchived_list";
            $Tpl->SetBlockVar("license_popup_archived", "");
            //Displaying popup table for licenses with the same grant number
            $grantNumber = $license["grant_number"];
            $licenseID = $license["id"];
            $params["grant_number"] = $grantNumber;
            $params["license_id"] = $licenseID;
            //Will make the method return only the archived ones
            $params["isArchived"] = 1;
            $licensesPopup = $products->getCustomerRelatedLicenses($params);
            $allLicensesPopup = $licensesPopup["licenses"];
            $totalShared = 0;
            foreach ($allLicensesPopup as $licensePopup) {
                $Tpl->setvar("lbguid_popup_archived", $guid);
                $Tpl->setvar("lblicense_guid_popup_archived", $licensePopup["guid"]);
                $Tpl->setvar("lbsuite_code_popup_archived", $licensePopup["suite_code"]);
                $Tpl->setvar("lbsuite_description_popup_archived", $licensePopup["suite_description"]);
                $Tpl->setvar("lbdescription_popup_archived", $licensePopup["description"]);
                $Tpl->setvar("lbproduct_typeicon_popup_archived", $licensePopup["type_icon_name"]);
                $Tpl->setvar("lblicense_name_popup_archived", $licensePopup["license_name"]);
                $Tpl->setvar("lblicensedby_name_popup_archived", $licensePopup["licensedby_name"]);
                $Tpl->setvar("lblicense_status_popup_archived", $licensePopup["license_status_name"]);
                $Tpl->setvar("lblicense_status_css_popup_archived", $licensePopup["alm_license_status_css_color"]);
                $Tpl->setvar("renewlicense_competitor_show_popup_archived", "hide");
                $Tpl->setvar("renewlicense_competitordate_show_popup_archived", "hide");
                if (strlen($licensePopup["renew_businesspartner"]) > 0) {
                    $Tpl->setvar("renewlicense_competitor_popup_archived", $licensePopup["renew_businesspartner"]);
                    $Tpl->setvar("renewlicense_competitordate_popup_archived", $licensePopup["renew_businesspartner_date"]);
                    $Tpl->setvar("renewlicense_competitor_show_popup_archived", "show");
                    $Tpl->setvar("renewlicense_competitordate_show_popup_archived", "show");
                }
                if ($licensePopup["id_licensed_by"] == "1") {
                    $Tpl->setvar("lbnodes_qty_popup_archived", $licensePopup["nodes"]);
                } else {
                    $Tpl->setvar("lbnodes_qty_popup_archived", $licensePopup["licensed_amount"]);
                }
                //Total cost of license
                $price = $licensePopup["msrp_price"];
                $licenseBy = $licensePopup["id_licensed_by"];
                $nodes = $licensePopup["nodes"];
                $licenseAmount = $licensePopup["licensed_amount"];
                //Hides the granttype info if not value present
                if (strlen(trim($licensePopup["grant_number"])) <= 0) {
                    $Tpl->setvar("lbgranttype_popup_archived_class", "hide");
                } else {
                    $Tpl->setvar("lbgranttype_popup_archived_class", "");
                    $Tpl->setvar("lbgranttype_popup_archived", $licensePopup["granttype_name"]);
                    $Tpl->setvar("lbgrantnumber_popup_archived", $licensePopup["grant_number"]);
                }
                if (strlen(trim($licensePopup["serial_number"])) <= 0) {
                    $Tpl->setvar("lbserial_popup_archived_class", "hide");
                } else {
                    $Tpl->setvar("lbserial_popup_archived_class", "");
                    $Tpl->setvar("lbserialnumber_popup_archived", $licensePopup["serial_number"]);
                }
                $Tpl->setvar("lblicense_for_popup_archived", $licensePopup["sector_name"]);
                if (strlen($licensePopup["expedition_date"]) <= 0) {
                    $expDate = "";
                } else {
                    $expDate = date("m/d/Y", strtotime($licensePopup["expedition_date"]));
                }
                $Tpl->setvar("lbexpedition_popup_archived", $expDate);
                if (strlen($licensePopup["expiration_date"]) <= 0) {
                    $expirDate = "";
                } else {
                    $expirDate = date("m/d/Y", strtotime($licensePopup["expiration_date"]));
                }
                $Tpl->setvar("lbexpiration_popup_archived", $expirDate);
                //Generate link to delete license only for admins
                $linkdelete_license = "";
                if (CCGetGroupID() == "4") {
                    $licenseGuid = $licensePopup["guid"];
                    $linkdelete_license = "<a href='licensing_customers.php?guid={$guid}&o=delfulllicense&license_guid={$licenseGuid}&tab=licenselist' class='dellicense'><li class='icon-trash bigger-150 red'></li></a>";
                }
                $Tpl->setvar("linkdelete_license_popup_archived", $linkdelete_license);
                $Tpl->parse("license_popup_archived", true);
                $totalShared++;
            }
            //foreach licenses group into a popup for those with same grant number
            $table_detail = $Tpl->GetVar("license_popup_archived");
            $Tpl->block_path = $parentPath;
            $Tpl->SetBlockVar("license_popup_archived", $table_detail);
            //Displaying total licenses sharing grant number
            $Tpl->setvar("lbtotalshared_archived", "+{$totalShared}");
            $Tpl->parse("licensearchived_list", true);
        }
    }
    // -------------------------
    //End Custom Code
    //Close licensing_competitor_renewals_BeforeShow @1-6FCB42C9
    return $licensing_competitor_renewals_BeforeShow;
}
function licensing_activelicense_tab_BeforeShow(&$sender)
{
    $licensing_activelicense_tab_BeforeShow = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $licensing_activelicense_tab;
    //Compatibility
    //End licensing_activelicense_tab_BeforeShow
    //Custom Code @2-2A29BDB7
    // -------------------------
    // Write your own code here.
    //*******************************//
    //Licensing active //
    //*******************************//
    $guid = CCGetFromGet("guid", "");
    $license_guid = CCGetFromGet("license_guid", "");
    $tab = CCGetFromGet("tab", "");
    $o = CCGetFromGet("o", "");
    $params = array();
    $params["customer_guid"] = $guid;
    $params["license_guid"] = $license_guid;
    if (strlen($guid) > 0) {
        global $Tpl;
        global $FileName;
        //Filling up licenses grid
        $products = new \Alm\Products();
        $licenses = $products->getCustomerUniqueLicenses($params);
        $allLicenses = $licenses["licenses"];
        foreach ($allLicenses as $license) {
            $Tpl->setvar("lbguid", $guid);
            $Tpl->setvar("lblicense_guid", $license["guid"]);
            $Tpl->setvar("lbsuite_code", $license["suite_code"]);
            $Tpl->setvar("lbsuite_description", $license["suite_description"]);
            $Tpl->setvar("lbdescription", $license["description"]);
            $Tpl->setvar("lbproduct_typeicon", $license["type_icon_name"]);
            $Tpl->setvar("lblicense_name", $license["license_name"]);
            $Tpl->setvar("lblicensedby_name", $license["licensedby_name"]);
            $Tpl->setvar("lblicense_status", $license["license_status_name"]);
            $Tpl->setvar("lblicense_status_css", $license["alm_license_status_css_color"]);
            if ($license["id_licensed_by"] == "1") {
                $Tpl->setvar("lbnodes_qty", $license["nodes"]);
            } else {
                $Tpl->setvar("lbnodes_qty", $license["licensed_amount"]);
            }
            //Total cost of license
            $price = $license["msrp_price"];
            $licenseBy = $license["id_licensed_by"];
            $nodes = $license["nodes"];
            $licenseAmount = $license["licensed_amount"];
            //Hides the granttype info if not value present
            if (strlen(trim($license["grant_number"])) <= 0) {
                $Tpl->setvar("lbgranttype_class", "hide");
            } else {
                $Tpl->setvar("lbgranttype_class", "");
                $Tpl->setvar("lbgranttype", $license["granttype_name"]);
                $Tpl->setvar("lbgrantnumber", $license["grant_number"]);
            }
            if (strlen(trim($license["serial_number"])) <= 0) {
                $Tpl->setvar("lbserial_class", "hide");
            } else {
                $Tpl->setvar("lbserial_class", "");
                $Tpl->setvar("lbserialnumber", $license["serial_number"]);
            }
            $Tpl->setvar("lblicense_for", $license["sector_name"]);
            if (strlen($license["expedition_date"]) <= 0) {
                $expDate = "";
            } else {
                $expDate = date("m/d/Y", strtotime($license["expedition_date"]));
            }
            $Tpl->setvar("lbexpedition", $expDate);
            if (strlen($license["expiration_date"]) <= 0) {
                $expirDate = "";
            } else {
                $expirDate = date("m/d/Y", strtotime($license["expiration_date"]));
            }
            $Tpl->setvar("lbexpiration", $expirDate);
            //Generate renew link only when license has status of expired (3).
            $linkrenew_license = "";
            if ($license["id_license_status"] == "3" && $license["isarchived"] == "0") {
                $licenseGuid = $license["guid"];
                global $CCSLocales;
                $renewCaption = $CCSLocales->GetText("renewlicense");
                $linkrenew_license = "<li class='divider'></li><li><a href='licensing_customers.php?o=renew&guid={$guid}&dguid={$licenseGuid}&tab=licensing'>{$renewCaption}</a></li>";
            }
            $Tpl->setvar("linkrenew_license", $linkrenew_license);
            $linkrenew_license_competitor = "";
            $linkarchive_only = "";
            $linkupgrade_license = "";
            $linkproduct_displacement = "";
            if ($license["id_license_status"] == "3" && $license["isarchived"] == "0") {
                $licenseGuid = $license["guid"];
                global $CCSLocales;
                $renewCaption_competitor = $CCSLocales->GetText("renewlicense_competitor");
                $linkrenew_license_competitor = "<li><a href='licensing_customers.php?o=renew_competitor&guid={$guid}&license_guid={$licenseGuid}&tab=licensing'>{$renewCaption_competitor}</a></li>";
                //Add archive only link used when the license is upgraded which just add a new license.
                $archiveOnlyCaption = $CCSLocales->GetText("archive_only");
                $linkarchive_only = "<li class='divider'></li><li><a href='licensing_customers.php?o=archive_only&guid={$guid}&license_guid={$licenseGuid}&tab=licensing'>{$archiveOnlyCaption}</a></li>";
                //Upgrade to new license which is a new license but will archive the expired one.
                $upgradeLicenseCaption = $CCSLocales->GetText("upgrade_license");
                $linkupgrade_license = "<li class='divider'></li><li><a href='licensing_customers.php?o=upgrade_license&guid={$guid}&dguid={$licenseGuid}&tab=licensing'>{$upgradeLicenseCaption}</a></li>";
                //Product Displacement
                $productDisplacementCaption = $CCSLocales->GetText("product_displacement");
                $linkproduct_displacement = "<li><a href='licensing_customers.php?o=product_displacement&guid={$guid}&license_guid={$licenseGuid}&tab=licensing'>{$productDisplacementCaption}</a></li>";
            }
            $Tpl->setvar("linkarchive_only", $linkarchive_only);
            $Tpl->setvar("linkupgrade_license", $linkupgrade_license);
            $Tpl->setvar("linkproduct_displacement", $linkproduct_displacement);
            $Tpl->setvar("linkrenew_license_competitor", $linkrenew_license_competitor);
            //Generate link to delete license only for admins
            $linkdelete_license = "";
            if (CCGetGroupID() == "4") {
                $licenseGuid = $license["guid"];
                global $CCSLocales;
                $deleteCaption = $CCSLocales->GetText("deletelicense");
                $linkdelete_license = "<a href='licensing_customers.php?guid={$guid}&o=delfulllicense&license_guid={$licenseGuid}&tab=licenselist' class='dellicense'>{$deleteCaption}</a>";
            }
            $Tpl->setvar("linkdelete_license", $linkdelete_license);
            //Generating block renewal when 2 or more groupped licenses are expired.
            $params["grant_number"] = $license["grant_number"];
            $countLicenses = $products->isBlockRenewal($params);
            $countLicenses = (int) $countLicenses["count"];
            if ($countLicenses >= 2) {
                global $CCSLocales;
                $bulkrenewalCaption = $CCSLocales->GetText("bulkrenewal");
                $grantNumber = $license["grant_number"];
                $linkrenew_bulk = "<li><a href='licensing_bulkrenewal.php?guid={$guid}&o=bulkrenewal&grant_number={$grantNumber}&tab=licenselist' class=''>{$bulkrenewalCaption}</a></li>";
                $Tpl->setvar("linkrenew_bulk", $linkrenew_bulk);
            }
            $parentPath = $Tpl->block_path;
            $Tpl->block_path = $Tpl->block_path . "/license_list";
            $Tpl->SetBlockVar("license_popup", "");
            //Displaying popup table for licenses with the same grant number
            $grantNumber = $license["grant_number"];
            $licenseID = $license["id"];
            $params["grant_number"] = $grantNumber;
            $params["license_id"] = $licenseID;
            $licensesPopup = $products->getCustomerRelatedLicenses($params);
            $allLicensesPopup = $licensesPopup["licenses"];
            $totalShared = 0;
            foreach ($allLicensesPopup as $licensePopup) {
                $Tpl->setvar("lbguid_popup", $guid);
                $Tpl->setvar("lblicense_guid_popup", $licensePopup["guid"]);
                $Tpl->setvar("lbsuite_code_popup", $licensePopup["suite_code"]);
                $Tpl->setvar("lbsuite_description_popup", $licensePopup["suite_description"]);
                $Tpl->setvar("lbdescription_popup", $licensePopup["description"]);
                $Tpl->setvar("lbproduct_typeicon_popup", $licensePopup["type_icon_name"]);
                $Tpl->setvar("lblicense_name_popup", $licensePopup["license_name"]);
                $Tpl->setvar("lblicensedby_name_popup", $licensePopup["licensedby_name"]);
                $Tpl->setvar("lblicense_status_popup", $licensePopup["license_status_name"]);
                $Tpl->setvar("lblicense_status_css_popup", $licensePopup["alm_license_status_css_color"]);
                if ($licensePopup["id_licensed_by"] == "1") {
                    $Tpl->setvar("lbnodes_qty_popup", $licensePopup["nodes"]);
                } else {
                    $Tpl->setvar("lbnodes_qty_popup", $licensePopup["licensed_amount"]);
                }
                //Total cost of license
                $price = $licensePopup["msrp_price"];
                $licenseBy = $licensePopup["id_licensed_by"];
                $nodes = $licensePopup["nodes"];
                $licenseAmount = $licensePopup["licensed_amount"];
                //Hides the granttype info if not value present
                if (strlen(trim($licensePopup["grant_number"])) <= 0) {
                    $Tpl->setvar("lbgranttype_popup_class", "hide");
                } else {
                    $Tpl->setvar("lbgranttype_popup_class", "");
                    $Tpl->setvar("lbgranttype_popup", $licensePopup["granttype_name"]);
                    $Tpl->setvar("lbgrantnumber_popup", $licensePopup["grant_number"]);
                }
                if (strlen(trim($licensePopup["serial_number"])) <= 0) {
                    $Tpl->setvar("lbserial_popup_class", "hide");
                } else {
                    $Tpl->setvar("lbserial_popup_class", "");
                    $Tpl->setvar("lbserialnumber_popup", $licensePopup["serial_number"]);
                }
                $Tpl->setvar("lblicense_for_popup", $licensePopup["sector_name"]);
                if (strlen($licensePopup["expedition_date"]) <= 0) {
                    $expDate = "";
                } else {
                    $expDate = date("m/d/Y", strtotime($licensePopup["expedition_date"]));
                }
                $Tpl->setvar("lbexpedition_popup", $expDate);
                if (strlen($licensePopup["expiration_date"]) <= 0) {
                    $expirDate = "";
                } else {
                    $expirDate = date("m/d/Y", strtotime($licensePopup["expiration_date"]));
                }
                $Tpl->setvar("lbexpiration_popup", $expirDate);
                //Generate renew link only when license has status of expired (3).
                $linkrenew_license = "";
                if ($licensePopup["id_license_status"] == "3" && $licensePopup["isarchived"] == "0") {
                    $licenseGuid = $licensePopup["guid"];
                    global $CCSLocales;
                    $renewCaption = $CCSLocales->GetText("renewlicense");
                    $linkrenew_license = "<li class='divider'></li><li><a href='licensing_customers.php?o=renew&guid={$guid}&dguid={$licenseGuid}&tab=licensing'>{$renewCaption}</a></li>";
                }
                $Tpl->setvar("linkrenew_license_popup", $linkrenew_license);
                $linkrenew_license = "";
                $linkarchive_only_popup = "";
                $linkupgrade_license_popup = "";
                $linkproduct_displacement_popup = "";
                if ($licensePopup["id_license_status"] == "3" && $licensePopup["isarchived"] == "0") {
                    $licenseGuid = $licensePopup["guid"];
                    global $CCSLocales;
                    $renewCaption = $CCSLocales->GetText("renewlicense_competitor");
                    $linkrenew_license = "<li><a href='licensing_customers.php?o=renew_competitor&guid={$guid}&license_guid={$licenseGuid}&tab=licensing'>{$renewCaption}</a></li>";
                    //Add archive only link used when the license is upgraded which just add a new license.
                    $archiveOnlyCaption = $CCSLocales->GetText("archive_only");
                    $linkarchive_only_popup = "<li class='divider'></li><li><a href='licensing_customers.php?o=archive_only&guid={$guid}&license_guid={$licenseGuid}&tab=licensing'>{$archiveOnlyCaption}</a></li>";
                    //Upgrade to new license which is a new license but will archive the expired one.
                    $upgradeLicenseCaption = $CCSLocales->GetText("upgrade_license");
                    $linkupgrade_license_popup = "<li class='divider'></li><li><a href='licensing_customers.php?o=upgrade_license&guid={$guid}&dguid={$licenseGuid}&tab=licensing'>{$upgradeLicenseCaption}</a></li>";
                    //Product Displacement
                    $productDisplacementCaption = $CCSLocales->GetText("product_displacement");
                    $linkproduct_displacement_popup = "<li><a href='licensing_customers.php?o=product_displacement&guid={$guid}&license_guid={$licenseGuid}&tab=licensing'>{$productDisplacementCaption}</a></li>";
                }
                $Tpl->setvar("linkarchive_only_popup", $linkarchive_only_popup);
                $Tpl->setvar("linkupgrade_license_popup", $linkupgrade_license_popup);
                $Tpl->setvar("linkproduct_displacement_popup", $linkproduct_displacement_popup);
                $Tpl->setvar("linkrenew_license_competitor_popup", $linkrenew_license);
                //Generate link to delete license only for admins
                $linkdelete_license = "";
                if (CCGetGroupID() == "4") {
                    $licenseGuid = $licensePopup["guid"];
                    global $CCSLocales;
                    $deleteCaption = $CCSLocales->GetText("deletelicense");
                    $linkdelete_license = "<a href='licensing_customers.php?guid={$guid}&o=delfulllicense&license_guid={$licenseGuid}&tab=licenselist' class='dellicense'>{$deleteCaption}</a>";
                }
                $Tpl->setvar("linkdelete_license_popup", $linkdelete_license);
                $Tpl->parse("license_popup", true);
                $totalShared++;
            }
            //foreach licenses group into a popup for those with same grant number
            $table_detail = $Tpl->GetVar("license_popup");
            $Tpl->block_path = $parentPath;
            $Tpl->SetBlockVar("license_popup", $table_detail);
            //Displaying total licenses sharing grant number
            $Tpl->setvar("lbtotalshared", "+{$totalShared}");
            $Tpl->parse("license_list", true);
        }
    }
    // Licensing active
    // -------------------------
    //End Custom Code
    //Close licensing_activelicense_tab_BeforeShow @1-E648715B
    return $licensing_activelicense_tab_BeforeShow;
}
function licensing_bulkrenewalcontent_BeforeShow(&$sender)
{
    $licensing_bulkrenewalcontent_BeforeShow = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $licensing_bulkrenewalcontent;
    //Compatibility
    //End licensing_bulkrenewalcontent_BeforeShow
    //Custom Code @2-2A29BDB7
    // -------------------------
    // Write your own code here.
    //*******************************//
    //Licensing active //
    //*******************************//
    $guid = CCGetFromGet("guid", "");
    $grantNumber = CCGetFromGet("grant_number", "");
    $tab = CCGetFromGet("tab", "");
    $o = CCGetFromGet("o", "");
    $params = array();
    $params["grant_number"] = $grantNumber;
    //Settingup saved message popup
    global $MainPage;
    global $Tpl;
    global $FileName;
    $showalert = CCGetSession("showalert", "hide");
    $MainPage->Attributes->SetValue("showalert", $showalert);
    if ($showalert == "show") {
        CCSetSession("showalert", "hide");
    }
    $showerror = CCGetSession("showerror", "hide");
    $MainPage->Attributes->SetValue("showerror", $showerror);
    if ($showerror == "show") {
        CCSetSession("showerror", "hide");
    }
    $o_post = CCGetFromPost("hido", "");
    $grant_post = CCGetFromPost("hidgrant_number", "");
    $newgrant_post = CCGetFromPost("grantnumber", "");
    $tab_post = CCGetFromPost("hidtab", "licenselist");
    $guid_post = CCGetFromPost("hidguid", "");
    $exped_post = CCGetFromPost("expedition_date", "");
    $expir_post = CCGetFromPost("expiration_date", "");
    if ($o_post == "bulkrenewal") {
        if (strlen($grant_post) > 0 && strlen($newgrant_post) > 0 && strlen($exped_post) > 0 && strlen($expir_post) > 0) {
            //Reformating the dates
            $exped_array = CCParseDate($exped_post, array("mm", "/", "dd", "/", "yyyy"));
            $format = array("yyyy", "-", "mm", "-", "dd");
            $exped_post = CCFormatDate($exped_array, $format);
            //Reformating the dates
            $expir_array = CCParseDate($expir_post, array("mm", "/", "dd", "/", "yyyy"));
            $format = array("yyyy", "-", "mm", "-", "dd");
            $expir_post = CCFormatDate($expir_array, $format);
            $params["newgrant_number"] = $newgrant_post;
            $params["grant_number"] = $grant_post;
            $params["expedition_date"] = $exped_post;
            $params["expiration_date"] = $expir_post;
            $params["user_id"] = CCGetUserID();
            $products = new \Alm\Products();
            $result = $products->bulkRenew($params);
            if ($result["status"]) {
                CCSetSession("showalert", "show");
                header("Location: licensing_customers.php?guid={$guid_post}&tab={$tab_post}");
            } else {
                CCSetSession("showerror", "show");
                header("Location: {$FileName}?guid={$guid_post}&o={$o_post}&grant_number={$grant_post}&tab={$tab_post}");
            }
        } else {
            CCSetSession("showerror", "show");
            header("Location: {$FileName}?guid={$guid_post}&o={$o_post}&grant_number={$grant_post}&tab={$tab_post}");
        }
    }
    //endif o_post
    if (strlen($grantNumber) > 0 && $o == "bulkrenewal") {
        global $Tpl;
        global $FileName;
        //Filling up licenses grid
        $products = new \Alm\Products();
        $licenses = $products->getLicensesByGrantNumber($params);
        $allLicenses = $licenses["licenses"];
        foreach ($allLicenses as $license) {
            $Tpl->setvar("lbguid", $guid);
            $Tpl->setvar("lblicense_guid", $license["guid"]);
            $Tpl->setvar("lbsuite_code", $license["suite_code"]);
            $Tpl->setvar("lbsuite_description", $license["suite_description"]);
            $Tpl->setvar("lbdescription", $license["description"]);
            $Tpl->setvar("lbproduct_typeicon", $license["type_icon_name"]);
            $Tpl->setvar("lblicense_name", $license["license_name"]);
            $Tpl->setvar("lblicensedby_name", $license["licensedby_name"]);
            $Tpl->setvar("lblicense_status", $license["license_status_name"]);
            $Tpl->setvar("lblicense_status_css", $license["alm_license_status_css_color"]);
            if ($license["id_licensed_by"] == "1") {
                $Tpl->setvar("lbnodes_qty", $license["nodes"]);
            } else {
                $Tpl->setvar("lbnodes_qty", $license["licensed_amount"]);
            }
            //Total cost of license
            $price = $license["msrp_price"];
            $licenseBy = $license["id_licensed_by"];
            $nodes = $license["nodes"];
            $licenseAmount = $license["licensed_amount"];
            //Hides the granttype info if not value present
            if (strlen(trim($license["grant_number"])) <= 0) {
                $Tpl->setvar("lbgranttype_class", "hide");
            } else {
                $Tpl->setvar("lbgranttype_class", "");
                $Tpl->setvar("lbgranttype", $license["granttype_name"]);
                $Tpl->setvar("lbgrantnumber", $license["grant_number"]);
            }
            if (strlen(trim($license["serial_number"])) <= 0) {
                $Tpl->setvar("lbserial_class", "hide");
            } else {
                $Tpl->setvar("lbserial_class", "");
                $Tpl->setvar("lbserialnumber", $license["serial_number"]);
            }
            $Tpl->setvar("lblicense_for", $license["sector_name"]);
            if (strlen($license["expedition_date"]) <= 0) {
                $expDate = "";
            } else {
                $expDate = date("m/d/Y", strtotime($license["expedition_date"]));
            }
            $Tpl->setvar("lbexpedition", $expDate);
            if (strlen($license["expiration_date"]) <= 0) {
                $expirDate = "";
            } else {
                $expirDate = date("m/d/Y", strtotime($license["expiration_date"]));
            }
            $Tpl->setvar("lbexpiration", $expirDate);
            $Tpl->parse("license_list", true);
        }
    }
    // Licensing active
    // -------------------------
    //End Custom Code
    //Close licensing_bulkrenewalcontent_BeforeShow @1-AC2FBD05
    return $licensing_bulkrenewalcontent_BeforeShow;
}