You are here

function uc_coupon_reports_form in Ubercart Discount Coupons 5

Same name and namespace in other branches
  1. 6 uc_coupon.reports.inc \uc_coupon_reports_form()
  2. 7.3 uc_coupon.reports.inc \uc_coupon_reports_form()
  3. 7.2 uc_coupon.reports.inc \uc_coupon_reports_form()

Coupon report form.

1 string reference to 'uc_coupon_reports_form'
uc_coupon_reports in ./uc_coupon.module
Output Coupon Reports

File

./uc_coupon.module, line 1120
Provides discount coupons for Ubercart.

Code

function uc_coupon_reports_form($start = NULL, $end = NULL, $statuses = NULL) {
  if (is_null($start)) {
    $start = time();
  }
  if (is_null($end)) {
    $end = time();
  }
  if (is_null($statuses)) {
    $statuses = variable_get('uc_reports_reported_statuses', array(
      'completed',
    ));
  }
  $options = array();
  foreach (uc_order_status_list() as $status) {
    $options[$status['id']] = $status['title'];
  }
  $form['start'] = array(
    '#type' => 'date',
    '#title' => t('Start date'),
    '#default_value' => array(
      'year' => format_date($start, 'custom', 'Y'),
      'month' => format_date($start, 'custom', 'n'),
      'day' => format_date($start, 'custom', 'j'),
    ),
    '#after_build' => array(
      '_uc_coupon_date_range',
    ),
  );
  $form['end'] = array(
    '#type' => 'date',
    '#title' => t('End date'),
    '#default_value' => array(
      'year' => format_date($end, 'custom', 'Y'),
      'month' => format_date($end, 'custom', 'n'),
      'day' => format_date($end, 'custom', 'j'),
    ),
    '#after_build' => array(
      '_uc_coupon_date_range',
    ),
  );
  $form['status'] = array(
    '#type' => 'select',
    '#title' => t('Order statuses'),
    '#description' => t('Only orders with selected statuses will be included in the report.') . '<br />' . t('Hold Ctrl + click to select multiple statuses.'),
    '#options' => $options,
    '#default_value' => $statuses,
    '#multiple' => TRUE,
    '#size' => 5,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Display report'),
  );
  return $form;
}