Exemplo n.º 1
0
 /**
  * Generates a URL for an existing subscriber to enter an additional credit card. Uses the given User's accountId to attach the paymentmethod to their account upon submission.
  * @param $accountName Name of the target account
  * @return Existing PaymentMethod URL
  */
 public static function getExistingIframeSrc($accountName)
 {
     $zapi;
     try {
         $zapi = new zApi();
     } catch (Exception $e) {
         throw new Exception('INVALID_ZLOGIN');
     }
     //Get Account with this name
     $accId = NULL;
     $accResult = $zapi->zQuery("SELECT Id FROM Account WHERE Name='" . $accountName . "'");
     //Get Account Information
     foreach ($accResult->result->records as $acc) {
         $accId = $acc->Id;
     }
     if ($accId == NULL) {
         throw new Exception('USER_DOESNT_EXIST');
     }
     $conResult = $zapi->zQuery("SELECT AccountId,Country,Address1,Address2,City,State,PostalCode,WorkPhone FROM Contact WHERE AccountId='" . $accId . "'");
     if ($conResult->result->size == 0) {
         return null;
     }
     $con;
     foreach ($conResult->result->records as $ccon) {
         $con = $ccon;
     }
     $URL = PaymentManager::generateUrl();
     $URL = $URL . '&field_accountId=' . $con->AccountId;
     if (isset($con->Country)) {
         if (strtolower($con->Country) == 'united states') {
             $URL .= '&field_creditCardCountry=USA';
         } else {
             if (strtolower($con->Country) == 'canada') {
                 $URL .= '&field_creditCardCountry=CAN';
             }
         }
     }
     $URL .= isset($con->State) ? '&field_creditCardState=' . $con->State : '';
     $URL .= isset($con->City) ? '&field_creditCardCity=' . $con->City : '';
     $URL .= isset($con->PostalCode) ? '&field_creditCardPostalCode=' . $con->PostalCode : '';
     $URL .= $con->Address1 != null ? '&field_creditCardAddress1=' . $con->Address1 : '';
     $URL .= isset($con->Address2) ? '&field_creditCardAddress2=' . $con->Address2 : '';
     $URL .= isset($con->WorkPhone) ? '&field_phone=' . $con->WorkPhone : '';
     $URL .= isset($con->WorkEmail) ? '&field_email=' . $con->WorkEmail : '';
     return $URL;
 }
Exemplo n.º 2
0
 public static function validateUsername($username)
 {
     $zapi;
     try {
         $zapi = new zApi();
     } catch (Exception $e) {
         return null;
     }
     //Disallow apostrophes
     if (strpos($username, "'") !== false) {
         return false;
     }
     //Get Account ID with this email
     $accResult = $zapi->zQuery("SELECT Id FROM Account WHERE Name='" . $username . "'");
     foreach ($accResult->result->records as $acc) {
         $_SESSION['accountId'] = $acc->Id;
         return true;
     }
     return false;
 }
Exemplo n.º 3
0
 public static function buildHierarchy($partnerID, $parentName, $parentId, $acctName, $acctId, $parentHierarchy)
 {
     $zapi;
     try {
         $zapi = new zApi();
     } catch (Exception $e) {
         return false;
     }
     $chldHierarchy = new Summary_Hierarchy();
     //$parentName, $parentID);
     $chldHierarchy->partnerId = $partnerID;
     $chldHierarchy->ParentName = $parentName;
     $chldHierarchy->ParentId = $parentId;
     $chldHierarchy->accountId = $acctId;
     $chldHierarchy->acctName = $acctName;
     $chldHierarchy->sub_Hierarchies = array();
     $hierarchy = $chldHierarchy;
     $acctResult = $zapi->zQuery("Select Id, Name from Account where ParentId = '" . $acctId . "'");
     foreach ($acctResult->result->records as $acc) {
         AccountManager::buildHierarchy($partnerID, $acctName, $acctId, $acc->Name, $acc->Id, $hierarchy);
     }
     if ($parentHierarchy != 'null') {
         array_push($parentHierarchy->sub_Hierarchies, $hierarchy);
     }
     return $hierarchy;
 }
Exemplo n.º 4
0
 /**
  * Reads the Product Catalog Data from Zuora and saves it to a JSON cache stored on the server to reduce load times. This method must be called each time the Product Catalog is changed in Zuora to ensure the catalog is not out of date for the user.
  * @return A model containing all necessary information needed to display the products and rate plans in the product catalog
  */
 public static function refreshCache()
 {
     //Initialize Zuora API Instance
     include './config.php';
     $zapi = new zApi();
     // if guided selling filter fields exist, loop through and create string for the query
     $guidedSellingFieldsString = '';
     if (count($guidedSellingFields) > 0) {
         $guidedSellingFieldsString = ',' . implode(",", $guidedSellingFields);
     }
     //For each classification
     $fieldGroups;
     $numGroups;
     if ($showAllProducts) {
         $numGroups = 1;
         $fieldGroups = array('');
     } else {
         $numGroups = count($groupingFieldValues);
         $fieldGroups = $groupingFieldValues;
     }
     $catalog_groups = array();
     foreach ($fieldGroups as $fieldGroup) {
         $catalog_group = new Catalog_Group();
         if ($fieldGroup == 'Base Product') {
             $catalog_group->isBase = true;
         } elseif ($fieldGroup == 'Add-On Product') {
             $catalog_group->isAddon = true;
             // } elseif ($fieldGroup == 'Partner') {
             // 	$catalog_group->isPartner = true;
         } else {
             $catalog_group->isHidden = true;
         }
         $catalog_group->Name = $fieldGroup;
         $catalog_group->products = array();
         date_default_timezone_set('America/Los_Angeles');
         $curDate = date('Y-m-d\\TH:i:s', time());
         //Get All Products
         $productZoql = "select Id,Name,SKU,Description" . $guidedSellingFieldsString . " from Product where EffectiveStartDate<'" . $curDate . "' and EffectiveEndDate>'" . $curDate . "'";
         if (!$showAllProducts) {
             $productZoql .= " and " . $groupingField . "='" . $fieldGroup . "'";
         }
         $result = $zapi->zQuery($productZoql);
         $qProducts = array();
         if ($result->result != null) {
             $qProducts = $result->result->records;
         } else {
             addErrors(null, 'No Products found.');
             return;
         }
         //Set up Catalog_Product objects
         foreach ($qProducts as $p) {
             $catalog_product = new Catalog_Product();
             $catalog_product->Id = $p->Id;
             $catalog_product->Name = $p->Name;
             $catalog_product->Description = isset($p->Description) ? $p->Description : "";
             $catalog_product->SKU = $p->SKU;
             // loop through the guided selling fields from config file
             if (count($guidedSellingFields) > 0) {
                 $guidedFieldsArray = array();
                 foreach ($guidedSellingFields as $filterField) {
                     // set the product to have the value of the guided selling field
                     $catalog_product->{$filterField} = isset($p->{$filterField}) ? $p->{$filterField} : "";
                     $guidedSellingValues = array();
                     if ($catalog_product->{$filterField} != "") {
                         $guidedFieldsArray[$filterField] = $catalog_product->{$filterField};
                     }
                 }
                 $catalog_product->filterValues = array();
                 array_push($catalog_product->filterValues, $guidedFieldsArray);
             }
             //Get RatePlans for this Product
             $result = $zapi->zQuery("select Id,Name,Description," . $promoField . " from ProductRatePlan where ProductId='" . $catalog_product->Id . "' and EffectiveStartDate<'" . $curDate . "' and EffectiveEndDate>'" . $curDate . "' ");
             $qRatePlans = array();
             $catalog_product->ratePlans = array();
             if ($result->result != null) {
                 $qRatePlans = $result->result->records;
                 if ($qRatePlans != null) {
                     foreach ($qRatePlans as $rp) {
                         $catalog_rateplan = new Catalog_RatePlan();
                         $catalog_rateplan->Id = $rp->Id;
                         $catalog_rateplan->Name = $rp->Name;
                         $catalog_rateplan->productName = $p->Name;
                         $catalog_rateplan->Description = isset($rp->Description) ? $rp->Description : "";
                         $catalog_rateplan->{$promoField} = isset($rp->{$promoField}) ? $rp->{$promoField} : "";
                         //Get Charges for the Rate Plan
                         $result = $zapi->zQuery("select Id,Name,DefaultQuantity,Description,UOM,ChargeModel,ChargeType,BillingPeriod from ProductRatePlanCharge where ProductRatePlanId='" . $catalog_rateplan->Id . "'");
                         $qCharges = array();
                         $catalog_rateplan->charges = array();
                         if ($result->result != null) {
                             $qCharges = $result->result->records;
                             if ($qCharges != null) {
                                 // start of for loop for rate plan charges
                                 foreach ($qCharges as $rpc) {
                                     $catalog_charge = new Catalog_Charge();
                                     $catalog_charge->Id = $rpc->Id;
                                     $catalog_charge->Name = $rpc->Name;
                                     $catalog_charge->Description = isset($rpc->Description) ? $rpc->Description : "";
                                     $catalog_charge->ChargeModel = $rpc->ChargeModel;
                                     $catalog_charge->ChargeType = $rpc->ChargeType;
                                     $catalog_charge->BillingPeriod = $rpc->BillingPeriod;
                                     if ($catalog_charge->ChargeModel == 'Tiered with Overage Pricing' || $catalog_charge->ChargeModel == 'Tiered Pricing' || $catalog_charge->ChargeModel == 'Volume Pricing') {
                                         $catalog_charge->Uom = $rpc->UOM;
                                         $catalog_charge->isTiered = true;
                                     }
                                     if ($catalog_charge->ChargeType != 'Usage' && ($catalog_charge->ChargeModel == 'Per Unit Pricing' || $catalog_charge->ChargeModel == 'Tiered Pricing' || $catalog_charge->ChargeModel == 'Volume Pricing')) {
                                         $catalog_charge->Uom = $rpc->UOM;
                                         $catalog_charge->quantifiable = true;
                                         $catalog_charge->DefaultQuantity = isset($rpc->DefaultQuantity) ? $rpc->DefaultQuantity : "1";
                                     }
                                     // probably need special case for ChargeModel == Overage Pricing to show overage price
                                     //MD New Lines to get detail for the individual charges
                                     $result = $zapi->zQuery("select Id,Price,Currency,Tier,StartingUnit,EndingUnit,PriceFormat from ProductRatePlanChargeTier where ProductRatePlanChargeId='" . $catalog_charge->Id . "'");
                                     $qChargeTiers = array();
                                     $catalog_charge->chargeTiers = array();
                                     if ($result->result != null) {
                                         usort($result->result->records, "Catalog::cmpTiers");
                                         $qChargeTiers = $result->result->records;
                                         if ($qChargeTiers != null) {
                                             foreach ($qChargeTiers as $rpct) {
                                                 $catalog_chargeTier = new Catalog_ChargeTier();
                                                 $catalog_chargeTier->Id = $rpct->Id;
                                                 $catalog_chargeTier->Price = $rpct->Price;
                                                 $catalog_chargeTier->Currency = $rpct->Currency;
                                                 $catalog_chargeTier->myCurrency = $rpct->Currency == $defaultCurrency;
                                                 $catalog_chargeTier->Tier = $rpct->Tier;
                                                 $catalog_chargeTier->StartingUnit = $rpct->StartingUnit;
                                                 $catalog_chargeTier->EndingUnit = $rpct->EndingUnit;
                                                 $catalog_chargeTier->PriceFormat = $rpct->PriceFormat;
                                                 array_push($catalog_charge->chargeTiers, $catalog_chargeTier);
                                             }
                                         }
                                     }
                                     //MD end new lines to get charge detail
                                     array_push($catalog_rateplan->charges, $catalog_charge);
                                 }
                             }
                         }
                         array_push($catalog_product->ratePlans, $catalog_rateplan);
                     }
                     array_push($catalog_group->products, $catalog_product);
                 }
             }
         }
         array_push($catalog_groups, $catalog_group);
     }
     $catalogJson = json_encode($catalog_groups);
     $lastSync = date(NULL);
     //Cache product list
     $myFile = $cachePath;
     $fh = fopen($myFile, 'w') or die("can't open file");
     fwrite($fh, $catalogJson);
     fclose($fh);
     return $catalog_groups;
 }
Exemplo n.º 5
0
function getAccountID()
{
    $zapi;
    try {
        $zapi = new zApi();
    } catch (Exception $e) {
        return null;
    }
    if (isset($_SESSION['email'])) {
        $accName = $_SESSION['email'];
    } else {
        return '';
    }
    //Get Contact with this email
    $accResult = $zapi->zQuery("SELECT Id FROM Account WHERE Name='" . $accName . "'");
    foreach ($accResult->result->records as $acc) {
        return $acc->Id;
    }
}
Exemplo n.º 6
0
function test_ChangeDefaultPaymentMethod()
{
    global $EXISTING_CUSTOMER_ACCOUNT_NAME;
    printResultStart(__FUNCTION__);
    $messages = array();
    $pmId;
    $checkPmId;
    try {
        $zapi = new zApi();
        $pres = $zapi->zQuery("SELECT DefaultPaymentMethodId FROM Account WHERE Name='" . $EXISTING_CUSTOMER_ACCOUNT_NAME . "'");
        if (count($pres->result->records) == 0) {
            throw new Exception("ACCOUNT_DOESNT_EXIST");
        }
        $pmId = $pres->result->records[0]->DefaultPaymentMethodId;
        $cpmres = $zapi->zQuery("SELECT Id from PaymentMethod where Name='Check'");
        //Test
        echo "Updating Default Payment Method on Account " . $EXISTING_CUSTOMER_ACCOUNT_NAME . " to 'Check': <br>";
        $changeRes = PaymentManager::changePaymentMethod($EXISTING_CUSTOMER_ACCOUNT_NAME, $pmId);
        print_r_html($changeRes);
        echo "Updating Default Payment Method on Account " . $EXISTING_CUSTOMER_ACCOUNT_NAME . " back to original payment method: <br>";
        $changeRes = PaymentManager::changePaymentMethod($EXISTING_CUSTOMER_ACCOUNT_NAME, $pmId);
        print_r_html($changeRes);
    } catch (Exception $e) {
        array_push($messages, $e->getMessage());
    }
    printResultEnd($messages);
}
Exemplo n.º 7
0
 public static function getUpgradeDowngradePlans($updownSku)
 {
     //Initialize Zuora API Instance
     include './config.php';
     $zapi = new zApi();
     $_SESSION['myCurrency'] = $defaultCurrency;
     //For each classification
     date_default_timezone_set('America/Los_Angeles');
     $curDate = date('Y-m-d\\TH:i:s', time());
     //Get the Upgrade/Downgrade Product by SKU
     $productZoql = "select Id,Name,SKU,Description from Product where SKU='" . $updownSku . "' or Id='" . $updownSku . "' and EffectiveStartDate<'" . $curDate . "' and EffectiveEndDate>'" . $curDate . "'";
     $result = $zapi->zQuery($productZoql);
     if ($result->result != null) {
         $qProduct = $result->result->records[0];
     } else {
         addErrors(null, 'No Products found.');
         return;
     }
     //Set up the Catalog_Product object
     $catalog_product = new Catalog_Product();
     $catalog_product->Id = $qProduct->Id;
     $catalog_product->Name = $qProduct->Name;
     $catalog_product->Description = isset($qProduct->Description) ? $qProduct->Description : "";
     $catalog_product->SKU = $qProduct->SKU;
     //Get RatePlans for this Product
     $result = $zapi->zQuery("select Id,Name,Description from ProductRatePlan where ProductId='" . $catalog_product->Id . "' and EffectiveStartDate<'" . $curDate . "' and EffectiveEndDate>'" . $curDate . "' ");
     $qRatePlans = array();
     $catalog_product->ratePlans = array();
     $qRatePlans = $result->result->records;
     if ($qRatePlans != null) {
         foreach ($qRatePlans as $rp) {
             $catalog_rateplan = new Catalog_RatePlan();
             $catalog_rateplan->Id = $rp->Id;
             $catalog_rateplan->Name = $rp->Name;
             $catalog_rateplan->productName = $qProduct->Name;
             $catalog_rateplan->Description = isset($rp->Description) ? $rp->Description : "";
             //Get Charges for the Rate Plan
             $result = $zapi->zQuery("select Id,Name,DefaultQuantity,Description,UOM,ChargeModel,ChargeType,BillingPeriod from ProductRatePlanCharge where ProductRatePlanId='" . $catalog_rateplan->Id . "'");
             $qCharges = array();
             $catalog_rateplan->charges = array();
             $qCharges = $result->result->records;
             if ($qCharges != null) {
                 // start of for loop for rate plan charges
                 foreach ($qCharges as $rpc) {
                     $catalog_charge = new Catalog_Charge();
                     $catalog_charge->Id = $rpc->Id;
                     $catalog_charge->Name = $rpc->Name;
                     $catalog_charge->Description = isset($rpc->Description) ? $rpc->Description : "";
                     $catalog_charge->ChargeModel = $rpc->ChargeModel;
                     $catalog_charge->ChargeType = $rpc->ChargeType;
                     $catalog_charge->BillingPeriod = $rpc->BillingPeriod;
                     if ($catalog_charge->ChargeModel == 'Tiered with Overage Pricing' || $catalog_charge->ChargeModel == 'Tiered Pricing' || $catalog_charge->ChargeModel == 'Volume Pricing') {
                         $catalog_charge->Uom = $rpc->UOM;
                         $catalog_charge->isTiered = true;
                     }
                     if ($catalog_charge->ChargeType != 'Usage' && ($catalog_charge->ChargeModel == 'Per Unit Pricing' || $catalog_charge->ChargeModel == 'Tiered Pricing' || $catalog_charge->ChargeModel == 'Volume Pricing')) {
                         $catalog_charge->Uom = $rpc->UOM;
                         $catalog_charge->quantifiable = true;
                         $catalog_charge->DefaultQuantity = isset($rpc->DefaultQuantity) ? $rpc->DefaultQuantity : "1";
                     }
                     // probably need special case for ChargeModel == Overage Pricing to show overage price
                     //MD New Lines to get detail for the individual charges
                     $result = $zapi->zQuery("select Id,Price,Currency,Tier,StartingUnit,EndingUnit,PriceFormat from ProductRatePlanChargeTier where ProductRatePlanChargeId='" . $catalog_charge->Id . "'");
                     $qChargeTiers = array();
                     $catalog_charge->chargeTiers = array();
                     if ($result->result != null) {
                         usort($result->result->records, "Amender::cmpTiers");
                         $qChargeTiers = $result->result->records;
                         if ($qChargeTiers != null) {
                             foreach ($qChargeTiers as $rpct) {
                                 $catalog_chargeTier = new Catalog_ChargeTier();
                                 $catalog_chargeTier->Id = $rpct->Id;
                                 $catalog_chargeTier->Price = $rpct->Price;
                                 $catalog_chargeTier->Currency = $rpct->Currency;
                                 $catalog_chargeTier->myCurrency = $rpct->Currency == $_SESSION['myCurrency'];
                                 $catalog_chargeTier->Tier = $rpct->Tier;
                                 $catalog_chargeTier->StartingUnit = $rpct->StartingUnit;
                                 $catalog_chargeTier->EndingUnit = $rpct->EndingUnit;
                                 $catalog_chargeTier->PriceFormat = $rpct->PriceFormat;
                                 array_push($catalog_charge->chargeTiers, $catalog_chargeTier);
                             }
                         }
                     }
                     //MD end new lines to get charge detail
                     array_push($catalog_rateplan->charges, $catalog_charge);
                 }
             }
             array_push($catalog_product->ratePlans, $catalog_rateplan);
         }
     }
     return $catalog_product;
 }
Exemplo n.º 8
0
    @(include './controller/' . $class . '.php');
}
//send the user back to the select_products page when completed
header("location: ../account_view.html");
session_start();
global $messages;
$zapi;
try {
    $zapi = new zApi();
} catch (Exception $e) {
    throw new Exception("INVALID_ZLOGIN");
}
$accId = $_SESSION['accountId'];
//Get Default Payment Method Id for this accountl
$defaultPmId;
$accResult = $zapi->zQuery("SELECT DefaultPaymentMethodId FROM Account WHERE Id='" . $accId . "'");
if ($accResult->result->size == 0) {
    // throw new Exception('SUBSCRIPTION_DOES_NOT_EXIST');
    return 'PAYMENT_METHOD_DOES_NOT_EXIST';
}
foreach ($accResult->result->records as $acc) {
    $defaultPmId = $acc->DefaultPaymentMethodId;
}
date_default_timezone_set('America/Los_Angeles');
$date = date('Y-m-d\\TH:i:s');
$payAmt = (double) $_POST["pay_amt"];
$invId = $_POST["inv_id"];
$invBal = (double) $_POST["inv_bal"];
echo "<br>inv_num: " . $invId;
echo "<br>pay_amt: " . $payAmt;
echo "<br>inv_bal: " . $invBal;
Exemplo n.º 9
0
<?php

function __autoload($class)
{
    @(include 'controller/' . $class . '.php');
}
session_start();
//Start of getting this invoice's body to view as PDF
$zapi;
try {
    $zapi = new zApi();
} catch (Exception $e) {
    return null;
}
$invPdfId = $_POST["pdf_inv_id"];
//Use this invoice and return the body
$invResult = $zapi->zQuery("SELECT Body FROM Invoice WHERE InvoiceNumber='" . $invPdfId . "'");
$body = $invResult->result->records[0]->Body;
header("Content-type: application/pdf");
echo base64_decode($body);
Exemplo n.º 10
0
 public static function getAmendSubscription($currentSubId)
 {
     $zapi = new zApi();
     $subResult = $zapi->zQuery("SELECT Id,Name,Status,Version,PreviousSubscriptionId,ContractEffectiveDate,TermStartDate,TermEndDate,TermType,RenewalTerm FROM Subscription WHERE Id='" . $currentSubId . "'");
     if ($subResult->result->size == 0) {
         // throw new Exception('SUBSCRIPTION_DOES_NOT_EXIST');
         return 'SUBSCRIPTION_DOES_NOT_EXIST';
     }
     date_default_timezone_set('America/Los_Angeles');
     $curDate = date("Y-m-d") . 'T00:00:00.000-08:00';
     //Array for Active Subscriptions
     $activeSubArray = array();
     foreach ($subResult->result->records as $sub) {
         $activeSub = new Amender_Subscription();
         $activeSub->subId = $sub->Id;
         $activeSub->Name = $sub->Name;
         $activeSub->startDate = $sub->TermStartDate;
         $activeSub->endDate = $sub->TermEndDate;
         $activeSub->active_plans = array();
         $activeSub->removed_plans = array();
         $rpResult = $zapi->zQuery("SELECT Id,Name,ProductRatePlanId FROM RatePlan WHERE SubscriptionId='" . $activeSub->subId . "'");
         // Get all rate plans
         foreach ($rpResult->result->records as $rp) {
             $newPlan = new Amender_Plan();
             $newPlan->Id = $rp->Id;
             $newPlan->Name = $rp->Name;
             //Get Product Name
             $prpResult = $zapi->zQuery("SELECT Description,ProductId FROM ProductRatePlan WHERE Id='" . $rp->ProductRatePlanId . "'");
             $newPlan->Description = isset($prpResult->result->records[0]->Description) ? $prpResult->result->records[0]->Description : '';
             $newPlan->ProdId = $prpResult->result->records[0]->ProductId;
             $pResult = $zapi->zQuery("SELECT Name, UpgradePathSKU__c, DowngradePathSKU__c FROM Product WHERE Id='" . $prpResult->result->records[0]->ProductId . "'");
             $newPlan->ProductName = $pResult->result->records[0]->Name;
             array_push($activeSub->active_plans, $newPlan);
         }
         //Get Removed Rate Plans
         $rpResult = $zapi->zQuery("SELECT Id,Name,AmendmentType,AmendmentId,ProductRatePlanId FROM RatePlan WHERE SubscriptionId='" . $activeSub->subId . "' AND AmendmentType='RemoveProduct'");
         foreach ($rpResult->result->records as $rp) {
             $newPlan = new Amender_Plan();
             $newPlan->Id = $rp->Id;
             $newPlan->Name = $rp->Name;
             //Get Product Name
             $prpResult = $zapi->zQuery("SELECT Description,ProductId FROM ProductRatePlan WHERE Id='" . $rp->ProductRatePlanId . "'");
             $newPlan->Description = isset($prpResult->result->records[0]->Description) ? $prpResult->result->records[0]->Description : '';
             $pResult = $zapi->zQuery("SELECT Name FROM Product WHERE Id='" . $prpResult->result->records[0]->ProductId . "'");
             $newPlan->ProductName = $pResult->result->records[0]->Name;
             $newPlan->AmendmentId = $rp->AmendmentId;
             $newPlan->AmendmentType = $rp->AmendmentType;
             $newPlan->effectiveDate = 'end of current billing period.';
             //Query Amendment for this rate plan to get Effective Removal Date
             $amdResult = $zapi->zQuery("SELECT Id,ContractEffectiveDate FROM Amendment WHERE Id='" . $newPlan->AmendmentId . "'");
             foreach ($amdResult->result->records as $amd) {
                 $newPlan->effectiveDate = $amd->ContractEffectiveDate;
             }
             array_push($activeSub->removed_plans, $newPlan);
         }
         array_push($activeSubArray, $activeSub);
     }
     // usort($activeSubArray, "SubscriptionManager::cmpSubscriptions");
     return $activeSubArray;
 }