From 919d743c1d64d24a1540873aebcc7f3e829a04e2 Mon Sep 17 00:00:00 2001 From: Yarosalv Andryushchenkov <7098013@gmail.com> Date: Fri, 20 Jun 2014 17:41:32 +0000 Subject: [PATCH] date granularity field addded to report form. Farm validation added --- amcr/amcr.admin.inc | 82 +++++++++++++++++++++++++++++++------- amcr/amcr.report.class.inc | 3 +- 2 files changed, 69 insertions(+), 16 deletions(-) diff --git a/amcr/amcr.admin.inc b/amcr/amcr.admin.inc index 5b3c395..becf6e7 100644 --- a/amcr/amcr.admin.inc +++ b/amcr/amcr.admin.inc @@ -79,13 +79,22 @@ function amcr_admin_form($form, &$form_state) { * @see amcr_form_report_submit() */ function amcr_report_form($form, &$form_state, AmcrReportConfig $report = NULL) { - $methods = array( + $method_options = array( 'ranked' => 'Ranked report', 'trended' => 'Trended report', 'overtime' => 'Overtime report', //'realtime' => 'Real time report', ); + $date_granularity_options = array( + 'none' => '', + 'hour' => 'hour', + 'dae' => 'day', + 'week' => 'week', + 'quarter' => 'hour', + 'year' => 'year', + ); + $form['name'] = array( '#type' => 'textfield', '#title' => t('Title'), @@ -99,7 +108,7 @@ function amcr_report_form($form, &$form_state, AmcrReportConfig $report = NULL) '#title' => t('Description'), '#default_value' => isset($report->description) ? $report->description : '', '#maxlength' => NULL, - '#description' => t('Report Description. It is shown or report details page'), + '#description' => t('It is shown or report edit page. Admins should leave their notes about the report here.'), '#required' => TRUE, ); $form['report_suite_id'] = array( @@ -114,7 +123,7 @@ function amcr_report_form($form, &$form_state, AmcrReportConfig $report = NULL) '#type' => 'select', '#title' => t('Report type'), '#default_value' => isset($report->method) ? $report->method : 'ranked', - '#options' => $methods, + '#options' => $method_options, ); $form['elements'] = _amcr_elements_list($form_state, @@ -123,6 +132,15 @@ function amcr_report_form($form, &$form_state, AmcrReportConfig $report = NULL) $form['metrics'] = _amcr_metrics_list($form_state, !empty($report->metrics) ? $report->metrics : array()); + $form['date_granularity'] = array( + '#type' => 'select', + '#title' => t('Date granularity'), + '#default_value' => isset($report->date_granularity) ? $report->date_granularity : 'none', + '#description' => t('A time period used to display report data.'), + '#required' => FALSE, + '#options' => $date_granularity_options, + ); + $form['date_from'] = array( '#type' => 'date', '#title' => t('Date from'), @@ -133,8 +151,8 @@ function amcr_report_form($form, &$form_state, AmcrReportConfig $report = NULL) 'day' => date('j', intval($report->date_from)), ) : '', '#maxlength' => NULL, - '#description' => t("Data is analysed since 'Date from ' till 'Date to'. It is '. - 'used if 'Period' is not specified "), + '#description' => t("Data is analysed since 'Date from' till 'Date to'. It is + not used if 'Period' is not specified "), '#required' => FALSE, ); @@ -148,17 +166,20 @@ function amcr_report_form($form, &$form_state, AmcrReportConfig $report = NULL) 'day' => date('j', intval($report->date_to)), ) : '', '#maxlength' => NULL, - '#description' => t("Data is analysed since 'Date from ' till 'Date to'. It is used if 'Period' is not specified."), + '#description' => t("Data is analysed since 'Date from ' till 'Date to'.' + . ' It is not used if 'Period' is not specified."), '#required' => FALSE, ); $form['period'] = array( '#type' => 'textfield', '#title' => t('Period'), - '#default_value' => isset($report->period) ? $report->period / 3600 : '', + '#default_value' => isset($report->period) ? $report->period / 86400 : '', '#maxlength' => NULL, '#size' => 5, - '#description' => t('Period in hours for getting data. It is counted for the moment report execution.'), + '#description' => t('Period in days for getting data. It is counted from the moment report execution.'), '#required' => FALSE, + '#element_validate' => array('amcr_int_number_validate'), + '#error_title' => t('Period'), ); $form['sort_by'] = array( '#type' => 'textfield', @@ -175,6 +196,8 @@ function amcr_report_form($form, &$form_state, AmcrReportConfig $report = NULL) '#size' => 5, '#description' => t('Number of minutes between running report update procedure.'), '#required' => FALSE, + '#element_validate' => array('amcr_int_number_validate'), + '#error_title' => t('Update frequency'), ); $form['actions'] = array('#type' => 'actions'); @@ -273,12 +296,16 @@ function _amcr_element_form($item = NULL) { '#default_value' => isset($item->top) ? $item->top : '', '#maxlength' => 5, '#size' => 2, + '#element_validate' => array('amcr_int_number_validate'), + '#error_title' => t('Top'), ), 'starting_with' => array( '#type' => 'textfield', '#default_value' => isset($item->starting_with) ? $item->starting_with : '', '#maxlength' => 5, '#size' => 2, + '#element_validate' => array('amcr_int_number_validate'), + '#error_title' => t('Starting with'), ), 'keywords' => array( '#type' => 'textfield', @@ -326,7 +353,20 @@ function _amcr_elements_list(&$form_state = NULL, $report_elements = NULL) { $form['#title'] = t('Elements'); $form['#tree'] = TRUE; - $form['#description'] = t('A list of elements that breaks down (organizes) the metrics data in the report'); + $form['#description'] = t('A list of elements that breaks down + (organizes) the metrics data in the report. Parameters: + "Top" - (Optional) Specifies the number of rows in the report to return. Use with + startingWith to generate paged reports. For example, top=5 returns five. rows. + "Starting with" - (Optional) Specifies the first row in the report to return. Use with top to + generate paged reports. For example, startingWith=20 returns report rows starting at row 20. + "Keywords" - a list of keywords to include or exclude from the search, based on the type. + Keyword values can also leverage the following special characters to define + advanced search criteria: + * Wild Card (e.g. "page*.html") + ^ Starts With (e.g. "^http://") + $ Ends With (e.g. ".html$") + "Search type" - boolean values used to link multiple search terms in a report search. + '); $form['#theme'] = 'amcr_element_form'; $form['#prefix'] = '