Mister Spy Say ="Hello Kids ... :D"
___ ____ _ _____
| \/ (_) | | / ___|
| . . |_ ___| |_ ___ _ __ \ `--. _ __ _ _
| |\/| | / __| __/ _ \ '__| `--. \ '_ \| | | |
| | | | \__ \ || __/ | /\__/ / |_) | |_| |
\_| |_/_|___/\__\___|_| \____/| .__/ \__, |
| | __/ |
|_| |___/
Bot Mister Spy V3
Mister Spy
Mister Spy
<?php
require_once('class.db.php');
require_once('class.dbaccess.php');
require_once('class.cupon.php');
require_once('class.filter.php');
require_once('class.page.php');
class Cupones extends DBAccess implements IFilterable
{
public function ParseFilter(array $filter)
{
$sql = '';
if ((isset($filter['Cupon'])) && ($filter['Cupon'] != ''))
{
$sql.= " AND (c.Cupon LIKE '%" . DB::StringUnquoted($filter['Cupon']) . "%'";
$sql.= " OR c.Cupon IS NULL)";
}
if ((isset($filter['IdVigencia'])) && ($filter['IdVigencia'] != ''))
$sql.= " AND c.IdVigencia = " . DB::Number($filter['IdVigencia']);
if ((isset($filter['IdTipo'])) && ($filter['IdTipo'] != ''))
$sql.= " AND c.IdTipo = " . DB::Number($filter['IdTipo']);
if ((isset($filter['IdProducto'])) && ($filter['IdProducto'] != ''))
$sql.= " AND c.IdProducto = " . DB::Number($filter['IdProducto']);
return $sql;
}
public function GetAll(array $filter = NULL, Page $oPage = NULL)
{
$sql = " SELECT c.*";
$sql.= " FROM tblCupones c";
$sql.= " WHERE 1";
$sql.= ($filter) ? $this->ParseFilter($filter) : "";
$sql.= " ORDER BY c.IdCupon DESC";
$sql.= ($oPage) ? Pageable::ParsePage($oPage) : "";
if ( !($oRes = $this->GetQuery($sql)) )
return false;
$arr = array();
while ($oRow = $oRes->GetRow())
{
$oCupon = new Cupon();
$oCupon->ParseFromArray($oRow);
array_push($arr, $oCupon);
$oRes->MoveNext();
}
return $arr;
}
public function GetById($IdCupon)
{
$sql = "SELECT c.*";
$sql.= " FROM tblCupones c";
$sql.= " WHERE c.IdCupon = " . DB::Number($IdCupon);
if ( !($oRes = $this->GetQuery($sql)) )
return false;
if ( !($oRow = $oRes->GetRow()) )
return false;
$oCupon = new Cupon();
$oCupon->ParseFromArray($oRow);
return $oCupon;
}
public function GetByCupon($Cupon)
{
$sql = "SELECT c.*";
$sql.= " FROM tblCupones c";
$sql.= " WHERE c.Cupon = " . DB::String($Cupon);
if ( !($oRes = $this->GetQuery($sql)) )
return false;
if ( !($oRow = $oRes->GetRow()) )
return false;
$oCupon = new Cupon();
$oCupon->ParseFromArray($oRow);
return $oCupon;
}
public function GetCountRows(array $filter = NULL)
{
$sql = " SELECT c.*";
$sql.= " FROM tblCupones c";
$sql.= " WHERE 1";
$sql.= ($filter) ? $this->ParseFilter($filter) : "";
$sql.= " ORDER BY c.IdCupon DESC";
if (!($oRes = $this->GetQuery($sql)))
return false;
$CountRows = $oRes->NumRows();
return $CountRows;
}
public function Create(Cupon $oCupon)
{
$arr = array
(
'IdVigencia' => DB::Number($oCupon->IdVigencia),
'IdTipo' => DB::Number($oCupon->IdTipo),
'IdProducto' => DB::Number($oCupon->IdProducto),
'Cupon' => DB::String($oCupon->Cupon),
'PorcentajeDescuento' => DB::Number($oCupon->PorcentajeDescuento)
);
if (!DBAccess::Insert('tblCupones', $arr))
{
DBAccess::$db->Rollback();
return false;
}
$oCupon->IdCupon = DBAccess::GetLastInsertId();
return $oCupon;
}
public function Update(Cupon $oCupon)
{
$arr = array
(
'IdVigencia' => DB::Number($oCupon->IdVigencia),
'IdTipo' => DB::Number($oCupon->IdTipo),
'IdProducto' => DB::Number($oCupon->IdProducto),
'Cupon' => DB::String($oCupon->Cupon),
'PorcentajeDescuento' => DB::Number($oCupon->PorcentajeDescuento),
'Estado' => DB::Number($oCupon->Estado)
);
$where = " IdCupon = " . (int)$oCupon->IdCupon;
if (!DBAccess::UpdateEntidad('tblCupones', $arr, $where))
return false;
return $oCupon;
}
public function Delete($IdCupon)
{
$where = " IdCupon = " . DB::Number($IdCupon);
if (!DBAccess::DeleteEntidad('tblCupones', $where))
return false;
return true;
}
}
?>
Mr. DellatioNx196 GaLers xh3LL Backd00r 1.0, Coded By Mr. DellatioNx196 - Bogor BlackHat