Fix incorrect calculation of availability
This commit is contained in:
@@ -43,7 +43,7 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa
|
|||||||
* @return \CalendR\Event\EventInterface[]
|
* @return \CalendR\Event\EventInterface[]
|
||||||
* @throws \Doctrine\DBAL\DBALException
|
* @throws \Doctrine\DBAL\DBALException
|
||||||
*/
|
*/
|
||||||
public function getEvents(\DateTime $dateFrom, \DateTime $dateTo, array $options = [])
|
public function getEvents(\DateTime $dateFrom, \DateTime $dateTo = null, array $options = [])
|
||||||
{
|
{
|
||||||
$optionsResolver = new OptionsResolver();
|
$optionsResolver = new OptionsResolver();
|
||||||
$optionsResolver->setDefined(['hotel']);
|
$optionsResolver->setDefined(['hotel']);
|
||||||
@@ -71,11 +71,16 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa
|
|||||||
|
|
||||||
$qb
|
$qb
|
||||||
->andWhere('date >= :dateFrom')
|
->andWhere('date >= :dateFrom')
|
||||||
->andWhere('date <= :dateTo')
|
|
||||||
->setParameter('dateFrom', $dateFrom->format('Y-m-d'))
|
->setParameter('dateFrom', $dateFrom->format('Y-m-d'))
|
||||||
->setParameter('dateTo', $dateTo->format('Y-m-d'))
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
if (null !== $dateTo) {
|
||||||
|
$qb
|
||||||
|
->andWhere('date <= :dateTo')
|
||||||
|
->setParameter('dateTo', $dateTo->format('Y-m-d'))
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
$result = $qb->execute()->fetchAll();
|
$result = $qb->execute()->fetchAll();
|
||||||
|
|
||||||
$dates = [];
|
$dates = [];
|
||||||
|
|||||||
@@ -229,6 +229,7 @@ class ContingentImportService implements SingletonInterface, LoggerAwareInterfac
|
|||||||
$roomType = $roomTypes[$roomTypeBusProId];
|
$roomType = $roomTypes[$roomTypeBusProId];
|
||||||
$roomCode = $roomType['code'];
|
$roomCode = $roomType['code'];
|
||||||
$availablePax = 0;
|
$availablePax = 0;
|
||||||
|
$capacity = 0;
|
||||||
if ($roomType['ctrl'] === true) {
|
if ($roomType['ctrl'] === true) {
|
||||||
if ((string) $xmlRoom['status'] === 'A') {
|
if ((string) $xmlRoom['status'] === 'A') {
|
||||||
$status = Contingent::STATUS_ONREQUEST;
|
$status = Contingent::STATUS_ONREQUEST;
|
||||||
|
|||||||
@@ -60,11 +60,11 @@ class IcalService implements SingletonInterface
|
|||||||
*/
|
*/
|
||||||
public function createContingentsFeed(Hotel $hotel): string
|
public function createContingentsFeed(Hotel $hotel): string
|
||||||
{
|
{
|
||||||
$range = Period::after(new \DateTime('now'), '1 year');
|
$now = new \DateTime('now');
|
||||||
try {
|
try {
|
||||||
$events = $this->contingentRepository->getEvents(
|
$events = $this->contingentRepository->getEvents(
|
||||||
\DateTime::createFromImmutable($range->getStartDate()),
|
$now,
|
||||||
\DateTime::createFromImmutable($range->getEndDate()),
|
null,
|
||||||
['hotel' => $hotel]
|
['hotel' => $hotel]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user