diff --git a/lib/Dojo/Controller/Data.pm b/lib/Dojo/Controller/Data.pm index 8687b9a..7f70449 100644 --- a/lib/Dojo/Controller/Data.pm +++ b/lib/Dojo/Controller/Data.pm @@ -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 ===================================================== diff --git a/lib/Dojo/Controller/Home.pm b/lib/Dojo/Controller/Home.pm index 8a3aa28..5f7739d 100644 --- a/lib/Dojo/Controller/Home.pm +++ b/lib/Dojo/Controller/Home.pm @@ -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 ); + } } diff --git a/lib/Dojo/Model/Vuelo.pm b/lib/Dojo/Model/Vuelo.pm index fa9c8f6..81ba805 100644 --- a/lib/Dojo/Model/Vuelo.pm +++ b/lib/Dojo/Model/Vuelo.pm @@ -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); diff --git a/lib/Dojo/Support.pm b/lib/Dojo/Support.pm index 19c9d1b..b06cc46 100644 --- a/lib/Dojo/Support.pm +++ b/lib/Dojo/Support.pm @@ -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{ diff --git a/public/home/admin/candySwitch/jsCSwitch.js b/public/home/admin/candySwitch/jsCSwitch.js index 5e8b95f..2cc085b 100755 --- a/public/home/admin/candySwitch/jsCSwitch.js +++ b/public/home/admin/candySwitch/jsCSwitch.js @@ -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){ diff --git a/public/home/admin/event/add/qCup.q b/public/home/admin/event/add/qCup.q new file mode 100755 index 0000000..3686dc0 --- /dev/null +++ b/public/home/admin/event/add/qCup.q @@ -0,0 +1,12 @@ + insert into curso + (nombre,temario,servicios,estado) + values( + ?, # cname + ?, # csubjects + ?, # cservices + case ? when "on" then 1 else 0 end #cen + ); + + + + diff --git a/public/home/admin/event/add/qEup.q b/public/home/admin/event/add/qEup.q new file mode 100755 index 0000000..d356643 --- /dev/null +++ b/public/home/admin/event/add/qEup.q @@ -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 + ); + diff --git a/public/home/admin/event/add/qPup.q b/public/home/admin/event/add/qPup.q new file mode 100755 index 0000000..3b22545 --- /dev/null +++ b/public/home/admin/event/add/qPup.q @@ -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 + ); + + diff --git a/public/home/admin/event/change/qCdel.q b/public/home/admin/event/change/qCdel.q new file mode 100755 index 0000000..e2cac52 --- /dev/null +++ b/public/home/admin/event/change/qCdel.q @@ -0,0 +1,3 @@ + delete from curso where id = ? ; # cprev + + diff --git a/public/home/admin/event/change/qCup.q b/public/home/admin/event/change/qCup.q new file mode 100755 index 0000000..a0d3c39 --- /dev/null +++ b/public/home/admin/event/change/qCup.q @@ -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 diff --git a/public/home/admin/event/change/qEdel.q b/public/home/admin/event/change/qEdel.q new file mode 100755 index 0000000..0b2ef59 --- /dev/null +++ b/public/home/admin/event/change/qEdel.q @@ -0,0 +1,2 @@ + delete from evento where id = ? ; # eprev + diff --git a/public/home/admin/event/change/qEup.q b/public/home/admin/event/change/qEup.q new file mode 100755 index 0000000..fd5674b --- /dev/null +++ b/public/home/admin/event/change/qEup.q @@ -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 ; + diff --git a/public/home/admin/event/change/qPdel.q b/public/home/admin/event/change/qPdel.q new file mode 100755 index 0000000..80f79a3 --- /dev/null +++ b/public/home/admin/event/change/qPdel.q @@ -0,0 +1,4 @@ + delete from lugar where id = ?; # pprev ; + + + diff --git a/public/home/admin/event/change/qPup.q b/public/home/admin/event/change/qPup.q new file mode 100755 index 0000000..a09f964 --- /dev/null +++ b/public/home/admin/event/change/qPup.q @@ -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 ; + diff --git a/public/home/admin/event/jsEvent.js b/public/home/admin/event/jsEvent.js index 951c352..5ac4e5b 100755 --- a/public/home/admin/event/jsEvent.js +++ b/public/home/admin/event/jsEvent.js @@ -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); diff --git a/public/home/admin/event/json/qCourse.q b/public/home/admin/event/json/qCourse.q index 1f12c85..8e37e15 100755 --- a/public/home/admin/event/json/qCourse.q +++ b/public/home/admin/event/json/qCourse.q @@ -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 ; diff --git a/public/home/admin/event/json/qEvent.q b/public/home/admin/event/json/qEvent.q index 8b9dab9..ce4f278 100755 --- a/public/home/admin/event/json/qEvent.q +++ b/public/home/admin/event/json/qEvent.q @@ -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 ; diff --git a/public/home/admin/event/json/qPlace.q b/public/home/admin/event/json/qPlace.q index 8e1c039..7ee697a 100755 --- a/public/home/admin/event/json/qPlace.q +++ b/public/home/admin/event/json/qPlace.q @@ -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 ; diff --git a/public/home/admin/event/qEprev.q b/public/home/admin/event/qEprev.q index e743b31..b266827 100755 --- a/public/home/admin/event/qEprev.q +++ b/public/home/admin/event/qEprev.q @@ -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 diff --git a/public/home/admin/event/update/add/qCup.q b/public/home/admin/event/update/add/qCup.q deleted file mode 100755 index b0e608f..0000000 --- a/public/home/admin/event/update/add/qCup.q +++ /dev/null @@ -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); - - - - diff --git a/public/home/admin/event/update/add/qEup.q b/public/home/admin/event/update/add/qEup.q deleted file mode 100755 index 87014e3..0000000 --- a/public/home/admin/event/update/add/qEup.q +++ /dev/null @@ -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); - - - diff --git a/public/home/admin/event/update/add/qPup.q b/public/home/admin/event/update/add/qPup.q deleted file mode 100755 index 5f7dea1..0000000 --- a/public/home/admin/event/update/add/qPup.q +++ /dev/null @@ -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); - - diff --git a/public/home/admin/event/update/change/qCdel.q b/public/home/admin/event/update/change/qCdel.q deleted file mode 100755 index 35ec3f6..0000000 --- a/public/home/admin/event/update/change/qCdel.q +++ /dev/null @@ -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 ; - - diff --git a/public/home/admin/event/update/change/qCup.q b/public/home/admin/event/update/change/qCup.q deleted file mode 100755 index e8d0577..0000000 --- a/public/home/admin/event/update/change/qCup.q +++ /dev/null @@ -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 ; - - diff --git a/public/home/admin/event/update/change/qEdel.q b/public/home/admin/event/update/change/qEdel.q deleted file mode 100755 index 1f419d6..0000000 --- a/public/home/admin/event/update/change/qEdel.q +++ /dev/null @@ -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 ; - diff --git a/public/home/admin/event/update/change/qEup.q b/public/home/admin/event/update/change/qEup.q deleted file mode 100755 index b4fce88..0000000 --- a/public/home/admin/event/update/change/qEup.q +++ /dev/null @@ -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 ; - diff --git a/public/home/admin/event/update/change/qPdel.q b/public/home/admin/event/update/change/qPdel.q deleted file mode 100755 index 747a10e..0000000 --- a/public/home/admin/event/update/change/qPdel.q +++ /dev/null @@ -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 ; - - - diff --git a/public/home/admin/event/update/change/qPup.q b/public/home/admin/event/update/change/qPup.q deleted file mode 100755 index 5424d34..0000000 --- a/public/home/admin/event/update/change/qPup.q +++ /dev/null @@ -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 ; - diff --git a/public/home/admin/event/htmlEvent.html b/templates/home/admin/event.html.ep similarity index 78% rename from public/home/admin/event/htmlEvent.html rename to templates/home/admin/event.html.ep index bd6594b..cfbef13 100755 --- a/public/home/admin/event/htmlEvent.html +++ b/templates/home/admin/event.html.ep @@ -16,30 +16,27 @@