Se hace la parte de administración de ofertas (ojo crear tabla ofetashoop_oferta
git-svn-id: https://192.168.0.254/svn/Proyectos.ClaveAudio_Web/trunk@12 44ade383-bb54-5b4f-835b-923f7702b206
This commit is contained in:
parent
96fdd18317
commit
8ef9b1d0d8
@ -12,4 +12,5 @@
|
||||
<li><a href="shoop/categorias.php" target="contenido">Categorías</a></li>
|
||||
<li><a href="shoop/productos.php" target="contenido">Productos</a></li></ul></li>
|
||||
<li class="mudo"><a href="shoop/ocasion.php" target="contenido" class="parent">OCASIÓN</a></li>
|
||||
<li class="mudo"><a href="shoop/oferta.php" target="contenido" class="parent">OFERTAS</a></li>
|
||||
<li class="mudo"><a href="shoop/pedidos.php" target="contenido" class="parent"">PEDIDOS</a></li></ul>
|
||||
101
admin/shoop/oferta.php
Normal file
101
admin/shoop/oferta.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (!session_is_registered("clave_audio")) {
|
||||
include("../login.php");
|
||||
if (!$continuar) exit;
|
||||
}
|
||||
include('../db.php');
|
||||
?>
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<title>ocasión</title>
|
||||
<link href="../sformi.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
<body>
|
||||
<table border="0" cellspacing="0" cellpadding="2">
|
||||
<tr>
|
||||
<td width="200"><a href="oferta_edit.php?op=add" class="button">[ añadir ocasión ]</a></td>
|
||||
<tr><td colspan="5"><img src="../_imgs/d.gif" width="200" height="5"></td></tr>
|
||||
</table>
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<?php
|
||||
$conn = db_connect();
|
||||
if($conn) {
|
||||
$query = "SELECT oferta_id, oferta_categoria, fab_nombre, oferta_nombre, oferta_estado, oferta_pvp, oferta_unidades, oferta_descripcion
|
||||
FROM shoop_oferta
|
||||
LEFT JOIN shoop_fabricantes on (oferta_fab_id=fab_id)
|
||||
/* WHERE oferta_unidades > 0 */
|
||||
ORDER BY oferta_categoria, oferta_id";
|
||||
$result = mysql_query($query, $conn);
|
||||
?>
|
||||
<tr>
|
||||
<td width="100" valign="top" class="hdr" align="left">Marca</td>
|
||||
<td width="355" valign="top" class="hdr">Nombre</td>
|
||||
<td width="40" valign="top" class="hdr" align="right">Uds.</td>
|
||||
<td width="80" valign="top" class="hdr" align="right">PVP</td>
|
||||
<td width="90" valign="top" class="hdr"> </td>
|
||||
</tr>
|
||||
<?php
|
||||
$secciones = array('', 'Altavoces', 'Electrónicas', 'Reproductores de CD, convertidores D/A, etc.', 'Varios');
|
||||
$curSeccion='';
|
||||
while ($row = mysql_fetch_array($result))
|
||||
{
|
||||
$oferta_id = $row['oferta_id'];
|
||||
$oferta_categoria = $row['oferta_categoria'];
|
||||
$oferta_nombre = $row['oferta_nombre'];
|
||||
$oferta_estado = $row['oferta_estado'];
|
||||
$oferta_pvp = $row['oferta_pvp'];
|
||||
$oferta_fab_nombre = $row['fab_nombre'];
|
||||
$oferta_unidades = $row['oferta_unidades'];
|
||||
$oferta_descripcion = $row['oferta_descripcion'];
|
||||
|
||||
if($oferta_categoria != $curSeccion){
|
||||
$curSeccion = $oferta_categoria;
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="5" class="lbl"><?php echo $secciones[$oferta_categoria]; ?><img src="../_imgs/d.gif" width="15" height="20"></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td width="100" valign="top" align="left" class="data"><?php echo $oferta_fab_nombre; ?></td>
|
||||
<td width="355" valign="top" class="data"> <?php echo '<span class="lbl">' . $oferta_nombre . '</span>' . (strlen($oferta_estado) ? ' (' . $oferta_estado . ')': "") . (strlen($oferta_descripcion) ? '<br> <i>' . $oferta_descripcion . '</i>': "") ; ?></td>
|
||||
<td width="40" valign="top" align="right" class="data"><?php echo $oferta_unidades; ?></td>
|
||||
<td width="80" valign="top" align="right" class="data"><?php echo number_format($oferta_pvp, 2, ',', '.');; ?></td>
|
||||
<td valign="top" class="data" align="center"> <a href="oferta_edit.php?op=edit&id=<?php echo $oferta_id; ?>" class="button">[ editar ]</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td bgcolor="#DBDEE6" colspan=7><img src="img/d.gif" width="5" height="1"></td>
|
||||
</tr>
|
||||
<?php
|
||||
} // while
|
||||
} else { // IF CONN
|
||||
echo '<p>An error has occurred while accessing the database: ' . mysql_error();
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
65
admin/shoop/oferta_db.php
Normal file
65
admin/shoop/oferta_db.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// this file has been generated by sformi, the clever tool for lazy developers.
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
session_start();
|
||||
if (!session_is_registered("clave_audio")) {
|
||||
include("../login.php");
|
||||
if (!$continuar) exit;
|
||||
}
|
||||
include('../db.php');
|
||||
include('upload.php');
|
||||
|
||||
if(isset($_REQUEST['op'])){
|
||||
$operacion = $_REQUEST['op'];
|
||||
|
||||
// here I read the variables passed by the calling page.
|
||||
$id = $_REQUEST['id'];
|
||||
$oferta_categoria=$_REQUEST['oferta_categoria'];
|
||||
$oferta_nombre=$_REQUEST['oferta_nombre'];
|
||||
$oferta_descripcion=$_REQUEST['oferta_descripcion'];
|
||||
$oferta_estado=$_REQUEST['oferta_estado'];
|
||||
$oferta_pvp=$_REQUEST['oferta_pvp'];
|
||||
$oferta_fab_id=$_REQUEST['oferta_fab_id'];
|
||||
$oferta_unidades=$_REQUEST['oferta_unidades'];
|
||||
|
||||
$conn = db_connect();
|
||||
if($conn) {
|
||||
switch($operacion) {
|
||||
case "add":
|
||||
$sql = 'INSERT INTO shoop_oferta(oferta_categoria, oferta_nombre, oferta_descripcion, oferta_estado, oferta_pvp, oferta_fab_id, oferta_unidades) VALUES("' . $oferta_categoria . '", "' . $oferta_nombre . '", "' . $oferta_descripcion . '", "' . $oferta_estado . '", "' . $oferta_pvp . '", "' . $oferta_fab_id . '", "' . $oferta_unidades . '");';
|
||||
$result = mysql_query($sql, $conn) or header('Location: ../error.php');
|
||||
$id = mysql_insert_id($conn);
|
||||
break;
|
||||
|
||||
case "edit":
|
||||
$sql = 'UPDATE shoop_oferta SET oferta_categoria="' . $oferta_categoria . '", oferta_nombre="' . $oferta_nombre . '", oferta_descripcion="' . $oferta_descripcion . '", oferta_estado="' . $oferta_estado . '", oferta_pvp="' . $oferta_pvp . '", oferta_fab_id="' . $oferta_fab_id . '", oferta_unidades="' . $oferta_unidades . '" WHERE oferta_id = ' . $id;
|
||||
$result = mysql_query($sql, $conn) or header('Location: ../error.php');
|
||||
break;
|
||||
|
||||
case "del":
|
||||
$sql = 'DELETE FROM shoop_oferta WHERE oferta_id = ' . $id;
|
||||
$result = mysql_query($sql, $conn) or header('Location: ../error.php');
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ($operacion != "del") {
|
||||
// modifico la imagen.
|
||||
uploadImagenOferta($id, 247, 95, 168, 102);
|
||||
// y vuelvo a la pantalla correspondiente
|
||||
header('Location: oferta_edit.php?op=edit&id=' . $id);
|
||||
}
|
||||
else
|
||||
header('Location: oferta.php');
|
||||
}
|
||||
}
|
||||
?>
|
||||
183
admin/shoop/oferta_edit.php
Normal file
183
admin/shoop/oferta_edit.php
Normal file
@ -0,0 +1,183 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
if (!session_is_registered("clave_audio")) {
|
||||
include("../login.php");
|
||||
if (!$continuar) exit;
|
||||
}
|
||||
|
||||
include('../db.php');
|
||||
include("../../_incl/code.php");
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>oferta</title>
|
||||
<link href="../sformi.css" rel="stylesheet" type="text/css">
|
||||
<script type="text/javascript" src="../../_incl/code.js"></script>
|
||||
<script language="JavaScript" type="text/JavaScript">function doSubmit() { document.formulario.submit(); }</script>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
if(isset($_REQUEST['op'])) {
|
||||
$operacion = $_REQUEST['op'];
|
||||
$id = $_REQUEST['id'];
|
||||
} else {
|
||||
$operacion = "add";
|
||||
}
|
||||
|
||||
$oferta_categoria = "";
|
||||
$oferta_nombre = "";
|
||||
$oferta_descripcion = "";
|
||||
$oferta_estado = "";
|
||||
$oferta_pvp = "";
|
||||
$oferta_fab_id = "";
|
||||
$oferta_unidades = "";
|
||||
|
||||
switch($operacion)
|
||||
{
|
||||
case "add";
|
||||
break;
|
||||
|
||||
case "edit";
|
||||
$conn = db_connect();
|
||||
if($conn) {
|
||||
$query = "SELECT oferta_id, oferta_categoria, oferta_nombre, oferta_descripcion, oferta_estado, oferta_pvp, oferta_fab_id, oferta_unidades FROM shoop_oferta WHERE oferta_id = " . $id;
|
||||
$result = mysql_query($query, $conn);
|
||||
if (mysql_num_rows($result)) {
|
||||
$row = mysql_fetch_array($result);
|
||||
$oferta_categoria = $row['oferta_categoria'];
|
||||
$oferta_nombre = $row['oferta_nombre'];
|
||||
$oferta_descripcion = $row['oferta_descripcion'];
|
||||
$oferta_estado = $row['oferta_estado'];
|
||||
$oferta_pvp = $row['oferta_pvp'];
|
||||
$oferta_fab_id = $row['oferta_fab_id'];
|
||||
$oferta_unidades = $row['oferta_unidades'];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$max_size = 1024 * 1536; // the max. size for uploading
|
||||
define("MAX_SIZE", $max_size);
|
||||
?>
|
||||
<form method="post" action="oferta_db.php" name="formulario" enctype="multipart/form-data">
|
||||
<input name="op" type="hidden" value="<?= $operacion; ?>">
|
||||
<input name="id" type="hidden" value="<?= $id; ?>">
|
||||
<table border="0" cellspacing="0" cellpadding="0" width="100%">
|
||||
<tr><td class="lbl12">Detalles del producto de ocasión</td></tr>
|
||||
<tr><td bgcolor="#777777"><img src="../../_imgs/d.gif" width="100" height="1"></td></tr>
|
||||
</table>
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td class= "lbl">Categoría</td>
|
||||
<td class= "lbl"> Imagen</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<select name="oferta_categoria" id="oferta_categoria" style="width:250px">
|
||||
<option value="1">Altavoces</option>
|
||||
<option value="2">Electrónicas</option>
|
||||
<option value="3">Reproductores de CD, convertidores D/A, etc.</option>
|
||||
<option value="4">Varios</option>
|
||||
</select>
|
||||
<script language="JavaScript" type="text/JavaScript"> selectOption('oferta_categoria', '<?= $oferta_categoria; ?>'); </script>
|
||||
</td>
|
||||
|
||||
<td rowspan="16" valign="top">
|
||||
<table width="250" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td><input name="ofr_imagen" type="file" style="width:250px" class="data"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<?php
|
||||
if(file_exists('../../_ofr/' . $id . '_247.jpg')) {
|
||||
?>
|
||||
<table width="247" border="1" cellspacing="0" cellpadding="0" bordercolor="#333333" style="margin-top:10px; border-style:solid; border-color:#444444; border:1px; border-padding:1px;">
|
||||
<tr>
|
||||
<td align="center"><img src="../../_ofr/<?php echo $id; ?>_247.jpg"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if(file_exists('../../_ofr/' . $id . '_168.jpg')) {
|
||||
?>
|
||||
<table width="168" border="1" cellspacing="0" cellpadding="0" bordercolor="#333333" style="margin-top:10px; border-style:solid; border-color:#444444; border:1px; border-padding:1px;">
|
||||
<tr>
|
||||
<td align="center"><img src="../../_ofr/<?php echo $id; ?>_168.jpg"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td width="200" class= "lbl">Marca</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="data"><select name="oferta_fab_id" id="oferta_fab_id" style="width:200px" class="data">
|
||||
<option value="" selected>Marcas</option>
|
||||
<?php include("menu_marcas.php"); ?>
|
||||
</select>
|
||||
<script language="JavaScript" type="text/JavaScript"> selectOption('oferta_fab_id', '<?php echo $oferta_fab_id; ?>'); </script>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td width="200" class= "lbl">Nombre</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr><td width="" class="data"><input name="oferta_nombre" id="oferta_nombre" type="text" size="50" maxlength="100" value="<?= $oferta_nombre; ?>"></td></tr>
|
||||
|
||||
<tr><td width="200" class= "lbl">Descripción</td></tr>
|
||||
<tr><td width="" class="data"><textarea name="oferta_descripcion" cols="50"><?= $oferta_descripcion; ?></textarea></td></tr>
|
||||
|
||||
<tr><td width="200" class= "lbl">Estado</td></tr>
|
||||
<tr><td width="" class="data"><input name="oferta_estado" style="width:px" value="<?= $oferta_estado; ?>">
|
||||
|
||||
<tr><td width="200" class= "lbl">PVP</td></tr>
|
||||
<tr><td width="" class="data"><input name="oferta_pvp" type="text" value="<?= $oferta_pvp; ?>" size="10" maxlength="10"></td></tr>
|
||||
|
||||
<tr><td width="200" class= "lbl">Unidades</td></tr>
|
||||
<tr><td width="" class="data"><input name="oferta_unidades" type="text" value="<?= $oferta_unidades; ?>" size="3" maxlength="3"></td></tr>
|
||||
|
||||
</table>
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="oferta.php" class="button">[ atrás ]</a>
|
||||
<a href="javascript:doSubmit();" class="button">[ Ok ]</a>
|
||||
</td>
|
||||
<?php
|
||||
if($operacion == 'edit') {
|
||||
?>
|
||||
<td>
|
||||
<a href="oferta_db.php?op=del&id=<?= $id; ?>" onClick="return confirm('Estás seguro de querer borrar este artículo?')" class="button">[ borrar ]</a>
|
||||
</td>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@ -95,6 +95,50 @@
|
||||
}
|
||||
}
|
||||
|
||||
function uploadImagenOferta($prodID, $size1_w, $size1_h, $size2_w=0, $size2_h=0, $mascara='') {
|
||||
$path = "../../_ofr/"; // este directorio tiene que tener chmod 777
|
||||
$upload_file_name = "ofr_imagen"; // el nombre del campo tipo file de nuestro formulario
|
||||
$acceptable_file_types = "image/gif|image/jpeg|image/pjpeg"; // acepta GIF et JPEG
|
||||
$default_extension = "";
|
||||
$mode = 1; // OPTIONS:
|
||||
// 1 = overwrite mode
|
||||
// 2 = create new with incremental extention
|
||||
// 3 = do nothing if exists, highest protection
|
||||
|
||||
|
||||
// un poco de limpieza previa
|
||||
// este es el temporal
|
||||
$glob = glob($path . $prodID. '_tmp');
|
||||
limpia($glob);
|
||||
|
||||
limpia($path . '_' . $size1_w . '.jpg');
|
||||
limpia($path . '_' . $size2_w . '.jpg');
|
||||
// fin de la limpia
|
||||
|
||||
if(strlen($_FILES['ofr_imagen']['name'])) {
|
||||
$my_uploader = new uploader('es'); // Create a new instance of the class
|
||||
$my_uploader->max_filesize(150000); // OPTIONAL: set the max filesize of uploadable files in bytes
|
||||
$my_uploader->max_image_size(1600, 1600); // OPTIONAL: if you're uploading images, you can set the max pixel dimensions
|
||||
// UPLOAD the file
|
||||
if ($my_uploader->upload($upload_file_name, $acceptable_file_types, $default_extension)) {
|
||||
$my_uploader->save_file($path, $prodID . '_tmp', $mode);
|
||||
if (!$my_uploader->error) {
|
||||
$my_uploader->resize($prodID . '_' . $size1_w . '.jpg', $size1_w, $size1_h, 60);
|
||||
if($size2_w) {
|
||||
$my_uploader->resize($prodID . '_' . $size2_w . '.jpg', $size2_w, $size2_h, 60);
|
||||
}
|
||||
$my_uploader->delete_file;
|
||||
}
|
||||
}
|
||||
if ($my_uploader->error) {
|
||||
echo $my_uploader->error;
|
||||
}
|
||||
|
||||
$glob = glob($path . $proid. '_tmp');
|
||||
limpia($glob);
|
||||
}
|
||||
}
|
||||
|
||||
function uploadImagenMarca($prodID, $size_w, $size_h, $mascara='') {
|
||||
$path = "../../_logos/c/"; // este directorio tiene que tener chmod 777
|
||||
$upload_file_name = "marca_imagen"; // el nombre del campo tipo file de nuestro formulario
|
||||
|
||||
@ -115,7 +115,7 @@ ini_set ('display_errors', '0');
|
||||
<div class="oferta">
|
||||
<?php
|
||||
// el parametro que paso es el nœmero de ofertas de tipo 1 de cualquier categoria que quiero
|
||||
$miOferta = new shoopOfertas(2);
|
||||
$miOferta = new shoopOfertas(4);
|
||||
if($miOferta->getNum()){
|
||||
$arrayOferta = $miOferta->getNextOferta();
|
||||
include('bann1.php');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user