/** * @param int $startDate * @param int $endDate * @param Partner $partner * @param reportInterval $resolution * @param int $tzOffset * @return string */ public static function getPartnerUsageGraph($startDate, $endDate, Partner $partner, $resolution = reportInterval::DAYS, $tzOffset = null, $reportType = myReportsMgr::REPORT_TYPE_PARTNER_BANDWIDTH_USAGE) { $reportFilter = new reportsInputFilter(); $reportFilter->from_date = $startDate; $reportFilter->to_date = $endDate; $reportFilter->from_day = date("Ymd", $startDate); $reportFilter->to_day = date("Ymd", $endDate); $reportFilter->interval = $resolution; // if TZ offset provided, add TZ offset to the UTC time created above to reflect the user's timezone // in myReportsMgr the offset will be later cleaned again to reflect UTC time so that the DWH query will be correct (with the TIME_SHIFT) if (!is_null($tzOffset)) { $tzOffsetSec = $tzOffset * 60; $reportFilter->timeZoneOffset = $tzOffsetSec; $reportFilter->from_date = $reportFilter->from_date + $tzOffsetSec; $reportFilter->to_date = $reportFilter->to_date + $tzOffsetSec; } $data = myReportsMgr::getGraph($partner->getId(), $reportType, $reportFilter, null, null); $graphPointsLine = array(); if ($resolution == reportInterval::MONTHS) { $graphPointsLine = myPartnerUtils::annualActivityGraph($data); } else { $graphPointsLine = myPartnerUtils::dailyActivityGraph($data, $startDate); } ksort($graphPointsLine); $graphLine = ''; foreach ($graphPointsLine as $point => $usage) { $graphLine .= intval($point) . ",{$usage};"; } return $graphLine; }