You are here

function ad_report_range_form_validate in Advertisement 6.3

Same name and namespace in other branches
  1. 5.2 report/ad_report.module \ad_report_range_form_validate()
  2. 6.2 report/ad_report.module \ad_report_range_form_validate()
  3. 7 report/ad_report.module \ad_report_range_form_validate()

Validate the form range.

File

report/ad_report.module, line 619
Provides comprehensive charts and reports about advertising statistics.

Code

function ad_report_range_form_validate($form, $form_state) {
  $start = isset($form_state['values']['start']) ? strtotime($form_state['values']['start']) : 0;
  $end = isset($form_state['values']['start']) ? strtotime($form_state['values']['end']) : 0;
  if (!$start) {
    form_set_error('start', t('You must enter a valid start date.'));
  }
  else {
    if ($start >= time() - 3600) {
      form_set_error('start', t('The report must start at least one hour before the current time.'));
    }
    else {
      if ($start >= $end) {
        form_set_error('start', t('The report must start before it ends.'));
      }
    }
  }
  if (!$end) {
    form_set_error('end', t('You must enter a valid end date.'));
  }
}