Files
ventas_php/classes/atributoValor.class.php
nickpons666 ccfa01fa0e feat(atributos): Mejora la funcionalidad de la página de atributos
- Deshabilita la paginación para mostrar todos los atributos por defecto.
- Corrige un error de renderizado en 'atributos-valores.tpl' añadiendo etiquetas de cierre faltantes.
- Cambia el orden de los atributos a 'atributoId' en 'atributo.class.php'.
- Corrige un bug en 'atributoValor.class.php' descomentando una condición.
- Asegura que las acciones AJAX (añadir, editar, eliminar) refresquen la lista correctamente sin paginación.
2026-01-08 01:06:11 -06:00

176 lines
4.1 KiB
PHP
Executable File

<?php
class AtributoValor extends Main
{
private $atribValId;
private $atributoId;
private $nombre;
public function setAtribValId($value)
{
$this->Util()->ValidateInteger($value);
$this->atribValId = $value;
}
public function setAtributoId($value)
{
$this->Util()->ValidateInteger($value);
$this->atributoId = $value;
}
public function setNombre($value)
{
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Nombre');
$this->nombre = $value;
}
public function Info()
{
$sql = 'SELECT
*
FROM
atributoValor
WHERE
atribValId = "'.$this->atribValId.'"';
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$info = $this->Util()->DBSelect($_SESSION['empresaId'])->GetRow();
return $info;
}
public function EnumerateAll()
{
$sql = 'SELECT
*
FROM
atributoValor
WHERE
baja = "0" AND
atributoId = "'.$this->atributoId.'"
ORDER BY
nombre ASC';
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
return $result;
}
function Enumerate()
{
$sql = 'SELECT COUNT(*) FROM atributoValor
WHERE baja = "0"
AND atributoId = "'.$this->atributoId.'"';
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT.'/atributos-valores');
$sqlAdd = 'LIMIT '.$pages['start'].', '.$pages['items_per_page'];
$sql = 'SELECT * FROM atributoValor
WHERE baja = "0"
AND atributoId = "'.$this->atributoId.'"
ORDER BY nombre ASC '.$sqlAdd;
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
$data['items'] = $result;
$data['pages'] = $pages;
return $data;
}
function Save()
{
if($this->Util()->PrintErrors()){ return false; }
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery('
INSERT INTO `atributoValor` (
atributoId,
nombre
)
VALUES (
"'.$this->atributoId.'",
"'.utf8_decode($this->nombre).'"
)'
);
$atribValId = $this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
$this->Util()->setError(30042, 'complete');
$this->Util()->PrintErrors();
return $atribValId;
}
function Update()
{
if($this->Util()->PrintErrors()){ return false; }
$sql = '
UPDATE `atributoValor` SET
`nombre` = "'.utf8_decode($this->nombre).'"
WHERE atribValId = "'.$this->atribValId.'"
';
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
$this->Util()->setError(30043, 'complete');
$this->Util()->PrintErrors();
return true;
}
function Delete()
{
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery('
DELETE FROM atributoValor
WHERE atribValId = "'.$this->atribValId.'"'
);
$this->Util()->DBSelect($_SESSION['empresaId'])->DeleteData();
$this->Util()->setError(30043, 'complete');
$this->Util()->PrintErrors();
return true;
}
function Baja(){
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
UPDATE atributoValor SET baja = '1'
WHERE atribValId = '".$this->atribValId."'"
);
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
$this->Util()->setError(30041, "complete");
$this->Util()->PrintErrors();
return true;
}//Baja
function GetNameById()
{
$sql = 'SELECT nombre FROM atributoValor
WHERE atribValId = "'.$this->atribValId.'"';
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$nombre = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
return $nombre;
}
function ExistValor()
{
$sql = 'SELECT atribValId FROM atributoValor
WHERE atributoId = "'.$this->atributoId.'"
AND nombre = "'.$this->nombre.'"
LIMIT 1';
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$atribValId = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
return $atribValId;
}
}
?>