Se hace la parte de administración de las ocasiones para que pueda meter fotos
git-svn-id: https://192.168.0.254/svn/Proyectos.ClaveAudio_Web/trunk@6 44ade383-bb54-5b4f-835b-923f7702b206
This commit is contained in:
parent
5a48ec0c94
commit
6ecee0038a
@ -17,7 +17,7 @@ include('../db.php');
|
||||
<body>
|
||||
<table border="0" cellspacing="0" cellpadding="2">
|
||||
<tr>
|
||||
<td width="200"><a href="ocasion_edit.php?op=add" class="button">[ añadir producto ]</a></td>
|
||||
<td width="200"><a href="ocasion_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">
|
||||
|
||||
@ -13,11 +13,13 @@ if (!session_is_registered("clave_audio")) {
|
||||
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.
|
||||
// here I read the variables passed by the calling page.
|
||||
$id = $_REQUEST['id'];
|
||||
$ocasion_categoria=$_REQUEST['ocasion_categoria'];
|
||||
$ocasion_nombre=$_REQUEST['ocasion_nombre'];
|
||||
$ocasion_descripcion=$_REQUEST['ocasion_descripcion'];
|
||||
@ -26,26 +28,38 @@ $ocasion_pvp=$_REQUEST['ocasion_pvp'];
|
||||
$ocasion_precio=$_REQUEST['ocasion_precio'];
|
||||
$ocasion_unidades=$_REQUEST['ocasion_unidades'];
|
||||
|
||||
|
||||
if(db_connect()) {
|
||||
$conn = db_connect();
|
||||
if($conn) {
|
||||
switch($operacion) {
|
||||
case "add":
|
||||
$sql = 'INSERT INTO shoop_ocasion(ocasion_categoria, ocasion_nombre, ocasion_descripcion, ocasion_estado, ocasion_pvp, ocasion_precio, ocasion_unidades) VALUES("' . $ocasion_categoria . '", "' . $ocasion_nombre . '", "' . $ocasion_descripcion . '", "' . $ocasion_estado . '", "' . $ocasion_pvp . '", "' . $ocasion_precio . '", "' . $ocasion_unidades . '");';
|
||||
$sql = 'INSERT INTO shoop_ocasion(ocasion_categoria, ocasion_nombre, ocasion_descripcion, ocasion_estado, ocasion_pvp, ocasion_precio, ocasion_unidades) VALUES("' . $ocasion_categoria . '", "' . $ocasion_nombre . '", "' . $ocasion_descripcion . '", "' . $ocasion_estado . '", "' . $ocasion_pvp . '", "' . $ocasion_precio . '", "' . $ocasion_unidades . '");';
|
||||
$result = mysql_query($sql, $conn) or header('Location: ../error.php');
|
||||
$id = mysql_insert_id($conn);
|
||||
break;
|
||||
|
||||
case "edit":
|
||||
$sql = 'UPDATE shoop_ocasion SET ocasion_categoria="' . $ocasion_categoria . '", ocasion_nombre="' . $ocasion_nombre . '", ocasion_descripcion="' . $ocasion_descripcion . '", ocasion_estado="' . $ocasion_estado . '", ocasion_pvp="' . $ocasion_pvp . '", ocasion_precio="' . $ocasion_precio . '", ocasion_unidades="' . $ocasion_unidades . '" WHERE ocasion_id = ' . $_REQUEST['id'];
|
||||
break;
|
||||
$sql = 'UPDATE shoop_ocasion SET ocasion_categoria="' . $ocasion_categoria . '", ocasion_nombre="' . $ocasion_nombre . '", ocasion_descripcion="' . $ocasion_descripcion . '", ocasion_estado="' . $ocasion_estado . '", ocasion_pvp="' . $ocasion_pvp . '", ocasion_precio="' . $ocasion_precio . '", ocasion_unidades="' . $ocasion_unidades . '" WHERE ocasion_id = ' . $id;
|
||||
$result = mysql_query($sql, $conn) or header('Location: ../error.php');
|
||||
break;
|
||||
|
||||
case "del":
|
||||
$sql = 'DELETE FROM shoop_ocasion WHERE ocasion_id = ' . $_REQUEST['id'];
|
||||
$sql = 'DELETE FROM shoop_ocasion WHERE ocasion_id = ' . $id;
|
||||
$result = mysql_query($sql, $conn) or header('Location: ../error.php');
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$result = mysql_query($sql) or header('Location: ../error.php');
|
||||
header('Location: ocasion.php');
|
||||
|
||||
|
||||
if ($operacion != "del") {
|
||||
// modifico la imagen.
|
||||
uploadImagenOcasion($id, 247, 95, 168, 102);
|
||||
// y vuelvo a la pantalla correspondiente
|
||||
header('Location: ocasion_edit.php?op=edit&id=' . $id);
|
||||
}
|
||||
else
|
||||
header('Location: ocasion.php');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -57,52 +57,110 @@ switch($operacion)
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$max_size = 1024 * 1536; // the max. size for uploading
|
||||
define("MAX_SIZE", $max_size);
|
||||
?>
|
||||
<form method="post" action="ocasion_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 width="200" class= "lbl">Categoría</td></tr>
|
||||
<tr><td width="" class="data"><select name="ocasion_categoria" id="ocasion_categoria" style="width:250px">
|
||||
<option value="1">Altavoces</option>
|
||||
<tr>
|
||||
<td class= "lbl">Categoría</td>
|
||||
<td class= "lbl"> Imagen</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<select name="ocasion_categoria" id="ocasion_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></td></tr>
|
||||
<script language="JavaScript" type="text/JavaScript"> selectOption('ocasion_categoria', '<?= $ocasion_categoria; ?>'); </script>
|
||||
<tr><td><img src="img/d.gif" width="100" height="5"></td></tr>
|
||||
</select>
|
||||
<script language="JavaScript" type="text/JavaScript"> selectOption('ocasion_categoria', '<?= $ocasion_categoria; ?>'); </script>
|
||||
</td>
|
||||
|
||||
<td rowspan="16" valign="top">
|
||||
<table width="250" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td><input name="prod_imagen" type="file" style="width:250px" class="data"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<?php
|
||||
if(file_exists('../../_ocs/' . $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="../../_ocs/<?php echo $id; ?>_247.jpg"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if(file_exists('../../_ocs/' . $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="../../_ocs/<?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">Nombre</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr><td width="" class="data"><input name="ocasion_nombre" id="ocasion_nombre" type="text" size="50" maxlength="100" value="<?= $ocasion_nombre; ?>"></td></tr>
|
||||
<tr><td><img src="img/d.gif" width="100" height="5"></td></tr>
|
||||
|
||||
<tr><td width="200" class= "lbl">Descripción</td></tr>
|
||||
<tr><td width="" class="data"><textarea name="ocasion_descripcion" cols="50"><?= $ocasion_descripcion; ?></textarea></td></tr>
|
||||
<tr><td><img src="img/d.gif" width="100" height="5"></td></tr>
|
||||
|
||||
<tr><td width="200" class= "lbl">Estado</td></tr>
|
||||
<tr><td width="" class="data"><input name="ocasion_estado" style="width:px" value="<?= $ocasion_estado; ?>">
|
||||
<tr><td><img src="img/d.gif" width="100" height="5"></td></tr>
|
||||
|
||||
<tr><td width="200" class= "lbl">PVP</td></tr>
|
||||
<tr><td width="" class="data"><input name="ocasion_pvp" type="text" value="<?= $ocasion_pvp; ?>" size="10" maxlength="10"></td></tr>
|
||||
<tr><td><img src="img/d.gif" width="100" height="5"></td></tr>
|
||||
|
||||
<tr><td width="200" class= "lbl">Precio</td></tr>
|
||||
<tr><td width="" class="data"><input name="ocasion_precio" type="text" value="<?= $ocasion_precio; ?>" size="10" maxlength="10"></td></tr>
|
||||
<tr><td><img src="img/d.gif" width="100" height="5"></td></tr>
|
||||
|
||||
<tr><td width="200" class= "lbl">Unidades</td></tr>
|
||||
<tr><td width="" class="data"><input name="ocasion_unidades" type="text" value="<?= $ocasion_unidades; ?>" size="3" maxlength="3"></td></tr>
|
||||
<tr><td><img src="img/d.gif" width="100" height="5"></td></tr>
|
||||
|
||||
</table>
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="ocasion.php" class="button">[ atrás ]</a>
|
||||
<a href="javascript:doSubmit();" class="button">[ <?= $operacion; ?> ]</a>
|
||||
<a href="javascript:doSubmit();" class="button">[ Ok ]</a>
|
||||
</td>
|
||||
<?php
|
||||
if($operacion == 'edit') {
|
||||
?>
|
||||
<td>
|
||||
<a href="ocasion_db.php?op=del&id=<?= $prod_id; ?>" onClick="return confirm('Estás seguro de querer borrar este artículo?')" class="button">[ borrar ]</a>
|
||||
<a href="ocasion_db.php?op=del&id=<?= $id; ?>" onClick="return confirm('Estás seguro de querer borrar este artículo?')" class="button">[ borrar ]</a>
|
||||
</td>
|
||||
<?php
|
||||
}
|
||||
|
||||
@ -51,6 +51,49 @@
|
||||
}
|
||||
}
|
||||
|
||||
function uploadImagenOcasion($prodID, $size1_w, $size1_h, $size2_w=0, $size2_h=0, $mascara='') {
|
||||
$path = "../../_ocs/"; // este directorio tiene que tener chmod 777
|
||||
$upload_file_name = "prod_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['prod_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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user