ref: Repositories
* Refactor all files
This commit is contained in:
parent
593958cc68
commit
9887889ecb
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\Case;
|
||||
|
||||
use App\Entity\CaseItinerary;
|
||||
use App\Entity\MemberCase;
|
||||
use App\Entity\User;
|
||||
use App\Entity\UserCase;
|
||||
use App\Entity\Case\CaseItinerary;
|
||||
use App\Entity\Case\MemberCase;;
|
||||
use App\Entity\System\User;
|
||||
use App\Entity\System\UserCase;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
@ -42,7 +42,7 @@ class CaseItineraryRepository extends ServiceEntityRepository
|
||||
}
|
||||
|
||||
$query->orderBy('ci.date', 'DESC')
|
||||
->addOrderBy('ci.arrival', 'DESC');
|
||||
->addOrderBy('ci.departure', 'DESC');
|
||||
|
||||
//dd($query->getQuery());
|
||||
|
||||
@ -60,7 +60,7 @@ class CaseItineraryRepository extends ServiceEntityRepository
|
||||
->andWhere('ci.date >= :from')
|
||||
->setParameter('from', $startDate->format('Y-01-01'))
|
||||
->orderBy('ci.date', 'DESC')
|
||||
->addOrderBy('ci.arrival', 'DESC')
|
||||
->addOrderBy('ci.departure', 'DESC')
|
||||
;
|
||||
|
||||
return $query->getQuery()->getResult();
|
||||
@ -77,7 +77,7 @@ class CaseItineraryRepository extends ServiceEntityRepository
|
||||
->andWhere('ci.date >= :from')
|
||||
->setParameter('from', $startDate->modify('-30 days')->format('Y-m-d'))
|
||||
->orderBy('ci.date', 'DESC')
|
||||
->addOrderBy('ci.arrival', 'DESC')
|
||||
->addOrderBy('ci.departure', 'DESC')
|
||||
;
|
||||
|
||||
return $query->getQuery()->getResult();
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\Case;
|
||||
|
||||
use App\Entity\CaseLocation;
|
||||
use App\Entity\Location;
|
||||
use App\Entity\MemberCase;
|
||||
use App\Entity\Case\CaseLocation;
|
||||
use App\Entity\System\Location;
|
||||
use App\Entity\Case\MemberCase;;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\Case;
|
||||
|
||||
use App\Entity\Company;
|
||||
use App\Entity\MemberCase;
|
||||
use App\Entity\Company\Company;
|
||||
use App\Entity\Case\MemberCase;;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\Case;
|
||||
|
||||
use App\Entity\MemberDocument;
|
||||
use App\Entity\Member;
|
||||
use App\Entity\Case\MemberDocument;
|
||||
use App\Entity\Case\Member;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\Case;
|
||||
|
||||
use App\Entity\Member;
|
||||
use App\Entity\MemberCase;
|
||||
use App\Entity\Case\Member;
|
||||
use App\Entity\Case\MemberCase;;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
43
src/Repository/Case/MonthlyCaseNoteRepository.php
Normal file
43
src/Repository/Case/MonthlyCaseNoteRepository.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository\Case;
|
||||
|
||||
use App\Entity\Case\MonthlyCaseNote;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<MonthlyCaseNote>
|
||||
*/
|
||||
class MonthlyCaseNoteRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, MonthlyCaseNote::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return MonthlyCaseNote[] Returns an array of MonthlyCaseNote objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('m')
|
||||
// ->andWhere('m.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('m.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?MonthlyCaseNote
|
||||
// {
|
||||
// return $this->createQueryBuilder('m')
|
||||
// ->andWhere('m.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\Case;
|
||||
|
||||
use App\Entity\Note;
|
||||
use App\Entity\Referral;
|
||||
use App\Entity\Case\Note;
|
||||
use App\Entity\Case\Referral;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\Case;
|
||||
|
||||
use App\Entity\MemberCase;
|
||||
use App\Entity\Referral;
|
||||
use App\Enums\ReferralServiceType;
|
||||
use App\Entity\Case\MemberCase;;
|
||||
use App\Entity\Case\Referral;
|
||||
use App\Enums\Case\ReferralServiceType;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
@ -57,10 +57,10 @@ class ReferralRepository extends ServiceEntityRepository
|
||||
|
||||
public function populateNotes(Referral &$referral): void
|
||||
{
|
||||
$noteType = 'App\Entity\StandardNote';
|
||||
$noteType = 'App\Entity\Case\StandardNote';
|
||||
|
||||
if ($referral->getServiceCode() == ReferralServiceType::VS_THBB) {
|
||||
$noteType = 'App\Entity\VisitNote';
|
||||
$noteType = 'App\Entity\Case\VisitNote';
|
||||
}
|
||||
|
||||
$query = $this->getEntityManager()->createQuery("
|
||||
@ -74,8 +74,6 @@ class ReferralRepository extends ServiceEntityRepository
|
||||
if (!count($res)){
|
||||
return;
|
||||
}
|
||||
|
||||
$referral->setNotes(new ArrayCollection($res));
|
||||
}
|
||||
|
||||
// /**
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\Case;
|
||||
|
||||
use App\Entity\StandardNoteMember;
|
||||
use App\Entity\Case\StandardNoteMember;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
@ -1,11 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\Case;
|
||||
|
||||
use App\Entity\Referral;
|
||||
use App\Entity\StandardNote;
|
||||
use App\Entity\User;
|
||||
use App\Entity\UserCase;
|
||||
use App\Entity\Case\Referral;
|
||||
use App\Entity\Case\StandardNote;
|
||||
use App\Entity\System\User;
|
||||
use App\Entity\System\UserCase;
|
||||
use App\Enums\Case\ReferralType;
|
||||
use DateTime;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
@ -69,6 +71,36 @@ class StandardNoteRepository extends ServiceEntityRepository
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to return the total time billed
|
||||
*
|
||||
* @param User $user
|
||||
* @param DateTime $startDate
|
||||
*
|
||||
* @return int
|
||||
* Total minutes rounded to the nearest 15 min increment
|
||||
*/
|
||||
public function getTotalBillableHours(User $user, DateTime $startDate, ReferralType $referralType = null): array
|
||||
{
|
||||
$res = $this->createQueryBuilder('s')
|
||||
->leftJoin(Referral::class, 'r', 'WITH', 'r.id = s.referral')
|
||||
->leftJoin(UserCase::class, 'uc', 'WITH', 'uc.memberCase = r.memberCase')
|
||||
->where('uc.user = :user')
|
||||
->andWhere('s.date >= :startDate')
|
||||
->setParameter('user', $user->getId()->toBinary())
|
||||
->setParameter('startDate', $startDate->format('Y-m-d'))
|
||||
;
|
||||
|
||||
if (null !== $referralType) {
|
||||
$res->andWhere('r.serviceCode = :referralType')
|
||||
->setParameter('referralType', $referralType);
|
||||
}
|
||||
|
||||
$ret = $res->getQuery()->getResult();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return StandardNote[] Returns an array of StandardNote objects
|
||||
// */
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\Case;
|
||||
|
||||
use App\Entity\VisitNoteMembers;
|
||||
use App\Entity\Case\VisitNoteMembers;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\Case;
|
||||
|
||||
use App\Entity\Referral;
|
||||
use App\Entity\UserCase;
|
||||
use App\Entity\User;
|
||||
use App\Entity\VisitNote;
|
||||
use App\Entity\VisitNoteMembers;
|
||||
use DateTimeImmutable;
|
||||
use App\Entity\Case\Referral;
|
||||
use App\Entity\System\UserCase;
|
||||
use App\Entity\System\User;
|
||||
use App\Entity\Case\VisitNote;
|
||||
use App\Enums\Case\ReferralType;
|
||||
use DateTime;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
@ -69,6 +69,36 @@ class VisitNoteRepository extends ServiceEntityRepository
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to return the total time billed
|
||||
*
|
||||
* @param User $user
|
||||
* @param DateTime $startDate
|
||||
*
|
||||
* @return int
|
||||
* Total minutes rounded to the nearest 15 min increment
|
||||
*/
|
||||
public function getTotalBillableHours(User $user, DateTime $startDate, ReferralType $referralType = null): array
|
||||
{
|
||||
$res = $this->createQueryBuilder('v')
|
||||
->leftJoin(Referral::class, 'r', 'WITH', 'r.id = v.referral')
|
||||
->leftJoin(UserCase::class, 'uc', 'WITH', 'uc.memberCase = r.memberCase')
|
||||
->where('uc.user = :user')
|
||||
->andWhere('v.date >= :startDate')
|
||||
->setParameter('user', $user->getId()->toBinary())
|
||||
->setParameter('startDate', $startDate->format('Y-m-d'))
|
||||
;
|
||||
|
||||
if (null !== $referralType) {
|
||||
$res->andWhere('r.serviceCode = :referralType')
|
||||
->setParameter('referralType', $referralType);
|
||||
}
|
||||
|
||||
$ret = $res->getQuery()->getResult();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return VisitNote[] Returns an array of VisitNote objects
|
||||
// */
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\Company;
|
||||
|
||||
use App\Entity\CompanyDocument;
|
||||
use App\Entity\Company\CompanyDocument;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\Company;
|
||||
|
||||
use App\Entity\Company;
|
||||
use App\Entity\Company\Company;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\Resources;
|
||||
|
||||
use App\Entity\CommunityResource;
|
||||
use App\Entity\Resources\CommunityResource;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\Staff;
|
||||
|
||||
use App\Entity\MemberCase;
|
||||
use App\Entity\StaffNote;
|
||||
use App\Entity\Case\MemberCase;;
|
||||
use App\Entity\Staff\StaffNote;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\Staff;
|
||||
|
||||
use App\Entity\Supervision;
|
||||
use App\Entity\User;
|
||||
use App\Entity\Staff\Supervision;
|
||||
use App\Entity\System\User;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\System;
|
||||
|
||||
use App\Entity\CaseLocation;
|
||||
use App\Entity\Location;
|
||||
use App\Entity\MemberCase;
|
||||
use App\Entity\User;
|
||||
use App\Entity\UserCase;
|
||||
use App\Entity\Case\CaseLocation;
|
||||
use App\Entity\System\Location;
|
||||
use App\Entity\Case\MemberCase;;
|
||||
use App\Entity\System\User;
|
||||
use App\Entity\System\UserCase;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\System;
|
||||
|
||||
use App\Entity\Messages;
|
||||
use App\Entity\User;
|
||||
use App\Entity\System\Messages;
|
||||
use App\Entity\System\User;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\System;
|
||||
|
||||
use App\Entity\ReferralSource;
|
||||
use App\Entity\System\ReferralSource;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
43
src/Repository/System/SubscriptionRepository.php
Normal file
43
src/Repository/System/SubscriptionRepository.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository\System;
|
||||
|
||||
use App\Entity\System\Subscription;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Subscription>
|
||||
*/
|
||||
class SubscriptionRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Subscription::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Subscription[] Returns an array of Subscription objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('s')
|
||||
// ->andWhere('s.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('s.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?Subscription
|
||||
// {
|
||||
// return $this->createQueryBuilder('s')
|
||||
// ->andWhere('s.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\System;
|
||||
|
||||
use App\Entity\UserCase;
|
||||
use App\Entity\System\UserCase;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Repository\System;
|
||||
|
||||
use App\Entity\Company;
|
||||
use App\Entity\User;
|
||||
use App\Entity\Company\Company;
|
||||
use App\Entity\System\User;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
Loading…
Reference in New Issue
Block a user