<h1>Atualizar Tipo:</h1> </header> <?php require '_models/AdminSetorType.class.php'; $data = filter_input_array(INPUT_POST, FILTER_DEFAULT); $typeId = filter_input(INPUT_GET, 'typeId', FILTER_VALIDATE_INT); if (!empty($data['SendPostForm'])) { unset($data['SendPostForm']); $data['type_id'] = $typeId; $cadastra = new AdminSetorType(); $cadastra->ExeUpdate($data); WSErro($cadastra->getError()[0], $cadastra->getError()[1]); } else { $Read = new WsSetorType(); $Read->setType_id($typeId); $Read->Execute()->Query("#type_id#"); if (!$Read->Execute()->getResult()) { header("Location: painel.php?exe=setor_type/index&empty=true"); } else { $data = (array) $Read->Execute()->getResult()[0]; } } $checkCreate = filter_input(INPUT_GET, 'create', FILTER_VALIDATE_BOOLEAN); if ($checkCreate && empty($cadastra)) { WSErro("O tipo <b>{$data['type_content']}</b> foi cadastrado com sucesso no sistema! Continue atualizando o mesmo!", WS_ACCEPT); } ?> <form name="PostForm" action="" method="post" enctype="multipart/form-data"> <label class="label">
<?php include "../../_app/Config.inc.php"; $Read = new WsSetorType(); $request = json_decode(file_get_contents("php://input")); if (!empty($request)) { if (!empty($request) && is_array($request)) { //excluir foreach ($request as $data) { $Read->setType_id($data->type_id); $Read->Execute()->delete(); } echo "excluido com sucesso!"; } elseif (!empty($request->edited)) { //editar $Read->setThis($request); $Read->Execute()->update(NULL, "type_id"); echo "Editado com sucesso!"; } else { //adicionar $Read->setThis($request); $Read->Execute()->insert(); echo "Adicionado com sucesso!"; } } else { $Read->Execute()->Query("type_status=1"); echo json_encode($Read->Execute()->getResult()); }