-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheventReg.php
168 lines (128 loc) · 7.01 KB
/
eventReg.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
<?php
include('session.php');
include 'php/PHPMailerAutoload.php';
include 'php/functions.php';
$allcondos = 'all';
$ncondominio = $_POST["condominios"];
$dataevento = $_POST["dataevento"];
$tipoevento = $_POST["tipo_evento"];
$descevento = $_POST["descevento"];
$horaevento = $_POST["horaevento"];
$ncondominio = stripslashes($ncondominio);
$ncondominio = mysqli_real_escape_string($connection, $ncondominio);
$dataevento = stripslashes($dataevento);
$dataevento = mysqli_real_escape_string($connection, $dataevento);
$tipoevento = stripslashes($tipoevento);
$tipoevento = mysqli_real_escape_string($connection, $tipoevento);
$descevento = stripslashes($descevento);
$descevento = mysqli_real_escape_string($connection, $descevento);
$horaevento = stripslashes($horaevento);
$horaevento = mysqli_real_escape_string($connection, $horaevento);
if($ncondominio != 'all'){
$query_consulta = "SELECT DISTINCT id_proprietario FROM fracoes WHERE id_condo ='" . $ncondominio . "'";
$query = mysqli_query($connection, $query_consulta);
while ($row = mysqli_fetch_assoc($query)) {
$query_users = "SELECT * FROM users WHERE id_user= '" . $row["id_proprietario"] . "'";
$query = mysqli_query($connection, $query_users);
$row = mysqli_fetch_assoc($query);
$usermail = $row["user_mail"];
$username = $row["user_nicename"];
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com;smtp-relay.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'arkham2016';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->CharSet = 'UTF-8';
$mail->setFrom('[email protected]', 'Condominus SA');
$mail->addAddress($usermail, $username);
$mail->addReplyTo('[email protected]', 'Information');
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true);
if($tipoevento == 'R'){
$tipoeventotxt = 'Reunião';
}
elseif($tipoevento == 'L'){
$tipoeventotxt = 'Limpeza';
}
elseif($tipoevento == 'M'){
$tipoeventotxt = 'Manutenção';
}
$mail->Subject = 'Novo Evento no seu Condomínio';
$mail->Body = 'Foi feita a marcação de uma ' . $tipoeventotxt . ' que irá ser realizada a : ' . $dataevento . ' pelas ' . $horaevento;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$query_insert = "INSERT INTO eventos ( id_frac, id_condo, tipo_evento, data_ini, descricao, hora_ini) VALUES ( null, '" . $ncondominio . "', '" . $tipoevento . "', '" . $dataevento . "','" . $descevento . "', '" . $horaevento . "')";
if ((mysqli_query($connection, $query_insert)) && ($mail->send())) {
echo "<script type=\"text/javascript\">".
"alert('Novo evento criado com sucesso');"
. "window.location = 'menu.php';".
"</script>";
}
else {
echo "<script type=\"text/javascript\">".
"alert('Erro ao criar evento!');"
. "window.location = 'menu.php';".
"</script>";
}
$connection->close();
}
}
/*
elseif($ncondominio == $allcondos){
$query_consultas = "SELECT DISTINCT id_proprietario FROM fracoes";
$query = mysqli_query($connection, $query_consultas);
while ($row = mysqli_fetch_assoc($query)) {
$query_user = "SELECT * FROM users WHERE id_user= '" . $row["id_proprietario"] . "'";
$query = mysqli_query($connection, $query_user);
$rows = mysqli_fetch_assoc($query);
$usermail = $rows["user_mail"];
$username = $rows["user_nicename"];
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com;smtp-relay.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'arkham2016';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->CharSet = 'UTF-8';
$mail->setFrom('[email protected]', 'Condominus SA');
$mail->addAddress($usermail, $username);
$mail->addReplyTo('[email protected]', 'Information');
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true);
if($tipoevento == 'R'){
$tipoeventotxt = 'Reunião';
}
elseif($tipoevento == 'L'){
$tipoeventotxt = 'Limpeza';
}
elseif($tipoevento == 'M'){
$tipoeventotxt = 'Manutenção';
}
$mail->Subject = 'Novo Evento no seu Condomínio';
$mail->Body = 'Foi feita a marcação de uma ' . $tipoeventotxt . ' que irá ser realizada a : ' . $dataevento . ' pelas ' . $horaevento;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$query_insert = "INSERT INTO eventos ( id_frac, id_condo, tipo_evento, data_ini, descricao, hora_ini) VALUES ( null, '" . $ncondominio . "', '" . $tipoevento . "', '" . $dataevento . "','" . $descevento . "', '" . $horaevento . "')";
if ((mysqli_query($connection, $query_insert)) && ($mail->send())) {
echo "<script type=\"text/javascript\">".
"alert('Novo evento criado com sucesso');"
. "window.location = 'painel.php';".
"</script>";
}
else {
echo "<script type=\"text/javascript\">".
"alert('Erro ao criar evento em todos os condominios!');"
.
"</script>";
echo $query_insert;
}
$connection->close();
}
}
*/
?>