<article> <header> <h1>Criar Setor:</h1> </header> <?php require '_models/AdminSetor.class.php'; $data = filter_input_array(INPUT_POST, FILTER_DEFAULT); if (!empty($data['SendPostForm'])) { unset($data['SendPostForm']); $cadastra = new AdminSetor(); $cadastra->ExeCreate($data); if ($cadastra->getResult() == null) { WSErro($cadastra->getError()[0], $cadastra->getError()[1]); } else { header('Location: painel.php?exe=setor/update&create=true&setId=' . $cadastra->getResult()); } } ?> <form name="PostForm" action="" method="post" enctype="multipart/form-data"> <label class="label"> <span class="field">Titulo:</span> <input type="text" name="setor_content" placeholder="nome do setor" value="<?php if (isset($data)) { echo $data['setor_content']; } ?> " />
if ($action) { require_once '_models/AdminSetor.class.php'; $postAction = filter_input(INPUT_GET, 'setor', FILTER_VALIDATE_INT); $postUpdate = new AdminSetor(); switch ($action) { case 'active': $postUpdate->ExeStatus($postAction, '1'); WSErro("O status do setor foi atualizado para <b>ativo</b>. Setor publicado!", WS_ACCEPT); break; case 'inative': $postUpdate->ExeStatus($postAction, '0'); WSErro("O status do setor foi atualizado para <b>inativo</b>. Setor agora é um rascunho!", WS_ACCEPT); break; case 'delete': $postUpdate->ExeDelete($postAction); WSErro('O Setor <b>' . $postUpdate->getError()[0] . "</b>, foi deletado com sucesso!", $postUpdate->getError()[1]); break; default: WSErro("Ação não foi identificada pelo sistema, favor utilize os botões", WS_ERROR); break; } } $posti = 0; $getPage = filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT); $Pager = new Pager("painel.php?exe=setor/index&page="); $Pager->ExePager($getPage, 6); $Read = new Controle(); $Read->FullRead("SELECT * FROM ws_setor ORDER by setor_status ASC, setor_date DESC LIMIT :limit OFFSET :offset", "limit={$Pager->getLimit()}&offset={$Pager->getOffset()}", true); if (!$Read->getResult()) { $Pager->ReturnPage(); WSErro("Desculpa, ainda não temos setor cadastrados", WS_INFOR);