diff --git a/.gitignore b/.gitignore index 768908c..87b616c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ /logs/* !/logs/README.md /templates/.cache -/db/ggdworkshop.db +/db/surfaces2018.db /db/.schema.lock diff --git a/public/js/registerform.js b/public/js/registerform.js index 3851591..91924da 100644 --- a/public/js/registerform.js +++ b/public/js/registerform.js @@ -10,8 +10,8 @@ $().ready(function(){ $("#txtbda,#txteda").datepicker({ dateFormat: "dd/mm/yy", - minDate:new Date(2018,6,16), - maxDate:new Date(2018,7,3) + minDate:new Date(2018,11,17), + maxDate:new Date(2018,11,19) }); $("#pais").select2({ @@ -66,8 +66,8 @@ function select2Focus() { required: function() { if(grecaptcha.getResponse() == "") return true; else return false; - } - }, + } + } }, @@ -94,27 +94,39 @@ function select2Focus() { formdata.find(item => item.name === "pais").value = $("#pais").select2("data")[0].text; formdata.find(item => item.name === "roomtype").value = $("#roomtype").select2("data")[0].text; var parameters = $.param(formdata); - $.post('api/register', parameters) - .done(function(data){ - alert("post done"); + /*$.ajax({ + url: 'api/register', + type: "POST", + data: parameters, + success:function(result){ + console.log(result); + }, + error: function(jqxhr, status, exception){ + console.log(exception); + console.log(jqxhr); + } + });*/ + + var req = $.post('api/register', parameters) + req.done(function(data){ + + if(data.success){ - if(data.success){ - alert("peter"); - validator.resetForm(); - reset($("#registerform")); - showMsg(false,data.msg); - } - else{ - - var errMsg = data.msg+""; - console.log(errMsg); - showMsg(true,errMsg); - } - }); + validator.resetForm(); + reset($("#registerform")); + showMsg(false,data.msg); + } + else{ + + var errMsg = data.msg+""; + console.log(errMsg); + showMsg(true,errMsg); + } + }); }, errorElement: "em", diff --git a/src/routes.php b/src/routes.php index 17fa584..7399a58 100644 --- a/src/routes.php +++ b/src/routes.php @@ -87,7 +87,7 @@ $mw = function ($request, $response, $next) { // API ROUTES $app->group('/api', function($app){ - + $app->get("/test", function(Request $request, Response $response, array $args) { $this->logger->info("GDDWorkshop '/api/test' route"); return var_dump($request); @@ -97,24 +97,21 @@ $app->group('/api', function($app){ $app->post('/register', function (Request $request, Response $response, array $args) { $messages = $this->flash; $data = $request->getParsedBody(); + $db = $this->db; if($this->settings['close_registration']){ $messages->addMessageNow("submit-register-err", "Registration has benn closed"); } else{ - $db = $this->db; + if(!isset($data['nombre'])||empty($data['nombre'])) $messages->addMessageNow("submit-register-err", "First name could not be empty"); if(!isset($data['apellido'])||empty($data['apellido'])) $messages->addMessageNow("submit-register-err", "Last name could not be empty"); if(!isset($data['email'])||empty($data['email'])) - $messages->addMessageNow("submit-register-err", "E-mail could not be empty"); - /*if(!isset($data['financiacion'])||!is_numeric($data['financiacion'])) - $messages->addMessageNow("submit-register-err", "Question about financial support must have a selected answer");*/ - /*if(!isset($data['invited'])||!is_numeric($data['invited'])) - $messages->addMessageNow("submit-register-err", "Question about 'invited to participate in this conference' must have a selected answer");*/ + $messages->addMessageNow("submit-register-err", "E-mail could not be empty"); if(!isset($data['letterinvited'])||!is_numeric($data['letterinvited'])) $messages->addMessageNow("submit-register-err", "Question about needing a letter of invitation must have a selected answer"); - + //ReCaptcha Validation if(!isset($data['g-recaptcha-response'])||empty($data['g-recaptcha-response'])){ $messages->addMessageNow("submit-register-err", "Please validate captcha!"); @@ -124,7 +121,7 @@ $app->group('/api', function($app){ if($this->settings['testing']){ $recapsecret = $this->settings['recaptcha']['secrettest']; } - var_dump($recapsecret); + $recaptcha = new ReCaptcha\ReCaptcha($recapsecret); //get remote ip from request header TODO $resp = $recaptcha->verify($data['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']); @@ -140,39 +137,41 @@ $app->group('/api', function($app){ if($db->findByMail($data['email'])) $messages->addMessageNow("submit-register-err", $data['email']." is already registered
" ."Please contact: surfacedynamics2018@cmat.edu.uy"); - else - $db->insert($data); - } - catch (Exception $e){ + }catch (Exception $e){ $this->logger->debug("Submit register DB error: ".$e->getMessage()); $messages->addMessageNow("submit-register-err", "DB error: ".$e->getMessage()); } - } - if($messages->hasMessage("submit-register-err")){ + } + + if($messages->hasMessage("submit-register-err")){ $arrayresponse = array("success" => false, "msg"=>"You registration could not be completed:\n", "errors"=>$messages->getMessage("submit-register-err"), "data"=>$data); + } + + else { + try{ + $db->insert($data); + }catch (Exception $e){ + $this->logger->debug("Submit register DB error: ".$e->getMessage()); + $messages->addMessageNow("submit-register-err", "DB error: ".$e->getMessage()); } - - else { - $arrayresponse = array("success" => true, - "msg"=>"You have been successfully registered to the GGDWorkshop", - "data"=>$data); - $msg = "Hello ".$data["nombre"]." ".$data["apellido"].",\n\n". - "You have been successfully registered to the Surface Dynamics 2018 Workshop!\n\n". - "For any questions please contact surfacedynamics2018@cmat.edu.uy\n\n". - "Best!\n\n"; - $headers = 'From: ' . "surfacedynamics2018@cmat.edu.uy" . "\r\n" . - 'Reply-To: ' . "surfacedynamics2018@edu.uy" . "\r\n" . - 'Content-Type: ' . "text/plain; charset=UTF-8". "\r\n" . - 'X-Mailer: PHP/' . phpversion(); - mail($data['email'], 'Successfully registered to the Surface Dynamics 2018 Workshop', $msg, $headers); - - - - } - $newres = $response->withJson($arrayresponse); - return $newres; + $arrayresponse = array("success" => true, + "msg"=>"You have been successfully registered to the GGDWorkshop", + "data"=>$data); + $mailbody = "Hello ".$data["nombre"]." ".$data["apellido"].",\n\n". + "You have been successfully registered to the Workshop on Surface Dynamics 2018!\n\n". + "If you need to change the information you have provided on the registration and for any". + "questions please contact surfacedynamics2018@cmat.edu.uy\n\n". + "Best!\n\n"; + $headers = 'From: ' . "surfacedynamics2018@cmat.edu.uy" . "\r\n" . + 'Reply-To: ' . "surfacedynamics2018@edu.uy" . "\r\n" . + 'Content-Type: ' . "text/plain; charset=UTF-8". "\r\n" . + 'X-Mailer: PHP/' . phpversion(); + mail($data['email'], 'Successfully registered to the Surface Dynamics 2018 Workshop', $mailbody, $headers); + } + $newres = $response->withJson($arrayresponse); + return $newres; }); }); diff --git a/templates/index.html b/templates/index.html index e117e04..2cbe179 100644 --- a/templates/index.html +++ b/templates/index.html @@ -2,19 +2,16 @@ {% block content %}

Welcome!

-

- The Dynamical Systems Group at the Universidad de la República has - been organizing several international Conferences and - Workshops in the last 20 years, focusing on different aspects of - dynamics and related topics. +

+ The Dynamical Systems Group at the Universidad de la República is very honored to host a workshop + on the occasion of Patrice Le Calvez's 60th anniversary.

- As our group expanded, both in number of participants and areas - of research, we are holding a Workshop on Groups, Geometry and Dynamics - on 2018 at Montevideo as a satellite conference of ICM 2018 (Rio de - Janeiro). The goal of the Workshop is to bring together top scientists - working on these areas to discuss new trends on these topics. The - idea is to have few talks and lots of discussion time. + The aim is to bring together top scientists working on surface topological dynamics to share their + knowledge and ideas. +

+

+ The event will take place on december 17th–20th, 2018.


-
- -
- + +