Primer commit del sistema avantika sin cambios
This commit is contained in:
156
classes/motivo.class.php
Executable file
156
classes/motivo.class.php
Executable file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
class Motivo extends Main
|
||||
{
|
||||
private $motivoId;
|
||||
private $nombre;
|
||||
|
||||
public function setMotivoId($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, "Motivo");
|
||||
$this->motivoId = $value;
|
||||
}
|
||||
|
||||
public function setNombre($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Nombre');
|
||||
$this->nombre = $value;
|
||||
}
|
||||
|
||||
function Info(){
|
||||
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
motivo
|
||||
WHERE
|
||||
motivoId = '".$this->motivoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$row = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function EnumerateAll()
|
||||
{
|
||||
$sql = "SELECT * FROM motivo WHERE baja = '0' ORDER BY nombre ASC";
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$motivos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $motivos;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$sql = "SELECT COUNT(*) FROM motivo WHERE baja = '0'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/motivos");
|
||||
|
||||
$sqlAdd = " LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$sql = "SELECT * FROM motivo WHERE baja = '0' ORDER BY nombre ASC".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$motivos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $motivos;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Save(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO `motivo`
|
||||
(
|
||||
nombre
|
||||
)
|
||||
VALUES (
|
||||
'".utf8_decode($this->nombre)."'
|
||||
)";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
$this->Util()->setError(30051, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function Update(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "UPDATE
|
||||
`motivo`
|
||||
SET
|
||||
nombre = '".utf8_decode($this->nombre)."'
|
||||
WHERE
|
||||
motivoId = ".$this->motivoId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
$this->Util()->setError(30052, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function Delete(){
|
||||
|
||||
$sql = "DELETE FROM
|
||||
motivo
|
||||
WHERE
|
||||
motivoId = '".$this->motivoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(30053, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function Baja(){
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
UPDATE motivo SET baja = '1'
|
||||
WHERE motivoId = '".$this->motivoId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(30053, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}//Baja
|
||||
|
||||
function GetNameById(){
|
||||
|
||||
$sql = "SELECT
|
||||
nombre
|
||||
FROM
|
||||
motivo
|
||||
WHERE
|
||||
motivoId = '".$this->motivoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$name = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
}//Motivo
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user