pen_map_hipotese_legal_envio_cadastrar.php
9.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?php
/**
*
* @author Join Tecnologia
*/
require_once dirname(__FILE__) . '/../../SEI.php';
session_start();
define('PEN_RECURSO_ATUAL', 'pen_map_hipotese_legal_envio_cadastrar');
define('PEN_RECURSO_BASE', 'pen_map_hipotese_legal_envio');
define('PEN_PAGINA_TITULO', 'Mapeamento de Hipótese Legal para Envio');
define('PEN_PAGINA_GET_ID', 'id_mapeamento');
$objPagina = PaginaSEI::getInstance();
$objBanco = BancoSEI::getInstance();
$objSessao = SessaoSEI::getInstance();
try {
$objBanco->abrirConexao();
$objSessao->validarLink();
$objSessao->validarPermissao(PEN_RECURSO_ATUAL);
$arrComandos = array();
$bolSomenteLeitura = false;
switch ($_GET['acao']) {
case PEN_RECURSO_BASE.'_cadastrar':
$arrComandos[] = '<button type="submit" id="btnSalvar" value="Salvar" class="infraButton"><span class="infraTeclaAtalho">S</span>alvar</button>';
$arrComandos[] = '<button type="button" id="btnCancelar" value="Cancelar" onclick="location.href=\'' . $objPagina->formatarXHTML($objSessao->assinarLink('controlador.php?acao='.PEN_RECURSO_BASE.'_listar&acao_origem=' . $_GET['acao'])) . '\';" class="infraButton"><span class="infraTeclaAtalho">C</span>ancelar</button>';
if(array_key_exists(PEN_PAGINA_GET_ID, $_GET) && !empty($_GET[PEN_PAGINA_GET_ID])){
$strTitulo = sprintf('Editar %s', PEN_PAGINA_TITULO);
}
else {
$strTitulo = sprintf('Novo %s', PEN_PAGINA_TITULO);
}
break;
case PEN_RECURSO_BASE.'_visualizar':
$arrComandos[] = '<button type="button" name="btnFechar" value="Fechar" class="infraButton" onclick="location.href=\'' . $objPagina->formatarXHTML($objSessao->assinarLink('controlador.php?acao='.PEN_RECURSO_BASE.'_listar&acao_origem=' . $_GET['acao'])) . '\';"><span class="infraTeclaAtalho">F</span>echar</button>';
$bolSomenteLeitura = true;
$strTitulo = sprintf('Consultar %s', PEN_PAGINA_TITULO);
break;
default:
throw new InfraException("Ação '" . $_GET['acao'] . "' não reconhecida.");
}
$objPenRelHipoteseLegalRN = new PenRelHipoteseLegalEnvioRN();
//--------------------------------------------------------------------------
// Ao por POST esta salvando o formulrio
if(strtoupper($_SERVER['REQUEST_METHOD']) === 'POST') {
if(!array_key_exists('id_hipotese_legal', $_POST) || empty($_POST['id_hipotese_legal'])) {
throw new InfraException('Nenhuma "Espécie Documental" foi selecionada');
}
if(!array_key_exists('id_barramento', $_POST) || empty($_POST['id_barramento'])) {
throw new InfraException('Nenhum "Tipo de Documento" foi selecionado');
}
$objPenRelHipoteseLegalDTO = new PenRelHipoteseLegalDTO();
$objPenRelHipoteseLegalDTO->setNumIdHipoteseLegal($_POST['id_hipotese_legal']);
$objPenRelHipoteseLegalDTO->setNumIdBarramento($_POST['id_barramento']);
$objPenRelHipoteseLegalDTO->setStrTipo('E');// Enviado
$numIdMapeamento = 0;
if(array_key_exists(PEN_PAGINA_GET_ID, $_GET) && !empty($_GET[PEN_PAGINA_GET_ID])) {
$objPenRelHipoteseLegalDTO->setDblIdMap($_GET[PEN_PAGINA_GET_ID]);
$mapeamento = $objPenRelHipoteseLegalRN->alterar($objPenRelHipoteseLegalDTO);
$numIdMapeamento = $_GET[PEN_PAGINA_GET_ID];
}
else {
$mapeamento = $objPenRelHipoteseLegalRN->cadastrar($objPenRelHipoteseLegalDTO);
$numIdMapeamento = $mapeamento->getDblIdMap();
}
header('Location: '.$objSessao->assinarLink('controlador.php?acao='.PEN_RECURSO_BASE.'_listar&acao_origem='.$_GET['acao'].'&id_mapeamento='.$numIdMapeamento.PaginaSEI::getInstance()->montarAncora($numIdMapeamento)));
exit(0);
}
// Ao por GET + ID esta carregando o formulrio
else if(array_key_exists(PEN_PAGINA_GET_ID, $_GET) && !empty($_GET[PEN_PAGINA_GET_ID])){
$objPenRelHipoteseLegalDTO = new PenRelHipoteseLegalDTO();
$objPenRelHipoteseLegalDTO->setDblIdMap($_GET[PEN_PAGINA_GET_ID]);
$objPenRelHipoteseLegalDTO->retTodos();
$objEspecieDocumentalBD = new GenericoBD(BancoSEI::getInstance());
$objPenRelHipoteseLegalDTO = $objEspecieDocumentalBD->consultar($objPenRelHipoteseLegalDTO);
}
if(empty($objPenRelHipoteseLegalDTO)){
$objPenRelHipoteseLegalDTO = new PenRelHipoteseLegalDTO();
$objPenRelHipoteseLegalDTO->setNumIdHipoteseLegal(0);
$objPenRelHipoteseLegalDTO->setNumIdBarramento(0);
}
if(array_key_exists(PEN_PAGINA_GET_ID, $_GET) && !empty($_GET[PEN_PAGINA_GET_ID])) {
$objPenRelHipoteseLegalDTO->setDblIdMap($_GET[PEN_PAGINA_GET_ID]);
}
//--------------------------------------------------------------------------
// Auto-Complete
//--------------------------------------------------------------------------
// Mapeamento da hipotese legal do local j utilizados
$arrNumIdHipoteseLegal = $objPenRelHipoteseLegalRN->getIdHipoteseLegalEmUso($objPenRelHipoteseLegalDTO, 'E');
// Mapeamento da hipotese legal local
$objHipoteseLegalDTO = new HipoteseLegalDTO();
if(!empty($arrNumIdHipoteseLegal)) {
// Remove os que j esto em uso
$objHipoteseLegalDTO->setNumIdHipoteseLegal($arrNumIdHipoteseLegal, InfraDTO::$OPER_NOT_IN);
}
$objHipoteseLegalDTO->setStrStaNivelAcesso(ProtocoloRN::$NA_RESTRITO); //Restrito
$objHipoteseLegalDTO->setStrSinAtivo('S');
$objHipoteseLegalDTO->setOrdStrNome(InfraDTO::$TIPO_ORDENACAO_ASC);
$objHipoteseLegalDTO->retNumIdHipoteseLegal();
$objHipoteseLegalDTO->retStrNome();
$objHipoteseLegalRN = new HipoteseLegalRN();
$arrMapIdHipoteseLegal = InfraArray::converterArrInfraDTO($objHipoteseLegalRN->listar($objHipoteseLegalDTO), 'Nome', 'IdHipoteseLegal');
// Mapeamento da hipotese legal remota
$objPenHipoteseLegalDTO = new PenHipoteseLegalDTO();
$objPenHipoteseLegalDTO->setOrdStrNome(InfraDTO::$TIPO_ORDENACAO_ASC);
$objPenHipoteseLegalDTO->retNumIdHipoteseLegal();
$objPenHipoteseLegalDTO->retStrNome();
$objPenHipoteseLegalRN = new PenHipoteseLegalRN();
$arrMapIdBarramento = InfraArray::converterArrInfraDTO($objPenHipoteseLegalRN->listar($objPenHipoteseLegalDTO), 'Nome', 'IdHipoteseLegal');
//--------------------------------------------------------------------------
}
catch (InfraException $e) {
$objPagina->processarExcecao($e);
}
catch(Exception $e) {
$objPagina->processarExcecao($e);
}
// View
ob_clean();
$objPagina->montarDocType();
$objPagina->abrirHtml();
$objPagina->abrirHead();
$objPagina->montarMeta();
$objPagina->montarTitle(':: ' . $objPagina->getStrNomeSistema() . ' - ' . $strTitulo . ' ::');
$objPagina->montarStyle();
?>
<style type="text/css">
.input-label-first{position:absolute;left:0%;top:0%;width:25%; color: #666!important}
.input-field-first{position:absolute;left:0%;top:15%;width:25%}
.input-label-third {position:absolute;left:0%;top:40%;width:25%; color:#666!important}
.input-field-third {position:absolute;left:0%;top:55%;width:25%;}
</style>
<?php $objPagina->montarJavaScript(); ?>
<script type="text/javascript">
function inicializar(){
}
function onSubmit() {
var form = jQuery('#<?php print PEN_RECURSO_BASE; ?>_form');
var field = jQuery('select[name=id_hipotese_legal]', form);
if(field.val() === 'null'){
alert('Nenhuma "Hipótese Legal SEI - <?=PaginaSEI::tratarHTML($objSessao->getStrSiglaOrgaoUnidadeAtual())?>" foi selecionada');
field.focus();
return false;
}
field = jQuery('select[name=id_barramento]', form);
if(field.val() === 'null'){
alert('Nenhum "Hipótese Legal PEN" foi selecionado');
field.focus();
return false;
}
}
</script>
<?php
$objPagina->fecharHead();
$objPagina->abrirBody($strTitulo,'onload="inicializar();"');
?>
<form id="<?php print PEN_RECURSO_BASE; ?>_form" onsubmit="return onSubmit();" method="post" action="<?php //print $objSessaoSEI->assinarLink($strProprioLink); ?>">
<?php $objPagina->montarBarraComandosSuperior($arrComandos); ?>
<?php $objPagina->montarAreaValidacao(); ?>
<?php $objPagina->abrirAreaDados('12em'); ?>
<label for="id_hipotese_legal" class="infraLabelObrigatorio input-label-first">Hipótese Legal SEI - <?=PaginaSEI::tratarHTML($objSessao->getStrSiglaOrgaoUnidadeAtual())?> :</label>
<select name="id_hipotese_legal" class="infraSelect input-field-first"<?php if($bolSomenteLeitura): ?> disabled="disabled" readonly="readonly"<?php endif; ?>>
<?php print InfraINT::montarSelectArray('', 'Selecione', $objPenRelHipoteseLegalDTO->getNumIdHipoteseLegal(), $arrMapIdHipoteseLegal); ?>
</select>
<label for="id_barramento" class="infraLabelObrigatorio input-label-third">Hipótese Legal PEN:</label>
<select name="id_barramento" class="infraSelect input-field-third"<?php if($bolSomenteLeitura): ?> disabled="disabled" readonly="readonly"<?php endif; ?>>
<?php print InfraINT::montarSelectArray('', 'Selecione', $objPenRelHipoteseLegalDTO->getNumIdBarramento(), $arrMapIdBarramento); ?>
</select>
<?php print $objPagina->fecharAreaDados(); ?>
</form>
<?php $objPagina->fecharBody(); ?>
<?php $objPagina->fecharHtml(); ?>