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{

View File

@@ -1,7 +1,7 @@
d3.select("#clink").on("click",function(){
var newWindow = window.open('candy','_blank');
});
// revisa que llama dos veces a la pagina
var ciface =" #exec candy_loader/candyInterface.pl&v=";
d3.json(ciface+"isOn" ,function(d){
if(d != undefined){

View File

@@ -0,0 +1,12 @@
insert into curso
(nombre,temario,servicios,estado)
values(
?, # cname
?, # csubjects
?, # cservices
case ? when "on" then 1 else 0 end #cen
);

View File

@@ -0,0 +1,14 @@
insert into evento
(lugar_id, fecha_inicio, fecha_fin,precio,curso_id,imagen_chica,estado,promocion,promo_estado)
values(
?, # eplace
" ?-?-? ", # yini - mini - dini
" ?-?-? ", # yend - mend - dend
?, # cost ,
?, # ecourse ,
?, # eimg ,
case ? when "on" then 1 else 0 end, # een
?, # promo ,
case ? when "on" then 1 else 0 end # pen
);

View File

@@ -0,0 +1,15 @@
insert into lugar
(nombre,direccion,observacion,municipio,federativa,pais,lat,lng,estado)
values(
?, # pname
?, # paddr
?, # pobs
?, # pto
?, # pst
?, # pco
?, # lat
?, # lng
case ? when "on" then 1 else 0 end #pen
);

View File

@@ -0,0 +1,3 @@
delete from curso where id = ? ; # cprev

View File

@@ -0,0 +1,6 @@
update curso set
nombre = ?, # cname
temario = ?, # csubjects
servicios = ?, # cservices
estado = case ? when "on" then 1 else 0 end # cen
where id = ? ; # cprev

View File

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

View File

@@ -0,0 +1,12 @@
update evento set
lugar_id = ?, # eplace ,
fecha_inicio='?-?-?', # yini - mini - dini ',
fecha_fin='?-?-?', # 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 ;

View File

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

View File

@@ -0,0 +1,12 @@
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 ;

View File

@@ -1,7 +1,7 @@
d3.select("li#evento").style("background-color","#cedeef");
var li = d3.select("article.label","ul").selectAll("li");
var img_path = " #path ../../cal/img/";
var json_path = " #data admin/event/json/";
var img_path = "/home/cal/img/";
var json_path = "/admin/json/";
/* menu hide and show edit window*/
li.on("click",function(){
li.style("background-color","#e6eeff");
@@ -22,7 +22,7 @@ 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+"qEvent.q&ecourse="+eprev_id ,function(d){
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);
@@ -43,7 +43,7 @@ d3.select("select#eprev").on("change",function(){
/*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.q&course="+cprev_id ,function(d){
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);
@@ -53,7 +53,7 @@ d3.select("select#cprev").on("change",function(){
/*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.q&course="+pprev_id ,function(d){
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);

View File

@@ -1,17 +1,9 @@
/* c#host localhost*/
/* c#database #dbdata */
/* c#user #dbdata_user */
/* c#password #dbdata_pass */
select
id as "cid",
nombre as "cname",
temario as "csubjects",
servicios as "cservices"
from curso
where id= #course ;
where id= ? ; #course ;

View File

@@ -1,11 +1,3 @@
/* c#host localhost*/
/* c#database #dbdata */
/* c#user #dbdata_user */
/* c#password #dbdata_pass */
select
"event" as "tag",
id,
@@ -24,6 +16,6 @@ select
estado as "een"
from evento
where id= #ecourse ;
where id= ? ; # ecourse ;

View File

@@ -1,10 +1,3 @@
/* c#host localhost*/
/* c#database #dbdata */
/* c#user #dbdata_user */
/* c#password #dbdata_pass */
select
id as "pid",
nombre as "pname",
@@ -17,6 +10,6 @@ select
lng as "plng",
estado as "pen"
from lugar
where id= #course ;
where id= ? ; # course ;

View File

@@ -1,13 +1,4 @@
/* c#host localhost*/
/* c#database #dbdata */
/* c#user #dbdata_user */
/* c#password #dbdata_pass */
select
"eprev" as "tag",
concat(day(e.fecha_inicio)," de ",m.nombre," ",l.nombre) as "name",
e.id as id
from evento as e

View File

@@ -1,20 +0,0 @@
/* c#host localhost*/
/* c#database #dbdata */
/* c#user #dbdata_w */
/* c#password #dbdata_wp */
/* c#write write*/
insert into curso
(nombre,temario,servicios,estado)
values(
q#cname ,
q#csubjects ,
q#cservices ,
case q#cen when "on" then 1 else 0 end);

View File

@@ -1,24 +0,0 @@
/* c#host localhost*/
/* c#database #dbdata */
/* c#user #dbdata_w */
/* c#password #dbdata_wp */
/* c#write write*/
insert into evento
(lugar_id, fecha_inicio, fecha_fin,precio,curso_id,imagen_chica,estado,promocion,promo_estado)
values(
q#eplace ,
" #yini - #mini - #dini ",
" #yend - #mend - #dend ",
q#cost ,
q#ecourse ,
q#eimg ,
case q#een when "on" then 1 else 0 end,
q#promo ,
case q#pen when "on" then 1 else 0 end);

View File

@@ -1,23 +0,0 @@
/* c#host localhost*/
/* c#database #dbdata */
/* c#user #dbdata_w */
/* c#password #dbdata_wp */
/* c#write write*/
insert into lugar
(nombre,direccion,observacion,municipio,federativa,pais,lat,lng,estado)
values(
q#pname ,
q#paddr ,
q#pobs ,
q#pto ,
q#pst ,
q#pco ,
q#lat ,
q#lng ,
case q#pen when "on" then 1 else 0 end);

View File

@@ -1,12 +0,0 @@
/* c#host localhost*/
/* c#database #dbdata */
/* c#user #dbdata_w */
/* c#password #dbdata_wp */
/* c#write write*/
delete from curso
where id = q#cprev ;

View File

@@ -1,18 +0,0 @@
/* c#host localhost*/
/* c#database #dbdata */
/* c#user #dbdata_w */
/* c#password #dbdata_wp */
/* c#write write*/
update curso set
nombre = q#cname ,
temario= q#csubjects ,
servicios= q#cservices ,
estado = case q#cen when "on" then 1 else 0 end
where id = q#cprev ;

View File

@@ -1,12 +0,0 @@
/* c#host localhost*/
/* c#database #dbdata */
/* c#user #dbdata_w */
/* c#password #dbdata_wp */
/* c#write write*/
delete from evento
where id = q#eprev ;

View File

@@ -1,22 +0,0 @@
/* c#host localhost*/
/* c#database #dbdata */
/* c#user #dbdata_w */
/* c#password #dbdata_wp */
/* c#write write*/
update evento set
lugar_id = q#eplace ,
fecha_inicio=' #yini - #mini - #dini ',
fecha_fin= ' #yend - #mend - #dend ',
precio= q#cost ,
promocion= q#promo ,
promo_estado = case q#pen when "on" then 1 else 0 end,
curso_id= q#ecourse ,
imagen_chica= q#eimg ,
estado = case q#een when "on" then 1 else 0 end
where id = q#eprev ;

View File

@@ -1,13 +0,0 @@
/* c#host localhost*/
/* c#database #dbdata */
/* c#user #dbdata_w */
/* c#password #dbdata_wp */
/* c#write write*/
delete from lugar
where id = q#pprev ;

View File

@@ -1,20 +0,0 @@
/* c#host localhost*/
/* c#database #dbdata */
/* c#user #dbdata_w */
/* c#password #dbdata_wp */
/* c#write write*/
update lugar set
nombre= q#pname ,
direccion= q#paddr ,
observacion= q#pobs ,
municipio= q#pto ,
federativa= q#pst ,
pais= q#pco ,
lat= q#plat ,
lng= q#plng ,
estado = case q#pen when "on" then 1 else 0 end
where id = q#pprev ;

View File

@@ -16,30 +16,27 @@
<div class="ehide" id="event"> <form action=" #nav admine" method="POST">
<div class="flex field">
<label>Curso</label>
<select id="ecourse" name="ecourse"> <!-- a#dropvar -->
<!-- ##ecourse --> <!-- r##hide -->
<!-- c#ecourse
<option value=" #id "> #name </option>
--> <!-- rr#hide -->
<select id="ecourse" name="ecourse">
<% map{ %>
<option value="<%= $_->{'id'} %>"><%= $_->{'name'} %></option>
<% } %><% (@{stash('ecourse')}) %><% if defined(stash('ecourse')); %>
</select>
</div>
<div class="flex field">
<label>Lugar</label> <!-- dropdown -->
<select id="eplace" name="eplace"> <!-- a#dropvar -->
<!-- ##eplace --> <!-- r##hide -->
<!-- c#eplace
<option value=" #id "> #name </option>
--> <!-- rr#hide -->
<% map{ %>
<option value="<%= $_->{'id'} %>"><%= $_->{'name'} %></option>
<% } %><% (@{stash('eplace')}) %><% if defined(stash('eplace')); %>
</select>
</div>
<div class="flex field">
<label>Fecha inicio</label> <!-- dropdown -->
<input id="dini" type="number" min="1" max="31" name="dini" value="1"/> <!-- a#dropvar -->
<select id="mini" name="mini"> <!-- a#dropvar -->
<!-- ##emini --> <!-- r##hide -->
<!-- c#emini
<option value=" #id "> #name </option>
--> <!-- rr#hide -->
<% map{ %>
<option value="<%= $_->{'id'} %>"><%= $_->{'name'} %></option>
<% } %><% (@{stash('emini')}) %><% if defined(stash('emini')); %>
</select>
<input id="yini" type="number" min="2017" max="2050" name="yini" value="2017"/> <!-- a#dropvar -->
</div>
@@ -47,6 +44,9 @@
<label>Fecha fin</label> <!-- dropdown -->
<input id="dend" type="number" min="1" max="31" name="dend" value="1"/> <!-- a#dropvar -->
<select id="mend" name="mend"> <!-- a#dropvar -->
<% map{ %>
<option value="<%= $_->{'id'} %>"><%= $_->{'name'} %></option>
<% } %><% (@{stash('emini')}) %><% if defined(stash('emini')); %>
<!-- ##emini -->
</select>
<input id="yend" type="number" min="2017" max="2050" name="yend" value="2017"/> <!-- a#dropvar -->
@@ -62,10 +62,9 @@
<label>Imagen</label> <!-- dropdown -->
<select id="eimg" name="eimg"> <!-- a#dropvar -->
<option value="0" selected> -- Elegir imagen -- </option>
<!-- ##ilist --> <!-- r##hide -->
<!-- c#ilist
<option value=" #name "> #name </option>
--> <!-- rr#hide -->
<% map{ %>
<option value="<%= $_ %>"><%= $_ %></option>
<% } %><% (@{stash('ilist')}) %><% if defined(stash('ilist')); %>
</select>
<div id=esimg></div>
</div>
@@ -73,10 +72,9 @@
<label>Existente</label>
<select id="eprev" name="eprev"> <!-- a#dropvar -->
<option value="0">-- Nuevo --</option>
<!-- ##eprev --> <!-- r##hide -->
<!-- c#eprev
<option value=" #id "> #name </option>
--> <!-- rr#hide -->
<% map{ %>
<option value="<%= $_->{'id'} %>"><%= $_->{'name'} %></option>
<% } %><% (@{stash('eprev')}) %><% if defined(stash('eprev')); %>
</select>
</div>
<div class="flex field update">
@@ -88,7 +86,7 @@
</div>
</form> </div>
<!-- Curso ====================================================== -->
<div class="ehide" id="course"><form id="fcourse" action=" #nav admine"
<div class="ehide" id="course"><form id="fcourse" action="/admin/event"
method="POST">
<div class="flex field">
<label>Nombre</label>
@@ -103,10 +101,9 @@
<label>Existente</label>
<select id="cprev" name="cprev"> <!-- a#dropvar -->
<option value="0">-- Nuevo --</option>
<!-- ##cprev --> <!-- r##hide -->
<!-- c#cprev
<option value=" #id "> #name </option>
--> <!-- rr#hide -->
<% map{ %>
<option value="<%= $_->{'id'} %>"><%= $_->{'name'} %></option>
<% } %><% (@{stash('ecourse')}) %><% if defined(stash('ecourse')); %>
</select>
</div> <div class="flex field update">
<input type="hidden" name="update" value="1"> <!-- a#dropvar -->
@@ -116,8 +113,8 @@
<input type="checkbox" checked="checked" id="cen" name="cen" > <!-- a#dropvar -->
</div>
</form> </div>
<!-- Lugar -->
<div class="ehide" id="place"><form action=" #nav admine" method="POST">
<!-- Lugar ====================================================== -->
<div class="ehide" id="place"><form action="/admin/event" method="POST">
<div class="flex field">
<label>Nombre</label><input type="text" id= "pname" name="pname"> <!-- a#dropvar -->
</div> <div class="flex field">
@@ -138,10 +135,9 @@
<label>Existente</label>
<select id="pprev" name="pprev"> <!-- a#dropvar -->
<option value="0">-- Nuevo --</option>
<!-- ##pprev --> <!-- r##hide -->
<!-- c#pprev
<option value=" #id "> #name </option>
--> <!-- rr#hide -->
<% map{ %>
<option value="<%= $_->{'id'} %>"><%= $_->{'name'} %></option>
<% } %><% (@{stash('eplace')}) %><% if defined(stash('eplace')); %>
</select>
</div> <div class="flex field update">
<input type="hidden" name="update" value="1"> <!-- a#dropvar -->

View File

@@ -1,9 +1,7 @@
<section class="flex messages">
<article class="select">
<select id="sentry" class="entry" size=10>
% foreach (@{stash('h')}){
<option value="<%= $_->{'mid'} %>" class=entry"> <%= $_->{'entry'} %></option>
% }
<% map{ %> <option value="<%= $_->{'mid'} %>" class="entry" ><%= $_->{'entry'} %> </option> <% } %><% (@{stash('h')}); %>
</select>
</article>
<article class="view">

View File

@@ -1,4 +1,10 @@
<p> <%= url_for("$controller/$action/img") %> </p>
<p>
%= url_for->path('/meself')
</p>
<p>
% foreach (@{$ilist}) {
<%= $_ %>
% }
</p>