• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

contributte / datagrid / 7048127238

30 Nov 2023 02:47PM UTC coverage: 34.081%. First build
7048127238

Pull #1060

github

paveljanda
Minor CSS changes for the next verison of datagrid
Pull Request #1060: [7.x] Next

118 of 431 new or added lines in 54 files covered. (27.38%)

1125 of 3301 relevant lines covered (34.08%)

0.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/DataSource/NetteDatabaseTableMssqlDataSource.php
1
<?php declare(strict_types = 1);
2

3
namespace Contributte\Datagrid\DataSource;
4

5
use Contributte\Datagrid\Exception\DatagridDateTimeHelperException;
6
use Contributte\Datagrid\Filter\FilterDate;
7
use Contributte\Datagrid\Filter\FilterDateRange;
8
use Contributte\Datagrid\Utils\DateTimeHelper;
9

10
class NetteDatabaseTableMssqlDataSource extends NetteDatabaseTableDataSource implements IDataSource
11
{
12

13
        protected function applyFilterDate(FilterDate $filter): void
14
        {
15
                $conditions = $filter->getCondition();
×
16

17
                try {
18
                        $date = DateTimeHelper::tryConvertToDateTime($conditions[$filter->getColumn()], [$filter->getPhpFormat()]);
×
19

20
                        $this->dataSource->where(
×
NEW
21
                                sprintf('CONVERT(varchar(10), %s, 112) = ?', $filter->getColumn()),
×
22
                                $date->format('Ymd')
×
23
                        );
NEW
24
                } catch (DatagridDateTimeHelperException) {
×
25
                        // ignore the invalid filter value
26
                }
27
        }
28

29
        protected function applyFilterDateRange(FilterDateRange $filter): void
30
        {
31
                $conditions = $filter->getCondition();
×
32

33
                $valueFrom = $conditions[$filter->getColumn()]['from'];
×
34
                $valueTo = $conditions[$filter->getColumn()]['to'];
×
35

36
                if ($valueFrom) {
×
37
                        try {
38
                                $dateFrom = DateTimeHelper::tryConvertToDateTime($valueFrom, [$filter->getPhpFormat()]);
×
39
                                $dateFrom->setTime(0, 0, 0);
×
40

41
                                $this->dataSource->where(
×
NEW
42
                                        sprintf('CONVERT(varchar(10), %s, 112) >= ?', $filter->getColumn()),
×
43
                                        $dateFrom->format('Ymd')
×
44
                                );
NEW
45
                        } catch (DatagridDateTimeHelperException) {
×
46
                                // ignore the invalid filter value
47
                        }
48
                }
49

50
                if ($valueTo) {
×
51
                        try {
52
                                $dateTo = DateTimeHelper::tryConvertToDateTime($valueTo, [$filter->getPhpFormat()]);
×
53
                                $dateTo->setTime(23, 59, 59);
×
54

55
                                $this->dataSource->where(
×
NEW
56
                                        sprintf('CONVERT(varchar(10), %s, 112) <= ?', $filter->getColumn()),
×
57
                                        $dateTo->format('Ymd')
×
58
                                );
NEW
59
                        } catch (DatagridDateTimeHelperException) {
×
60
                                // ignore the invalid filter value
61
                        }
62
                }
63
        }
64

65
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc