/** * Runs the example. * @param AdWordsUser $user the user to run the example with * @param string $filePath the path of the file to download the report to */ function DownloadCriteriaReportWithAwqlExample(AdWordsUser $user, $filePath, $reportFormat) { // Optional: Set clientCustomerId to get reports of your child accounts // $user->SetClientCustomerId('INSERT_CLIENT_CUSTOMER_ID_HERE'); // Prepare a date range for the last week. Instead you can use 'LAST_7_DAYS'. $dateRange = sprintf('%d,%d', date('Ymd', strtotime('-7 day')), date('Ymd', strtotime('-1 day'))); // Create report query. $reportQuery = 'SELECT CampaignId, AdGroupId, Id, Criteria, CriteriaType, ' . 'Impressions, Clicks, Cost FROM CRITERIA_PERFORMANCE_REPORT ' . 'WHERE Status IN [ENABLED, PAUSED] DURING ' . $dateRange; // Set additional options. $options = array('version' => ADWORDS_VERSION); // Optional: Set skipReportHeader, skipColumnHeader, skipReportSummary to // suppress headers or summary rows. // $options['skipReportHeader'] = true; // $options['skipColumnHeader'] = true; // $options['skipReportSummary'] = true; // // Optional: Set useRawEnumValues to return enum values instead of enum // display values. // $options['useRawEnumValues'] = false; // // Optional: Set includeZeroImpressions to include zero impression rows in // the report output. // $options['includeZeroImpressions'] = true; // Download report. $reportUtils = new ReportUtils(); $reportUtils->DownloadReportWithAwql($reportQuery, $filePath, $user, $reportFormat, $options); printf("Report was downloaded to '%s'.\n", $filePath); }
/** * @param [Array] $definition * $definition['reportType'] * $definition['periode'] * $definition['fields'] * $definition['predicates'] */ public function createReport(array $definition) { $filePath = dirname(__FILE__) . $this->tempDirPath . uniqid() . 'report.csv'; $this->AdWordsUser->LoadService('ReportDefinitionService', ADWORDS_VERSION); // Create selector. $selector = new \Selector(); $selector->fields = $definition['fields']; $selector->dateRange = new \DateRange((new \DateTime($definition['periode']['start']))->format('Ymd'), (new \DateTime($definition['periode']['end']))->format('Ymd')); // predicates if (isset($definition['predicates']) && count($definition['predicates']) > 0) { foreach ($definition['predicates'] as $predicate) { $selector->predicates[] = new \Predicate($predicate['field'], $predicate['condition'], $predicate['value']); } } // Create report definition. $reportDefinition = new \ReportDefinition(); $reportDefinition->selector = $selector; $reportDefinition->reportName = 'Custom Report'; $reportDefinition->dateRangeType = 'CUSTOM_DATE'; $reportDefinition->reportType = $definition['reportType']; $reportDefinition->downloadFormat = 'CSV'; $options = array('version' => ADWORDS_VERSION, 'includeZeroImpressions' => false); // Download report. try { $reportUtils = new \ReportUtils(); $report = $reportUtils->DownloadReport($reportDefinition, $filePath, $this->AdWordsUser, $options); $this->result = $this->parseAccountReport($filePath); $this->result = $this->convertMicroMoney($definition['fields'], $this->result); } catch (\Exception $e) { printf("An error has occurred: %s\n", $e->getMessage()); } unlink($filePath); }
/** * Runs the example. * @param AdWordsUser $user the user to run the example with * @param string $filePath the path of the file to download the report to */ function DownloadCriteriaReportExample(AdWordsUser $user, $filePath) { // Load the service, so that the required classes are available. $user->LoadService('ReportDefinitionService', ADWORDS_VERSION); // Create selector. $selector = new Selector(); $selector->fields = array('CampaignId', 'AdGroupId', 'Id', 'Criteria', 'CriteriaType', 'Impressions', 'Clicks', 'Cost'); // Optional: use predicate to filter out paused criteria. $selector->predicates[] = new Predicate('Status', 'NOT_IN', array('PAUSED')); // Create report definition. $reportDefinition = new ReportDefinition(); $reportDefinition->selector = $selector; $reportDefinition->reportName = 'Criteria performance report #' . uniqid(); $reportDefinition->dateRangeType = 'LAST_7_DAYS'; $reportDefinition->reportType = 'CRITERIA_PERFORMANCE_REPORT'; $reportDefinition->downloadFormat = 'CSV'; // Exclude criteria that haven't recieved any impressions over the date range. $reportDefinition->includeZeroImpressions = false; // Set additional options. $options = array('version' => ADWORDS_VERSION); // Optional: Set skipReportHeader, skipColumnHeader, skipReportSummary to // suppress headers or summary rows. // $options['skipReportHeader'] = true; // $options['skipColumnHeader'] = true; // $options['skipReportSummary'] = true; // Optional: Set includeZeroImpressions to include zero impression rows in // the report output. // $options['includeZeroImpressions'] = true; // Download report. ReportUtils::DownloadReport($reportDefinition, $filePath, $user, $options); printf("Report with name '%s' was downloaded to '%s'.\n", $reportDefinition->reportName, $filePath); }
/** * Runs the example. * @param AdWordsUser $user the user to run the example with * @param string $reportDefinitionId the ID of the report definition to download * @param string $filePath the path of the file to download the report to */ function DownloadDefinedReportExample(AdWordsUser $user, $reportDefinitionId, $filePath) { // Set options. $options = array('version' => 'v201109', 'returnMoneyInMicros' => TRUE); // Download report. ReportUtils::DownloadReport($reportDefinitionId, $filePath, $user, $options); printf("Report with definition id '%s' was downloaded to '%s'.\n", $reportDefinitionId, $filePath); }
/** * Runs the example. * @param AdWordsUser $user the user to run the example with * @param string $filePath the path of the file to download the report to */ function DownloadCriteriaReportWithAwqlExample(AdWordsUser $user, $filePath, $reportFormat) { // Prepare a date range for the last week. Instead you can use 'LAST_7_DAYS'. $dateRange = sprintf('%d,%d', date('Ymd', strtotime('-7 day')), date('Ymd', strtotime('-1 day'))); // Create report query. $reportQuery = 'SELECT CampaignId, AdGroupId, Id, Criteria, CriteriaType, ' . 'Impressions, Clicks, Cost FROM CRITERIA_PERFORMANCE_REPORT ' . 'WHERE Status IN [ACTIVE, PAUSED] DURING ' . $dateRange; // Set additional options. $options = array('version' => 'v201206'); // Download report. ReportUtils::DownloadReportWithAwql($reportQuery, $filePath, $user, $reportFormat, $options); printf("Report was downloaded to '%s'.\n", $filePath); }
/** * Runs the example. * @param AdWordsUser $user the user to run the example with * @param string $filePath the path of the file to download the report to */ function DownloadCriteriaReportExample(AdWordsUser $user, $filePath) { // Load the service, so that the required classes are available. $user->LoadService('ReportDefinitionService', ADWORDS_VERSION); // Optional: Set clientCustomerId to get reports of your child accounts // $user->SetClientCustomerId('INSERT_CLIENT_CUSTOMER_ID_HERE'); // Create selector. $selector = new Selector(); $selector->fields = array('CampaignId', 'AdGroupId', 'Id', 'Criteria', 'CriteriaType', 'Impressions', 'Clicks', 'Cost'); // Optional: use predicate to filter out paused criteria. $selector->predicates[] = new Predicate('Status', 'NOT_IN', array('PAUSED')); // Create report definition. $reportDefinition = new ReportDefinition(); $reportDefinition->selector = $selector; $reportDefinition->reportName = 'Criteria performance report #' . uniqid(); $reportDefinition->dateRangeType = 'LAST_7_DAYS'; $reportDefinition->reportType = 'CRITERIA_PERFORMANCE_REPORT'; $reportDefinition->downloadFormat = 'CSV'; // Set additional options. $options = array('version' => ADWORDS_VERSION); // Optional: Set skipReportHeader, skipColumnHeader, skipReportSummary to // suppress headers or summary rows. // $options['skipReportHeader'] = true; // $options['skipColumnHeader'] = true; // $options['skipReportSummary'] = true; // // Optional: Set useRawEnumValues to return enum values instead of enum // display values. // $options['useRawEnumValues'] = true; // // Optional: Set includeZeroImpressions to include zero impression rows in // the report output. // $options['includeZeroImpressions'] = true; // Download report. $reportUtils = new ReportUtils(); $reportUtils->DownloadReport($reportDefinition, $filePath, $user, $options); printf("Report with name '%s' was downloaded to '%s'.\n", $reportDefinition->reportName, $filePath); }
/** * Runs the example. * @param AdWordsUser $user the user to run the example with * @param string $filePath the path of the file to download the report to */ function DownloadCriteriaReportWithAwqlExample(AdWordsUser $user, $filePath, $reportFormat) { // Prepare a date range for the last week. Instead you can use 'LAST_7_DAYS'. $dateRange = sprintf('%d,%d', date('Ymd', strtotime('-7 day')), date('Ymd', strtotime('-1 day'))); // Create report query. $reportQuery = 'SELECT CampaignId, AdGroupId, Id, Criteria, CriteriaType, ' . 'Impressions, Clicks, Cost FROM CRITERIA_PERFORMANCE_REPORT ' . 'WHERE Status IN [ENABLED, PAUSED] DURING ' . $dateRange; // Set additional options. $options = array('version' => ADWORDS_VERSION); // Optional: Set skipReportHeader, skipColumnHeader or skipReportSummary to // suppress header or summary rows in the report output. // $options['skipReportHeader'] = true; // $options['skipColumnHeader'] = true; // $options['skipReportSummary'] = true; // Download report. ReportUtils::DownloadReportWithAwql($reportQuery, $filePath, $user, $reportFormat, $options); printf("Report was downloaded to '%s'.\n", $filePath); }
/** * Runs the example. * @param AdWordsUser $user the user to run the example with * @param string $filePath the path of the file to download the report to */ function DownloadCriteriaReportExample(AdWordsUser $user, $filePath) { // Load the service, so that the required classes are available. $user->LoadService('ReportDefinitionService', ADWORDS_VERSION); // Create selector. $selector = new Selector(); $selector->fields = array('CampaignId', 'AdGroupId', 'Id', 'Criteria', 'CriteriaType', 'Impressions', 'Clicks', 'Cost'); // Filter out deleted criteria. $selector->predicates[] = new Predicate('Status', 'NOT_IN', array('DELETED')); // Create report definition. $reportDefinition = new ReportDefinition(); $reportDefinition->selector = $selector; $reportDefinition->reportName = 'Criteria performance report #' . uniqid(); $reportDefinition->dateRangeType = 'LAST_7_DAYS'; $reportDefinition->reportType = 'CRITERIA_PERFORMANCE_REPORT'; $reportDefinition->downloadFormat = 'CSV'; // Exclude criteria that haven't recieved any impressions over the date range. $reportDefinition->includeZeroImpressions = FALSE; // Set additional options. $options = array('version' => ADWORDS_VERSION, 'returnMoneyInMicros' => TRUE); // Download report. ReportUtils::DownloadReport($reportDefinition, $filePath, $user, $options); printf("Report with name '%s' was downloaded to '%s'.\n", $reportDefinition->reportName, $filePath); }
$path = dirname(__FILE__) . '/../../../../src'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php'; require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php'; require_once 'Google/Api/Ads/Dfp/Util/ReportUtils.php'; try { // Get DfpUser from credentials in "../auth.ini" // relative to the DfpUser.php file's directory. $user = new DfpUser(); // Log SOAP XML request and response. $user->LogDefaults(); // Get the ReportService. $reportService = $user->GetService('ReportService', 'v201208'); // Set the ID of the completed report. $reportJobId = 'INSERT_REPORT_JOB_ID_HERE'; // Set the format of the report. Ex: CSV_DUMP $exportFormat = 'INSERT_EXPORT_FORMAT_HERE'; // Set the file name to download the gzipped report to. Ex: report.csv.gz. $fileName = 'INSERT_FILE_NAME_HERE' . '.gz'; $filePath = dirname(__FILE__) . '/' . $fileName; $downloadUrl = $reportService->getReportDownloadURL($reportJobId, $exportFormat); printf("Downloading report from URL '%s'.\n", $downloadUrl); ReportUtils::DownloadReport($downloadUrl, $filePath); printf("Report downloaded to file '%s'.\n", $filePath); } catch (OAuth2Exception $e) { ExampleUtils::CheckForOAuth2Errors($e); } catch (ValidationException $e) { ExampleUtils::CheckForOAuth2Errors($e); } catch (Exception $e) { print $e->getMessage() . "\n"; }
/** * Test downloading a report to a string. A dummy URL is used in place of a * report URL. * @covers ReportUtils::DownloadReport */ public function testDownloadReportToString() { $result = ReportUtils::DownloadReport(ReportUtilsTest::DUMMY_REPORT_URL); $this->assertTrue(isset($result)); }
function getMentorColumns($model) { //get or initialize the current column order $columnArrayOrder = getColumnArrayOrder(); //only if make a cache of the columns if needed if (isset($_GET['sourceColumn']) && isset($_GET['destinationColumn'])) { $source = $_GET['sourceColumn']; $destination = $_GET['destinationColumn']; $sourceIndex = $source[0]; $destIndex = $destination[0]; ReportUtils::moveColumnsByIndex($sourceIndex, $destIndex, $columnArrayOrder); Yii::app()->session['MentorColumnOrder'] = $columnArrayOrder; } $columns = array(); for ($i = 0; $i < count($columnArrayOrder); $i++) { switch ($columnArrayOrder[$i]) { case MentorColumns::userID: $columns[] = array('name' => 'userID', 'header' => 'Mentor User ID', 'filter' => CHtml::activeNumberField($model, 'userID'), 'headerHtmlOptions' => array('width' => '75')); break; case MentorColumns::name: $columns[] = array('name' => 'name', 'header' => 'Mentor Name', 'filter' => CHtml::activeTextField($model, 'name'), 'headerHtmlOptions' => array('width' => '200')); break; case MentorColumns::email: $columns[] = array('name' => 'email', 'header' => 'Mentor Email', 'filter' => CHtml::activeEmailField($model, 'email'), 'headerHtmlOptions' => array('width' => '200')); break; case MentorColumns::userName: $columns[] = array('name' => 'userName', 'header' => 'Mentor User Name', 'filter' => CHtml::activeTextField($model, 'userName'), 'headerHtmlOptions' => array('width' => '120')); break; case MentorColumns::disabled: $columns[] = array('name' => 'disabled', 'header' => 'Mentor Disabled', 'value' => 'ReportUtils::getZeroOneToYesNo($data->disabled)', 'filter' => array('1' => 'Yes', '0' => 'No'), 'headerHtmlOptions' => array('width' => '80')); break; case MentorColumns::isProjectMentor: $columns[] = array('name' => 'isProjectMentor', 'header' => 'Project Mentor', 'value' => 'ReportUtils::getZeroOneToYesNo($data->isProjectMentor)', 'filter' => array('1' => 'Yes', '0' => 'No'), 'headerHtmlOptions' => array('width' => '80')); break; case MentorColumns::isPersonalMentor: $columns[] = array('name' => 'isPersonalMentor', 'header' => 'Personal Mentor', 'value' => 'ReportUtils::getZeroOneToYesNo($data->isPersonalMentor)', 'filter' => array('1' => 'Yes', '0' => 'No'), 'headerHtmlOptions' => array('width' => '80')); break; case MentorColumns::isDomainMentor: $columns[] = array('name' => 'isDomainMentor', 'header' => 'Domain Mentor', 'value' => 'ReportUtils::getZeroOneToYesNo($data->isDomainMentor)', 'filter' => array('1' => 'Yes', '0' => 'No'), 'headerHtmlOptions' => array('width' => '80')); break; case MentorColumns::isJudge: $columns[] = array('name' => 'isJudge', 'header' => 'Judge', 'value' => 'ReportUtils::getZeroOneToYesNo($data->isJudge)', 'filter' => array('1' => 'Yes', '0' => 'No'), 'headerHtmlOptions' => array('width' => '80')); break; case MentorColumns::isNew: $columns[] = array('name' => 'isNew', 'header' => 'Is New', 'value' => 'ReportUtils::getZeroOneToYesNo($data->isNew)', 'filter' => array('1' => 'Yes', '0' => 'No'), 'headerHtmlOptions' => array('width' => '80')); break; case MentorColumns::isEmployer: $columns[] = array('name' => 'isEmployer', 'header' => 'Is Employer', 'value' => 'ReportUtils::getZeroOneToYesNo($data->isEmployer)', 'filter' => array('1' => 'Yes', '0' => 'No'), 'headerHtmlOptions' => array('width' => '80')); break; case MentorColumns::employer: $columns[] = array('name' => 'employer', 'header' => 'Mentor Employer', 'filter' => CHtml::activeTextField($model, 'employer'), 'headerHtmlOptions' => array('width' => '200')); break; case MentorColumns::position: $columns[] = array('name' => 'position', 'header' => 'Mentor Position', 'filter' => CHtml::activeTextField($model, 'position'), 'headerHtmlOptions' => array('width' => '200')); break; case MentorColumns::fieldOfStudy: $columns[] = array('name' => 'fieldOfStudy', 'header' => 'Mentor Field Of Study', 'filter' => CHtml::activeTextField($model, 'fieldOfStudy'), 'headerHtmlOptions' => array('width' => '200')); break; case MentorColumns::degree: $columns[] = array('name' => 'degree', 'header' => 'Mentor Degree', 'filter' => CHtml::activeTextField($model, 'degree'), 'headerHtmlOptions' => array('width' => '200')); break; case MentorColumns::gradYear: $columns[] = array('name' => 'gradYear', 'header' => 'Mentor Graduation Year', 'filter' => CHtml::activeNumberField($model, 'gradYear'), 'headerHtmlOptions' => array('width' => '200')); break; } } return $columns; }
$path = dirname(__FILE__) . '/../../../../src'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php'; require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php'; require_once 'Google/Api/Ads/Dfp/Util/ReportUtils.php'; try { // Get DfpUser from credentials in "../auth.ini" // relative to the DfpUser.php file's directory. $user = new DfpUser(); // Log SOAP XML request and response. $user->LogDefaults(); // Get the ReportService. $reportService = $user->GetService('ReportService', 'v201311'); // Set the ID of the completed report. $reportJobId = 'INSERT_REPORT_JOB_ID_HERE'; // Set the format of the report (e.g., CSV_DUMP) and download without // compression so we can print it. $reportDownloadOptions = new ReportDownloadOptions(); $reportDownloadOptions->exportFormat = 'INSERT_EXPORT_FORMAT_HERE'; $reportDownloadOptions->useGzipCompression = false; $downloadUrl = $reportService->getReportDownloadUrlWithOptions($reportJobId, $reportDownloadOptions); printf("Downloading report from URL '%s'.\n", $downloadUrl); $report = ReportUtils::DownloadReport($downloadUrl); printf("\n%s\n", $report); } catch (OAuth2Exception $e) { ExampleUtils::CheckForOAuth2Errors($e); } catch (ValidationException $e) { ExampleUtils::CheckForOAuth2Errors($e); } catch (Exception $e) { printf("%s\n", $e->getMessage()); }
function getMenteColumns($model) { //get or initialize the current column order $columnArrayOrder = getColumnArrayOrder(); //only if make a cache of the columns if needed if (isset($_GET['sourceColumn']) && isset($_GET['destinationColumn'])) { $source = $_GET['sourceColumn']; $destination = $_GET['destinationColumn']; $sourceIndex = $source[0]; $destIndex = $destination[0]; ReportUtils::moveColumnsByIndex($sourceIndex, $destIndex, $columnArrayOrder); Yii::app()->session['MenteeColumnOrder'] = $columnArrayOrder; } //Now render the columns $columns = array(); for ($i = 0; $i < count($columnArrayOrder); $i++) { switch ($columnArrayOrder[$i]) { case MenteeColumns::userId: $menteeUserID = array('name' => 'UserID', 'header' => 'Mentee User ID', 'filter' => CHtml::activeNumberField($model, 'UserID'), 'headerHtmlOptions' => array('width' => '75')); $columns[] = $menteeUserID; break; case MenteeColumns::menteeName: $menteeName = array('name' => 'Name', 'header' => 'Mentee Name', 'filter' => CHtml::activeTextField($model, 'Name'), 'headerHtmlOptions' => array('width' => '200')); $columns[] = $menteeName; break; case MenteeColumns::menteeEmail: $menteeEmail = array('name' => 'Email', 'header' => 'Mentee Email', 'filter' => CHtml::activeEmailField($model, 'Email'), 'headerHtmlOptions' => array('width' => '150')); $columns[] = $menteeEmail; break; case MenteeColumns::menteeUserName: $menteeUserName = array('name' => 'UserName', 'header' => 'Mentee User Name', 'filter' => CHtml::activeTextField($model, 'UserName'), 'headerHtmlOptions' => array('width' => '100')); $columns[] = $menteeUserName; break; case MenteeColumns::menteeDisabled: $menteeDisabled = array('name' => 'Disabled', 'header' => 'Mentee Disabled', 'value' => 'ReportUtils::getZeroOneToYesNo($data->Disabled)', 'filter' => array('1' => 'Yes', '0' => 'No'), 'headerHtmlOptions' => array('width' => '100')); $columns[] = $menteeDisabled; break; case MenteeColumns::menteeUniversityName: $universityName = array('name' => 'UniversityName', 'header' => 'Mentee University', 'filter' => CHtml::activeDropDownList($model, 'UniversityID', CHtml::listData(University::model()->findAll(), 'id', 'name'), array('empty' => ' ')), 'headerHtmlOptions' => array('width' => '220')); $columns[] = $universityName; break; case MenteeColumns::menteePersonalMentorID: $PersonalMentorID = array('name' => 'PersonalMentorID', 'header' => 'Personal Mentor (ID)', 'filter' => CHtml::activeNumberField($model, 'PersonalMentorID'), 'headerHtmlOptions' => array('width' => '100')); $columns[] = $PersonalMentorID; break; case MenteeColumns::menteePersonalMentorName: $PersonalMentorName = array('name' => 'PersonalMentorName', 'header' => 'Personal Mentor (Name)', 'filter' => CHtml::activeTextField($model, 'PersonalMentorName'), 'headerHtmlOptions' => array('width' => '150')); $columns[] = $PersonalMentorName; break; case MenteeColumns::menteePersonalMentorEmail: $PersonalMentorEmail = array('name' => 'PersonalMentorEmail', 'header' => 'Personal Mentor (Email)', 'filter' => CHtml::activeEmailField($model, 'PersonalMentorEmail'), 'headerHtmlOptions' => array('width' => '150')); $columns[] = $PersonalMentorEmail; break; case MenteeColumns::menteePersonalMentorDisabled: $PersonalMentorDisabled = array('name' => 'PersonalMentorDisabled', 'header' => 'Personal Mentor (Disabled)', 'value' => 'ReportUtils::getZeroOneToYesNo($data->PersonalMentorDisabled)', 'filter' => array('1' => 'Yes', '0' => 'No'), 'headerHtmlOptions' => array('width' => '150')); $columns[] = $PersonalMentorDisabled; break; case MenteeColumns::menteeProjectTitle: $menteeProjectTitle = array('name' => 'menteeProjectTitle', 'header' => 'Project Title', 'filter' => CHtml::activeDropDownList($model, 'menteeProjectID', CHtml::listData(Project::model()->findAll(), 'id', 'title'), array('empty' => ' ')), 'headerHtmlOptions' => array('width' => '300')); $columns[] = $menteeProjectTitle; break; case MenteeColumns::menteeProjectStartDate: $menteeProjectTitle = array('name' => 'menteeProjectStartDate', 'header' => 'Project Start Date', 'value' => 'ReportUtils::dateformat($data->menteeProjectStartDate)', 'filter' => CHtml::activeDateField($model, 'menteeProjectStartDate'), 'headerHtmlOptions' => array('width' => '160')); $columns[] = $menteeProjectTitle; break; case MenteeColumns::menteeProjectDueDate: $menteeProjectDueDate = array('name' => 'menteeProjectDueDate', 'header' => 'Project Due Date', 'value' => 'ReportUtils::dateformat($data->menteeProjectDueDate)', 'filter' => CHtml::activeDateField($model, 'menteeProjectDueDate'), 'headerHtmlOptions' => array('width' => '160')); $columns[] = $menteeProjectDueDate; break; case MenteeColumns::menteeProjectCustomerName: $menteeProjectCustomerName = array('name' => 'menteeProjectCustomerName', 'header' => 'Project Customer', 'filter' => CHtml::activeTextField($model, 'menteeProjectCustomerName'), 'headerHtmlOptions' => array('width' => '150')); $columns[] = $menteeProjectCustomerName; break; } } return $columns; }
/** * @param $reportQuery * @param string $format * @param array $options * @return null|string|void */ public function downloadReportWithAwql($reportQuery, $format, $path = null, array $options = null) { $allowformats = array("CSV", "XML", "TSV", "GZIPPED_CSV", "GZIPPED_XML"); if (!in_array($format, $allowformats)) { return; } if (!$this->validateUser()) { return; } $report = null; try { $report = \ReportUtils::DownloadReportWithAwql($reportQuery, $path, $this->adwordsuser, $format, $options); if ("GZIPPED_CSV" == $format || "GZIPPED_XML" == $format) { $report = gzdecode($report); } } catch (\Exception $e) { $this->lastexception = $e; return; } return $report; }
/** * Runs the example. * @param AdWordsUser $user the user to run the example with */ function ParallelReportDownloadExample(AdWordsUser $user) { // Load the service, so that the required classes are available. $user->LoadService('ReportDefinitionService', ADWORDS_VERSION); // Create selector. $selector = new Selector(); $selector->fields = array('CampaignId', 'AdGroupId', 'Impressions', 'Clicks', 'Cost'); // Create report definition. $reportDefinition = new ReportDefinition(); $reportDefinition->selector = $selector; $reportDefinition->reportName = 'Custom ADGROUP_PERFORMANCE_REPORT'; $reportDefinition->dateRangeType = 'LAST_7_DAYS'; $reportDefinition->reportType = 'ADGROUP_PERFORMANCE_REPORT'; $reportDefinition->downloadFormat = 'CSV'; // Set additional options. $options = array('version' => ADWORDS_VERSION); // Optional: Set skipReportHeader, skipColumnHeader, skipReportSummary to // suppress headers or summary rows. // $options['skipReportHeader'] = true; // $options['skipColumnHeader'] = true; // $options['skipReportSummary'] = true; // // Optional: Set useRawEnumValues to return enum values instead of enum // display values. // $options['useRawEnumValues'] = true; // // Optional: Set includeZeroImpressions to include zero impression rows in // the report output. // $options['includeZeroImpressions'] = true; $customerIds = getAllManagedCustomerIds($user); printf("Downloading reports for %d managed customers.\n", count($customerIds)); $successfulReports = array(); $failedReports = array(); $reportDir = sys_get_temp_dir(); $reportUtils = new ReportUtils(); foreach ($customerIds as $customerId) { $filePath = sprintf('%s.csv', tempnam($reportDir, 'adgroup_')); $user->SetClientCustomerId($customerId); $retryCount = 0; $doContinue = true; do { $retryCount++; try { $reportUtils->DownloadReport($reportDefinition, $filePath, $user, $options); printf("Report for client customer ID %d successfully downloaded to: %s\n", $customerId, $filePath); $successfulReports[$customerId] = $filePath; $doContinue = false; } catch (ReportDownloadException $e) { printf("Report attempt #%d for client customer ID %d was not downloaded" . " due to: %s\n", $retryCount, $customerId, $e->getMessage()); if ($e->GetHttpCode() >= 500 && $retryCount < MAX_RETRIES) { $sleepTime = $retryCount * BACKOFF_FACTOR; printf("Sleeping %d seconds before retrying report for client customer " . "ID %d.\n", $sleepTime, $customerId); sleep($sleepTime); } else { printf("Report request failed for client customer ID %d.\n", $customerId); $failedReports[$customerId] = $filePath; $doContinue = false; } } } while ($doContinue === true); } print "All downloads completed. Results:\n"; print "Successful reports:\n"; foreach ($successfulReports as $customerId => $filePath) { printf("\tClient ID %d => '%s'\n", $customerId, $filePath); } print "Failed reports:\n"; foreach ($failedReports as $customerId => $filePath) { printf("\tClient ID %d => '%s'\n", $customerId, $filePath); } print "End of results.\n"; }
function getTicketColumns($model) { //get or initialize the current column order $columnArrayOrder = getColumnArrayOrder(); //only if make a cache of the columns if needed if (isset($_GET['sourceColumn']) && isset($_GET['destinationColumn'])) { $source = $_GET['sourceColumn']; $destination = $_GET['destinationColumn']; $sourceIndex = $source[0]; $destIndex = $destination[0]; ReportUtils::moveColumnsByIndex($sourceIndex, $destIndex, $columnArrayOrder); Yii::app()->session['TicketColumnOrder'] = $columnArrayOrder; } $columns = array(); for ($i = 0; $i < count($columnArrayOrder); $i++) { switch ($columnArrayOrder[$i]) { case TicketReportColumns::ticketID: $columns[] = array('name' => 'ticketID', 'header' => 'Ticket #', 'filter' => CHtml::activeNumberField($model, 'ticketID'), 'headerHtmlOptions' => array('width' => '75')); break; case TicketReportColumns::creatorName: $columns[] = array('name' => 'creatorName', 'header' => 'Creator Name', 'filter' => CHtml::activeTextField($model, 'creatorName'), 'headerHtmlOptions' => array('width' => '200')); break; case TicketReportColumns::creatorID: $columns[] = array('name' => 'creatorID', 'header' => 'Creator ID', 'filter' => CHtml::activeNumberField($model, 'creatorID'), 'headerHtmlOptions' => array('width' => '75')); break; case TicketReportColumns::creatorDisabled: $columns[] = array('name' => 'creatorDisabled', 'header' => 'Creator Disabled', 'value' => 'ReportUtils::getZeroOneToYesNo($data->creatorDisabled)', 'filter' => array('1' => 'Yes', '0' => 'No'), 'headerHtmlOptions' => array('width' => '80')); break; case TicketReportColumns::creatorEmail: $columns[] = array('name' => 'creatorEmail', 'header' => 'Creator Email', 'filter' => CHtml::activeEmailField($model, 'creatorEmail'), 'headerHtmlOptions' => array('width' => '150')); break; case TicketReportColumns::ticketStatus: $columns[] = array('name' => 'ticketStatus', 'header' => 'Ticket Status', 'filter' => array('Close' => 'Close', 'Pending' => 'Pending'), 'headerHtmlOptions' => array('width' => '105')); break; case TicketReportColumns::ticketCreatedDate: $columns[] = array('name' => 'ticketCreatedDate', 'header' => 'Created Date', 'value' => 'ReportUtils::dateformat($data->ticketCreatedDate)', 'filter' => CHtml::activeDateField($model, 'ticketCreatedDate'), 'headerHtmlOptions' => array('width' => '160')); break; case TicketReportColumns::assignedUserName: $columns[] = array('name' => 'assignedUserName', 'header' => 'Assigned To (Name)', 'filter' => CHtml::activeTextField($model, 'assignedUserName'), 'headerHtmlOptions' => array('width' => '150')); break; case TicketReportColumns::ticketAssignUserID: $columns[] = array('name' => 'ticketAssignUserID', 'header' => 'Assigned To (Id)', 'filter' => CHtml::activeNumberField($model, 'ticketAssignUserID'), 'headerHtmlOptions' => array('width' => '100')); break; case TicketReportColumns::assignedUserDisabled: $columns[] = array('name' => 'assignedUserDisabled', 'header' => 'Assigned To (Disabled)', 'value' => 'ReportUtils::getZeroOneToYesNo($data->assignedUserDisabled)', 'filter' => array('1' => 'Yes', '0' => 'No'), 'headerHtmlOptions' => array('width' => '100')); break; case TicketReportColumns::assignedUserEmail: $columns[] = array('name' => 'assignedUserEmail', 'header' => 'Assigned To (Email)', 'filter' => CHtml::activeEmailField($model, 'assignedUserEmail'), 'headerHtmlOptions' => array('width' => '150')); break; case TicketReportColumns::ticketDomainName: $columns[] = array('name' => 'ticketDomainName', 'header' => 'Ticket Domain', 'filter' => CHtml::activeDropDownList($model, 'ticketDomainID', CHtml::listData(Domain::model()->findAll(), 'id', 'name'), array('empty' => ' ')), 'headerHtmlOptions' => array('width' => '200')); break; case TicketReportColumns::ticketSubDomainName: $columns[] = array('name' => 'ticketSubDomainName', 'header' => 'Ticket Sub Domain', 'filter' => CHtml::activeDropDownList($model, 'ticketSubDomainID', CHtml::listData(Subdomain::model()->findAll(), 'id', 'name'), array('empty' => ' ')), 'headerHtmlOptions' => array('width' => '170')); break; case TicketReportColumns::ticketPriorityDescription: $columns[] = array('name' => 'ticketPriorityDescription', 'header' => 'Ticket Priority', 'filter' => CHtml::activeDropDownList($model, 'ticketPriorityID', CHtml::listData(Priority::model()->findAll(), 'id', 'description'), array('empty' => ' ')), 'headerHtmlOptions' => array('width' => '110')); break; case TicketReportColumns::ticketAssignedDate: $columns[] = array('name' => 'ticketAssignedDate', 'header' => 'Ticket Assigned Date', 'value' => 'ReportUtils::dateformat($data->ticketAssignedDate)', 'filter' => CHtml::activeDateField($model, 'ticketAssignedDate'), 'headerHtmlOptions' => array('width' => '160')); break; case TicketReportColumns::ticketClosedDate: $columns[] = array('name' => 'ticketClosedDate', 'header' => 'Ticket Closed Date', 'value' => 'ReportUtils::dateformat($data->ticketClosedDate)', 'filter' => CHtml::activeDateField($model, 'ticketClosedDate'), 'headerHtmlOptions' => array('width' => '160')); break; case TicketReportColumns::ticketIsEscalated: $columns[] = array('name' => 'ticketIsEscalated', 'header' => 'Escalated', 'value' => 'ReportUtils::getZeroOneToYesNo($data->ticketIsEscalated)', 'filter' => array('1' => 'Yes', '0' => 'No'), 'headerHtmlOptions' => array('width' => '80')); break; case TicketReportColumns::ticketSubject: $columns[] = array('name' => 'ticketSubject', 'header' => 'Subject', 'filter' => CHtml::activeTextField($model, 'ticketSubject'), 'headerHtmlOptions' => array('width' => '300')); break; case TicketReportColumns::ticketDescription: $columns[] = array('name' => 'ticketDescription', 'header' => 'Description', 'filter' => CHtml::activeTextField($model, 'ticketDescription'), 'headerHtmlOptions' => array('width' => '400')); break; } } return $columns; }