feat: show due documents on teamer dashboard
This commit is contained in:
@@ -45,6 +45,12 @@ class IndexController extends AbstractController
|
||||
->getPendingForTeamer($teamer)
|
||||
;
|
||||
|
||||
$currentDispositions = $this
|
||||
->entityManager
|
||||
->getRepository(Disposition::class)
|
||||
->findCurrentDispositionsByTeamer($teamer)
|
||||
;
|
||||
|
||||
$upcomingDispositions = $this
|
||||
->entityManager
|
||||
->getRepository(Disposition::class)
|
||||
@@ -55,6 +61,7 @@ class IndexController extends AbstractController
|
||||
'matchingAssignments' => $matchingAssignments,
|
||||
'recentFeedback' => $recentFeedback,
|
||||
'pendingApplications' => $pendingApplications,
|
||||
'currentDispositions' => $currentDispositions,
|
||||
'upcomingDispositions' => $upcomingDispositions,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ use App\Entity\Traits\BlameableEntity;
|
||||
use App\Entity\Traits\SoftDeletableEntity;
|
||||
use App\Entity\Traits\TimestampableEntity;
|
||||
use App\Repository\DispositionRepository;
|
||||
use Carbon\Carbon;
|
||||
use Carbon\CarbonPeriod;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
@@ -187,4 +189,34 @@ class Disposition implements BlameableEntityInterface, TimestampableEntityInterf
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isContractDue(): bool
|
||||
{
|
||||
if (null !== $this->getDocumentByType(Upload::TYPE_CONTRACT)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$assignment = $this->getAssignment();
|
||||
$assignmentPeriod = $assignment->getEffectivePeriod();
|
||||
$dueDateFrom = $this->getCreatedAt()->modify('+ 7days');
|
||||
$dueDateTo = $assignmentPeriod->end->modify('-1 day');
|
||||
|
||||
$period = CarbonPeriod::create($dueDateFrom, $dueDateTo);
|
||||
|
||||
return $period->isStarted();
|
||||
}
|
||||
|
||||
public function isInvoiceDue(): bool
|
||||
{
|
||||
if (null !== $this->getDocumentByType(Upload::TYPE_INVOICE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$assignment = $this->getAssignment();
|
||||
$assignmentPeriod = $assignment->getEffectivePeriod();
|
||||
|
||||
$period = CarbonPeriod::create($assignmentPeriod->getEndDate(), $assignmentPeriod->getEndDate()->modify('+14 days'));
|
||||
|
||||
return $period->isStarted();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,6 +124,29 @@ class DispositionRepository extends ServiceEntityRepository
|
||||
;
|
||||
}
|
||||
|
||||
public function findCurrentDispositionsByTeamer(Teamer $teamer): array
|
||||
{
|
||||
$qb = $this->createQueryBuilder('disposition');
|
||||
|
||||
return $qb
|
||||
->select('disposition', 'assignment', 'destination')
|
||||
->innerJoin('disposition.assignment', 'assignment')
|
||||
->innerJoin('assignment.destination', 'destination')
|
||||
->where($qb->expr()->andX(
|
||||
$qb->expr()->eq('disposition.teamer', ':teamer'),
|
||||
$qb->expr()->in('disposition.status', ':status')
|
||||
))
|
||||
->setParameter('teamer', $teamer)
|
||||
->setParameter('status', [
|
||||
Disposition::STATUS_NEW,
|
||||
Disposition::STATUS_CONFIRMED,
|
||||
])
|
||||
->orderBy('destination.dateFrom', 'ASC')
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
|
||||
public function findNewDispositionsByHotelBusProIds(array $hotelBusProIds): array
|
||||
{
|
||||
$qb = $this->createQueryBuilder('disposition');
|
||||
|
||||
Reference in New Issue
Block a user