Example #1
0
 public static function doMonthlyPartnerUsage(Partner $partner)
 {
     KalturaLog::debug("Validating partner [" . $partner->getId() . "]");
     $packages = new PartnerPackages();
     $partnerPackage = $packages->getPackageDetails($partner->getPartnerPackage());
     if ($partnerPackage[PartnerPackages::PACKAGE_CYCLE_FEE] != 0) {
         KalturaLog::debug("Partner has paid package, skipping validation [" . $partner->getId() . "]");
         return;
     }
     $block_notification_grace = time() - dateUtils::DAY * self::BLOCKING_DAYS_GRACE;
     $delete_grace = time() - dateUtils::DAY * 30;
     $report_date = dateUtils::todayOffset(-1);
     list($monthlyStorage, $monthlyTraffic, $monthlyTranscoding) = myPartnerUtils::collectPartnerMonthlyStatisticsFromDWH($partner, $report_date);
     $email_link_hash = 'pid=' . $partner->getId() . '&h=' . self::getEmailLinkHash($partner->getId(), $partner->getSecret());
     self::validatePartnerMonthlyUsagePerType($partner, $partnerPackage, $monthlyStorage, PartnerPackages::PACKAGE_STORAGE_USAGE, $report_date, $block_notification_grace, $delete_grace, $email_link_hash);
     self::validatePartnerMonthlyUsagePerType($partner, $partnerPackage, $monthlyTraffic, PartnerPackages::PACKAGE_TRAFFIC_USAGE, $report_date, $block_notification_grace, $delete_grace, $email_link_hash);
     self::validatePartnerMonthlyUsagePerType($partner, $partnerPackage, $monthlyTranscoding, PartnerPackages::PACKAGE_TRANSCODING_USAGE, $report_date, $block_notification_grace, $delete_grace, $email_link_hash);
     $partner->save();
 }