public static function editar() { $agenda = new Agenda(); $agenda->selecionarPorId($_GET['id']); $evento = new Evento(); $evento->selecionarPorId($agenda->fkEvento); $sala = new Sala(); $salas = $sala->listar(); $arrListaDatas = Funcao::retornaDataIntervalo($evento->dataInicio, $evento->dataFim); $arrHoraInicial = Funcao::intervaloDeHoraPorMinutos('07:00', '23:30'); $arrHoraFinal = Funcao::intervaloDeHoraPorMinutos('07:00', '23:30'); if (!empty($_POST)) { $agenda = new Agenda(); foreach ($_POST as $pKey => $p) { if ($pKey == 'dia') { $agenda->{$pKey} = Funcao::dateFormatToDatabase($p); } else { $agenda->{$pKey} = $p; } } $idAgenda = $agenda->salvar(); $evento = new Evento(); $evento->selecionarPorId($_POST['fkEvento']); self::redirecionar(Configuracao::$baseUrl . self::$viewController . '/listar/' . $evento->id . '-' . Funcao::prepararLink($evento->nome) . Configuracao::$extensaoPadrao); } self::$corpo = "editar"; self::$variaveis = array('agenda' => $agenda, 'salas' => $salas, 'evento' => $evento, 'dias' => $arrListaDatas, 'horaInicial' => $arrHoraInicial, 'horaFinal' => $arrHoraFinal); self::renderizar(self::$viewController); }
<?php $app->group('/agenda', function () use($app) { $agendaController = new AgendaController(); $app->get('/list', function () use($app, $agendaController) { $list = $agendaController->listAll(); $app->render("agenda/agendaListView.php", array("list" => $list)); $app->conn = null; }); $app->get('/list/json', function () use($app, $agendaController) { header('Access-Control-Allow-Origin: *'); $list = $agendaController->listAll(); echo json_encode($list); $app->conn = null; }); $app->get('/:id/new', function ($id) use($app, $agendaController) { $list = $agendaController->listAll(); $app->render("agenda/agendaNewView.php", array("pageTitle" => "Agendar horário", "customHeader" => '<link href="' . BASE_URL . '/css/bootstrap-datetimepicker.min.css" rel="stylesheet">', "includeFooter" => 'api/view/agenda/footerInclude/agendaNewViewFooterInclude.php', "list" => $list)); $app->conn = null; }); $app->post('/:id/new', function ($id) use($app, $agendaController) { $post = $app->request->params(); $owner = @$post['owner']; $dateStart = @$post['dateStart']; $dateFinish = @$post['dateFinish']; if (!empty($owner) && !empty($dateStart) && !empty($dateFinish)) { $agenda = new Agenda(); $agenda->roomId = $id; $agenda->owner = $owner; $agenda->dateStart = $dateStart; $agenda->dateFinish = $dateFinish;