diff --git a/assets/uploads/marketing_images/69f9563f75358.webp b/assets/uploads/marketing_images/69f9563f75358.webp new file mode 100644 index 00000000..e12441bd Binary files /dev/null and b/assets/uploads/marketing_images/69f9563f75358.webp differ diff --git a/assets/uploads/marketing_images/69f95a0b3cbf6.jpg b/assets/uploads/marketing_images/69f95a0b3cbf6.jpg new file mode 100644 index 00000000..cbaa81e2 Binary files /dev/null and b/assets/uploads/marketing_images/69f95a0b3cbf6.jpg differ diff --git a/db/migrations/037_create_marketing_videos_table.sql b/db/migrations/037_create_marketing_videos_table.sql new file mode 100644 index 00000000..969ece01 --- /dev/null +++ b/db/migrations/037_create_marketing_videos_table.sql @@ -0,0 +1,10 @@ +CREATE TABLE IF NOT EXISTS marketing_videos ( + id INT AUTO_INCREMENT PRIMARY KEY, + producto_id INT NULL, + foto_producto VARCHAR(255) NULL, + instrucciones TEXT NULL, + link_video VARCHAR(255) NULL, + estado ENUM('Pendiente', 'En Proceso', 'Terminado', 'Aprobado') DEFAULT 'Pendiente', + fecha_creacion TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (producto_id) REFERENCES products(id) ON DELETE SET NULL +); \ No newline at end of file diff --git a/db/migrations/038_update_marketing_videos_columns.sql b/db/migrations/038_update_marketing_videos_columns.sql new file mode 100644 index 00000000..b3a09266 --- /dev/null +++ b/db/migrations/038_update_marketing_videos_columns.sql @@ -0,0 +1,7 @@ +ALTER TABLE marketing_videos +ADD COLUMN fecha_entrega DATE NULL AFTER fecha_creacion, +ADD COLUMN angulo_video TEXT NULL AFTER instrucciones, +ADD COLUMN link_inspiracion_landing VARCHAR(255) NULL AFTER angulo_video, +ADD COLUMN link_inspiracion_video VARCHAR(255) NULL AFTER link_inspiracion_landing, +ADD COLUMN link_landing VARCHAR(255) NULL AFTER link_video, +ADD COLUMN orden INT DEFAULT 0 AFTER id; \ No newline at end of file diff --git a/db/migrations/039_add_link_flyer_to_marketing_videos.sql b/db/migrations/039_add_link_flyer_to_marketing_videos.sql new file mode 100644 index 00000000..a55ba78b --- /dev/null +++ b/db/migrations/039_add_link_flyer_to_marketing_videos.sql @@ -0,0 +1 @@ +ALTER TABLE marketing_videos ADD COLUMN link_flyer VARCHAR(255) NULL AFTER link_landing; \ No newline at end of file diff --git a/db/migrations/039_add_material_to_marketing_videos.sql b/db/migrations/039_add_material_to_marketing_videos.sql new file mode 100644 index 00000000..897ead5f --- /dev/null +++ b/db/migrations/039_add_material_to_marketing_videos.sql @@ -0,0 +1 @@ +ALTER TABLE marketing_videos ADD COLUMN material TEXT AFTER foto_producto; \ No newline at end of file diff --git a/db/migrations/045_create_marketing_assets_table.sql b/db/migrations/045_create_marketing_assets_table.sql new file mode 100644 index 00000000..523cfd35 --- /dev/null +++ b/db/migrations/045_create_marketing_assets_table.sql @@ -0,0 +1,7 @@ +CREATE TABLE IF NOT EXISTS marketing_assets ( + id INT AUTO_INCREMENT PRIMARY KEY, + nombre VARCHAR(255) NOT NULL, + categoria ENUM('Logo', 'Intro/Outro', 'Música', 'Gráficos', 'Otros') DEFAULT 'Otros', + archivo_path VARCHAR(255) NOT NULL, + fecha_subida TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); \ No newline at end of file diff --git a/delete_marketing_asset.php b/delete_marketing_asset.php new file mode 100644 index 00000000..7b43c32d --- /dev/null +++ b/delete_marketing_asset.php @@ -0,0 +1,24 @@ +prepare("SELECT archivo_path FROM marketing_assets WHERE id = ?"); + $stmt->execute([$id]); + $asset = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($asset) { + if (file_exists($asset['archivo_path'])) { + unlink($asset['archivo_path']); + } + + $stmt = $db->prepare("DELETE FROM marketing_assets WHERE id = ?"); + $stmt->execute([$id]); + } +} + +header("Location: marketing_assets.php"); +exit; \ No newline at end of file diff --git a/marketing_assets.php b/marketing_assets.php index a2cd7476..beae20b0 100644 --- a/marketing_assets.php +++ b/marketing_assets.php @@ -1,14 +1,148 @@ query("SELECT * FROM marketing_assets ORDER BY categoria ASC, nombre ASC"); +$assets = $stmt->fetchAll(PDO::FETCH_ASSOC); + +// Agrupar por categoría +$categorias = [ + 'Logo' => [], + 'Intro/Outro' => [], + 'Música' => [], + 'Gráficos' => [], + 'Otros' => [] +]; + +foreach ($assets as $asset) { + $categorias[$asset['categoria']][] = $asset; +} ?> -
-
-
Biblioteca de Recursos de Marketing
-

Aquí podrás subir y organizar logos, intros de video, música y otros materiales que la editora deba utilizar de forma recurrente.

-
- Esta sección está en desarrollo. Pronto podrás gestionar tus archivos aquí. + +
+
+
+

Biblioteca de Assets

+ +
+ +
+ +
+
+ $items): ?> +
+
+
+
+
+
+ +

No hay archivos en esta categoría.

+ +
+ + + + + + + + + + + + + + + + + +
NombreFechaAcciones
+
+ + + +
+
+ + + + +
+
+ +
+
+
+ +
+
+ + + -
+ + + + \ No newline at end of file diff --git a/marketing_produccion.php b/marketing_produccion.php index 90096b80..65f51732 100644 --- a/marketing_produccion.php +++ b/marketing_produccion.php @@ -13,73 +13,186 @@ $productos = $stmt_products->fetchAll(PDO::FETCH_ASSOC); $stmt_videos = $db->query("SELECT mv.*, p.nombre as nombre_producto FROM marketing_videos mv LEFT JOIN products p ON mv.producto_id = p.id - ORDER BY mv.fecha_creacion DESC"); + ORDER BY mv.orden ASC, mv.fecha_creacion DESC"); $videos = $stmt_videos->fetchAll(PDO::FETCH_ASSOC); ?> + +
-

Gestión de Producción

- +
+

Producción de Video

+

Vista de control estilo Excel

+
+
+ + Biblioteca de Assets + + +
-
- -
- -

No hay pedidos de video registrados aún.

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OrdenFecha EntregaProductoImagenMaterialÁnguloInsp. LandingInsp. VideoLink VideoLink LandingLink FlyerEstadoAcción
No hay pedidos registrados.
+ -'; ?> + + + Ref + + Sin foto + + +
+ +
+
+
+ +
+
+ + + + - + + + + + + - + + + + + + - + + + + + + - + + + + + + - + + + + + + + +
- - -
-
-
- - Producto - -
- -
- - - - -
-
-
-

- ... -

-
- - - - Ver Video - - -
-
- -
-
- - +
@@ -93,8 +206,16 @@ $videos = $stmt_videos->fetchAll(PDO::FETCH_ASSOC);
+ + + \ No newline at end of file diff --git a/save_marketing_asset.php b/save_marketing_asset.php new file mode 100644 index 00000000..e77643c5 --- /dev/null +++ b/save_marketing_asset.php @@ -0,0 +1,29 @@ +prepare("INSERT INTO marketing_assets (nombre, categoria, archivo_path) VALUES (?, ?, ?)"); + $stmt->execute([$nombre, $categoria, $targetPath]); + + header("Location: marketing_assets.php?success=1"); + exit; + } + } +} + +header("Location: marketing_assets.php?error=1"); +exit; \ No newline at end of file diff --git a/save_marketing_video.php b/save_marketing_video.php index 920003af..e6c59141 100644 --- a/save_marketing_video.php +++ b/save_marketing_video.php @@ -9,29 +9,110 @@ if (!isset($_SESSION['user_id'])) { if ($_SERVER['REQUEST_METHOD'] == 'POST') { $db = db(); - $producto_id = !empty($_POST['producto_id']) ? $_POST['producto_id'] : null; - $instrucciones = $_POST['instrucciones'] ?? ''; - $foto_path = null; + $action = $_POST['action'] ?? 'create'; - // Manejo de la subida de foto - if (isset($_FILES['foto_producto']) && $_FILES['foto_producto']['error'] == 0) { - $target_dir = "assets/uploads/marketing_images/"; - $file_extension = pathinfo($_FILES["foto_producto"]["name"], PATHINFO_EXTENSION); - $file_name = uniqid() . '.' . $file_extension; - $target_file = $target_dir . $file_name; + if ($action == 'update') { + // Lógica para actualizar (Editora o Tú) + $id = $_POST['id']; + $estado = $_POST['estado']; + $link_video = $_POST['link_video'] ?? ''; + $link_landing = $_POST['link_landing'] ?? ''; + $link_flyer = $_POST['link_flyer'] ?? ''; + $material = $_POST['material'] ?? ''; + $fecha_entrega = !empty($_POST['fecha_entrega']) ? $_POST['fecha_entrega'] : null; + $orden = !empty($_POST['orden']) ? $_POST['orden'] : 0; + $angulo_video = $_POST['angulo_video'] ?? ''; + $link_inspiracion_landing = $_POST['link_inspiracion_landing'] ?? ''; + $link_inspiracion_video = $_POST['link_inspiracion_video'] ?? ''; - if (move_uploaded_file($_FILES["foto_producto"]["tmp_name"], $target_file)) { - $foto_path = $target_file; + try { + $stmt = $db->prepare("UPDATE marketing_videos SET + estado = ?, + link_video = ?, + link_landing = ?, + link_flyer = ?, + material = ?, + fecha_entrega = ?, + orden = ?, + angulo_video = ?, + link_inspiracion_landing = ?, + link_inspiracion_video = ? + WHERE id = ?"); + $stmt->execute([ + $estado, + $link_video, + $link_landing, + $link_flyer, + $material, + $fecha_entrega, + $orden, + $angulo_video, + $link_inspiracion_landing, + $link_inspiracion_video, + $id + ]); + header('Location: marketing_produccion.php?success=updated'); + } catch (PDOException $e) { + echo "Error: " . $e->getMessage(); } - } - - try { - $stmt = $db->prepare("INSERT INTO marketing_videos (producto_id, foto_producto, instrucciones, estado) VALUES (?, ?, ?, 'Pendiente')"); - $stmt->execute([$producto_id, $foto_path, $instrucciones]); + } else { + // Lógica para crear (Tú) + $producto_id = !empty($_POST['producto_id']) ? $_POST['producto_id'] : null; + $instrucciones = $_POST['instrucciones'] ?? ''; + $fecha_entrega = !empty($_POST['fecha_entrega']) ? $_POST['fecha_entrega'] : null; + $orden = !empty($_POST['orden']) ? $_POST['orden'] : 0; + $angulo_video = $_POST['angulo_video'] ?? ''; + $link_inspiracion_landing = $_POST['link_inspiracion_landing'] ?? ''; + $link_inspiracion_video = $_POST['link_inspiracion_video'] ?? ''; + $link_flyer = $_POST['link_flyer'] ?? ''; + $material = $_POST['material'] ?? ''; - header('Location: marketing_produccion.php?success=1'); - } catch (PDOException $e) { - echo "Error: " . $e->getMessage(); + $foto_path = null; + + if (isset($_FILES['foto_producto']) && $_FILES['foto_producto']['error'] == 0) { + $target_dir = "assets/uploads/marketing_images/"; + if (!is_dir($target_dir)) { + mkdir($target_dir, 0777, true); + } + $file_extension = pathinfo($_FILES["foto_producto"]["name"], PATHINFO_EXTENSION); + $file_name = uniqid() . '.' . $file_extension; + $target_file = $target_dir . $file_name; + + if (move_uploaded_file($_FILES["foto_producto"]["tmp_name"], $target_file)) { + $foto_path = $target_file; + } + } + + try { + $stmt = $db->prepare("INSERT INTO marketing_videos ( + producto_id, + foto_producto, + material, + instrucciones, + estado, + fecha_entrega, + orden, + angulo_video, + link_inspiracion_landing, + link_inspiracion_video, + link_flyer + ) VALUES (?, ?, ?, ?, 'Pendiente', ?, ?, ?, ?, ?, ?)"); + $stmt->execute([ + $producto_id, + $foto_path, + $material, + $instrucciones, + $fecha_entrega, + $orden, + $angulo_video, + $link_inspiracion_landing, + $link_inspiracion_video, + $link_flyer + ]); + header('Location: marketing_produccion.php?success=created'); + } catch (PDOException $e) { + echo "Error: " . $e->getMessage(); + } } } ?> \ No newline at end of file diff --git a/update_marketing_video_field.php b/update_marketing_video_field.php new file mode 100644 index 00000000..a54e7cbc --- /dev/null +++ b/update_marketing_video_field.php @@ -0,0 +1,46 @@ + 'Acceso no autorizado.']); + exit; +} + +$data = json_decode(file_get_contents('php://input'), true); + +if (!$data || !isset($data['id']) || !isset($data['field']) || !isset($data['value'])) { + http_response_code(400); + echo json_encode(['error' => 'Datos incompletos.']); + exit; +} + +$video_id = $data['id']; +$field = $data['field']; +$value = $data['value']; + +// Whitelist allowed fields for security +$allowed_fields = ['material', 'estado', 'angulo_video']; +if (!in_array($field, $allowed_fields)) { + http_response_code(400); + echo json_encode(['error' => 'Campo no permitido.']); + exit; +} + +try { + $pdo = db(); + + $sql = "UPDATE marketing_videos SET $field = ? WHERE id = ?"; + $stmt = $pdo->prepare($sql); + $stmt->execute([$value, $video_id]); + + echo json_encode([ + 'success' => true, + 'message' => 'Campo actualizado correctamente.' + ]); +} catch (PDOException $e) { + http_response_code(500); + echo json_encode(['error' => 'Error al actualizar la base de datos: ' . $e->getMessage()]); +} +?> \ No newline at end of file