-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcongregacion.php
301 lines (274 loc) · 11.4 KB
/
congregacion.php
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<?php require_once("includes/conexion.php");
PermitirAcceso(101);
if (isset($_GET['id']) && ($_GET['id'] != "")) {
$NumCong = base64_decode($_GET['id']);
}
if (isset($_GET['tl']) && ($_GET['tl'] != "")) { //0 Si se está creando. 1 Se se está editando.
$edit = $_GET['tl'];
} elseif (isset($_POST['tl']) && ($_POST['tl'] != "")) {
$edit = $_POST['tl'];
} else {
$edit = 0;
}
if ($edit == 0) {
$Title = "Crear congregación";
} else {
$Title = "Editar congregación";
}
if (isset($_POST['P']) && ($_POST['P'] != "")) { //Insertar registro
try {
if ($_POST['tl'] == 1) { //Actualizar
$Type = 2;
} else { //Crear
$Type = 1;
}
$ParamInsert = array(
"'" . base64_decode($_POST['ID']) . "'",
"'" . $_POST['NumCong'] . "'",
"'" . strtoupper($_POST['NombreCong']) . "'",
"'" . strtoupper($_POST['Ciudad']) . "'",
"'" . strtoupper($_POST['Municipio']) . "'",
"'" . strtoupper($_POST['Pais']) . "'",
"'" . strtoupper($_POST['Direccion']) . "'",
"'" . $_POST['CorreoJW'] . "'",
"'" . $_POST['Token'] . "'",
"'" . $_SESSION['CodUser'] . "'",
$Type
);
$SQL_InsUser = EjecutarSP('usp_tbl_Congregaciones', $ParamInsert, $_POST['P']);
if ($SQL_InsUser) {
sqlsrv_close($conexion);
if ($_POST['tl'] == 0) { //Creando Entrega
header('Location:' . base64_decode($_POST['return']) . '&a=' . base64_encode("OK_Cong"));
} else { //Actualizando Entrega
header('Location:' . base64_decode($_POST['return']) . '&a=' . base64_encode("OK_EditCong"));
}
} else {
throw new Exception('Ha ocurrido un error al insertar la congregacion');
sqlsrv_close($conexion);
}
} catch (Exception $e) {
echo 'Excepcion capturada: ', $e->getMessage(), "\n";
}
}
if ($edit == 1) { //Editar
$SQL = Seleccionar('uvw_tbl_Congregaciones', '*', "NumCong='" . $NumCong . "'");
$row = sqlsrv_fetch_array($SQL);
//Publicadores
// $SQL_Publicadores=Seleccionar('uvw_tbl_Publicadores','*',"NumCong='".$row['NumCong']."'",'Nombre');
}
//Estados
$SQL_Estados = Seleccionar('uvw_tbl_Estados', '*');
//Perfiles
// if(PermitirFuncion(101)){
// $SQL_Perfiles=Seleccionar('uvw_tbl_PerfilesUsuarios','*',"NumCong='".$_SESSION['NumCong']."' OR NumCong='0'",'PerfilUsuario');
// }else{
// $SQL_Perfiles=Seleccionar('uvw_tbl_PerfilesUsuarios','*',"NumCong='".$_SESSION['NumCong']."'",'PerfilUsuario');
// }
// if(PermitirFuncion(101)){
// $SQL_Cong=Seleccionar('uvw_tbl_Congregaciones','*','','NombreCongregacion');
// }else{
// $SQL_Publicadores=Seleccionar('uvw_tbl_Publicadores','*',"NumCong='".$_SESSION['NumCong']."'",'Nombre');
// }
?>
<!DOCTYPE html>
<html><!-- InstanceBegin template="/Templates/PlantillaPrincipal.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<?php include_once("includes/cabecera.php"); ?>
<!-- InstanceBeginEditable name="doctitle" -->
<title><?php echo $Title; ?> | <?php echo NOMBRE_PORTAL; ?></title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<script>
function ValidarUsuario(Cong) {
var spinner = document.getElementById('spinner1');
spinner.style.visibility = 'visible';
$.ajax({
type: "GET",
url: "includes/procedimientos.php?type=3&cong=" + Cong,
success: function(response) {
document.getElementById('Validar').innerHTML = response;
spinner.style.visibility = 'hidden';
if (response == "<p class='text-danger'><i class='fa fa-times-circle-o'></i> No disponible</p>") {
document.getElementById('Crear').disabled = true;
} else {
document.getElementById('Crear').disabled = false;
}
}
});
}
function generarToken() {
const rand = Math.random().toString(36).substr(2);
// console.log(rand)
const text = document.getElementById("Token")
text.value = rand
}
function Mostrar() {
var x = document.getElementById("Password").getAttribute("type");
if (x == "password") {
document.getElementById('Password').setAttribute('type', 'text');
document.getElementById('VerPass').setAttribute('class', 'glyphicon glyphicon-eye-close');
document.getElementById('aVerPass').setAttribute('title', 'Ocultar contrase' + String.fromCharCode(241) + 'a');
} else {
document.getElementById('Password').setAttribute('type', 'password');
document.getElementById('VerPass').setAttribute('class', 'glyphicon glyphicon-eye-open');
document.getElementById('aVerPass').setAttribute('title', 'Mostrar contrase' + String.fromCharCode(241) + 'a');
}
}
</script>
<!-- InstanceEndEditable -->
</head>
<body>
<div id="wrapper">
<?php include_once("includes/menu.php"); ?>
<div id="page-wrapper" class="gray-bg">
<?php include_once("includes/menu_superior.php"); ?>
<!-- InstanceBeginEditable name="Contenido" -->
<div class="row wrapper border-bottom white-bg page-heading">
<div class="col-sm-8">
<h2><?php echo $Title; ?></h2>
<ol class="breadcrumb">
<li>
<a href="index1.php">Inicio</a>
</li>
<li>
<a href="#">Administración</a>
</li>
<li>
<a href="gestionar_congregacion.php">Gestionar congregación</a>
</li>
<li class="active">
<strong><?php echo $Title; ?></strong>
</li>
</ol>
</div>
</div>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-lg-12">
<div class="ibox-content">
<?php include("includes/spinner.php"); ?>
<form action="congregacion.php" method="post" class="form-horizontal" id="frmCong">
<div class="form-group">
<label class="col-lg-12">
<h3 class="bg-success p-xs b-r-sm"><i class="fa fa-info-circle"></i> Datos de la congregación</h3>
</label>
</div>
<div class="form-group">
<label class="col-lg-1 control-label">Número de congregación <span class="text-danger">*</span></label>
<div class="col-lg-2"><input name="NumCong" type="text" required="required" class="form-control" id="NumCong" value="<?php if ($edit == 1) {
echo $row['NumCong'];
} ?>" onChange="ValidarUsuario(this.value);"></div>
<label class="col-lg-2 control-label">Nombre de la congregación <span class="text-danger">*</span></label>
<div class="col-lg-3"><input name="NombreCong" type="text" required="required" class="form-control" id="NombreCong" value="<?php if ($edit == 1) {
echo $row['NombreCongregacion'];
} ?>"></div>
<div id="Validar" class="col-lg-1">
<div id="spinner1" style="visibility: hidden;" class="sk-spinner sk-spinner-wave">
<div class="sk-rect1"></div>
<div class="sk-rect2"></div>
<div class="sk-rect3"></div>
<div class="sk-rect4"></div>
<div class="sk-rect5"></div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-lg-1 control-label">Ciudad <span class="text-danger">*</span></label>
<div class="col-lg-3"><input name="Ciudad" type="text" required="required" class="form-control" id="Ciudad" value="<?php if ($edit == 1) {
echo $row['Ciudad'];
} ?>"></div>
<label class="col-lg-1 control-label">Municipio</label>
<div class="col-lg-3"><input name="Municipio" type="text" class="form-control" id="Municipio" value="<?php if ($edit == 1) {
echo $row['Municipio'];
} ?>"></div>
<label class="col-lg-1 control-label">Pais</label>
<div class="col-lg-3"><input name="Pais" type="text" class="form-control" id="Pais" value="<?php if ($edit == 1) {
echo $row['Pais'];
} ?>"></div>
</div>
<div class="form-group">
<label class="col-lg-1 control-label">Dirección <span class="text-danger">*</span></label>
<div class="col-lg-3"><input name="Direccion" type="text" required="required" class="form-control" id="Direccion" value="<?php if ($edit == 1) {
echo $row['Direccion'];
} ?>"></div>
<label class="col-lg-1 control-label">Correo JW</label>
<div class="col-lg-3"><input name="CorreoJW" type="text" class="form-control" id="CorreoJW" value="<?php if ($edit == 1) {
echo $row['CorreoJW'];
} ?>"></div>
<label class="col-lg-1 control-label">Token <span class="text-danger">*</span></label>
<div class="col-lg-2"><input name="Token" type="text" required="required" class="form-control" id="Token" value="<?php if ($edit == 1) {
echo $row['Token'];
} ?>"></div>
<div class="col-lg-1"><button type="button" onClick="generarToken();" class="alkin btn btn-success btn-xs" title="Generar nuevo token"><i class="fa fa-refresh"></i></button></div>
</div>
<div class="form-group">
<div class="col-lg-9">
<?php if ($edit == 1) { ?>
<button class="btn btn-warning" type="submit" id="Crear"><i class="fa fa-refresh"></i> Actualizar congregación</button>
<?php } else { ?>
<button class="btn btn-primary" type="submit" id="Crear"><i class="fa fa-check"></i> Crear congregación</button>
<?php } ?>
<a href="gestionar_congregacion.php" class="btn btn-outline btn-default"><i class="fa fa-arrow-circle-o-left"></i> Regresar</a>
</div>
</div>
<?php
$EliminaMsg = array("&a=" . base64_encode("OK_Cong"), "&a=" . base64_encode("OK_EditCong")); //Eliminar mensajes
if (isset($_GET['return'])) {
$_GET['return'] = str_replace($EliminaMsg, "", base64_decode($_GET['return']));
}
if (isset($_GET['return'])) {
$return = base64_decode($_GET['pag']) . "?" . $_GET['return'];
} else {
$return = "gestionar_congregacion.php?";
} ?>
<input type="hidden" id="P" name="P" value="<?php if ($edit == 1) {
echo "1";
} else {
echo "2";
} ?>" />
<input type="hidden" id="tl" name="tl" value="<?php echo $edit; ?>" />
<input type="hidden" id="return" name="return" value="<?php echo base64_encode($return); ?>" />
<input type="hidden" id="ID" name="ID" value="<?php if ($edit == 1) {
echo base64_encode($row['ID']);
} ?>" />
</form>
</div>
</div>
</div>
</div>
<!-- InstanceEndEditable -->
<?php include_once("includes/footer.php"); ?>
</div>
</div>
<?php include_once("includes/pie.php"); ?>
<!-- InstanceBeginEditable name="EditRegion4" -->
<script>
$(document).ready(function() {
$("#frmCong").validate({
submitHandler: function(form) {
Swal.fire({
title: "¿Está seguro que desea guardar los datos?",
icon: "question",
showCancelButton: true,
confirmButtonText: "Si, confirmo",
cancelButtonText: "No"
}).then((result) => {
if (result.isConfirmed) {
$('.ibox-content').toggleClass('sk-loading', true);
form.submit();
}
});
}
});
$('.chosen-select').chosen({
width: "100%"
});
$(".select2").select2();
});
</script>
<!-- InstanceEndEditable -->
</body>
<!-- InstanceEnd -->
</html>
<?php sqlsrv_close($conexion); ?>