public static function exibeDepartamentos()
 {
     $departamentos = DepartamentoService::getDepartamentos();
     $institutos = InstitutoService::getInstitutos();
     $table = "";
     $table .= "<form> Nome do Departamento|Instituto <br> <input class='noEnter' id='criardept' type='text'>";
     $table .= "<select class='institutos' style='display:inline'>";
     if ($institutos != null) {
         for ($i = 0; $i < sizeof($institutos); $i++) {
             $table .= "<option value='" . $institutos[$i]->getId() . "'>" . $institutos[$i]->getNome() . "</option>";
         }
     }
     $table .= "</select>";
     $table .= "</form>";
     $table .= "<button class='criar'> Criar </button><br><br>";
     $table .= "<table>";
     $table .= "<tr>";
     $table .= "<th>Nome</th>";
     $table .= "<th>Instituto</th>";
     $table .= "<th>Excluir</th>";
     $table .= "<th>Atualizar</th>";
     $table .= "</tr>";
     if ($departamentos != null) {
         for ($i = 0; $i < sizeof($departamentos); $i++) {
             $instituto = InstitutoService::getById($departamentos[$i]->getInst_id());
             $table .= "<tr id='tr" . $departamentos[$i]->getId() . "'>";
             $table .= "<td>";
             $table .= $departamentos[$i]->getNome();
             $table .= "</td>";
             $table .= "<td>";
             $table .= $instituto->getNome();
             $table .= "</td>";
             $table .= "<td>";
             $table .= "<button id='e" . $departamentos[$i]->getId() . "' class='excluir'>Excluir</button>";
             $table .= "</td>";
             $table .= "<td>";
             $table .= "<button id='a" . $departamentos[$i]->getId() . "' class='atualizar'>Atualizar</button>";
             $table .= "</td>";
             $table .= "<td style='display:none'>";
             $table .= "<form><input id='atualizar" . $departamentos[$i]->getId() . "' class='atualizardept' type='text'></form>";
             $table .= "</td>";
             $table .= "<td style='display:none'>";
             $table .= "<select id='drop" . $departamentos[$i]->getId() . "' class='dropatu'>";
             if ($institutos != null) {
                 for ($j = 0; $j < sizeof($institutos); $j++) {
                     $table .= "<option value='" . $institutos[$j]->getId() . "'";
                     if ($institutos[$j]->getNome() == $instituto->getNome()) {
                         $table .= " selected";
                     }
                     $table .= ">" . $institutos[$j]->getNome() . "</option>";
                 }
             }
             $table .= "</select>";
             $table .= "</td>";
             $table .= "<td style='display:none'>";
             $table .= "<button id='c" . $departamentos[$i]->getId() . "' class='confirmar'>Confirmar</button>";
             $table .= "</td>";
             $table .= "<td style='display:none'>";
             $table .= "<button id='can" . $departamentos[$i]->getId() . "' class='cancelar'>Cancelar</button>";
             $table .= "</td>";
             $table .= "</tr>";
         }
     }
     $table .= "</table>";
     $table .= "<br>";
     $table .= "<button class='instbut nav'>Institutos</button>";
     $table .= "<button class='deptbut nav'>Departamentos</button>";
     $table .= "<button class='cursbut nav'>Cursos</button>";
     $output = file_get_contents("/var/www/html/Projeto Final BD/Codigo/exibicao/html/departamento.html");
     $output = str_replace("tabela", $table, $output);
     echo $output;
 }
     $creditos = $_POST['creditos'];
     $cursocriar = new Curso();
     $cursocriar->setNome(utf8_encode($nomecurs));
     $cursocriar->setDept_id($iddept);
     $cursocriar->setCred_form($creditos);
     $cursocriar->setDuracao($duracao);
     $criou = CursoService::inserir($cursocriar);
     if (!is_null($criou)) {
         $cursocriado = CursoService::getByNome($nomecurs);
         $arrayretorno['nomecurs'] = $nomecurs;
         $arrayretorno['idcurs'] = $cursocriado->getId();
         $arrayretorno['iddept'] = $cursocriado->getDept_id();
         $arrayretorno['nomedept'] = DepartamentoService::getById($iddept)->getNome();
         $arrayretorno['duracao'] = $cursocriado->getDuracao();
         $arrayretorno['creditos'] = $cursocriado->getCred_form();
         $departamentos = DepartamentoService::getDepartamentos();
         for ($i = 0; $i < sizeof($departamentos); $i++) {
             $nomesdepartamentos[$i] = $departamentos[$i]->getNome();
             $idsdepartamentos[$i] = $departamentos[$i]->getId();
         }
         $arrayretorno['nomesdept'] = $nomesdepartamentos;
         $arrayretorno['idsdept'] = $idsdepartamentos;
         $retornoJSON = json_encode($arrayretorno);
         echo $retornoJSON;
     } else {
         $retornoJSON = json_encode(NULL);
         echo $retornoJSON;
     }
 } else {
     if ($funcao == "atualizar") {
         $novonome = $_POST['novonome'];
Beispiel #3
0
 public static function exibeCursos()
 {
     $cursos = CursoService::getCursos();
     $departamentos = DepartamentoService::getDepartamentos();
     $table = "";
     $table .= "<form> Nome do Curso|Duração|Créditos|Departamento <br> <input class='noEnter' id='criarcurs' type='text'>";
     $table .= "<select class='criarduracao style='display:inline'>";
     $table .= "<option value='4'>4</option>";
     $table .= "<option value='8'>8</option>";
     $table .= "<option value='10'>10</option>";
     $table .= "</select>";
     $table .= "<input class='creditoscriar' type='number' min='80' max='500'>";
     $table .= "<select class='departamentos' style='display:inline'>";
     if ($departamentos != null) {
         for ($i = 0; $i < sizeof($departamentos); $i++) {
             $table .= "<option value='" . $departamentos[$i]->getId() . "'>" . $departamentos[$i]->getNome() . "</option>";
         }
     }
     $table .= "</select>";
     $table .= "</form>";
     $table .= "<button class='criar'> Criar </button><br><br>";
     $table .= "<table>";
     $table .= "<tr>";
     $table .= "<th>Nome</th>";
     $table .= "<th>Departamento</th>";
     $table .= "<th>Duração</th>";
     $table .= "<th>Créditos</th>";
     $table .= "<th>Excluir</th>";
     $table .= "<th>Atualizar</th>";
     $table .= "</tr>";
     if ($cursos != null) {
         for ($i = 0; $i < sizeof($cursos); $i++) {
             $departamento = DepartamentoService::getById($cursos[$i]->getDept_id());
             $table .= "<tr id='tr" . $cursos[$i]->getId() . "'>";
             $table .= "<td>";
             $table .= $cursos[$i]->getNome();
             $table .= "</td>";
             $table .= "<td>";
             $table .= $departamento->getNome();
             $table .= "</td>";
             $table .= "<td>";
             $table .= $cursos[$i]->getDuracao();
             $table .= "</td>";
             $table .= "<td>";
             $table .= $cursos[$i]->getCred_form();
             $table .= "</td>";
             $table .= "<td>";
             $table .= "<button id='e" . $cursos[$i]->getId() . "' class='excluir'>Excluir</button>";
             $table .= "</td>";
             $table .= "<td>";
             $table .= "<button id='a" . $cursos[$i]->getId() . "' class='atualizar'>Atualizar</button>";
             $table .= "</td>";
             $table .= "<td style='display:none'>";
             $table .= "<form><input id='atualizar" . $cursos[$i]->getId() . "' class='atualizarcurs' type='text'></form>";
             $table .= "</td>";
             $table .= "<td style='display:none'>";
             $table .= "<select id='atualizardura" . $cursos[$i]->getId() . "'>";
             $table .= "<option value='4'>4</option>";
             $table .= "<option value='8'>8</option>";
             $table .= "<option value='10'>10</option>";
             $table .= "</select>";
             $table .= "</td>";
             $table .= "<td style='display:none'>";
             $table .= "<input id='creditosatu" . $cursos[$i]->getId() . "' type='number' min='80' max='500'>";
             $table .= "</td>";
             $table .= "<td style='display:none'>";
             $table .= "<select id='drop" . $cursos[$i]->getId() . "' class='dropatu'>";
             if ($departamentos != null) {
                 for ($j = 0; $j < sizeof($departamentos); $j++) {
                     $table .= "<option value='" . $departamentos[$j]->getId() . "'";
                     if ($departamentos[$j]->getNome() == $departamento->getNome()) {
                         $table .= " selected";
                     }
                     $table .= ">" . $departamentos[$j]->getNome() . "</option>";
                 }
             }
             $table .= "</select>";
             $table .= "</td>";
             $table .= "<td style='display:none'>";
             $table .= "<button id='c" . $cursos[$i]->getId() . "' class='confirmar'>Confirmar</button>";
             $table .= "</td>";
             $table .= "<td style='display:none'>";
             $table .= "<button id='can" . $cursos[$i]->getId() . "' class='cancelar'>Cancelar</button>";
             $table .= "</td>";
             $table .= "</tr>";
         }
     }
     $table .= "</table>";
     $table .= "<br>";
     $table .= "<button class='instbut nav'>Institutos</button>";
     $table .= "<button class='deptbut nav'>Departamentos</button>";
     $table .= "<button class='cursbut nav'>Cursos</button>";
     $output = file_get_contents("/var/www/html/Projeto Final BD/Codigo/exibicao/html/curso.html");
     $output = str_replace("tabela", $table, $output);
     echo $output;
 }