public static function getBillingPreview($accId) { $zapi; $accountDetail = new Summary_Account(); try { $zapi = new zApi(); } catch (Exception $e) { $accountDetail->success = false; $accountDetail->error = 'INVALID_ZLOGIN'; return $accountDetail; } if ($accId == NULL) { $accountDetail->success = false; $accountDetail->error = 'USER_DOESNT_EXIST'; return $accountDetail; } date_default_timezone_set('America/Los_Angeles'); $todayDate = date('Y-m-d\\TH:i:s', time()); $targetDate = strtotime("+6 months", strtotime($todayDate)); $excludedCharges = 'OneTime,Recurring'; //Get billingPreview for this account $billingPreviewRequest = array("AccountId" => $accId, "ChargeTypeToExclude" => $excludedCharges, "TargetDate" => $targetDate, "IncludingEvergreenSubscription" => true); $billingPreviewResult = $zapi->zBillingPreview($billingPreviewRequest); $billingPreviewArray = array(); $TotalBillingPreview = 0; if ($billingPreviewResult->results->InvoiceItem) { foreach ($billingPreviewResult->results->InvoiceItem as $billingPreviewRecord) { if ($billingPreviewRecord->ChargeType == 'Usage' && $billingPreviewRecord->ChargeAmount != "0" && $billingPreviewRecord->Quantity != "0") { $billingPreviewDetail = new Summary_Forecast(); $billingPreviewDetail->Id = $billingPreviewRecord->Id; $billingPreviewDetail->ChargeAmount = $billingPreviewRecord->ChargeAmount; $billingPreviewDetail->ChargeDate = $billingPreviewRecord->ChargeDate; $billingPreviewDetail->ChargeType = $billingPreviewRecord->ChargeType; $billingPreviewDetail->Quantity = $billingPreviewRecord->Quantity; $billingPreviewDetail->RatePlanChargeId = $billingPreviewRecord->RatePlanChargeId; $billingPreviewDetail->ServiceEndDate = $billingPreviewRecord->ServiceEndDate; $billingPreviewDetail->ServiceStartDate = $billingPreviewRecord->ServiceStartDate; $billingPreviewDetail->SubscriptionId = $billingPreviewRecord->SubscriptionId; $billingPreviewDetail->UOM = $billingPreviewRecord->UOM; $TotalBillingPreview += $billingPreviewRecord->ChargeAmount; array_push($billingPreviewArray, $billingPreviewDetail); } } } if (count($billingPreviewArray) > 0) { $accountDetail->billingPreviewRecords = $billingPreviewArray; } $accountDetail->success = true; return $accountDetail; }