/
guardarRespuesta.php
167 lines (145 loc) · 6.45 KB
/
guardarRespuesta.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
<?php
include("sources/funciones.php");
if ($_SESSION["Activa"] && $_POST and $_SESSION["Tipo_usuario"] = "normal") {
include_once("sources/Query.inc");
$query = new Query();
$vR_id = __($_POST['idOficio']);
$mailQuery = $query->select("mailCiudadano m", "oficio", "idOficio='$vR_id'");
if ($mailQuery) {
foreach ($mailQuery as $m) {
$mail = $m->m;
}
}
$notificacionRespuesta = getRedNotificacionRespuestas();
$mailOpcional = __($_POST['mailOpcional']);
$v_asunto = __($_POST['asunto']);
$v_redaccion = __($_POST['redaccion']);
$cuerpoMail = '<p style="font-size: large;">
' . $notificacionRespuesta['redaccionRespuestas'] . '
<br>
' . $v_redaccion . '
</p>
<p style="text-align: center; font-weight: bold;">
<font style="font-size: larger;">Coordinación General de Atención Ciudadana</font><br>
Delegación SEP Estado de México
</p>';
$nom = "respuesta";
$query2 = new Query();
if ($mailOpcional != '') {
$_FILES["imagen"]["name"];
$archivoAdjunto = guardaArchivo("Respuestas", $nom);
if ($query2->insert("respuesta", "fecha, asunto, redaccion, archivoAdjunto, oficio_idOficio", "now(), '$v_asunto', '$v_redaccion','$archivoAdjunto', $vR_id")) {
require_once('sources/AttachMailer.php');
$mailer = new AttachMailer("no-reply@sep.com", "$mail,$mailOpcional", "$v_asunto", "$cuerpoMail");
$mailer->attachFile($archivoAdjunto);
$res = ($mailer->send() ? "OK" : "error");
if ($res == "OK") {
$query->update("oficio", "status=3", "idOficio=$vR_id");
$respuesta = '
<img src="images/ok.png" width="100">
<h4>
Respuesta enviada correctamente
</h4>
';
} else {
$respuesta = '
<img src="images/error.png" width="100">
<h4>
Ha ocurrido un error
</h4>
';
}
} else {
$respuesta = '
<img src="images/error.png" width="100">
<h4>
Ha ocurrido un error
</h4>
';
}
} else {
$_FILES["imagen"]["name"];
$archivoAdjunto = guardaArchivo("Respuestas", $nom);
if ($query2->insert("respuesta", "fecha, asunto, redaccion, archivoAdjunto, oficio_idOficio", "now(), '$v_asunto', '$v_redaccion','$archivoAdjunto', $vR_id")) {
require_once('sources/AttachMailer.php');
$mailer = new AttachMailer("no-reply@sep.com", "$mail", "$v_asunto", "$cuerpoMail");
$mailer->attachFile($archivoAdjunto);
$res = ($mailer->send() ? "OK" : "error");
if ($res == "OK") {
$query->update("oficio", "status=3", "idOficio=$vR_id");
$respuesta = '
<img src="images/ok.png" width="100">
<h4>
Respuesta enviada correctamente
</h4>
';
} else {
$respuesta = '
<img src="images/error.png" width="100">
<h4>
Ha ocurrido un error
</h4>
';
}
} else {
$respuesta = '
<img src="images/error.png" width="100">
<h4>
Ha ocurrido un error
</h4>
';
}
}
?>
<!DOCTYPE html>
<html>
<head>
<?php include ('sources/template/head.php'); ?>
<meta charset="UTF-8">
<title>Registro Respuesta></title>
<meta http-equiv="Refresh" content="2;url=consultarRespuesta.php" />
</head>
<body class="skin-black-light sidebar-mini sidebar-collapse">
<!-- Site wrapper -->
<div class="wrapper">
<header class="main-header">
<?php include ('sources/template/header.php'); ?>
</header>
<div class="content-wrapper">
<?php include ('sources/template/titulo.php'); ?>
<!-- Main content -->
<section class="content">
<div class="row">
<!-- left column -->
<div class="col-md-6 col-md-offset-3">
<!-- Default box -->
<div class="box box-solid box-default">
<div class="box-header with-border">
<h3 class="box-title">Redactar Respuesta</h3>
</div>
<div class="box-body text-center">
<?php echo $respuesta; ?>
</div><!-- /.box-body -->
<div class="box-footer text-center">
<h4>
<small>Redireccionando...</small>
</h4>
<img src="images/cargando.gif" width="20">
<br>
</div><!-- /.box-footer-->
</div><!-- /.box -->
</div>
</div>
</section><!-- /.content -->
</div><!-- /.content-wrapper -->
<?php include ('sources/template/pie.php'); ?>
</div><!-- ./wrapper -->
<?php include ('sources/template/scripts.php'); ?>
</body>
</html>
<?php
} else {
redireccionar();
}
?>