2011-05-06 11:33:27 +00:00
|
|
|
<?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');
|
2011-05-09 15:07:48 +00:00
|
|
|
include('upload.php');
|
2011-05-06 11:33:27 +00:00
|
|
|
|
|
|
|
|
if(isset($_REQUEST['op'])){
|
|
|
|
|
$operacion = $_REQUEST['op'];
|
|
|
|
|
|
2011-05-09 15:07:48 +00:00
|
|
|
// here I read the variables passed by the calling page.
|
|
|
|
|
$id = $_REQUEST['id'];
|
2011-05-06 11:33:27 +00:00
|
|
|
$ocasion_categoria=$_REQUEST['ocasion_categoria'];
|
|
|
|
|
$ocasion_nombre=$_REQUEST['ocasion_nombre'];
|
|
|
|
|
$ocasion_descripcion=$_REQUEST['ocasion_descripcion'];
|
|
|
|
|
$ocasion_estado=$_REQUEST['ocasion_estado'];
|
|
|
|
|
$ocasion_pvp=$_REQUEST['ocasion_pvp'];
|
|
|
|
|
$ocasion_precio=$_REQUEST['ocasion_precio'];
|
|
|
|
|
$ocasion_unidades=$_REQUEST['ocasion_unidades'];
|
2011-06-06 14:29:53 +00:00
|
|
|
$ocasion_fab_id=$_REQUEST['ocasion_fab_id'];
|
2011-05-06 11:33:27 +00:00
|
|
|
|
2011-05-09 15:07:48 +00:00
|
|
|
$conn = db_connect();
|
|
|
|
|
if($conn) {
|
2011-05-06 11:33:27 +00:00
|
|
|
switch($operacion) {
|
|
|
|
|
case "add":
|
2011-06-06 14:29:53 +00:00
|
|
|
$sql = 'INSERT INTO shoop_ocasion(ocasion_categoria, ocasion_nombre, ocasion_descripcion, ocasion_estado, ocasion_pvp, ocasion_precio, ocasion_unidades, ocasion_fab_id) VALUES("' . $ocasion_categoria . '", "' . $ocasion_nombre . '", "' . $ocasion_descripcion . '", "' . $ocasion_estado . '", "' . $ocasion_pvp . '", "' . $ocasion_precio . '", "' . $ocasion_unidades . '", "' . $ocasion_fab_id . '");';
|
2011-05-09 15:07:48 +00:00
|
|
|
$result = mysql_query($sql, $conn) or header('Location: ../error.php');
|
|
|
|
|
$id = mysql_insert_id($conn);
|
2011-05-06 11:33:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "edit":
|
2011-06-06 14:29:53 +00:00
|
|
|
$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 . '", ocasion_fab_id="' . $ocasion_fab_id .'" WHERE ocasion_id = ' . $id;
|
|
|
|
|
$result = mysql_query($sql, $conn) or header('Location: ../error.php');
|
2011-05-09 15:07:48 +00:00
|
|
|
break;
|
2011-05-06 11:33:27 +00:00
|
|
|
|
|
|
|
|
case "del":
|
2011-05-09 15:07:48 +00:00
|
|
|
$sql = 'DELETE FROM shoop_ocasion WHERE ocasion_id = ' . $id;
|
|
|
|
|
$result = mysql_query($sql, $conn) or header('Location: ../error.php');
|
2011-05-06 11:33:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-05-09 15:07:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($operacion != "del") {
|
|
|
|
|
// modifico la imagen.
|
2011-06-27 16:12:27 +00:00
|
|
|
uploadImagenOcasion($id, 348, 248, 168, 102);
|
|
|
|
|
uploadImagenOcasion($id, 247, 95, 108, 108);
|
2011-05-09 15:07:48 +00:00
|
|
|
// y vuelvo a la pantalla correspondiente
|
|
|
|
|
header('Location: ocasion_edit.php?op=edit&id=' . $id);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
header('Location: ocasion.php');
|
2011-05-06 11:33:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
?>
|