165 lines
3.5 KiB
PHP
Executable File
165 lines
3.5 KiB
PHP
Executable File
<?php
|
|
|
|
class Temporada extends Main
|
|
{
|
|
private $temporadaId;
|
|
private $nombre;
|
|
|
|
public function setTemporadaId($value)
|
|
{
|
|
$this->Util()->ValidateInteger($value);
|
|
$this->temporadaId = $value;
|
|
}
|
|
|
|
public function setNombre($value)
|
|
{
|
|
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, "Nombre");
|
|
$this->nombre = $value;
|
|
}
|
|
|
|
public $page = 0;
|
|
|
|
public function SetPage($page)
|
|
{
|
|
$this->page = $page;
|
|
}
|
|
|
|
public function Info()
|
|
{
|
|
|
|
$sql = 'SELECT
|
|
*
|
|
FROM
|
|
temporada
|
|
WHERE
|
|
temporadaId = "'.$this->temporadaId.'"';
|
|
|
|
$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
|
|
temporada
|
|
WHERE
|
|
baja = "0"
|
|
ORDER BY
|
|
nombre ASC';
|
|
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
|
|
|
return $result;
|
|
}
|
|
|
|
function Enumerate()
|
|
{
|
|
$db = $this->Util()->DBSelect($_SESSION["empresaId"]);
|
|
|
|
$sql = "SELECT COUNT(*) FROM temporada WHERE baja = '0'";
|
|
$db->setQuery($sql);
|
|
$total = $db->GetSingle();
|
|
|
|
$pages = $this->Util()->HandleMultipages($this->page, $total ,WEB_ROOT."/temporadas", "p");
|
|
|
|
$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
|
|
|
$sql = "SELECT * FROM temporada WHERE baja = '0' ORDER BY nombre ASC ".$sqlAdd;
|
|
$db->setQuery($sql);
|
|
$result = $db->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 `temporada` (
|
|
`nombre`
|
|
)
|
|
VALUES (
|
|
'".utf8_decode($this->nombre)."'
|
|
)"
|
|
);
|
|
|
|
$temporadaId = $this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
|
|
|
$this->Util()->setError(20037, "complete");
|
|
$this->Util()->PrintErrors();
|
|
|
|
return true;
|
|
}
|
|
|
|
function Update()
|
|
{
|
|
if($this->Util()->PrintErrors()){ return false; }
|
|
|
|
$sql = "
|
|
UPDATE `temporada` SET
|
|
`nombre` = '".utf8_decode($this->nombre)."'
|
|
WHERE temporadaId = '".$this->temporadaId."'
|
|
";
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
|
|
|
|
$this->Util()->setError(20038, "complete");
|
|
$this->Util()->PrintErrors();
|
|
|
|
return true;
|
|
}
|
|
|
|
function Delete()
|
|
{
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
|
DELETE FROM temporada
|
|
WHERE temporadaId = '".$this->temporadaId."'"
|
|
);
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
|
|
|
$this->Util()->setError(20039, "complete");
|
|
$this->Util()->PrintErrors();
|
|
|
|
return true;
|
|
}
|
|
|
|
function Baja(){
|
|
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
|
UPDATE temporada SET baja = '1'
|
|
WHERE temporadaId = '".$this->temporadaId."'"
|
|
);
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
|
|
|
$this->Util()->setError(20039, "complete");
|
|
$this->Util()->PrintErrors();
|
|
|
|
return true;
|
|
|
|
}//Baja
|
|
|
|
function GetNameById()
|
|
{
|
|
$sql = 'SELECT nombre FROM temporada
|
|
WHERE temporadaId = "'.$this->temporadaId.'"';
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$nombre = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
|
|
|
return $nombre;
|
|
}
|
|
|
|
}
|
|
|
|
?>
|