diff --git a/trunk/WEB-INF/classes/siprp/pagina/MailerServlet.java b/trunk/WEB-INF/classes/siprp/pagina/MailerServlet.java index 6ee441ee..8f6d6690 100644 --- a/trunk/WEB-INF/classes/siprp/pagina/MailerServlet.java +++ b/trunk/WEB-INF/classes/siprp/pagina/MailerServlet.java @@ -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() ); diff --git a/trunk/WEB-INF/classes/siprp/pagina/RequestServlet.java b/trunk/WEB-INF/classes/siprp/pagina/RequestServlet.java index 6bedce77..4257daca 100644 --- a/trunk/WEB-INF/classes/siprp/pagina/RequestServlet.java +++ b/trunk/WEB-INF/classes/siprp/pagina/RequestServlet.java @@ -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" ) ); diff --git a/trunk/WEB-INF/classes/siprp/pagina/ScheduleServlet.java b/trunk/WEB-INF/classes/siprp/pagina/ScheduleServlet.java index b4de0e39..ef35993c 100644 --- a/trunk/WEB-INF/classes/siprp/pagina/ScheduleServlet.java +++ b/trunk/WEB-INF/classes/siprp/pagina/ScheduleServlet.java @@ -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; } } diff --git a/trunk/html/css/funcs.js b/trunk/html/css/funcs.js index 512e0fb6..099f6df4 100644 --- a/trunk/html/css/funcs.js +++ b/trunk/html/css/funcs.js @@ -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 ); diff --git a/trunk/html/marcacao/marcacao.html b/trunk/html/marcacao/marcacao.html new file mode 100644 index 00000000..b549c435 --- /dev/null +++ b/trunk/html/marcacao/marcacao.html @@ -0,0 +1,13 @@ + +
+ + +Empresa: $empresa