Merge branch 'zero' into 'master'

Zero

See merge request mynah/dojo!4
This commit is contained in:
mynah
2020-01-23 01:21:42 +00:00
112 changed files with 1981 additions and 894 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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();}
#=========================================================

View File

@@ -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;

View File

@@ -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;

222
lib/Dojo/Controller/Proc.pm Normal file
View File

@@ -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;

View File

@@ -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);

View File

@@ -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(?,?,?,?,?,?,?,?);

View File

@@ -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( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);

View File

@@ -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(?,?,?,?,?,?,?,?,?);

View File

@@ -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

View File

@@ -1,2 +1,2 @@
delete from evento where id = ? ; # eprev
delete from curso_tienda where id = ? ; # eprev

View File

@@ -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

View File

@@ -1,4 +1,4 @@
delete from lugar where id = ?; # pprev ;
delete from curso_lugar where id = ?; # pprev ;

View File

@@ -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 ;

View File

@@ -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 ;

View File

@@ -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 ;

View File

@@ -9,7 +9,7 @@ select
lat as "plat",
lng as "plng",
estado as "pen"
from lugar
from curso_lugar
where id= ? ; # course ;

View File

@@ -1,10 +1,3 @@
/* c#host localhost*/
/* c#database #dbdata */
/* c#user #dbdata_user */
/* c#password #dbdata_pass */
select
"cprev" as "tag",

View File

@@ -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",

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -1,3 +1,4 @@
select
id as mid,
concat(nombre," ",date(fecha)) as "entry"

View File

@@ -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=?;

View File

@@ -1,4 +0,0 @@
select
correo,telefono as tel, observacion as obs,date(ultima) as ultima
from usuario where id=?;

View File

@@ -1,3 +0,0 @@
select
id,nombre,existencia,precio,activo
from tienda order by id;

View File

@@ -1,4 +0,0 @@
select
id,usuario,nombre
from usuario order by usuario;

View File

@@ -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;

View File

@@ -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
;

View File

@@ -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 = ?
;

View File

@@ -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
;

View File

@@ -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())
;

View File

@@ -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 = ?
;

View File

@@ -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
;

View File

@@ -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;

View File

@@ -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);

266
lib/Dojo/Model/Vdgproc.pm Normal file
View File

@@ -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;

View File

@@ -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|\<a|feedback|forms|suscribe|advertise|newsletter|promotion|Madam/;
return _writemsg($q,@a) unless $a[3]=~m/http|website|\<a|feedback|forms|suscribe|investment|funding|site|company|advertise|newsletter|promotion|Madam|Sir/;
return 0;
}
#==============================================================================
@@ -130,35 +88,6 @@ sub umod{
return _write($q,@_);
}
sub event_del { return _write("delete from evento where id = ?;",pop);}
sub course_del{ return _write("delete from curso where id = ?;",pop); }
sub place_del { return _write("delete from lugar where id = ?;",pop); }
sub 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);
}
#==============================================================================
#ayudas =====================================

View File

@@ -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;

View File

@@ -76,6 +76,7 @@ div.update{
article.edit input[type=submit]{
margin:15px;
}
div#cimg,
div#esimg{
height:180px;
width:180px;

View File

@@ -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;

0
public/global/error/404.css Normal file → Executable file
View File

0
public/global/error/hono.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 45 KiB

View File

@@ -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{
}

View File

@@ -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;
}

View File

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 122 KiB

View File

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 112 KiB

View File

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

View File

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 86 KiB

View File

Before

Width:  |  Height:  |  Size: 104 KiB

After

Width:  |  Height:  |  Size: 104 KiB

View File

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 118 KiB

View File

Before

Width:  |  Height:  |  Size: 171 KiB

After

Width:  |  Height:  |  Size: 171 KiB

View File

Before

Width:  |  Height:  |  Size: 136 KiB

After

Width:  |  Height:  |  Size: 136 KiB

View File

Before

Width:  |  Height:  |  Size: 140 KiB

After

Width:  |  Height:  |  Size: 140 KiB

View File

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 132 KiB

View File

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

View File

Before

Width:  |  Height:  |  Size: 124 KiB

After

Width:  |  Height:  |  Size: 124 KiB

View File

Before

Width:  |  Height:  |  Size: 111 KiB

After

Width:  |  Height:  |  Size: 111 KiB

View File

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 105 KiB

View File

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 105 KiB

View File

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 148 KiB

View File

Before

Width:  |  Height:  |  Size: 151 KiB

After

Width:  |  Height:  |  Size: 151 KiB

View File

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 59 KiB

View File

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 130 KiB

View File

Before

Width:  |  Height:  |  Size: 128 KiB

After

Width:  |  Height:  |  Size: 128 KiB

View File

Before

Width:  |  Height:  |  Size: 144 KiB

After

Width:  |  Height:  |  Size: 144 KiB

127
public/proc/event/event.css Executable file
View File

@@ -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{
}

View File

Before

Width:  |  Height:  |  Size: 493 KiB

After

Width:  |  Height:  |  Size: 493 KiB

BIN
public/proc/spay/grulla_10.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 KiB

BIN
public/proc/spay/img/China.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

View File

Before

Width:  |  Height:  |  Size: 185 KiB

After

Width:  |  Height:  |  Size: 185 KiB

View File

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 130 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

201
public/proc/spay/storep.css Executable file
View File

@@ -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;
}

242
public/proc/spay/stripe.js Normal file
View File

@@ -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;
});

200
templates/admin/event.html.ep Executable file
View File

@@ -0,0 +1,200 @@
% stash css=>["/admin/admin.css","/admin/event/event.css"];
% stash js=>["/admin/event/event.js"];
<section class="name" flex>
<article class="user">
<p class="title">Editar Eventos</p>
</article>
</section>
<section class="event flex">
<article class="label">
<ul>
<li id="evento" value="event">Evento</li>
<li id="curso" value="course">Curso</li>
<li id="lugar" value="place">Lugar</li>
</ul>
</article>
<article class="edit">
<!-- Evento ============================================================== -->
<div class="ehide" id="event">
<form id="fev" action="/admin/eventos/e" method="POST">
<div class="flex field">
<label>Curso</label>
<select id="ecourse" name="ecourse">
<% map{ %>
<option value="<%= $_->{'id'} %>"><%= $_->{'name'} %></option>
<% } %><% (@{stash('courses')}) %><% if defined(stash('courses')); %>
</select>
</div>
<div class="flex field">
<label>Lugar</label>
<select id="eplace" name="eplace">
<% map{ %>
<option value="<%= $_->{'id'} %>"><%= $_->{'name'} %></option>
<% } %><% (@{stash('places')}) %><% if defined(stash('places')); %>
</select>
</div>
<div class="flex field">
<label>Fecha inicio</label> <!-- dropdown -->
<input id="dini" type="number" min="1" max="31" name="dini" value="1"/>
<select id="mini" name="mini">
<% foreach(1 .. 12){ %>
<option value="<%= $_ %>"><%= ${stash('months')}[$_ -1] %> </option>
<% } %>
</select>
<input id="yini" type="number" min="2020" max="2050" name="yini" value="2020"/>
</div>
<div class="flex field">
<label>Fecha fin</label>
<input id="dend" type="number" min="1" max="31" name="dend" value="1"/>
<select id="mend" name="mend">
<% foreach(1 .. 12){ %>
<option value="<%= $_ %>"><%= ${stash('months')}[$_ -1] %> </option>
<% } %>
</select>
<input id="yend" type="number" min="2020" max="2050" name="yend" value="2020"/>
</div>
<div class="flex field">
<label>Costo</label> <input id="cost" type="text" name="cost"/>
</div>
<div class="flex field">
<label>Promoción</label><input id="promo" type="text" name="promo"/>
<label>Habilitar</label><input type="checkbox" checked="checked" id="pen" name="pen"/>
</div>
<div class="flex field">
<label>Imagen</label>
<select id="eimg" name="eimg">
<option value="0" selected> -- Elegir imagen -- </option>
<% map{ %>
<option value="<%= $_ %>"><%= $_ %></option>
<% } %><% (@{stash('img')}) %><% if defined(stash('img')); %>
</select>
<div id=esimg></div>
</div>
<div class="flex field">
<label>¿con pago en linea?</label><input type="checkbox" checked="checked" id="spay" name="spay"/>
</div>
<div class="flex field">
<label>¿incluye playera?</label><input type="checkbox" id="ten" name="ten"/>
</div>
<div class="flex field">
<label>¿es público?</label><input type="checkbox" checked="checked" id="estore" name="estore"/>
</div>
<div class="flex field">
<label>Pago a meses max:</label><input id="meses" type="number" min="0" max="18" name="meses" value="0"/>
</div>
<div class="flex field">
<label>Cupo</label><input id="meses" type="number" min="0" max="500" name="meses" value="0"/>
</div>
<div class="flex field">
<label>Comentario</label>
<textarea form="fev" id="comment" name="comment"></textarea>
</div>
<div class="flex field">
<label>Existente</label>
<select id="eprev" name="id">
<option value="0">-- Nuevo --</option>
<% map{ %>
<option value="<%= $_->{'id'} %>"><%= $_->{'name'} %></option>
<% } %><% (@{stash('events')}) %><% if defined(stash('events')); %>
</select>
</div>
<div class="flex field update">
<input type="submit" name="req" value="Aceptar">
<input type="submit" name="req" value="Eliminar">
<label>Habilitar</label>
<input id="een" type="checkbox" checked="checked" name="een" >
</div>
</form>
</div>
<!-- Curso ================================================================ -->
<div class="ehide" id="course">
<form id="fcourse" action="/admin/eventos/c" method="POST">
<div class="flex field">
<label>Nombre</label>
<input id="cname" type="text" name="cname"/>
</div> <div class="flex field">
<label>Subnombre</label>
<input id="csubname" type="text" name="csubname"/>
</div> <div class="flex field">
<label>Descripcion</label>
<textarea form="fcourse" id="cdesc" name="cdesc"></textarea>
</div> <div class="flex field">
<label>Maestro</label>
<input id="cmas" type="text" name="cmas"/>
<div class="flex field">
<label>Imagen</label>
<select id="cimga" name="cimga">
<option value="0" selected> -- Elegir imagen -- </option>
<% map{ %>
<option value="<%= $_ %>"><%= $_ %></option>
<% } %><% (@{stash('img')}) %><% if defined(stash('img')); %>
</select>
<div id=cimg></div>
</div>
</div> <div class="flex field">
<label>Temario</label>
<textarea form="fcourse" id="csubjects" name="csubjects"></textarea>
</div> <div class="flex field">
<label>Servicios</label>
<textarea form="fcourse" id="cservices" name="cservices"></textarea>
</div> <div class="flex field">
<label>Existente</label>
<select id="cprev" name="id">
<option value="0">-- Nuevo --</option>
<% map{ %>
<option value="<%= $_->{'id'} %>"><%= $_->{'name'} %></option>
<% } %><% (@{stash('courses')}) %><% if defined(stash('courses')); %>
</select>
</div> <div class="flex field update">
<input type="submit" name="req" value="Aceptar">
<input type="submit" name="req" value="Eliminar">
<label>Habilitar</label>
<input type="checkbox" checked="checked" id="cen" name="cen" >
</div>
</form>
</div>
<!-- Lugar ================================================================ -->
<div class="ehide" id="place">
<form action="/admin/eventos/p" method="POST">
<div class="flex field">
<label>Nombre</label><input type="text" id= "pname" name="pname">
</div> <div class="flex field">
<label>Direccion</label> <input type="text" id="paddr" name="paddr">
</div> <div class="flex field">
<label>Observación</label> <input type="text" id="pobs" name="pobs">
</div> <div class="flex field">
<label>Municipio</label> <input type="text" id="pto" name="pto">
</div> <div class="flex field">
<label>Entidad</label> <input type="text" id="pst" name="pst">
</div> <div class="flex field">
<label>País</label> <input type="text" id="pco" name="pco">
</div> <div class="flex field">
<label>Latitud</label> <input type="text"id="plat" name="plat">
</div> <div class="flex field">
<label>Longitud</label> <input type="text" id="plng" name="plng">
</div> <div class="flex field">
<label>Existente</label>
<select id="pprev" name="id">
<option value="0">-- Nuevo --</option>
<% map{ %>
<option value="<%= $_->{'id'} %>"><%= $_->{'name'} %></option>
<% } %><% (@{stash('places')}) %><% if defined(stash('places')); %>
</select>
</div> <div class="flex field update">
<input type="submit" name="req" value="Aceptar">
<input type="submit" name="req" value="Eliminar">
<label>Habilitar</label>
<input id="pen" type="checkbox" checked="checked" name="pen" >
</div>
</form>
<div class="mapa"></div>
</div>
</article>
</section>

View File

@@ -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"];
<section class="title flex">
<article class="title"> <p>Editar Casa</p> </article>
</section>

Some files were not shown because too many files have changed in this diff Show More