You are here

function commerce_reports_tax_table_form in Commerce Reporting 7.3

1 string reference to 'commerce_reports_tax_table_form'
commerce_reports_tax_menu in modules/tax/commerce_reports_tax.module
Implements hook_menu().

File

modules/tax/commerce_reports_tax.admin.inc, line 66
Administrative forms.

Code

function commerce_reports_tax_table_form($form, &$form_state) {
  $form['start'] = array(
    '#type' => 'date',
    '#title' => t('Start date'),
    '#default_value' => array(
      'day' => format_date(REQUEST_TIME, 'custom', 'j'),
      'month' => format_date(REQUEST_TIME, 'custom', 'n'),
      'year' => format_date(REQUEST_TIME, 'custom', 'Y') - 1,
    ),
    '#required' => TRUE,
  );
  $form['end'] = array(
    '#type' => 'date',
    '#title' => t('End date'),
    '#default_value' => array(
      'day' => format_date(REQUEST_TIME, 'custom', 'j'),
      'month' => format_date(REQUEST_TIME, 'custom', 'n'),
      'year' => format_date(REQUEST_TIME, 'custom', 'Y'),
    ),
    '#required' => TRUE,
  );
  $form['refresh'] = array(
    '#type' => 'submit',
    '#value' => t('Refresh'),
  );
  if (empty($form_state['input'])) {
    $start = 0;
    $end = REQUEST_TIME;
  }
  else {
    $start = $form_state['input']['start'];
    $start = mktime(0, 0, 0, $start['month'], $start['day'], $start['year']);
    $end = $form_state['input']['end'];
    $end = mktime(0, 0, 0, $end['month'], $end['day'], $end['year']);
  }
  $tax_table = commerce_reports_tax_table($start, $end);
  $form['taxes'] = array(
    '#markup' => drupal_render($tax_table),
  );
  return $form;
}