no message

git-svn-id: https://svn.coded.pt/svn/SIPRP@458 bb69d46d-e84e-40c8-a05a-06db0d633741
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
P Santos 21 years ago
parent c66d8fc273
commit 7831f66c38

@ -89,7 +89,7 @@ public class MailerServlet extends HttpServlet
return null;
}
protected boolean sendMail( String from, String destination, String subject, String content )
protected boolean sendMail( String from, String destination, String subject, String content, boolean html )
{
String smtp_server = "localhost";
String mailer = "Evolute Mailer";
@ -97,6 +97,8 @@ public class MailerServlet extends HttpServlet
Properties props = System.getProperties();
props.put( "mail.smtp.host", smtp_server );
String content_type = ( html ) ? "text/html" : "text/plain";
Session session = Session.getInstance( props, null );
Message msg = new MimeMessage( session );
try
@ -108,7 +110,7 @@ public class MailerServlet extends HttpServlet
msg.setRecipients( Message.RecipientType.TO, InternetAddress.parse( destination, true ) );
msg.setSubject( subject );
msg.setContent( content.toString(), "text/plain" );
msg.setContent( content.toString(), content_type );
msg.setHeader( "X-Mailer", mailer );
msg.setSentDate( new Date() );

@ -50,7 +50,7 @@ public class RequestServlet extends MailerServlet
String destination = "psantos@evolute.pt";
String subject = "Pedido de informação através do site www.siprp.pt";
// manda mail
boolean success = sendMail( from, destination, subject, content );
boolean success = sendMail( from, destination, subject, content, false );
// mostra pagina correspondente
out.println( showResultPage( success, "mail/pedido_enviado.html", "mail/pedido_nao_enviado.html" ) );

@ -39,21 +39,22 @@ public class ScheduleServlet extends MailerServlet
ServletOutputStream out = res.getOutputStream();
res.setContentType( "text/html" );
VelocityContext context = new VelocityContext();
StringWriter output = new StringWriter();
try
{
Velocity.mergeTemplate( "marcacao/marcacao_menu.html", Velocity.ENCODING_DEFAULT, context, output );
Hashtable parameters = new Hashtable();
out.println( output.toString() );
}
catch( Exception e )
// Ir buscar os parametros à sessão
HttpSession session = req.getSession( false );
if( session == null )
{
e.printStackTrace();
// timeout
out.println( showPage( "marcacao/marcacao_sessao_expirou.html", null ) );
return;
}
return;
parameters.put( EMPRESA, session.getAttribute( siprpServlet.sessionCompanyName ) );
parameters.put( ESTABELECIMENTO, session.getAttribute( "session_estabelecimento_nome" ) );
parameters.put( FUNCIONARIO, session.getAttribute( "session_funcionario_nome" ) );
out.println( showPage( "marcacao/marcacao_menu.html", parameters ) );
}
public void doPost( HttpServletRequest req, HttpServletResponse res )
@ -71,6 +72,7 @@ public class ScheduleServlet extends MailerServlet
if( session == null )
{
// timeout
out.println( showPage( "marcacao/marcacao_sessao_expirou.html", null ) );
return;
}
@ -85,11 +87,40 @@ public class ScheduleServlet extends MailerServlet
String destination = "psantos@evolute.pt";
String subject = "Pedido de marcação de " + marcacao_tipo + " via web";
String content = createContent( parameters, FORM_FIELDS, "marcacao/marcacao.txt" );
String content = createContent( parameters, FORM_FIELDS, "marcacao/marcacao.html" );
// manda mail
boolean success = sendMail( null, destination, subject, content );
boolean success = sendMail( null, destination, subject, content, true );
// mostra pagina correspondente
out.println( showResultPage( success, "marcacaco/marcacao_enviada.html", "marcacaco/marcacao_nao_enviada.html" ) );
out.println( showResultPage( success, "marcacao/marcacao_enviada.html", "marcacao/marcacao_nao_enviada.html" ) );
}
private String showPage( String page, Hashtable parameters )
{
VelocityContext context = new VelocityContext();
StringWriter output = new StringWriter();
try
{
if( parameters != null )
{
String key;
for( Enumeration e = parameters.keys(); e.hasMoreElements(); )
{
key = ( String ) e.nextElement();
context.put( key, parameters.get( key ) );
}
}
Velocity.mergeTemplate( page, Velocity.ENCODING_DEFAULT, context, output );
return output.toString();
}
catch( Exception e )
{
e.printStackTrace();
}
return null;
}
}

@ -50,8 +50,8 @@ function isValid( element, type )
window.setTimeout( "document.getElementById( '" + element.name + "' ).focus()", 1 );
return false;
}
hora_value = element.value.split( "/" );
if( date_value[ 0 ] > 23 || date_value[ 1 ] > 59 )
time_value = element.value.split( ":" );
if( time_value[ 0 ] > 23 || time_value[ 1 ] > 59 )
{
alert( "Hora inválida." );
window.setTimeout( "document.getElementById( '" + element.name + "').focus()", 1 );

@ -0,0 +1,13 @@
<html>
<head>
</head>
<body>
Empresa: $empresa<br>
Estabelecimento: $estabelecimento<br>
Funcionário: $funcionario<br>
<br>
$marcacao_tipo no dia $data#if( $marcacao_tipo == 'Consulta' ) às $hora#end.<br>
<br>
Email de resposta<br>
</body>
</html>

@ -0,0 +1,11 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Marca&ccedil;&atilde;o de consulta / exame</title>
<link rel="stylesheet" href="/siprpWeb/html/css/style.css" type="text/css">
</head>
<body class='text'>
O pedido de marca&ccedil;&atilde;o foi enviado com sucesso.
</body>
</html>

@ -3,48 +3,56 @@
<html>
<head>
<title>Marca&ccedil;&atilde;o de consulta / exame</title>
<link rel="stylesheet" href="/siprpWeb/html/css/style.css" type="text/css">
</head>
<script language="javascript" src="/siprpWeb/html/css/funcs.js"></script>
<script>
function validateForm()
{
alert( document.f.ola.value );
if( document.f.marcacao_tipo.value == null )
checked = -1;
for( i = 0; i < document.f.marcacao_tipo.length; i++ )
{
if( document.f.marcacao_tipo[ i ].checked )
{
checked = i;
}
}
if( checked == -1 )
{
alert( "Tem que escolher o tipo de marcação." );
return false;
}
return isValid( document.f.data, 0 ) && isValid( document.f.hora, 1 ) ;
return isValid( document.f.data, 0 ) && ( checked == 1 || isValid( document.f.hora, 1 ) );
}
</script>
<body>
<form method='post' action='/siprpWeb/schedule' name='f'>
<table>
<table class='text'>
<tr>
<td>
<input type='radio' id='ola' name='ola' value='ola'>Ola
<input type='radio' id='ola' name='ola' value='adeus'>Ola
<td colspan='2'>
Marca&ccedil;&atilde;o para:<br>
$funcionario
</td>
</tr>
<tr>
<td colspan='2'>
<input type='radio' id='marcacao_tipo' name='marcacao_tipo' value='Consulta' onclick='document.getElementById( "hora" ).disabled = false;'>Consulta
<input type='radio' id='marcacao_tipo' name='marcacao_tipo' value='Exame' onclick='document.getElementById( "hora" ).disabled = true;'>Exame
</td>
</tr>
<tr>
<td>
Data:<input type='text' id='data' name='data'>dd/mm/aaaa
</td>
<td>Data:</td><td><input type='text' id='data' name='data'>dd/mm/aaaa</td>
</tr>
<tr>
<td>
Hora:<input type='text' id='hora' name='hora'>hh:mm
</td>
<td>Hora:</td><td><input type='text' id='hora' name='hora'>hh:mm</td>
</tr>
<tr>
<td>
<td colspan='2'>
Nota: a marca&ccedil;&atilde;o est&aacute; sujeita a confirma&ccedil;&atilde;o via email.
</td>
</tr>
<tr>
<td>
<td colspan='2'>
<input type='submit' value='Marcar' onclick='return validateForm()'>
</td>
</tr>

@ -0,0 +1,11 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Marca&ccedil;&atilde;o de consulta / exame</title>
<link rel="stylesheet" href="/siprpWeb/html/css/style.css" type="text/css">
</head>
<body class='text'>
Ocorreu um erro a enviar o pedido de marca&ccedil;&atilde;o.
</body>
</html>

@ -0,0 +1,11 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Sess&atilde;o expirou</title>
<link rel="stylesheet" href="/siprpWeb/html/css/style.css" type="text/css">
</head>
<body class='text'>
A sua sess&atilde;o expirou. Para efectuar uma marca&ccedil;&atilde;o, autentique-se novamente.
</body>
</html>

@ -128,7 +128,7 @@ td.box6
<script>
function marcacaoWindow()
{
wnd = window.open( "schedule", "marcacao_window", "menubar=0, resizeable=0, width=350, height=250, top=100, left=450" );
wnd = window.open( "schedule", "marcacao_window", "menubar=0, resizeable=0, width=400, height=250, top=100, left=450" );
wnd.focus();
}
</script>
@ -246,7 +246,7 @@ td.box6
</tr>
<tr align='center'>
<td class='box5'>$!funcionario.ultimo_exame&nbsp;</td><td class='box6'>$!funcionario.realizado&nbsp;</td><td class='box6'>$!funcionario.proximo_exame&nbsp;</td><td class='box6'>$!funcionario.ultima_consulta&nbsp;</td><td class='box6'>$!funcionario.realizada&nbsp;</td><td class='box6'>$!funcionario.proxima_consulta&nbsp;</td>
<td class='box6'><a class='text' href='' onclick='marcacaoWindow()'>Marcar</a></td>
<td class='box6'><a class='text' href='javascript:marcacaoWindow();'>Marcar</a></td>
</tr>
</table>
#else

Loading…
Cancel
Save