work_time-1.0.x-dev/modules/fingerprint/src/Form/FingerprintSettingsForm.php
modules/fingerprint/src/Form/FingerprintSettingsForm.php
<?php
namespace Drupal\fingerprint\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
/**
* Configuration form for a work time fingerprint entity type.
*/
class FingerprintSettingsForm extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'fingerprint_settings';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$month = date('Y-m');
$week = date('Y-\WW');
$defaultFilter = 'week';
$form['#attributes']['class'][] = 'row';
$form['type'] = [
'#type' => 'select',
'#title' => $this->t('Type'),
'#default_value' => 'week',
'#options' => [
'week' => $this->t('Week'),
'month' => $this->t('Month'),
],
'#attributes' => [
'class' => ['type-timeline', 'w-auto'],
],
'#wrapper_attributes' => [
'class' => ['container-inline', 'col-auto'],
],
];
$form['date'] = [
'#type' => 'date',
'#title' => $this->t('Filter'),
'#default_value' => $$defaultFilter,
'#attributes' => [
'class' => ['date-timeline', 'w-auto'],
'type' => $defaultFilter,
],
'#wrapper_attributes' => [
'class' => ['container-inline', 'col-auto'],
],
];
$form['timeline'] = [
'#type' => 'container',
'#title' => $this->t('Attendance'),
'#attributes' => [
'class' => ['timeline'],
'id' => 'fingerprint-timeline',
'data-url' => Url::fromRoute('fingerprint.timeline', ['date' => ''])
->toString(),
],
'list' => [],
];
$form['#attached'] = [
'library' => [
'fingerprint/fingerprint',
],
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->messenger()->addStatus($this->t('The configuration has been updated.'));
}
}
