list($ano, $mes, $dia) = explode("-", $_POST["data"]); } else { $dia = 1; $mes = $_POST["mes"]; $ano = $_POST["ano"]; } $prevData = date('Y-m-d', mktime(0, 0, 0, $mes - 1, 1, $ano)); $nextData = date('Y-m-d', mktime(0, 0, 0, $mes + 1, 1, $ano)); $where = array("agenda.mes" => $mes, "agenda.ano" => $ano); $holidays = Funcoes::getFeriados($mes, $ano); if (!empty($_POST["fisioterapeuta"])) { $idFisioterapeuta = $where["agenda_fisioterapeutas.fisioterapeuta"] = $_POST["fisioterapeuta"]; $fisioterapeuta = $dao->findByPk($conexao->getConexao(), "vw_usuarios", (int) $_POST["fisioterapeuta"]); $fisioterapeuta["diasAtendimento"] = !empty($fisioterapeuta["diasAtendimento"]) ? explode(",", $fisioterapeuta["diasAtendimento"]) : array(); } $objetos = $dao->findAll($conexao->getConexao(), "agenda", array("dados" => array("agenda.id", "agenda.tipo", "agenda.data", "agenda.hora", "agenda.dia", "agenda.mes", "agenda.ano", "agenda.telefoneResidencial", "agenda.telefoneCelular", "agenda.lembrete", "agenda.observacoes", "agenda.nomePaciente", "agenda.marcador", "CONCAT_WS('T', agenda.data, agenda.hora) as timestamp"), "where" => $where, "leftJoin" => array("agenda_fisioterapeutas" => "agenda.id = agenda_fisioterapeutas.compromisso"), "order" => array("agenda.hora" => "asc"))); $mesRange = rangeMonth($ano . "-" . $mes . "-01"); for ($i = $mesRange["start"]; $i <= $mesRange["end"]; $i++) { foreach ($objetos as $objeto) { if ($objeto["dia"] == $i) { $compromissos[(int) $i][$objeto["hora"]] = $objeto; } } } // Create array containing abbreviations of days of week. $daysOfWeek = array('Seg', 'Ter', 'Qua', 'Qui', 'Sex'); // What is the first day of the month in question? $firstDayOfMonth = mktime(0, 0, 0, $mes, $dia, $ano); // Retrieve some information about the first day of the month in question. $dateComponents = getdate($firstDayOfMonth); // What is the index value (0-6) of the first day of the month in question.
header("Access-Control-Allow-Origin: *"); require_once "../../config.php"; $conexao = new Conexao(); $dao = new DAOGenerico(); switch ($_GET['acao']) { case 'recupera': $compromisso = $dao->findByPk($conexao->getConexao(), "agenda", $_POST['id']); if (!empty($compromisso["fotoPaciente"])) { $diretorio = DIR_UPLOADS . SEPARADOR_DIRETORIO . "pacientes" . SEPARADOR_DIRETORIO . $compromisso["paciente"]; $diretorio .= SEPARADOR_DIRETORIO . $compromisso["fotoPaciente"]; if (existeArquivo($diretorio)) { $compromisso["pathFoto"] = "uploads/pacientes/" . $compromisso["paciente"] . '/' . $compromisso["fotoPaciente"]; } } $fisioterapeutas = $dao->findAll($conexao->getConexao(), "agenda_fisioterapeutas", array("where" => array("compromisso" => $_POST['id']))); $arr = array(); foreach ($fisioterapeutas as $f) { $arr[] = $f["fisioterapeuta"]; } $compromisso["fisioterapeutas"] = implode(",", $arr); echo json_encode($compromisso); break; case 'dados': $paciente = $dao->find($conexao->getConexao(), "pacientes", array('where' => array('nome' => $_POST['nome']))); $diretorio = DIR_UPLOADS . SEPARADOR_DIRETORIO . "pacientes" . SEPARADOR_DIRETORIO . $paciente["id"]; $diretorio .= SEPARADOR_DIRETORIO . $paciente["foto"]; if (!existeArquivo($diretorio)) { $paciente["pathFoto"] = "imagens/user.gif"; } else { $paciente["pathFoto"] = "uploads/pacientes/" . $paciente["id"] . '/' . $paciente["foto"];