Commit 4f3477ad by Damien Moulard

for operations list, filter only on date instead of datetime

parent b3184aff
...@@ -6,7 +6,7 @@ use App\Enum\MoyenEnum; ...@@ -6,7 +6,7 @@ use App\Enum\MoyenEnum;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType; use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpFoundation\Session\SessionInterface;
...@@ -40,13 +40,13 @@ class ListOperationFormType extends AbstractType ...@@ -40,13 +40,13 @@ class ListOperationFormType extends AbstractType
return MoyenEnum::getTypeName($choice); return MoyenEnum::getTypeName($choice);
}, },
]) ])
->add('datemin', DateTimeType::class, [ ->add('datemin', DateType::class, [
'label' => 'Date min', 'label' => 'Date min',
'required' => false, 'required' => false,
'widget' => 'single_text', 'widget' => 'single_text',
// 'data' => new \DateTime('first day of this month') // 'data' => new \DateTime('first day of this month')
]) ])
->add('datemax', DateTimeType::class, [ ->add('datemax', DateType::class, [
'label' => 'Date max', 'label' => 'Date max',
'required' => false, 'required' => false,
'widget' => 'single_text', 'widget' => 'single_text',
......
...@@ -60,13 +60,13 @@ class OperationUtils ...@@ -60,13 +60,13 @@ class OperationUtils
if (!empty($request->get('formListOperations')['datemin'])) { if (!empty($request->get('formListOperations')['datemin'])) {
$qb $qb
->andWhere('a.createdAt >= :datemin') ->andWhere('a.createdAt >= :datemin')
->setParameter('datemin', $request->get('formListOperations')['datemin'] . ' 00:00:00') ->setParameter('datemin', $request->get('formListOperations')['datemin']) // Date only comparison: error in queries comparing datetimes with some MYSQL versions
; ;
} }
if (!empty($request->get('formListOperations')['datemax'])) { if (!empty($request->get('formListOperations')['datemax'])) {
$qb $qb
->andWhere('a.createdAt <= :datemax') ->andWhere('a.createdAt <= :datemax')
->setParameter('datemax', $request->get('formListOperations')['datemax'] . ' 23:59:59') ->setParameter('datemax', $request->get('formListOperations')['datemax'])
; ;
} }
if (!empty($request->get('formListOperations')['moyen'])) { if (!empty($request->get('formListOperations')['moyen'])) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment