From ef16d6f7b5dfd476d38333cfb9feeb0c7d42dbf7 Mon Sep 17 00:00:00 2001 From: mynah Date: Fri, 20 Jul 2018 05:16:47 -0500 Subject: [PATCH] concat inferno --- lib/Dojo.pm | 77 ++++--- lib/Dojo/Controller/Home.pm | 304 +++++++++++++++----------- lib/Dojo/Model/Vuelo.pm | 226 ++++++++++--------- lib/Dojo/Support.pm | 2 +- public/home/admin/event/add/qEup.q | 12 +- public/home/admin/event/add/qPup.q | 4 +- public/home/admin/event/change/qEup.q | 16 +- public/home/admin/event/jsEvent.js | 62 +++--- public/home/admin/home/qAdmin.q | 11 - public/home/admin/mensajes/jsMsg.js | 12 +- public/home/tv/qSeries.q | 1 - public/home/tv/qTable.q | 9 - templates/home/admin.html.ep | 9 - templates/home/admin/event.html.ep | 129 ++++++----- templates/home/cal.html.ep | 2 - templates/home/htmlAdmin.html.ep | 9 + templates/home/store.html.ep | 14 +- templates/home/tv.html.ep | 12 +- templates/layouts/admin.html.ep | 30 +++ 19 files changed, 518 insertions(+), 423 deletions(-) delete mode 100755 public/home/admin/home/qAdmin.q delete mode 100755 templates/home/admin.html.ep create mode 100755 templates/home/htmlAdmin.html.ep create mode 100644 templates/layouts/admin.html.ep diff --git a/lib/Dojo.pm b/lib/Dojo.pm index 060bc51..f1f2c43 100644 --- a/lib/Dojo.pm +++ b/lib/Dojo.pm @@ -6,42 +6,55 @@ use Dojo::Model::Users; use Dojo::Model::Data; # 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->helper(ddtt => sub { state $ddtt = Dojo::Model::Data->new }); - $self->defaults({%Dojo::Conf::def}); + $self->helper(dbv => sub { state $dbv = Dojo::Model::Vuelo->new }); + $self->helper(dbg => sub { state $dbg = Dojo::Model::Users->new }); + $self->helper(ddtt => sub { state $ddtt = Dojo::Model::Data->new }); + $self->defaults({%Dojo::Conf::def}); + my $r = $self->routes; #router + +# user ======================================================================== + $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'); +# ============================================================================= + +# json ======================================================================== + $r->any('/json/:dreq')->to('data#simple'); +# ============================================================================= + +# candy ======================================================================= + $r->any('/json/candy/:command')->to('data#candy'); +# ============================================================================= - my $r = $self->routes; #router +# admin ======================================================================= + $r->any('/admin/home')->to('home#admin_home'); + $r->any('/admin/radio')->to('home#admin_radio'); + $r->any('/admin/eventos')->to('home#admin_eventos'); + $r->any('/admin/eventos/:type'=> [type=>['e','p','c']])->to('home#admin_eventos'); + $r->any('/admin/mensajes')->to('home#admin_mensajes'); + $r->any('/admin/json/:dreq/:id')->to('home#admin_json'); +# ============================================================================= - $r->any('/home')->to('home#home'); - $r->any('/cal')->to('home#cal'); - $r->any('/event/:id'=> [id => qr/\d+/])->to('home#event'); - #$r->any('/radio')->to('home#radio'); - $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'); - - $r->any('/json/:dreq')->to('data#simple'); - $r->any('/json/candy/:command')->to('data#candy'); - - $r->any('/admin/:section'=> {section =>'home'})->to('home#admin'); - $r->any('/admin/json/:dreq/:id/')->to('data#admin'); +# login ======================================================================= + $r->any('/login')->to('users#login'); + $r->any('/logout')->to('users#logout'); - $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'); +# ============================================================================= } diff --git a/lib/Dojo/Controller/Home.pm b/lib/Dojo/Controller/Home.pm index 5f7739d..91828b3 100644 --- a/lib/Dojo/Controller/Home.pm +++ b/lib/Dojo/Controller/Home.pm @@ -16,146 +16,202 @@ sub tst{ my $x = [get_names("public/home/cal/img/")]; log("@$x"); $c->stash( ilist => $x); + $c->dbv->tst; } -sub home { - my $c = shift; - $c->stash((load_module("home/home"))[0]); - $c->stash( map{ $_->{nombre} => $_->{contenido}} @{$c->dbv->mod}); -} - -sub pang { - my $c = shift; - my ($v,$w)=load_module("home/pang"); - $c->stash($v); - $c->stash( $c->dbv->pang($w) ); -} - -sub cal { - my $c = shift; - $c->stash((load_module("home/cal"))[0]); - my ($data,$block)=$c->dbv->cal; - my %hdata; - map{ push @{ $hdata{$_->{bid}} },$_; }(@$data); - $c->stash( r=>\%hdata, b=>$block); -} - -sub event{ - my $c = shift; - $c->stash((load_module("home/event"))[0]); - $c->stash(%{($c->dbv->event($c->param("id")))->[0]}); - $c->stash(layout=> "defaultContact"); -} - -sub contact{ - my $c = shift; - if ($c->param("mup")){ - $c->flash(mname => $c->param("mname")); - $c->redirect_to('contact2'); - }else{ - $c->stash((load_module("home/contact"))[0]); +# User ======================================================================== + sub home { + my $c = shift; + $c->stash((load_module("home/home"))[0]); + $c->stash( $c->dbv->mod) ; } -} -sub contact2{ - my $c = shift; - $c->redirect_to("home") unless $c->flash('mname'); - $c->stash( mname=>$c->flash('mname')); - $c->stash((load_module("home/contact2"))[0]); -} + sub pang { + my $c = shift; + my ($v,$w)=load_module("home/pang"); + $c->stash($v); + $c->stash( $c->dbv->md_to_hash(@{$w->{'md'}}) ); + } -sub store{ - my $c = shift; - $c->stash((load_module("home/store"))[0]); - $c->stash( r=>$c->dbv->store); - $c->stash(layout=> "defaultContact"); -} + sub cal { + my $c = shift; + $c->stash((load_module("home/cal"))[0]); + my $data=$c->dbv->calendar_events; + my $block=$c->dbv->calendar_monthblock; + my %hdata; + map{ push @{ $hdata{$_->{bid}} },$_; }(@$data); + $c->stash( r=>\%hdata, b=>$block); + } -sub tv{ - my $c = shift; - $c->stash( merge_hash( - (load_module("home/tv"))[0], - (load_module("home/tv/trans"))[0] - )); - my ($series,$table)=$c->dbv->tv; - $c->stash( series=>$series, table=>$table); - $c->stash(layout=> "defaultContact"); -} + sub event{ + my $c = shift; + $c->stash((load_module("home/event"))[0]); + $c->stash(layout=> "defaultContact"); + $c->stash($c->dbv->event($c->param("id"))); + } + + sub contact{ + my $c = shift; + if ($c->param("mup")){ + $c->flash(mname => $c->param("mname")); + $c->redirect_to('contact2'); + }else{ + $c->stash((load_module("home/contact"))[0]); + } + } + + sub contact2{ + my $c = shift; + $c->redirect_to("home") unless $c->flash('mname'); + $c->stash( mname=>$c->flash('mname')); + $c->stash((load_module("home/contact2"))[0]); + } + + sub store{ + my $c = shift; + $c->stash((load_module("home/store"))[0]); + $c->stash( r=>$c->dbv->store); + $c->stash(layout=> "defaultContact"); + } + + sub tv{ + my $c = shift; + $c->stash( merge_hash( + (load_module("home/tv"))[0], + (load_module("home/tv/trans"))[0] + )); + $c->stash( videos=>$c->dbv->tv_videos, table=>$c->dbv->tv_series); + $c->stash(layout=> "defaultContact"); + } + + sub podcast{ + my $c = shift; + $c->stash((load_module("home/podcast"))[0]); + $c->stash(layout=> "defaultContact"); + $c->stash( t=>$c->dbv->podcast_txt, pod=>$c->dbv->podcast_infoHash); + } + + sub radio{ + my $c=shift; + $c->stash((load_module("home/radio"))[0]); + $c->stash(layout=> "defaultContact"); + $c->stash($c->dbv->mod); + $c->stash($c->dbv->conf_radio); + $c->stash(nick=>$c->session("nick")); + } +#============================================================================== -sub podcast{ - my $c = shift; - $c->stash((load_module("home/podcast"))[0]); - my ($txt,$h)=$c->dbv->podcast; - $c->stash( t=>$txt, pod=>$h,); - $c->stash(layout=> "defaultContact"); -} - -sub radio{ - my $c=shift; - $c->stash((load_module("home/radio"))[0]); - $c->stash(%{($c->dbv->radio)->[0]}); - $c->stash($Dojo::Conf::radio); - $c->stash(nick=>$c->session("nick")); -} - -sub admin{ - my $c=shift; - if (($c->param("hup") // " " )=~/Cambiar/){ - $c->dbv->umod($c->param('link'),$c->param('update')); +# Admin ======================================================================= + sub admin_home{ + my $c=shift; + $c->dbv->umod($c->param('link'),$c->param('update')) + if (($c->param("hup") // " " )=~/Cambiar/); + $c->stash((load_module("home/admin/home"))[0]); + $c->stash(template=>"home/admin/home"); + $c->stash(layout=>"admin"); + $c->stash( $c->dbv->mod); } - ### ¡¡aqui me quede!! puedo hacerlo mas facil con router!!!! ### - if ( $c->param("update") // 0 ) ==1 ){ - if ($c->param("id") // 1 ) == 0) ){ - $c->dbv->eup($c) if (($c->param("eup") // " " )=~/Aceptar/) - elsif(($c->param("cup") // " " )=~/Aceptar/){ $c->dbv->cup($c); } - elsif(($c->param("pup") // " " )=~/Aceptar/){ $c->dbv->pup($c); } - else{ - elsif(($c->param("eup") // " " )=~/Aceptar/){ $c->dbv->ech($c); } - elsif(($c->param("cup") // " " )=~/Aceptar/){ $c->dbv->cch($c); } - elsif(($c->param("pup") // " " )=~/Aceptar/){ $c->dbv->pch($c); } - elsif(($c->param("edel") // " " )=~/Eliminar/){ $c->dbv->edel($c); } - elsif(($c->param("cdel") // " " )=~/Eliminar/){ $c->dbv->cdel($c); } - elsif(($c->param("pdel") // " " )=~/Eliminar/){ $c->dbv->pdel($c); }; - } - if ($c->param("section")=~/home/){ - my $v=(load_module("home/admin"))[0]; - my ($x,$w)= load_module("home/admin/home"); - $c->stash( merge_hash($x,$v) ); - $c->stash(apend => ["home/admin/home"]); - $c->stash( map{ $_->{nombre} => $_->{contenido}} @{$c->dbv->mod}); - } - elsif ( $c->param("section")=~/radio/ ){ + sub admin_radio{ + my $c=shift; + $c->dbv->umod($c->param('link'),'rmod') + if (($c->param("hup") // " " )=~/Cambiar/); + $c->stash($c->dbv->mod); + $c->stash($c->dbv->conf_radio); $c->stash( merge_hash( - (load_module("home/admin"))[0], (load_module("home/admin/radio"))[0], (load_module("home/admin/candySwitch"))[0], )); - $c->stash(apend => ["home/admin/radio","home/admin/candySwitch"]); - $c->stash(%{($c->dbv->radio)->[0]}); - $c->stash($Dojo::Conf::radio); - } - elsif ( $c->param("section")=~/mensajes/ ){ - $c->stash(merge_hash( - (load_module("home/admin"))[0], - (load_module("home/admin/mensajes"))[0] - )); - $c->stash(apend => ["home/admin/mensajes"]); - my $h = $c->dbv->rmsg; - $c->stash( h=>$h ); - - } - elsif ( $c->param("section")=~/event/ ){ - $c->stash(merge_hash( - (load_module("home/admin"))[0], - (load_module("home/admin/event"))[0] - )); - $c->stash(apend => ["home/admin/event"]); - $c->stash( $c->dbv->admevent ); + $c->stash(apend => ["home/admin/candySwitch"]); + $c->stash(template=>"home/admin/radio"); + $c->stash(layout=>"admin"); } -} + sub admin_mensajes{ + my $c=shift; + $c->stash((load_module("home/admin/mensajes"))[0]); + $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((load_module("home/admin/event"))[0]); + $c->stash(template=>"home/admin/event"); + $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->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); + } + + + # if (($c->param("id") // " " ) eq "0") { + # $c->dbv->eup if (($c->param("eup") // " " ) =~/Aceptar/); + # $c->dbv->cup if (($c->param("cup") // " " ) =~/Aceptar/); + # $c->dbv->pup if (($c->param("pup") // " " ) =~/Aceptar/); + # } + # else{ + # if (($c->param("cup") // " " )=~/Aceptar/){ $c->dbv->cch; } + # elsif (($c->param("eup") // " " )=~/Aceptar/){ $c->dbv->ech; } + # elsif (($c->param("pup") // " " )=~/Aceptar/){ $c->dbv->pch; } + # elsif (($c->param("edel") // " " )=~/Eliminar/){ $c->dbv->edel; } + # elsif (($c->param("cdel") // " " )=~/Eliminar/){ $c->dbv->cdel; } + # elsif (($c->param("pdel") // " " )=~/Eliminar/){ $c->dbv->pdel; } + #}}; + #} + #} +#============================================================================== 1; diff --git a/lib/Dojo/Model/Vuelo.pm b/lib/Dojo/Model/Vuelo.pm index 81ba805..caafad3 100644 --- a/lib/Dojo/Model/Vuelo.pm +++ b/lib/Dojo/Model/Vuelo.pm @@ -1,7 +1,9 @@ package Dojo::Model::Vuelo; use Mojo::File 'path'; use Mojo::JSON qw(decode_json encode_json); -use Dojo::Support qw{ dmph merge_hash load_module get_names}; +use Dojo::Support qw{ log dmph merge_hash load_module get_names}; +use Mojo::Base 'Mojolicious::Controller'; + use File::Basename; use Text::Markdown qw{ markdown }; @@ -12,128 +14,150 @@ use Dojo::Conf; sub new { bless {}, shift }; -sub mod{ - my $q="select nombre,contenido from casa;"; - return \@{_read($q)}; -} +# Read vdg user =============================================================== + sub mod{ + my $q="select nombre,contenido from casa;"; + my %h=map{ $_->{nombre} => $_->{contenido}}@{_read($q)}; + return %h; + } -sub pang{ - my ($c,$q)=@_; - return {map { basename($_,".md") => load_md("public/$_")}@{$q->{md}}}; -} -sub cal { - my $block=_read (path("public/home/cal/q1Block.q")->slurp); - my $data=_read (path("public/home/cal/q3Event.q")->slurp); - return ($data,$block); -} + sub md_to_hash{ + my ($self,@filelist)=@_; + return {map { basename($_,".md") => load_md("public/$_")}@filelist}; + } -sub event{ - my ($self,$id)=@_; - return _read (path("public/home/event/qEvent.q")->slurp,$id); -} + sub calendar_monthblock { + return _read (path("public/home/cal/q1Block.q")->slurp); + } + sub calendar_events { + return _read (path("public/home/cal/q3Event.q")->slurp); + } -sub store{ - return _read (path("public/home/store/qStore.q")->slurp); -} + sub event{ + my ($self,$id)=@_; + return shift @{ _read (path("public/home/event/qEvent.q")->slurp,$id)}; + } + sub store{ + return _read (path("public/home/store/qStore.q")->slurp); + } + sub tv_videos{ + return _read (path("public/home/tv/qSeries.q")->slurp); #group,name + } + sub tv_series{ + return _read (path("public/home/tv/qTable.q")->slurp); #name,order,group + } + sub podcast_txt{ + return path("public/home/podcast/text.txt")->slurp; + } + sub podcast_infoHash{ + return decode_json path("public/home/podcast/jsonPod.json")->slurp; + } + sub conf_radio{ + return $Dojo::Conf::radio; + } +#============================================================================== -sub tv{ - my $series = _read (path("public/home/tv/qSeries.q")->slurp); #group,name - my $table = _read (path("public/home/tv/qTable.q")->slurp); #name,order,group - return ($series,$table); -} +# Read vdg admin ============================================================== + sub msg_heads{ + my ($self,@bind)=@_; + my @empty; + my $q= path("public/home/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); + return \@empty unless($dbh); + my $h=$dbh->selectall_arrayref($q,{ Slice => {} },@bind); + #((col1=>d1,col2=>d1),(col1=>d2,col2=>d2)) + $dbh->disconnect(); + return $h; + } -sub podcast{ - my $txt = path("public/home/podcast/text.txt")->slurp; - my $hash = decode_json path("public/home/podcast/jsonPod.json")->slurp; - return ($txt,$hash); -} + sub msg{ + my ($c,@bind)=@_; + my @empty; + my $q= path("public/home/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); + return \@empty unless($dbh); + my $h=$dbh->selectall_arrayref($q,{ Slice => {} },@bind); + #((col1=>d1,col2=>d1),(col1=>d2,col2=>d2)) + $dbh->disconnect(); + return shift @$h; + } + sub courses{ return _read("select nombre as name, id from curso;")} + sub course { return shift @{_read(path("public/home/admin/event/json/qCourse.q")->slurp,pop)}} + sub places { return _read("select nombre as name, id from lugar;")} + sub place { return shift @{_read(path("public/home/admin/event/json/qPlace.q")->slurp,pop)}} + sub months { return _read("select nombre as name, id from mes;")}; + sub events { return _read(path("public/home/admin/event/qEprev.q")->slurp)} + sub eventa { return shift @{_read(path("public/home/admin/event/json/qEvent.q")->slurp,pop)}} + sub eimgList{ return [get_names("public/home/cal/img/")] } +#============================================================================== +# Write vdg admin ============================================================== + sub umod{ + my $c=shift; + my $q="update casa set contenido = ? where nombre = ? ;"; + return _write($q,@_); + } -sub radio{ - my $q="select contenido as rmod from casa where nombre='rmod';"; - return _read($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(path("public/home/admin/event/add/qEup.q")->slurp,@bind); + } + sub course_up{ + my ($self,@bind)=@_; + return _write(path("public/home/admin/event/add/qCup.q")->slurp,@bind); + } + sub place_up{ + my ($self,@bind)=@_; + return _write(path("public/home/admin/event/add/qPup.q")->slurp,@bind); + } + sub event_ch{ + my ($self,@bind)=@_; + return _write(path("public/home/admin/event/change/qEup.q")->slurp,@bind); + } + sub course_ch{ + my ($self,@bind)=@_; + return _write(path("public/home/admin/event/change/qCup.q")->slurp,@bind); + } + sub place_ch{ + my ($self,@bind)=@_; + return _write(path("public/home/admin/event/change/qPup.q")->slurp,@bind); + } - -sub umod{ - my $c=shift; - my $q="update casa set contenido = ? where nombre = ? ;"; - return _write($q,@_); -} -# admin =================================0 -sub urmod{ - my $c=shift; - my $q="update casa set contenido = ? where nombre = ? ;"; - return _write($q,@_); -} -sub rmsg{ - my @empty; - my $q= path("public/home/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); - return \@empty unless($dbh); - my $h=$dbh->selectall_arrayref($q,{ Slice => {} },@bind); - #((col1=>d1,col2=>d1),(col1=>d2,col2=>d2)) - $dbh->disconnect(); - return $h; -} -sub rmsgid{ - my ($c,@bind)=@_; - my @empty; - my $q= path("public/home/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); - return \@empty unless($dbh); - my $h=$dbh->selectall_arrayref($q,{ Slice => {} },@bind); - #((col1=>d1,col2=>d1),(col1=>d2,col2=>d2)) - $dbh->disconnect(); - return $h; -} -sub admevent{ - my $h = { - ecourse=>_read("select nombre as name, id from curso;"), - eplace =>_read("select nombre as name, id from lugar;"), - emini =>_read("select nombre as name, id from mes;"), - ilist => [get_names("public/home/cal/img/")], - eprev =>_read(path("public/home/admin/event/qEprev.q")->slurp), - }; - return $h -} -# json ====== -sub ecourse{ - my ($c,@id)=@_; - return _read(path("public/home/admin/event/json/qEvent.q")->slurp,@id); -} -sub qcourse{ - my ($c,@id)=@_; - return _read(path("public/home/admin/event/json/qCourse.q")->slurp,@id); -} -sub qplace{ - my ($c,@id)=@_; - return _read(path("public/home/admin/event/json/qPlace.q")->slurp,@id); -} -#============ -#Change ===== - - -#============ +#============================================================================== #ayudas ===================================== +sub tst{ + + my $c=shift; + my $d=$c->param('n'); + log("------log-------"); + log("$d"); + log("------log-------"); + return 0; +} + sub _read{ my ($q,@bind)=@_; - my (@empty,$arr); + my @empty; my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::VUELODB.":".Dojo::Conf::VUELODB_H,Dojo::Conf::VUELODB_UR,Dojo::Conf::VUELODB_URP); return \@empty unless($dbh); - #$dbh->do(qq{SET NAMES 'utf8'}); my $h=$dbh->selectall_arrayref($q,{ Slice => {} },@bind); - #((col1=>d1,col2=>d1),(col1=>d2,col2=>d2)) $dbh->disconnect(); + #((col1=>d1,col2=>d1),(col1=>d2,col2=>d2)) return $h; } + sub _write{ - my $q=shift; + my ($q,@bind)=@_; my (@empty); my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::VUELODB.":".Dojo::Conf::VUELODB_H,Dojo::Conf::VUELODB_UW,Dojo::Conf::VUELODB_UWP); return 0 unless($dbh); - my $h=$dbh->do($q,{ Slice => {} },@_); + my $h=$dbh->do($q,{ Slice => {} },@bind); $dbh->disconnect(); + log("db write: $h"); return $h; } diff --git a/lib/Dojo/Support.pm b/lib/Dojo/Support.pm index b06cc46..63001f3 100644 --- a/lib/Dojo/Support.pm +++ b/lib/Dojo/Support.pm @@ -15,7 +15,7 @@ use Mojo::Log; sub log{ my $log = Mojo::Log->new; - $log->debug(shift); + $log->debug("============ ".shift." ==========="); } sub get_names{ my $dir = shift; diff --git a/public/home/admin/event/add/qEup.q b/public/home/admin/event/add/qEup.q index d356643..ba4ae19 100755 --- a/public/home/admin/event/add/qEup.q +++ b/public/home/admin/event/add/qEup.q @@ -1,14 +1,14 @@ insert into evento - (lugar_id, fecha_inicio, fecha_fin,precio,curso_id,imagen_chica,estado,promocion,promo_estado) + (lugar_id, fecha_inicio, fecha_fin, precio, promocion, promo_estado, curso_id, imagen_chica, estado) values( ?, # eplace - " ?-?-? ", # yini - mini - dini - " ?-?-? ", # yend - mend - dend + 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 - ?, # promo , - case ? when "on" then 1 else 0 end # pen + case ? when "on" then 1 else 0 end # een ); diff --git a/public/home/admin/event/add/qPup.q b/public/home/admin/event/add/qPup.q index 3b22545..33e4e44 100755 --- a/public/home/admin/event/add/qPup.q +++ b/public/home/admin/event/add/qPup.q @@ -7,8 +7,8 @@ ?, # pto ?, # pst ?, # pco - ?, # lat - ?, # lng + ?, # plat + ?, # plng case ? when "on" then 1 else 0 end #pen ); diff --git a/public/home/admin/event/change/qEup.q b/public/home/admin/event/change/qEup.q index fd5674b..162cf69 100755 --- a/public/home/admin/event/change/qEup.q +++ b/public/home/admin/event/change/qEup.q @@ -1,12 +1,12 @@ update evento set - lugar_id = ?, # eplace , - fecha_inicio='?-?-?', # yini - mini - dini ', - fecha_fin='?-?-?', # yend - mend - dend ', - precio= ?, # cost , - promocion= ?, # promo , + 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 , + curso_id = ?, # ecourse + imagen_chica = ?, # eimg estado = case ? when "on" then 1 else 0 end # een - where id = ?; # eprev ; + where id = ?; # eprev diff --git a/public/home/admin/event/jsEvent.js b/public/home/admin/event/jsEvent.js index 5ac4e5b..2792d68 100755 --- a/public/home/admin/event/jsEvent.js +++ b/public/home/admin/event/jsEvent.js @@ -22,48 +22,48 @@ d3.select("select#eimg").on("change",updateImage); /*preload form contents for event*/ d3.select("select#eprev").on("change",function(){ var eprev_id=d3.select("select#eprev").node().value; - d3.json( json_path+"ecourse/"+eprev_id ,function(d){ - if(d[0] !=undefined) {if(d[0].cid != 0){ - dropdownUpdate("ecourse",d[0].cid); - dropdownUpdate("eplace",d[0].pid); - d3.select("input#dini").attr("value",d[0].dini); - dropdownUpdate("mini",d[0].mini); - dropdownUpdate("yini",d[0].yini); - d3.select("input#dend").attr("value",d[0].dend); - dropdownUpdate("mend",d[0].mend); - dropdownUpdate("yend",d[0].yend); - d3.select("input#cost").attr("value",d[0].cost); - d3.select("input#promo").attr("value",d[0].promo); - d3.select("input#pen").attr("checked",d[0].pen); - d3.select("input#een").attr("checked",d[0].een); - dropdownUpdate("eimg",d[0].eimg); + d3.json( json_path+"event/"+eprev_id ,function(d){ + if(d !=undefined) {if(d.cid != 0){ + dropdownUpdate("ecourse",d.cid); + dropdownUpdate("eplace",d.pid); + d3.select("input#dini").attr("value",d.dini); + dropdownUpdate("mini",d.mini); + dropdownUpdate("yini",d.yini); + d3.select("input#dend").attr("value",d.dend); + dropdownUpdate("mend",d.mend); + dropdownUpdate("yend",d.yend); + d3.select("input#cost").attr("value",d.cost); + d3.select("input#promo").attr("value",d.promo); + d3.select("input#pen").attr("checked",d.pen); + d3.select("input#een").attr("checked",d.een); + dropdownUpdate("eimg",d.eimg); updateImage(); }} }); }); /*preload form content for course*/ d3.select("select#cprev").on("change",function(){ var cprev_id=d3.select("select#cprev").node().value; - d3.json(json_path+"qcourse/"+cprev_id ,function(d){ - if(d[0]!=undefined){if(d[0].cid != 0){ - d3.select("input#cname").attr("value",d[0].cname); - d3.select("textarea#csubjects").text(d[0].csubjects); - d3.select("textarea#cservices").text(d[0].cservices); + 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("textarea#csubjects").text(d.csubjects); + d3.select("textarea#cservices").text(d.cservices); }} }); }); /*preload form content for place*/ d3.select("select#pprev").on("change",function(){ var pprev_id=d3.select("select#pprev").node().value; - d3.json(json_path+"qplace/"+pprev_id ,function(d){ - if(d[0]!=undefined){if(d[0].pid != 0){ - d3.select("input#pname").attr("value",d[0].pname); - d3.select("input#paddr").attr("value",d[0].paddr); - d3.select("input#pobs").attr("value",d[0].pobs); - d3.select("input#pto").attr("value",d[0].pto); - d3.select("input#pst").attr("value",d[0].pst); - d3.select("input#pco").attr("value",d[0].pco); - d3.select("input#plat").attr("value",d[0].plat); - d3.select("input#plng").attr("value",d[0].plng); - d3.select("input#pen").attr("checked",d[0].pen); + d3.json(json_path+"place/"+pprev_id ,function(d){ + if(d!=undefined){if(d.pid != 0){ + d3.select("input#pname").attr("value",d.pname); + d3.select("input#paddr").attr("value",d.paddr); + d3.select("input#pobs").attr("value",d.pobs); + d3.select("input#pto").attr("value",d.pto); + d3.select("input#pst").attr("value",d.pst); + d3.select("input#pco").attr("value",d.pco); + d3.select("input#plat").attr("value",d.plat); + d3.select("input#plng").attr("value",d.plng); + d3.select("input#pen").attr("checked",d.pen); }} }); }); /*support "selected" option on other drop down*/ diff --git a/public/home/admin/home/qAdmin.q b/public/home/admin/home/qAdmin.q deleted file mode 100755 index d111be2..0000000 --- a/public/home/admin/home/qAdmin.q +++ /dev/null @@ -1,11 +0,0 @@ - - /* c#host localhost*/ - /* c#database #dbdata */ - /* c#user #dbdata_user */ - /* c#password #dbdata_pass */ - -select - nombre as "tag", - contenido as "admContent" -from casa where 1=1; - diff --git a/public/home/admin/mensajes/jsMsg.js b/public/home/admin/mensajes/jsMsg.js index c07732b..752959b 100755 --- a/public/home/admin/mensajes/jsMsg.js +++ b/public/home/admin/mensajes/jsMsg.js @@ -1,11 +1,11 @@ d3.select("select#sentry").on("change",function(){ var msg_id=d3.select("select#sentry").node().value; - d3.json("/admin/json/mensajes/"+msg_id ,function(d){ - if(d[0] !=undefined) {if(d[0] != 0){ - d3.select("p#fecha").text(d[0].imdate); - d3.select("p#correo").text(d[0].imail); - d3.select("p#nombre").text(d[0].imname); - d3.select("p#mensaje").text(d[0].immsg); + d3.json("/admin/json/mensaje/"+msg_id ,function(d){ + if(d !=undefined) {if(d != 0){ + d3.select("p#fecha").text(d.imdate); + d3.select("p#correo").text(d.imail); + d3.select("p#nombre").text(d.imname); + d3.select("p#mensaje").text(d.immsg); }}}); }); diff --git a/public/home/tv/qSeries.q b/public/home/tv/qSeries.q index 0543423..5db16df 100755 --- a/public/home/tv/qSeries.q +++ b/public/home/tv/qSeries.q @@ -1,4 +1,3 @@ - select distinct replace(grupo,' ','_' ) as "group", grupo as "name" diff --git a/public/home/tv/qTable.q b/public/home/tv/qTable.q index 5987970..47d0fd0 100755 --- a/public/home/tv/qTable.q +++ b/public/home/tv/qTable.q @@ -1,13 +1,4 @@ - - /* c#host localhost*/ - /* c#database #dbdata */ - /* c#user #dbdata_user */ - /* c#password #dbdata_pass */ - - - select - "table" as "tag", nombre as "name", vinculo as "link", orden as "order", diff --git a/templates/home/admin.html.ep b/templates/home/admin.html.ep deleted file mode 100755 index 7acdddf..0000000 --- a/templates/home/admin.html.ep +++ /dev/null @@ -1,9 +0,0 @@ -
-

Administracion

- -
diff --git a/templates/home/admin/event.html.ep b/templates/home/admin/event.html.ep index cfbef13..0c59e3e 100755 --- a/templates/home/admin/event.html.ep +++ b/templates/home/admin/event.html.ep @@ -12,139 +12,134 @@
- -
+ +
- - <% map{ %> - <% } %><% (@{stash('eplace')}) %><% if defined(stash('eplace')); %> + <% } %><% (@{stash('places')}) %><% if defined(stash('places')); %>
- - + - +
- - - + - +
- +
- - + +
- - - <% map{ %> + <% map{ %> - <% } %><% (@{stash('ilist')}) %><% if defined(stash('ilist')); %> + <% } %><% (@{stash('img')}) %><% if defined(stash('img')); %>
- - <% map{ %> - - <% } %><% (@{stash('eprev')}) %><% if defined(stash('eprev')); %> + <% map{ %> + + <% } %><% (@{stash('events')}) %><% if defined(stash('events')); %>
- - - + + - +
- -
+ +
- +
- +
- +
- - <% map{ %> - - <% } %><% (@{stash('ecourse')}) %><% if defined(stash('ecourse')); %> + <% map{ %> + + <% } %><% (@{stash('courses')}) %><% if defined(stash('courses')); %>
- - - + + - +
- -
+ +
- +
- +
- +
- +
- +
- +
- +
- +
- - <% map{ %> - - <% } %><% (@{stash('eplace')}) %><% if defined(stash('eplace')); %> + <% map{ %> + + <% } %><% (@{stash('places')}) %><% if defined(stash('places')); %>
- - - + + - +
diff --git a/templates/home/cal.html.ep b/templates/home/cal.html.ep index 35e61ff..9895d18 100755 --- a/templates/home/cal.html.ep +++ b/templates/home/cal.html.ep @@ -11,7 +11,6 @@
% foreach my $d( @{ $r->{$_->{id}} } ) { -
@@ -29,7 +28,6 @@
%} - %} diff --git a/templates/home/htmlAdmin.html.ep b/templates/home/htmlAdmin.html.ep new file mode 100755 index 0000000..f9d5ee1 --- /dev/null +++ b/templates/home/htmlAdmin.html.ep @@ -0,0 +1,9 @@ +
+

Administracion

+ +
diff --git a/templates/home/store.html.ep b/templates/home/store.html.ep index 888c5eb..d520481 100755 --- a/templates/home/store.html.ep +++ b/templates/home/store.html.ep @@ -1,14 +1,14 @@

TIENDA VIRTUAL

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

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

-

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

-

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

-

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

-

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

+

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

+

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

+

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

+

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

+

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

diff --git a/templates/home/tv.html.ep b/templates/home/tv.html.ep index bf753d1..b34ce01 100755 --- a/templates/home/tv.html.ep +++ b/templates/home/tv.html.ep @@ -27,9 +27,9 @@
    - % for my $s(@$series){ -
  • - <%= $s->{name} %> + % for (@$videos){ +
  • + <%= $_->{name} %>
  • % } @@ -39,9 +39,9 @@
      - % for my $t(@$table){ -
    • - <%= $t->{order} %> <%= $t->{name} %> + % for (@$table){ +
    • + <%= $_->{order} %> <%= $_->{name} %>
    • % } diff --git a/templates/layouts/admin.html.ep b/templates/layouts/admin.html.ep new file mode 100644 index 0000000..d3350fe --- /dev/null +++ b/templates/layouts/admin.html.ep @@ -0,0 +1,30 @@ + + + + <%= title %> + + + + <%= javascript "/ext/d3.v4.min.js"; %> + <%= stylesheet "/global/layout.css" %> + <%= stylesheet "/global/nav/cssSide.css" %> + <%= stylesheet "/global/nav/cssNav.css" %> + <%= stylesheet "/global/chaos/c.css" %> + <%= stylesheet "/home/admin/cssAdmin.css" %> + <% map{%><%= stylesheet "$_"%><%}(@{stash('css')}) if defined(stash('css'));%> + + + %= include 'home/htmlNav' + %= include 'home/htmlSide' + %= include 'home/htmlAdmin' + <% map{%><%= include "$_"%><%}(@{stash('prepend')}) + if defined(stash('prepend'));%> + <%= content %> + <% map{%><%= include "$_"%><%}(@{stash('apend')}) + if defined(stash('apend'));%> + %= include 'home/htmlChaos' + <%= javascript "/global/nav/d3Side.js"; %> + <% map{%><%= javascript "$_"%><%}(@{stash('js')}) if defined(stash('js'));%> + + +