git-svn-id: https://192.168.0.254/svn/Proyectos.ClaveAudio_Web/trunk@15 44ade383-bb54-5b4f-835b-923f7702b206
175 lines
5.4 KiB
PHP
175 lines
5.4 KiB
PHP
<?php
|
|
|
|
// este script devuelve N ofertas de la categoria que se le pase
|
|
|
|
include('code.php');
|
|
|
|
|
|
class shoopOfertas{
|
|
|
|
var $result;
|
|
var $cuantas;
|
|
var $numOfertas;
|
|
var $curTipo;
|
|
|
|
//LA QUE VIENE POR DEFECTO CON LA TIENDA - (NO SE USA)
|
|
function shoopOfertas($cuantos, $categoria = '', $tipo = 1){
|
|
// esta es mi entrada en la clase, aqu? inicializo las globales.
|
|
$this->numOfertas = 0;
|
|
$this->contador = 0;
|
|
$this->result = false;
|
|
$this->curTipo = $tipo;
|
|
|
|
$cuantos = $cuantos * 4;
|
|
|
|
$conn = db_connect();
|
|
if($conn) {
|
|
$query = 'SELECT fab_nombre, fab_id, prod_id, prod_modelo, prod_precio, prod_descripcion, prod_categoria_id, cat_nombre, cat_seccion
|
|
FROM shoop_prod_ofertas, shoop_productos, shoop_fabricantes, shoop_categorias
|
|
WHERE oferta_tipo=' . $tipo .
|
|
(strlen($categoria) ? ' AND oferta_cat_id="' . $categoria .'"': '') .
|
|
' AND prod_precio > 0 AND prod_id=oferta_prod_id AND cat_codigo=prod_categoria_id AND fab_id=prod_fab_id
|
|
ORDER BY RAND()';
|
|
// LIMIT ' . $cuantos;
|
|
|
|
$this->result = mysql_query($query, $conn);
|
|
$this->numOfertas = mysql_num_rows($this->result);
|
|
}
|
|
}
|
|
|
|
function getNum() {
|
|
return $this->numOfertas;
|
|
}
|
|
|
|
function getNextOferta(){
|
|
$oferta = '';
|
|
|
|
if($this->contador < $this->numOfertas) {
|
|
$row = mysql_fetch_array($this->result);
|
|
$this->contador ++;
|
|
if(file_exists('_prds/' . $row['prod_id'] . ($this->curTipo != 2 ? '_168.jpg' : '_247.jpg'))) {
|
|
$oferta = array ( 'marca' => $row['fab_nombre'],
|
|
'marca_id' => $row['fab_id'],
|
|
'id_modelo' => $row['prod_id'],
|
|
'modelo' => $row['prod_modelo'],
|
|
'precio' => $row['prod_precio'],
|
|
'texto' => $row['prod_descripcion'],
|
|
'catid' => $row['prod_categoria_id'],
|
|
'producto' => componProducto($row['cat_nombre'], $row['cat_seccion']));
|
|
} else {
|
|
$oferta = $this->getNextOferta();
|
|
}
|
|
}
|
|
return $oferta; // es un array
|
|
}
|
|
}
|
|
|
|
//Esta clase sale para hacer ofertas igual que ocasiones, segun como ya viene hecho
|
|
class shoopOfertaNueva{
|
|
var $result;
|
|
var $cuantas;
|
|
var $numOfertas;
|
|
var $curTipo;
|
|
|
|
function shoopOfertaNueva($cuantos, $categoria = '', $tipo = 1){
|
|
// esta es mi entrada en la clase, aqu? inicializo las globales.
|
|
$this->numOfertas = 0;
|
|
$this->contador = 0;
|
|
$this->result = false;
|
|
$this->curTipo = $tipo;
|
|
|
|
$conn = db_connect();
|
|
if($conn) {
|
|
$query = 'SELECT oferta_id, oferta_fab_id, fab_nombre, oferta_categoria, oferta_nombre, oferta_estado, oferta_pvp, oferta_descripcion
|
|
FROM shoop_oferta
|
|
LEFT JOIN shoop_fabricantes on (oferta_fab_id=fab_id)
|
|
WHERE oferta_unidades > 0
|
|
ORDER BY RAND() LIMIT '. $cuantos;
|
|
|
|
$this->result = mysql_query($query, $conn);
|
|
$this->numOfertas = mysql_num_rows($this->result);
|
|
}
|
|
}
|
|
|
|
function getNum() {
|
|
return $this->numOfertas;
|
|
}
|
|
|
|
function getNextOferta(){
|
|
$oferta = '';
|
|
|
|
if($this->contador < $this->numOfertas) {
|
|
$row = mysql_fetch_array($this->result);
|
|
$this->contador ++;
|
|
// if(file_exists('_ofr/' . $row['oferta_id'] . ($this->curTipo != 2 ? '_168.jpg' : '_247.jpg'))) {
|
|
$oferta = array ( 'categoria_id' => $row['oferta_categoria'],
|
|
'nombre' => $row['oferta_nombre'],
|
|
'id' => $row['oferta_id'],
|
|
'estado' => $row['oferta_estado'],
|
|
'fab_id' => $row['oferta_fab_id'],
|
|
'fab_nombre' => $row['fab_nombre'],
|
|
'pvp' => $row['oferta_pvp'],
|
|
'descripcion' => $row['oferta_descripcion']);
|
|
// } else {
|
|
// $oferta = $this->getNextOferta();
|
|
// }
|
|
}
|
|
return $oferta; // es un array
|
|
}
|
|
}
|
|
|
|
class shoopOcasion{
|
|
var $result;
|
|
var $cuantas;
|
|
var $numOfertas;
|
|
var $curTipo;
|
|
|
|
function shoopOcasion($cuantos, $categoria = '', $tipo = 1){
|
|
// esta es mi entrada en la clase, aqu? inicializo las globales.
|
|
$this->numOcasiones = 0;
|
|
$this->contador = 0;
|
|
$this->result = false;
|
|
$this->curTipo = $tipo;
|
|
|
|
$conn = db_connect();
|
|
if($conn) {
|
|
$query = 'SELECT ocasion_id, ocasion_categoria, ocasion_nombre, ocasion_estado, ocasion_pvp, ocasion_precio, ocasion_descripcion, ocasion_fab_id, fab_nombre
|
|
FROM shoop_ocasion
|
|
LEFT JOIN shoop_fabricantes on (ocasion_fab_id=fab_id)
|
|
WHERE (ocasion_unidades > 0)
|
|
ORDER BY RAND() LIMIT '. $cuantos;
|
|
|
|
$this->result = mysql_query($query, $conn);
|
|
$this->numOcasiones = mysql_num_rows($this->result);
|
|
}
|
|
}
|
|
|
|
function getNum() {
|
|
return $this->numOcasiones;
|
|
}
|
|
|
|
function getNextOcasion(){
|
|
$ocasion = '';
|
|
|
|
if($this->contador < $this->numOcasiones) {
|
|
$row = mysql_fetch_array($this->result);
|
|
$this->contador ++;
|
|
// if(file_exists('_ocs/' . $row['ocasion_id'] . ($this->curTipo != 2 ? '_168.jpg' : '_247.jpg'))) {
|
|
$ocasion = array ( 'categoria_id' => $row['ocasion_categoria'],
|
|
'nombre' => $row['ocasion_nombre'],
|
|
'id' => $row['ocasion_id'],
|
|
'fab_id' => $row['ocasion_fab_id'],
|
|
'fab_nombre' => $row['fab_nombre'],
|
|
'estado' => $row['ocasion_estado'],
|
|
'precio' => $row['ocasion_precio'],
|
|
'pvp' => $row['ocasion_pvp'],
|
|
'descripcion' => $row['ocasion_descripcion']);
|
|
// } else {
|
|
// $ocasion = $this->getNextOcasion();
|
|
// }
|
|
}
|
|
return $ocasion; // es un array
|
|
}
|
|
}
|
|
|
|
?>
|