This commit is contained in:
mynah
2020-01-22 18:22:31 -06:00
parent f16d579996
commit 174f4b0756
38 changed files with 503 additions and 473 deletions

View File

@@ -5,78 +5,103 @@ use Mojo::Base 'Mojolicious::Controller';
use Dojo::Support qw{ log };
# pagina y mensajes ===========================================================
# Admin =======================================================================
sub admin{
my $c=shift;
my $n=$c->param("dreq")//"";
my $json = {status => "304"};
$json = ($c->dbv->rmsgid ($c->param('id')))[0] if ($n =~m/^mensajes$/);
$json = ($c->dbv->ecourse($c->param('id')))[0] if ($n =~m/^ecourse$/);
$json = ($c->dbv->qcourse($c->param('id')))[0] if ($n =~m/^qcourse$/);
$json = ($c->dbv->qplace ($c->param('id')))[0] if ($n =~m/^qplace$/);
$c->render(json=>$json);
my $c= shift;
$c->redirect_to('/admin/home');
}
sub home{
my $c=shift;
$c->dbv->umod($c->param('link'),$c->param('update'))
if (($c->param("hup") // " " )=~/Cambiar/);
$c->stash(template=>"admin/home");
$c->stash(layout=>"admin");
$c->stash( $c->dbv->mod);
}
sub radio{
my $c=shift;
$c->dbv->umod($c->param('link'),'rmod')
if (($c->param("hup") // " " )=~/Cambiar/);
$c->dbg->ugrulla_pass($c->param('gpass'))
if (($c->param("pup") // " " )=~/Cambiar/);
$c->stash($c->dbv->mod);
$c->stash($c->dbg->grulla_pass);
$c->stash(apend => ["admin/candySwitch"]);
$c->stash(template=>"admin/radio");
$c->stash(layout=>"admin");
}
sub mensajes{
my $c=shift;
$c->stash( h=>$c->dbv->msg_heads);
$c->stash(template=>"admin/mensajes");
$c->stash(layout=>"admin");
}
# Eventos =====================================================================
sub admin_eventos{
sub eventos{
my $c=shift;
if ( (my $t=$c->param('type') // "") =~/[ecp]/){
my $id=$c->param('id');
my $req=$c->param('req');
if ( $req eq "Eliminar"){
$c->dbv->event_del($id) if ($t eq 'e');
$c->dbv->course_del($id) if ($t eq 'c');
$c->dbv->place_del($id) if ($t eq 'p');
$c->mproc->event_del($id) if ($t eq 'e');
$c->mproc->course_del($id) if ($t eq 'c');
$c->mproc->place_del($id) if ($t eq 'p');
}
elsif( $req eq "Aceptar"){
if($t eq 'e'){
my @list=map{$c->param($_)}qw/eplace yini mini dini yend mend dend cost promo pen ecourse eimg een id/;
$c->dbv->event_up(@list) if ($id ==0);
$c->dbv->event_ch(@list) if ($id >0);
$c->mproc->event_up(@list) if ($id ==0);
$c->mproc->event_ch(@list) if ($id >0);
}
if($t eq 'c'){
my @list=map{$c->param($_)}qw/cname csubjects cservices cen id/;
$c->dbv->course_up(@list) if ($id ==0);
$c->dbv->course_ch(@list) if ($id >0);
$c->mproc->course_up(@list) if ($id ==0);
$c->mproc->course_ch(@list) if ($id >0);
}
if($t eq 'p'){
my @list=map{$c->param($_)}qw/pname paddr pobs pto pst pco plat plng pen id/;
$c->dbv->place_up(@list) if ($id ==0);
$c->dbv->place_ch(@list) if ($id >0);
$c->mproc->place_up(@list) if ($id ==0);
$c->mproc->place_ch(@list) if ($id >0);
}
}
$c->redirect_to("/admin/eventos");
}
$c->stash(
courses=>$c->dbv->courses,
places=>$c->dbv->places,
months=>$c->dbv->months,
events=>$c->dbv->events,
img=>$c->dbv->eimgList,
courses=>$c->mproc->courses,
places=>$c->mproc->places,
months=>['enero','febrero','marzo','abril','mayo','junio','julio','agosto','septiembre','octubre','noviembre','diciembre' ],
events=>$c->mproc->events,
img=>$c->mproc->eimgList,
);
$c->stash(template=>"home/admin/event");
$c->stash(layout=>"admin");
}
sub admin_tienda{
my $c=shift;
$c->stash(u=>$c->dbv->user_heads);
$c->stash(s=>$c->dbv->store_heads);
$c->stash(template=>"home/admin/tienda");
$c->stash(template=>"admin/event");
$c->stash(layout=>"admin");
}
# Funciones auxiliares ========================================================
sub admin_json{
sub json{
my $c=shift;
my $id = $c->param('id');
my $req = $c->param('dreq');
my $json = "304";
$json = $c->dbv->astore($id) if $req=~/tienda/;
$json = $c->dbv->course($id) if $req=~/course/;
$json = $c->dbv->place($id) if $req=~/place/;
$json = $c->dbv->eventa($id) if $req=~/event/;
$json = $c->dbv->msg($id) if $req=~/mensaje/;
$json = $c->dbv->rmsgid ($id) if $req =~/^mensajes$/;
$json = $c->mproc->course($id) if $req=~/course/;
$json = $c->mproc->place($id) if $req=~/place/;
$json = $c->mproc->eventa($id) if $req=~/event/;
$json = $c->mproc->ecourse($id) if $req =~/^ecourse$/;
$json = $c->mproc->qcourse($id) if $req =~/^qcourse$/;
$json = $c->mproc->qplace ($id) if $req =~/^qplace$/;
$c->render(json=>$json);
}
1;