false, 'error' => 'No autenticado']); exit; } $pdo = Database::getInstance()->getConnection(); $body = json_decode(file_get_contents('php://input'), true) ?? []; $items = is_array($body['items'] ?? null) ? $body['items'] : []; if (!$items) { echo json_encode(['ok' => false, 'error' => 'items requerido']); exit; } $stmt = $pdo->prepare( "UPDATE turnero_tv_media SET orden = ?, duracion_segundos = ? WHERE id = ?" ); foreach ($items as $i => $it) { $id = (int)($it['id'] ?? 0); if (!$id) continue; $dur = max(1, (int)($it['duracion_segundos'] ?? 8)); $stmt->execute([$i, $dur, $id]); } echo json_encode(['ok' => true]);