noche, actualiza tablas eventos

This commit is contained in:
mynah
2018-07-19 03:45:46 -05:00
parent 5a7566eaf7
commit e25fc46010
31 changed files with 207 additions and 258 deletions

View File

@@ -19,7 +19,10 @@ 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->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 =====================================================

View File

@@ -1,7 +1,7 @@
package Dojo::Controller::Home;
use Mojo::Base 'Mojolicious::Controller';
use Mojo::Template;
use Dojo::Support qw{ dmph merge_hash load_module };
use Dojo::Support qw{ log dmph merge_hash load_module get_names};
use Dojo::Conf;
sub tst{
@@ -13,6 +13,10 @@ sub tst{
# $c->stash(apend => ["home/contact"]);
$c->stash( (load_module("home/tst"))[0] );
$c->stash(layout=> "defaultContact");
my $x = [get_names("public/home/cal/img/")];
log("@$x");
$c->stash( ilist => $x);
}
sub home {
@@ -98,9 +102,24 @@ sub radio{
sub admin{
my $c=shift;
if ($c->param("hup")=~/Cambiar/){
if (($c->param("hup") // " " )=~/Cambiar/){
$c->dbv->umod($c->param('link'),$c->param('update'));
};
}
### ¡¡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");
@@ -109,17 +128,15 @@ sub admin{
$c->stash( map{ $_->{nombre} => $_->{contenido}} @{$c->dbv->mod});
}
elsif ( $c->param("section")=~/radio/ ){
$c->stash(
merge_hash( (load_module("home/admin"))[0],
merge_hash( (load_module("home/admin/candySwitch"))[0],
(load_module("home/admin/radio"))[0],
)));
$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")=~/event/ ){
}
elsif ( $c->param("section")=~/mensajes/ ){
$c->stash(merge_hash(
(load_module("home/admin"))[0],
@@ -130,6 +147,14 @@ sub admin{
$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 );
}
}

View File

@@ -1,7 +1,7 @@
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 };
use Dojo::Support qw{ dmph merge_hash load_module get_names};
use File::Basename;
use Text::Markdown qw{ markdown };
@@ -53,12 +53,13 @@ sub radio{
return _read($q);
}
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 = ? ;";
@@ -85,7 +86,36 @@ sub rmsgid{
$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 _read{
my ($q,@bind)=@_;
my (@empty,$arr);

View File

@@ -2,7 +2,7 @@ package Dojo::Support;
use strict;
use warnings;
use Exporter 'import';
our @EXPORT = qw/ dmph merge_hash load_module /;
our @EXPORT = qw/ log dmph merge_hash load_module get_names /;
use Mojo::Base 'Mojolicious';
use File::Basename;
@@ -11,9 +11,12 @@ use Path::Class;
use Encode qw{ decode_utf8 };
use Hash::Merge;
use Dojo::Conf;
use Mojo::Log;
sub log{
my $log = Mojo::Log->new;
$log->debug(shift);
}
sub get_names{
my $dir = shift;
my @file_name;
@@ -28,9 +31,13 @@ sub get_names{
};
sub merge_hash{
my ($v,$w)=@_;
#my ($v,$w)=@_;
my $h={};
my $merger = Hash::Merge->new('LEFT_PRECEDENT');
return $merger->merge( $v, $w );
foreach (@_){
$h= $merger->merge($h,$_);
}
return $h;
}
sub load_module{