|
|
|
@ -92,18 +92,57 @@ class Reservation extends Common\Ideal\Repository
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param int $buyer_rut
|
|
|
|
|
* @param int $unit_id
|
|
|
|
|
* @param DateTimeInterface $date
|
|
|
|
|
* @return Model\Venta\Reservation
|
|
|
|
|
* @throws Common\Implement\Exception\EmptyResult
|
|
|
|
|
* @throws EmptyResult
|
|
|
|
|
*/
|
|
|
|
|
public function fetchByBuyerAndDate(int $buyer_rut, DateTimeInterface $date): Model\Venta\Reservation
|
|
|
|
|
public function fetchByBuyerAndUnitAndDate(int $buyer_rut, int $unit_id, DateTimeInterface $date): Model\Venta\Reservation
|
|
|
|
|
{
|
|
|
|
|
$query = $this->connection->getQueryBuilder()
|
|
|
|
|
->select('a.*')
|
|
|
|
|
->from('reservations a')
|
|
|
|
|
->joined('INNER JOIN reservation_details rd ON a.id = rd.reservation_id')
|
|
|
|
|
->where('a.buyer_rut = :buyer_rut AND rd.unit_id = :unit_id AND a.date >= :date');
|
|
|
|
|
return $this->fetchOne($query, ['buyer_rut' => $buyer_rut, 'unit_id' => $unit_id, 'date' => $date->sub(new DateInterval('P10D'))->format('Y-m-d')]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param int $buyer_rut
|
|
|
|
|
* @param int $project_id
|
|
|
|
|
* @param DateTimeInterface $date
|
|
|
|
|
* @return array
|
|
|
|
|
* @throws EmptyResult
|
|
|
|
|
*/
|
|
|
|
|
public function fetchByBuyerAndProjectAndDate(int $buyer_rut, int $project_id, DateTimeInterface $date): array
|
|
|
|
|
{
|
|
|
|
|
$query = $this->connection->getQueryBuilder()
|
|
|
|
|
->select()
|
|
|
|
|
->from('reservations')
|
|
|
|
|
->where('buyer_rut = :buyer_rut AND project_id = :project_id AND date >= :date');
|
|
|
|
|
return $this->fetchMany($query, ['buyer_rut' => $buyer_rut, 'project_id' => $project_id, 'date' => $date->sub(new DateInterval('P10D'))->format('Y-m-d')]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param int $buyer_rut
|
|
|
|
|
* @param DateTimeInterface $date
|
|
|
|
|
* @return array
|
|
|
|
|
* @throws EmptyResult
|
|
|
|
|
*/
|
|
|
|
|
public function fetchByBuyerAndDate(int $buyer_rut, DateTimeInterface $date): array
|
|
|
|
|
{
|
|
|
|
|
$query = $this->connection->getQueryBuilder()
|
|
|
|
|
->select()
|
|
|
|
|
->from('reservations')
|
|
|
|
|
->where('buyer_rut = :buyer_rut AND date >= :date');
|
|
|
|
|
return $this->fetchOne($query, ['buyer_rut' => $buyer_rut, 'date' => $date->sub(new DateInterval('P10D'))->format('Y-m-d')]);
|
|
|
|
|
return $this->fetchMany($query, ['buyer_rut' => $buyer_rut, 'date' => $date->sub(new DateInterval('P10D'))->format('Y-m-d')]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param int $project_id
|
|
|
|
|
* @return array
|
|
|
|
|
* @throws EmptyResult
|
|
|
|
|
*/
|
|
|
|
|
public function fetchByProject(int $project_id): array
|
|
|
|
|
{
|
|
|
|
|
$query = $this->connection->getQueryBuilder()
|
|
|
|
@ -145,6 +184,7 @@ class Reservation extends Common\Ideal\Repository
|
|
|
|
|
return $this->fetchMany($query, ['project_id' => $project_id,
|
|
|
|
|
'state' => $state]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param int $project_id
|
|
|
|
|
* @return array
|
|
|
|
|