static function ConcluiCrlChave(CrlChave $ch) { TTransaction::open('my_config'); if ($conn = TTransaction::get()) { $sql = "UPDATE laboratorios SET chave_laboratorio=0\r\n WHERE id_laboratorio = ?"; $sth = $conn->prepare($sql); $sth->execute(array($ch->getLaboratorioId())); $sql = "UPDATE ctrl_chaves SET dt_final_controle=?\r\n WHERE laboratorio_id = ?"; $sth = $conn->prepare($sql); $sth->execute(array($ch->getDtFinalControle(), $ch->getLaboratorioId())); TTransaction::close(); } else { echo 'Sem conexão com banco!'; } }
$criteria->setValueCriteria('0'); $laboratorios = LabMapper::getLabs($criteria); } if (array_key_exists('save', $_POST)) { $dados = array('nome_usuario' => array('Usuário'), 'dt_inicial_controle' => array('Data', 'tipo' => 'data')); $validacao = ValidaFormulario($dados); if ($validacao === true) { $data = array('professor_id' => $_GET['key'], 'laboratorio_id' => $_POST['laboratorio_id'], 'observacao_controle' => $_POST['observacao_controle'] == '' ? null : $_POST['observacao_controle'], 'dt_inicial_controle' => Utils::conv_data_to_us($_POST['dt_inicial_controle']) . ' ' . $_POST['hora_inicial_controle']); $ch = new CrlChave(); CrlChaveMapper::map($ch, $data); CrlChaveMapper::addCrlChave($ch); header('location:index.php?modulo=chaves&page=visualizar'); } } if (array_key_exists('labkey', $_GET)) { $crlchave = new CrlChave(); $crlchave->setLaboratorioId($_GET['labkey']); $crlchave->setDtFinalControle(date('Y-m-d H:i:s')); CrlChaveMapper::ConcluiCrlChave($crlchave); header('location:index.php?modulo=chaves&page=visualizar'); } if (array_key_exists('lab', $_GET)) { $page = 'add-lab'; if (array_key_exists('labkeyedit', $_GET)) { $lab = Utils::getById($_GET['labkeyedit'], 'laboratorios', 'id_laboratorio', 'Lab'); } if (array_key_exists('saveLab', $_POST)) { $dados = array('nome_laboratorio' => array('Laboratório'), 'numero_laboratorio' => array('Número', 'tipo' => 'inteiro')); $validacao = ValidaFormulario($dados); if ($validacao === true) { $data = array('nome_laboratorio' => $_POST['nome_laboratorio'], 'numero_laboratorio' => $_POST['numero_laboratorio']);