You are here

public function CustomSalesReport::submitForm in Ubercart 8.4

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

uc_report/src/Form/CustomSalesReport.php, line 123

Class

CustomSalesReport
Generates customized sales reports.

Namespace

Drupal\uc_report\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Build the start and end dates from the form.
  $start_date = mktime(0, 0, 0, $form_state
    ->getValue([
    'start_date',
    'month',
  ]), $form_state
    ->getValue([
    'start_date',
    'day',
  ]), $form_state
    ->getValue([
    'start_date',
    'year',
  ]));
  $end_date = mktime(23, 59, 59, $form_state
    ->getValue([
    'end_date',
    'month',
  ]), $form_state
    ->getValue([
    'end_date',
    'day',
  ]), $form_state
    ->getValue([
    'end_date',
    'year',
  ]));
  $args = [
    'start_date' => $start_date,
    'end_date' => $end_date,
    'length' => $form_state
      ->getValue('length'),
    'status' => implode(',', array_keys(array_filter($form_state
      ->getValue('status')))),
    'detail' => $form_state
      ->getValue('detail'),
  ];
  $form_state
    ->setRedirect('uc_report.custom.sales', $args);
}