One Hat Cyber Team
Your IP :
216.73.216.36
Server IP :
162.240.179.46
Server :
Linux vps-14493116.nutrivittasaude.com.br 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
Server Software :
Apache
PHP Version :
8.2.31
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
lifeprimeti
/
meta.lifeprimeti.com.br
/
api
/
Edit File:
horarios.php
<?php require_once __DIR__ . '/../config/database.php'; header('Content-Type: application/json; charset=utf-8'); $profissionalId = (int)($_GET['profissional_id'] ?? 0); $data = $_GET['data'] ?? ''; $servicoId = (int)($_GET['servico_id'] ?? 0); if (!$profissionalId || !$data) { echo json_encode([]); exit; } $empresaId = (int)($_GET['empresa_id'] ?? 1); $diaSemana = (int)date('w', strtotime($data)); $horariosProf = $pdo->prepare("SELECT * FROM horarios_profissionais WHERE profissional_id = ? AND dia_semana = ?"); $horariosProf->execute([$profissionalId, $diaSemana]); $horariosProfLista = $horariosProf->fetchAll(); if (empty($horariosProfLista)) { echo json_encode([]); exit; } $bloqueios = $pdo->prepare("SELECT * FROM bloqueio_dias WHERE (empresa_id = ? OR profissional_id = ?) AND data = ?"); $bloqueios->execute([$empresaId, $profissionalId, $data]); $bloqueiosLista = $bloqueios->fetchAll(); $duracao = 60; if ($servicoId) { $s = $pdo->prepare("SELECT duracao FROM servicos WHERE id = ?"); $s->execute([$servicoId]); $serv = $s->fetch(); if ($serv) $duracao = (int)$serv['duracao']; } $agendamentosDia = $pdo->prepare("SELECT hora, hora_fim FROM agendamentos WHERE profissional_id = ? AND data = ? AND status NOT IN ('cancelado')"); $agendamentosDia->execute([$profissionalId, $data]); $ocupados = $agendamentosDia->fetchAll(); $slots = []; foreach ($horariosProfLista as $hp) { $inicio = strtotime($hp['hora_inicio']); $fim = strtotime($hp['hora_fim']); $intInicio = $hp['intervalo_inicio'] ? strtotime($hp['intervalo_inicio']) : null; $intFim = $hp['intervalo_fim'] ? strtotime($hp['intervalo_fim']) : null; while ($inicio + ($duracao * 60) <= $fim) { $horaSlot = date('H:i', $inicio); $horaFimSlot = date('H:i', $inicio + ($duracao * 60)); // Pular slots dentro do intervalo if ($intInicio && $intFim) { $slotStart = $inicio; $slotEnd = $inicio + ($duracao * 60); if ($slotStart < $intFim && $slotEnd > $intInicio) { $inicio += $duracao * 60; continue; } } $bloqueado = false; foreach ($bloqueiosLista as $b) { if ($b['hora_inicio']) { if ($horaSlot < $b['hora_fim'] && $horaFimSlot > $b['hora_inicio']) { $bloqueado = true; break; } } else { $bloqueado = true; break; } } if ($bloqueado) { $inicio += $duracao * 60; continue; } $ocupado = false; foreach ($ocupados as $o) { if ($horaSlot < $o['hora_fim'] && $horaFimSlot > $o['hora']) { $ocupado = true; break; } } if (!$ocupado) { $slots[] = $horaSlot; } $inicio += $duracao * 60; } } // Filtrar horarios passados se a data for hoje $hoje = date('Y-m-d'); if ($data === $hoje) { $agora = date('H:i'); $slots = array_filter($slots, function($s) use ($agora) { return $s > $agora; }); $slots = array_values($slots); } echo json_encode($slots);
Simpan