From 30aa37e7be8f819305119146caa82cc140229734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Correa?= Date: Wed, 16 Jun 2021 14:05:57 -0300 Subject: [PATCH] crea registro, modifica trabla de particpantes y algunas cosas mas en backend --- db/bkp/2017-12-18.bkp.db | 62 ----------------- db/{clam2020.db => clam2021.db} | Bin 20480 -> 20480 bytes db/db.php | 22 ++---- db/schema.sql | 29 +------- public/js/registerform.js | 84 +++++++++++++---------- src/routes.php | 54 ++++++++++++--- src/settings.php | 2 +- templates/header.html | 2 +- templates/participants.html | 31 ++++++--- templates/registration.html | 117 ++++++++++++++++++-------------- 10 files changed, 186 insertions(+), 217 deletions(-) delete mode 100644 db/bkp/2017-12-18.bkp.db rename db/{clam2020.db => clam2021.db} (87%) diff --git a/db/bkp/2017-12-18.bkp.db b/db/bkp/2017-12-18.bkp.db deleted file mode 100644 index dd3ca00..0000000 --- a/db/bkp/2017-12-18.bkp.db +++ /dev/null @@ -1,62 +0,0 @@ -PRAGMA foreign_keys=OFF; -BEGIN TRANSACTION; -CREATE TABLE Registro -( - id INTEGER PRIMARY KEY AUTOINCREMENT, - nombre VARCHAR(50) NOT NULL, - apellido VARCHAR(50) NOT NULL, - titulo VARCHAR(50), - afiliacion VARCHAR(50), - ciudad VARCHAR(50), - pais VARCHAR(50), - email VARCHAR(80) NOT NULL UNIQUE, - fechaLlegada DATE, - fechaPartida DATE, - financiacion BOOLEAN NOT NULL, - invitado BOOLEAN NOT NULL, - cartaInvitacion BOOLEAN NOT NULL, - roomingPref VARCHAR(50), - roommate VARCHAR(50), - fechaRegistro DATETIME NOT NULL -); -INSERT INTO "Registro" VALUES(1,'German','Correa','','','Montevideo','Uruguay','german.correa.balier@gmail.com','','',0,0,0,' - ','German Correa','2017-12-18 18:05:28'); -INSERT INTO "Registro" VALUES(2,'German','Correa','','','Montevideo','Uruguay','german.correa.basslier@gmail.com','','',1,1,1,' - ','German Correa','2017-12-18 19:04:38'); -INSERT INTO "Registro" VALUES(3,'German','Correa','','','Montevideo','Uruguay','gaaerman.correa.balier@gmail.com','','',0,0,1,' - ','German Correa','2017-12-18 19:05:15'); -INSERT INTO "Registro" VALUES(4,'German','Correa','','','Montevideo','Uruguay','aagerman.correa.balier@gmail.com','','',1,0,1,' - ','German Correa','2017-12-18 19:06:34'); -CREATE TABLE Speakers -( - id INTEGER PRIMARY KEY AUTOINCREMENT, - nombre VARCHAR(50) NOT NULL, - apellido VARCHAR(50) NOT NULL, - afiliacion VARCHAR(50) NOT NULL, - foto VARCHAR(200), - web VARCHAR(200), - confirmado BOOLEAN -); -INSERT INTO "Speakers" VALUES(1,'Jairo','Bochi','Universidad Católica de Chile','img/speakers/jariobochi.jpg','http://www.mat.uc.cl/~jairo.bochi/',1); -INSERT INTO "Speakers" VALUES(2,'Christian','Bonatti','Université de Bourgogne','img/speakers/cbonatti.jpg','http://bonatti.perso.math.cnrs.fr/',1); -INSERT INTO "Speakers" VALUES(3,'Keith','Burns','Northwestern University','img/speakers/kburns.jpg','http://www.math.northwestern.edu/~burns/',1); -INSERT INTO "Speakers" VALUES(4,'Yaiza','Canzani','University of North Carolina at Chapel Hill','img/speakers/ycanzani.jpg','http://canzani.web.unc.edu/',1); -INSERT INTO "Speakers" VALUES(5,'Gonzalo','Contreras','CIMAT, Guanajuato','img/speakers/gcontreras.jpg','http://www.cimat.mx/~gonzalo/',1); -INSERT INTO "Speakers" VALUES(6,'Adriana','da Luz','Universidad de la República','img/speakers/adaluz.jpg','',1); -INSERT INTO "Speakers" VALUES(7,'Colin','Guillarmou','Université Paris-Sud','img/speakers/cguillarmou.jpg','https://www.math.u-psud.fr/~guillarmou/',1); -INSERT INTO "Speakers" VALUES(8,'Ursula','Hamenstädt','Universität Bonn','img/speakers/uhamenstadt.jpg','http://www.math.uni-bonn.de/people/ursula/',1); -INSERT INTO "Speakers" VALUES(9,'Thomas','Koberda','University of Virginia','img/speakers/tkoberda.jpg','http://faculty.virginia.edu/Koberda/',1); -INSERT INTO "Speakers" VALUES(10,'Andrés','Koropecki','Universidade Federal Fluminense','img/speakers/akoropecki.jpg','http://www.professores.uff.br/koro/',1); -INSERT INTO "Speakers" VALUES(11,'François','Ledrappier','University of Notre Dame','img/speakers/fledrappier.jpg','http://math.nd.edu/people/faculty/francois-ledrappier/',1); -INSERT INTO "Speakers" VALUES(12,'Yash','Lodha','Cornell University','img/speakers/ylodha.jpg','http://www.math.cornell.edu/m/People/bynetid/yl763',1); -INSERT INTO "Speakers" VALUES(13,'Leonardo','Macarini','Universidade Federal do Rio de Janeiro','img/speakers/lmacarini.jpg','http://www.im.ufrj.br/visualizarDocente.php?idDepartamento=3&idDocente=28',1); -INSERT INTO "Speakers" VALUES(14,'Kathryn','Mann','Brown University','img/speakers/kmann.jpg','http://www.math.brown.edu/~mann/index.html',1); -INSERT INTO "Speakers" VALUES(15,'Andrés','Navas','Universidad de Santiago de Chile','img/speakers/anavas.jpg','http://www.mat.usach.cl/index.php/2012-12-19-12-50-19/academicos/75-andres-navas-flores',1); -INSERT INTO "Speakers" VALUES(16,'Jean-François','Quint','Université Bordeaux I','img/speakers/jfquint.jpg','https://www.math.u-bordeaux.fr/~jquint/',1); -INSERT INTO "Speakers" VALUES(17,'Andrés','Sambarino','Université Paris VI','img/speakers/asambarino.jpg','https://webusers.imj-prg.fr/~andres.sambarino/',1); -INSERT INTO "Speakers" VALUES(18,'Pablo','Shmerkin','Universidad Torcuato Di Tella','img/speakers/pshmerkin.jpg','http://www.utdt.edu/profesores/pshmerkin',1); -INSERT INTO "Speakers" VALUES(19,'Maxime','Wolff','Université Paris VI','img/speakers/mwolff.jpg','https://webusers.imj-prg.fr/~maxime.wolff/',1); -DELETE FROM sqlite_sequence; -INSERT INTO "sqlite_sequence" VALUES('Speakers',19); -INSERT INTO "sqlite_sequence" VALUES('Registro',4); -COMMIT; diff --git a/db/clam2020.db b/db/clam2021.db similarity index 87% rename from db/clam2020.db rename to db/clam2021.db index be648e1c955b992b594fce1a05d9e95560012d20..5127719353db299c54efa52139889352cbf440e1 100644 GIT binary patch literal 20480 zcmeI4&2Jk;6u@`0whIaF@*%LIXr+mIXsouW*IOsVr)#O{J-`I{Z}M#(VL3uj`p!-hPJ0-2UeGgi{x<&9-RxJPD^+v++W zIUUmOxJ|orL>@Xv#O`$u-4@trI<4+qP!e)<60qlbpW2}OJhOvz2m47kr}pG$FRXl}UAV~$$*Ov=%f$_vB?tpAv%z(M5$*vzimbTUlK<@;Kp)G$K<3qTJHYRODUMCf(DP;YsuqQgq$z#EBfa*f4%ux@fWCKLIOwt2_OL^ zfCP{L55<>(ZKyK0z^;kfAfh(`NM#EGW8`oC2~OQ z!H|kQIt0(4`j`s1v7lm{sAtp9wz8>f#H`h=O1);C-&lfuDD7;ouK|Pon2I(F*xBsl zV;N57Z}RX<8cD(X(#qbZ6vuaM>;Q(4ON6S*?MS^CC*E~iRcabp>YAXG1Te<9l@Adbb_W=|zp^`o z_~Jw5OE3K&dh5Nn9-Bk|js6E!d#ZZsn}xxE${|waRMs0Ac6R2y`R@D718HPEPL69_ zFwzSmj|%dsc2CoF?Mp&5P0PV+1751FK_{hd;HuB{S9Nom@%WE?;V&(<^|O|*6@JbA z4IOMq00|%gB!C2v01`j~NB{}EC4p}bQg@2m+xk^q(5}l)LPpP76szk-xmB^+71Fj2 zYZanKvpZQrxI-3Nwb8CTt+Yt9RjpgCGxEH0My%8JQMCbU)GLklLvZo~uN$#zzpt%U z`75in^VxohG>+P&aayZMI~p?Aen=}%9aopVP zai9A3b;3>4Ad#G<@2&}Jo4ee9#l%6 zY59edmv8sv8#W|>1dsp{Kmter2_OL^fCP{L5$`hFibGAT}g`1dsp{Kmter2_OL^fCT9YD35}}z#i~s;0xa4P?t?qyt0VAOvRg@q^NwN@_@T+L3`MhzDgXT9*@T|W@BU< zwrgGv<@!cqWcqi2?S}{DlZ@p{dO;l|soSN#5}W`oQpdo->prepare($sql); $stmt->execute([ @@ -27,13 +24,7 @@ ':ciudad' => $registro['ciudad'], ':pais' => $registro['pais'], ':email' => $registro['email'], - ':fechaLlegada' => $registro['bda'], - ':fechaPartida' => $registro['eda'], - //':financiacion' => $registro['financiacion'], - //':invitado' => $registro['invited'], - ':cartaInvitacion' => $registro['letterinvited'], - ':roomingPref' => $registro['roomtype'], - ':roommate' => $registro['roomate'], + ':emailzoom' => $registro['emailzoom'], ':fechaRegistro' => $date = date('Y-m-d H:i:s'), ]); return $this->pdo->lastInsertId(); @@ -45,12 +36,7 @@ return $stmt->fetchAll(\PDO::FETCH_BOTH); } - public function getSpeakers(){ - $stmt = $this->pdo->prepare("SELECT * FROM Speakers"); - $stmt -> execute(); - return $stmt->fetchAll(\PDO::FETCH_BOTH); - - } + public function findByMail($email){ $stmt = $this->pdo->prepare("SELECT * FROM Registro WHERE email=:email"); $stmt->bindParam(":email",$email); diff --git a/db/schema.sql b/db/schema.sql index 8ccbd8c..4f35460 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -8,34 +8,7 @@ CREATE TABLE IF NOT EXISTS Registro ciudad VARCHAR(50), pais VARCHAR(50), email VARCHAR(80) NOT NULL UNIQUE, - fechaLlegada DATE, - fechaPartida DATE, - /*financiacion BOOLEAN NOT NULL,*/ - /*invitado BOOLEAN NOT NULL,*/ - cartaInvitacion BOOLEAN NOT NULL, - roomingPref VARCHAR(50), - roommate VARCHAR(50), + emailzoom VARCHAR(80) NOT NULL UNIQUE, fechaRegistro DATETIME NOT NULL ); -CREATE TABLE IF NOT EXISTS Speakers -( - id INTEGER PRIMARY KEY AUTOINCREMENT, - nombre VARCHAR(50) NOT NULL, - apellido VARCHAR(50) NOT NULL, - afiliacion VARCHAR(50) NOT NULL, - foto VARCHAR(200), - web VARCHAR(200), - confirmado BOOLEAN -); - -INSERT INTO Speakers(nombre,apellido,afiliacion,foto,web,confirmado) -VALUES('Alicia','Dickenstein','Universidad de Buenos Aires','img/speakers/adickenstein.jpg','http://mate.dm.uba.ar/~alidick/',1); -INSERT INTO Speakers(nombre,apellido,afiliacion,foto,web,confirmado) -VALUES('Antonio','Montalban','University of California','img/speakers/amontalban.jpg','https://math.berkeley.edu/~antonio/',1); -INSERT INTO Speakers(nombre,apellido,afiliacion,foto,web,confirmado) -VALUES('Jairo','Bochi','Pontificia Universidad Católica de Chile','img/speakers/jbochi.jpg','http://www.mat.uc.cl/~jairo.bochi/',1); -INSERT INTO Speakers(nombre,apellido,afiliacion,foto,web,confirmado) -VALUES('Milton','Jara','Instituto de Matemática Pura e Aplicada','img/speakers/mjara.jpg','https://impa.br/page-pessoas/milton-jara/',1); -INSERT INTO Speakers(nombre,apellido,afiliacion,foto,web,confirmado) -VALUES('Tatiana', 'Toro','University of Washington','img/speakers/ttoro.jpg','https://sites.math.washington.edu/~toro/',1); \ No newline at end of file diff --git a/public/js/registerform.js b/public/js/registerform.js index 5af60d6..7afb509 100644 --- a/public/js/registerform.js +++ b/public/js/registerform.js @@ -5,7 +5,7 @@ function recaptchaCallback(){ } $().ready(function(){ - + $("#otrotitulohidden").hide() $("#statusmsg").hide(); $("#txtbda,#txteda").datepicker({ @@ -13,34 +13,31 @@ $().ready(function(){ minDate:new Date(2018,11,17), maxDate:new Date(2018,11,20) }); - + $("#titulo").select2({ + data: [ + "Estudiante de grado", + "Estudiante de posgrado", + "Posdoctorando", + "Profesor", + "Otro", + ], + placeholder: "Seleccione", + width: "100%", + minimumResultsForSearch: Infinity, + }); + $("#titulo").on('select2:select', function (e){ + var data = e.params.data; + if(data.text==="Otro") + $("#otrotitulohidden").show(500) + else + $("#otrotitulohidden").hide(); + }) $("#pais").select2({ data: data.paises, - placeholder: "Select Country", + placeholder: "Seleccione", width: "100%", - });/*.one('select2-focus', select2Focus).on("select2-blur", function () { - $(this).one('select2-focus', select2Focus) }); -function select2Focus() { - var select2 = $(this).data('select2'); - setTimeout(function() { - if (!select2.opened()) { - select2.open(); - } - }, 0); - }*/ - - $("#roomtype").select2({ - data: data.roomtypes, - placeholder: "Select Rooming Preference", - width:"100%", - minimumResultsForSearch: -1, - dropdownCssClass: "bigdrop", - - }); - - $('#registerform').on('submit',function(e) { e.preventDefault(); }); @@ -59,9 +56,16 @@ function select2Focus() { required: true, email: true }, - //invited:{required:true}, - //financiacion:"required", - letterinvited:"required", + ciudad:{required:true}, + pais:{required:true}, + titulo:{required:true}, + otrotitulo:{required: function(){ + if($("#titulo").select2('data')[0].id === 'Otro') + return true; + else return false + }}, + profesion:{required:true}, + afiliacion:{required:true}, hiddenRecaptcha: { required: function() { if(grecaptcha.getResponse() == "") return true; @@ -73,18 +77,20 @@ function select2Focus() { }, messages: { nombre: { - required: "Please enter your firstname", - minlength: "Your firstname must be at least 2 characters long" + required: "Debe ingresar Nombre", + minlength: "Nombre debe tener al menos 2 caracteres" }, apellido: { - required: "Please enter your lastname", - minlength: "Your lastname must be at least 2 characters long" + required: "Debe ingresar Apellido", + minlength: "Apellido debe tener al menos 2 caracteres" }, - email: "Please enter a valid e-mail address", - invited: "Select one option please", - financiacion: "Select one option please", - letterinvited: "Select one option please", - hiddenRecaptcha: "Please validate reCAPTCHA", + email: "Dirección de e-mail inválida", + ciudad:"Ingrese ciudad", + pais:"Seleccione País", + titulo: "Debe ingresar profesión o actividiad", + otrotitulo:"Aclare el detalle de su profesión o actividad", + afiliacion:"Debe ingresar su afiliación", + hiddenRecaptcha: "Debe validar reCAPTCHA", }, @@ -92,7 +98,11 @@ function select2Focus() { var formdata = $(form).serializeArray(); formdata.find(item => item.name === "pais").value = $("#pais").select2("data")[0].text.trim(); - formdata.find(item => item.name === "roomtype").value = $("#roomtype").select2("data")[0].text.trim(); + if ($("#titulo").select2("data")[0].id !== "Otro") + formdata.find((item) => item.name === "titulo").value = $("#titulo").select2("data")[0].text.trim(); + else + formdata.find((item) => item.name === "titulo").value = $("#otrotitulo").val() + console.log(formdata) var parameters = $.param(formdata); /*$.ajax({ url: 'api/register', diff --git a/src/routes.php b/src/routes.php index 0646a7c..116eef6 100644 --- a/src/routes.php +++ b/src/routes.php @@ -41,7 +41,29 @@ $app->get('/participantes', function (Request $request, Response $response, arra $this->logger->info("GDDWorkshop '/participants' route"); $db = $this->db; $data = $db->getAll(); - return $this->renderer->render($response, 'participants.html', ['registros' => $data]); + $result = array('Estudiante de grado'=>array(),'Estudiante de posgrado'=>array(),'Profesor'=>array(),'Posdoctorando'=>array(),'Otro'=>array()); + foreach ($data as $element) { + switch ($element['titulo']){ + case 'Profesor': + $result['Profesor'][] = $element; + break; + case 'Posdoctorando': + $result['Posdoctorando'][] = $element; + break; + case 'Estudiante de posgrado': + $result['Estudiante de posgrado'][] = $element; + break; + case 'Estudiante de grado': + $result['Estudiante de grado'][] = $element; + break; + default: + $result['Otro'][] = $element; + break; + } + } + //echo '
' . json_encode($result,JSON_PRETTY_PRINT). '
'; + + return $this->renderer->render($response, 'participants.html', ['registros' => $result]); }); @@ -158,13 +180,23 @@ $app->group('/api', function($app){ else{ if(!isset($data['nombre'])||empty($data['nombre'])) - $messages->addMessageNow("submit-register-err", "First name could not be empty"); + $messages->addMessageNow("submit-register-err", "Debe ingresar nombre"); if(!isset($data['apellido'])||empty($data['apellido'])) - $messages->addMessageNow("submit-register-err", "Last name could not be empty"); + $messages->addMessageNow("submit-register-err", "Debe ingresar apellido"); if(!isset($data['email'])||empty($data['email'])) - $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"); + $messages->addMessageNow("submit-register-err", "Debe ingresar e-mail"); + if(!isset($data['ciudad'])||empty($data['ciudad'])) + $messages->addMessageNow("submit-register-err", "Debe ingresar ciudad"); + if(!isset($data['pais'])||empty($data['pais'])) + $messages->addMessageNow("submit-register-err", "Debe seleccionar pais"); + if(!isset($data['titulo'])||empty($data['titulo'])) + $messages->addMessageNow("submit-register-err", "Debe seleccionar profesión o actividad"); + if(!isset($data['afiliacion'])||empty($data['afiliacion'])) + $messages->addMessageNow("submit-register-err", "Debe ingresar afiliación"); + if(!isset($data['emailzoom'])||empty($data['emailzoom'])) + $messages->addMessageNow("submit-register-err", "Debe ingresar e-mail asociado a cuenta Zoom"); + /*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'])){ @@ -189,8 +221,8 @@ $app->group('/api', function($app){ try{ if($db->findByMail($data['email'])) - $messages->addMessageNow("submit-register-err", $data['email']." is already registered
" - ."Please contact: surfacedynamics2018@cmat.edu.uy"); + $messages->addMessageNow("submit-register-err", $data['email']." ya está registrado
" + ."Contacte a: clam2021@fing.edu.uy"); }catch (Exception $e){ $this->logger->debug("Submit register DB error: ".$e->getMessage()); $messages->addMessageNow("submit-register-err", "DB error: ".$e->getMessage()); @@ -199,7 +231,7 @@ $app->group('/api', function($app){ if($messages->hasMessage("submit-register-err")){ $arrayresponse = array("success" => false, - "msg"=>"You registration could not be completed:\n", + "msg"=>"Su registro NO pudo ser completado:\n", "errors"=>$messages->getMessage("submit-register-err"), "data"=>$data); } @@ -213,7 +245,7 @@ $app->group('/api', function($app){ $arrayresponse = array("success" => true, "msg"=>"You have been successfully registered to Workshop on Surface Dynamics 2018", "data"=>$data); - $mailbody = "Hello ".$data["nombre"]." ".$data["apellido"].",\n\n". + /*$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 and for any ". "questions please contact surfacedynamics2018@cmat.edu.uy\n\n". @@ -222,7 +254,7 @@ $app->group('/api', function($app){ '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); + mail($data['email'], 'Successfully registered to the Surface Dynamics 2018 Workshop', $mailbody, $headers);*/ } $newres = $response->withJson($arrayresponse); return $newres; diff --git a/src/settings.php b/src/settings.php index 1c9d316..a67277b 100644 --- a/src/settings.php +++ b/src/settings.php @@ -23,7 +23,7 @@ return [ 'level' => \Monolog\Logger::DEBUG, ], 'db' => [ - 'path' => __DIR__."/../db/clam2020.db", + 'path' => __DIR__."/../db/clam2021.db", 'schema' => __DIR__."/../db/schema.sql", 'load_schema' => __DIR__."/../db/.schema.lock" ], diff --git a/templates/header.html b/templates/header.html index 56536db..ae667c9 100644 --- a/templates/header.html +++ b/templates/header.html @@ -24,7 +24,7 @@ - Clam2020 Menu + Clam2021 Menu - --> + {% endblock %}