git-svn-id: https://192.168.0.254/svn/Proyectos.ClaveAudio_Web/trunk@2 44ade383-bb54-5b4f-835b-923f7702b206
102 lines
2.8 KiB
PHP
102 lines
2.8 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;
|
|
|
|
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
|
|
}
|
|
}
|
|
|
|
|
|
class shoopOcasion{
|
|
var $result;
|
|
var $cuantas;
|
|
var $numOfertas;
|
|
var $curTipo;
|
|
|
|
function shoopOcasionSurtiditos($cuantos) {
|
|
// 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 ocasion_categoria AS CATEGORIA, ocasion_nombre AS NOMBRE, ocasion_estado AS ESTADO, ocasion_pvp AS PVP, ocasion_precio AS PRECIO, ocasion_descripcion AS TEXTO
|
|
FROM shoop_ocasion
|
|
WHERE ocasion_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 getNext(){
|
|
return mysql_fetch_array($this->result);
|
|
}
|
|
}
|
|
|
|
|
|
?>
|