diff --git a/lib/Dojo.pm b/lib/Dojo.pm index 91a066d..9417aaf 100755 --- a/lib/Dojo.pm +++ b/lib/Dojo.pm @@ -3,83 +3,88 @@ use Mojo::Base 'Mojolicious'; use Dojo::Conf; use Dojo::Model::Vuelo; use Dojo::Model::Users; +use Dojo::Model::Vdgproc; # This method will run once at server start - sub startup { - my $self = shift; - my $config = $self->plugin('Config'); #Config hash dojo.conf - # $self->plugin('PODRenderer') if $config->{perldoc}; #doc - $self->secrets(['Mojojojo jojo']); #cookies +sub startup { + my $self = shift; + my $config = $self->plugin('Config'); #Config hash dojo.conf + # $self->plugin('PODRenderer') if $config->{perldoc}; #doc + $self->secrets(['Mojojojo jojo']); #cookies - $self->helper(dbv => sub { state $dbv = Dojo::Model::Vuelo->new }); - $self->helper(dbg => sub { state $dbg = Dojo::Model::Users->new }); - $self->defaults({%Dojo::Conf::def}); - my $r = $self->routes; #router + $self->helper(dbv => sub { state $dbv = Dojo::Model::Vuelo->new }); + $self->helper(dbg => sub { state $dbg = Dojo::Model::Users->new }); + $self->helper(mproc => sub { state $mproc = Dojo::Model::Vdgproc->new }); + $self->defaults({%Dojo::Conf::def}); + my $r = $self->routes; #router -# user ======================================================================== - $r->any('/')->to('home#home_'); - $r->any('/home')->to('home#home'); - $r->any('/cal')->to('home#cal'); - $r->any('/event/:id'=> [id => qr/\d+/])->to('home#event'); - $r->any('/pod')->to('home#podcast'); - $r->any('/store')->to('home#store'); - $r->any('/tv')->to('home#tv'); - $r->any('/contact')->to('home#contact'); - $r->any('/contact2')->to('home#contact2'); - $r->any('/pang')->to('home#pang'); - # $r->any('/tst')->to('home#tst'); -# ============================================================================= + # de la pagina =============================================================== + $r->any('/')->to('home#home_'); + $r->any('/home')->to('home#home'); + $r->any('/pod')->to('home#podcast'); + # $r->any('/store')->to('home#store'); + $r->any('/tv')->to('home#tv'); + $r->any('/contact')->to('home#contact'); + $r->any('/contact2')->to('home#contact2'); + $r->any('/pang')->to('home#pang'); + # json ================== + $r->any('/json/*dreq')->to('data#simple'); + # ============================================================================= + # de la tienda ================================================================ + $r->any('/cal')->to('proc#cal'); + $r->any('/event/:id'=> [id => qr/\d+/])->to('proc#event'); + $r->any('/spay/:class/:id' => [class => qr/\d+/, id => qr/\d+/])->to('proc#spay'); + $r->any('/spay/intentCreate')->to('proc#intentCreate'); + $r->any('/spay/intentConfirm')->to('proc#intentConfirm'); + $r->any('/spay/userCheck')->to('proc#userCheck'); + # ============================================================================= -# candy ======================================================================= - $r->any('/json/candy/:command')->to('data#candy'); - $r->any('/candy')->to('home#candy'); -# ============================================================================= + # candy ======================================================================= + $r->any('/json/candy/:command')->to('data#candy'); + $r->any('/candy')->to('home#candy'); + # ============================================================================= -# json ======================================================================== - $r->any('/json/*dreq')->to('data#simple'); -# ============================================================================= + # usuarios y accesos ========================================================== + $r->any('/reg')->to('users#reg'); -# register user =============================================================== - $r->any('/reg')->to('users#reg'); -# ============================================================================= - -# login guest ================================================================= - $r->any('/login')->to('users#login'); - $r->any('/logout')->to('users#logout'); + # login guest ====== + $r->any('/login')->to('users#login'); + $r->any('/logout')->to('users#logout'); - my $logged_in = $r->under('/')->to('users#is_logged'); - $logged_in->get('/radio')->to('home#radio'); -# ============================================================================= + my $logged_in = $r->under('/')->to('users#is_logged'); + $logged_in->get('/radio')->to('home#radio'); + # =================== -# login user grulla =========================================================== - # common grulla user - my $user = $r->under('/')->to('users#is_grulla'); - $user->any('/ccast')->to('home#bcast'); - # personal - my $guest = $r->under('/')->to('users#is_grulla_tmp'); - $guest->any('/bcast')->to('home#bcast'); -# ============================================================================= - -# admin ======================================================================= - my $admin = $r->under('/admin')->to('users#is_admin'); - $admin->any('')->to('home#admin'); - $admin->any('home')->to('home#admin_home'); - $admin->any('radio')->to('home#admin_radio'); - $admin->any('eventos')->to('home#admin_eventos'); - $admin->any('eventos/:type'=> [type=>['e','p','c']])->to('home#admin_eventos'); - $admin->any('mensajes')->to('home#admin_mensajes'); - $admin->any('tienda')->to('home#admin_tienda'); - $admin->any('json/:dreq/:id')->to('home#admin_json'); + # login user grulla = + # common grulla user + my $user = $r->under('/')->to('users#is_grulla'); + $user->any('/ccast')->to('home#bcast'); + # personal + my $guest = $r->under('/')->to('users#is_grulla_tmp'); + $guest->any('/bcast')->to('home#bcast'); + # =================== + + # admin ======================================================================= + my $admin = $r->under('/admin')->to('users#is_admin'); + $admin->any('')->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('json/:dreq/:id')->to('admin#json'); + + # ============================================================================= + + # a not foud ================================================================== -# ============================================================================= - $r->any('/*whatever' => {whatever => ''} => sub { - my $c = shift; - my $whatever = $c->param('whatever'); - $c->stash(layout=>'clean'); - $c->render(template=>'home/not_found', status=>404); -}); + my $c = shift; + my $whatever = $c->param('whatever'); + $c->stash(layout=>'clean'); + $c->render(template=>'home/not_found', status=>404); + }); } 1; diff --git a/lib/Dojo/Controller/Admin.pm b/lib/Dojo/Controller/Admin.pm new file mode 100644 index 0000000..eaaf6b9 --- /dev/null +++ b/lib/Dojo/Controller/Admin.pm @@ -0,0 +1,107 @@ +package Dojo::Controller::Admin; +use Mojo::File 'path'; +use Mojo::JSON qw(decode_json encode_json); +use Mojo::Base 'Mojolicious::Controller'; +use Dojo::Support qw{ log }; + + + +# Admin ======================================================================= +sub admin{ + 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 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->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->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->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->mproc->place_up(@list) if ($id ==0); + $c->mproc->place_ch(@list) if ($id >0); + } + } + $c->redirect_to("/admin/eventos"); + } + + $c->stash( + 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=>"admin/event"); + $c->stash(layout=>"admin"); +} + +# Funciones auxiliares ======================================================== +sub 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->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/Data.pm b/lib/Dojo/Controller/Data.pm index c56b0a2..b440f03 100755 --- a/lib/Dojo/Controller/Data.pm +++ b/lib/Dojo/Controller/Data.pm @@ -8,6 +8,7 @@ use Net::Telnet; my $server_name = ""; our $t; #telnet server object my $data_path = path('lib/Dojo/Model/Data')->make_path; + sub simple{ my $c=shift; my $n=$c->param("dreq")//""; @@ -18,16 +19,6 @@ sub simple{ $c->render(json=>$json); } -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); -} #==== candy ===================================================== sub candy{ my $c=shift; @@ -43,32 +34,36 @@ sub candy{ $c->render(json => {a=>$r}); } - sub turnOff{ - grep(/Result: true/,join('',sendT('host:deactivate("'.$server_name.'")')))?1:0 - unless (isOn()==0); - } - sub turnOn{ - grep(/Result: true/,join('',sendT('host:activate("'.$server_name.'")')))?1:0 - unless (isOn()==1); +sub turnOff{ + grep(/Result: true/,join('',sendT('host:deactivate("'.$server_name.'")')))?1:0 + unless (isOn()==0); +} + +sub turnOn{ + grep(/Result: true/,join('',sendT('host:activate("'.$server_name.'")')))?1:0 + unless (isOn()==1); } - sub isOn{return grep(/\s$server_name/,sendT("host:list()"))? 1:0; } +sub isOn{return grep(/\s$server_name/,sendT("host:list()"))? 1:0; } sub sendT{ commandT(shift); my @r = $t->getlines(All=>0); return @r } + sub connectT{ $t = new Net::Telnet ( Port=>5582, Timeout=>1, Errmode=>'return' ); # $t = new Net::Telnet ( Port=>5582, Timeout=>1, Errmode=>'die' ); return 1 if $t->open(); return 0; } + sub commandT{ $t->getlines(All=>0);#empty buffer $t->print(shift); #run istruction } + sub disconnectT{ $t->close();} #========================================================= diff --git a/lib/Dojo/Controller/Example.pm b/lib/Dojo/Controller/Example.pm deleted file mode 100755 index ccf02fe..0000000 --- a/lib/Dojo/Controller/Example.pm +++ /dev/null @@ -1,12 +0,0 @@ -package Dojo::Controller::Example; -use Mojo::Base 'Mojolicious::Controller'; - -# This action will render a template -sub welcome { - my $self = shift; - - # Render template "example/welcome.html.ep" with message - $self->render(msg => 'Welcome to the Mojolicious real-time web framework!'); -} - -1; diff --git a/lib/Dojo/Controller/Home.pm b/lib/Dojo/Controller/Home.pm index d30d08f..890fd2b 100755 --- a/lib/Dojo/Controller/Home.pm +++ b/lib/Dojo/Controller/Home.pm @@ -1,10 +1,7 @@ package Dojo::Controller::Home; use Mojo::Base 'Mojolicious::Controller'; use Mojo::Template; -use Dojo::Support qw{ log get_names}; -# estos son paypal=======:w -use LWP::UserAgent; -use HTTP::Request::Common; +use Dojo::Support qw{send_mail log get_names}; use JSON; use Data::Dumper; #========================= @@ -43,9 +40,9 @@ sub tst{ # interesan create time, id, payer: email address, shippng address } else{ - my %f=('descripcion',' Había una vez un lobito bueno al que maltrataban todos los corderos','precio','33','promo','si!','existencia','3','nombre','Super master evil man','titulo'=>'venganzas del medievo'); - $c->stash(%f); - $c->stash(res=> "no"); + my $data=$c->dbg->store_id($c->param('id')); + $c->redirect_to('store') unless ($data->{'id'}); + $c->stash($data); $c->stash(layout=>'default'); } #$c->render(text=> $c->config->{radio}{'channel'}); @@ -70,23 +67,6 @@ sub pang { my $h=$c->dbv->pang_md; map { $c->stash( $_ => $h->{$_}) } keys %$h; $c->stash(layout=>'default'); - -} - -sub cal { - my $c = shift; - my $data=$c->dbv->calendar_events; - my $block=$c->dbv->calendar_monthblock; - my %h; - map{ push @{ $h{$_->{bid}} },$_; }(@$data); - $c->stash( r=>\%h, b=>$block); - $c->stash(layout=>'default'); -} - -sub event{ - my $c = shift; - $c->stash($c->dbv->event($c->param("id"))); - $c->stash(layout=> "defaultContact"); } sub contact{ @@ -112,12 +92,6 @@ sub contact2{ $c->stash(layout=>'default'); } -sub store{ - my $c = shift; - $c->stash( r=>$c->dbv->store); - $c->stash(layout=> "defaultContact"); -} - sub tv{ my $c = shift; $c->stash( videos=>$c->dbv->tv_videos, table=>$c->dbv->tv_series); @@ -135,123 +109,23 @@ sub bcast{ $c->stash(layout=> "defaultContact"); } - sub radio{ - my $c=shift; - $c->stash(layout=> "defaultContact"); - $c->stash($c->dbv->mod); - $c->stash(nick=>$c->session("nick")); - } +sub radio{ + my $c=shift; + $c->stash(layout=> "defaultContact"); + $c->stash($c->dbv->mod); + $c->stash(nick=>$c->session("nick")); +} - sub candy{ - my $c=shift; - $c->stash( css=>["/ext/candy/libs.min.css","/home/candy/default.css"]); - $c->stash( js=>["/home/candy/loader.js","/ext/candy/libs.min.js","/ext/candy/candy.min.js"]); +sub candy{ + my $c=shift; + $c->stash( css=>["/ext/candy/libs.min.css","/home/candy/default.css"]); + $c->stash( js=>["/home/candy/loader.js","/ext/candy/libs.min.js","/ext/candy/candy.min.js"]); - $c->stash(layout=> "clean"); - $c->stash(nick=>$c->session("nick")); - } + $c->stash(layout=> "clean"); + $c->stash(nick=>$c->session("nick")); +} #============================================================================== - -# 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_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'); - } - 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); - } - 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); - } - 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->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, - ); - $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(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/; - $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/; - $c->render(json=>$json); - } - - -#============================================================================== 1; diff --git a/lib/Dojo/Controller/Proc.pm b/lib/Dojo/Controller/Proc.pm new file mode 100644 index 0000000..6986297 --- /dev/null +++ b/lib/Dojo/Controller/Proc.pm @@ -0,0 +1,222 @@ +package Dojo::Controller::Proc; +use Mojo::Base 'Mojolicious::Controller'; +use Mojo::Template; +use Dojo::Support qw{ send_mail log get_names}; + +use LWP::UserAgent; +use HTTP::Request::Common; +use JSON; +use Data::Dumper; +#========================= + + +# User ======================================================================== + +sub cal { + my $c = shift; + my $data=$c->mproc->calendar_events; + my $block=$c->mproc->calendar_monthblock; + my %h; + map{ push @{ $h{$_->{bid}} },$_; }(@$data); + $c->stash( r=>\%h, b=>$block); + $c->stash(layout=>'default'); +} + +sub event{ + my $c = shift; + my $data=$c->mproc->event($c->param('id')); + $c->redirect_to('cal') unless (defined $data->{'cname'}); + $c->stash($data); + $c->stash(layout=> "defaultContact"); +} + +sub spay{ + my $c = shift; + my $data=$c->mproc->spay(1,$c->param('id')); + + $c->redirect_to('cal') unless (defined $data->{'tid'}); + if ($c->param('id') >= 80 && $c->param('id') <= 86 ){ + $c->stash(layout=> "xpay"); + } + else { + $c->stash(layout=> "defaultContact"); + } + $c->stash($data); +} + +#stripe appi function ============================================================================= +sub intentCreate{ + my $c = shift; + unless (defined ($c->req->json)){ + $c->stash(layout=>'clean'); + $c->render(template=>'home/not_found', status=>404); + return 0; + } + + my $data=$c->mproc->intentCreate($c->req->json->{'tid'}); + # if(!@$data){ intentError($c,"event not found",1); return;}; + + my $pmi=$c->req->json->{'payment_method_id'} // 0; + my $amount = $data->{'precio'} * $c->req->json->{'mq'} ; + my $description = $data->{'nombre'}; + my $max_time = 9; + + my $api_create_path='https://api.stripe.com/v1/payment_intents'; + my $payment_info=[ + 'payment_method'=>$pmi, + 'amount'=>$amount*100, + 'currency'=>'mxn', + 'description'=>$description, + 'payment_method_options[card][installments][enabled]'=>'true' + ]; + my $r=stripeAppi($api_create_path,$payment_info); + if ($r==0){intentError($c,"api create error",1); return;} + my $t->{intent_id}=$r->{id}; + foreach (@{$r->{payment_method_options}{card}{installments}{available_plans}}){ + push (@{$t->{available_plans}}, $_) unless ($_->{count} > $max_time); + } + $c->render(json=>$t); + return 0; +} + +sub intentConfirm{ + my $c = shift; + my $max_time = 9; + + unless (defined ($c->req->json)){ + $c->stash(layout=>'clean'); + $c->render(template=>'home/not_found', status=>404); + return; + } + + unless ($c->mproc->intentSanity($c->req->json) == 0 ){ + intentError($c,"sanity failed",0); return; } + + my $data = $c->req->json; + my $pii = $data->{'payment_intent_id'}; + my $plan = $data->{'selected_plan'} // 0; + my $api_confirm_path = "https://api.stripe.com/v1/payment_intents/$pii/confirm"; + + my $cplan = 0; + if ($plan != 0){ + if ($plan->{count} > $max_time) { + intentError($c,'max time installment attempt error',3); + return 0; + } + $cplan = [ + 'payment_method_options[card][installments][plan][type]'=>'fixed_count', + 'payment_method_options[card][installments][plan][interval]'=>'month', + 'payment_method_options[card][installments][plan][count]'=>$plan->{count}, + ] + } + + if ( + intentCheck( + $c, + $data->{'payment_intent_id'}, + $data->{'tid'}, + $data->{'mq'} + ) == -1) { + intentError($c,"api confirm error pre",2); return; + } + + my $r = stripeAppi($api_confirm_path,$cplan); + if ($r==0){intentError($c,"api confirm error post",2); return;} + 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'}, + }; + $c->render(json=>$rtt); + return 0; +} + +sub intentError{ # e: error msg, stage: 0-userinfo, 1 icreate. 2 iconfirm + my $c = shift; + $c->render(json => { 'e'=>shift, 'stage'=>shift }); + return 0; +} + +sub userCheck{ + my $c=shift; + my $r = { 'userst' => $c->mproc->userDataSanity($c->req->json)}; + $c->render(json=>$r); + return 0; +} + +sub intentCheck{ + my ($c, $cid, $tid, $mq) = @_; + my $stripe = stripeAppi("https://api.stripe.com/v1/payment_intents/$cid",0); + my $data=$c->mproc->intentCreate($tid); + return -1 unless ( $stripe->{'amount'} == ($data->{'precio'} * $mq)*100); + return 0; +} + +sub stripeAppi{ + my ($path,$data) = @_; + my $req; + if ($data == 0 ) { $req = POST $path;} # -.- + else { $req = POST $path, $data;} + $req->authorization_basic(Dojo::Conf::STRIPE_SK,''); + $req->content_type('application/x-www-form-urlencoded'); + my $ua = LWP::UserAgent->new; + my $res=$ua->request($req); + unless ($res->is_success){ + log("stripe error! path=$path\n data=".Dumper($data)."\n $res->status_line "); + return 0; + } + my $json = JSON->new->utf8; + return $json->decode($res->decoded_content); +} + +# Not used but maybe later ====================================================== + +#sub storeppl{ + #my $c=shift; + #if( defined($c->req->json) ){ + #my $oid = $c->req->json->{'orderID'} //0; + #log( $oid ); + ##credentials==== + #my $client='AQdZ1JJL-GNBgGTI3W6cXChmj6MnZsInRGlWeHw1kbGiE_49eTtZ2fPvEq9ersU2y6O5WpxccdsyAQw7'; + #my $secter='EBn8CNOCrJbVZ_fNllXB7oUIm9_vhtqrJMm2zSBGbxSyiiych3cHOIWOLAD5NVw4Z3dmNhmsHQwPsrZ0'; + #my $pauth='https://api.sandbox.paypal.com/v1/oauth2/token/'; + #my $porder='https://api.sandbox.paypal.com/v2/checkout/orders/'; + ##================= + ##pre auth ==== + #my $ua = LWP::UserAgent->new; + #my $req=POST $pauth, ["grant_type"=>"client_credentials"]; + #$req->authorization_basic($client,$secter); + #$req->content_type('application/x-www-form-urlencoded'); + #my $res=$ua->request($req); + #log("paypal pre auth error! $res->status_line") unless ($res->is_success ); + #my $json = JSON->new->utf8; + #my $r=$json->decode($res->decoded_content); + ##============== + + ##order details ==== + #my $ub = LWP::UserAgent->new; + #$ub->default_header('Content-Type'=> 'application/json' ); + #$ub->default_header('Authorization'=> 'Bearer ' . $r->{access_token} ); + #my $resb=$ub->get($porder.$oid); + #log("paypal checkout error!") unless ($resb->is_success ); + #my $jsonb = JSON->new->utf8; + #my $s=$jsonb->decode($resb->decoded_content); + ##=================== + #$c->rendered(200); #es default,nomas para enfatizar que puede ser 400 o 500 + ## interesan create time, id, payer: email address, shippng address + #} + #else{ + #my $data=$c->dbg->store_id($c->param('id')); + #$c->redirect_to('cal') if ($c->param('id')==4); + #$c->redirect_to('store') unless ($data->{'id'}); + #$c->stash($data); + #$c->stash(layout=>'default'); + #} +#} + +1; 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 100644 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 100644 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/cal/q1Block.q b/lib/Dojo/Model/Data/cal/q1Block.q index fed47e7..4472b7c 100755 --- a/lib/Dojo/Model/Data/cal/q1Block.q +++ b/lib/Dojo/Model/Data/cal/q1Block.q @@ -1,10 +1,6 @@ - select distinct - concat(mes.nombre,' ',year(evento.fecha_inicio)) as text, - date_format(evento.fecha_inicio,'%Y%m') as id - from evento - inner join mes on month(evento.fecha_inicio)=mes.id - where evento.estado=1 - order by evento.fecha_inicio - ; - + month(t.fecha_inicio) as month, + year(t.fecha_inicio) as year, + date_format(t.fecha_inicio,'%Y%m') as id +from curso_tienda as t + where estado=1 and estore = 1; diff --git a/lib/Dojo/Model/Data/cal/q3Event.q b/lib/Dojo/Model/Data/cal/q3Event.q index 38015df..bc055c1 100755 --- a/lib/Dojo/Model/Data/cal/q3Event.q +++ b/lib/Dojo/Model/Data/cal/q3Event.q @@ -1,23 +1,20 @@ select - date_format(evento.fecha_inicio,'%Y%m') as bid, - evento.id as eeid, - concat(lugar.municipio,", ",lugar.federativa) as ciudad, - concat(lugar.nombre,". ") as lugar, - lugar.direccion as dir, - case when month(evento.fecha_inicio) = month(evento.fecha_fin) - then concat("Del ", day(evento.fecha_inicio)," al ",day(evento.fecha_fin)," de ",mi.nombre) - else concat("Del ",day(evento.fecha_inicio)," de ",mi.nombre," al ", - day(evento.fecha_fin)," de ", mo.nombre) - end as fecha, - curso.nombre as nombre, - evento.imagen_chica as imagen_chica -from evento - inner join lugar on evento.lugar_id=lugar.id - inner join curso on evento.curso_id=curso.id - join mes as mi on mi.id=month(evento.fecha_inicio) - join mes as mo on mo.id=month(evento.fecha_fin) -where evento.estado=1 -order by evento.fecha_inicio + date_format(t.fecha_inicio,'%Y%m') as bid, + t.id as eeid, + concat(l.municipio,", ",l.federativa) as ciudad, + concat(l.nombre,". ") as lugar, + l.direccion as dir, + day(t.fecha_inicio) as dini, + day(t.fecha_fin) as dfin, + month(t.fecha_inicio) as mini, + month(t.fecha_fin) as mfin, + c.nombre as nombre, + t.imagen_chica as imagen_chica +from curso_tienda as t + inner join curso_lugar as l on t.lugar_id=l.id + inner join curso as c on t.curso_id=c.id +where t.estado=1 and t.estore=1 +order by t.fecha_inicio ; diff --git a/lib/Dojo/Model/Data/event/qEvent.q b/lib/Dojo/Model/Data/event/qEvent.q index 3e2e6a9..f8e3907 100755 --- a/lib/Dojo/Model/Data/event/qEvent.q +++ b/lib/Dojo/Model/Data/event/qEvent.q @@ -1,29 +1,27 @@ - + select - curso.nombre as cname, - concat(lugar.municipio,', ',lugar.federativa) as place, + c.nombre as cname, + concat(l.municipio,', ',l.federativa) as place, - lugar.direccion as paddr, - lugar.observacion as pobs, - lugar.municipio as city, - evento.precio as cost, - case evento.promo_estado when 1 then coalesce(evento.promocion,"") else "" end as promo, - curso.temario as csubjects, - curso.servicios as cservices, + l.direccion as paddr, + l.observacion as pobs, + l.municipio as city, + t.precio as cost, + t.spay as spay, + case t.promo_estado when 1 then coalesce(t.promocion,"") else "" end as promo, + c.descripcion as cdescription, + c.temario as csubjects, + c.servicios as cservices, + l.nombre as pname, + day(t.fecha_inicio) as dini, + day(t.fecha_fin) as dend, + month(t.fecha_inicio) as mini, + month(t.fecha_fin) as mend - lugar.nombre as pname, - case when month(evento.fecha_inicio) = month(evento.fecha_fin) - then concat("Del ", day(evento.fecha_inicio)," al ",day(evento.fecha_fin)," de ",mi.nombre) - else concat("Del ",day(evento.fecha_inicio)," de ",mi.nombre," al ", - day(evento.fecha_fin)," de ", mo.nombre) - end as date - - - from evento - inner join lugar on evento.lugar_id=lugar.id - inner join curso on evento.curso_id=curso.id - join mes as mi on mi.id=month(evento.fecha_inicio) - join mes as mo on mo.id=month(evento.fecha_fin) - where evento.estado=1 - and evento.id = ? +from curso_tienda as t + inner join curso_lugar as l on t.lugar_id=l.id + inner join curso as c on t.curso_id=c.id + where t.estado=1 + and t.id = ? +; diff --git a/lib/Dojo/Model/Data/spay/qIdStore.q b/lib/Dojo/Model/Data/spay/qIdStore.q new file mode 100755 index 0000000..4ca0c12 --- /dev/null +++ b/lib/Dojo/Model/Data/spay/qIdStore.q @@ -0,0 +1,30 @@ + +select + t.id as tid, + c.nombre as nombre, + c.subnombre as subnombre, + c.descripcion as descripcion, + c.maestro as maestro, + c.imagen_a as cimga, + c.imagen_b as cimgb, + c.imagen_c as cimgc, + day(t.fecha_inicio) as dini, + month(t.fecha_inicio) as mini, + day(t.fecha_fin) as dfin, + month(t.fecha_fin) as mfin, + t.precio as precio, + t.promocion as promo, + t.promo_estado as promo_estado, + t.playera_estado as playera_estado, + t.cupo as cupo, + l.nombre as lnombre, + l.federativa as federativa, + l.pais as pais, + l.municipio as municipio +from curso_tienda as t + join curso as c on c.id = t.curso_id + join curso_lugar as l on l.id = t.lugar_id + +where t.id=? and t.estado =1 +; + diff --git a/lib/Dojo/Model/Data/spay/qIntentConfirm.q b/lib/Dojo/Model/Data/spay/qIntentConfirm.q new file mode 100644 index 0000000..738fa87 --- /dev/null +++ b/lib/Dojo/Model/Data/spay/qIntentConfirm.q @@ -0,0 +1,19 @@ +insert into curso_caja + ( + cliente_nombre, + cliente_correo, + cliente_comentario, + curso_tienda_id, + talla_id, + cantidad, + monto, + etapa_id, + entrega_id, + pago_clave, + plazo, + fecha_pago + ) +values (?,?,?,?,?,?,?,?,?,?,?,now()) +; + + diff --git a/lib/Dojo/Model/Data/spay/qIntentCreate.q b/lib/Dojo/Model/Data/spay/qIntentCreate.q new file mode 100644 index 0000000..8f0c74e --- /dev/null +++ b/lib/Dojo/Model/Data/spay/qIntentCreate.q @@ -0,0 +1,10 @@ +select + t.precio as precio, + c.nombre as nombre +from + curso_tienda as t +inner join + curso as c on t.curso_id=c.id +where + t.id = ? +; 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/Data/store/qStore.q b/lib/Dojo/Model/Data/store/qStore.q deleted file mode 100755 index 1049aeb..0000000 --- a/lib/Dojo/Model/Data/store/qStore.q +++ /dev/null @@ -1,10 +0,0 @@ -select - nombre as "titulo", - descripcion as "descripcion", - precio as "precio", - opcion as "opciones", - promocion as "promocion", - imagen as "imagen" - -from tienda where precio >= -1; - diff --git a/lib/Dojo/Model/Users.pm b/lib/Dojo/Model/Users.pm index 044cb18..05d2c8c 100755 --- a/lib/Dojo/Model/Users.pm +++ b/lib/Dojo/Model/Users.pm @@ -3,10 +3,12 @@ package Dojo::Model::Users; use strict; use warnings; +use Mojo::File 'path'; use DBI; use Mojo::Util 'secure_compare'; use Dojo::Conf; +my $data_path = path('lib/Dojo/Model/Data')->make_path; sub new { bless {}, shift } sub createu{ @@ -56,6 +58,15 @@ sub check { return $r->{pid} // 0; } +sub store{ + return _read ($data_path->child("/store/qStore.q")->slurp); +} + +sub store_id{ + my ($self,$id)=@_; + return _read ($data_path->child("/store/qIdStore.q")->slurp,$id)->[0]; +} + sub _read{ my ($q,@bind)=@_; my (@empty,$arr); diff --git a/lib/Dojo/Model/Vdgproc.pm b/lib/Dojo/Model/Vdgproc.pm new file mode 100644 index 0000000..3d09c80 --- /dev/null +++ b/lib/Dojo/Model/Vdgproc.pm @@ -0,0 +1,266 @@ +package Dojo::Model::Vdgproc; use Mojo::File 'path'; +use Mojo::JSON qw(decode_json encode_json); +use Dojo::Support qw{ mtxt month_num2txt log dmph} ; +use Mojo::Base 'Mojolicious::Controller'; + +use Email::Valid; +use Data::Dumper; +use File::Basename; +use Encode qw(decode_utf8 encode_utf8); +use Text::Markdown qw{ markdown }; +use DBI; +use Dojo::Conf; + +sub new { bless {}, shift }; +my $data_path = path('lib/Dojo/Model/Data')->make_path; +#just for fun + + +# Tienda de eventos =========================================================== +sub calendar_monthblock { + my $r = _read ($data_path->child("cal/q1Block.q")->slurp); + map { $_->{fecha}=month_num2txt($_->{month})." ".$_->{year} } @$r; + return $r; +} + +sub calendar_events { + my $r = _read ($data_path->child("cal/q3Event.q")->slurp); + foreach (@$r) { $_->{fecha} = mtxt( $_->{dini},$_->{mini},$_->{dfin},$_->{mfin}) } + return $r; +} + +sub event{ + my ($c,$id)=@_; + my $r = shift @{ _read ($data_path->child("event/qEvent.q")->slurp,$id)}; + $r->{date} = mtxt( $r->{dini},$r->{mini},$r->{dend},$r->{mend}); + return $r; +} + +sub spay{ + my ($c,$class,$id) = @_; + my $r = shift @{ _read ($data_path->child("spay/qIdStore.q")->slurp,$id)}; + $r->{fecha} = mtxt( $r->{dini},$r->{mini},$r->{dfin},$r->{mfin}); + return $r; +} + +# Stripe payment process ============================================================== +# ====================== +# 4000004840000008 3, 6, 9, 12, and 18 month installment plans available +# "*p4000004840000008 +# 4242424242424242 No installment plans available. +# ====================== + +sub intentCreate{ + my ($c,$id) = @_; + return _read ($data_path->child("spay/qIntentCreate.q")->slurp,$id)->[0]; +} + + +sub intentConfirm{ + my ($c,$data,$r) = @_; + # cliente_nombre,cliente_correo,cliente_comentario,tienda_evento_id,talla_id,cantidad(1),monto,etapa_id(4),entrega(3),pago_clave,plazo,fecha_pago + my $mq = $data->{'mq'}; + my $students = $data->{'students'}; + my $plan = 0; + if (defined $data->{'selected_plan'}){ + $plan = $data->{'selected_plan'}->{'count'}; + } + for (1..$mq){ + _write ( + $data_path->child("/spay/qIntentConfirm.q")->slurp, + $$students[$_ -1][0], + $$students[$_ -1][1], + $$students[$_ -1][2], + $data->{'tid'}, + $$students[$_ -1][3], + $data->{'mq'}, + $r->{'amount'}, + 4, + 3, + $r->{'id'}, + $plan + ); + } # falta plazo + 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: + # =============== + #'selected_plan' => { 'type' => 'fixed_count', 'count' => 6, 'interval' => 'month' }, + #'mq' => '2', # cantidad de alumnas + #'req' => 'check', + #'payment_intent_id' => 'pi_1G1luSFBHoXN2vhnkl3PIiL1', + #'tid' => 80, #tienda id + #'students' => [ [ 'User', 'me@me.com', 'obs', 'M' ], [ 'usr2', 'mail2', 'obs', 'G' ], undef, undef, undef, undef, undef, undef, undef, undef ] #arr(10) +# =============== + +sub intentSanity{ + my ($c,$d)=@_; + if (defined $d->{'selected_plan'} ){ + return -1 unless defined ($d->{'selected_plan'}{'type'}); + return -1 unless defined ($d->{'selected_plan'}{'count'}); + return -1 unless defined ($d->{'selected_plan'}{'interval'}); + } + return -1 unless defined ($d->{'tid'}) && $d->{'tid'} =~ /^\d+$/ ; + return -1 unless defined ($d->{'req'}) && $d->{'req'} eq 'check'; + return -1 unless defined ($d->{'payment_intent_id'}); + return userDataSanity($c,$d) ; +} + +sub userDataSanity{ + my ($c,$d) = @_; + return -1 unless ( + defined ($d->{'students'}) && # (nombre,mail,observaciones, talla) + defined ($d->{'mq'}) && + $d->{'mq'} =~/^\d+$/ && + $d->{'mq'} < 10 + ); + my %h=qw(n 0 CH 1 M 2 G 3); + my $mq = $d->{'mq'}; + my $students = $d->{'students'}; + for (1..$mq){ + return $_ unless defined( $$students[$_ -1][0] ); + return $_ unless defined( $$students[$_ -1][1] ) && + is_mail($$students[$_ -1][1] ); + $$students[$_ -1][3] = $h{$$students[$_ -1][3] // 'n'}; + } + return 0; +} + +sub is_mail{ + return Email::Valid->address(shift); +} + +#============================================================================== + +# admin evets +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 curso_lugar where id = ?;",pop); } + +sub event_up{ + my ($self,@bind)=@_; + return _write($data_path->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); +} + +#============================================================================== +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 ===================================== + +sub _read{ + my ($q,@bind)=@_; + my @empty; + my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::VDGPROCDB.":".Dojo::Conf::VDGPROCDB_H,Dojo::Conf::VDGPROCDB_UR,Dojo::Conf::VDGPROCDB_URP, {mysql_enable_utf8 => 1}); + return \@empty unless($dbh); + my $h=$dbh->selectall_arrayref($q,{ Slice => {} },@bind)//"error"; + $dbh->disconnect(); + #((col1=>d1,col2=>d1),(col1=>d2,col2=>d2)) + return $h; +} + +sub _write{ + my ($q,@bind)=@_; + my (@empty); + my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::VDGPROCDB.":".Dojo::Conf::VDGPROCDB_H,Dojo::Conf::VDGPROCDB_UW,Dojo::Conf::VDGPROCDB_UWP,{mysql_enable_utf8 => 1} ); + return 0 unless($dbh); + my $h=$dbh->do($q,{ Slice => {} },@bind)//"error"; + $dbh->disconnect(); + log("db write: $h"); + return $h; +} + +sub load_md{ + return "" unless + my $text = path(shift)->slurp; + return markdown( decode_utf8($text) ); +} + +sub load_txt{ + return "" unless + my $text = path(shift)->slurp; + return decode_utf8($text); +} + +1; + diff --git a/lib/Dojo/Model/Vuelo.pm b/lib/Dojo/Model/Vuelo.pm index 031f974..df2513a 100755 --- a/lib/Dojo/Model/Vuelo.pm +++ b/lib/Dojo/Model/Vuelo.pm @@ -30,20 +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 store{ - return _read ($data_path->child("/store/qStore.q")->slurp); -} sub tv_videos{ return _read ($data_path->child("/tv/qSeries.q")->slurp); #group,name } @@ -60,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 ============================================================== @@ -119,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 63001f3..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/ 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; @@ -17,6 +17,12 @@ sub log{ my $log = Mojo::Log->new; $log->debug("============ ".shift." ==========="); } + +sub _log{ + my $log = Mojo::Log->new; + $log->debug("============ ".shift." ==========="); +} + sub get_names{ my $dir = shift; my @file_name; @@ -36,8 +42,36 @@ sub merge_hash{ my $merger = Hash::Merge->new('LEFT_PRECEDENT'); foreach (@_){ $h= $merger->merge($h,$_); - } - return $h; + } + return $h; +} + +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; + if ($mi == $mf){ + if ($di == $df){ $txt = "$di de ".month_num2txt($mi);} + else{ $txt = "Del $di al $df de ".month_num2txt($mi);} + } + else{ + $txt = "Del $di de ".month_num2txt($mi)." al $df de ".month_num2txt($mf); + } + return $txt; +} + +#put comas on price numbers +sub commify { + my $text = reverse $_[0]; + $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; + return scalar reverse $text; } sub load_module{ @@ -64,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/home/admin/admin.css b/public/admin/admin.css similarity index 100% rename from public/home/admin/admin.css rename to public/admin/admin.css diff --git a/public/home/admin/candySwitch/cSwitch.js b/public/admin/candySwitch/cSwitch.js similarity index 100% rename from public/home/admin/candySwitch/cSwitch.js rename to public/admin/candySwitch/cSwitch.js diff --git a/public/home/admin/candySwitch/main.css b/public/admin/candySwitch/main.css similarity index 100% rename from public/home/admin/candySwitch/main.css rename to public/admin/candySwitch/main.css diff --git a/public/home/admin/candySwitch/switch.css b/public/admin/candySwitch/switch.css similarity index 100% rename from public/home/admin/candySwitch/switch.css rename to public/admin/candySwitch/switch.css diff --git a/public/home/admin/event/event.css b/public/admin/event/event.css similarity index 99% rename from public/home/admin/event/event.css rename to public/admin/event/event.css index 31c45ca..240eac3 100755 --- a/public/home/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/home/admin/event/event.js b/public/admin/event/event.js similarity index 85% rename from public/home/admin/event/event.js rename to public/admin/event/event.js index 2792d68..ed05735 100755 --- a/public/home/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/public/home/admin/home/admin.css b/public/admin/home/admin.css similarity index 100% rename from public/home/admin/home/admin.css rename to public/admin/home/admin.css diff --git a/public/home/admin/home/buttons.js b/public/admin/home/buttons.js similarity index 100% rename from public/home/admin/home/buttons.js rename to public/admin/home/buttons.js diff --git a/public/home/admin/home/fb.js b/public/admin/home/fb.js similarity index 100% rename from public/home/admin/home/fb.js rename to public/admin/home/fb.js diff --git a/public/home/admin/mensajes/msg.css b/public/admin/mensajes/msg.css similarity index 100% rename from public/home/admin/mensajes/msg.css rename to public/admin/mensajes/msg.css diff --git a/public/home/admin/mensajes/msg.js b/public/admin/mensajes/msg.js similarity index 100% rename from public/home/admin/mensajes/msg.js rename to public/admin/mensajes/msg.js diff --git a/public/home/admin/radio/admin.css b/public/admin/radio/admin.css similarity index 100% rename from public/home/admin/radio/admin.css rename to public/admin/radio/admin.css diff --git a/public/home/admin/radio/loadInfo.js b/public/admin/radio/loadInfo.js similarity index 100% rename from public/home/admin/radio/loadInfo.js rename to public/admin/radio/loadInfo.js diff --git a/public/home/admin/tienda/tienda.css b/public/admin/tienda/tienda.css similarity index 100% rename from public/home/admin/tienda/tienda.css rename to public/admin/tienda/tienda.css diff --git a/public/home/admin/tienda/tienda.js b/public/admin/tienda/tienda.js similarity index 100% rename from public/home/admin/tienda/tienda.js rename to public/admin/tienda/tienda.js diff --git a/public/global/error/404.css b/public/global/error/404.css old mode 100644 new mode 100755 diff --git a/public/global/error/hono.jpg b/public/global/error/hono.jpg old mode 100644 new mode 100755 diff --git a/public/home/event/event.css b/public/home/event/event.css deleted file mode 100755 index 6b9c5a4..0000000 --- a/public/home/event/event.css +++ /dev/null @@ -1,94 +0,0 @@ -section.item{ - background-size:cover; - height:80vh; - background-attachment: fixed; - margin: auto; - background-image:url("img/grulla_10.jpg"); - background-position:center; -} -section.place{ - background: #C22A39; - padding:40px; -} -p.place{ - font-size: 1.5em; - color: white; - text-align: center; -} -p.cname{ - font-size: 1.7em; - color: white; - text-align: center; - margin: 7px; -} -section.description{ - background-color:white; - justify-content: center; - -webkit-justify-content: center; -} -article.info{ - flex:1 1 250px; - max-width:370px; - margin:auto; - min-width:250px; - padding-left:20px; -} -p.pbig{ - font-weight:bold; - font-size:1.8em; - } -p.pmed{ - font-size:1.1em; - } - -article.specs{ - flex:2 2 250px; - margin:auto; - max-width:420px; -} -p#subt{ -margin: 10px; -color: black; -font-size: 1.2em; -} - -article.specs >p{ -margin-bottom: 30px; -color: black; -font-size: .875rem; -font-weight: 400; -line-height: 1.5; -min-width:250px; -} - -p.promo{ -margin: 10px; -color: #c22a39; -font-size: 1.2em; -} - -section.map{ -background-color:#333333; -overflow:hidden; - height:80vh; - min-height:400px; - position:relative; -} - -section.map > iframe{ - width:70%; - height:70%; - top:15%; - left:15%; - overflow: hidden; - position:absolute; -} -p.arrive{ - position:absolute; - left:10%; - top:1%; - font-size:1.5em; - color:white; - } -article.contact{ - } diff --git a/public/home/store/shop.css b/public/home/store/shop.css deleted file mode 100755 index bb91fd8..0000000 --- a/public/home/store/shop.css +++ /dev/null @@ -1,52 +0,0 @@ -article.heading{ - width:100%; - height:55vh; - min-height:350px; - display: inline-block; - background-color: #333333; - text-align: center; - margin-top: 50px; - - -} -p.heading{ - font-size:5em; - color:white; - color: white; - margin: 20vh auto auto auto; -} -article.shop{ - justify-content:center; - -webkit-justify-content:center; - margin-top: 40px; -} -div.simage{ - flex:3; - max-width:350px; - transition: .5s ease; -} -div.simage:hover{ - transform:scale(1.2,1.2); -} -div.simage > img{ - max-width:70%; - max-height:100%; - margin:auto; - display:block; -} -div.description{ - flex:2; - max-width:250px; -} -p.description{ font-size:0.8em; } -p.title{font-weight:bold;} -p.promo{font-weight:bold; color:#C22A39;} -article.separator{ - background-repeat: no-repeat; - background-image: url(" #path img/separa.jpg"); - height: 20px; - background-size: contain; - background-position: center; - margin-top:30px; -} - diff --git a/public/home/cal/cal.css b/public/proc/cal/cal.css similarity index 100% rename from public/home/cal/cal.css rename to public/proc/cal/cal.css diff --git a/public/home/cal/img/Argentina.jpg b/public/proc/cal/img/Argentina.jpg similarity index 100% rename from public/home/cal/img/Argentina.jpg rename to public/proc/cal/img/Argentina.jpg diff --git a/public/home/cal/img/CDMX.jpg b/public/proc/cal/img/CDMX.jpg similarity index 100% rename from public/home/cal/img/CDMX.jpg rename to public/proc/cal/img/CDMX.jpg diff --git a/public/home/cal/img/Cancun.jpg b/public/proc/cal/img/Cancun.jpg similarity index 100% rename from public/home/cal/img/Cancun.jpg rename to public/proc/cal/img/Cancun.jpg diff --git a/public/home/cal/img/Carmen.jpg b/public/proc/cal/img/Carmen.jpg similarity index 100% rename from public/home/cal/img/Carmen.jpg rename to public/proc/cal/img/Carmen.jpg diff --git a/public/home/cal/img/Chile.jpg b/public/proc/cal/img/Chile.jpg similarity index 100% rename from public/home/cal/img/Chile.jpg rename to public/proc/cal/img/Chile.jpg diff --git a/public/home/cal/img/China.jpg b/public/proc/cal/img/China.jpg similarity index 100% rename from public/home/cal/img/China.jpg rename to public/proc/cal/img/China.jpg diff --git a/public/home/cal/img/Cuba.jpg b/public/proc/cal/img/Cuba.jpg similarity index 100% rename from public/home/cal/img/Cuba.jpg rename to public/proc/cal/img/Cuba.jpg diff --git a/public/home/cal/img/Ensenada.jpg b/public/proc/cal/img/Ensenada.jpg similarity index 100% rename from public/home/cal/img/Ensenada.jpg rename to public/proc/cal/img/Ensenada.jpg diff --git a/public/home/cal/img/Guadalajara.jpg b/public/proc/cal/img/Guadalajara.jpg similarity index 100% rename from public/home/cal/img/Guadalajara.jpg rename to public/proc/cal/img/Guadalajara.jpg diff --git a/public/home/cal/img/Hidalgo.jpg b/public/proc/cal/img/Hidalgo.jpg similarity index 100% rename from public/home/cal/img/Hidalgo.jpg rename to public/proc/cal/img/Hidalgo.jpg diff --git a/public/home/cal/img/Leon.jpg b/public/proc/cal/img/Leon.jpg similarity index 100% rename from public/home/cal/img/Leon.jpg rename to public/proc/cal/img/Leon.jpg diff --git a/public/home/cal/img/Merida.jpg b/public/proc/cal/img/Merida.jpg similarity index 100% rename from public/home/cal/img/Merida.jpg rename to public/proc/cal/img/Merida.jpg diff --git a/public/home/cal/img/Mexicali.jpg b/public/proc/cal/img/Mexicali.jpg similarity index 100% rename from public/home/cal/img/Mexicali.jpg rename to public/proc/cal/img/Mexicali.jpg diff --git a/public/home/cal/img/Monterrey.jpg b/public/proc/cal/img/Monterrey.jpg similarity index 100% rename from public/home/cal/img/Monterrey.jpg rename to public/proc/cal/img/Monterrey.jpg diff --git a/public/home/cal/img/Oaxaca.jpg b/public/proc/cal/img/Oaxaca.jpg similarity index 100% rename from public/home/cal/img/Oaxaca.jpg rename to public/proc/cal/img/Oaxaca.jpg diff --git a/public/home/cal/img/Puebla.jpg b/public/proc/cal/img/Puebla.jpg similarity index 100% rename from public/home/cal/img/Puebla.jpg rename to public/proc/cal/img/Puebla.jpg diff --git a/public/home/cal/img/Queretaro.jpg b/public/proc/cal/img/Queretaro.jpg similarity index 100% rename from public/home/cal/img/Queretaro.jpg rename to public/proc/cal/img/Queretaro.jpg diff --git a/public/home/cal/img/Tepoztlan.jpg b/public/proc/cal/img/Tepoztlan.jpg similarity index 100% rename from public/home/cal/img/Tepoztlan.jpg rename to public/proc/cal/img/Tepoztlan.jpg diff --git a/public/home/cal/img/Veracruz.jpg b/public/proc/cal/img/Veracruz.jpg similarity index 100% rename from public/home/cal/img/Veracruz.jpg rename to public/proc/cal/img/Veracruz.jpg diff --git a/public/home/cal/img/Xalapa.jpg b/public/proc/cal/img/Xalapa.jpg similarity index 100% rename from public/home/cal/img/Xalapa.jpg rename to public/proc/cal/img/Xalapa.jpg diff --git a/public/home/cal/img/Xalpan.jpg b/public/proc/cal/img/Xalpan.jpg similarity index 100% rename from public/home/cal/img/Xalpan.jpg rename to public/proc/cal/img/Xalpan.jpg diff --git a/public/proc/event/event.css b/public/proc/event/event.css new file mode 100755 index 0000000..b3ae55f --- /dev/null +++ b/public/proc/event/event.css @@ -0,0 +1,127 @@ +section.item{ + background-size:cover; + height:80vh; + background-attachment: fixed; + margin: auto; + background-image:url("img/grulla_10.jpg"); + background-position:center; +} +section.place{ + background: #C22A39; + padding:40px; +} +p.place{ + font-size: 1.5em; + color: white; + text-align: center; +} + +p.cname{ + font-size: 1.7em; + color: white; + text-align: center; + margin: 7px; +} +a.bt3{ +display:block; +padding:0.7em 1.7em; +margin: 4em 20vw 2px; +border-radius:0.2em; +font-family:'Roboto',sans-serif; +color:#FFFFFF; +background-color:#333333; +box-shadow:inset 0 -0.6em 1em -0.35em rgba(0,0,0,0.17),inset 0 0.6em 2em -0.3em rgba(255,255,255,0.15),inset 0 0 0em 0.05em rgba(255,255,255,0.12); +text-align:center; +} +a.bt3:active{ +box-shadow:inset 0 0.6em 2em -0.3em rgba(0,0,0,0.15),inset 0 0 0em 0.05em rgba(255,255,255,0.12); +} +@media all and (max-width:30em){ +a.bt3{ +display:block; +margin:0.4em auto; +}} +span.bt3{ +font-size:3em; + font-family:'Comic Sans MS'; + border-right:1px solid rgba(255,255,255,0.5); + padding-right:0.3em; + margin-right:0.3em; + vertical-align:middle; +} +/*===========================*/ +section.description{ + background-color:white; + justify-content: center; + -webkit-justify-content: center; +} + +article.info{ + flex:1 1 250px; + max-width:370px; + margin:auto; + min-width:250px; + padding-left:20px; +} + +p.pbig{ + font-weight:bold; + font-size:1.8em; +} + +p.pmed{ + font-size:1.1em; +} + +article.specs{ + flex:2 2 250px; + margin:auto; + max-width:420px; +} + +p#subt{ + margin: 10px; + color: black; + font-size: 1.2em; +} + +article.specs >p{ + margin-bottom: 30px; + color: black; + font-size: .875rem; + font-weight: 400; + line-height: 1.5; + min-width:250px; +} + +p.promo{ + margin: 10px; + color: #c22a39; + font-size: 1.2em; +} + +section.map{ + background-color:#333333; + overflow:hidden; + height:80vh; + min-height:400px; + position:relative; +} + +section.map > iframe{ + width:70%; + height:70%; + top:15%; + left:15%; + overflow: hidden; + position:absolute; +} +p.arrive{ + position:absolute; + left:10%; + top:1%; + font-size:1.5em; + color:white; +} +article.contact{ +} diff --git a/public/home/event/img/grulla_10.jpg b/public/proc/event/img/grulla_10.jpg similarity index 100% rename from public/home/event/img/grulla_10.jpg rename to public/proc/event/img/grulla_10.jpg diff --git a/public/proc/spay/grulla_10.jpg b/public/proc/spay/grulla_10.jpg new file mode 100755 index 0000000..5e7a690 Binary files /dev/null and b/public/proc/spay/grulla_10.jpg differ diff --git a/public/proc/spay/img/China.jpg b/public/proc/spay/img/China.jpg new file mode 100755 index 0000000..870d653 Binary files /dev/null and b/public/proc/spay/img/China.jpg differ diff --git a/public/home/store/img/libreta.jpg b/public/proc/spay/img/libreta.jpg similarity index 100% rename from public/home/store/img/libreta.jpg rename to public/proc/spay/img/libreta.jpg diff --git a/public/home/store/img/libro.jpg b/public/proc/spay/img/libro.jpg old mode 100644 new mode 100755 similarity index 100% rename from public/home/store/img/libro.jpg rename to public/proc/spay/img/libro.jpg diff --git a/public/home/store/img/libro_old.jpg b/public/proc/spay/img/libro_old.jpg similarity index 100% rename from public/home/store/img/libro_old.jpg rename to public/proc/spay/img/libro_old.jpg diff --git a/public/home/store/img/mapa.jpg b/public/proc/spay/img/mapa.jpg similarity index 100% rename from public/home/store/img/mapa.jpg rename to public/proc/spay/img/mapa.jpg diff --git a/public/home/store/img/momo.jpg b/public/proc/spay/img/momo.jpg similarity index 100% rename from public/home/store/img/momo.jpg rename to public/proc/spay/img/momo.jpg diff --git a/public/home/store/img/playera.jpg b/public/proc/spay/img/playera.jpg similarity index 100% rename from public/home/store/img/playera.jpg rename to public/proc/spay/img/playera.jpg diff --git a/public/home/store/img/separa.jpg b/public/proc/spay/img/separa.jpg similarity index 100% rename from public/home/store/img/separa.jpg rename to public/proc/spay/img/separa.jpg diff --git a/public/proc/spay/storep.css b/public/proc/spay/storep.css new file mode 100755 index 0000000..1bcf01a --- /dev/null +++ b/public/proc/spay/storep.css @@ -0,0 +1,201 @@ + +section.item{ + background-color:rgba(255,255,255); + max-width: 1000px; + margin: auto; +} + +article.iimage{ + flex:5 1; + margin:auto; + display:inline; + padding:0px 5px; + +} +img.small{ + border-radius:20px; + display:block; + width:auto; + height:100%; + margin:auto; + padding:15px; +} +article.iinfo{ + background-color:white; + flex:4 1; + margin:0px 10px; +} +p.txt{ + font-size:1.2em; +} + +section.ibottom{ + background: #C22A39; + padding-bottom:1px; + padding-bottom:1px; + +} + +section.description{ + background-color:white; + justify-content: center; + -webkit-justify-content: center; +} + +p.promo{ + color: #c22a39; + font-size: 1.4em; + text-align:right; + margin-right:10%; + font-weight:bold; +} + + +p.elow{ + color: black; + font-size: 1.4em; + text-align:right; + margin-right:10%; +} + +p.eldep{ + color: #c22a39; + font-size: 1.4em; + text-align:right; + text-transform: uppercase; + margin-right:10%; + font-weight:bold; +} + +div.ppl{ + background-color: rgba(0,0,0,0.8); + border-radius: 25px; + padding:20px; + text-align: center; +} +p.nombre{ + font-size: 2.2em; + color: white; + text-align: left; + margin: auto; + max-width:850px; + font-weight:bold; +} + +p.tit{ + font-size: 1.8em; + color: white; + text-align: center; + margin: 30px auto; + font-style: italic; +} + +p.total{ + font-weight: bold; + font-size: 1.2em; + text-align: end; +} + +div#cover{ + background: black; + z-index: 100; + position: fixed; + width: 100%; + height: 100%; + transition:opacity .4s linear; + top:0px; + opacity:0; +} + /* * form css based on */ + /* * https://www.sanwebe.com/2014/08/css-html-forms-designs*/ + /* * thaks for make my life a bit easier*/ + /* ***************************************************************/ + +.form-style-1 { + margin:10px auto; + max-width: 400px; + padding: 20px 12px 10px 20px; + font: 13px "Lucida Sans Unicode", "Lucida Grande", sans-serif; +} +.form-style-1 li { + padding: 0; + display: block; + list-style: none; + margin: 10px 0 0 0; +} +.form-style-1 label{ + margin:0 0 3px 0; + padding:0px; + display:block; + font-weight: bold; +} +.form-style-1 input[type=text], +.form-style-1 input[type=date], +.form-style-1 input[type=datetime], +.form-style-1 input[type=number], +.form-style-1 input[type=search], +.form-style-1 input[type=time], +.form-style-1 input[type=url], +.form-style-1 input[type=email], +textarea, +select{ + box-sizing: border-box; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + border:1px solid #BEBEBE; + padding: 7px; + margin:0px; + -webkit-transition: all 0.30s ease-in-out; + -moz-transition: all 0.30s ease-in-out; + -ms-transition: all 0.30s ease-in-out; + -o-transition: all 0.30s ease-in-out; + outline: none; +} +.form-style-1 input[type=text]:focus, +.form-style-1 input[type=date]:focus, +.form-style-1 input[type=datetime]:focus, +.form-style-1 input[type=number]:focus, +.form-style-1 input[type=search]:focus, +.form-style-1 input[type=time]:focus, +.form-style-1 input[type=url]:focus, +.form-style-1 input[type=email]:focus, +.form-style-1 textarea:focus, +.form-style-1 select:focus{ + -moz-box-shadow: 0 0 8px #88D5E9; + -webkit-box-shadow: 0 0 8px #88D5E9; + box-shadow: 0 0 8px #88D5E9; + border: 1px solid #88D5E9; +} +.form-style-1 .field-divided{ + width: 49%; +} +.form-style-1 .field-mini{ + width: 5em; +} +.form-style-1 .field-long{ + width: 100%; +} +.form-style-1 .field-select{ + width: 100%; +} +.form-style-1 .field-textarea{ + height: 100px; +} + +.fbutton, +.form-style-1 input[type=submit], .form-style-1 input[type=button]{ + background: #4B99AD; + padding: 8px 15px 8px 15px; + border: none; + color: #fff; +} +.form-style-1 input[type=submit]:hover, .form-style-1 input[type=button]:hover{ + background: #4691A4; + box-shadow:none; + -moz-box-shadow:none; + -webkit-box-shadow:none; +} +.form-style-1 .required{ + color:red; +} + diff --git a/public/proc/spay/stripe.js b/public/proc/spay/stripe.js new file mode 100644 index 0000000..7a5beb2 --- /dev/null +++ b/public/proc/spay/stripe.js @@ -0,0 +1,242 @@ +/* some format to numbers */ +var it=1; +var students = new Array(10); + +/* price format (comas) */ +window.addEventListener('load', function() { + document.getElementById('cu').innerHTML=cu.toLocaleString(); + document.getElementById('gt').innerHTML=cu.toLocaleString(); +}); + +var mq = document.forms["cform"]["mq"]; +mq.addEventListener('change',function() { + var mult = cu*mq.value; + document.getElementById('gt').innerHTML=mult.toLocaleString(); +}); +/* ====================== */ + +/* vars to hide contact form, show card info fields */ +var cinfob = document.getElementById('cinfob'); +var cinfo = document.getElementById('cinfo'); +var cform = document.getElementById('cform'); +var ccard = document.getElementById('ccard'); +/* ====================== */ + +/* back button ========== */ +cinfob.addEventListener('click', function(ev){ + it --; + atof(); + if (it==1){cinfob.hidden=true;} + +}); +/* ====================== */ + +/* fwd button============ */ +cinfo.addEventListener('click', function(ev){ + if ( + (document.forms["cform"]["mname"].value =="") || + (document.forms["cform"]["mmail"].value =="") + ){console.log("form incomplete");} + else if ( mq.value > it) { + students[it - 1]=ftoa(); + it ++; + if(typeof students[it - 1]!== "undefined"){ atof(); } + cinfob.hidden=false; + } + else { + students[it - 1]=ftoa(); + document.getElementById('cover').hidden = false; + document.getElementById("cover").style.opacity = "0.8"; + fetch('/spay/userCheck', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ students:students, req:"precheck", mq:mq.value}) + + }) + .then((response) => response.json()) + .then((data) => { + if(data.userst == "0"){ + cform.hidden = true; + ccard.hidden = false; + } + else{ alert("hay un error en los datos de alumnos"); } + }) + .catch((error) => { + console.error('Error:', error); + }); + + document.getElementById("cover").style.opacity = "0"; + setTimeout(function(){ document.getElementById('cover').hidden = true;},500); + } +}); + +/* ====================== */ + +/* save form to array=== */ +function ftoa(){ + var rad; + if (document.getElementById('r2').checked) { rad = document.getElementById('r2').value; } + else if(document.getElementById('r1').checked) { rad = document.getElementById('r1').value; } + else { rad = document.getElementById('r3').value; } + + var x= [ + document.forms["cform"]["mname"].value, + document.forms["cform"]["mmail"].value, + document.getElementById('obs').value, + rad + ] + var tmp=mq.value; + document.getElementById("cform").reset(); + mq.value=tmp; + + return x; +} +/* ====================== */ + +/* load form from array=== */ +function atof(){ + document.forms["cform"]["mname"].value = students[it-1][0]; + document.forms["cform"]["mmail"].value = students[it-1][1]; + document.getElementById('obs').value = students[it-1][2]; + if(document.getElementById('r2').value == students[it-1][3]){ document.getElementById('r2').checked=true;} + if(document.getElementById('r1').value == students[it-1][3]){ document.getElementById('r1').checked=true;} + if(document.getElementById('r3').value == students[it-1][3]){ document.getElementById('r3').checked=true;} +} +/* ====================== */ + +/* stripe magic begins here */ +/* ====================================================== */ +var stripe = Stripe('pk_test_wxFt0GhsUK2YsprkLXa2iFrQ00nfjAeucu'); +var elements = stripe.elements(); +var cardElement = elements.create('card', { + style: { + base: { + //iconColor: '#c4f0ff', + iconColor: '#64a0af', + color: '#000000', + fontWeight: 500, + fontFamily: 'Roboto, Open Sans, Segoe UI, sans-serif', + fontSize: '18px', + fontSmoothing: 'antialiased', + ':-webkit-autofill': { + color: '#fce883', + }, + '::placeholder': { + // color: '#87BBFD', + color: '#87BBFD', + }, + }, + invalid: { + iconColor: '#8f577e', + color: '#8F577E', + }, + }, +}); + +cardElement.mount('#card-element'); + +var cardholderName = document.getElementById('cardholder-name'); +var cardButton = document.getElementById('card-button'); + +///*y este el codigo de validación de la tarjeta*/ +cardButton.addEventListener('click', function(ev) { + document.getElementById('cover').hidden = false; + document.getElementById("cover").style.opacity = "0.8"; + stripe.createPaymentMethod('card', cardElement, { + billing_details: {name: cardholderName.value} + }) + .then(function(result) { + // Show error in payment form + if (result.error) { + document.getElementById("cover").style.opacity = "0"; + setTimeout(function(){ document.getElementById('cover').hidden = true;},500); + console.log("network error"); + } + // Otherwise send paymentMethod.id to your server (see Step 2) + else { + fetch('/spay/intentCreate', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ payment_method_id: result.paymentMethod.id, req:"precheck", mq:mq.value, tid:tid}) + }) + .then(function(result) { + // Handle server response (see Step 3) + result.json().then(function(json) { handleInstallmentPlans(json); }) + }); + } + }); +}); + +///*presenta los planes de pago */ +const selectPlanForm = document.getElementById('installment-plan-form'); +let availablePlans = []; + +const handleInstallmentPlans = async (response) => { + if (response.error) { // Show error from server on payment form + console.log("preauth response error"); + } + else { + // si avaliable plans es indefinido, se queda alli con el cover + // Store the payment intent ID. + document.getElementById('payment-intent-id').value = response.intent_id; + availablePlans = response.available_plans; + // Show available installment options + availablePlans.forEach((plan, idx) => { + const newInput = document.getElementById('immediate-plan').cloneNode(); + newInput.setAttribute('value', idx); + newInput.setAttribute('id', ''); + const label = document.createElement('label'); + label.appendChild(newInput); + label.appendChild( + document.createTextNode(`${plan.count} meses`), + ); + selectPlanForm.appendChild(label); + }); + document.getElementById('ccard').hidden = true; + document.getElementById('cplan').hidden = false; + } + document.getElementById("cover").style.opacity = "0"; + setTimeout(function(){ document.getElementById('cover').hidden = true;},500); +}; + +// termina la transacción +const confirmButton = document.getElementById('confirm-button'); +confirmButton.addEventListener('click', async (ev) => { + document.getElementById('cover').hidden = false; + document.getElementById("cover").style.opacity = "0.8"; + const selectedPlanIdx = selectPlanForm.installment_plan.value; + const selectedPlan = availablePlans[selectedPlanIdx]; + const intentId = document.getElementById('payment-intent-id').value; + const response = await fetch('/spay/intentConfirm', { + method: 'POST', + headers: {'Content-Type': 'application/json'}, + body: JSON.stringify({ + payment_intent_id: intentId, + selected_plan: selectedPlan, + req:"check", + students:students, + mq:mq.value, + tid:tid + }), + }); + const responseJson = await response.json(); + // Show success / error response. + document.getElementById("cover").style.opacity = "0"; + setTimeout(function(){ document.getElementById('cover').hidden = true;},500); + document.getElementById('cmsg').hidden = false; + document.getElementById('cplan').hidden = true; + var message; + if (responseJson.status === "succeeded" && selectedPlan !== undefined) { + message = `¡Tu compra a ${ + selectedPlan.count + } meses sin intereses se ha realizado con éxito! `; + } else if (responseJson.status === "succeeded") { + message = "¡Tu compra se ha realizado con éxito!"; + } else { + message = `Tenemos un problema para verificar tus datos. + Por favor intenta de nuevo o comunícate con nosotros`; + } + + document.getElementById("status-message").innerText = message; +}); + diff --git a/templates/home/admin/candySwitch.html.ep b/templates/admin/candySwitch.html.ep similarity index 100% rename from templates/home/admin/candySwitch.html.ep rename to templates/admin/candySwitch.html.ep diff --git a/templates/admin/event.html.ep b/templates/admin/event.html.ep new file mode 100755 index 0000000..17d7701 --- /dev/null +++ b/templates/admin/event.html.ep @@ -0,0 +1,200 @@ +% stash css=>["/admin/admin.css","/admin/event/event.css"]; +% stash js=>["/admin/event/event.js"]; +
+
+

Editar Eventos

+
+
+ +
+ +
+
    +
  • Evento
  • +
  • Curso
  • +
  • Lugar
  • +
+
+ +
+ +
+
+
+ + +
+
+ + +
+
+ + + + +
+
+ + + + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+ + +
+ + +
+
+ + + + +
+
+
+ +
+
+
+ + +
+ + +
+ + +
+ + +
+ + +
+
+
+ + +
+ + +
+ + +
+ + + + +
+
+
+ +
+
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + +
+ + + + +
+
+
+
+
+ +
diff --git a/templates/home/admin/home.html.ep b/templates/admin/home.html.ep similarity index 93% rename from templates/home/admin/home.html.ep rename to templates/admin/home.html.ep index b391c33..833e1b5 100755 --- a/templates/home/admin/home.html.ep +++ b/templates/admin/home.html.ep @@ -1,5 +1,5 @@ -% stash css=>["/home/admin/admin.css","/home/admin/home/admin.css"]; -% stash js=>["/home/admin/home/buttons.js","/home/admin/home/fb.js"]; +% stash css=>["/admin/admin.css","/admin/home/admin.css"]; +% stash js=>["/admin/home/buttons.js","/admin/home/fb.js"];

Editar Casa

diff --git a/templates/home/admin/mensajes.html.ep b/templates/admin/mensajes.html.ep similarity index 80% rename from templates/home/admin/mensajes.html.ep rename to templates/admin/mensajes.html.ep index e1c6659..78e790d 100755 --- a/templates/home/admin/mensajes.html.ep +++ b/templates/admin/mensajes.html.ep @@ -1,5 +1,5 @@ -% stash css=>["/home/admin/admin.css","/home/admin/mensajes/msg.css"]; -% stash js=>["/home/admin/mensajes/msg.js"]; +% stash css=>["/admin/admin.css","/admin/mensajes/msg.css"]; +% stash js=>["/admin/mensajes/msg.js"];
diff --git a/templates/home/admin/event.html.ep b/templates/home/admin/event.html.ep deleted file mode 100755 index b5c2d0b..0000000 --- a/templates/home/admin/event.html.ep +++ /dev/null @@ -1,148 +0,0 @@ -% stash css=>["/home/admin/admin.css","/home/admin/event/event.css"]; -% stash js=>["/home/admin/event/event.js"]; -
-

Editar Eventos

-
- -
-
-
    -
  • Evento
  • -
  • Curso
  • -
  • Lugar
  • -
-
- -
- -
-
- - -
-
- - -
-
- - - - -
-
- - - - -
-
- -
-
- - -
-
- - -
-
-
- - -
-
- - - - -
-
- -
-
- - -
- - -
- - -
- - -
- - - - -
-
- -
-
- -
- -
- -
- -
- -
- -
- -
- -
- - -
- - - - -
-
-
-
diff --git a/templates/home/htmlNav.html.ep b/templates/home/htmlNav.html.ep index c2103e2..8e9b2a6 100755 --- a/templates/home/htmlNav.html.ep +++ b/templates/home/htmlNav.html.ep @@ -14,7 +14,7 @@

Vuelo de Grulla TV

Programas Grabados

Contacto

-

Tienda Virtual

+

Nuestra Escuela

@@ -37,7 +37,7 @@

Vuelo de Grulla TV

Programas Grabados

Contacto

-

Tienda Virtual

+

Nuestra Escuela

diff --git a/templates/home/store.html.ep b/templates/home/store.html.ep deleted file mode 100755 index 839e7a5..0000000 --- a/templates/home/store.html.ep +++ /dev/null @@ -1,18 +0,0 @@ -% stash css=>["/home/store/shop.css"]; -
-

TIENDA VIRTUAL

- % for (@$r){ -
-
{imagen} "%> >
-
-

<%= $_->{titulo} %>

-

<%= $_->{descripcion} %>

-

$<%= $_->{precio} %> pesos

-

<%= $_->{opciones} %>

-

<%= $_->{promocion} %>

-
-
-
- %} -
- diff --git a/templates/home/tst.html.ep b/templates/home/tst.html.ep index 3052997..6ec4bab 100755 --- a/templates/home/tst.html.ep +++ b/templates/home/tst.html.ep @@ -5,11 +5,12 @@ %stash css=>["/home/tst/tst.css"];
- +
+

<%= $subnombre %>

<%= $descripcion %>

-

<%= $promo %>

+

<%= $promocion %>

Precio:$<%= $precio %> pesos

<% if ($existencia > 10) { =%>

<% } =%> @@ -21,8 +22,8 @@
-

<%= $nombre %>

-

<%= $titulo %>

+

<%= $objeto %>

+

<%= $nombre %>

diff --git a/templates/layouts/xpay.html.ep b/templates/layouts/xpay.html.ep new file mode 100755 index 0000000..4baedbc --- /dev/null +++ b/templates/layouts/xpay.html.ep @@ -0,0 +1,49 @@ + + + + <%= title %> + + + + <%= javascript "/ext/d3.v4.min.js"; %> + <%= stylesheet "/global/layout.css" %> + <%= stylesheet "/global/chaos/c.css" %> + + <% map{%><%= stylesheet "$_"%><%}(@{stash('css')}) if defined(stash('css'));%> + + +

Beijing Wisdom

Healing Center

+ <% map{%><%= include "$_"%><%}(@{stash('prepend')}) + if defined(stash('prepend'));%> + <%= content %> + <% map{%><%= include "$_"%><%}(@{stash('apend')}) + if defined(stash('apend'));%> + %= include 'home/htmlChaos' + <% map{%><%= javascript "$_"%><%}(@{stash('js')}) if defined(stash('js'));%> + + + diff --git a/templates/home/cal.html.ep b/templates/proc/cal.html.ep similarity index 86% rename from templates/home/cal.html.ep rename to templates/proc/cal.html.ep index a919d56..c4ceb14 100755 --- a/templates/home/cal.html.ep +++ b/templates/proc/cal.html.ep @@ -1,10 +1,10 @@ -% stash css=>["home/cal/cal.css/"]; +% stash css=>["proc/cal/cal.css/"];

Próximos eventos

% foreach (@$b) {

- <%= $_->{text} %> + <%= $_->{fecha} %>

@@ -19,7 +19,7 @@

<%= $d->{nombre} %>

- +
...
diff --git a/templates/home/event.html.ep b/templates/proc/event.html.ep similarity index 70% rename from templates/home/event.html.ep rename to templates/proc/event.html.ep index d115977..cb95770 100755 --- a/templates/home/event.html.ep +++ b/templates/proc/event.html.ep @@ -1,10 +1,13 @@ -% stash css=> ["/home/event/event.css"]; +% stash css=> ["/proc/event/event.css"];

<%= $cname %>

<%= $place %>

+ <% if ($spay== 1) { =%> + »Inscríbete + <% } =%>
@@ -13,14 +16,18 @@

<%= $paddr %>

<%= $pobs %>

<%= $city %>

-

<%= $cost %>

<%= $promo %>

-

Temario

- <%== $csubjects %> -

El evento incluye

- <%== $cservices %> + <%== $cdescription %> + <% if ($csubjects) { =%> +

Temario

+ <%== $csubjects %> + <% } =%> + <% if ($cservices) { =%> +

El evento incluye

+ <%== $cservices %> + <% } =%>
diff --git a/templates/proc/spay.html.ep b/templates/proc/spay.html.ep new file mode 100755 index 0000000..c15c6f3 --- /dev/null +++ b/templates/proc/spay.html.ep @@ -0,0 +1,104 @@ +%stash css=>["/proc/spay/storep.css"]; +%stash js => ["/proc/spay/stripe.js"]; + + +
+

<%= $nombre %>

+

<%= $municipio %>, <%= $federativa %>

+
+ +
+ + +
+

<%= $subnombre %>

+ +

<%= $descripcion %>

+
+ +
+

<%= $fecha %>

+

<%= $promo %>

+

+ <% if ($cupo > 10) { =%>

<% } =%> + <% elsif ($cupo >= 5) { =%>

¡Nos quedan pocos!

<% } =%> + <% elsif ($cupo == 0) { =%>

¡Agotado!

<% } =%> + +
+ +

Costo por asistente: $ pesos

+
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + CH + M + G +
  • +
  • + + +
  • +
  • +

    Total = $ pesos

    +
  • +
  • + + +
  • +
+
+ + + + + + + +
+
+
+ diff --git a/templates/users/reg.html.ep b/templates/users/reg.html.ep old mode 100644 new mode 100755