src/Repository/PositionGpsRepository.php line 100

Open in your IDE?
  1. <?php
  2. namespace App\Repository;
  3. use Doctrine\ORM\Query\ResultSetMapping;
  4. /**
  5. * ActionFormationRepository
  6. *
  7. * This class was generated by the Doctrine ORM. Add your own custom
  8. * repository methods below.
  9. */
  10. class PositionGpsRepository extends \Doctrine\ORM\EntityRepository
  11. {
  12. public function findPositionByDate($date, $user = null)
  13. {
  14. $em = $this->getEntityManager();
  15. $data = [];
  16. $where = " ";
  17. $tabParameter = [];
  18. $dql = 'SELECT position FROM App:PositionGps position
  19. WHERE position.dateCreatedByServer LIKE :dateServer
  20. AND position.user = :user
  21. ';
  22. $query = $em->createQuery($dql);
  23. $query->setParameter("dateServer", "%{$date}%");
  24. $query->setParameter("user", $user);
  25. $data = $query->getResult();
  26. return $data;
  27. }
  28. public function findPositionByTwoDate($dateStart, $dateEnd, $user = null)
  29. {
  30. $em = $this->getEntityManager();
  31. $data = [];
  32. $where = " ";
  33. $tabParameter = [];
  34. $dql = 'UPDATE App:PositionGps position
  35. SET position.sync = 1
  36. WHERE position.datePrinted BETWEEN :dateStart AND :dateEnd
  37. AND position.user = :user
  38. ';
  39. $query = $em->createQuery($dql);
  40. $query->setParameter("dateStart", $dateStart);
  41. $query->setParameter("dateEnd", $dateEnd);
  42. $query->setParameter("user", $user);
  43. $data = $query->getResult();
  44. return $data;
  45. }
  46. public function findPositionNext($sync, $user = null, $activityConfidence, $idPosition, $nextStillId, $accuracy, $numberLimit)
  47. {
  48. $em = $this->getEntityManager();
  49. $data = [];
  50. $where = " ";
  51. $tabParameter = [];
  52. //array('datePrinted' => 'ASC', 'dateCreatedByServer' => 'ASC')
  53. $dql = 'SELECT position FROM App:PositionGps position
  54. WHERE position.sync LIKE :sync
  55. AND position.user = :user
  56. AND position.activityConfidence = :activityConfidence
  57. AND position.id > :idPosition
  58. AND position.id < :idPositionNext
  59. AND position.accuracy < :accuracy
  60. AND position.activityType != :activityType
  61. ORDER BY position.datePrinted ASC, position.dateCreatedByServer ASC
  62. ';
  63. $query = $em->createQuery($dql);
  64. $query->setParameter("sync", $sync);
  65. $query->setParameter("user", $user);
  66. $query->setParameter("activityConfidence", $activityConfidence);
  67. $query->setParameter("idPosition", $idPosition);
  68. $query->setParameter("idPositionNext", $nextStillId);
  69. $query->setParameter("accuracy", $accuracy);
  70. $query->setParameter("activityType", "still");
  71. //->add('orderBy', 'u.name ASC')
  72. $query->setMaxResults($numberLimit);
  73. $data = $query->getResult();
  74. return $data;
  75. }
  76. public function findOnePositionNext($sync, $user = null, $idPosition, $accuracy)
  77. {
  78. $em = $this->getEntityManager();
  79. $data = [];
  80. $where = " ";
  81. $tabParameter = [];
  82. //array('datePrinted' => 'ASC', 'dateCreatedByServer' => 'ASC')
  83. $dql = 'SELECT position FROM App:PositionGps position
  84. WHERE position.sync LIKE :sync
  85. AND position.user = :user
  86. AND position.id > :idPosition
  87. AND position.accuracy < :accuracy
  88. ORDER BY position.datePrinted ASC, position.dateCreatedByServer ASC
  89. ';
  90. $query = $em->createQuery($dql);
  91. $query->setParameter("sync", $sync);
  92. $query->setParameter("user", $user);
  93. $query->setParameter("idPosition", $idPosition);
  94. $query->setParameter("accuracy", $accuracy);
  95. //->add('orderBy', 'u.name ASC')
  96. $query->setMaxResults(1);
  97. $data = $query->getResult();
  98. return $data;
  99. }
  100. }