-
Notifications
You must be signed in to change notification settings - Fork 11
/
DateRange.php
72 lines (59 loc) · 2.14 KB
/
DateRange.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
namespace PedroTeixeira\Bundle\GridBundle\Grid\Filter;
/**
* Filter DateRange
*/
class DateRange extends Date
{
/**
* @var string
*/
protected $operatorType = 'date_range';
/**
* @var string
*/
protected $inputSeparator = ' : ';
/**
* @return string
*/
public function render()
{
if ($this->getUseDatePicker()) {
$html = '<input class="date-input" name="' . $this->getIndex() . '[]" id="' . $this->getId() .
'from" type="text" value="' . $this->getValue() .
'" placeholder="' . $this->getPlaceholder() .
'" data-date-format="' . strtolower($this->dateFormat) . '">';
$html .= $this->getInputSeparator();
$html .= '<input class="date-input" name="' . $this->getIndex() . '[]" id="' . $this->getId() .
'to" type="text" value="' . $this->getValue() .
'" placeholder="' . $this->getPlaceholder() .
'" data-date-format="' . strtolower($this->dateFormat) . '">';
$html .= '<script type="text/javascript">$(document).ready(function () {$("#' .
$this->getId() . 'from").datepicker(); $("#' . $this->getId() . 'to").datepicker()})</script>';
} else {
$html = '<input class="date-input" name="' . $this->getIndex() . '[]" id="' . $this->getId() .
'from" type="date" placeholder="' . $this->getPlaceholder() . '" value="' . $this->getValue() . '"> ';
$html .= $this->getInputSeparator();
$html .= '<input class="date-input" name="' . $this->getIndex() . '[]" id="' . $this->getId() .
'to" type="date" placeholder="' . $this->getPlaceholder() . '" value="' . $this->getValue() . '">';
}
return $html;
}
/**
* @param string $inputSeparator
*
* @return DateRange
*/
public function setInputSeparator($inputSeparator)
{
$this->inputSeparator = $inputSeparator;
return $this;
}
/**
* @return string
*/
public function getInputSeparator()
{
return $this->inputSeparator;
}
}