Search
This commit is contained in:
@ -52,10 +52,10 @@ class Propietario extends Ideal\Repository
|
||||
}))
|
||||
->register('otro', (new Implement\Repository\Mapper())
|
||||
->setFunction(function($data) {
|
||||
if ($data['otro'] === null or $data['otro'] === 0) {
|
||||
if ($data['otro'] === null) {
|
||||
return null;
|
||||
}
|
||||
return $this->fetchById($data['otro']);
|
||||
return $data['otro'] !== 0;
|
||||
})
|
||||
->setDefault(null));
|
||||
return $this->parseData(new Model\Venta\Propietario(), $data, $map);
|
||||
|
@ -15,7 +15,7 @@ class Unidad extends Ideal\Repository
|
||||
$this->setTable('unidad');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Define\Model
|
||||
public function create(?array $data = null): Model\Venta\Unidad
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser(['subtipo', 'piso', 'descripcion', 'orientacion']))
|
||||
->register('pt', (new Implement\Repository\Mapper())
|
||||
@ -25,7 +25,7 @@ class Unidad extends Ideal\Repository
|
||||
}));
|
||||
return $this->parseData(new Model\Venta\Unidad(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Define\Model
|
||||
public function save(Define\Model $model): Model\Venta\Unidad
|
||||
{
|
||||
$model->id = $this->saveNew(
|
||||
['subtipo', 'piso', 'descripcion', 'orientacion', 'pt'],
|
||||
@ -33,7 +33,7 @@ class Unidad extends Ideal\Repository
|
||||
);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Define\Model $model, array $new_data): Define\Model
|
||||
public function edit(Define\Model $model, array $new_data): Model\Venta\Unidad
|
||||
{
|
||||
return $this->update($model, ['subtipo', 'piso', 'descripcion', 'orientacion', 'pt'], $new_data);
|
||||
}
|
||||
@ -83,4 +83,17 @@ WHERE ptu.`proyecto` = ? AND (pu.`id` IS NULL OR `venta`.`id` IS NULL OR tev.`ac
|
||||
ORDER BY tu.`orden`";
|
||||
return $this->fetchMany($query, [$proyecto_id]);
|
||||
}
|
||||
public function fetchDisponiblesByDescripcionAndTipo(string $descripcion, string $tipo): array
|
||||
{
|
||||
$query = "SELECT DISTINCT a.*
|
||||
FROM `{$this->getTable()}` a
|
||||
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->fetchMany($query, [$descripcion, $tipo]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user