public static function parse($record) { if ($record == null) { return null; } $instituto = new Instituto(); $instituto->setId($record["idInstituto"]); $instituto->setNome($record["Nome"]); return $instituto; }
<?php include_once "../../class/Carrega.class.php"; if (isset($_POST['enviar'])) { $object = new Instituto(); $object->instituto = $_POST['instituto']; $object->Inserir(); header("Location:ViewInstitutosObj.php"); } else { if (isset($_POST['excluir'])) { $object = new Instituto(); $object->id = $_POST['id']; $object->Excluir(); header("Location:ViewInstitutosObj.php"); } else { if (isset($_POST['atualizar'])) { $object = new Instituto(); $object->id = $_POST['id']; $object->instituto = $_POST['instituto']; $object->Atualizar(); header("Location:ViewInstitutosObj.php"); } } }
require '../persistencia/instituto/InstitutoDao.php'; require '../persistencia/instituto/InstitutoService.php'; $tiporequest = $_SERVER['REQUEST_METHOD']; if ($tiporequest == "GET") { InstitutoView::exibeInstitutos(); } else { if ($tiporequest == "POST") { $funcao = $_POST['funcao']; if ($funcao == "deletar") { $idinst = $_POST['idinst']; $institutodeletar = InstitutoService::getById($idinst); InstitutoService::delete($institutodeletar); } else { if ($funcao == "criar") { $nomeinst = $_POST['nomeinst']; $institutocriar = new Instituto(); $institutocriar->setNome(utf8_encode($nomeinst)); $criou = InstitutoService::inserir($institutocriar); if (!is_null($criou)) { $institutocriado = InstitutoService::getByNome($nomeinst); $arrayretorno['nomeinst'] = $nomeinst; $arrayretorno['idinst'] = $institutocriado->getId(); $retornoJSON = json_encode($arrayretorno); echo $retornoJSON; } else { $retornoJSON = json_encode(NULL); echo $retornoJSON; } } else { if ($funcao == "atualizar") { $novonome = $_POST['novonome'];
<div class="box box-info"> <div class="box-header"> <h3 class="box-title">Listagem de instituições</h3> <a class="btn btn-info btn-flat pull-right" href="ViewInstitutosObj.php" title="Atualizar resultados" data-toggle="tooltip" data-placement="left"><i class="fa fa-refresh"></i></a> </div><!-- /.box-header --> <div class="box-body"> <table id="dataT" class="table table-bordered table-hover"> <thead> <tr> <th>Nome</th> <th>Opções</th> </tr> </thead> <tbody> <?php $listar = new Instituto(); $list = $listar->listar(); if ($list != null) { foreach ($list as $line) { ?> <tr class="odd gradeX"> <form name="view" action="EditInstitutoObj.php" method="post"> <td><?php echo $line->instituto; ?> </td> <td> <input type='hidden' name='id' value='<?php echo $line->id; ?> '>
<h1>Institutos</h1> </section> <!-- Main content --> <section class="content"> <div class="row"> <div class="col-lg-12"> <!-- Horizontal Form --> <div class="box box-success"> <div class="box-header with-border"> <h3 class="box-title">Edição de institutos</h3> </div><!-- /.box-header --> <!-- form start --> <?php $id = $_POST["id"]; if (isset($_POST["editar"])) { $edit = new Instituto(); $comp = $edit->editar($id); if ($edit != null) { ?> <form class="form-horizontal" id="form" method="post" action="CrudInstituto.php"> <div class="box-body"> <div class="form-group"> <label for="nome" class="col-sm-2 control-label">Nome do instituto:</label> <div class="col-sm-10"> <input type="text" class="form-control" name="instituto" id="nome" value="<?php echo $comp->instituto; ?> " placeholder="Digite aqui" autofocus required> </div> </div> </div><!-- /.box-body -->