Mister Spy Say ="Hello Kids ... :D" ___ ____ _ _____ | \/ (_) | | / ___| | . . |_ ___| |_ ___ _ __ \ `--. _ __ _ _ | |\/| | / __| __/ _ \ '__| `--. \ '_ \| | | | | | | | \__ \ || __/ | /\__/ / |_) | |_| | \_| |_/_|___/\__\___|_| \____/| .__/ \__, | | | __/ | |_| |___/ Bot Mister Spy V3
Mister Spy

Mister Spy

Current Path : /home/caballoscriollos/public_html/espanol/library/
Upload File :
Current File : /home/caballoscriollos/public_html/espanol/library/class.exiss.php

<?php 

require_once('class.dbaccess.php');
require_once('class.exis.php');
require_once('class.filter.php');
require_once('class.page.php');

class Exiss extends DBAccess implements IFilterable
{

	public function ParseFilter(array $filter)
	{
		$sql = '';

		if (isset($filter['SBA']) && $filter['SBA'] != "")
		{
			$sql.= " AND HBAE = " . DB::Number($filter['SBA']);
		}

		if (isset($filter['RP']) && $filter['RP'] != "")
		{
			$sql.= " AND RPEX = " . DB::Number($filter['RP']);
		}
		
		if (isset($filter['Animal']) && $filter['Animal'] != "")
		{
			$sql.= " AND NOMB LIKE '%" . DB::StringUnquoted($filter['Animal']) . "%'";
		}

		return $sql;
	}

	public function GetPagesCount(Page $oPage, $filter = false)
	{	
		$sql = "SELECT COUNT(1) / " . DB::Number($oPage->Size) . " AS Count";
		$sql.= " FROM tblExis ";
		$sql.= " WHERE 1 ";
		
		if ($filter)
			$sql.= " " . $this->ParseFilter($filter);

		if (!($oRes = $this->GetQuery($sql)) )		
			return false;

		if ( !($oRow = $oRes->GetRow()) )
			return false;
		
		$Count = $oRow['Count'];
		$Count = ceil($Count);
		
		return $Count;
	}

	
	public function GetAllFNAC(array $filter = NULL, Page $oPage = NULL)
	{
		$sql = "SELECT IdExis, FNAC ";
		$sql.= " FROM tblExis ";
		$sql.= " WHERE LENGTH(FNAC) >= 9 ";
		
		if ($filter)
			$sql.= $this->ParseFilter($filter);

		if ($oPage != NULL)
			$sql.= " " . Pageable::ParsePage($oPage);

		if (!($oRes = $this->GetQuery($sql)))
			return false;

		$arr = array();
		
		while ($oRow = $oRes->GetRow())	
		{	
			$oExis = new Exis();
			$oExis->ParseFromArray($oRow);
			
			array_push($arr, $oExis);
			
			$oRes->MoveNext();
		}	
		
		return $arr;
	}
	
	public function GetAll(array $filter = NULL, Page $oPage = NULL)
	{
		$sql = "SELECT * ";
		$sql.= " FROM tblExis ";
		$sql.= " WHERE 1 ";
		
		if ($filter)
			$sql.= $this->ParseFilter($filter);

		if ($oPage != NULL)
			$sql.= " " . Pageable::ParsePage($oPage);

		if (!($oRes = $this->GetQuery($sql)))
			return false;

		$arr = array();
		
		while ($oRow = $oRes->GetRow())	
		{	
			$oExis = new Exis();
			$oExis->ParseFromArray($oRow);
			
			array_push($arr, $oExis);
			
			$oRes->MoveNext();
		}	
		
		return $arr;
	}
	
	public function GetBySba($SBA, $RP)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblExis ";
		$sql.= " WHERE 1 ";
		
		if ($SBA != "")
			$sql.= " AND HBAE = '" .$SBA. "' ";

		if ($RP != "")
			$sql .= " AND RPEX = '".$RP."'";

		if (!($oRes = $this->GetQuery($sql)))
			return false;

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{
			$oExis = new Exis();
			$oExis->ParseFromArray($oRow);

			array_push($arr, $oExis);

			$oRes->MoveNext();
		}

		return $arr;
	}

	public function GetAnimalBySba($SBA, $RP, $RGST = '')
	{
		$sql = "SELECT IdExis, HBAE, RPEX, NOMB, PROP, HBAP, RPPD, HBAM, RPMD, FNAC, CPEL, RGST, ASOC, ASOP, ASOM, RGST, RGSM, RGSP  ";
		$sql.= " FROM tblExis ";
		$sql.= " WHERE 1 ";
		
		//if ($SBA != "")
		$sql.= " AND HBAE = '" .$SBA. "' ";

		//if ($RP != "")
			//$sql .= " AND RPEX LIKE '%".$RP."'"; // SE PONE LIKE PORQUE SI EL RP ES 28, PUEDE APARECER COMO 028
		
		if ($RGST != "")
			$sql.= " AND RGST = '" . $RGST . "'";
		
		if (!($oRes = $this->GetQuery($sql)))
			return false;

		if (!($oRow = $oRes->GetRow()))
			return false;

		$oExis = new Exis();
		$oExis->ParseFromArray($oRow);

		return $oExis;		
	}
	
	
	public function GetById($IdExis)
	{
		$sql = "SELECT * ";
		$sql.= " FROM tblExis ";
		$sql.= " WHERE IdExis = " . DB::Number($IdExis);	

		if (!($oRes = $this->GetQuery($sql)))
			return false;

		if (!($oRow = $oRes->GetRow()))
			return false;

		$oExis = new Exis();
		$oExis->ParseFromArray($oRow);

		return $oExis;		
	}

	public function GetNombreBySBA($SBA)
	{
		$sql = "SELECT * ";
		$sql.= " FROM tblExis ";
		$sql.= " WHERE HBAE = " . DB::Number($SBA);	

		if (!($oRes = $this->GetQuery($sql)))
			return false;

		if (!($oRow = $oRes->GetRow()))
			return false;

		$oExis = new Exis();
		$oExis->ParseFromArray($oRow);

		return $oExis->NOMB;		
	}
	
	
	public function GetNombreById($IdExis)
	{
		$sql = "SELECT * ";
		$sql.= " FROM tblExis ";
		$sql.= " WHERE IdExis = " . DB::Number($IdExis);	

		if (!($oRes = $this->GetQuery($sql)))
			return false;

		if (!($oRow = $oRes->GetRow()))
			return false;

		$oExis = new Exis();
		$oExis->ParseFromArray($oRow);

		return $oExis->Nombre;		
	}
	
	
	public function GetByNombre($Nombre, $IdExis)
	{
		$sql = " SELECT * ";
		$sql.= " FROM tblExis ";
		$sql.= " WHERE WHERE 1 ";

		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		if (!($oRow = $oRes->GetRow()))
			return false;
		
		$oExis = new Exis();
		$oExis->ParseFromArray($oRow);
		
		return $oExis;		
	}
	
	
	public function GetCountRows(array $filter = NULL)
	{
		$sql = "SELECT * ";
		$sql.= " FROM tblExis ";
		$sql.= " WHERE 1";
		
		if ($filter)
			$sql.= $this->ParseFilter($filter);

		$sql.= " ORDER BY HBAE, NOMB ASC";
		
		if (!($oRes = $this->GetQuery($sql)))
			return false;
		
		$CountRows = $oRes->NumRows();
		
		return $CountRows;
	}
	
	
	public function Create(Exis $oExis)
	{
		$arr = array
		(
			'TANA'  	=> DB::String($oExis->TANA),
			'RAZA' 		=> DB::String($oExis->RAZA),
			'RGST' 		=> DB::String($oExis->RGST),
			'VARI' 		=> DB::String($oExis->VARI),
			'ASOC' 		=> DB::String($oExis->ASOC),
			'HBAE' 		=> DB::String($oExis->HBAE),
			'CDPX' 		=> DB::String($oExis->CDPX),
			'RPEX' 		=> DB::String($oExis->RPEX),
			'RPTI' 		=> DB::String($oExis->RPTI),
			'NOMB' 		=> DB::String($oExis->NOMB),
			'CBAJ' 		=> DB::String($oExis->CBAJ),
			'OBSI' 		=> DB::String($oExis->OBSI),
			'DADO' 		=> DB::String($oExis->DADO),
			'PROP' 		=> DB::String($oExis->PROP),
			'CRIA' 		=> DB::String($oExis->CRIA),
			'TRAN' 		=> DB::String($oExis->TRAN),
			'ANLS' 		=> DB::String($oExis->ANLS),
			'RANA' 		=> DB::String($oExis->RANA),
			'CALG' 		=> DB::String($oExis->CALG),
			'APRB' 		=> DB::String($oExis->APRB),
			'SIET' 		=> DB::String($oExis->SIET),
			'DONA' 		=> DB::String($oExis->DONA),
			'MELL' 		=> DB::String($oExis->MELL),
			'TRNS' 		=> DB::String($oExis->TRNS),
			'TSER' 		=> DB::String($oExis->TSER),
			'EMBA' 		=> DB::String($oExis->EMBA),
			'COLO' 		=> DB::String($oExis->COLO),
			'RGSP' 		=> DB::String($oExis->RGSP),
			'VARP' 		=> DB::String($oExis->VARP),
			'ASOP' 		=> DB::String($oExis->ASOP),
			'HBAP' 		=> DB::String($oExis->HBAP),
			'RPPD' 		=> DB::String($oExis->RPPD),
			'RGSM' 		=> DB::String($oExis->RGSM),
			'VARM' 		=> DB::String($oExis->VARM),
			'ASOM' 		=> DB::String($oExis->ASOM),
			'HBAM' 		=> DB::String($oExis->HBAM),
			'RPMD' 		=> DB::String($oExis->RPMD),
			'FNAC' 		=> DB::Date($oExis->FNAC),
			'FBAJ' 		=> DB::String($oExis->FBAJ),
			'FESB' 		=> DB::String($oExis->FESB),
			'FOBS' 		=> DB::String($oExis->FOBS),
			'FTRF' 		=> DB::String($oExis->FTRF),
			'FSER' 		=> DB::String($oExis->FSER),
			'CPEL' 		=> DB::String($oExis->CPEL),
			'CCUE' 		=> DB::String($oExis->CCUE),
			'CCAB' 		=> DB::String($oExis->CCAB),
			'CMIE' 		=> DB::String($oExis->CMIE),
			'RPNU' 		=> DB::String($oExis->RPNU),
			'HBAS'  	=> DB::String($oExis->HBAS),
			'APDO' 		=> DB::String($oExis->APDO),
			'PENA' 		=> DB::String($oExis->PENA),
			'PEDE' 		=> DB::String($oExis->PEDE),
			'PEFI' 		=> DB::String($oExis->PEFI),
			'EPNA' 		=> DB::String($oExis->EPNA),
			'EPDE' 		=> DB::String($oExis->EPDE),
			'EPFI' 		=> DB::String($oExis->EPFI),
			'NROC' 		=> DB::String($oExis->NROC),
			'SIGLA' 	=> DB::String($oExis->SIGLA),
			'SIGPA' 	=> DB::String($oExis->SIGPA),
			'SIGMA' 	=> DB::String($oExis->SIGMA),
			'PURE' 		=> DB::String($oExis->PURE),
			'IdProd'	=> DB::Number($oExis->IdProd),
			'IdPa'		=> DB::Number($oExis->IdPa),
			'IdMa'		=> DB::Number($oExis->IdMa),
			'IdPPdre'	=> DB::Number($oExis->IdPPdre),
			'IdPExtr'	=> DB::Number($oExis->IdPExtr),
			'IdEExis'	=> DB::Number($oExis->IdEExis),
			'IdEExtr'	=> DB::Number($oExis->IdEExtr)
		);

		if (!$this->Insert('tblExis', $arr))
			return false;

		
		$oExis->IdExis = DBAccess::GetLastInsertId();
			
		return $oExis;
	}

	
	public function UpdateFNAC(Exis $oExis)
	{
		$where = " IdExis = " . DB::Number($oExis->IdExis);
		
		$arr = array
		(
			'FNAC' 	=> DB::String($oExis->FNAC)
		);
		
		if (!DBAccess::Update('tblExis', $arr, $where))
			return false;
		
		return $oExis;
	}
	
	public function Update(Exis $oExis)
	{
		$where = " IdExis = " . DB::Number($oExis->IdExis);
		
		$arr = array
		(
			'IdExis'	=> DB::Number($oExis->IdExis),
			'TANA'  	=> DB::String($oExis->TANA),
			'RAZA' 		=> DB::String($oExis->RAZA),
			'RGST' 		=> DB::String($oExis->RGST),
			'VARI' 		=> DB::String($oExis->VARI),
			'ASOC' 		=> DB::String($oExis->ASOC),
			'HBAE' 		=> DB::String($oExis->HBAE),
			'CDPX' 		=> DB::String($oExis->CDPX),
			'RPEX' 		=> DB::String($oExis->RPEX),
			'RPTI' 		=> DB::String($oExis->RPTI),
			'NOMB' 		=> DB::String($oExis->NOMB),
			'CBAJ' 		=> DB::String($oExis->CBAJ),
			'OBSI' 		=> DB::String($oExis->OBSI),
			'DADO' 		=> DB::String($oExis->DADO),
			'PROP' 		=> DB::String($oExis->PROP),
			'CRIA' 		=> DB::String($oExis->CRIA),
			'TRAN' 		=> DB::String($oExis->TRAN),
			'ANLS' 		=> DB::String($oExis->ANLS),
			'RANA' 		=> DB::String($oExis->RANA),
			'CALG' 		=> DB::String($oExis->CALG),
			'APRB' 		=> DB::String($oExis->APRB),
			'SIET' 		=> DB::String($oExis->SIET),
			'DONA' 		=> DB::String($oExis->DONA),
			'MELL' 		=> DB::String($oExis->MELL),
			'TRNS' 		=> DB::String($oExis->TRNS),
			'TSER' 		=> DB::String($oExis->TSER),
			'EMBA' 		=> DB::String($oExis->EMBA),
			'COLO' 		=> DB::String($oExis->COLO),
			'RGSP' 		=> DB::String($oExis->RGSP),
			'VARP' 		=> DB::String($oExis->VARP),
			'ASOP' 		=> DB::String($oExis->ASOP),
			'HBAP' 		=> DB::String($oExis->HBAP),
			'RPPD' 		=> DB::String($oExis->RPPD),
			'RGSM' 		=> DB::String($oExis->RGSM),
			'VARM' 		=> DB::String($oExis->VARM),
			'ASOM' 		=> DB::String($oExis->ASOM),
			'HBAM' 		=> DB::String($oExis->HBAM),
			'RPMD' 		=> DB::String($oExis->RPMD),
			'FNAC' 		=> DB::Date($oExis->FNAC),
			'FBAJ' 		=> DB::String($oExis->FBAJ),
			'FESB' 		=> DB::String($oExis->FESB),
			'FOBS' 		=> DB::String($oExis->FOBS),
			'FTRF' 		=> DB::String($oExis->FTRF),
			'FSER' 		=> DB::String($oExis->FSER),
			'CPEL' 		=> DB::String($oExis->CPEL),
			'CCUE' 		=> DB::String($oExis->CCUE),
			'CCAB' 		=> DB::String($oExis->CCAB),
			'CMIE' 		=> DB::String($oExis->CMIE),
			'RPNU' 		=> DB::String($oExis->RPNU),
			'HBAS'  	=> DB::String($oExis->HBAS),
			'APDO' 		=> DB::String($oExis->APDO),
			'PENA' 		=> DB::String($oExis->PENA),
			'PEDE' 		=> DB::String($oExis->PEDE),
			'PEFI' 		=> DB::String($oExis->PEFI),
			'EPNA' 		=> DB::String($oExis->EPNA),
			'EPDE' 		=> DB::String($oExis->EPDE),
			'EPFI' 		=> DB::String($oExis->EPFI),
			'NROC' 		=> DB::String($oExis->NROC),
			'SIGLA' 	=> DB::String($oExis->SIGLA),
			'SIGPA' 	=> DB::String($oExis->SIGPA),
			'SIGMA' 	=> DB::String($oExis->SIGMA),
			'PURE' 		=> DB::String($oExis->PURE),
			'IdProd'	=> DB::Number($oExis->IdProd),
			'IdPa'		=> DB::Number($oExis->IdPa),
			'IdMa'		=> DB::Number($oExis->IdMa),
			'IdPPdre'	=> DB::Number($oExis->IdPPdre),
			'IdPExtr'	=> DB::Number($oExis->IdPExtr),
			'IdEExis'	=> DB::Number($oExis->IdEExis),
			'IdEExtr'	=> DB::Number($oExis->IdEExtr)
		);
		
		if (!DBAccess::Update('tblExis', $arr, $where))
			return false;
		
		return $oExis;
	}
	

	public function Delete($IdExis)
	{
		if (!DBAccess::$db->Begin())
			return false;
			
		$where = " IdExis = " . DB::Number($IdExis);
		if (!DBAccess::Delete('tblExis', $where))
		{
				DBAccess::$db->Rollback();	
				return false;
		}

		DBAccess::$db->Commit();
		
		return true;	
	}		
}

?>

Mr. DellatioNx196 GaLers xh3LL Backd00r 1.0, Coded By Mr. DellatioNx196 - Bogor BlackHat