Primer commit del sistema avantika sin cambios
This commit is contained in:
379
classes/sucursal.class.php
Executable file
379
classes/sucursal.class.php
Executable file
@@ -0,0 +1,379 @@
|
||||
<?php
|
||||
|
||||
class Sucursal extends Main
|
||||
{
|
||||
private $sucursalId;
|
||||
private $rfcId;
|
||||
private $nombre;
|
||||
private $noSuc;
|
||||
private $calle;
|
||||
private $noInt;
|
||||
private $noExt;
|
||||
private $referencia;
|
||||
private $colonia;
|
||||
private $localidad;
|
||||
private $municipio;
|
||||
private $ciudad;
|
||||
private $estado;
|
||||
private $pais;
|
||||
private $codigoPostal;
|
||||
private $iva;
|
||||
private $telefono;
|
||||
private $mapa;
|
||||
private $arrendatario;
|
||||
private $montoRenta;
|
||||
private $fechaVenc;
|
||||
private $tipo;
|
||||
|
||||
//private $idNota;
|
||||
|
||||
public function setSucursalId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->sucursalId = $value;
|
||||
}
|
||||
|
||||
public function setRfcId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->rfcId = $value;
|
||||
}
|
||||
|
||||
public function setNombre($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=300, $minChars = 1, "Nombre");
|
||||
$this->nombre = $value;
|
||||
}
|
||||
|
||||
public function setNoSuc($value)
|
||||
{
|
||||
$this->noSuc = $value;
|
||||
}
|
||||
|
||||
public function setCalle($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=200, $minChars = 0, 'Dirección');
|
||||
$this->calle = $value;
|
||||
}
|
||||
|
||||
public function setNoInt($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'No. Interior');
|
||||
$this->noInt = $value;
|
||||
}
|
||||
|
||||
public function setNoExt($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'No. Exterior');
|
||||
$this->noExt = $value;
|
||||
}
|
||||
|
||||
public function setLocalidad($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Localidad');
|
||||
$this->localidad = $value;
|
||||
}
|
||||
|
||||
public function setColonia($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Colonia');
|
||||
$this->colonia = $value;
|
||||
}
|
||||
|
||||
public function setReferencia($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Referencia');
|
||||
$this->referencia = $value;
|
||||
}
|
||||
|
||||
public function setMunicipio($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Municipio');
|
||||
$this->municipio = $value;
|
||||
}
|
||||
|
||||
public function setCiudad($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Ciudad');
|
||||
$this->ciudad = $value;
|
||||
}
|
||||
|
||||
public function setEstado($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Estado');
|
||||
$this->estado = $value;
|
||||
}
|
||||
|
||||
public function setPais($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Pais');
|
||||
$this->pais = $value;
|
||||
}
|
||||
|
||||
public function setCodigoPostal($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Código Postal');
|
||||
$this->codigoPostal = $value;
|
||||
}
|
||||
|
||||
public function setIva($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, '% IVA');
|
||||
$this->iva = $value;
|
||||
}
|
||||
|
||||
public function setTelefono($value)
|
||||
{
|
||||
$this->telefono = $value;
|
||||
}
|
||||
|
||||
public function setMapa($value)
|
||||
{
|
||||
$this->mapa = $value;
|
||||
}
|
||||
|
||||
public function setArrendatario($value)
|
||||
{
|
||||
$this->arrendatario = $value;
|
||||
}
|
||||
|
||||
public function setMontoRenta($value)
|
||||
{
|
||||
$this->montoRenta = $value;
|
||||
}
|
||||
|
||||
public function setFechaVenc($value)
|
||||
{
|
||||
$this->fechaVenc = $value;
|
||||
}
|
||||
|
||||
public function setTipo($value)
|
||||
{
|
||||
$this->tipo = $value;
|
||||
}
|
||||
|
||||
function Info()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
SELECT * FROM sucursal
|
||||
WHERE sucursalId ='".$this->sucursalId."'"
|
||||
);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
function GetSucursalesByEmpresaId($sucursalId = 0)
|
||||
{
|
||||
if($sucursalId)
|
||||
$sqlFilter = ' WHERE sucursalId = '.$sucursalId;
|
||||
|
||||
$sql = "SELECT * FROM sucursal
|
||||
LEFT JOIN rfc ON rfc.rfcId = sucursal.rfcId
|
||||
".$sqlFilter."
|
||||
ORDER BY nombre ASC";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$sucursales = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $sucursales;
|
||||
}
|
||||
|
||||
function GetSucursalesByRfc()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
SELECT * FROM sucursal
|
||||
LEFT JOIN rfc ON rfc.rfcId = sucursal.rfcId
|
||||
WHERE sucursal.rfcId ='".$this->rfcId."'
|
||||
ORDER BY noSuc ASC");
|
||||
$sucursales = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $sucursales;
|
||||
}
|
||||
|
||||
function EnumerateAll()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
SELECT * FROM sucursal
|
||||
ORDER BY noSuc ASC");
|
||||
$sucursales = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $sucursales;
|
||||
}
|
||||
|
||||
function GetNameById()
|
||||
{
|
||||
$sql = 'SELECT nombre FROM sucursal
|
||||
WHERE sucursalId = "'.$this->sucursalId.'"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$nombre = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
function GetNoSucById()
|
||||
{
|
||||
$sql = 'SELECT noSuc FROM sucursal
|
||||
WHERE sucursalId = "'.$this->sucursalId.'"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$noSuc = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $noSuc;
|
||||
}
|
||||
|
||||
function Save()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
INSERT INTO `sucursal` (
|
||||
`rfcId`,
|
||||
`nombre`,
|
||||
noSuc,
|
||||
`pais`,
|
||||
`calle`,
|
||||
`noInt`,
|
||||
`noExt`,
|
||||
`referencia`,
|
||||
`colonia`,
|
||||
`localidad`,
|
||||
`municipio`,
|
||||
`ciudad`,
|
||||
`iva`,
|
||||
`estado`,
|
||||
`cp`,
|
||||
telefono,
|
||||
mapa,
|
||||
arrendatario,
|
||||
montoRenta,
|
||||
fechaVenc
|
||||
)
|
||||
VALUES (
|
||||
'".$this->rfcId."',
|
||||
'".$this->nombre."',
|
||||
'".$this->noSuc."',
|
||||
'".$this->pais."',
|
||||
'".$this->calle."',
|
||||
'".$this->noInt."',
|
||||
'".$this->noExt."',
|
||||
'".$this->referencia."',
|
||||
'".$this->colonia."',
|
||||
'".$this->localidad."',
|
||||
'".$this->municipio."',
|
||||
'".$this->ciudad."',
|
||||
'".$this->iva."',
|
||||
'".$this->estado."',
|
||||
'".$this->codigoPostal."',
|
||||
'".$this->telefono."',
|
||||
'".$this->mapa."',
|
||||
'".$this->arrendatario."',
|
||||
'".$this->montoRenta."',
|
||||
'".$this->fechaVenc."'
|
||||
)"
|
||||
);
|
||||
$sucursalId = $this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
||||
|
||||
$this->Util()->setError(20009, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return $sucursalId;
|
||||
}
|
||||
|
||||
function Update()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
UPDATE `sucursal` SET
|
||||
`nombre` = '".$this->nombre."',
|
||||
noSuc = '".$this->noSuc."',
|
||||
`pais` = '".$this->pais."',
|
||||
`iva` = '".$this->iva."',
|
||||
`calle` = '".$this->calle."',
|
||||
`noInt` = '".$this->noInt."',
|
||||
`noExt` = '".$this->noExt."',
|
||||
`referencia` = '".$this->referencia."',
|
||||
`colonia` = '".$this->colonia."',
|
||||
`localidad` = '".$this->localidad."',
|
||||
`municipio` = '".$this->municipio."',
|
||||
`ciudad` = '".$this->ciudad."',
|
||||
`estado` = '".$this->estado."',
|
||||
`cp` = '".$this->codigoPostal."',
|
||||
telefono = '".$this->telefono."',
|
||||
mapa = '".$this->mapa."',
|
||||
arrendatario = '".$this->arrendatario."',
|
||||
montoRenta = '".$this->montoRenta."',
|
||||
fechaVenc = '".$this->fechaVenc."'
|
||||
WHERE
|
||||
sucursalId = '".$this->sucursalId."'");
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
|
||||
|
||||
$this->Util()->setError(20010, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Delete()
|
||||
{
|
||||
$sql = "DELETE FROM sucursal WHERE sucursalId = '".$this->sucursalId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(20008, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function GetIva()
|
||||
{
|
||||
$sql = 'SELECT iva FROM sucursal
|
||||
WHERE sucursalId = "'.$this->sucursalId.'"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$iva = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $iva;
|
||||
}
|
||||
|
||||
function getGerente()
|
||||
{
|
||||
$sql = 'SELECT * FROM usuario
|
||||
WHERE type = "gerente"
|
||||
AND sucursalId = "'.$this->sucursalId.'"';
|
||||
$this->Util()->DB()->setQuery($sql);
|
||||
$infG = $this->Util()->DB()->GetRow();
|
||||
|
||||
return $infG;
|
||||
}
|
||||
|
||||
function getSubGerente()
|
||||
{
|
||||
$sql = 'SELECT * FROM usuario
|
||||
WHERE type = "subgerente"
|
||||
AND sucursalId = "'.$this->sucursalId.'"';
|
||||
$this->Util()->DB()->setQuery($sql);
|
||||
$infSg = $this->Util()->DB()->GetRow();
|
||||
|
||||
return $infSg;
|
||||
}
|
||||
|
||||
function GetNomGerente(){
|
||||
|
||||
$sql = 'SELECT nombre, apellidos FROM usuario
|
||||
WHERE type = "gerente"
|
||||
AND sucursalId = "'.$this->sucursalId.'"';
|
||||
$this->Util()->DB()->setQuery($sql);
|
||||
$info = $this->Util()->DB()->GetRow();
|
||||
|
||||
$nombre = $info['nombre'].' '.$info['apellidos'];
|
||||
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
}//Sucursal
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user