public static function createReport($report_title, $report_text, $headers, $report_type, reportsInputFilter $input_filter, $dimension, $graphs, $total_header, $total_data, $table_header, $table_data, $table_total_count, $csv)
 {
     list($total_dictionary, $table_dictionary) = self::buildDictionaries($headers);
     // store on disk
     $csv = new myCsvWrapper();
     $csv->addNewLine($report_title);
     $origTimeZone = date_default_timezone_get();
     date_default_timezone_set('UTC');
     $csv->addNewLine($csv->formatDate($input_filter->from_date), $csv->formatDate($input_filter->to_date));
     date_default_timezone_set($origTimeZone);
     $csv->addNewLine($report_text);
     $csv->addNewLine("# ------------------------------------");
     $csv->addNewLine("");
     $csv->addNewLine("# ------------------------------------");
     $csv->addNewLine("# Graph");
     $csv->addNewLine("# ------------------------------------");
     $csv->addNewLine("");
     if ($dimension) {
         $graph = @$graphs[$dimension];
     } else {
         $graph = $graphs;
     }
     foreach ($graph as $data => $value) {
         if ($report_type == myReportsMgr::REPORT_TYPE_CONTENT_DROPOFF || $report_type == myReportsMgr::REPORT_TYPE_USER_CONTENT_DROPOFF || $report_type == myReportsMgr::REPORT_TYPE_OPERATION_SYSTEM || $report_type == myReportsMgr::REPORT_TYPE_BROWSERS) {
             $csv->addNewLine($data, $value);
         } else {
             if ($dimension) {
                 $added = false;
                 if (strlen($data) == 6) {
                     $date = DateTime::createFromFormat("Ym", $data);
                     if ($date) {
                         $csv->addNewLine($date->format("M Y"), $value);
                         $added = true;
                     }
                 }
                 if (!$added) {
                     $csv->addNewLine($csv->formatDate(myReportsMgr::formatDateFromDateId($data)), $value);
                 }
             }
         }
     }
     $csv->addNewLine("");
     $csv->addNewLine("# ------------------------------------");
     $csv->addNewLine("# Total");
     $csv->addNewLine("# ------------------------------------");
     $csv->addNewLine($total_dictionary);
     $csv->addNewLine($total_data);
     $csv->addNewLine("");
     $csv->addNewLine("# ------------------------------------");
     $csv->addNewLine("# Table", "", "Total Count", $table_total_count);
     $csv->addNewLine("# ------------------------------------");
     $csv->addNewLine($table_dictionary);
     foreach ($table_data as $row) {
         $csv->addNewLine($row);
     }
     return $csv;
 }
 public function execute()
 {
     $this->forceSystemAuthentication();
     $this->partners_stat = array();
     $start = microtime(true);
     $this->from_date = $this->getP("from_date");
     $this->to_date = $this->getP("to_date", date("Y-m-d", time()));
     $this->days = $this->getP("days", 7);
     $this->data = array();
     $totals = array();
     $header = "";
     if ($this->days) {
         $timeStamp = strtotime($this->to_date);
         $timeStamp -= 24 * 60 * 60 * ($this->days - 1);
         // because it's inclusive-inclusive - reduce one day
         $this->from_date = date("Y-m-d", $timeStamp);
     }
     if ($this->getP("go")) {
         $input_filter = new reportsInputFilter();
         $input_filter->from_date = strtotime($this->from_date);
         $input_filter->to_date = strtotime($this->to_date);
         list($header, $data, $totalCount) = myReportsMgr::getTable(null, "system/system_generic_partner_billing", $input_filter, "", 300, null, null);
         $this->data = $data;
         // create total summary line
         /*
         $i=0;
         foreach ($this->data[0] as $columns )
         {
         	$totals[$i] = $i<1 ? "TOTAL" : 0 ;
         	$i++;			
         }
         foreach ( $this->data as $line )
         {
         	$i=0;			
         	foreach ( $line as $val )
         	{
         		if ( is_numeric ($val ) )
         			@$totals[$i]+=$val;
         		$i++;	
         	}
         }
         */
     }
     $this->data[] = $totals;
     $this->header = $header;
     $end = microtime(true);
     $this->go = $this->getP("go");
     $this->bench = $end - $start;
     $this->format = $this->getP("format", "row");
 }
 public function execute()
 {
     ini_set("memory_limit", "256M");
     ini_set("max_execution_time", "240");
     $this->forceSystemAuthentication();
     $start = microtime(true);
     $this->from_date = $this->getP("from_date");
     $this->to_date = $this->getP("to_date", date("Y-m-d", time()));
     $this->days = $this->getP("days", 7);
     $page = $this->getP("page", 1);
     if ($page < 1) {
         $page = 1;
     }
     $this->page = $page;
     if ($this->days) {
         $timeStamp = strtotime($this->to_date);
         $timeStamp -= 24 * 60 * 60 * ($this->days - 1);
         // because it's inclusive-inclusive - reduce one day
         $this->from_date = date("Y-m-d", $timeStamp);
     }
     $this->new_first = $this->getP("new_first", null);
     if ($this->new_first == "false") {
         $this->new_first = false;
     }
     $this->package_list = array("all" => "1=1", "paying" => "dim_partner.partner_package>1", "kaltura_signup" => "dim_partner.partner_type_id=1 AND dim_partner.partner_package=1", "other" => "dim_partner.partner_type_id=1 AND dim_partner.partner_package=2", "wiki" => "dim_partner.partner_type_id=1 AND dim_partner.partner_package=100", "wordpress" => "dim_partner.partner_type_id=1 AND dim_partner.partner_package=101", "drupal" => "dim_partner.partner_type_id=1 AND dim_partner.partner_package=102", "mind_touch" => "dim_partner.partner_type_id=1 AND dim_partner.partner_package=103", "moodle" => "dim_partner.partner_type_id=1 AND dim_partner.partner_package=104", "kaltura_ce" => "dim_partner.partner_type_id=1 AND dim_partner.partner_package=105");
     $updated_at = null;
     $this->selected_package = $this->getP("pkg", "paying");
     $input_filter = new reportsInputFilter();
     if ($this->selected_package) {
         $criteria = @$this->package_list[$this->selected_package];
         $input_filter->extra_map = array("{PARTNER_PACKAGE_CRITERIA}" => $criteria);
     }
     $input_filter->from_date = strtotime($this->from_date);
     $input_filter->to_date = strtotime($this->to_date);
     $data = $header = null;
     $this->go = $this->getP("go");
     if ($this->go) {
         list($header, $data, $totalCount) = myReportsMgr::getTable(null, myReportsMgr::REPORT_TYPE_SYSTEM_GENERIC_PARTNER, $input_filter, self::MAX_PAGE_SIZE, $this->page, null, null);
     }
     if ($data) {
         $this->partners_stat = $data;
         $this->data = $data;
     }
     $this->header = $header;
     $this->updated_at = $updated_at;
     $end = microtime(true);
     $this->bench = $end - $start;
 }
 public function execute()
 {
     $this->forceSystemAuthentication();
     $this->partners_stat = array();
     $start = microtime(true);
     $file_path = dirname(__FILE__) . "/../data/viewPartnersData.txt";
     $partner_groups = new partnerGroups($file_path);
     $this->partner_group_list = $partner_groups->partner_group_list;
     $group_rest = new partnerGroup();
     $group_rest->setName("_rest");
     $this->partner_group_list[] = $group_rest;
     $this->from_date = $this->getP("from_date");
     $this->to_date = $this->getP("to_date", date("Y-m-d", time()));
     $this->days = $this->getP("days", 7);
     if ($this->days) {
         $timeStamp = strtotime($this->to_date);
         $timeStamp -= 24 * 60 * 60 * ($this->days - 1);
         // because it's inclusive-inclusive - reduce one day
         $this->from_date = date("Y-m-d", $timeStamp);
     }
     $input_filter = new reportsInputFilter();
     $input_filter->from_date = strtotime($this->from_date);
     $input_filter->to_date = strtotime($this->to_date);
     list($header, $data, $totalCount) = myReportsMgr::getTable(null, myReportsMgr::REPORT_TYPE_SYSTEM_GENERIC_PARTNER_TYPE, $input_filter, "", 300, null, null);
     $this->data = $data;
     // create total summary line
     $totals = array();
     $i = 0;
     foreach ($this->data[0] as $columns) {
         $totals[$i] = $i < 3 ? "TOTAL" : 0;
         $i++;
     }
     foreach ($this->data as $line) {
         $i = 0;
         foreach ($line as $val) {
             if (is_numeric($val)) {
                 @($totals[$i] += $val);
             }
             $i++;
         }
     }
     $this->data[] = $totals;
     $this->header = $header;
     $end = microtime(true);
     $this->go = $this->getP("go");
     $this->bench = $end - $start;
     $this->format = $this->getP("format", "row");
 }
 public static function createReport($report_title, $report_text, $headers, $report_type, reportsInputFilter $input_filter, $dimension, $graphs, $total_header, $total_data, $table_header, $table_data, $table_total_count)
 {
     list($total_dictionary, $table_dictionary) = self::buildDictionaries($headers);
     // store on disk
     $csv = new myCsvWrapper();
     $csv->addNewLine($report_title);
     $csv->addNewLine($csv->formatDate($input_filter->from_date), $csv->formatDate($input_filter->to_date));
     $csv->addNewLine($report_text);
     $csv->addNewLine("# ------------------------------------");
     $csv->addNewLine("");
     $csv->addNewLine("# ------------------------------------");
     $csv->addNewLine("# Graph");
     $csv->addNewLine("# ------------------------------------");
     $csv->addNewLine("");
     if ($dimension) {
         $graph = @$graphs[$dimension];
     } else {
         $graph = $graphs;
     }
     foreach ($graph as $data => $value) {
         if ($report_type == myReportsMgr::REPORT_TYPE_CONTENT_DROPOFF) {
             $csv->addNewLine($data, $value);
         } else {
             $csv->addNewLine($csv->formatDate(myReportsMgr::formatDateFromDateId($data)), $value);
         }
     }
     $csv->addNewLine("");
     $csv->addNewLine("# ------------------------------------");
     $csv->addNewLine("# Total");
     $csv->addNewLine("# ------------------------------------");
     $csv->addNewLine($total_dictionary);
     $csv->addNewLine($total_data);
     $csv->addNewLine("");
     $csv->addNewLine("# ------------------------------------");
     $csv->addNewLine("# Table", "", "Total Count", $table_total_count);
     $csv->addNewLine("# ------------------------------------");
     $csv->addNewLine($table_dictionary);
     foreach ($table_data as $row) {
         $csv->addNewLine($row);
     }
     $data = $csv->getData();
     return $data;
 }
 /**
  * @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;
 }
 /**
  * 
  * will create a Csv file for the given report and return the URL to access it
  * @action getUrlForReportAsCsv
  * 
  * @param string $reportTitle The title of the report to display at top of CSV 
  * @param string $reportText The text of the filter of the report
  * @param string $headers The headers of the columns - a map between the enumerations on the server side and the their display text  
  * @param KalturaReportType $reportType  
  * @param KalturaReportInputFilter $reportInputFilter
  * @param string $dimension	  
  * @param KalturaFilterPager $pager
  * @param KalturaReportType $reportType 
  * @param string $order
  * @param string $objectIds - one ID or more (separated by ',') of specific objects to query
  * @return string 
  */
 public function getUrlForReportAsCsvAction($reportTitle, $reportText, $headers, $reportType, KalturaReportInputFilter $reportInputFilter, $dimension = null, KalturaFilterPager $pager = null, $order = null, $objectIds = null)
 {
     if ($reportType == KalturaReportType::PARTNER_USAGE || $reportType == KalturaReportType::VAR_USAGE) {
         $objectIds = $this->validateObjectsAreAllowedPartners($objectIds);
     }
     $report = myReportsMgr::getUrlForReportAsCsv($this->getPartnerId(), $reportTitle, $reportText, $headers, $reportType, $reportInputFilter->toReportsInputFilter(), $dimension, $objectIds, $pager->pageSize, $pager->pageIndex, $order);
     return $report;
 }
 private static function getTotalTableCount($partner_id, $report_type, reportsInputFilter $input_filter, $page_size, $page_index, $order_by, $object_ids = null)
 {
     $cache_key = self::createCacheKey($partner_id, $report_type, $input_filter, $object_ids);
     if (!self::$count_cache) {
         self::$count_cache = new myCache("reportscount", self::REPORTS_COUNT_CACHE);
         // store the cache for
     }
     $total_count = self::$count_cache->get($cache_key);
     if ($total_count) {
         KalturaLog::log("count from cache: [{$total_count}]");
         return $total_count;
     }
     $total_count_arr = self::executeQueryByType($partner_id, $report_type, self::REPORT_FLAVOR_COUNT, $input_filter, null, null, null, $object_ids);
     if ($total_count_arr && isset($total_count_arr[0]["count_all"])) {
         $total_count = $total_count_arr[0]["count_all"];
     } else {
         $total_count = 0;
     }
     KalturaLog::log("count: [{$total_count}]");
     self::$count_cache->put($cache_key, $total_count);
     // store in the cache for next time
     return $total_count;
 }
 /**
  * @action getUsage
  * @param KalturaSystemPartnerUsageFilter $filter
  * @param KalturaFilterPager $pager
  * @return KalturaSystemPartnerUsageListResponse
  */
 public function getUsageAction(KalturaPartnerFilter $partnerFilter = null, KalturaSystemPartnerUsageFilter $usageFilter = null, KalturaFilterPager $pager = null)
 {
     if (is_null($partnerFilter)) {
         $partnerFilter = new KalturaPartnerFilter();
     }
     if (is_null($usageFilter)) {
         $usageFilter = new KalturaSystemPartnerUsageFilter();
         $usageFilter->fromDate = time() - 60 * 60 * 24 * 30;
         // last 30 days
         $usageFilter->toDate = time();
     }
     if (is_null($pager)) {
         $pager = new KalturaFilterPager();
     }
     $partnerFilterDb = new partnerFilter();
     $partnerFilter->toObject($partnerFilterDb);
     $partnerFilterDb->set('_gt_id', 0);
     // total count
     $c = new Criteria();
     $partnerFilterDb->attachToCriteria($c);
     $totalCount = PartnerPeer::doCount($c);
     // filter partners criteria
     $pager->attachToCriteria($c);
     $c->addAscendingOrderByColumn(PartnerPeer::ID);
     // select partners
     $partners = PartnerPeer::doSelect($c);
     $partnerIds = array();
     foreach ($partners as &$partner) {
         $partnerIds[] = $partner->getId();
     }
     $items = array();
     if (!count($partnerIds)) {
         // no partners fit the filter - don't fetch data
         $totalCount = 0;
         // the items are set to an empty KalturaSystemPartnerUsageArray
     } else {
         $inputFilter = new reportsInputFilter();
         $inputFilter->from_date = $usageFilter->fromDate;
         $inputFilter->to_date = $usageFilter->toDate;
         list($reportHeader, $reportData, $totalCountNoNeeded) = myReportsMgr::getTable(null, myReportsMgr::REPORT_TYPE_ADMIN_CONSOLE, $inputFilter, $pager->pageSize, 0, null, implode(",", $partnerIds));
         $unsortedItems = array();
         foreach ($reportData as $line) {
             $item = KalturaSystemPartnerUsageItem::fromString($reportHeader, $line);
             if ($item) {
                 $unsortedItems[$item->partnerId] = $item;
             }
         }
         // create the items in the order of the partnerIds and create some dummy for ones that don't exist
         foreach ($partnerIds as $partnerId) {
             if (isset($unsortedItems[$partnerId])) {
                 $items[] = $unsortedItems[$partnerId];
             } else {
                 // if no item for partner - get its details from the db
                 $items[] = KalturaSystemPartnerUsageItem::fromPartner(PartnerPeer::retrieveByPK($partnerId));
             }
         }
     }
     $response = new KalturaSystemPartnerUsageListResponse();
     $response->totalCount = $totalCount;
     $response->objects = $items;
     return $response;
 }
 public static function getPartnerBandwidthUsageFromDWH($partnerId, $startDate, $endDate, $resolution, $tzOffset = null)
 {
     $reportFilter = new reportsInputFilter();
     // use gmmktime to avoid server timezone offset - this is for backward compatibility while the KMC is not sending TZ info
     list($year, $month, $day) = explode('-', $startDate);
     $reportFilter->from_date = gmmktime(0, 0, 0, $month, $day, $year);
     list($year, $month, $day) = explode('-', $endDate);
     $reportFilter->to_date = gmmktime(0, 0, 0, $month, $day, $year);
     // 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;
     }
     $reportFilter->extra_map = array('{GROUP_COLUMN}' => $resolution == 'months' ? "month_id" : "date_id");
     $res = myReportsMgr::getGraph($partnerId, myReportsMgr::REPORT_TYPE_PARTNER_BANDWIDTH_USAGE, $reportFilter, null, null);
     return $res;
 }
Exemple #11
0
 /**
  * Function which calulates partner usage of a group of a VAR's sub-publishers
  * 
  * @action getPartnerUsage
  * @param KalturaPartnerFilter $partnerFilter
  * @param KalturaReportInputFilter $usageFilter
  * @param KalturaFilterPager $pager
  * @return KalturaPartnerUsageListResponse
  * @throws KalturaVarConsoleErrors::MAX_SUB_PUBLISHERS_EXCEEDED
  */
 public function getPartnerUsageAction(KalturaPartnerFilter $partnerFilter = null, KalturaReportInputFilter $usageFilter = null, KalturaFilterPager $pager = null)
 {
     if (is_null($partnerFilter)) {
         $partnerFilter = new KalturaPartnerFilter();
     }
     if (is_null($usageFilter)) {
         $usageFilter = new KalturaReportInputFilter();
         $usageFilter->fromDate = time() - 60 * 60 * 24 * 30;
         // last 30 days
         $usageFilter->toDate = time();
     } else {
         //The first time the filter is sent, it it sent with 0 as fromDate
         if (!$usageFilter->fromDate) {
             $usageFilter->fromDate = time() - 60 * 60 * 24 * 30;
         }
         if (!$usageFilter->interval) {
             $usageFilter->interval = KalturaReportInterval::MONTHS;
         }
     }
     if (is_null($pager)) {
         $pager = new KalturaFilterPager();
     }
     //Create a propel filter for the partner
     $partnerFilterDb = new partnerFilter();
     $partnerFilter->toObject($partnerFilterDb);
     //add filter to criteria
     $c = PartnerPeer::getDefaultCriteria();
     $partnerFilterDb->attachToCriteria($c);
     $partnersCount = PartnerPeer::doCount($c);
     if ($partnersCount > self::MAX_SUB_PUBLISHERS) {
         throw new KalturaAPIException(KalturaVarConsoleErrors::MAX_SUB_PUBLISHERS_EXCEEDED);
     }
     $partners = PartnerPeer::doSelect($c);
     $partnerIds = array();
     foreach ($partners as &$partner) {
         $partnerIds[] = $partner->getId();
     }
     // add pager to criteria
     $pager->attachToCriteria($c);
     $c->addAscendingOrderByColumn(PartnerPeer::ID);
     // select partners
     $items = array();
     $inputFilter = new reportsInputFilter();
     $inputFilter->from_date = $usageFilter->fromDate;
     $inputFilter->to_date = $usageFilter->toDate;
     $inputFilter->from_day = date("Ymd", $usageFilter->fromDate);
     $inputFilter->to_day = date("Ymd", $usageFilter->toDate);
     $inputFilter->timeZoneOffset = $usageFilter->timeZoneOffset;
     $inputFilter->interval = $usageFilter->interval;
     if (!count($partnerIds)) {
         $total = new KalturaVarPartnerUsageTotalItem();
         // no partners fit the filter - don't fetch data
         $totalCount = 0;
         // the items are set to an empty KalturaSystemPartnerUsageArray
     } else {
         $totalCount = 0;
         $orderBy = ($inputFilter->interval == reportInterval::MONTHS ? "+month_id" : "+date_id") . ",+partner_id";
         list($reportHeader, $reportData, $totalCount) = myReportsMgr::getTable(null, myReportsMgr::REPORT_TYPE_VAR_USAGE, $inputFilter, $pager->pageSize, $pager->pageIndex, $orderBy, implode(",", $partnerIds));
         foreach ($reportData as $line) {
             $item = new KalturaVarPartnerUsageItem();
             $item->fromString($reportHeader, $line);
             if ($item) {
                 $items[] = $item;
             }
         }
         list($reportHeader, $reportData) = myReportsMgr::getTotal(null, myReportsMgr::REPORT_TYPE_PARTNER_USAGE, $inputFilter, implode(",", $partnerIds));
         $total = new KalturaVarPartnerUsageTotalItem();
         $total->fromString($reportHeader, $reportData);
         list($peakStoragereportHeader, $peakStoragereportData) = myReportsMgr::getTotal(null, myReportsMgr::REPORT_TYPE_PEAK_STORAGE, $inputFilter, implode(",", $partnerIds));
         if ($peakStoragereportData[0]) {
             $total->peakStorage = ceil(@$peakStoragereportData[0]);
         }
     }
     $response = new KalturaPartnerUsageListResponse();
     //Sort according to dateId and partnerId
     uasort($items, array($this, 'sortByDate'));
     $response->total = $total;
     $response->totalCount = $totalCount;
     $response->objects = $items;
     return $response;
 }
 public function execute()
 {
     $start = microtime(true);
     $this->go = $this->getP("go");
     $this->ks_str = $this->getP("ks_str");
     $this->partner_id = $this->validateKs($this->ks_str);
     if (!$this->ks_str || $this->partner_id === null) {
         $this->email = $this->getP("email");
         $this->err = "";
         if ($this->getP("act") == "login") {
             // admin login
             $admin_login_service = new adminloginAction();
             $_REQUEST["format"] = 6;
             $admin_login_service->setInputParams($_REQUEST);
             //				var_dump ( $_REQUEST );
             try {
                 $res = $admin_login_service->internalExecute(null, null, null, null, null);
                 if ($res["error"]) {
                     $this->err = @$res["error"][0]["desc"];
                     return sfView::ERROR;
                 } else {
                     //var_dump ( $res );
                     $this->ks_str = $res["result"]["ks"];
                 }
             } catch (Exception $ex) {
                 $this->err = "Invalid details";
             }
         } else {
             return sfView::ERROR;
         }
     }
     $this->from_date = $this->getP("from_date");
     $this->to_date = $this->getP("to_date", date("Y-m-d", time() - 2 * 86400));
     // take 2 days back
     $this->days = $this->getP("days", 7);
     if ($this->days) {
         $timeStamp = strtotime($this->to_date);
         $timeStamp -= 24 * 60 * 60 * ($this->days - 1);
         // because it's inclusive-inclusive - reduce one day
         $this->from_date = date("Y-m-d", $timeStamp);
     }
     if ($this->go && $this->getP("act") == "report") {
         $input_filter = new reportsInputFilter();
         $input_filter->from_date = strtotime($this->from_date);
         $input_filter->to_date = strtotime($this->to_date);
         $from_date_id = str_replace("-", "", $this->from_date);
         $to_date_id = str_replace("-", "", $this->to_date);
         $debug = $this->getP("debug");
         $map = array("partner_id" => $this->partner_id, "from_date_id" => $from_date_id, "to_date_id" => $to_date_id);
         try {
             list($this->query, $this->res, $this->header) = myReportsMgr::runQuery("system/system_widget_count", $map, $debug);
             if ($debug) {
                 var_dump($this->query);
                 die;
             }
         } catch (Exception $ex) {
             list($this->res, $this->header) = array(array("Error"), array("error"));
         }
     } else {
         $this->query = "";
         $this->res = null;
     }
     $end = microtime(true);
     $this->bench = $end - $start;
 }
Exemple #13
0
 /**
  * 
  * will create a Csv file for the given report and return the URL to access it
  * @action getUrlForReportAsCsv
  * 
  * @param string $reportTitle The title of the report to display at top of CSV 
  * @param string $reportText The text of the filter of the report
  * @param string $headers The headers of the columns - a map between the enumerations on the server side and the their display text  
  * @param KalturaReportType $reportType  
  * @param KalturaReportInputFilter $reportInputFilter
  * @param string $dimension	  
  * @param KalturaFilterPager $pager
  * @param KalturaReportType $reportType 
  * @param string $order
  * @param string $objectIds - one ID or more (separated by ',') of specific objects to query
  * @return string 
  */
 public function getUrlForReportAsCsvAction($reportTitle, $reportText, $headers, $reportType, KalturaReportInputFilter $reportInputFilter, $dimension = null, KalturaFilterPager $pager = null, $order = null, $objectIds = null)
 {
     if ($reportType == KalturaReportType::PARTNER_USAGE || $reportType == KalturaReportType::VAR_USAGE) {
         $objectIds = $this->validateObjectsAreAllowedPartners($objectIds);
     }
     try {
         $report = myReportsMgr::getUrlForReportAsCsv($this->getPartnerId(), $reportTitle, $reportText, $headers, $reportType, $reportInputFilter->toReportsInputFilter(), $dimension, $objectIds, $pager->pageSize, $pager->pageIndex, $order);
     } catch (Exception $e) {
         $code = $e->getCode();
         if ($code == kCoreException::SEARCH_TOO_GENERAL) {
             throw new KalturaAPIException(KalturaErrors::SEARCH_TOO_GENERAL);
         }
     }
     if (infraRequestUtils::getProtocol() == infraRequestUtils::PROTOCOL_HTTPS) {
         $report = str_replace("http://", "https://", $report);
     }
     return $report;
 }
Exemple #14
0
 /**
  * 
  * will create a Csv file for the given report and return the URL to access it
  * @action getUrlForReportAsCsv
  * 
  * @param string $reportTitle The title of the report to display at top of CSV 
  * @param string $reportText The text of the filter of the report
  * @param string $headers The headers of the columns - a map between the enumerations on the server side and the their display text  
  * @param KalturaReportType $reportType  
  * @param KalturaReportInputFilter $reportInputFilter
  * @param string $dimension	  
  * @param KalturaFilterPager $pager
  * @param KalturaReportType $reportType 
  * @param string $order
  * @param string $objectIds - one ID or more (separated by ',') of specific objects to query
  * @return string 
  */
 function getUrlForReportAsCsvAction($reportTitle, $reportText, $headers, $reportType, KalturaReportInputFilter $reportInputFilter, $dimension = null, KalturaFilterPager $pager = null, $order = null, $objectIds = null)
 {
     return myReportsMgr::getUrlForReportAsCsv($this->getPartnerId(), $reportTitle, $reportText, $headers, $reportType, $reportInputFilter->toReportsInputFilter(), $dimension, $objectIds, $pager->pageSize, $pager->pageIndex, $order);
 }