137 lines
3.0 KiB
PHP
Executable File
137 lines
3.0 KiB
PHP
Executable File
<?php
|
|
|
|
class Talla extends Main
|
|
{
|
|
private $tallaId;
|
|
private $nombre;
|
|
|
|
public function setTallaId($value)
|
|
{
|
|
$this->Util()->ValidateInteger($value);
|
|
$this->tallaId = $value;
|
|
}
|
|
|
|
public function setNombre($value)
|
|
{
|
|
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, "Nombre");
|
|
$this->nombre = $value;
|
|
}
|
|
|
|
public function Info()
|
|
{
|
|
|
|
$sql = 'SELECT
|
|
*
|
|
FROM
|
|
talla
|
|
WHERE
|
|
tallaId = "'.$this->tallaId.'"';
|
|
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
|
|
|
$row = $this->Util->EncodeRow($info);
|
|
|
|
return $row;
|
|
}
|
|
|
|
public function EnumerateAll()
|
|
{
|
|
|
|
$sql = 'SELECT
|
|
*
|
|
FROM
|
|
talla
|
|
ORDER BY
|
|
nombre ASC';
|
|
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
|
|
|
return $result;
|
|
}
|
|
|
|
function Enumerate()
|
|
{
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT COUNT(*) FROM talla");
|
|
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
|
|
|
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/tallas");
|
|
|
|
$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
|
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM talla ORDER BY nombre ASC ".$sqlAdd);
|
|
$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 `talla` (
|
|
`nombre`
|
|
)
|
|
VALUES (
|
|
'".utf8_decode($this->nombre)."'
|
|
)"
|
|
);
|
|
|
|
$tallaId = $this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
|
|
|
$this->Util()->setError(20040, "complete");
|
|
$this->Util()->PrintErrors();
|
|
|
|
return true;
|
|
}
|
|
|
|
function Update()
|
|
{
|
|
if($this->Util()->PrintErrors()){ return false; }
|
|
|
|
$sql = "
|
|
UPDATE `talla` SET
|
|
`nombre` = '".utf8_decode($this->nombre)."'
|
|
WHERE tallaId = '".$this->tallaId."'
|
|
";
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
|
|
|
|
$this->Util()->setError(20041, "complete");
|
|
$this->Util()->PrintErrors();
|
|
|
|
return true;
|
|
}
|
|
|
|
function Delete()
|
|
{
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
|
DELETE FROM talla
|
|
WHERE tallaId = '".$this->tallaId."'"
|
|
);
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
|
|
|
$this->Util()->setError(20042, "complete");
|
|
$this->Util()->PrintErrors();
|
|
|
|
return true;
|
|
}
|
|
|
|
function GetNameById()
|
|
{
|
|
$sql = 'SELECT nombre FROM talla
|
|
WHERE tallaId = "'.$this->tallaId.'"';
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$nombre = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
|
|
|
return $nombre;
|
|
}
|
|
|
|
}
|
|
|
|
?>
|