· 8 years ago · Aug 06, 2018, 02:04 PM
1<!DOCTYPE html>
2<?php
3$anexo = '';
4if (!empty($_POST['anexo'])) {
5 $moveu = false;
6 $dirArquivo = '../arquivoTemp/';
7 $size = 2; //MegaByte ---> (1.024*1.024)= 1.048.576 Bytes
8 $arquivo = $_FILES['arquivo'];
9 if ($arquivo['type'] != 'application/pdf' && $arquivo['type'] != 'image/jpeg') {
10 echo '<br><br><center><h1>Selecione somente arquivo em PDF ou JPG.</h1></center>';
11 echo"<center><a href='../lista/Lista.php'>Voltar</a></center>";
12 exit;
13 }
14 if ($arquivo['size'] > ($size * (1024 * 1024))) {
15 echo '<br><br><center><h1>Arquivo maior que ' . $size . ' MB não é permitido.</h1></center>';
16
17 echo"<center><a href='../lista/Lista.php'>Voltar</a></center>";
18 exit;
19 }
20
21 if (isset($arquivo['tmp_name']) && !empty($arquivo['tmp_name']) && ($arquivo['type'] == 'image/jpeg' || $arquivo['type'] == 'application/pdf')) {
22 $ext = pathinfo($arquivo['name'], PATHINFO_EXTENSION);
23 $nomeArqDB = md5(time() . rand(0, 99));
24 $nomeArquivo = $nomeArqDB . '.' . $ext;
25 move_uploaded_file($arquivo['tmp_name'], $dirArquivo . $nomeArquivo);
26 $moveu = true;
27 }
28}
29?>
30
31<?php
32//-----------------------------------------------------------------------------------------------------------
33$deEmail = 'sistema@sistema.org.br';
34$senha = 'minhasenha';
35$deNome = 'Sistema Sta Casa';
36$paraEmal = array(// Quem vai receber o email
37 array('email' => '@gmail.com', 'nome' => 'Moises'),
38);
39$paraCopia = array(// Quem vai receber uma copia do email
40 array('email' => 'email do ulhost.org.br', 'nome' => 'Santa Casa'),
41 array('email' => '@hotmail.com', 'nome' => 'Moisa 10')
42);
43$assunto = 'Este é o assunto do teste de email';
44//$corpoEmail = 'Aqui esta o texto do corpo da mensagem. <b> em itálico!!</b>';
45//--------------------------------------------------------------------------------------------------------------
46?>
47<?php
48include_once '../session.php';
49require_once '../conector/conectoreditortexto.php';
50$solCod = '';
51$acao = 'enviar';
52$usuario = 'Nome do Usuário';
53//----------------------------
54$solTipo = ''; //Tipo de solicitação
55//---------------------------------
56$solicitante = 'Santa Casa de Misericórdia de Capivari';
57$cnssol = '';
58$executante = '';
59$cnsexe = '';
60$nomepaciente = '';
61$prontuario = '';
62$nrcns = '';
63$dtnas = '';
64$rg = '';
65$cpf = '';
66$sexo = '';
67$masc = '';
68$fem = '';
69$responsavel = '';
70$fone = '';
71$endereco = '';
72$cidade = '';
73$codcidade = '';
74$uf = '';
75$cep = '';
76$principalsintoma = '';
77$condicaojustifica = '';
78$exame = '';
79$diaginicial = '';
80$cidprincipal = '';
81$cidsecundario = '';
82$cidassociado = '';
83$medsol = '';
84$crmsol = '';
85$dtsol = '';
86$dtavaliacao = '';
87$avalregulador = '';
88$medreg = '';
89$crmreg = '';
90?>
91
92<?php
93if (isset($_SESSION['USU_NOME'])) {
94 $usuario = explode(' ', $_SESSION['USU_NOME']);
95 $usuCod = $_SESSION['USU_CODIGO'];
96 $usuario = $usuCod . ' - ' . $usuario[0];
97}
98if (isset($_POST['solCod']) && !empty($_POST['solCod'])) {
99 $acao = $_POST['acao'];
100 $solCod = base64_decode($_POST['solCod']);
101 $sql = 'select s.*, date_format(sol_dt_nas, \'%d/%m/%Y\') as nasc, date_format(sol_dt_atendi, \'%d/%m/%Y\') as dtSol , date_format(sol_data, \'%d/%m/%Y\') as dtAval from solicitacao s where sol_codigo = \'' . $solCod . '\';';
102 //echo '<br>' . $sql . '<br>' . 'acao = ' . $acao . '<br>';
103 // exit;
104 $sql = $pdo->query($sql);
105 if ($sql->rowCount() > 0) {
106 $dados = $sql->fetch();
107 $solCod = $dados['SOL_CODIGO'];
108 $solTipo = $dados['SOL_TIPO'];
109 $assunto = $dados['SOL_TIPO'];
110 $executante = $dados['SOL_CONVENIO'];
111 $nomepaciente = $dados['SOL_NOME_CLIENTE'];
112 $prontuario = $dados['SOL_PRONTUARIO'];
113 $nrcns = $dados['SOL_CARTEIRINHA'];
114 $dtnas = $dados['nasc'];
115 $rg = $dados['SOL_RG'];
116 $cpf = $dados['SOL_CPF'];
117 $exame = $dados['SOL_PROCEDIMENTO'];
118 //----------------------------------
119 $sexo = $dados['SOL_SEXO'];
120 if ($sexo == '1') {
121 $sexo = 'Masculino (1)';
122 } else if ($sexo == '2') {
123 $sexo = 'Feminino (2)';
124 }
125 $responsavel = $dados['SOL_RESPONSAVEL'];
126 $fone = $dados['SOL_FONE'];
127 $endereco = $dados['SOL_ENDERECO'];
128 $cidade = $dados['SOL_CIDADE'];
129 $codcidade = $dados['SOL_IBGE_CIDADE'];
130 $uf = $dados['SOL_UF'];
131 $cep = $dados['SOL_CEP'];
132 $principalsintoma = $dados['SOL_SINTOMA'];
133 $condicaojustifica = $dados['SOL_JUSTIFICATIVA'];
134 $diaginicial = $dados['SOL_DIAGNOSTICO'];
135 $cidprincipal = $dados['SOL_CID_PRINCIPAL'];
136 $cidsecundario = $dados['SOL_CID_SECUNDARIO'];
137 $cidassociado = $dados['SOL_CID_ASSOCIADO'];
138 $dtsol = $dados['dtSol'];
139 if ($dtsol == '00/00/0000') {
140 $dtsol = '';
141 }
142 $medsol = $dados['SOL_MEDICO_SOL'];
143 $crmsol = $dados['SOL_CRM_MED_SOL'];
144 $avalregulador = $dados['SOL_AVAL_CONVENIO'];
145 $dtavaliacao = $dados['dtAval'];
146 if ($dtavaliacao == '00/00/0000') {
147 $dtavaliacao = '';
148 }
149 $medreg = $dados['SOL_MEDICO_REG'];
150 $crmreg = $dados['SOL_CRM_MED_REG'];
151
152 //-----------------------
153 }
154}
155
156//--------------------------------------------------------------------------------------------------------------
157date_default_timezone_set('America/Sao_Paulo');
158ob_start();
159?>
160<html>
161 <head>
162 <title>Solcitação de vaga:</title>
163 <meta charset='UTF-8'>
164 <meta name='viewport' content='width=device-width, initial-scale=1.0'>
165 </head>
166 <body style='width: 680px;'>
167 <div class='content' style='width: 100%;'>
168 <h4 style='margin: 0px; margin-bottom: 5px;'><?php echo $solicitante; ?></h4>
169 <h5 style='margin: 0px; margin-bottom: 5px;'><?php echo $solTipo; ?></h5>
170 <div class='line' style='display: flex;'>
171 <label style='margin: 1px;font-weight: bold;'>Paciente:</label>
172 <p style='margin: 1px;'><?php echo $nomepaciente; ?></p>
173 </div>
174 <div class='line' style='display: flex;'>
175 <label style='margin: 1px;font-weight: bold;'>Prontuário:</label>
176 <p style='margin: 1px;'><?php echo $prontuario; ?></p>
177 </div>
178 <div class='line' style='display: flex;'>
179 <label style='margin: 1px;font-weight: bold;'>Cartão nacional de Saúde:</label>
180 <p style='margin: 1px;'><?php echo $nrcns; ?></p>
181 </div>
182 <div class='line' style='display: flex;'>
183 <label style='margin: 1px;font-weight: bold;'>Data de Nascimento:</label>
184 <p style='margin: 1px;'><?php echo $dtnas; ?></p>
185 </div>
186 <div class='line' style='display: flex;'>
187 <label style='margin: 1px;font-weight: bold;'>RG:</label>
188 <p style='margin: 1px;'><?php echo $rg; ?></p>
189 </div>
190 <div class='line' style='display: flex;'>
191 <label style='margin: 1px;font-weight: bold;'>CPF:</label>
192 <p style='margin: 1px;'><?php echo $cpf; ?></p>
193 </div>
194 <div class='line' style='display: flex;'>
195 <label style='margin: 1px;font-weight: bold;'>Sexo:</label>
196 <p style='margin: 1px;'><?php echo $sexo; ?></p>
197 </div>
198 <div class='line' style='display: flex;'>
199 <label style='margin: 1px;font-weight: bold;'>Nome da Mãe:</label>
200 <p style='margin: 1px;'><?php echo $responsavel; ?></p>
201 </div>
202 <div class='line' style='display: flex;'>
203 <label style='margin: 1px;font-weight: bold;'>Telefone:</label>
204 <p style='margin: 1px;'><?php echo $fone; ?></p>
205 </div>
206 <div class='line' style='display: flex;'>
207 <label style='margin: 1px;font-weight: bold;'>Endereço:</label>
208 <p style='margin: 1px;'><?php echo $endereco; ?></p>
209 </div>
210 <div class='line' style='display: flex;'>
211 <label style='margin: 1px;font-weight: bold;'>MunicÃpio de Residência:</label>
212 <p style='margin: 1px;'><?php echo $cidade . '/' . $uf; ?></p>
213 </div>
214 <div class='line' style='display: flex;'>
215 <label style='margin: 1px;font-weight: bold;'>Código IBGE do MunicÃpio:</label>
216 <p style='margin: 1px;'><?php echo $codcidade; ?></p>
217 </div>
218 <div class='line' style='display: flex;'>
219 <label style='margin: 1px;font-weight: bold;'>CEP:</label>
220 <p style='margin: 1px;'><?php echo $cep; ?></p>
221 </div>
222 <label style='margin: 1px;font-weight: bold;'>Principais Sinais e Sintomas ClÃnicos:</label>
223 <div class='line' style='display: flex;'>
224 <p style='margin: 1px;'><?php echo $principalsintoma; ?></p>
225 </div>
226 <label style='margin: 1px;font-weight: bold;'>Condições que justificam a internação:</label>
227 <div class='line' style='display: flex;'>
228 <p style='margin: 1px;'><?php echo $condicaojustifica; ?></p>
229 </div>
230 <label style='margin: 1px;font-weight: bold;'>Principais Resultados de Provas Diagnósticas</label><br>
231 <label style='margin: 1px;font-weight: bold;'>(Resultado de exames realizados):</label>
232 <div class='line' style='display: flex;'>
233 <p style='margin: 1px;'><?php echo $exame; ?></p>
234 </div>
235 <div class='line' style='display: flex;'>
236 <label style='margin: 1px;font-weight: bold;'>Diagnóstico Inicial:</label>
237 <p style='margin: 1px;'><?php echo $diaginicial; ?></p>
238 </div>
239 <div class='line' style='display: flex;'>
240 <label style='margin: 1px;font-weight: bold;'>CID 10 Principal:</label>
241 <p style='margin: 1px;'><?php echo $cidprincipal; ?></p>
242 </div>
243 <div class='line' style='display: flex;'>
244 <label style='margin: 1px;font-weight: bold;'>CID 10 Secundário:</label>
245 <p style='margin: 1px;'><?php echo $cidsecundario; ?></p>
246 </div>
247 <div class='line' style='display: flex;'>
248 <label style='margin: 1px;font-weight: bold;'>CID 10 Causas Associadas:</label>
249 <p style='margin: 1px;'><?php echo $cidassociado; ?></p>
250 </div>
251 <div class='line' style='display: flex;'>
252 <label style='margin: 1px;font-weight: bold;'>Data solicitação:</label>
253 <p style='margin: 1px;'><?php echo $dtsol; ?></p>
254 </div>
255 <label style='margin: 1px;font-weight: bold;'>Médico solicitante:</label>
256 <div class='line' style='display: flex;'>
257 <p style='margin: 1px;'><?php echo $medsol; ?></p>
258 </div>
259 <div class='line' style='display: flex;'>
260 <label style='margin: 1px;font-weight: bold;'>CRM:</label>
261 <p style='margin: 1px;'><?php echo $crmsol; ?></p>
262 </div>
263 <hr>
264 <div class='line' style='display: flex;'>
265 <label style='margin: 1px;font-weight: bold;'>Usuário do Sistema:</label>
266 <p style='margin: 1px;'><?php echo $_SESSION['USU_NOME']; ?></p>
267 </div>
268 <div style='font-size: 9px;text-align: center;margin-bottom: 12px;' >
269 <hr>
270 </div>
271 </div>
272 </body>
273</html>
274<?php
275//--------------------------------------------------------------------------------------------------------------
276$corpoEmail = ob_get_contents();
277ob_end_clean();
278
279//echo $corpoEmail;
280//exit;
281
282use PHPMailer\PHPMailer\PHPMailer;
283use PHPMailer\PHPMailer\Exception;
284
285require '../PHPMailer/src/Exception.php';
286require '../PHPMailer/src/PHPMailer.php';
287require '../PHPMailer/src/SMTP.php';
288
289$mail = new PHPMailer(true);// Passing `true` enables exceptions
290try {
291 $mail->CharSet = "UTF-8";
292 //Server settings
293 //$mail->SMTPDebug = 3; // Nivel de saida de debug: padrão = 2 todas=3
294 $mail->isSMTP(); // Set mailer to use SMTP
295 $mail->Host = 'meu smtp'; //smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
296 $mail->SMTPAuth = true; // Enable SMTP authentication
297 $mail->Username = $deEmail; //'user@example.com'; // SMTP username
298 $mail->Password = $senha; // SMTP password
299 //$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
300 $mail->Port = 587; // TCP port to connect to
301 //Recipients
302 $mail->setFrom($deEmail, $deNome);
303 foreach ($paraEmal as $para) {// Quem vai receber o email
304 //echo "$" . "mail->addAddress('" . $para['email'] . "','" . $para['nome'] . "');" . '<br>';
305 $mail->addAddress($para['email'], $para['nome']);
306 }
307 //------------------------------------
308 //$mail->addAddress('ellen@example.com'); // Name is optional
309 $mail->addCC($deEmail, $deNome); //Com cópia para o propio email de envio
310 foreach ($paraCopia as $copia) {// Quem vai receber uma copia do email
311 $mail->addCC($copia['email'], $copia['nome']);
312 }
313 //$mail->addBCC('bcc@example.com');
314 //Attachments
315 // $mail->addAttachment('/var/tmp/file.tar.gz'); // Adiconar arquivo em anexo (Sem tÃtulo arquivo)
316 //$mail->addAttachment('Teste.pdf', 'Arquivo em PDF'); // Adiconar arquivo em anexo (Com o tÃtulo do arquivo)
317 if ($moveu) {
318 $mail->addAttachment($dirArquivo . '\\' . $nomeArquivo, $nomepaciente); // Adiconar arquivo em anexo (Com o tÃtulo do arquivo)
319 }
320//Content
321 $mail->isHTML(true); // Set email format to HTML
322 $mail->Subject = $assunto;
323 $mail->Body = $corpoEmail;
324 $mail->AltBody = 'Este é o corpo em texto sem formatação para clientes de email não HTML.';
325
326 $mail->send();
327 if ($moveu) {//Exclui o arquivo depois de enviar
328 if (file_exists($dirArquivo . $nomeArquivo)) {
329 unlink($dirArquivo . $nomeArquivo);
330 }
331 }
332 $sql = 'update solicitacao set sol_ocorre = now(), sol_dt_ho_envio = now(), usu_codigo =' . $usuCod . ' where sol_codigo = ' . $solCod;
333 $sql = $pdo->query($sql);
334 if ($sql) {
335 header('Location: sendSucesses.php');
336 }
337 //echo 'Memsagem enviada com sucesso';
338} catch (Exception $e) {
339 //echo 'Falha ao enviar mensagem. Erro: ', $mail->ErrorInfo;
340 //exit;
341 echo '<div style="color: #721c24; background-color: #f8d7da; border-color: #f5c6cb; width: 450px; text-align: center; margin: 0 auto; margin-top: 40px; border-radius: 15px; height: 50px; line-height: 50px; font-size: 25px; box-shadow: 4px -3px 3px #A5A5A5; ">Falha ao enviar a mensagem.</div>';
342 echo '<div style="color: #0c5460; background-color: #d1ecf1; border-color: #bee5eb; width: 450px; box-shadow: 4px -3px 3px #A5A5A5; text-align: center; margin: 0 auto; margin-top: 10px; border-radius: 15px; height: 50px; line-height: 50px; font-size: 25px;"><a href="../unimed/unimedLista.php" style="text-decoration: none;display: block;">Voltar</a></div>';
343}