public function exportCsvAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $request = $this->getRequest(); $from = $this->_getParam('from_date', $this->getDefaultFromDate()); $to = $this->_getParam('to_date', $this->getDefaultToDate()); $client = Infra_ClientHelper::getClient(); if ($client->getKs() == null) { $client->setKs(self::generateKs()); } $form = new Form_PartnerUsageFilter(); $form->populate($request->getParams()); // init filters $partnerFilter = $this->getPartnerFilterFromForm($form); $usageFilter = new Kaltura_Client_Type_ReportInputFilter(); $usageFilter->fromDate = DateTime::createFromFormat('m/d/Y', $from)->getTimestamp(); $usageFilter->toDate = DateTime::createFromFormat('m/d/Y', $to)->getTimestamp(); $usageFilter->timeZoneOffset = Infra_AuthHelper::getAuthInstance()->getIdentity()->getTimezoneOffset(); if ($form->getElement('interval')->getValue()) { $usageFilter->interval = $form->getElement('interval')->getValue() == 'daily' ? Kaltura_Client_Enum_ReportInterval::DAYS : Kaltura_Client_Enum_ReportInterval::MONTHS; } $pager = new Kaltura_Client_Type_FilterPager(); $pager->pageIndex = 1; $pager->pageSize = 500; $varConsolePlugin = Kaltura_Client_VarConsole_Plugin::get($client); $items = array(); while (true) { $response = $varConsolePlugin->varConsole->getPartnerUsage($partnerFilter, $usageFilter, $pager); if (count($response->objects) <= 0) { break; } foreach ($response->objects as &$object) { $items[] = $object; } $pager->pageIndex++; } $format = $this->view->translate('csv date'); $fileName = 'Usage report ' . $from . ' to ' . $to . '.csv'; header('Content-type: text/csv'); header('Content-Disposition: attachment; filename="' . $fileName . '"'); // echo the csv header echo $this->view->translate('partner-usage table timeUnit'), ',', $this->view->translate('partner-usage table partnerStatus'), ',', $this->view->translate('partner-usage table partnerName'), ',', $this->view->translate('partner-usage table partnerId'), ',', $this->view->translate('partner-usage table partnerCreatedAt'), ',', $this->view->translate('partner-usage table bandwidth'), ',', $this->view->translate('partner-usage table averageStorage'), ',', $this->view->translate('partner-usage table peakStorage'), ',', $this->view->translate('partner-usage table storage'), ',', $this->view->translate('partner-usage table deletedStorage'), ',', $this->view->translate('partner-usage table combinedBandwidthStorage'), "\r\n"; // echo the csv data foreach ($items as $item) { $d = new Zend_Date($item->partnerCreatedAt); $dateId = strlen($item->dateId) == 6 ? DateTime::createFromFormat("Ym", $item->dateId) : DateTime::createFromFormat("Ymd", $item->dateId); echo strlen($item->dateId) == 6 ? $dateId->format("M Y") : $dateId->format("d M Y"), ',', $this->view->enumTranslate('Kaltura_Client_Enum_PartnerStatus', $item->partnerStatus), ',', $item->partnerName, ',', $item->partnerId, ',', '"', $d->toString(Zend_Date::DATE_LONG), '",', (int) $item->bandwidth, ',', (int) $item->avgStorage, ',', (int) $item->peakStorage, ',', (int) $item->storage, ',', (int) $item->deletedStorage, ',', (int) $item->combinedStorageBandwidth, ',', "\r\n"; } }
public function updateStatusAction() { $this->_helper->viewRenderer->setNoRender(); $partnerId = $this->_getParam('partner_id'); $status = $this->_getParam('status'); $client = Infra_ClientHelper::getClient(); $varConsolePlugin = Kaltura_Client_VarConsole_Plugin::get($client); $varConsolePlugin->varConsole->updateStatus($partnerId, $status); echo $this->_helper->json('ok', false); }