ClaveAudio_Web/admin/shoop/oferta_db.php

67 lines
2.4 KiB
PHP
Raw Normal View History

<?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, 348, 248, 168, 102);
uploadImagenOferta($id, 247, 95, 108, 108);
uploadPDFOferta($id);
// y vuelvo a la pantalla correspondiente
header('Location: oferta_edit.php?op=edit&id=' . $id);
}
else
header('Location: oferta.php');
}
}
?>