From 174f4b0756c8b8c9facb1bbdf8e17d53d5f440ae Mon Sep 17 00:00:00 2001 From: mynah Date: Wed, 22 Jan 2020 18:22:31 -0600 Subject: [PATCH] parriba --- lib/Dojo.pm | 3 +- lib/Dojo/Controller/Admin.pm | 101 +++--- lib/Dojo/Controller/Home.pm | 49 +-- lib/Dojo/Controller/Proc.pm | 5 +- lib/Dojo/Controller/Users.pm | 6 +- lib/Dojo/Model/Data/admin/event/add/qCup.q | 20 +- lib/Dojo/Model/Data/admin/event/add/qEup.q | 32 +- lib/Dojo/Model/Data/admin/event/add/qPup.q | 26 +- lib/Dojo/Model/Data/admin/event/change/qCup.q | 17 +- .../Model/Data/admin/event/change/qEdel.q | 2 +- lib/Dojo/Model/Data/admin/event/change/qEup.q | 29 +- .../Model/Data/admin/event/change/qPdel.q | 2 +- lib/Dojo/Model/Data/admin/event/change/qPup.q | 23 +- .../Model/Data/admin/event/json/qCourse.q | 8 +- lib/Dojo/Model/Data/admin/event/json/qEvent.q | 20 +- lib/Dojo/Model/Data/admin/event/json/qPlace.q | 2 +- lib/Dojo/Model/Data/admin/event/qCprev.q | 7 - lib/Dojo/Model/Data/admin/event/qEcourse.q | 6 - lib/Dojo/Model/Data/admin/event/qEmend.q | 13 - lib/Dojo/Model/Data/admin/event/qEmini.q | 14 - lib/Dojo/Model/Data/admin/event/qEplace.q | 9 +- lib/Dojo/Model/Data/admin/event/qEprev.q | 16 +- lib/Dojo/Model/Data/admin/event/qPprev.q | 9 +- .../Model/Data/admin/mensajes/json/qGetInfo.q | 3 +- lib/Dojo/Model/Data/admin/mensajes/qEntries.q | 1 + .../Model/Data/admin/tienda/json/qStore.q | 4 - .../Model/Data/admin/tienda/json/qUsers.q | 4 - lib/Dojo/Model/Data/admin/tienda/qStore.q | 3 - lib/Dojo/Model/Data/admin/tienda/qUsers.q | 4 - lib/Dojo/Model/Data/spay/qIntentConfirm.q | 4 +- lib/Dojo/Model/Data/spay/qIntentCreate.q | 2 +- lib/Dojo/Model/Data/spay/qNotify.q | 12 + lib/Dojo/Model/Vdgproc.pm | 64 +++- lib/Dojo/Model/Vuelo.pm | 114 ++----- lib/Dojo/Support.pm | 16 +- public/admin/event/event.css | 1 + public/admin/event/event.js | 13 +- templates/admin/event.html.ep | 312 ++++++++++-------- 38 files changed, 503 insertions(+), 473 deletions(-) delete mode 100755 lib/Dojo/Model/Data/admin/event/qEmend.q delete mode 100755 lib/Dojo/Model/Data/admin/event/qEmini.q delete mode 100755 lib/Dojo/Model/Data/admin/tienda/json/qStore.q delete mode 100755 lib/Dojo/Model/Data/admin/tienda/json/qUsers.q delete mode 100755 lib/Dojo/Model/Data/admin/tienda/qStore.q delete mode 100755 lib/Dojo/Model/Data/admin/tienda/qUsers.q create mode 100644 lib/Dojo/Model/Data/spay/qNotify.q diff --git a/lib/Dojo.pm b/lib/Dojo.pm index a035b95..9417aaf 100755 --- a/lib/Dojo.pm +++ b/lib/Dojo.pm @@ -68,12 +68,11 @@ sub startup { # admin ======================================================================= my $admin = $r->under('/admin')->to('users#is_admin'); $admin->any('')->to('admin#admin'); - $admin->any('home')->to('admin#admin'); + $admin->any('home')->to('admin#home'); $admin->any('radio')->to('admin#radio'); $admin->any('eventos')->to('admin#eventos'); $admin->any('eventos/:type'=> [type=>['e','p','c']])->to('admin#eventos'); $admin->any('mensajes')->to('admin#mensajes'); - $admin->any('tienda')->to('admin#tienda'); $admin->any('json/:dreq/:id')->to('admin#json'); # ============================================================================= diff --git a/lib/Dojo/Controller/Admin.pm b/lib/Dojo/Controller/Admin.pm index 0ccc467..eaaf6b9 100644 --- a/lib/Dojo/Controller/Admin.pm +++ b/lib/Dojo/Controller/Admin.pm @@ -5,78 +5,103 @@ use Mojo::Base 'Mojolicious::Controller'; use Dojo::Support qw{ log }; -# pagina y mensajes =========================================================== + +# Admin ======================================================================= sub admin{ - my $c=shift; - my $n=$c->param("dreq")//""; - my $json = {status => "304"}; - $json = ($c->dbv->rmsgid ($c->param('id')))[0] if ($n =~m/^mensajes$/); - $json = ($c->dbv->ecourse($c->param('id')))[0] if ($n =~m/^ecourse$/); - $json = ($c->dbv->qcourse($c->param('id')))[0] if ($n =~m/^qcourse$/); - $json = ($c->dbv->qplace ($c->param('id')))[0] if ($n =~m/^qplace$/); - $c->render(json=>$json); + my $c= shift; + $c->redirect_to('/admin/home'); } +sub home{ + my $c=shift; + $c->dbv->umod($c->param('link'),$c->param('update')) + if (($c->param("hup") // " " )=~/Cambiar/); + $c->stash(template=>"admin/home"); + $c->stash(layout=>"admin"); + $c->stash( $c->dbv->mod); +} + +sub radio{ + my $c=shift; + $c->dbv->umod($c->param('link'),'rmod') + if (($c->param("hup") // " " )=~/Cambiar/); + $c->dbg->ugrulla_pass($c->param('gpass')) + if (($c->param("pup") // " " )=~/Cambiar/); + $c->stash($c->dbv->mod); + $c->stash($c->dbg->grulla_pass); + $c->stash(apend => ["admin/candySwitch"]); + $c->stash(template=>"admin/radio"); + $c->stash(layout=>"admin"); +} + +sub mensajes{ + my $c=shift; + $c->stash( h=>$c->dbv->msg_heads); + $c->stash(template=>"admin/mensajes"); + $c->stash(layout=>"admin"); +} + # Eventos ===================================================================== -sub admin_eventos{ +sub eventos{ my $c=shift; if ( (my $t=$c->param('type') // "") =~/[ecp]/){ my $id=$c->param('id'); my $req=$c->param('req'); if ( $req eq "Eliminar"){ - $c->dbv->event_del($id) if ($t eq 'e'); - $c->dbv->course_del($id) if ($t eq 'c'); - $c->dbv->place_del($id) if ($t eq 'p'); + $c->mproc->event_del($id) if ($t eq 'e'); + $c->mproc->course_del($id) if ($t eq 'c'); + $c->mproc->place_del($id) if ($t eq 'p'); } elsif( $req eq "Aceptar"){ if($t eq 'e'){ my @list=map{$c->param($_)}qw/eplace yini mini dini yend mend dend cost promo pen ecourse eimg een id/; - $c->dbv->event_up(@list) if ($id ==0); - $c->dbv->event_ch(@list) if ($id >0); + $c->mproc->event_up(@list) if ($id ==0); + $c->mproc->event_ch(@list) if ($id >0); } if($t eq 'c'){ my @list=map{$c->param($_)}qw/cname csubjects cservices cen id/; - $c->dbv->course_up(@list) if ($id ==0); - $c->dbv->course_ch(@list) if ($id >0); + $c->mproc->course_up(@list) if ($id ==0); + $c->mproc->course_ch(@list) if ($id >0); } if($t eq 'p'){ my @list=map{$c->param($_)}qw/pname paddr pobs pto pst pco plat plng pen id/; - $c->dbv->place_up(@list) if ($id ==0); - $c->dbv->place_ch(@list) if ($id >0); + $c->mproc->place_up(@list) if ($id ==0); + $c->mproc->place_ch(@list) if ($id >0); } } $c->redirect_to("/admin/eventos"); } $c->stash( - courses=>$c->dbv->courses, - places=>$c->dbv->places, - months=>$c->dbv->months, - events=>$c->dbv->events, - img=>$c->dbv->eimgList, + courses=>$c->mproc->courses, + places=>$c->mproc->places, + months=>['enero','febrero','marzo','abril','mayo','junio','julio','agosto','septiembre','octubre','noviembre','diciembre' ], + events=>$c->mproc->events, + img=>$c->mproc->eimgList, ); - $c->stash(template=>"home/admin/event"); - $c->stash(layout=>"admin"); -} - -sub admin_tienda{ - my $c=shift; - $c->stash(u=>$c->dbv->user_heads); - $c->stash(s=>$c->dbv->store_heads); - $c->stash(template=>"home/admin/tienda"); + $c->stash(template=>"admin/event"); $c->stash(layout=>"admin"); } # Funciones auxiliares ======================================================== -sub admin_json{ +sub json{ my $c=shift; my $id = $c->param('id'); my $req = $c->param('dreq'); my $json = "304"; - $json = $c->dbv->astore($id) if $req=~/tienda/; - $json = $c->dbv->course($id) if $req=~/course/; - $json = $c->dbv->place($id) if $req=~/place/; - $json = $c->dbv->eventa($id) if $req=~/event/; + $json = $c->dbv->msg($id) if $req=~/mensaje/; + $json = $c->dbv->rmsgid ($id) if $req =~/^mensajes$/; + + $json = $c->mproc->course($id) if $req=~/course/; + $json = $c->mproc->place($id) if $req=~/place/; + $json = $c->mproc->eventa($id) if $req=~/event/; + $json = $c->mproc->ecourse($id) if $req =~/^ecourse$/; + $json = $c->mproc->qcourse($id) if $req =~/^qcourse$/; + $json = $c->mproc->qplace ($id) if $req =~/^qplace$/; $c->render(json=>$json); } + + + +1; diff --git a/lib/Dojo/Controller/Home.pm b/lib/Dojo/Controller/Home.pm index 796b39d..890fd2b 100755 --- a/lib/Dojo/Controller/Home.pm +++ b/lib/Dojo/Controller/Home.pm @@ -1,7 +1,7 @@ package Dojo::Controller::Home; use Mojo::Base 'Mojolicious::Controller'; use Mojo::Template; -use Dojo::Support qw{ log get_names}; +use Dojo::Support qw{send_mail log get_names}; use JSON; use Data::Dumper; #========================= @@ -127,52 +127,5 @@ sub candy{ #============================================================================== - -# Admin ======================================================================= - sub admin{ - my $c= shift; - $c->redirect_to('/admin/home'); - } - sub admin_home{ - my $c=shift; - $c->dbv->umod($c->param('link'),$c->param('update')) - if (($c->param("hup") // " " )=~/Cambiar/); - $c->stash(template=>"home/admin/home"); - $c->stash(layout=>"admin"); - $c->stash( $c->dbv->mod); - } - - sub admin_radio{ - my $c=shift; - $c->dbv->umod($c->param('link'),'rmod') - if (($c->param("hup") // " " )=~/Cambiar/); - $c->dbg->ugrulla_pass($c->param('gpass')) - if (($c->param("pup") // " " )=~/Cambiar/); - $c->stash($c->dbv->mod); - $c->stash($c->dbg->grulla_pass); - $c->stash(apend => ["home/admin/candySwitch"]); - $c->stash(template=>"home/admin/radio"); - $c->stash(layout=>"admin"); - } - - sub admin_mensajes{ - my $c=shift; - $c->stash( h=>$c->dbv->msg_heads); - $c->stash(template=>"home/admin/mensajes"); - $c->stash(layout=>"admin"); - } - - sub admin_json{ - my $c=shift; - my $id = $c->param('id'); - my $req = $c->param('dreq'); - my $json = "304"; - $json = $c->dbv->msg($id) if $req=~/mensaje/; - $json = $c->dbv->user($id) if $req=~/usuarios/; - $c->render(json=>$json); - } - - -#============================================================================== 1; diff --git a/lib/Dojo/Controller/Proc.pm b/lib/Dojo/Controller/Proc.pm index 7c07a39..6986297 100644 --- a/lib/Dojo/Controller/Proc.pm +++ b/lib/Dojo/Controller/Proc.pm @@ -1,7 +1,7 @@ package Dojo::Controller::Proc; use Mojo::Base 'Mojolicious::Controller'; use Mojo::Template; -use Dojo::Support qw{ log get_names}; +use Dojo::Support qw{ send_mail log get_names}; use LWP::UserAgent; use HTTP::Request::Common; @@ -125,6 +125,9 @@ sub intentConfirm{ if ($r->{'status'} ne "succeeded" ){intentError($c,"payment not completed,2"); return;} $c->mproc->intentConfirm($data,$r); + map { send_mail(@$_) }$c->mproc->notify($data,$r); + + my $rtt = { 'status'=>$r->{'status'}, 'plan' => $r->{'payment_method_options'}{'card'}{'installments'}{'plan'}, diff --git a/lib/Dojo/Controller/Users.pm b/lib/Dojo/Controller/Users.pm index b19137b..7a5b398 100755 --- a/lib/Dojo/Controller/Users.pm +++ b/lib/Dojo/Controller/Users.pm @@ -22,8 +22,7 @@ sub reg{ $self->stash(layout=>"default"); } - - sub login { +sub login { my $self = shift; #falta si el usuario ya está registrado y llama a login. if (($self->session('ureq')//0) == 4){ #admin @@ -57,18 +56,21 @@ sub is_logged { $self->session(ureq=>1,prev=>$self->url_for); $self->redirect_to('login'); } + sub is_admin { my $self = shift; return 1 if ( ($self->session('pmid') //0) == 4); $self->session(ureq=>4,prev=>$self->url_for); $self->redirect_to('login'); } + sub is_grulla { my $self = shift; return 1 if (($self->session('pmid')//0)>=2); $self->session(ureq=>2,tmpreq=>0,prev=>$self->url_for); $self->redirect_to('login'); } + sub is_grulla_tmp{ my $self = shift; return 1 if (($self->session('pmid')//0)>=2); diff --git a/lib/Dojo/Model/Data/admin/event/add/qCup.q b/lib/Dojo/Model/Data/admin/event/add/qCup.q index 3686dc0..2557cf4 100755 --- a/lib/Dojo/Model/Data/admin/event/add/qCup.q +++ b/lib/Dojo/Model/Data/admin/event/add/qCup.q @@ -1,11 +1,15 @@ - insert into curso - (nombre,temario,servicios,estado) - values( - ?, # cname - ?, # csubjects - ?, # cservices - case ? when "on" then 1 else 0 end #cen - ); + +insert into curso ( + nombre, + subnombre, + descripcion, + imagena, + maestro, + temario, + servicios, + estado +) +values(?,?,?,?,?,?,?,?); diff --git a/lib/Dojo/Model/Data/admin/event/add/qEup.q b/lib/Dojo/Model/Data/admin/event/add/qEup.q index ba4ae19..67e0fc6 100755 --- a/lib/Dojo/Model/Data/admin/event/add/qEup.q +++ b/lib/Dojo/Model/Data/admin/event/add/qEup.q @@ -1,14 +1,20 @@ - insert into evento - (lugar_id, fecha_inicio, fecha_fin, precio, promocion, promo_estado, curso_id, imagen_chica, estado) - values( - ?, # eplace - concat(?,"-",?,"-",?), # yini - mini - dini - concat(?,"-",?,"-",?), # yend - mend - dend - ?, # cost , - ?, # promo , - case ? when "on" then 1 else 0 end, # pen - ?, # ecourse , - ?, # eimg , - case ? when "on" then 1 else 0 end # een - ); + +insert into curso_tienda ( + lugar_id, + fecha_inicio, + fecha_fin, + imagen_chica, + comentario, + precio, + promocion, + promo_estado, + playera_estado, + spay, + store, + meses, + cupo, + curso_id, + estado +) +values( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?); diff --git a/lib/Dojo/Model/Data/admin/event/add/qPup.q b/lib/Dojo/Model/Data/admin/event/add/qPup.q index 33e4e44..9caf0a1 100755 --- a/lib/Dojo/Model/Data/admin/event/add/qPup.q +++ b/lib/Dojo/Model/Data/admin/event/add/qPup.q @@ -1,15 +1,15 @@ - insert into lugar - (nombre,direccion,observacion,municipio,federativa,pais,lat,lng,estado) - values( - ?, # pname - ?, # paddr - ?, # pobs - ?, # pto - ?, # pst - ?, # pco - ?, # plat - ?, # plng - case ? when "on" then 1 else 0 end #pen - ); + +insert into curso_lugar ( + nombre, + direccion, + observacion, + municipio, + federativa, + pais, + lat, + lng, + estado +) +values(?,?,?,?,?,?,?,?,?); diff --git a/lib/Dojo/Model/Data/admin/event/change/qCup.q b/lib/Dojo/Model/Data/admin/event/change/qCup.q index a0d3c39..bc10366 100755 --- a/lib/Dojo/Model/Data/admin/event/change/qCup.q +++ b/lib/Dojo/Model/Data/admin/event/change/qCup.q @@ -1,6 +1,11 @@ - update curso set - nombre = ?, # cname - temario = ?, # csubjects - servicios = ?, # cservices - estado = case ? when "on" then 1 else 0 end # cen - where id = ? ; # cprev + +update curso set + nombre=?, + subnombre=?, + descripcion=?, + imagena=?, + maestro=?, + temario=?, + servicios=?, + estado=? +where id = ? ; # cprev diff --git a/lib/Dojo/Model/Data/admin/event/change/qEdel.q b/lib/Dojo/Model/Data/admin/event/change/qEdel.q index 0b2ef59..0a75991 100755 --- a/lib/Dojo/Model/Data/admin/event/change/qEdel.q +++ b/lib/Dojo/Model/Data/admin/event/change/qEdel.q @@ -1,2 +1,2 @@ - delete from evento where id = ? ; # eprev + delete from curso_tienda where id = ? ; # eprev diff --git a/lib/Dojo/Model/Data/admin/event/change/qEup.q b/lib/Dojo/Model/Data/admin/event/change/qEup.q index 162cf69..dd99fba 100755 --- a/lib/Dojo/Model/Data/admin/event/change/qEup.q +++ b/lib/Dojo/Model/Data/admin/event/change/qEup.q @@ -1,12 +1,19 @@ - update evento set - lugar_id = ?, # eplace - fecha_inicio = concat(?,"-",?,"-",?), # yini - mini - dini - fecha_fin = concat(?,"-",?,"-",?), # yend - mend - dend - precio = ?, # cost - promocion = ?, # promo - promo_estado = case ? when "on" then 1 else 0 end, #pen - curso_id = ?, # ecourse - imagen_chica = ?, # eimg - estado = case ? when "on" then 1 else 0 end # een - where id = ?; # eprev + +update curso_tienda set + lugar_id=?, + fecha_inicio=?, + fecha_fin=?, + imagen_chica=?, + comentario=?, + precio=?, + promocion=?, + promo_estado=?, + playera_estado=?, + spay=?, + store=?, + meses=?, + cupo=?, + curso_id=?, + estado=? + where id = ?; # eprev diff --git a/lib/Dojo/Model/Data/admin/event/change/qPdel.q b/lib/Dojo/Model/Data/admin/event/change/qPdel.q index 80f79a3..373c861 100755 --- a/lib/Dojo/Model/Data/admin/event/change/qPdel.q +++ b/lib/Dojo/Model/Data/admin/event/change/qPdel.q @@ -1,4 +1,4 @@ - delete from lugar where id = ?; # pprev ; + delete from curso_lugar where id = ?; # pprev ; diff --git a/lib/Dojo/Model/Data/admin/event/change/qPup.q b/lib/Dojo/Model/Data/admin/event/change/qPup.q index a09f964..4ee363d 100755 --- a/lib/Dojo/Model/Data/admin/event/change/qPup.q +++ b/lib/Dojo/Model/Data/admin/event/change/qPup.q @@ -1,12 +1,13 @@ - update lugar set - nombre= ?, # pname - direccion= ?, # paddr - observacion= ?,# pobs - municipio= ?, # pto - federativa= ?, # pst - pais= ?, # pco - lat=?, # plat - lng=?, # plng - estado = case ? when "on" then 1 else 0 end # pen - where id = ?; # pprev ; + +update curso_lugar set + nombre= ?, # pname + direccion= ?, # paddr + observacion= ?,# pobs + municipio= ?, # pto + federativa= ?, # pst + pais= ?, # pco + lat=?, # plat + lng=?, # plng + estado = ? +where id = ?; # pprev ; diff --git a/lib/Dojo/Model/Data/admin/event/json/qCourse.q b/lib/Dojo/Model/Data/admin/event/json/qCourse.q index 8e37e15..d15e759 100755 --- a/lib/Dojo/Model/Data/admin/event/json/qCourse.q +++ b/lib/Dojo/Model/Data/admin/event/json/qCourse.q @@ -1,8 +1,14 @@ + select id as "cid", nombre as "cname", + subnombre as "csubname", + descripcion as "cdesc", + imagen_a as "cimga", + maestro as "cmas", temario as "csubjects", - servicios as "cservices" + servicios as "cservices", + estado as "cestado" from curso where id= ? ; #course ; diff --git a/lib/Dojo/Model/Data/admin/event/json/qEvent.q b/lib/Dojo/Model/Data/admin/event/json/qEvent.q index ce4f278..77c1b0e 100755 --- a/lib/Dojo/Model/Data/admin/event/json/qEvent.q +++ b/lib/Dojo/Model/Data/admin/event/json/qEvent.q @@ -1,11 +1,8 @@ + select "event" as "tag", id, lugar_id as "pid", - curso_id as "cid", - precio as "cost", - promocion as "promo", - promo_estado as "pen", day(fecha_inicio) as "dini", month(fecha_inicio) as "mini", year(fecha_inicio) as "yini", @@ -13,9 +10,18 @@ select month(fecha_fin) as "mend", year(fecha_fin) as "yend", coalesce(imagen_chica,0) as "eimg", - + comentario as "comment", + precio as "cost", + promocion as "promo", + promo_estado as "pen", + playera_estado as "ten", + spay, + estore, + meses, + cupo, + curso_id as "cid", estado as "een" - from evento - where id= ? ; # ecourse ; +from curso_tienda +where id= ? ; # ecourse ; diff --git a/lib/Dojo/Model/Data/admin/event/json/qPlace.q b/lib/Dojo/Model/Data/admin/event/json/qPlace.q index 7ee697a..5f18d4b 100755 --- a/lib/Dojo/Model/Data/admin/event/json/qPlace.q +++ b/lib/Dojo/Model/Data/admin/event/json/qPlace.q @@ -9,7 +9,7 @@ select lat as "plat", lng as "plng", estado as "pen" -from lugar +from curso_lugar where id= ? ; # course ; diff --git a/lib/Dojo/Model/Data/admin/event/qCprev.q b/lib/Dojo/Model/Data/admin/event/qCprev.q index b72bd8b..70a75a6 100755 --- a/lib/Dojo/Model/Data/admin/event/qCprev.q +++ b/lib/Dojo/Model/Data/admin/event/qCprev.q @@ -1,10 +1,3 @@ - - /* c#host localhost*/ - /* c#database #dbdata */ - /* c#user #dbdata_user */ - /* c#password #dbdata_pass */ - - select "cprev" as "tag", diff --git a/lib/Dojo/Model/Data/admin/event/qEcourse.q b/lib/Dojo/Model/Data/admin/event/qEcourse.q index 5b1e231..9f91945 100755 --- a/lib/Dojo/Model/Data/admin/event/qEcourse.q +++ b/lib/Dojo/Model/Data/admin/event/qEcourse.q @@ -1,10 +1,4 @@ - /* c#host localhost*/ - /* c#database #dbdata */ - /* c#user #dbdata_user */ - /* c#password #dbdata_pass */ - - select "ecourse" as "tag", nombre as "name", diff --git a/lib/Dojo/Model/Data/admin/event/qEmend.q b/lib/Dojo/Model/Data/admin/event/qEmend.q deleted file mode 100755 index 4b90bba..0000000 --- a/lib/Dojo/Model/Data/admin/event/qEmend.q +++ /dev/null @@ -1,13 +0,0 @@ - - /* c#host localhost*/ - /* c#database #dbdata */ - /* c#user #dbdata_user */ - /* c#password #dbdata_pass */ - - - -select - "emend" as "tag", - nombre as "name", - id - from mes; diff --git a/lib/Dojo/Model/Data/admin/event/qEmini.q b/lib/Dojo/Model/Data/admin/event/qEmini.q deleted file mode 100755 index 17cc96e..0000000 --- a/lib/Dojo/Model/Data/admin/event/qEmini.q +++ /dev/null @@ -1,14 +0,0 @@ - - /* c#host localhost*/ - /* c#database #dbdata */ - /* c#user #dbdata_user */ - /* c#password #dbdata_pass */ - - - - -select - "emini" as "tag", - nombre as "name", - id - from mes; diff --git a/lib/Dojo/Model/Data/admin/event/qEplace.q b/lib/Dojo/Model/Data/admin/event/qEplace.q index 0a705e7..7212e9f 100755 --- a/lib/Dojo/Model/Data/admin/event/qEplace.q +++ b/lib/Dojo/Model/Data/admin/event/qEplace.q @@ -1,13 +1,6 @@ - /* c#host localhost*/ - /* c#database #dbdata */ - /* c#user #dbdata_user */ - /* c#password #dbdata_pass */ - - - select "eplace" as "tag", nombre as "name", id - from lugar where estado=1; + from curso_lugar where estado=1; diff --git a/lib/Dojo/Model/Data/admin/event/qEprev.q b/lib/Dojo/Model/Data/admin/event/qEprev.q index b266827..66cdace 100755 --- a/lib/Dojo/Model/Data/admin/event/qEprev.q +++ b/lib/Dojo/Model/Data/admin/event/qEprev.q @@ -1,9 +1,9 @@ -select - concat(day(e.fecha_inicio)," de ",m.nombre," ",l.nombre) as "name", - e.id as id - from evento as e - inner join lugar as l on e.lugar_id=l.id - inner join mes as m on month(e.fecha_inicio)=m.id - where e.estado=1 - order by e.fecha_inicio desc; + +select + concat(month(t.fecha_inicio)," ",day(t.fecha_inicio)," ",l.nombre) as "name", + t.id as id + from curso_tienda as t + inner join curso_lugar as l on t.lugar_id=l.id + where t.estado=1 + order by t.fecha_inicio desc; diff --git a/lib/Dojo/Model/Data/admin/event/qPprev.q b/lib/Dojo/Model/Data/admin/event/qPprev.q index 3372a4e..f75a521 100755 --- a/lib/Dojo/Model/Data/admin/event/qPprev.q +++ b/lib/Dojo/Model/Data/admin/event/qPprev.q @@ -1,15 +1,8 @@ - - /* c#host localhost*/ - /* c#database #dbdata */ - /* c#user #dbdata_user */ - /* c#password #dbdata_pass */ - - select "pprev" as "tag", nombre as "name", id - from lugar +from curso_lugar order by nombre asc; diff --git a/lib/Dojo/Model/Data/admin/mensajes/json/qGetInfo.q b/lib/Dojo/Model/Data/admin/mensajes/json/qGetInfo.q index 649022b..72857b8 100755 --- a/lib/Dojo/Model/Data/admin/mensajes/json/qGetInfo.q +++ b/lib/Dojo/Model/Data/admin/mensajes/json/qGetInfo.q @@ -1,11 +1,10 @@ select e.id as imid, - concat(day(e.fecha)," de ",m.nombre," ", year(e.fecha)) as imdate, + concat(month(e.fecha)," ",day(e.fecha)," ", year(e.fecha)) as imdate, e.nombre as imname, e.correo as imail, e.texto as immsg from entrada as e -inner join vuelo.mes as m on m.id=month(e.fecha) where e.id= ? ; #imid diff --git a/lib/Dojo/Model/Data/admin/mensajes/qEntries.q b/lib/Dojo/Model/Data/admin/mensajes/qEntries.q index e534e58..6655cb8 100755 --- a/lib/Dojo/Model/Data/admin/mensajes/qEntries.q +++ b/lib/Dojo/Model/Data/admin/mensajes/qEntries.q @@ -1,3 +1,4 @@ + select id as mid, concat(nombre," ",date(fecha)) as "entry" diff --git a/lib/Dojo/Model/Data/admin/tienda/json/qStore.q b/lib/Dojo/Model/Data/admin/tienda/json/qStore.q deleted file mode 100755 index 82f26e5..0000000 --- a/lib/Dojo/Model/Data/admin/tienda/json/qStore.q +++ /dev/null @@ -1,4 +0,0 @@ -select - a.id,a.nombre,a.existencia,a.imagen,a.precio,a.activo,a.descripcion,date(a.vigencia) as vigencia,b.nombre as entrega -from tienda as a inner join entrega as b where a.entrega_id=b.id -and a.id=?; diff --git a/lib/Dojo/Model/Data/admin/tienda/json/qUsers.q b/lib/Dojo/Model/Data/admin/tienda/json/qUsers.q deleted file mode 100755 index 7cd1b29..0000000 --- a/lib/Dojo/Model/Data/admin/tienda/json/qUsers.q +++ /dev/null @@ -1,4 +0,0 @@ -select -correo,telefono as tel, observacion as obs,date(ultima) as ultima -from usuario where id=?; - diff --git a/lib/Dojo/Model/Data/admin/tienda/qStore.q b/lib/Dojo/Model/Data/admin/tienda/qStore.q deleted file mode 100755 index 707bff3..0000000 --- a/lib/Dojo/Model/Data/admin/tienda/qStore.q +++ /dev/null @@ -1,3 +0,0 @@ -select - id,nombre,existencia,precio,activo -from tienda order by id; diff --git a/lib/Dojo/Model/Data/admin/tienda/qUsers.q b/lib/Dojo/Model/Data/admin/tienda/qUsers.q deleted file mode 100755 index 6c1d65c..0000000 --- a/lib/Dojo/Model/Data/admin/tienda/qUsers.q +++ /dev/null @@ -1,4 +0,0 @@ -select -id,usuario,nombre -from usuario order by usuario; - diff --git a/lib/Dojo/Model/Data/spay/qIntentConfirm.q b/lib/Dojo/Model/Data/spay/qIntentConfirm.q index c6a2808..738fa87 100644 --- a/lib/Dojo/Model/Data/spay/qIntentConfirm.q +++ b/lib/Dojo/Model/Data/spay/qIntentConfirm.q @@ -1,9 +1,9 @@ -insert into caja_evento +insert into curso_caja ( cliente_nombre, cliente_correo, cliente_comentario, - tienda_evento_id, + curso_tienda_id, talla_id, cantidad, monto, diff --git a/lib/Dojo/Model/Data/spay/qIntentCreate.q b/lib/Dojo/Model/Data/spay/qIntentCreate.q index e66bed1..8f0c74e 100644 --- a/lib/Dojo/Model/Data/spay/qIntentCreate.q +++ b/lib/Dojo/Model/Data/spay/qIntentCreate.q @@ -2,7 +2,7 @@ select t.precio as precio, c.nombre as nombre from - tienda_evento as t + curso_tienda as t inner join curso as c on t.curso_id=c.id where diff --git a/lib/Dojo/Model/Data/spay/qNotify.q b/lib/Dojo/Model/Data/spay/qNotify.q new file mode 100644 index 0000000..449943f --- /dev/null +++ b/lib/Dojo/Model/Data/spay/qNotify.q @@ -0,0 +1,12 @@ +select + c.nombre as cnombre, + c.subnombre as csubnobre, + t.mmail as mmail, + t.fecha_inicio, + t.fecha_fin, + t.precio as cantidad +from curso_tienda as t +inner join curso as c on c.id = t.curso_id +where t.id = ? and t.estado =1 +; + diff --git a/lib/Dojo/Model/Vdgproc.pm b/lib/Dojo/Model/Vdgproc.pm index f5dba26..3d09c80 100644 --- a/lib/Dojo/Model/Vdgproc.pm +++ b/lib/Dojo/Model/Vdgproc.pm @@ -84,6 +84,50 @@ sub intentConfirm{ return ; } +sub notify{ + my ($c,$d,$r) = @_; + my $t =shift @{ _read ($data_path->child("spay/qNotify.q")->slurp,$d->{'tid'})}; + my @ra; + my %h=qw/0 na 1 ch 2 m 3 g/; + my $plazo= defined( $d->{'selected_plan'})? + $d->{'selected_plan'}->{'count'} : "0"; + my $students = $d->{'students'}; + my $basetxta = "$t->{'cnombre'} + clave de pago stripe: $d->{'payment_intent_id'} + plazo: $plazo meses + cantidad: $t->{'cantidad'} + "; + my $basetxtu = $t->{'cnombre'}//""." + ".$t->{'subnombre'}//""." + + "; + + foreach(1 .. $d->{'mq'}) { + push (@ra, [" + $basetxtu +$$students[$_ -1][0] + $t->{'mmail'} + + + tu clave de pago es la sigiente. Tenla a la mano para cualquier aclaración +========================== + $d->{'payment_intent_id'} +=========================== + ", " Inscripción ", $$students[$_ -1][1]]); + $basetxta .= " + Nombre: $$students[$_ -1][0] + Correo: $$students[$_ -1][1] + Telefono:$$students[$_ -1][0] + Playera:$h{$$students[$_ -1][3]} + Comentario:$$students[$_ -1][2] + ===================== + "; + } + + push (@ra, [$basetxta,"Inscripciones",'david@chaos.foundation']); + return @ra; +} + # Check payment user info ============== # data: # =============== @@ -135,9 +179,9 @@ sub is_mail{ #============================================================================== # admin evets -sub event_del { return _write("delete from evento where id = ?;",pop);} +sub event_del { return _write("delete from curso_tienda where id = ?;",pop);} sub course_del{ return _write("delete from curso where id = ?;",pop); } -sub place_del { return _write("delete from lugar where id = ?;",pop); } +sub place_del { return _write("delete from curso_lugar where id = ?;",pop); } sub event_up{ my ($self,@bind)=@_; @@ -165,6 +209,22 @@ sub place_ch{ } #============================================================================== +sub courses{ return _read("select nombre as name, id from curso;")} + +sub course { return shift @{_read($data_path->child("/admin/event/json/qCourse.q")->slurp,pop)}} + +sub places { return _read("select nombre as name, id from curso_lugar;")} + +sub place { return shift @{_read($data_path->child("/admin/event/json/qPlace.q")->slurp,pop)}} + +sub events { return _read($data_path->child("/admin/event/qEprev.q")->slurp)} + +sub eventa { return shift @{_read($data_path->child("/admin/event/json/qEvent.q")->slurp,pop)}} + +sub eimgList{ + my $dp = path('public/proc/cal/img')->make_path; + return [ map{ $_->basename} grep{/(jpg|png)$/i}@{$dp->list} ]; +} # lower level read ===================================== diff --git a/lib/Dojo/Model/Vuelo.pm b/lib/Dojo/Model/Vuelo.pm index c957911..df2513a 100755 --- a/lib/Dojo/Model/Vuelo.pm +++ b/lib/Dojo/Model/Vuelo.pm @@ -30,17 +30,6 @@ sub pang_md{ return \%h; } -sub calendar_monthblock { - return _read ($data_path->child("cal/q1Block.q")->slurp); -} -sub calendar_events { - return _read ($data_path->child("cal/q3Event.q")->slurp); -} - -sub event{ - my ($c,$id)=@_; - return shift @{ _read ($data_path->child("event/qEvent.q")->slurp,$id)}; -} sub tv_videos{ return _read ($data_path->child("/tv/qSeries.q")->slurp); #group,name } @@ -57,57 +46,29 @@ sub podcast_infoHash{ #============================================================================== # Read vdg admin ============================================================== - sub msg_heads{ - my ($self,@bind)=@_; - my @empty; - my $q= $data_path->child("/admin/mensajes/qEntries.q")->slurp; - my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::MSGDB.":".Dojo::Conf::MSGDB_H,Dojo::Conf::MSGDB_UR,Dojo::Conf::MSGDB_URP,{mysql_enable_utf8 => 1}); - return \@empty unless($dbh); - my $h=$dbh->selectall_arrayref($q,{ Slice => {} },@bind)//"error"; - #((col1=>d1,col2=>d1),(col1=>d2,col2=>d2)) - $dbh->disconnect(); - return $h; - } +sub msg_heads{ + my ($self,@bind)=@_; + my @empty; + my $q= $data_path->child("/admin/mensajes/qEntries.q")->slurp; + my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::MSGDB.":".Dojo::Conf::MSGDB_H,Dojo::Conf::MSGDB_UR,Dojo::Conf::MSGDB_URP,{mysql_enable_utf8 => 1}); + return \@empty unless($dbh); + my $h=$dbh->selectall_arrayref($q,{ Slice => {} },@bind)//"error"; + #((col1=>d1,col2=>d1),(col1=>d2,col2=>d2)) + $dbh->disconnect(); + return $h; +} - sub msg{ - my ($c,@bind)=@_; - my @empty; - my $q= $data_path->child("/admin/mensajes/json/qGetInfo.q")->slurp; - my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::MSGDB.":".Dojo::Conf::MSGDB_H,Dojo::Conf::MSGDB_UR,Dojo::Conf::MSGDB_URP,{mysql_enable_utf8 => 1}); - return \@empty unless($dbh); - my $h=$dbh->selectall_arrayref($q,{ Slice => {} },@bind)//\@empty; - #((col1=>d1,col2=>d1),(col1=>d2,col2=>d2)) - $dbh->disconnect(); - return shift @$h; - } - - sub user_heads{ - return _readgrulla($data_path->child("admin/tienda/qUsers.q")->slurp); - } - - sub store_heads{ - return _readgrulla($data_path->child("admin/tienda/qStore.q")->slurp); - } - - sub user { - return shift @{_readgrulla($data_path->child("admin/tienda/json/qUsers.q")->slurp,pop)}} - - sub astore { - return shift @{_readgrulla($data_path->child("/admin/tienda/json/qStore.q")->slurp,pop)}} - - - sub courses{ return _read("select nombre as name, id from curso;")} - sub course { return shift @{_read($data_path->child("/admin/event/json/qCourse.q")->slurp,pop)}} - sub places { return _read("select nombre as name, id from lugar;")} - sub place { return shift @{_read($data_path->child("/admin/event/json/qPlace.q")->slurp,pop)}} - sub months { return _read("select nombre as name, id from mes;")}; - sub events { return _read($data_path->child("/admin/event/qEprev.q")->slurp)} - sub eventa { return shift @{_read($data_path->child("/admin/event/json/qEvent.q")->slurp,pop)}} - # sub eimgList{ return [get_names("public/home/cal/img/")] } - sub eimgList{ - my $dp = path('public/home/cal/img')->make_path; - return [ map{ $_->basename} grep{/(jpg|png)$/i}@{$dp->list} ]; - } +sub msg{ + my ($c,@bind)=@_; + my @empty; + my $q= $data_path->child("/admin/mensajes/json/qGetInfo.q")->slurp; + my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::MSGDB.":".Dojo::Conf::MSGDB_H,Dojo::Conf::MSGDB_UR,Dojo::Conf::MSGDB_URP,{mysql_enable_utf8 => 1}); + return \@empty unless($dbh); + my $h=$dbh->selectall_arrayref($q,{ Slice => {} },@bind)//\@empty; + #((col1=>d1,col2=>d1),(col1=>d2,col2=>d2)) + $dbh->disconnect(); + return shift @$h; +} #============================================================================== # Write vdg user ============================================================== @@ -116,7 +77,7 @@ sub contact{ my $q="insert into entrada (nombre,correo,pagina,texto,fecha) values(?,?,?,?,now() )" ; my @a=@_; #simple method to ignore spam - return _writemsg($q,@a) unless $a[3]=~m/http|website|\child("/admin/event/add/qEup.q")->slurp,@bind); -} -sub course_up{ - my ($self,@bind)=@_; - return _write($data_path->child("/admin/event/add/qCup.q")->slurp,@bind); -} -sub place_up{ - my ($self,@bind)=@_; - return _write($data_path->child("/admin/event/add/qPup.q")->slurp,@bind); -} -sub event_ch{ - my ($self,@bind)=@_; - return _write($data_path->child("/admin/event/change/qEup.q")->slurp,@bind); -} -sub course_ch{ - my ($self,@bind)=@_; - return _write($data_path->child("/admin/event/change/qCup.q")->slurp,@bind); -} -sub place_ch{ - my ($self,@bind)=@_; - return _write($data_path->child("/admin/event/change/qPup.q")->slurp,@bind); -} - #============================================================================== #ayudas ===================================== diff --git a/lib/Dojo/Support.pm b/lib/Dojo/Support.pm index 910e43d..d96096d 100755 --- a/lib/Dojo/Support.pm +++ b/lib/Dojo/Support.pm @@ -2,7 +2,7 @@ package Dojo::Support; use strict; use warnings; use Exporter 'import'; -our @EXPORT = qw/ mtxt commify month_num2txt log dmph merge_hash load_module get_names /; +our @EXPORT = qw/send_mail mtxt commify month_names month_num2txt log dmph merge_hash load_module get_names /; use Mojo::Base 'Mojolicious'; use File::Basename; @@ -18,6 +18,11 @@ sub log{ $log->debug("============ ".shift." ==========="); } +sub _log{ + my $log = Mojo::Log->new; + $log->debug("============ ".shift." ==========="); +} + sub get_names{ my $dir = shift; my @file_name; @@ -45,6 +50,10 @@ sub month_num2txt{ return ("enero febrero marzo abril mayo junio julio agosto septiembre octubre noviembre diciembre" =~ m/\w+/g)[shift (@_) -1]; } +sub month_names{ + return qw /enero febrero marzo abril mayo junio julio agosto septiembre octubre noviembre diciembre/; +} + sub mtxt { my ($di, $mi, $df, $mf)=@_; # dini,mini,dfin,mfin my $txt; @@ -89,5 +98,10 @@ sub dmph{ return $y; } +sub send_mail{ #msg header mail + system( 'echo "'.shift.'" | mutt -s '.shift.' '.shift.' &'); + _log("mail sent"); + return 0; +} 1; diff --git a/public/admin/event/event.css b/public/admin/event/event.css index 31c45ca..240eac3 100755 --- a/public/admin/event/event.css +++ b/public/admin/event/event.css @@ -76,6 +76,7 @@ div.update{ article.edit input[type=submit]{ margin:15px; } +div#cimg, div#esimg{ height:180px; width:180px; diff --git a/public/admin/event/event.js b/public/admin/event/event.js index 2792d68..ed05735 100755 --- a/public/admin/event/event.js +++ b/public/admin/event/event.js @@ -1,6 +1,6 @@ d3.select("li#evento").style("background-color","#cedeef"); var li = d3.select("article.label","ul").selectAll("li"); -var img_path = "/home/cal/img/"; +var img_path = "/proc/cal/img/"; var json_path = "/admin/json/"; /* menu hide and show edit window*/ li.on("click",function(){ @@ -46,10 +46,21 @@ d3.select("select#cprev").on("change",function(){ d3.json(json_path+"course/"+cprev_id ,function(d){ if(d!=undefined){if(d.cid != 0){ d3.select("input#cname").attr("value",d.cname); + d3.select("input#csubname").attr("value",d.csubname); + d3.select("textarea#cdesc").text(d.cdesc); + d3.select("input#cmas").attr("value",d.mas); d3.select("textarea#csubjects").text(d.csubjects); d3.select("textarea#cservices").text(d.cservices); }} }); }); +function updateImagea(){ + var iname=d3.select("select#cimga").node().value; + if(iname != 0){ + d3.select("div#cimg").style("background-image","url("+img_path+iname+")");} + else{ d3.select("div#cimg").style("background-image","none"); } +} +d3.select("select#cimga").on("change",updateImagea); + /*preload form content for place*/ d3.select("select#pprev").on("change",function(){ var pprev_id=d3.select("select#pprev").node().value; diff --git a/templates/admin/event.html.ep b/templates/admin/event.html.ep index 6ac7c99..17d7701 100755 --- a/templates/admin/event.html.ep +++ b/templates/admin/event.html.ep @@ -1,10 +1,13 @@ % stash css=>["/admin/admin.css","/admin/event/event.css"]; -% stash js=>["//admin/event/event.js"]; -
-

Editar Eventos

-
+% stash js=>["/admin/event/event.js"]; +
+
+

Editar Eventos

+
+
+
  • Evento
  • @@ -12,137 +15,186 @@
  • Lugar
- +
- -
-
- - -
-
- - -
-
- - - - -
-
- - - - -
-
- -
-
- - -
-
- - <% map{ %> - + + <% } %><% (@{stash('courses')}) %><% if defined(stash('courses')); %> + +
+
+ + +
+
+ + + + +
+
+ + + + +
+
+ +
+
+ + +
+
+ + -
-
-
- - +
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+ + +
+ + -
-
- - - - -
-
- -
-
- - -
- - -
- - -
- - +
+
+ + + + +
+
+
+ +
+
+
+ + +
+ + +
+ + +
+ + +
+ + +
+
+
+ + +
+ + +
+ + -
- - - - -
-
- -
-
- -
- -
- -
- -
- -
- -
- -
- -
- - +
+ + + + +
+
+
+ +
+
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + -
- - - - -
-
+ <% } %><% (@{stash('places')}) %><% if defined(stash('places')); %> + +
+ + + + +
+ +
+
+