Search update and optimization

This commit is contained in:
2023-11-23 23:35:19 -03:00
parent bf03e85975
commit e1ef31dccd
10 changed files with 232 additions and 36 deletions

View File

@ -1,6 +1,7 @@
<?php
namespace Incoviba\Repository\Venta;
use PDO;
use Incoviba\Common\Ideal;
use Incoviba\Common\Define;
use Incoviba\Common\Implement;
@ -117,6 +118,20 @@ class Unidad extends Ideal\Repository
->where("a.`descripcion` LIKE ? AND tu.`descripcion` = ? AND (pu.`id` IS NULL OR `venta`.`id` IS NULL OR tev.`activa` = 0)");
return $this->fetchMany($query, [$descripcion, $tipo]);
}
public function fetchDisponiblesIdsByDescripcionAndTipo(string $descripcion, string $tipo): array
{
$query = $this->connection->getQueryBuilder()
->select('a.id')
->from("{$this->getTable()} a")
->joined("JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = a.`pt`
JOIN `tipo_unidad` tu ON tu.`id` = ptu.`tipo`
LEFT OUTER JOIN `propiedad_unidad` pu ON pu.`unidad` = a.`id`
LEFT OUTER JOIN `venta` ON `venta`.`propiedad` = pu.`propiedad`
LEFT OUTER JOIN (SELECT ev1.* FROM `estado_venta` ev1 JOIN (SELECT MAX(`id`) as 'id', `venta` FROM `estado_venta`) ev0 ON ev0.`id` = ev1.`id`) ev ON ev.`venta` = `venta`.`id`
LEFT OUTER JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado`")
->where("a.`descripcion` LIKE ? AND tu.`descripcion` = ? AND (pu.`id` IS NULL OR `venta`.`id` IS NULL OR tev.`activa` = 0)");
return $this->connection->execute($query, [$descripcion, $tipo])->fetchAll(PDO::FETCH_ASSOC);
}
protected function joinProrrateo(): string
{