Commercial -> infomercial

This commit is contained in:
Mark Pinkster 2026-01-14 12:19:07 +01:00
parent 999e76744b
commit ced3b87e1d
18 changed files with 253 additions and 253 deletions

View File

@ -73,7 +73,7 @@ mysql -u talpa_user -p talpa_planning -e "SHOW TABLES;"
Je zou moeten zien: Je zou moeten zien:
- block_templates - block_templates
- commercials - infomercials
- daily_blocks - daily_blocks
- transmissions - transmissions
@ -202,7 +202,7 @@ http://talpa-planning.local/
``` ```
**8.2 Controleer of je het dashboard ziet met:** **8.2 Controleer of je het dashboard ziet met:**
- Navigatie menu (Dashboard, Kalender, Blokken, Commercials) - Navigatie menu (Dashboard, Kalender, Blokken, Infomercials)
- Statistieken cards - Statistieken cards
- Snelle acties - Snelle acties
@ -220,9 +220,9 @@ http://talpa-planning.local/
- Net5 Ochtendblok (07:30-11:30) - Net5 Ochtendblok (07:30-11:30)
- Net5 Middagblok (13:20-13:50) - Net5 Middagblok (13:20-13:50)
**9.2 Test Commercial Registratie:** **9.2 Test Infomercial Registratie:**
- Ga naar **Commercials** - Ga naar **Infomercials**
- Probeer een test commercial aan te maken: - Probeer een test infomercial aan te maken:
- Titel: "Test Product" - Titel: "Test Product"
- Duur: 00:30:00 - Duur: 00:30:00
- Series Code: TEST01 - Series Code: TEST01
@ -231,7 +231,7 @@ http://talpa-planning.local/
**9.3 Test Kalender:** **9.3 Test Kalender:**
- Ga naar **Kalender** - Ga naar **Kalender**
- Controleer of de kalender laadt - Controleer of de kalender laadt
- Probeer een commercial te slepen (als je er een hebt aangemaakt) - Probeer een infomercial te slepen (als je er een hebt aangemaakt)
## Troubleshooting ## Troubleshooting
@ -355,7 +355,7 @@ Bij problemen:
- [ ] Webserver geconfigureerd - [ ] Webserver geconfigureerd
- [ ] Dashboard bereikbaar in browser - [ ] Dashboard bereikbaar in browser
- [ ] Blok templates zichtbaar - [ ] Blok templates zichtbaar
- [ ] Test commercial aangemaakt - [ ] Test infomercial aangemaakt
- [ ] Kalender laadt correct - [ ] Kalender laadt correct
Als alle items zijn afgevinkt, is de installatie succesvol! 🎉 Als alle items zijn afgevinkt, is de installatie succesvol! 🎉

View File

@ -11,10 +11,10 @@ Een geavanceerd TV-planning systeem voor het beheren en plannen van homeshopping
- **Kleurgecodeerde uitzendingen** voor overzichtelijkheid - **Kleurgecodeerde uitzendingen** voor overzichtelijkheid
- **Conflict detectie** bij overlappende uitzendingen - **Conflict detectie** bij overlappende uitzendingen
### 📺 Commercial Management ### 📺 Infomercial Management
- Registratie van commercials via Talpa API - Registratie van infomercials via Talpa API
- Automatische media asset aanmaak - Automatische media asset aanmaak
- Kleurcode toewijzing per commercial - Kleurcode toewijzing per infomercial
- Series code voor groepering - Series code voor groepering
- Upload status tracking - Upload status tracking
@ -102,7 +102,7 @@ chmod 644 api/*.php
├── index.php # Dashboard ├── index.php # Dashboard
├── calendar.php # Kalender planning view ├── calendar.php # Kalender planning view
├── blocks.php # Blok template management ├── blocks.php # Blok template management
├── commercials.php # Commercial management ├── infomercials.php # Infomercial management
├── helpers.php # Helper functies ├── helpers.php # Helper functies
├── TalpaAPI.php # API wrapper ├── TalpaAPI.php # API wrapper
├── /api # API endpoints ├── /api # API endpoints
@ -142,9 +142,9 @@ chmod 644 api/*.php
- Net5 Ochtend: Ma-Vr, 07:30-11:30 - Net5 Ochtend: Ma-Vr, 07:30-11:30
- Net5 Middag: Ma-Vr, 13:20-13:50 - Net5 Middag: Ma-Vr, 13:20-13:50
### 2. Commercials Registreren ### 2. Infomercials Registreren
1. Ga naar **Commercials** in het menu 1. Ga naar **Infomercials** in het menu
2. Vul het formulier in: 2. Vul het formulier in:
- Product naam - Product naam
- Duur (HH:MM:SS formaat) - Duur (HH:MM:SS formaat)
@ -165,7 +165,7 @@ chmod 644 api/*.php
- Wijzig de starttijd - Wijzig de starttijd
- Kies of je alle uitzendingen wilt herberekenen - Kies of je alle uitzendingen wilt herberekenen
4. **Plan uitzendingen:** 4. **Plan uitzendingen:**
- Sleep een commercial uit de sidebar - Sleep een infomercial uit de sidebar
- Drop deze op het gewenste tijdslot - Drop deze op het gewenste tijdslot
- Het systeem berekent automatisch de volgende starttijd - Het systeem berekent automatisch de volgende starttijd
5. **Bewerk uitzendingen:** 5. **Bewerk uitzendingen:**
@ -184,12 +184,12 @@ chmod 644 api/*.php
## 🎨 Kleurcode Systeem ## 🎨 Kleurcode Systeem
Het systeem wijst automatisch unieke kleuren toe aan commercials voor visuele identificatie: Het systeem wijst automatisch unieke kleuren toe aan infomercials voor visuele identificatie:
- Kleuren worden automatisch gegenereerd met voldoende contrast - Kleuren worden automatisch gegenereerd met voldoende contrast
- Elke commercial krijgt een unieke kleur - Elke infomercial krijgt een unieke kleur
- Series codes kunnen dezelfde kleur delen - Series codes kunnen dezelfde kleur delen
- Kleuren zijn handmatig aanpasbaar in Commercial Management - Kleuren zijn handmatig aanpasbaar in Infomercial Management
## 🔧 Geavanceerde Functies ## 🔧 Geavanceerde Functies
@ -230,12 +230,12 @@ Wanneer je een blok starttijd aanpast:
### Drag-and-drop werkt niet ### Drag-and-drop werkt niet
**Probleem:** Commercials zijn niet sleepbaar **Probleem:** Infomercials zijn niet sleepbaar
**Oplossing:** **Oplossing:**
1. Controleer of FullCalendar correct is geladen 1. Controleer of FullCalendar correct is geladen
2. Check browser console voor errors 2. Check browser console voor errors
3. Zorg dat commercials status "uploaded" hebben 3. Zorg dat infomercials status "uploaded" hebben
### API Sync Errors ### API Sync Errors
@ -260,7 +260,7 @@ Wanneer je een blok starttijd aanpast:
``` ```
2. Controleer of alle kolommen bestaan: 2. Controleer of alle kolommen bestaan:
```sql ```sql
SHOW COLUMNS FROM commercials LIKE 'color_code'; SHOW COLUMNS FROM infomercials LIKE 'color_code';
``` ```
## 📊 Database Schema ## 📊 Database Schema
@ -279,7 +279,7 @@ Wanneer je een blok starttijd aanpast:
### Uitgebreide Kolommen ### Uitgebreide Kolommen
**commercials** **infomercials**
- `color_code` (VARCHAR(7)): Hex kleurcode - `color_code` (VARCHAR(7)): Hex kleurcode
- `series_code` (VARCHAR(20)): Series identifier - `series_code` (VARCHAR(20)): Series identifier
@ -319,7 +319,7 @@ Voor vragen of problemen:
### Versie 1.0.0 (2026-01-13) ### Versie 1.0.0 (2026-01-13)
- ✅ Kalender planning met drag-and-drop - ✅ Kalender planning met drag-and-drop
- ✅ Blok template management - ✅ Blok template management
- ✅ Commercial management met kleurcodes - ✅ Infomercial management met kleurcodes
- ✅ Automatische tijdberekening - ✅ Automatische tijdberekening
- ✅ Talpa API integratie - ✅ Talpa API integratie
- ✅ Conflict detectie - ✅ Conflict detectie
@ -328,7 +328,7 @@ Voor vragen of problemen:
## 🎯 Roadmap ## 🎯 Roadmap
Toekomstige features: Toekomstige features:
- [ ] Bulk import van commercials - [ ] Bulk import van infomercials
- [ ] Excel export van planning - [ ] Excel export van planning
- [ ] Email notificaties bij sync errors - [ ] Email notificaties bij sync errors
- [ ] Gebruikersbeheer en rechten - [ ] Gebruikersbeheer en rechten

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* API Endpoint: Assign Color to Commercial * API Endpoint: Assign Color to Infomercial
* Assigns or updates color code for a commercial * Assigns or updates color code for a infomercial
*/ */
require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../vendor/autoload.php';
@ -25,22 +25,22 @@ try {
} }
// Validate required fields // Validate required fields
if (empty($input['commercial_id'])) { if (empty($input['infomercial_id'])) {
jsonResponse([ jsonResponse([
'success' => false, 'success' => false,
'error' => 'Missing commercial_id' 'error' => 'Missing infomercial_id'
], 400); ], 400);
} }
// Check if commercial exists // Check if infomercial exists
$stmt = $db->prepare("SELECT id, color_code FROM commercials WHERE id = ?"); $stmt = $db->prepare("SELECT id, color_code FROM infomercials WHERE id = ?");
$stmt->execute([$input['commercial_id']]); $stmt->execute([$input['infomercial_id']]);
$commercial = $stmt->fetch(); $infomercial = $stmt->fetch();
if (!$commercial) { if (!$infomercial) {
jsonResponse([ jsonResponse([
'success' => false, 'success' => false,
'error' => 'Commercial not found' 'error' => 'Infomercial not found'
], 404); ], 404);
} }
@ -60,33 +60,33 @@ try {
} }
} else { } else {
// Auto-generate distinct color // Auto-generate distinct color
$stmt = $db->query("SELECT color_code FROM commercials WHERE color_code IS NOT NULL"); $stmt = $db->query("SELECT color_code FROM infomercials WHERE color_code IS NOT NULL");
$existingColors = $stmt->fetchAll(PDO::FETCH_COLUMN); $existingColors = $stmt->fetchAll(PDO::FETCH_COLUMN);
$colorCode = generateDistinctColor($existingColors); $colorCode = generateDistinctColor($existingColors);
} }
// Update commercial // Update infomercial
$stmt = $db->prepare(" $stmt = $db->prepare("
UPDATE commercials UPDATE infomercials
SET color_code = ?, series_code = ? SET color_code = ?, series_code = ?
WHERE id = ? WHERE id = ?
"); ");
$stmt->execute([ $stmt->execute([
$colorCode, $colorCode,
$input['series_code'] ?? null, $input['series_code'] ?? null,
$input['commercial_id'] $input['infomercial_id']
]); ]);
// Get updated commercial // Get updated infomercial
$stmt = $db->prepare("SELECT * FROM commercials WHERE id = ?"); $stmt = $db->prepare("SELECT * FROM infomercials WHERE id = ?");
$stmt->execute([$input['commercial_id']]); $stmt->execute([$input['infomercial_id']]);
$updated = $stmt->fetch(); $updated = $stmt->fetch();
jsonResponse([ jsonResponse([
'success' => true, 'success' => true,
'message' => 'Color assigned successfully', 'message' => 'Color assigned successfully',
'commercial' => $updated 'infomercial' => $updated
]); ]);
} catch (Exception $e) { } catch (Exception $e) {

View File

@ -25,7 +25,7 @@ try {
} }
// Validate required fields // Validate required fields
$required = ['commercial_id', 'channel', 'start_date', 'start_time']; $required = ['infomercial_id', 'channel', 'start_date', 'start_time'];
foreach ($required as $field) { foreach ($required as $field) {
if (empty($input[$field])) { if (empty($input[$field])) {
jsonResponse([ jsonResponse([
@ -50,15 +50,15 @@ try {
], 400); ], 400);
} }
// Get commercial details (duration) // Get infomercial details (duration)
$stmt = $db->prepare("SELECT duration, title FROM commercials WHERE id = ?"); $stmt = $db->prepare("SELECT duration, title FROM infomercials WHERE id = ?");
$stmt->execute([$input['commercial_id']]); $stmt->execute([$input['infomercial_id']]);
$commercial = $stmt->fetch(); $infomercial = $stmt->fetch();
if (!$commercial) { if (!$infomercial) {
jsonResponse([ jsonResponse([
'success' => false, 'success' => false,
'error' => 'Commercial not found' 'error' => 'Infomercial not found'
], 404); ], 404);
} }
@ -66,7 +66,7 @@ try {
$template = $input['template'] ?? 'HOME030'; $template = $input['template'] ?? 'HOME030';
// Calculate end time // Calculate end time
$endTime = addTimeToTime($input['start_time'], $commercial['duration']); $endTime = addTimeToTime($input['start_time'], $infomercial['duration']);
// Validate that transmission falls within a block (inline to avoid curl issues) // Validate that transmission falls within a block (inline to avoid curl issues)
ensureDailyBlocks($db, $input['start_date'], $input['start_date']); ensureDailyBlocks($db, $input['start_date'], $input['start_date']);
@ -126,7 +126,7 @@ try {
$stmt = $db->prepare(" $stmt = $db->prepare("
SELECT t.id, t.start_time, t.duration, c.title SELECT t.id, t.start_time, t.duration, c.title
FROM transmissions t FROM transmissions t
JOIN commercials c ON t.commercial_id = c.id JOIN infomercials c ON t.infomercial_id = c.id
WHERE t.start_date = ? WHERE t.start_date = ?
AND t.channel = ? AND t.channel = ?
AND t.id != ? AND t.id != ?
@ -152,17 +152,17 @@ try {
// Insert transmission // Insert transmission
$stmt = $db->prepare(" $stmt = $db->prepare("
INSERT INTO transmissions INSERT INTO transmissions
(commercial_id, channel, template, start_date, start_time, duration, api_status) (infomercial_id, channel, template, start_date, start_time, duration, api_status)
VALUES (?, ?, ?, ?, ?, ?, 'pending') VALUES (?, ?, ?, ?, ?, ?, 'pending')
"); ");
$stmt->execute([ $stmt->execute([
$input['commercial_id'], $input['infomercial_id'],
$input['channel'], $input['channel'],
$template, $template,
$input['start_date'], $input['start_date'],
$input['start_time'], $input['start_time'],
$commercial['duration'] $infomercial['duration']
]); ]);
$transmissionId = $db->lastInsertId(); $transmissionId = $db->lastInsertId();
@ -175,7 +175,7 @@ try {
c.color_code, c.color_code,
c.series_code c.series_code
FROM transmissions t FROM transmissions t
JOIN commercials c ON t.commercial_id = c.id JOIN infomercials c ON t.infomercial_id = c.id
WHERE t.id = ? WHERE t.id = ?
"); ");
$stmt->execute([$transmissionId]); $stmt->execute([$transmissionId]);

View File

@ -29,7 +29,7 @@ try {
$sql = " $sql = "
SELECT SELECT
t.id, t.id,
t.commercial_id, t.infomercial_id,
t.channel, t.channel,
t.template, t.template,
t.start_date, t.start_date,
@ -40,7 +40,7 @@ try {
c.color_code, c.color_code,
c.series_code c.series_code
FROM transmissions t FROM transmissions t
JOIN commercials c ON t.commercial_id = c.id JOIN infomercials c ON t.infomercial_id = c.id
WHERE t.start_date BETWEEN ? AND ? WHERE t.start_date BETWEEN ? AND ?
"; ";
@ -79,7 +79,7 @@ try {
'borderColor' => $tx['color_code'] ?? '#cccccc', 'borderColor' => $tx['color_code'] ?? '#cccccc',
'textColor' => '#ffffff', 'textColor' => '#ffffff',
'extendedProps' => [ 'extendedProps' => [
'commercial_id' => $tx['commercial_id'], 'infomercial_id' => $tx['infomercial_id'],
'template' => $tx['template'], 'template' => $tx['template'],
'duration' => $tx['duration'], 'duration' => $tx['duration'],
'api_status' => $tx['api_status'], 'api_status' => $tx['api_status'],

View File

@ -25,7 +25,7 @@ try {
} }
// Validate required fields // Validate required fields
$required = ['commercial_id', 'channel', 'date', 'block_id', 'position']; $required = ['infomercial_id', 'channel', 'date', 'block_id', 'position'];
foreach ($required as $field) { foreach ($required as $field) {
if (!isset($input[$field])) { if (!isset($input[$field])) {
jsonResponse([ jsonResponse([
@ -35,15 +35,15 @@ try {
} }
} }
// Get commercial duration // Get infomercial duration
$stmt = $db->prepare("SELECT duration FROM commercials WHERE id = ?"); $stmt = $db->prepare("SELECT duration FROM infomercials WHERE id = ?");
$stmt->execute([$input['commercial_id']]); $stmt->execute([$input['infomercial_id']]);
$duration = $stmt->fetchColumn(); $duration = $stmt->fetchColumn();
if (!$duration) { if (!$duration) {
jsonResponse([ jsonResponse([
'success' => false, 'success' => false,
'error' => 'Commercial not found' 'error' => 'Infomercial not found'
], 404); ], 404);
} }
@ -58,7 +58,7 @@ try {
$stmt = $db->prepare(" $stmt = $db->prepare("
SELECT t.id, t.start_time, c.duration SELECT t.id, t.start_time, c.duration
FROM transmissions t FROM transmissions t
JOIN commercials c ON t.commercial_id = c.id JOIN infomercials c ON t.infomercial_id = c.id
WHERE t.start_date = ? AND t.channel = ? WHERE t.start_date = ? AND t.channel = ?
AND t.start_time >= ? AND t.start_time < ? AND t.start_time >= ? AND t.start_time < ?
ORDER BY t.start_time ASC ORDER BY t.start_time ASC
@ -71,7 +71,7 @@ try {
// Create temporary transmission entry // Create temporary transmission entry
$newTransmission = [ $newTransmission = [
'commercial_id' => $input['commercial_id'], 'infomercial_id' => $input['infomercial_id'],
'duration' => $duration 'duration' => $duration
]; ];
@ -86,11 +86,11 @@ try {
// Insert new transmission // Insert new transmission
$stmt = $db->prepare(" $stmt = $db->prepare("
INSERT INTO transmissions INSERT INTO transmissions
(commercial_id, channel, template, start_date, start_time, duration, api_status) (infomercial_id, channel, template, start_date, start_time, duration, api_status)
VALUES (?, ?, 'HOME030', ?, ?, ?, 'pending') VALUES (?, ?, 'HOME030', ?, ?, ?, 'pending')
"); ");
$stmt->execute([ $stmt->execute([
$input['commercial_id'], $input['infomercial_id'],
$input['channel'], $input['channel'],
$input['date'], $input['date'],
$currentTime, $currentTime,

View File

@ -47,7 +47,7 @@ try {
$stmt = $db->prepare(" $stmt = $db->prepare("
SELECT t.*, c.content_id, c.title as commercial_title SELECT t.*, c.content_id, c.title as commercial_title
FROM transmissions t FROM transmissions t
JOIN commercials c ON t.commercial_id = c.id JOIN infomercials c ON t.infomercial_id = c.id
WHERE t.start_date = ? WHERE t.start_date = ?
AND t.channel = ? AND t.channel = ?
AND t.api_status != 'synced' AND t.api_status != 'synced'

View File

@ -107,7 +107,7 @@ try {
$stmt = $db->prepare(" $stmt = $db->prepare("
SELECT t.id, t.start_time, c.duration SELECT t.id, t.start_time, c.duration
FROM transmissions t FROM transmissions t
JOIN commercials c ON t.commercial_id = c.id JOIN infomercials c ON t.infomercial_id = c.id
WHERE t.start_date = ? AND t.channel = ? WHERE t.start_date = ? AND t.channel = ?
ORDER BY t.start_time ASC ORDER BY t.start_time ASC
"); ");

View File

@ -36,7 +36,7 @@ try {
$stmt = $db->prepare(" $stmt = $db->prepare("
SELECT t.*, c.duration SELECT t.*, c.duration
FROM transmissions t FROM transmissions t
JOIN commercials c ON t.commercial_id = c.id JOIN infomercials c ON t.infomercial_id = c.id
WHERE t.id = ? WHERE t.id = ?
"); ");
$stmt->execute([$input['id']]); $stmt->execute([$input['id']]);
@ -136,7 +136,7 @@ try {
$stmt = $db->prepare(" $stmt = $db->prepare("
SELECT t.id, t.start_time, t.duration, c.title SELECT t.id, t.start_time, t.duration, c.title
FROM transmissions t FROM transmissions t
JOIN commercials c ON t.commercial_id = c.id JOIN infomercials c ON t.infomercial_id = c.id
WHERE t.start_date = ? WHERE t.start_date = ?
AND t.channel = ? AND t.channel = ?
AND t.id != ? AND t.id != ?
@ -175,7 +175,7 @@ try {
c.color_code, c.color_code,
c.series_code c.series_code
FROM transmissions t FROM transmissions t
JOIN commercials c ON t.commercial_id = c.id JOIN infomercials c ON t.infomercial_id = c.id
WHERE t.id = ? WHERE t.id = ?
"); ");
$stmt->execute([$input['id']]); $stmt->execute([$input['id']]);

View File

@ -238,8 +238,8 @@ body {
border-right: 3px solid rgba(0,0,0,0.2); border-right: 3px solid rgba(0,0,0,0.2);
} }
/* Commercial Sidebar */ /* Infomercial Sidebar */
.commercial-sidebar { .infomercial-sidebar {
max-height: 600px; max-height: 600px;
overflow-y: auto; overflow-y: auto;
background: #f8f9fa; background: #f8f9fa;
@ -247,7 +247,7 @@ body {
padding: 15px; padding: 15px;
} }
.commercial-item { .infomercial-item {
background: white; background: white;
border-radius: 6px; border-radius: 6px;
padding: 12px; padding: 12px;
@ -258,27 +258,27 @@ body {
box-shadow: 0 1px 3px rgba(0,0,0,0.1); box-shadow: 0 1px 3px rgba(0,0,0,0.1);
} }
.commercial-item:hover { .infomercial-item:hover {
transform: translateX(5px); transform: translateX(5px);
box-shadow: 0 2px 8px rgba(0,0,0,0.15); box-shadow: 0 2px 8px rgba(0,0,0,0.15);
} }
.commercial-item.dragging { .infomercial-item.dragging {
opacity: 0.5; opacity: 0.5;
} }
.commercial-title { .infomercial-title {
font-weight: 600; font-weight: 600;
font-size: 0.95rem; font-size: 0.95rem;
margin-bottom: 4px; margin-bottom: 4px;
} }
.commercial-duration { .infomercial-duration {
font-size: 0.85rem; font-size: 0.85rem;
color: #6c757d; color: #6c757d;
} }
.commercial-series { .infomercial-series {
font-size: 0.8rem; font-size: 0.8rem;
font-weight: 500; font-weight: 500;
opacity: 0.8; opacity: 0.8;
@ -336,7 +336,7 @@ body {
/* Responsive */ /* Responsive */
@media (max-width: 768px) { @media (max-width: 768px) {
.commercial-sidebar { .infomercial-sidebar {
max-height: 300px; max-height: 300px;
margin-bottom: 20px; margin-bottom: 20px;
} }
@ -347,21 +347,21 @@ body {
} }
/* Scrollbar Styling */ /* Scrollbar Styling */
.commercial-sidebar::-webkit-scrollbar { .infomercial-sidebar::-webkit-scrollbar {
width: 8px; width: 8px;
} }
.commercial-sidebar::-webkit-scrollbar-track { .infomercial-sidebar::-webkit-scrollbar-track {
background: #f1f1f1; background: #f1f1f1;
border-radius: 4px; border-radius: 4px;
} }
.commercial-sidebar::-webkit-scrollbar-thumb { .infomercial-sidebar::-webkit-scrollbar-thumb {
background: #888; background: #888;
border-radius: 4px; border-radius: 4px;
} }
.commercial-sidebar::-webkit-scrollbar-thumb:hover { .infomercial-sidebar::-webkit-scrollbar-thumb:hover {
background: #555; background: #555;
} }
@ -475,7 +475,7 @@ body {
@media print { @media print {
.navbar, .navbar,
.btn, .btn,
.commercial-sidebar { .infomercial-sidebar {
display: none !important; display: none !important;
} }

View File

@ -174,7 +174,7 @@ document.addEventListener('DOMContentLoaded', function() {
// Event resize (change duration) // Event resize (change duration)
eventResize: function(info) { eventResize: function(info) {
showAlert('warning', 'Duur aanpassen is niet toegestaan. Gebruik de commercial instellingen.'); showAlert('warning', 'Duur aanpassen is niet toegestaan. Gebruik de infomercial instellingen.');
info.revert(); info.revert();
}, },
@ -185,7 +185,7 @@ document.addEventListener('DOMContentLoaded', function() {
// Event receive (when external event is dropped) // Event receive (when external event is dropped)
eventReceive: function(info) { eventReceive: function(info) {
const event = info.event; const event = info.event;
const commercialId = event.extendedProps.commercial_id || info.draggedEl.dataset.commercialId; const commercialId = event.extendedProps.infomercial_id || info.draggedEl.dataset.commercialId;
const resourceId = event.getResources()[0]?.id || 'SBS9'; const resourceId = event.getResources()[0]?.id || 'SBS9';
// Remove the temporary event // Remove the temporary event
@ -214,7 +214,7 @@ document.addEventListener('DOMContentLoaded', function() {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify({ body: JSON.stringify({
commercial_id: commercialId, infomercial_id: commercialId,
channel: resourceId, channel: resourceId,
start_date: dropDate, start_date: dropDate,
start_time: startTime start_time: startTime
@ -309,10 +309,10 @@ document.addEventListener('DOMContentLoaded', function() {
}); });
/** /**
* Initialize draggable commercials from sidebar * Initialize draggable infomercials from sidebar
*/ */
function initDraggableCommercials() { function initDraggableCommercials() {
const commercialItems = document.querySelectorAll('.commercial-item'); const commercialItems = document.querySelectorAll('.infomercial-item');
commercialItems.forEach(item => { commercialItems.forEach(item => {
new FullCalendar.Draggable(item, { new FullCalendar.Draggable(item, {
@ -323,7 +323,7 @@ function initDraggableCommercials() {
backgroundColor: eventEl.dataset.color, backgroundColor: eventEl.dataset.color,
borderColor: eventEl.dataset.color, borderColor: eventEl.dataset.color,
extendedProps: { extendedProps: {
commercial_id: eventEl.dataset.commercialId, infomercial_id: eventEl.dataset.commercialId,
series_code: eventEl.dataset.seriesCode series_code: eventEl.dataset.seriesCode
} }
}; };
@ -469,10 +469,10 @@ function showAlert(type, message) {
} }
/** /**
* Filter commercials in sidebar * Filter infomercials in sidebar
*/ */
function filterCommercials(searchTerm) { function filterCommercials(searchTerm) {
const items = document.querySelectorAll('.commercial-item'); const items = document.querySelectorAll('.infomercial-item');
const term = searchTerm.toLowerCase(); const term = searchTerm.toLowerCase();
items.forEach(item => { items.forEach(item => {

View File

@ -114,7 +114,7 @@ $dayNames = [
<a class="nav-link" href="planner.php">Excel Planner</a> <a class="nav-link" href="planner.php">Excel Planner</a>
<a class="nav-link" href="calendar.php">Kalender</a> <a class="nav-link" href="calendar.php">Kalender</a>
<a class="nav-link active" href="blocks.php">Blokken</a> <a class="nav-link active" href="blocks.php">Blokken</a>
<a class="nav-link" href="commercials.php">Commercials</a> <a class="nav-link" href="infomercials.php">Infomercials</a>
</div> </div>
</div> </div>
</nav> </nav>

View File

@ -17,30 +17,30 @@ $dotenv->load();
$db = getDbConnection(); $db = getDbConnection();
// Get all commercials with colors for sidebar // Get all infomercials with colors for sidebar
$commercials = $db->query(" $infomercials = $db->query("
SELECT id, title, duration, color_code, series_code, upload_status SELECT id, title, duration, color_code, series_code, upload_status
FROM commercials FROM infomercials
WHERE upload_status = 'uploaded' WHERE upload_status = 'uploaded'
ORDER BY title ASC ORDER BY title ASC
")->fetchAll(); ")->fetchAll();
// Auto-assign colors to commercials without colors // Auto-assign colors to infomercials without colors
foreach ($commercials as $commercial) { foreach ($infomercials as $infomercial) {
if (empty($commercial['color_code'])) { if (empty($infomercial['color_code'])) {
$stmt = $db->query("SELECT color_code FROM commercials WHERE color_code IS NOT NULL"); $stmt = $db->query("SELECT color_code FROM infomercials WHERE color_code IS NOT NULL");
$existingColors = $stmt->fetchAll(PDO::FETCH_COLUMN); $existingColors = $stmt->fetchAll(PDO::FETCH_COLUMN);
$newColor = generateDistinctColor($existingColors); $newColor = generateDistinctColor($existingColors);
$stmt = $db->prepare("UPDATE commercials SET color_code = ? WHERE id = ?"); $stmt = $db->prepare("UPDATE infomercials SET color_code = ? WHERE id = ?");
$stmt->execute([$newColor, $commercial['id']]); $stmt->execute([$newColor, $infomercial['id']]);
} }
} }
// Refresh commercials after color assignment // Refresh infomercials after color assignment
$commercials = $db->query(" $infomercials = $db->query("
SELECT id, title, duration, color_code, series_code, upload_status SELECT id, title, duration, color_code, series_code, upload_status
FROM commercials FROM infomercials
WHERE upload_status = 'uploaded' WHERE upload_status = 'uploaded'
ORDER BY title ASC ORDER BY title ASC
")->fetchAll(); ")->fetchAll();
@ -74,7 +74,7 @@ $commercials = $db->query("
<a class="nav-link" href="planner.php">Excel Planner</a> <a class="nav-link" href="planner.php">Excel Planner</a>
<a class="nav-link active" href="calendar.php">Kalender</a> <a class="nav-link active" href="calendar.php">Kalender</a>
<a class="nav-link" href="blocks.php">Blokken</a> <a class="nav-link" href="blocks.php">Blokken</a>
<a class="nav-link" href="commercials.php">Commercials</a> <a class="nav-link" href="infomercials.php">Infomercials</a>
</div> </div>
</div> </div>
</nav> </nav>
@ -128,12 +128,12 @@ $commercials = $db->query("
</div> </div>
<div class="row"> <div class="row">
<!-- Sidebar with draggable commercials --> <!-- Sidebar with draggable infomercials -->
<div class="col-md-3"> <div class="col-md-3">
<div class="card shadow-sm"> <div class="card shadow-sm">
<div class="card-header bg-primary text-white"> <div class="card-header bg-primary text-white">
<h5 class="mb-0"> <h5 class="mb-0">
<i class="bi bi-collection-play"></i> Beschikbare Commercials <i class="bi bi-collection-play"></i> Beschikbare Infomercials
</h5> </h5>
</div> </div>
<div class="card-body p-2"> <div class="card-body p-2">
@ -145,40 +145,40 @@ $commercials = $db->query("
onkeyup="filterCommercials(this.value)"> onkeyup="filterCommercials(this.value)">
</div> </div>
<!-- Commercial List --> <!-- Infomercial List -->
<div class="commercial-sidebar"> <div class="infomercial-sidebar">
<?php if (empty($commercials)): ?> <?php if (empty($infomercials)): ?>
<div class="text-center text-muted p-3"> <div class="text-center text-muted p-3">
<i class="bi bi-inbox" style="font-size: 2rem;"></i> <i class="bi bi-inbox" style="font-size: 2rem;"></i>
<p class="mt-2 small">Geen commercials beschikbaar</p> <p class="mt-2 small">Geen infomercials beschikbaar</p>
<a href="commercials.php" class="btn btn-sm btn-primary"> <a href="infomercials.php" class="btn btn-sm btn-primary">
Voeg Commercial Toe Voeg Infomercial Toe
</a> </a>
</div> </div>
<?php else: ?> <?php else: ?>
<?php foreach ($commercials as $commercial): ?> <?php foreach ($infomercials as $infomercial): ?>
<div class="commercial-item" <div class="infomercial-item"
style="border-left-color: <?= htmlspecialchars($commercial['color_code']) ?>;" style="border-left-color: <?= htmlspecialchars($infomercial['color_code']) ?>;"
data-commercial-id="<?= $commercial['id'] ?>" data-infomercial-id="<?= $infomercial['id'] ?>"
data-title="<?= htmlspecialchars($commercial['title']) ?>" data-title="<?= htmlspecialchars($infomercial['title']) ?>"
data-duration="<?= $commercial['duration'] ?>" data-duration="<?= $infomercial['duration'] ?>"
data-color="<?= htmlspecialchars($commercial['color_code']) ?>" data-color="<?= htmlspecialchars($infomercial['color_code']) ?>"
data-series-code="<?= htmlspecialchars($commercial['series_code'] ?? '') ?>"> data-series-code="<?= htmlspecialchars($infomercial['series_code'] ?? '') ?>">
<div class="d-flex align-items-center"> <div class="d-flex align-items-center">
<div class="color-preview me-2" <div class="color-preview me-2"
style="background-color: <?= htmlspecialchars($commercial['color_code']) ?>; width: 20px; height: 20px; border-radius: 3px;"> style="background-color: <?= htmlspecialchars($infomercial['color_code']) ?>; width: 20px; height: 20px; border-radius: 3px;">
</div> </div>
<div class="flex-grow-1"> <div class="flex-grow-1">
<div class="commercial-title"> <div class="infomercial-title">
<?= htmlspecialchars($commercial['title']) ?> <?= htmlspecialchars($infomercial['title']) ?>
</div> </div>
<div class="commercial-duration"> <div class="infomercial-duration">
<i class="bi bi-clock"></i> <?= $commercial['duration'] ?> <i class="bi bi-clock"></i> <?= $infomercial['duration'] ?>
</div> </div>
<?php if ($commercial['series_code']): ?> <?php if ($infomercial['series_code']): ?>
<div class="commercial-series"> <div class="infomercial-series">
<i class="bi bi-tag"></i> <?= htmlspecialchars($commercial['series_code']) ?> <i class="bi bi-tag"></i> <?= htmlspecialchars($infomercial['series_code']) ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
</div> </div>
@ -194,7 +194,7 @@ $commercials = $db->query("
<div class="mt-3 p-2 bg-light rounded"> <div class="mt-3 p-2 bg-light rounded">
<small class="text-muted"> <small class="text-muted">
<i class="bi bi-info-circle"></i> <i class="bi bi-info-circle"></i>
Sleep commercials naar de kalender om te plannen Sleep infomercials naar de kalender om te plannen
</small> </small>
</div> </div>
</div> </div>
@ -209,9 +209,9 @@ $commercials = $db->query("
<div class="small"> <div class="small">
<?php <?php
$uniqueColors = []; $uniqueColors = [];
foreach ($commercials as $commercial) { foreach ($infomercials as $infomercial) {
if ($commercial['series_code'] && !isset($uniqueColors[$commercial['series_code']])) { if ($infomercial['series_code'] && !isset($uniqueColors[$infomercial['series_code']])) {
$uniqueColors[$commercial['series_code']] = $commercial['color_code']; $uniqueColors[$infomercial['series_code']] = $infomercial['color_code'];
} }
} }
?> ?>

View File

@ -16,7 +16,7 @@ $db = new PDO("mysql:host={$_ENV['DB_HOST']};dbname={$_ENV['DB_NAME']}", $_ENV['
// Array om logs voor console te verzamelen // Array om logs voor console te verzamelen
$apiLogs = []; $apiLogs = [];
// 1. Registratie Commercial (Stap 1, 2, 4) // 1. Registratie Infomercial (Stap 1, 2, 4)
if (isset($_POST['add_commercial'])) { if (isset($_POST['add_commercial'])) {
$ep = $api->createEpisode($_POST['title'], $_POST['duration'], $_POST['season_id']); $ep = $api->createEpisode($_POST['title'], $_POST['duration'], $_POST['season_id']);
$apiLogs[] = ['call' => 'Create Episode', 'response' => $api->lastResponse]; $apiLogs[] = ['call' => 'Create Episode', 'response' => $api->lastResponse];
@ -30,7 +30,7 @@ if (isset($_POST['add_commercial'])) {
$apiLogs[] = ['call' => 'Get Media Asset Details', 'response' => $api->lastResponse]; $apiLogs[] = ['call' => 'Get Media Asset Details', 'response' => $api->lastResponse];
$label = $details['mediaAssetLabel'] ?? 'Pending'; $label = $details['mediaAssetLabel'] ?? 'Pending';
$stmt = $db->prepare("INSERT INTO commercials (title, duration, season_id, content_id, media_asset_id, media_asset_label, upload_status) VALUES (?, ?, ?, ?, ?, ?, 'pending')"); $stmt = $db->prepare("INSERT INTO infomercials (title, duration, season_id, content_id, media_asset_id, media_asset_label, upload_status) VALUES (?, ?, ?, ?, ?, ?, 'pending')");
$stmt->execute([$_POST['title'], $_POST['duration'], $_POST['season_id'], $ep['id'], $asset['id'], $label]); $stmt->execute([$_POST['title'], $_POST['duration'], $_POST['season_id'], $ep['id'], $asset['id'], $label]);
} }
} }
@ -38,16 +38,16 @@ if (isset($_POST['add_commercial'])) {
// 2. LOKALE Planning opslaan of bewerken // 2. LOKALE Planning opslaan of bewerken
if (isset($_POST['schedule_transmission'])) { if (isset($_POST['schedule_transmission'])) {
$stmt = $db->prepare("SELECT duration FROM commercials WHERE id = ?"); $stmt = $db->prepare("SELECT duration FROM infomercials WHERE id = ?");
$stmt->execute([$_POST['commercial_id']]); $stmt->execute([$_POST['infomercial_id']]);
$commDuration = $stmt->fetchColumn(); $commDuration = $stmt->fetchColumn();
if (!empty($_POST['edit_id'])) { if (!empty($_POST['edit_id'])) {
$stmt = $db->prepare("UPDATE transmissions SET commercial_id=?, channel=?, template=?, start_date=?, start_time=?, duration=?, api_status='pending' WHERE id=?"); $stmt = $db->prepare("UPDATE transmissions SET infomercial_id=?, channel=?, template=?, start_date=?, start_time=?, duration=?, api_status='pending' WHERE id=?");
$stmt->execute([$_POST['commercial_id'], $_POST['channel'], $_POST['template'], $_POST['start_date'], $_POST['start_time'], $commDuration, $_POST['edit_id']]); $stmt->execute([$_POST['infomercial_id'], $_POST['channel'], $_POST['template'], $_POST['start_date'], $_POST['start_time'], $commDuration, $_POST['edit_id']]);
} else { } else {
$stmt = $db->prepare("INSERT INTO transmissions (commercial_id, channel, template, start_date, start_time, duration, api_status) VALUES (?, ?, ?, ?, ?, ?, 'pending')"); $stmt = $db->prepare("INSERT INTO transmissions (infomercial_id, channel, template, start_date, start_time, duration, api_status) VALUES (?, ?, ?, ?, ?, ?, 'pending')");
$stmt->execute([$_POST['commercial_id'], $_POST['channel'], $_POST['template'], $_POST['start_date'], $_POST['start_time'], $commDuration]); $stmt->execute([$_POST['infomercial_id'], $_POST['channel'], $_POST['template'], $_POST['start_date'], $_POST['start_time'], $commDuration]);
} }
header("Location: index.php?view_date=" . $_POST['start_date']); header("Location: index.php?view_date=" . $_POST['start_date']);
exit; exit;
@ -55,7 +55,7 @@ if (isset($_POST['schedule_transmission'])) {
// 3. Handmatige Sync naar Talpa (Stap 3 op verzoek) // 3. Handmatige Sync naar Talpa (Stap 3 op verzoek)
if (isset($_POST['sync_item'])) { if (isset($_POST['sync_item'])) {
$stmt = $db->prepare("SELECT t.*, c.content_id FROM transmissions t JOIN commercials c ON t.commercial_id = c.id WHERE t.id = ?"); $stmt = $db->prepare("SELECT t.*, c.content_id FROM transmissions t JOIN infomercials c ON t.infomercial_id = c.id WHERE t.id = ?");
$stmt->execute([$_POST['sync_id']]); $stmt->execute([$_POST['sync_id']]);
$tx = $stmt->fetch(); $tx = $stmt->fetch();
@ -76,16 +76,16 @@ if (isset($_POST['sync_item'])) {
// 4. Media Asset Label en Status bijwerken // 4. Media Asset Label en Status bijwerken
if (isset($_POST['update_media_asset'])) { if (isset($_POST['update_media_asset'])) {
$stmt = $db->prepare("UPDATE commercials SET media_asset_label = ?, upload_status = ? WHERE id = ?"); $stmt = $db->prepare("UPDATE infomercials SET media_asset_label = ?, upload_status = ? WHERE id = ?");
$stmt->execute([$_POST['media_asset_label'], $_POST['upload_status'], $_POST['commercial_id']]); $stmt->execute([$_POST['media_asset_label'], $_POST['upload_status'], $_POST['infomercial_id']]);
header("Location: index.php?view_date=" . $selectedDate); header("Location: index.php?view_date=" . $selectedDate);
exit; exit;
} }
// Data ophalen // Data ophalen
$commercials = $db->query("SELECT * FROM commercials ORDER BY created_at DESC")->fetchAll(); $infomercials = $db->query("SELECT * FROM infomercials ORDER BY created_at DESC")->fetchAll();
$selectedDate = $_GET['view_date'] ?? date('Y-m-d'); $selectedDate = $_GET['view_date'] ?? date('Y-m-d');
$stmt = $db->prepare("SELECT t.*, c.title, c.duration as comm_duration FROM transmissions t JOIN commercials c ON t.commercial_id = c.id WHERE t.start_date = ? ORDER BY t.start_time ASC"); $stmt = $db->prepare("SELECT t.*, c.title, c.duration as comm_duration FROM transmissions t JOIN infomercials c ON t.infomercial_id = c.id WHERE t.start_date = ? ORDER BY t.start_time ASC");
$stmt->execute([$selectedDate]); $stmt->execute([$selectedDate]);
$dailySchedule = $stmt->fetchAll(); $dailySchedule = $stmt->fetchAll();
@ -118,7 +118,7 @@ if (isset($_GET['edit'])) {
<a class="nav-link" href="planner.php">Excel Planner</a> <a class="nav-link" href="planner.php">Excel Planner</a>
<a class="nav-link" href="calendar.php">Kalender</a> <a class="nav-link" href="calendar.php">Kalender</a>
<a class="nav-link" href="blocks.php">Blokken</a> <a class="nav-link" href="blocks.php">Blokken</a>
<a class="nav-link" href="commercials.php">Commercials</a> <a class="nav-link" href="infomercials.php">Infomercials</a>
</div> </div>
</div> </div>
</nav> </nav>
@ -134,8 +134,8 @@ if (isset($_GET['edit'])) {
<!-- Statistics Cards --> <!-- Statistics Cards -->
<div class="row mb-4"> <div class="row mb-4">
<?php <?php
$totalCommercials = $db->query("SELECT COUNT(*) FROM commercials")->fetchColumn(); $totalCommercials = $db->query("SELECT COUNT(*) FROM infomercials")->fetchColumn();
$uploadedCommercials = $db->query("SELECT COUNT(*) FROM commercials WHERE upload_status = 'uploaded'")->fetchColumn(); $uploadedCommercials = $db->query("SELECT COUNT(*) FROM infomercials WHERE upload_status = 'uploaded'")->fetchColumn();
$totalTransmissions = $db->query("SELECT COUNT(*) FROM transmissions")->fetchColumn(); $totalTransmissions = $db->query("SELECT COUNT(*) FROM transmissions")->fetchColumn();
$pendingSync = $db->query("SELECT COUNT(*) FROM transmissions WHERE api_status = 'pending'")->fetchColumn(); $pendingSync = $db->query("SELECT COUNT(*) FROM transmissions WHERE api_status = 'pending'")->fetchColumn();
$syncedTransmissions = $db->query("SELECT COUNT(*) FROM transmissions WHERE api_status = 'synced'")->fetchColumn(); $syncedTransmissions = $db->query("SELECT COUNT(*) FROM transmissions WHERE api_status = 'synced'")->fetchColumn();
@ -144,7 +144,7 @@ if (isset($_GET['edit'])) {
<div class="col-md-3"> <div class="col-md-3">
<div class="stat-card"> <div class="stat-card">
<div class="stat-number"><?= $totalCommercials ?></div> <div class="stat-number"><?= $totalCommercials ?></div>
<div class="stat-label">Totaal Commercials</div> <div class="stat-label">Totaal Infomercials</div>
</div> </div>
</div> </div>
@ -202,10 +202,10 @@ if (isset($_GET['edit'])) {
<div class="card shadow-sm h-100"> <div class="card shadow-sm h-100">
<div class="card-body text-center"> <div class="card-body text-center">
<i class="bi bi-collection-play" style="font-size: 3rem; color: #e74c3c;"></i> <i class="bi bi-collection-play" style="font-size: 3rem; color: #e74c3c;"></i>
<h5 class="mt-3">Commercials</h5> <h5 class="mt-3">Infomercials</h5>
<p class="text-muted">Registreer en beheer</p> <p class="text-muted">Registreer en beheer</p>
<a href="commercials.php" class="btn btn-danger"> <a href="infomercials.php" class="btn btn-danger">
<i class="bi bi-arrow-right-circle"></i> Naar Commercials <i class="bi bi-arrow-right-circle"></i> Naar Infomercials
</a> </a>
</div> </div>
</div> </div>
@ -230,7 +230,7 @@ if (isset($_GET['edit'])) {
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-4">
<div class="card p-3 shadow-sm"> <div class="card p-3 shadow-sm">
<h5>1. Commercial Registreren</h5> <h5>1. Infomercial Registreren</h5>
<form method="POST"> <form method="POST">
<input type="text" name="title" class="form-control mb-2" placeholder="Product Naam" required> <input type="text" name="title" class="form-control mb-2" placeholder="Product Naam" required>
<input type="text" name="duration" class="form-control mb-2" placeholder="Duur (HH:MM:SS)" required> <input type="text" name="duration" class="form-control mb-2" placeholder="Duur (HH:MM:SS)" required>
@ -246,10 +246,10 @@ if (isset($_GET['edit'])) {
<form method="POST" class="row g-2" id="planningForm"> <form method="POST" class="row g-2" id="planningForm">
<input type="hidden" name="edit_id" value="<?= $editItem['id'] ?? '' ?>"> <input type="hidden" name="edit_id" value="<?= $editItem['id'] ?? '' ?>">
<div class="col-md-6"> <div class="col-md-6">
<select name="commercial_id" id="commercial_select" class="form-select" required> <select name="infomercial_id" id="commercial_select" class="form-select" required>
<option value="">Selecteer Commercial...</option> <option value="">Selecteer Infomercial...</option>
<?php foreach($commercials as $c): ?> <?php foreach($infomercials as $c): ?>
<option value="<?= $c['id'] ?>" data-duration="<?= $c['duration'] ?>" <?= (isset($editItem) && $editItem['commercial_id'] == $c['id']) ? 'selected' : '' ?>> <option value="<?= $c['id'] ?>" data-duration="<?= $c['duration'] ?>" <?= (isset($editItem) && $editItem['infomercial_id'] == $c['id']) ? 'selected' : '' ?>>
<?= htmlspecialchars($c['title']) ?> <?= htmlspecialchars($c['title']) ?>
</option> </option>
<?php endforeach; ?> <?php endforeach; ?>
@ -348,10 +348,10 @@ if (isset($_GET['edit'])) {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach($commercials as $c): ?> <?php foreach($infomercials as $c): ?>
<tr> <tr>
<form method="POST"> <form method="POST">
<input type="hidden" name="commercial_id" value="<?= $c['id'] ?>"> <input type="hidden" name="infomercial_id" value="<?= $c['id'] ?>">
<td><?= htmlspecialchars($c['title']) ?></td> <td><?= htmlspecialchars($c['title']) ?></td>
<td><span class="badge bg-info text-dark"><?= $c['duration'] ?></span></td> <td><span class="badge bg-info text-dark"><?= $c['duration'] ?></span></td>
<td><code><?= htmlspecialchars($c['content_id']) ?></code></td> <td><code><?= htmlspecialchars($c['content_id']) ?></code></td>

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* Commercial Management * Infomercial Management
* Enhanced version of commercial registration with color management * Enhanced version of infomercial registration with color management
*/ */
ini_set('display_errors', 1); ini_set('display_errors', 1);
@ -20,7 +20,7 @@ $api = new TalpaApi();
$db = getDbConnection(); $db = getDbConnection();
$apiLogs = []; $apiLogs = [];
// Handle commercial registration // Handle infomercial registration
if (isset($_POST['add_commercial'])) { if (isset($_POST['add_commercial'])) {
$apiLogs[] = ['step' => 'Start registration', 'input' => $_POST]; $apiLogs[] = ['step' => 'Start registration', 'input' => $_POST];
@ -51,13 +51,13 @@ if (isset($_POST['add_commercial'])) {
$apiLogs[] = ['step' => 'Media asset label', 'label' => $label]; $apiLogs[] = ['step' => 'Media asset label', 'label' => $label];
// Auto-generate color // Auto-generate color
$stmt = $db->query("SELECT color_code FROM commercials WHERE color_code IS NOT NULL"); $stmt = $db->query("SELECT color_code FROM infomercials WHERE color_code IS NOT NULL");
$existingColors = $stmt->fetchAll(PDO::FETCH_COLUMN); $existingColors = $stmt->fetchAll(PDO::FETCH_COLUMN);
$colorCode = generateDistinctColor($existingColors); $colorCode = generateDistinctColor($existingColors);
$apiLogs[] = ['step' => 'Color generated', 'color' => $colorCode]; $apiLogs[] = ['step' => 'Color generated', 'color' => $colorCode];
$stmt = $db->prepare(" $stmt = $db->prepare("
INSERT INTO commercials INSERT INTO infomercials
(title, duration, season_id, content_id, media_asset_id, media_asset_label, upload_status, color_code, series_code) (title, duration, season_id, content_id, media_asset_id, media_asset_label, upload_status, color_code, series_code)
VALUES (?, ?, ?, ?, ?, ?, 'pending', ?, ?) VALUES (?, ?, ?, ?, ?, ?, 'pending', ?, ?)
"); ");
@ -74,7 +74,7 @@ if (isset($_POST['add_commercial'])) {
$apiLogs[] = ['step' => 'Database insert', 'success' => true]; $apiLogs[] = ['step' => 'Database insert', 'success' => true];
header('Location: commercials.php?success=created'); header('Location: infomercials.php?success=created');
exit; exit;
} else { } else {
$apiLogs[] = ['step' => 'Media asset creation failed', 'response' => $asset]; $apiLogs[] = ['step' => 'Media asset creation failed', 'response' => $asset];
@ -87,7 +87,7 @@ if (isset($_POST['add_commercial'])) {
// Handle media asset update // Handle media asset update
if (isset($_POST['update_media_asset'])) { if (isset($_POST['update_media_asset'])) {
$stmt = $db->prepare(" $stmt = $db->prepare("
UPDATE commercials UPDATE infomercials
SET media_asset_label = ?, upload_status = ?, series_code = ?, color_code = ? SET media_asset_label = ?, upload_status = ?, series_code = ?, color_code = ?
WHERE id = ? WHERE id = ?
"); ");
@ -96,33 +96,33 @@ if (isset($_POST['update_media_asset'])) {
$_POST['upload_status'], $_POST['upload_status'],
$_POST['series_code'] ?? null, $_POST['series_code'] ?? null,
$_POST['color_code'], $_POST['color_code'],
$_POST['commercial_id'] $_POST['infomercial_id']
]); ]);
header('Location: commercials.php?success=updated'); header('Location: infomercials.php?success=updated');
exit; exit;
} }
// Handle delete // Handle delete
if (isset($_POST['delete_commercial'])) { if (isset($_POST['delete_commercial'])) {
// Check if commercial is used in transmissions // Check if infomercial is used in transmissions
$stmt = $db->prepare("SELECT COUNT(*) FROM transmissions WHERE commercial_id = ?"); $stmt = $db->prepare("SELECT COUNT(*) FROM transmissions WHERE infomercial_id = ?");
$stmt->execute([$_POST['commercial_id']]); $stmt->execute([$_POST['infomercial_id']]);
$count = $stmt->fetchColumn(); $count = $stmt->fetchColumn();
if ($count > 0) { if ($count > 0) {
header('Location: commercials.php?error=in_use'); header('Location: infomercials.php?error=in_use');
exit; exit;
} }
// Get commercial details before deletion // Get infomercial details before deletion
$stmt = $db->prepare("SELECT content_id, media_asset_id FROM commercials WHERE id = ?"); $stmt = $db->prepare("SELECT content_id, media_asset_id FROM infomercials WHERE id = ?");
$stmt->execute([$_POST['commercial_id']]); $stmt->execute([$_POST['infomercial_id']]);
$commercial = $stmt->fetch(); $infomercial = $stmt->fetch();
// Delete from Talpa API if content_id exists // Delete from Talpa API if content_id exists
if ($commercial && $commercial['content_id']) { if ($infomercial && $infomercial['content_id']) {
try { try {
$api->deleteEpisode($commercial['content_id']); $api->deleteEpisode($infomercial['content_id']);
$apiLogs[] = ['call' => 'Delete Episode', 'response' => $api->lastResponse]; $apiLogs[] = ['call' => 'Delete Episode', 'response' => $api->lastResponse];
} catch (Exception $e) { } catch (Exception $e) {
// Log error but continue with local deletion // Log error but continue with local deletion
@ -131,17 +131,17 @@ if (isset($_POST['delete_commercial'])) {
} }
// Delete from local database // Delete from local database
$stmt = $db->prepare("DELETE FROM commercials WHERE id = ?"); $stmt = $db->prepare("DELETE FROM infomercials WHERE id = ?");
$stmt->execute([$_POST['commercial_id']]); $stmt->execute([$_POST['infomercial_id']]);
header('Location: commercials.php?success=deleted'); header('Location: infomercials.php?success=deleted');
exit; exit;
} }
// Get all commercials // Get all infomercials
$commercials = $db->query(" $infomercials = $db->query("
SELECT c.*, SELECT c.*,
(SELECT COUNT(*) FROM transmissions WHERE commercial_id = c.id) as usage_count (SELECT COUNT(*) FROM transmissions WHERE infomercial_id = c.id) as usage_count
FROM commercials c FROM infomercials c
ORDER BY c.created_at DESC ORDER BY c.created_at DESC
")->fetchAll(); ")->fetchAll();
?> ?>
@ -151,7 +151,7 @@ $commercials = $db->query("
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Commercials - Telvero Talpa</title> <title>Infomercials - Telvero Talpa</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
<link rel="stylesheet" href="assets/css/custom.css"> <link rel="stylesheet" href="assets/css/custom.css">
@ -167,14 +167,14 @@ $commercials = $db->query("
<a class="nav-link" href="planner.php">Excel Planner</a> <a class="nav-link" href="planner.php">Excel Planner</a>
<a class="nav-link" href="calendar.php">Kalender</a> <a class="nav-link" href="calendar.php">Kalender</a>
<a class="nav-link" href="blocks.php">Blokken</a> <a class="nav-link" href="blocks.php">Blokken</a>
<a class="nav-link active" href="commercials.php">Commercials</a> <a class="nav-link active" href="infomercials.php">Infomercials</a>
</div> </div>
</div> </div>
</nav> </nav>
<div class="container mt-4"> <div class="container mt-4">
<div class="d-flex justify-content-between align-items-center mb-4"> <div class="d-flex justify-content-between align-items-center mb-4">
<h1><i class="bi bi-collection-play"></i> Commercial Management</h1> <h1><i class="bi bi-collection-play"></i> Infomercial Management</h1>
<a href="calendar.php" class="btn btn-primary"> <a href="calendar.php" class="btn btn-primary">
<i class="bi bi-calendar-week"></i> Naar Kalender <i class="bi bi-calendar-week"></i> Naar Kalender
</a> </a>
@ -184,9 +184,9 @@ $commercials = $db->query("
<div class="alert alert-success alert-dismissible fade show" role="alert"> <div class="alert alert-success alert-dismissible fade show" role="alert">
<?php <?php
$messages = [ $messages = [
'created' => 'Commercial succesvol aangemaakt en geregistreerd bij Talpa!', 'created' => 'Infomercial succesvol aangemaakt en geregistreerd bij Talpa!',
'updated' => 'Commercial succesvol bijgewerkt!', 'updated' => 'Infomercial succesvol bijgewerkt!',
'deleted' => 'Commercial succesvol verwijderd!' 'deleted' => 'Infomercial succesvol verwijderd!'
]; ];
echo $messages[$_GET['success']] ?? 'Actie succesvol uitgevoerd!'; echo $messages[$_GET['success']] ?? 'Actie succesvol uitgevoerd!';
?> ?>
@ -198,7 +198,7 @@ $commercials = $db->query("
<div class="alert alert-danger alert-dismissible fade show" role="alert"> <div class="alert alert-danger alert-dismissible fade show" role="alert">
<?php <?php
$messages = [ $messages = [
'in_use' => 'Deze commercial kan niet verwijderd worden omdat deze nog in gebruik is in de planning!' 'in_use' => 'Deze infomercial kan niet verwijderd worden omdat deze nog in gebruik is in de planning!'
]; ];
echo $messages[$_GET['error']] ?? 'Er is een fout opgetreden!'; echo $messages[$_GET['error']] ?? 'Er is een fout opgetreden!';
?> ?>
@ -212,7 +212,7 @@ $commercials = $db->query("
<div class="card shadow-sm"> <div class="card shadow-sm">
<div class="card-header bg-primary text-white"> <div class="card-header bg-primary text-white">
<h5 class="mb-0"> <h5 class="mb-0">
<i class="bi bi-plus-circle"></i> Nieuwe Commercial Registreren <i class="bi bi-plus-circle"></i> Nieuwe Infomercial Registreren
</h5> </h5>
</div> </div>
<div class="card-body"> <div class="card-body">
@ -249,24 +249,24 @@ $commercials = $db->query("
<div class="mt-3 p-2 bg-light rounded"> <div class="mt-3 p-2 bg-light rounded">
<small class="text-muted"> <small class="text-muted">
<i class="bi bi-info-circle"></i> <i class="bi bi-info-circle"></i>
Dit registreert de commercial bij Talpa en maakt automatisch een media asset aan. Dit registreert de infomercial bij Talpa en maakt automatisch een media asset aan.
</small> </small>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- Commercial List --> <!-- Infomercial List -->
<div class="col-md-8"> <div class="col-md-8">
<div class="card shadow-sm"> <div class="card shadow-sm">
<div class="card-header bg-secondary text-white"> <div class="card-header bg-secondary text-white">
<h5 class="mb-0"><i class="bi bi-list-ul"></i> Geregistreerde Commercials</h5> <h5 class="mb-0"><i class="bi bi-list-ul"></i> Geregistreerde Infomercials</h5>
</div> </div>
<div class="card-body p-0"> <div class="card-body p-0">
<?php if (empty($commercials)): ?> <?php if (empty($infomercials)): ?>
<div class="p-4 text-center text-muted"> <div class="p-4 text-center text-muted">
<i class="bi bi-inbox" style="font-size: 3rem;"></i> <i class="bi bi-inbox" style="font-size: 3rem;"></i>
<p class="mt-2">Nog geen commercials geregistreerd</p> <p class="mt-2">Nog geen infomercials geregistreerd</p>
</div> </div>
<?php else: ?> <?php else: ?>
<div class="table-responsive"> <div class="table-responsive">
@ -284,7 +284,7 @@ $commercials = $db->query("
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($commercials as $c): ?> <?php foreach ($infomercials as $c): ?>
<tr> <tr>
<td> <td>
<div class="color-preview" <div class="color-preview"
@ -329,8 +329,8 @@ $commercials = $db->query("
</button> </button>
<?php if ($c['usage_count'] == 0): ?> <?php if ($c['usage_count'] == 0): ?>
<form method="POST" style="display:inline;" <form method="POST" style="display:inline;"
onsubmit="return confirm('Weet je zeker dat je deze commercial wilt verwijderen?');"> onsubmit="return confirm('Weet je zeker dat je deze infomercial wilt verwijderen?');">
<input type="hidden" name="commercial_id" value="<?= $c['id'] ?>"> <input type="hidden" name="infomercial_id" value="<?= $c['id'] ?>">
<button type="submit" name="delete_commercial" <button type="submit" name="delete_commercial"
class="btn btn-outline-danger" title="Verwijderen"> class="btn btn-outline-danger" title="Verwijderen">
<i class="bi bi-trash"></i> <i class="bi bi-trash"></i>
@ -352,12 +352,12 @@ $commercials = $db->query("
</div> </div>
<!-- Edit Modals (outside the table loop) --> <!-- Edit Modals (outside the table loop) -->
<?php foreach ($commercials as $c): ?> <?php foreach ($infomercials as $c): ?>
<div class="modal fade" id="editModal<?= $c['id'] ?>" tabindex="-1" aria-labelledby="editModalLabel<?= $c['id'] ?>" aria-hidden="true"> <div class="modal fade" id="editModal<?= $c['id'] ?>" tabindex="-1" aria-labelledby="editModalLabel<?= $c['id'] ?>" aria-hidden="true">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<form method="POST"> <form method="POST">
<input type="hidden" name="commercial_id" value="<?= $c['id'] ?>"> <input type="hidden" name="infomercial_id" value="<?= $c['id'] ?>">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title">Bewerk: <?= htmlspecialchars($c['title']) ?></h5> <h5 class="modal-title">Bewerk: <?= htmlspecialchars($c['title']) ?></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button> <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
@ -405,7 +405,7 @@ $commercials = $db->query("
// API Logs to console with enhanced debugging // API Logs to console with enhanced debugging
const apiLogs = <?= json_encode($apiLogs) ?>; const apiLogs = <?= json_encode($apiLogs) ?>;
if (apiLogs.length > 0) { if (apiLogs.length > 0) {
console.group("🔍 Talpa API Debug Logs - Commercial Registration"); console.group("🔍 Talpa API Debug Logs - Infomercial Registration");
apiLogs.forEach((log, index) => { apiLogs.forEach((log, index) => {
if (log.call) { if (log.call) {
console.group(`${index + 1}. ${log.call}`); console.group(`${index + 1}. ${log.call}`);
@ -429,7 +429,7 @@ $commercials = $db->query("
if (hasErrors) { if (hasErrors) {
console.warn("⚠️ Er zijn fouten opgetreden tijdens de registratie. Zie bovenstaande logs voor details."); console.warn("⚠️ Er zijn fouten opgetreden tijdens de registratie. Zie bovenstaande logs voor details.");
} else { } else {
console.log("Commercial registratie succesvol voltooid"); console.log("Infomercial registratie succesvol voltooid");
} }
} }
</script> </script>

View File

@ -2,8 +2,8 @@
-- Date: 2026-01-13 -- Date: 2026-01-13
-- Description: Extends existing schema for TV planning system -- Description: Extends existing schema for TV planning system
-- Add color and series code to commercials table -- Add color and series code to infomercials table
ALTER TABLE commercials ALTER TABLE infomercials
ADD COLUMN color_code VARCHAR(7) DEFAULT NULL COMMENT 'Hex color code for visual identification', ADD COLUMN color_code VARCHAR(7) DEFAULT NULL COMMENT 'Hex color code for visual identification',
ADD COLUMN series_code VARCHAR(20) DEFAULT NULL COMMENT 'Series identifier (e.g., 006a, 007a)'; ADD COLUMN series_code VARCHAR(20) DEFAULT NULL COMMENT 'Series identifier (e.g., 006a, 007a)';

View File

@ -19,13 +19,13 @@ $db = getDbConnection();
// Handle adding transmission to block // Handle adding transmission to block
if (isset($_POST['add_to_block'])) { if (isset($_POST['add_to_block'])) {
$commercialId = $_POST['commercial_id']; $commercialId = $_POST['infomercial_id'];
$channel = $_POST['channel']; $channel = $_POST['channel'];
$date = $_POST['date']; $date = $_POST['date'];
$blockId = $_POST['block_id'] ?? null; $blockId = $_POST['block_id'] ?? null;
// Get commercial duration // Get infomercial duration
$stmt = $db->prepare("SELECT duration FROM commercials WHERE id = ?"); $stmt = $db->prepare("SELECT duration FROM infomercials WHERE id = ?");
$stmt->execute([$commercialId]); $stmt->execute([$commercialId]);
$duration = $stmt->fetchColumn(); $duration = $stmt->fetchColumn();
@ -35,7 +35,7 @@ if (isset($_POST['add_to_block'])) {
// Insert transmission // Insert transmission
$stmt = $db->prepare(" $stmt = $db->prepare("
INSERT INTO transmissions INSERT INTO transmissions
(commercial_id, channel, template, start_date, start_time, duration, api_status) (infomercial_id, channel, template, start_date, start_time, duration, api_status)
VALUES (?, ?, 'HOME030', ?, ?, ?, 'pending') VALUES (?, ?, 'HOME030', ?, ?, ?, 'pending')
"); ");
$stmt->execute([$commercialId, $channel, $date, $nextStartTime, $duration]); $stmt->execute([$commercialId, $channel, $date, $nextStartTime, $duration]);
@ -72,7 +72,7 @@ if (isset($_POST['reorder'])) {
$stmt = $db->prepare(" $stmt = $db->prepare("
SELECT t.id, t.start_time, c.duration SELECT t.id, t.start_time, c.duration
FROM transmissions t FROM transmissions t
JOIN commercials c ON t.commercial_id = c.id JOIN infomercials c ON t.infomercial_id = c.id
WHERE t.start_date = ? AND t.channel = ? WHERE t.start_date = ? AND t.channel = ?
AND t.start_time >= ? AND t.start_time < ? AND t.start_time >= ? AND t.start_time < ?
ORDER BY t.start_time ASC ORDER BY t.start_time ASC
@ -130,7 +130,7 @@ if (isset($_POST['reorder'])) {
$stmt = $db->prepare(" $stmt = $db->prepare("
SELECT t.id, c.duration SELECT t.id, c.duration
FROM transmissions t FROM transmissions t
JOIN commercials c ON t.commercial_id = c.id JOIN infomercials c ON t.infomercial_id = c.id
WHERE t.start_date = ? AND t.channel = ? AND t.start_time >= ? WHERE t.start_date = ? AND t.channel = ? AND t.start_time >= ?
ORDER BY t.start_time ASC ORDER BY t.start_time ASC
"); ");
@ -172,9 +172,9 @@ foreach ($allBlocks as $block) {
$blocksByChannel[$block['channel']][] = $block; $blocksByChannel[$block['channel']][] = $block;
} }
// Get all commercials // Get all infomercials
$commercials = $db->query(" $infomercials = $db->query("
SELECT * FROM commercials SELECT * FROM infomercials
WHERE upload_status = 'uploaded' WHERE upload_status = 'uploaded'
ORDER BY title ASC ORDER BY title ASC
")->fetchAll(); ")->fetchAll();
@ -272,7 +272,7 @@ function calculateNextStartTimeForBlock($db, $date, $channel, $blockId) {
<a class="nav-link active" href="planner.php">Excel Planner</a> <a class="nav-link active" href="planner.php">Excel Planner</a>
<a class="nav-link" href="calendar.php">Kalender</a> <a class="nav-link" href="calendar.php">Kalender</a>
<a class="nav-link" href="blocks.php">Blokken</a> <a class="nav-link" href="blocks.php">Blokken</a>
<a class="nav-link" href="commercials.php">Commercials</a> <a class="nav-link" href="infomercials.php">Infomercials</a>
</div> </div>
</div> </div>
</nav> </nav>
@ -321,12 +321,12 @@ function calculateNextStartTimeForBlock($db, $date, $channel, $blockId) {
<!-- Both Channels Side by Side --> <!-- Both Channels Side by Side -->
<div class="row"> <div class="row">
<!-- Commercial Sidebar --> <!-- Infomercial Sidebar -->
<div class="col-md-2"> <div class="col-md-2">
<div class="card shadow-sm sticky-top" style="top: 20px;"> <div class="card shadow-sm sticky-top" style="top: 20px;">
<div class="card-header bg-success text-white"> <div class="card-header bg-success text-white">
<h6 class="mb-0"> <h6 class="mb-0">
<i class="bi bi-collection-play"></i> Commercials <i class="bi bi-collection-play"></i> Infomercials
</h6> </h6>
</div> </div>
<div class="card-body p-2"> <div class="card-body p-2">
@ -339,33 +339,33 @@ function calculateNextStartTimeForBlock($db, $date, $channel, $blockId) {
onkeyup="filterPlannerCommercials(this.value)"> onkeyup="filterPlannerCommercials(this.value)">
</div> </div>
<!-- Commercial List --> <!-- Infomercial List -->
<div class="commercial-sidebar" style="max-height: 70vh;"> <div class="infomercial-sidebar" style="max-height: 70vh;">
<?php if (empty($commercials)): ?> <?php if (empty($infomercials)): ?>
<div class="text-center text-muted p-2"> <div class="text-center text-muted p-2">
<i class="bi bi-inbox"></i> <i class="bi bi-inbox"></i>
<p class="small mt-2">Geen commercials</p> <p class="small mt-2">Geen infomercials</p>
</div> </div>
<?php else: ?> <?php else: ?>
<?php foreach ($commercials as $commercial): ?> <?php foreach ($infomercials as $infomercial): ?>
<div class="commercial-item draggable-commercial" <div class="infomercial-item draggable-infomercial"
style="border-left-color: <?= htmlspecialchars($commercial['color_code']) ?>; padding: 8px; margin-bottom: 8px;" style="border-left-color: <?= htmlspecialchars($infomercial['color_code']) ?>; padding: 8px; margin-bottom: 8px;"
draggable="true" draggable="true"
data-commercial-id="<?= $commercial['id'] ?>" data-infomercial-id="<?= $infomercial['id'] ?>"
data-title="<?= htmlspecialchars($commercial['title']) ?>" data-title="<?= htmlspecialchars($infomercial['title']) ?>"
data-duration="<?= $commercial['duration'] ?>" data-duration="<?= $infomercial['duration'] ?>"
data-color="<?= htmlspecialchars($commercial['color_code']) ?>" data-color="<?= htmlspecialchars($infomercial['color_code']) ?>"
data-series-code="<?= htmlspecialchars($commercial['series_code'] ?? '') ?>"> data-series-code="<?= htmlspecialchars($infomercial['series_code'] ?? '') ?>">
<div class="d-flex align-items-center"> <div class="d-flex align-items-center">
<div style="background-color: <?= htmlspecialchars($commercial['color_code']) ?>; width: 15px; height: 15px; border-radius: 2px; margin-right: 6px;"> <div style="background-color: <?= htmlspecialchars($infomercial['color_code']) ?>; width: 15px; height: 15px; border-radius: 2px; margin-right: 6px;">
</div> </div>
<div class="flex-grow-1"> <div class="flex-grow-1">
<div style="font-weight: 600; font-size: 0.8em;"> <div style="font-weight: 600; font-size: 0.8em;">
<?= htmlspecialchars($commercial['title']) ?> <?= htmlspecialchars($infomercial['title']) ?>
</div> </div>
<div style="font-size: 0.7em; color: #6c757d;"> <div style="font-size: 0.7em; color: #6c757d;">
<?= round(timeToSeconds($commercial['duration']) / 60) ?> min <?= round(timeToSeconds($infomercial['duration']) / 60) ?> min
</div> </div>
</div> </div>
<div> <div>
@ -408,7 +408,7 @@ function calculateNextStartTimeForBlock($db, $date, $channel, $blockId) {
$stmt = $db->prepare(" $stmt = $db->prepare("
SELECT t.*, c.title, c.color_code, c.series_code SELECT t.*, c.title, c.color_code, c.series_code
FROM transmissions t FROM transmissions t
JOIN commercials c ON t.commercial_id = c.id JOIN infomercials c ON t.infomercial_id = c.id
WHERE t.start_date = ? AND t.channel = ? WHERE t.start_date = ? AND t.channel = ?
AND t.start_time >= ? AND t.start_time < ? AND t.start_time >= ? AND t.start_time < ?
ORDER BY t.start_time ASC ORDER BY t.start_time ASC
@ -538,7 +538,7 @@ function calculateNextStartTimeForBlock($db, $date, $channel, $blockId) {
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
<!-- Add Commercial Row (also a drop zone) --> <!-- Add Infomercial Row (also a drop zone) -->
<tr class="table-success drop-zone-end" <tr class="table-success drop-zone-end"
data-block-id="<?= $block['id'] ?>" data-block-id="<?= $block['id'] ?>"
data-channel="<?= $channel ?>" data-channel="<?= $channel ?>"
@ -550,9 +550,9 @@ function calculateNextStartTimeForBlock($db, $date, $channel, $blockId) {
<input type="hidden" name="block_id" value="<?= $block['id'] ?>"> <input type="hidden" name="block_id" value="<?= $block['id'] ?>">
<div class="col-md-8"> <div class="col-md-8">
<select name="commercial_id" class="form-select form-select-sm" required> <select name="infomercial_id" class="form-select form-select-sm" required>
<option value="">+ Voeg commercial toe...</option> <option value="">+ Voeg infomercial toe...</option>
<?php foreach ($commercials as $c): ?> <?php foreach ($infomercials as $c): ?>
<option value="<?= $c['id'] ?>"> <option value="<?= $c['id'] ?>">
<?= htmlspecialchars($c['series_code'] ?? '') ?> - <?= htmlspecialchars($c['series_code'] ?? '') ?> -
<?= htmlspecialchars($c['title']) ?> <?= htmlspecialchars($c['title']) ?>
@ -636,9 +636,9 @@ function calculateNextStartTimeForBlock($db, $date, $channel, $blockId) {
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.0/Sortable.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.0/Sortable.min.js"></script>
<script> <script>
// Filter commercials in sidebar // Filter infomercials in sidebar
function filterPlannerCommercials(searchTerm) { function filterPlannerCommercials(searchTerm) {
const items = document.querySelectorAll('.draggable-commercial'); const items = document.querySelectorAll('.draggable-infomercial');
const term = searchTerm.toLowerCase(); const term = searchTerm.toLowerCase();
items.forEach(item => { items.forEach(item => {
@ -653,10 +653,10 @@ function calculateNextStartTimeForBlock($db, $date, $channel, $blockId) {
}); });
} }
// Make commercial items draggable // Make infomercial items draggable
document.querySelectorAll('.draggable-commercial').forEach(item => { document.querySelectorAll('.draggable-infomercial').forEach(item => {
item.addEventListener('dragstart', function(e) { item.addEventListener('dragstart', function(e) {
e.dataTransfer.setData('commercial_id', this.dataset.commercialId); e.dataTransfer.setData('infomercial_id', this.dataset.commercialId);
e.dataTransfer.setData('title', this.dataset.title); e.dataTransfer.setData('title', this.dataset.title);
e.dataTransfer.setData('duration', this.dataset.duration); e.dataTransfer.setData('duration', this.dataset.duration);
this.style.opacity = '0.5'; this.style.opacity = '0.5';
@ -688,7 +688,7 @@ function calculateNextStartTimeForBlock($db, $date, $channel, $blockId) {
e.preventDefault(); e.preventDefault();
this.style.borderTop = ''; this.style.borderTop = '';
const commercialId = e.dataTransfer.getData('commercial_id'); const commercialId = e.dataTransfer.getData('infomercial_id');
// Insert at this position // Insert at this position
fetch('api/insert_transmission_at_position.php', { fetch('api/insert_transmission_at_position.php', {
@ -697,7 +697,7 @@ function calculateNextStartTimeForBlock($db, $date, $channel, $blockId) {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify({ body: JSON.stringify({
commercial_id: commercialId, infomercial_id: commercialId,
channel: channel, channel: channel,
date: date, date: date,
block_id: blockId, block_id: blockId,
@ -716,7 +716,7 @@ function calculateNextStartTimeForBlock($db, $date, $channel, $blockId) {
}); });
}); });
// Make "Add Commercial" rows also drop zones (for adding at end) // Make "Add Infomercial" rows also drop zones (for adding at end)
document.querySelectorAll('.drop-zone-end').forEach(row => { document.querySelectorAll('.drop-zone-end').forEach(row => {
const blockId = row.dataset.blockId; const blockId = row.dataset.blockId;
const channel = row.dataset.channel; const channel = row.dataset.channel;
@ -737,14 +737,14 @@ function calculateNextStartTimeForBlock($db, $date, $channel, $blockId) {
e.stopPropagation(); e.stopPropagation();
this.style.backgroundColor = ''; this.style.backgroundColor = '';
const commercialId = e.dataTransfer.getData('commercial_id'); const commercialId = e.dataTransfer.getData('infomercial_id');
if (!commercialId) return; if (!commercialId) return;
// Add at end (use existing add_to_block logic) // Add at end (use existing add_to_block logic)
const form = this.querySelector('form'); const form = this.querySelector('form');
if (form) { if (form) {
const select = form.querySelector('select[name="commercial_id"]'); const select = form.querySelector('select[name="infomercial_id"]');
if (select) { if (select) {
select.value = commercialId; select.value = commercialId;
form.submit(); form.submit();

View File

@ -159,7 +159,7 @@
result of this License or out of the use or inability to use the result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill, Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor other infomercial damages or losses), even if such Contributor
has been advised of the possibility of such damages. has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing 9. Accepting Warranty or Additional Liability. While redistributing